/* ==========================================================================
   FOOTER — Pied de page : groupes sémantiques + responsive
   --------------------------------------------------------------------------
   Structure :
     1. .footer-tech      — crédits technologiques
     2. .footer-meta      — .diagram-info + hamburger (.footer-legal)
     3. .footer-copyright — mention de copyright
   --------------------------------------------------------------------------
   Liens légaux : menu déroulant (hamburger) sur tous les breakpoints.
   ========================================================================== */

/* ── Base (tous viewports) ───────────────────────────────────────────────── */
.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: 0 var(--sp-6);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
    min-height: var(--footer-height);
    flex-wrap: nowrap;
}

.footer-tech {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-shrink: 0;
    white-space: nowrap;
}

.footer-tech > i {
    color: var(--accent);
    font-size: 0.8em;
    flex-shrink: 0;
}

/* Stats diagramme + hamburger sur une même ligne */
.footer-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    flex: 1;
    min-width: 0;
}

.diagram-info {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-tertiary);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.footer-legal {
    position: relative;
    flex-shrink: 0;
    z-index: 20;
}

.footer-legal-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-tertiary);
    font-size: 0.85rem;
    line-height: 1;
    transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}

.footer-legal-toggle:hover,
.footer-legal[data-open="true"] .footer-legal-toggle {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-tertiary);
}

.footer-legal-links {
    position: absolute;
    right: 0;
    bottom: calc(100% + var(--sp-1));
    min-width: 220px;
    max-width: min(92vw, 280px);
    max-height: min(50vh, 320px);
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--sp-2);
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-1);
    z-index: 30;
}

.footer-legal[data-open="true"] .footer-legal-links {
    display: flex;
}

.footer-legal-links .footer-sep {
    display: none;
}

.footer-copyright {
    flex-shrink: 0;
    white-space: nowrap;
    opacity: 0.7;
}

.footer-sep {
    color: var(--border-default);
    user-select: none;
    pointer-events: none;
    flex-shrink: 0;
}

.footer-tech a,
.footer-legal a {
    color: var(--text-tertiary);
    text-decoration: none;
    transition: color var(--t-fast), opacity var(--t-fast);
}

.footer-tech a:hover,
.footer-legal a:hover {
    color: var(--accent);
    text-decoration: none;
}

/* ── Tablette paysage ≤ 1280px ───────────────────────────────────────────── */
@media (max-width: 1280px) {
    .app-footer {
        padding: 0 var(--sp-4);
        gap: var(--sp-3);
    }
}

/* ── Tablette portrait ≤ 1024px ──────────────────────────────────────────── */
@media (max-width: 1024px) {
    .app-footer {
        flex-wrap: wrap;
        padding: var(--sp-2) var(--sp-4);
        gap: var(--sp-1) var(--sp-3);
        min-height: auto;
    }

    .footer-tech {
        order: 1;
        flex: 1 1 auto;
    }

    .footer-meta {
        order: 2;
        flex: 1 1 auto;
        justify-content: flex-end;
    }

    .footer-copyright {
        order: 3;
        flex: 0 1 auto;
    }
}

/* ── Tablette étroite / grand mobile ≤ 768px ─────────────────────────────── */
@media (max-width: 768px) {
    .app-footer {
        padding: var(--sp-2) var(--sp-3);
        font-size: 0.7rem;
    }

    .footer-tech {
        display: none;
    }

    .footer-meta {
        order: 1;
        flex: 1 1 auto;
        justify-content: flex-start;
    }

    .diagram-info {
        text-align: left;
    }

    .footer-copyright {
        order: 2;
        font-size: 0.65rem;
    }
}

/* ── Mobile ≤ 640px ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .app-footer {
        flex-direction: column;
        align-items: center;
        flex-shrink: 0;
        padding: var(--sp-2);
        padding-bottom: max(var(--sp-3), env(safe-area-inset-bottom));
        gap: var(--sp-2);
        min-height: auto;
    }

    .footer-meta {
        width: 100%;
        flex: 0 0 auto;
        justify-content: center;
    }

    .diagram-info {
        flex: 0 1 auto;
        max-width: calc(100% - 2.5rem);
    }

    .footer-legal-links {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }

    .footer-legal a {
        font-size: 0.65rem;
        padding: 2px 0;
    }

    .footer-copyright {
        font-size: 0.6rem;
        width: 100%;
        text-align: center;
    }
}

/* ── Petit mobile ≤ 480px ────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .app-footer {
        padding-left: max(var(--sp-2), env(safe-area-inset-left));
        padding-right: max(var(--sp-2), env(safe-area-inset-right));
    }

    .footer-legal a {
        font-size: 0.62rem;
    }

    .footer-sep {
        font-size: 0.6rem;
    }

    .footer-copyright {
        font-size: 0.58rem;
    }
}

/* ── Paysage court (≤ 600px de hauteur) ───────────────────────────────────── */
@media (max-height: 600px) and (orientation: landscape) {
    .app-footer {
        min-height: auto;
        padding-top: var(--sp-1);
        padding-bottom: max(var(--sp-2), env(safe-area-inset-bottom));
        gap: var(--sp-1);
    }

    .footer-legal-toggle {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 0.8rem;
    }
}
