/* ==============================================
   TREE MENU
   Composant dossier arborescent animé.
=============================================== */

.tree-menu {
    font-size: clamp(18px, 2.2vw, 26px);
    -webkit-user-select: none;
    user-select: none;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Root (dossier parent) ───────────────── */

.root-item {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    color: var(--text-dark);
    padding: 8px 0;
    width: fit-content;
    position: relative;
    z-index: 2;
}

/* Connecteur vertical entre dossier et enfants */
.root-item::after {
    content: "";
    position: absolute;
    left: var(--tree-connector-x);
    top: calc(100% - 1px);
    width: 2px;
    height: var(--tree-connector-drop);
    background-color: var(--primary-blue);
    transform-origin: top;
    transform: scaleY(0);
    transition: transform var(--anim-speed) var(--ease-snap);
}

.tree-menu.is-open .root-item::after {
    transform: scaleY(1);
}

/* ── Icône dossier ───────────────────────── */

.icon-wrap {
    width: 32px;
    height: 32px;
    color: var(--primary-blue);
    transform-origin: center;
    transition: transform 0.28s var(--ease-snap);
}

.folder-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.folder-back {
    fill: var(--bg-color);
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.28s var(--ease-snap), fill 0.22s linear;
}

.folder-flap {
    fill: var(--bg-color);
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transform-origin: 2px 20px;
    transition: transform 0.34s var(--ease-bounce), fill 0.22s linear, stroke 0.22s linear;
}

/* États hover */
.root-item:hover .folder-flap {
    transform: translateY(0.8px) skewX(-12deg) scaleY(0.92);
}

.root-item:hover .icon-wrap {
    transform: translateY(-1.5px) scale(1.05);
}

/* États ouvert */
.tree-menu.is-open .folder-back {
    fill: var(--primary-blue);
    transform: translateY(1px) scale(1.02);
}

.tree-menu.is-open .folder-flap {
    transform: translateY(1.2px) skewX(-24deg) scaleY(0.78);
    fill: var(--light-blue);
    stroke: var(--light-blue);
}

.tree-menu.is-open .icon-wrap {
    transform: translateY(-1.5px) scale(1.085);
}

/* ── Enfants ─────────────────────────────── */

.children-wrapper {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows var(--anim-speed) var(--ease-snap);
    overflow: hidden;
}

.tree-menu.is-open .children-wrapper {
    grid-template-rows: 1fr;
}

.children-inner {
    overflow: hidden;
    position: relative;
    margin-left: var(--tree-connector-x);
    margin-top: calc(var(--tree-connector-drop) - 1px);
}

.line-vertical {
    position: absolute;
    left: 0;
    top: 0;
    bottom: var(--tree-line-bottom, 28px);
    width: 2px;
    background-color: var(--primary-blue);
    transform-origin: top;
    transform: scaleY(0);
    transition: transform var(--anim-speed) var(--ease-snap);
}

.tree-menu.is-open .line-vertical {
    transform: scaleY(1);
}

.child-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-height: 52px;
    padding: 8px 0 8px 24px;
    gap: 2px;
    cursor: pointer;
    color: var(--text-dark);
    text-decoration: none;
    transition: color 0.2s;
}

.child-item:hover {
    color: var(--primary-blue);
}

.child-item.is-disabled {
    cursor: default;
    color: var(--text-dark);
}

.child-item.is-disabled:hover {
    color: var(--text-dark);
}

.child-item.is-disabled .child-text,
.child-item.is-disabled .child-lang,
.child-item.is-disabled .child-desc {
    color: var(--text-muted);
}

.line-horizontal {
    position: absolute;
    left: 0;
    top: 24px;
    width: 14px;
    height: 2px;
    background-color: var(--primary-blue);
    transform: translateY(-50%) scaleX(0);
    transform-origin: left;
    transition: transform 0.2s var(--ease-snap);
}

.child-main {
    display: flex;
    align-items: baseline;
    min-height: 32px;
}

.child-text {
    opacity: 0;
    transform: translateX(-18px);
    transition: opacity 0.2s ease, transform 0.28s var(--ease-bounce);
}

.child-lang {
    margin-left: 8px;
    font-size: 0.55em;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    opacity: 0;
    transform: translateX(-18px);
    transition: opacity 0.2s ease, transform 0.28s var(--ease-bounce);
}

.child-desc {
    font-size: 0.46em;
    color: var(--text-muted);
    line-height: 1.35;
    max-width: min(32ch, 100%);
    opacity: 0;
    transform: translateX(-18px);
    transition: opacity 0.2s ease, transform 0.28s var(--ease-bounce);
}

.tree-menu.is-open .line-horizontal {
    transform: translateY(-50%) scaleX(1);
}

.tree-menu.is-open .child-text,
.tree-menu.is-open .child-lang,
.tree-menu.is-open .child-desc {
    opacity: 1;
    transform: translateX(0);
}

.tree-menu.is-open .child-item .line-horizontal,
.tree-menu.is-open .child-item .child-text,
.tree-menu.is-open .child-item .child-lang,
.tree-menu.is-open .child-item .child-desc {
    transition-delay: var(--item-delay, 0s);
}

/* Décalage en cascade à l'ouverture */

