/*
 * TUSSOR — Pages légales (CGV & Politique de confidentialité)
 * Mise en page lecture longue : sommaire collant, typographie optimisée,
 * ancres par section, retour en haut.
 */

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

.legal-page {
    color: var(--t-color-text);
    font-family: var(--t-font-base);
    padding: var(--t-space-7) 0 var(--t-space-12);
}

/* ============================================================
 * En-tête de page
 * ============================================================ */

.legal-hero {
    text-align: center;
    max-width: 760px;
    margin: 0 auto var(--t-space-10);
    padding: 0 var(--t-space-5);
}

.legal-hero__eyebrow {
    display: inline-block;
    font-size: var(--t-text-xs);
    letter-spacing: var(--t-tracking-wider);
    text-transform: uppercase;
    color: var(--t-color-red);
    font-weight: var(--t-weight-semibold);
    margin-bottom: var(--t-space-4);
}

.legal-hero__title {
    font-size: var(--t-text-8xl);
    font-weight: var(--t-weight-medium);
    letter-spacing: var(--t-tracking-wide);
    color: var(--t-color-black);
    margin: 0 0 var(--t-space-5);
    line-height: var(--t-leading-tight);
}

.legal-hero__lede {
    font-size: var(--t-text-2xl);
    font-weight: var(--t-weight-extralight);
    line-height: var(--t-leading-relaxed);
    color: var(--t-gray-400);
    margin: 0 auto var(--t-space-6);
    max-width: 640px;
}

.legal-hero__meta {
    display: inline-flex;
    align-items: center;
    gap: var(--t-space-3);
    font-size: var(--t-text-xs);
    letter-spacing: var(--t-tracking-wide);
    text-transform: uppercase;
    color: var(--t-gray-300);
    padding: var(--t-space-2) var(--t-space-4);
    border: var(--t-border-width-1) solid var(--t-color-border);
}

.legal-hero__meta::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--t-color-red);
    border-radius: var(--t-radius-full);
}

/* ============================================================
 * Layout : sommaire + contenu
 * ============================================================ */

.legal-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: var(--t-space-10);
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 var(--t-space-5);
}

/* ============================================================
 * Sommaire
 * ============================================================ */

.legal-toc {
    position: sticky;
    top: var(--t-space-7);
    align-self: start;
    max-height: calc(100vh - var(--t-space-9));
    overflow-y: auto;
    padding-right: var(--t-space-4);
    scrollbar-width: thin;
}

/* Sur desktop on cache le résumé (mobile-only) */
.legal-toc > summary {
    display: none;
}

.legal-toc__title {
    font-size: var(--t-text-xs);
    text-transform: uppercase;
    letter-spacing: var(--t-tracking-wider);
    color: var(--t-gray-300);
    font-weight: var(--t-weight-semibold);
    margin: 0 0 var(--t-space-5);
    padding-bottom: var(--t-space-3);
    border-bottom: var(--t-border-width-1) solid var(--t-color-border);
}

.legal-toc__list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: toc;
}

.legal-toc__item {
    counter-increment: toc;
    margin-bottom: var(--t-space-1);
}

.legal-toc__link {
    display: flex;
    align-items: baseline;
    gap: var(--t-space-3);
    padding: var(--t-space-2) 0;
    color: var(--t-gray-400);
    font-size: var(--t-text-base);
    line-height: var(--t-leading-snug);
    text-decoration: none;
    transition: color var(--t-duration-fast) var(--t-ease-default);
    border-left: var(--t-border-width-2) solid transparent;
    padding-left: var(--t-space-3);
    margin-left: calc(var(--t-border-width-2) * -1);
}

.legal-toc__link::before {
    content: counter(toc, decimal-leading-zero);
    font-size: var(--t-text-xs);
    font-weight: var(--t-weight-semibold);
    color: var(--t-gray-250);
    letter-spacing: var(--t-tracking-wide);
    flex-shrink: 0;
    min-width: 22px;
    transition: color var(--t-duration-fast) var(--t-ease-default);
}

.legal-toc__link:hover,
.legal-toc__link:focus-visible {
    color: var(--t-color-black);
    outline: none;
}

.legal-toc__link:hover::before,
.legal-toc__link:focus-visible::before {
    color: var(--t-color-red);
}

.legal-toc__link:focus-visible {
    border-left-color: var(--t-color-red);
}

.legal-toc__link.is-active {
    color: var(--t-color-black);
    border-left-color: var(--t-color-red);
    font-weight: var(--t-weight-medium);
}

