/* =============================================================================
   LA BARRIQUE — FINITIONS PREMIUM (v3)
   -----------------------------------------------------------------------------
   Signature : l'ARCHE et la FOUGÈRE du logo, en filigranes tracés (SVG vivant,
   inc/filigranes.php), dans un dégradé « feuille d'or ».

   - Bandeaux des pages intérieures : la même grande arche, centrée, qui
     encadre le titre comme une porte, en transparence derrière le texte.
   - Accueil : seulement les fougères (carte, territoire) ; le bandeau de
     l'accueil reste une photo pure.
   - Pied de page (toutes les pages) : le portique autour du crédit.
   - Ouverture de page : chorégraphie orchestrée — les arches se tracent une
     à une, le halo s'allume, puis fil d'Ariane, titre (lever de rideau
     souligné d'un filet d'or) et sous-titre apparaissent en cascade.
   - Fougères et portique : ils se déploient / se dessinent d'eux-mêmes
     quand ils arrivent à l'écran.

   Garde-fous :
   - Aucun décalage de mise en page : on n'anime que l'opacité, le tracé et
     des déplacements visuels (translate/scale), jamais la géométrie.
   - L'état « prêt à apparaître » est posé AVANT le premier affichage
     (classe .labar-anim, dans le <head>) : aucun flash.
   - Visiteurs ayant demandé à réduire les animations : tout est affiché
     d'emblée, complet et immobile.
   ========================================================================== */

