/* ========================================
   EN-TÊTE, MENU, BAS DE PAGE, COOKIES, PAGES LÉGALES
   (le HTML de l'en-tête et du bas de page est généré par js/layout.js)
======================================== */

:root { --header-h: 88px; }

html { scroll-padding-top: calc(var(--header-h) + 16px); }


/* ===== EN-TÊTE ===== */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: var(--header-h);
    background: var(--bg);
    border-bottom: 1px solid transparent;
    transition: border-color 0.4s ease, background-color 0.4s ease;
}

.site-header.is-scrolled {
    border-bottom-color: var(--line);
}

.header {
    position: relative;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.logo {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--fg);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 28px;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 40px;
    font-size: 15px;
}

.site-nav a {
    padding: 10px 0;
    color: var(--muted);
    transition: color 0.4s ease;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
    color: var(--fg);
}

.nav-index {
    display: none;
}

/* Bouton clair / sombre */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-right: -10px;
    background: none;
    border: 0;
    border-radius: 50%;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.4s ease;
    -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover {
    color: var(--fg);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

/* Lune en mode clair, soleil en mode sombre */
.theme-toggle .icon-sun { display: none; }

:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
    :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* Bouton du menu (mobile) */
.nav-toggle {
    display: none;
    position: relative;
    width: 44px;
    height: 44px;
    margin-right: -10px;
    background: none;
    border: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.nav-toggle span {
    position: absolute;
    left: 11px;
    width: 22px;
    height: 1px;
    background: var(--fg);
    transition: transform 0.5s var(--ease), top 0.5s var(--ease);
}

.nav-toggle span:nth-child(1) { top: 18px; }
.nav-toggle span:nth-child(2) { top: 25px; }
.menu-open .nav-toggle span:nth-child(1) { top: 21.5px; transform: rotate(45deg); }
.menu-open .nav-toggle span:nth-child(2) { top: 21.5px; transform: rotate(-45deg); }


/* ===== « VOIR PLUS » (mobile) ===== */

.read-more {
    margin-top: 6px;
    padding: 0 0 4px;
    background: none;
    border: 0;
    border-bottom: 1px solid var(--fg);
    font-size: 14px;
    color: var(--fg);
    cursor: pointer;
}

.book-description.is-collapsible {
    position: relative;
    max-height: 9.5rem;
    overflow: hidden;
    transition: max-height 0.5s var(--ease);
}

.book-description.is-collapsible.is-open { max-height: 60rem; }

.book-description.is-collapsible:not(.is-open)::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3.5rem;
    background: linear-gradient(to bottom, transparent, var(--bg));
    pointer-events: none;
}


/* ===== BAS DE PAGE ===== */

.site-footer {
    border-top: 1px solid var(--line);
    font-size: 14px;
    color: var(--muted);
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px 48px;
    padding-block: 40px 56px;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 32px;
}

.site-footer a,
.footer-cookie {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    color: var(--muted);
    transition: color 0.4s ease;
}

.site-footer a:hover,
.footer-cookie:hover {
    color: var(--fg);
}

.footer-cookie {
    padding: 0;
    background: none;
    border: 0;
    font-size: 14px;
    cursor: pointer;
}


/* ===== BANDEAU DE COOKIES ===== */

.cookie-banner {
    position: fixed;
    left: 24px;
    bottom: 24px;
    z-index: 100;
    width: min(400px, calc(100% - 48px));
    padding: 28px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(var(--rise, 24px));
    transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

.cookie-banner.is-visible { opacity: 1; transform: none; }

.cookie-banner h2 {
    margin-bottom: 10px;
    font-size: 22px;
    line-height: 1.2;
}

.cookie-banner p { font-size: 14px; line-height: 1.65; color: var(--body); }

.cookie-banner p a { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }

.cookie-options { margin-top: 16px; }

.cookie-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.cookie-option input { margin-top: 4px; accent-color: var(--fg); }
.cookie-option small { display: block; color: var(--muted); font-size: 13px; font-weight: 400; }

.cookie-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }

.cookie-btn {
    min-height: 44px;
    padding: 10px 18px;
    background: transparent;
    border: 1px solid var(--fg);
    border-radius: 999px;
    font-size: 13px;
    color: var(--fg);
    cursor: pointer;
    transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}

.cookie-btn[data-action="accept"],
.cookie-btn:hover { background: var(--fg); color: var(--bg); }

.cookie-btn[data-action="accept"]:hover { background: transparent; color: var(--fg); }

.cookie-btn--ghost { border-color: transparent; text-decoration: underline; text-underline-offset: 4px; }

.cookie-btn--ghost:hover { background: transparent; color: var(--fg); text-underline-offset: 6px; }


/* ===== PAGES LÉGALES ===== */

.legal-page {
    width: min(760px, calc(100% - 2 * var(--gutter)));
    margin: auto;
    padding: clamp(56px, 8vw, 112px) 0 clamp(96px, 12vw, 160px);
}

.legal-intro .kicker { margin-bottom: 20px; }

.legal-page h1 {
    font-size: clamp(2.6rem, 5vw, 4.25rem);
    line-height: 1.05;
    letter-spacing: -0.035em;
}

.legal-date {
    margin-top: 24px;
    font-size: 15px;
    color: var(--muted);
}

.legal-note {
    margin-top: 32px;
    padding: 18px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    font-size: 15px;
    line-height: 1.65;
    color: var(--body);
}

.legal-page section {
    margin-top: clamp(48px, 6vw, 72px);
}

.legal-page h2 {
    font-size: clamp(1.6rem, 2.6vw, 2rem);
    line-height: 1.15;
}

.legal-page h3 {
    margin-top: 28px;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0;
}

.legal-page section p,
.legal-page section li { margin-top: 14px; color: var(--body); line-height: 1.75; }

.legal-page ul { padding-left: 20px; }

.legal-page li::marker { color: var(--muted); }

.legal-page section a { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }

.legal-page strong { font-weight: 500; color: var(--fg); }


/* ===== MOBILE : menu plein écran ===== */

@media (max-width: 900px) {

    :root { --header-h: 72px; }

    .nav-toggle { display: block; }

    .header-right { gap: 8px; }

    .site-nav {
        position: fixed;
        top: var(--header-h);
        left: 0;
        right: 0;
        height: calc(100dvh - var(--header-h));
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 24px var(--gutter) max(32px, env(safe-area-inset-bottom));
        overflow-y: auto;
        background: var(--bg);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.5s var(--ease), visibility 0.5s;
    }

    .site-header.menu-open .site-nav { opacity: 1; visibility: visible; }

    .site-header.menu-open { border-bottom-color: var(--line); }

    .site-nav a {
        display: flex;
        align-items: baseline;
        gap: 16px;
        padding: 20px 0;
        border-bottom: 1px solid var(--line);
        font-size: clamp(2rem, 8vw, 2.6rem);
        font-weight: 300;
        line-height: 1.1;
        letter-spacing: -0.03em;
        color: var(--fg);
        opacity: 0;
        transform: translateY(14px);
        transition: opacity 0.6s var(--ease), transform 0.6s var(--ease), color 0.4s ease;
    }

    .nav-index {
        display: inline;
        font-size: 13px;
        letter-spacing: 0;
        color: var(--muted);
    }

    /* Apparition échelonnée des liens */
    .site-header.menu-open .site-nav > * { opacity: 1; transform: none; }
    .site-header.menu-open .site-nav > :nth-child(1) { transition-delay: 0.06s; }
    .site-header.menu-open .site-nav > :nth-child(2) { transition-delay: 0.12s; }
    .site-header.menu-open .site-nav > :nth-child(3) { transition-delay: 0.18s; }
    .site-header.menu-open .site-nav > :nth-child(4) { transition-delay: 0.24s; }

    html.menu-locked { overflow: hidden; }
}

@media (max-width: 800px) {

    .footer-inner { flex-direction: column; }

    .cookie-banner { left: 12px; bottom: 12px; width: calc(100% - 24px); padding: 22px; }
}


@media (prefers-reduced-motion: reduce) {

    .cookie-banner,
    .book-description.is-collapsible,
    .site-nav,
    .site-nav a,
    .site-header,
    .nav-toggle span,
    .theme-toggle { transition: none !important; }

    .site-nav a { transform: none !important; }
}