.legal-toc__link.is-active::before {
    color: var(--t-color-red);
}

/* ============================================================
 * Contenu principal
 * ============================================================ */

.legal-content {
    max-width: 70ch;
    font-size: var(--t-text-lg);
    line-height: var(--t-leading-relaxed);
    color: var(--t-gray-600);
}

.legal-content > p:first-of-type {
    font-size: var(--t-text-xl);
    font-weight: var(--t-weight-extralight);
    color: var(--t-gray-400);
    line-height: var(--t-leading-relaxed);
    padding-bottom: var(--t-space-7);
    margin-bottom: var(--t-space-9);
    border-bottom: var(--t-border-width-1) solid var(--t-color-border);
}

.legal-section {
    padding-top: var(--t-space-7);
    margin-bottom: var(--t-space-9);
    scroll-margin-top: var(--t-space-7);
}

.legal-section + .legal-section {
    border-top: var(--t-border-width-1) solid var(--t-color-border);
}

.legal-section__number {
    display: inline-block;
    font-size: var(--t-text-xs);
    font-weight: var(--t-weight-semibold);
    letter-spacing: var(--t-tracking-wider);
    text-transform: uppercase;
    color: var(--t-color-red);
    margin-bottom: var(--t-space-3);
}

.legal-section__title {
    font-size: var(--t-text-5xl);
    font-weight: var(--t-weight-medium);
    letter-spacing: var(--t-tracking-wide);
    color: var(--t-color-black);
    line-height: var(--t-leading-tight);
    margin: 0 0 var(--t-space-6);
}

.legal-section__subtitle {
    font-size: var(--t-text-3xl);
    font-weight: var(--t-weight-semibold);
    color: var(--t-color-black);
    letter-spacing: var(--t-tracking-normal);
    margin: var(--t-space-7) 0 var(--t-space-4);
}

.legal-section p {
    margin: 0 0 var(--t-space-5);
    text-align: justify;
    hyphens: auto;
}

.legal-section ul,
.legal-section ol {
    margin: 0 0 var(--t-space-5);
    padding-left: var(--t-space-6);
}

.legal-section li {
    margin-bottom: var(--t-space-3);
    line-height: var(--t-leading-relaxed);
}

.legal-section li::marker {
    color: var(--t-color-red);
}

.legal-section a {
    color: var(--t-color-black);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    transition: color var(--t-duration-fast) var(--t-ease-default);
}

.legal-section a:hover,
.legal-section a:focus-visible {
    color: var(--t-color-red);
}

.legal-section strong {
    font-weight: var(--t-weight-semibold);
    color: var(--t-color-black);
}

/* Bloc citation / texte de loi */
.legal-quote {
    border-left: var(--t-border-width-2) solid var(--t-color-red);
    padding: var(--t-space-3) var(--t-space-5);
    margin: var(--t-space-5) 0;
    background: var(--t-color-bg-muted);
    font-size: var(--t-text-base);
    color: var(--t-gray-400);
}

/* ============================================================
 * Carte de contact en pied de page
 * ============================================================ */

.legal-contact {
    max-width: 70ch;
    margin: var(--t-space-10) 0 0;
    padding: var(--t-space-7);
    border: var(--t-border-width-1) solid var(--t-color-border);
    background: var(--t-color-bg-muted);
}

.legal-contact__title {
    font-size: var(--t-text-xs);
    text-transform: uppercase;
    letter-spacing: var(--t-tracking-wider);
    color: var(--t-color-red);
    font-weight: var(--t-weight-semibold);
    margin: 0 0 var(--t-space-3);
}

.legal-contact__heading {
    font-size: var(--t-text-4xl);
    font-weight: var(--t-weight-medium);
    color: var(--t-color-black);
    letter-spacing: var(--t-tracking-wide);
    margin: 0 0 var(--t-space-5);
}