:root {
    --fil-monogramme: url("../img/filigrane/monogramme.svg");
    --fil-fougere:    url("../img/filigrane/fougere.svg");
    --fil-grain:      url("../img/filigrane/grain.svg");
    --or-feuille: linear-gradient(165deg, #F0CFB5 0%, #D98A45 45%, #9A4F16 100%);
    --courbe-douce: cubic-bezier(0.2, 0.72, 0.2, 1);
    --courbe-trace: cubic-bezier(0.55, 0.08, 0.25, 1);
}

/* =============================================================================
   1. MATIÈRE
   ========================================================================== */
/* « clip » plutôt que « hidden » : pas de défilement horizontal, sans faire
   de body un conteneur de défilement (qui figerait les effets au défilement). */
body { overflow-x: clip; }

body,
.section--cream:not(.ig),
.menu-section {
    background-image: var(--fil-grain);
    background-size: 180px 180px;
}

/* =============================================================================
   2. FILIGRANES TRACÉS — socle
   ========================================================================== */
.fil {
    position: absolute;
    z-index: 0;
    display: block;
    height: auto;
    overflow: visible;
    pointer-events: none;
}
/* Épaisseur du trait en unités du dessin (--trait), calibrée par emplacement
   selon l'agrandissement du motif, pour un trait d'environ 1,1 px à l'écran.
   (Pas de « non-scaling-stroke » : combiné à pathLength, Chrome calcule alors
   les pointillés en pixels d'écran et le tracé progressif devient faux.) */
.fil .trace {
    fill: none;
    stroke-width: var(--trait, 1.2);
    stroke-dasharray: 1 1;          /* pathLength = 1 : un trait = toute la longueur */
    stroke-dashoffset: 0;           /* état par défaut : motif complet               */
}
.fil--fougere .trace.tige { stroke-width: calc(var(--trait, 1.2) * 1.4); }
.fil--fougere .rachis { fill: none; stroke-width: calc(var(--trait, 1.2) * 0.7); opacity: 0.55; }
.fil--fougere .penne > path:not(.rachis) { stroke: none; }
.fil--fougere .penne { transform-box: view-box; }

/* Les jambages des arches s'évanouissent dans le fond. */
.fil--arches {
    -webkit-mask-image: linear-gradient(to bottom, #000 42%, transparent 92%);
            mask-image: linear-gradient(to bottom, #000 42%, transparent 92%);
}

/* Sections porteuses : on rogne proprement, le contenu passe au-dessus. */
#carte, #tourisme, .site-footer { overflow: clip; }
#carte > .container, #tourisme > .container,
.site-footer > :not(.fil) { position: relative; z-index: 1; }

/* =============================================================================
   3. COMPOSITIONS
   ========================================================================== */

/* — Bandeaux (toutes les pages) : la grande arche centrée, derrière le titre — */
.fil--banner-centre {
    --trait: 0.55;        /* motif agrandi ≈ ×2 */
    --halo: 0.6;          /* halo plus doux : le sous-titre garde tout son contraste */
    left: 50%;
    top: calc(var(--nav-h, 110px) - 0.6rem);
    width: min(36vw, 30rem);
    margin-left: calc(min(36vw, 30rem) / -2);
    opacity: 0.42;
}

/* — Titre des bandeaux : filet d'or sous le titre — */
.page-banner h1 { position: relative; margin-bottom: 1.1rem; }
.page-banner h1::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -0.58rem;
    width: 3.4rem;
    height: 1px;
    margin-left: -1.7rem;
    background: linear-gradient(90deg, transparent, #F0CFB5 30%, var(--c-or) 50%, #F0CFB5 70%, transparent);
    pointer-events: none;
}

/* — La carte : la fougère penchée vers l'ardoise — */
.fil--carte {
    --trait: 2.3;
    right: clamp(0.5rem, 3vw, 4rem);
    top: 2.5rem;
    width: clamp(8rem, 12vw, 12rem);
    rotate: 12deg;
    scale: -1 1;
    opacity: 0.16;
}

/* — Le territoire : la fougère dorée — */
.fil--tourisme {
    --trait: 2.5;
    right: clamp(2rem, 10vw, 11rem);
    top: -1.2rem;
    width: clamp(8rem, 11vw, 11rem);
    rotate: 16deg;
    opacity: 0.32;
}

/* — Pied de page : le portique autour du crédit —
   Accroché au bloc du crédit (footer.php) : son sommet part SOUS la ligne des
   liens légaux, qui ne passent donc jamais derrière le dessin. Le bloc réserve
   en haut la hauteur de l'arc (≈ 40 % de la largeur de l'arche) pour que le
   texte se loge sous la voûte, entre les jambages. */
.footer-credit-row {
    --portique: clamp(215px, 15vw, 260px);   /* toujours plus large que le cartouche */
    position: relative;
    padding-top: calc(var(--portique) * 0.4);
}
/* Le texte est plus large que les arcs intérieurs : il repose sur un cartouche
   de la couleur du fond, liseré d'or, qui interrompt les traits autour de lui. */
.footer-credit-row .footer-credit {
    position: relative;
    z-index: 1;
    gap: 0.6rem;
    padding: 0.75rem 1.15rem 0.85rem;
    background: var(--c-jet);
    border: 1px solid rgba(208, 117, 31, 0.35);
    border-radius: 14px;
    box-shadow: 0 0 0 6px var(--c-jet);
}
.footer-credit-row .footer-credit:hover,
.footer-credit-row .footer-credit:focus-visible { border-color: rgba(223, 169, 132, 0.7); }
.fil--portique {
    --trait: 1.4;
    left: 50%;
    top: 0;
    bottom: auto;
    width: var(--portique, 13.5rem);
    margin-left: calc(var(--portique, 13.5rem) / -2);
    opacity: 0.5;
    -webkit-mask-image: none; mask-image: none;
}

/* — Autres pages : fougère des fonds crème, alternée gauche / droite — */
.section--cream:not(.ig) { position: relative; overflow: clip; }
.section--cream:not(.ig) > * { position: relative; z-index: 1; }
.section--cream:not(.ig)::before {
    content: "";
    position: absolute; z-index: 0; pointer-events: none;
    left: clamp(-2rem, -1vw, 0rem);
    top: 2.5rem;
    width: clamp(8rem, 13vw, 12rem);
    aspect-ratio: 290 / 450;
    background: var(--c-vert-deep);   /* fougère verte, comme celle du logo */
    -webkit-mask: var(--fil-fougere) no-repeat center / contain;
            mask: var(--fil-fougere) no-repeat center / contain;
    opacity: 0.06;
    rotate: -14deg;
}
.section--cream:not(.ig):nth-of-type(even)::before {
    left: auto;
    right: clamp(-2rem, -1vw, 0rem);
    rotate: 14deg;
    scale: -1 1;
}

/* =============================================================================
   4. APPARITIONS — la chorégraphie d'ouverture et l'arrivée des sections
   ========================================================================== */
@keyframes fil-trace { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes fil-halo  { from { opacity: 0; } to { opacity: var(--halo, 1); } }
@keyframes fil-penne { from { scale: 0.08; opacity: 0; } to { scale: 1; opacity: 1; } }
@keyframes rideau {
    from { opacity: 0; translate: 0 0.45em; clip-path: inset(100% -6% -30% -6%); }
    to   { opacity: 1; translate: 0 0;      clip-path: inset(-20% -6% -30% -6%); }
}
@keyframes monte { from { opacity: 0; translate: 0 0.7rem; } to { opacity: 1; translate: 0 0; } }
@keyframes filet { from { opacity: 0; scale: 0 1; } to { opacity: 1; scale: 1 1; } }

/* État « prêt à apparaître », posé avant le premier affichage. */
.labar-anim .fil--entree .trace,
.labar-anim .fil--vue .trace { stroke-dashoffset: 1; }
.labar-anim .fil--entree .halo,
.labar-anim .fil--vue .halo { opacity: 0; }
.labar-anim .fil--vue .penne { opacity: 0; scale: 0.08; }

/* — Les arches se tracent, de l'arc extérieur vers le cœur (0,14 s d'écart) — */
.labar-anim .fil--entree .trace,
.labar-anim .fil--vue.is-vu .trace {
    animation: fil-trace 2.1s var(--courbe-trace) forwards;
    animation-delay: calc(0.1s + var(--i, 0) * 0.14s);
}
/* … puis la lumière s'allume en leur cœur. */
.labar-anim .fil--entree .halo,
.labar-anim .fil--vue.is-vu .halo { animation: fil-halo 1.6s ease-out 1.3s forwards; }

/* — La fougère : la tige se trace, les pennes s'ouvrent de la base à la pointe — */
.labar-anim .fil--vue.is-vu .penne {
    animation: fil-penne 0.95s var(--courbe-douce) forwards;
    animation-delay: calc(0.55s + var(--i) * 0.075s);
}

/* — Texte des bandeaux : fil d'Ariane, lever de rideau du titre, filet d'or, sous-titre — */
.labar-anim .page-banner .breadcrumb { animation: monte 0.9s var(--courbe-douce) 0.2s both; }
.labar-anim .page-banner h1          { animation: rideau 1.15s var(--courbe-douce) 0.35s both; }
.labar-anim .page-banner h1::after   { animation: filet 1s cubic-bezier(0.65, 0, 0.35, 1) 1.05s both; }
.labar-anim .page-banner .lead       { animation: monte 1s var(--courbe-douce) 0.75s both; }

/* =============================================================================
   5. EFFETS AU DÉFILEMENT (le navigateur les calcule avant l'affichage)
   ========================================================================== */
@keyframes fil-derive  { from { translate: 0 0; } to { translate: 0 3.5rem; } }
@keyframes hero-recul  { from { translate: 0 0; } to { translate: 0 14%; } }
@keyframes hero-efface { from { opacity: 1; translate: 0 0; } to { opacity: 0; translate: 0 -2.5rem; } }
@keyframes fil-lecture { from { scale: 0 1; } to { scale: 1 1; } }

@media (prefers-reduced-motion: no-preference) {
    @supports (animation-timeline: scroll()) {
        /* L'arche des bandeaux s'éloigne doucement quand on descend. */
        .fil--banner { animation: fil-derive linear both; animation-timeline: scroll(root); animation-range: 0 60vh; }

        /* Accueil : la photo recule, le texte (et son arche) s'efface. */
        .hero__media img, .hero__media video { animation: hero-recul linear both; animation-timeline: scroll(root); animation-range: 0 100vh; }
        .hero__inner { animation: hero-efface linear both; animation-timeline: scroll(root); animation-range: 15vh 75vh; }

        /* Fil de lecture doré sous l'en-tête. */
        .site-header::after {
            content: "";
            position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
            background: linear-gradient(90deg, transparent, var(--c-or) 18%, #F0CFB5 50%, var(--c-or) 82%, transparent);
            transform-origin: left center;
            animation: fil-lecture linear both;
            animation-timeline: scroll(root);
            pointer-events: none;
        }
    }
}

/* =============================================================================
   6. AU SURVOL — un reflet de lumière traverse les photos de la galerie
   ========================================================================== */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    .gallery-item::before {
        content: "";
        position: absolute; inset: 0; z-index: 1;
        background: linear-gradient(115deg, transparent 38%, rgba(255, 228, 205, 0.2) 50%, transparent 62%);
        translate: -115% 0;
        transition: translate 1.1s cubic-bezier(0.22, 0.61, 0.36, 1);
        pointer-events: none;
    }
    .gallery-item:hover::before { translate: 115% 0; }
    .gallery-item__cap { z-index: 2; }
}

/* =============================================================================
   7. TRANSITION ENTRE LES PAGES — fondu enchaîné, en-tête immobile
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {
    @view-transition { navigation: auto; }
}
.site-header { view-transition-name: labar-en-tete; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.32s; animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1); }
::view-transition-group(labar-en-tete) { animation-duration: 0s; }

/* =============================================================================
   8. TYPOGRAPHIE ET DÉTAILS
   ========================================================================== */
h1, h2, h3, .section-title, .hero__title { text-wrap: balance; }
p, .lead, li { text-wrap: pretty; }
.dish__price, .mdj__price, .wine__price { font-variant-numeric: lining-nums tabular-nums; }

::selection { background: var(--c-bordeaux); color: var(--c-cream); }
.section--dark ::selection, .section--bordeaux ::selection,
.site-footer ::selection, .page-banner ::selection, .mdj ::selection { background: var(--c-or); color: var(--c-jet); }
html { scrollbar-color: rgba(208, 117, 31, 0.75) transparent; }

/* =============================================================================
   9. ÉCRANS PLUS ÉTROITS
   ========================================================================== */
@media (max-width: 1180px) {
    .fil--carte { display: none; }
}
@media (max-width: 900px) {
    .fil--tourisme { display: none; }
    .fil--banner-centre { --trait: 0.8; width: min(72vw, 20rem); margin-left: calc(min(72vw, 20rem) / -2); opacity: 0.34; }
    .footer-credit-row { --portique: 12.5rem; }
    .fil--portique { --trait: 1.6; }
    .section--cream:not(.ig)::before { width: 6.5rem; opacity: 0.045; }
}

/* =============================================================================
   10. IMPRESSION
   ========================================================================== */
@media print {
    .fil, .section--cream::before, .site-header::after, .page-banner h1::after { display: none !important; }
    body, .section--cream, .menu-section { background-image: none !important; }
    .page-banner .breadcrumb, .page-banner h1, .page-banner .lead {
        animation: none !important; opacity: 1 !important; translate: none !important; clip-path: none !important;
    }
}