.legal-contact__list {
    display: grid;
    gap: var(--t-space-4);
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.legal-contact__item {
    display: flex;
    flex-direction: column;
    gap: var(--t-space-1);
}

.legal-contact__label {
    font-size: var(--t-text-xs);
    text-transform: uppercase;
    letter-spacing: var(--t-tracking-wide);
    color: var(--t-gray-300);
    font-weight: var(--t-weight-semibold);
}

.legal-contact__value {
    font-size: var(--t-text-base);
    color: var(--t-color-black);
    line-height: var(--t-leading-snug);
    word-break: break-word;
}

.legal-contact__value a {
    color: var(--t-color-black);
    text-decoration: none;
    border-bottom: var(--t-border-width-1) solid var(--t-gray-150);
    padding-bottom: 1px;
    transition: border-color var(--t-duration-fast) var(--t-ease-default),
                color var(--t-duration-fast) var(--t-ease-default);
}

.legal-contact__value a:hover,
.legal-contact__value a:focus-visible {
    color: var(--t-color-red);
    border-bottom-color: var(--t-color-red);
}

/* ============================================================
 * Bouton retour en haut
 * ============================================================ */

.legal-back-to-top {
    position: fixed;
    bottom: var(--t-space-7);
    right: var(--t-space-7);
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--t-color-black);
    color: var(--t-color-white);
    border: none;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity var(--t-duration-base) var(--t-ease-default),
                transform var(--t-duration-base) var(--t-ease-default),
                background-color var(--t-duration-fast) var(--t-ease-default);
    z-index: var(--t-z-fixed);
}

.legal-back-to-top.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.legal-back-to-top:hover,
.legal-back-to-top:focus-visible {
    background: var(--t-color-red);
    outline: none;
}

.legal-back-to-top svg {
    width: 18px;
    height: 18px;
}

/* ============================================================
 * Responsive
 * ============================================================ */

@media (max-width: 992px) {
    .legal-layout {
        grid-template-columns: 1fr;
        gap: var(--t-space-7);
    }

    .legal-toc {
        position: static;
        max-height: none;
        overflow: visible;
        padding-right: 0;
        border: var(--t-border-width-1) solid var(--t-color-border);
        background: var(--t-color-bg-muted);
    }

    .legal-toc > .legal-toc__title {
        display: none;
    }

    .legal-toc > summary {
        list-style: none;
        cursor: pointer;
        padding: var(--t-space-5);
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: var(--t-text-xs);
        text-transform: uppercase;
        letter-spacing: var(--t-tracking-wider);
        color: var(--t-color-black);
        font-weight: var(--t-weight-semibold);
    }

    .legal-toc summary::-webkit-details-marker {
        display: none;
    }

    .legal-toc summary::after {
        content: "";
        display: inline-block;
        width: 10px;
        height: 10px;
        border-right: var(--t-border-width-2) solid var(--t-color-black);
        border-bottom: var(--t-border-width-2) solid var(--t-color-black);
        transform: rotate(45deg);
        transition: transform var(--t-duration-base) var(--t-ease-default);
        margin-top: -4px;
    }

    .legal-toc[open] summary::after {
        transform: rotate(-135deg);
        margin-top: 4px;
    }

    .legal-toc__list {
        padding: 0 var(--t-space-5) var(--t-space-5);
        border-top: var(--t-border-width-1) solid var(--t-color-border);
    }

    .legal-toc__list .legal-toc__item:first-child {
        padding-top: var(--t-space-4);
    }
}

@media (max-width: 720px) {
    .legal-page {
        padding: var(--t-space-5) 0 var(--t-space-10);
    }

    .legal-hero {
        margin-bottom: var(--t-space-7);
    }

    .legal-hero__title {
        font-size: var(--t-text-7xl);
    }

    .legal-hero__lede {
        font-size: var(--t-text-lg);
    }

    .legal-content {
        font-size: var(--t-text-base);
    }

    .legal-content > p:first-of-type {
        font-size: var(--t-text-lg);
    }

    .legal-section__title {
        font-size: var(--t-text-4xl);
    }

    .legal-section__subtitle {
        font-size: var(--t-text-2xl);
    }

    .legal-section p {
        text-align: left;
    }

    .legal-contact {
        padding: var(--t-space-5);
    }

    .legal-back-to-top {
        bottom: var(--t-space-5);
        right: var(--t-space-5);
        width: 44px;
        height: 44px;
    }
}

/* ============================================================
 * Print
 * ============================================================ */

@media print {
    .legal-toc,
    .legal-back-to-top,
    .legal-hero__meta {
        display: none !important;
    }

    .legal-layout {
        display: block;
    }

    .legal-content {
        max-width: 100%;
        font-size: 11pt;
        color: #000;
    }

    .legal-section {
        page-break-inside: avoid;
        border-top: 1px solid #ccc;
    }

    .legal-section__title {
        font-size: 16pt;
    }

    a {
        color: #000 !important;
        text-decoration: underline;
    }
}
