/* ===== Le Fil (2026-11-14): pages built with page(..., fil=...) in build.py =====
   html.fil > main.fil > section.ch (one screen, vertical snap) > .deck (horizontal snap) > article.pn (one scene).
   One line per panel (.say), drawn in 3D by hero/src/fil.js on the fixed canvas; the engine adds .gl to the panel,
   then the DOM line is clip-hidden (never display:none). Plain mode (html.plain: T0, no WebGL, or the « Texte »
   toggle in the Menu) keeps it visible over a scrim. Light mode uses real tokens here: no invert filter on these pages.
   Loaded after style.css; nothing here touches pages without html.fil. */

html.fil {
  --fg: #f4eee4; --fg2: #b9b3a9; --bg: #070708; --sheet: #100f0f; --acc: #ff5722;
  --line-f: rgba(244,238,228,.18); --chip: rgba(7,7,8,.55); --scrim: rgba(7,7,8,.78); --dim: rgba(0,0,0,.5);
  --hd: 56px; --g: clamp(16px, 4vw, 64px); --sb: env(safe-area-inset-bottom, 0px);
  --pb: 6vh;                                     /* space under the button row */
  --say: 700 clamp(38px, 4.8vw, 80px)/1.03 var(--head);
  scroll-snap-type: y mandatory; scroll-behavior: auto; background: var(--bg); color-scheme: dark;
}
/* light: real tokens, the canvas and images are never filtered (scenes draw their day look from uLight) */
html.fil[data-theme="light"] {
  filter: none; color-scheme: light;
  --fg: #0a0a0a; --fg2: #55524d; --bg: #f4eee4; --sheet: #fbf8f2; --acc: #ff5722;
  --line-f: rgba(10,10,10,.16); --chip: rgba(244,238,228,.72); --scrim: rgba(244,238,228,.84); --dim: rgba(10,10,10,.32);
  /* style.css night tokens, back to day for the shared components (.btn, details, cards) */
  --paper: #f4eee4; --paper-2: #ebe3d6; --ink: #0a0a0a; --ink-2: #1a1a1a; --muted: #55524d; --line: rgba(10,10,10,.14);
  --tile: #fffaf2; --edge: #d8cfc0; --orange: #ff5722;
}
html.fil[data-theme="light"] :is(img, video, canvas, iframe, .pano img) { filter: none; }
html.fil body { background: var(--bg); color: var(--fg); overflow-x: clip; }
html.fil body::before { display: none; }
html.fil-jump main.fil { visibility: hidden; }          /* a deep link: hidden for at most a frame while reel-ui places it */
html.fil :focus-visible { outline: 2px solid var(--acc); outline-offset: 3px; }

/* hidden for the eye, kept for readers and search: .vh, and the DOM line once the glyphs are drawn */
.vh, html.fil:not(.plain) .pn.gl:not(.plain) .say {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

.skip { position: fixed; left: 12px; top: -64px; z-index: 90; padding: 12px 18px; border-radius: 999px; background: var(--acc); color: #0a0a0a;
  font: 600 14px/1 var(--head); text-decoration: none; }
.skip:focus { top: 12px; }

/* the one WebGL canvas (hero/src/fil.js); hidden on T0 */
.fil-gl { position: fixed; left: 0; top: 0; width: 100%; height: 100lvh; z-index: 0; display: block; pointer-events: none; }
html.t0 .fil-gl, html[data-tier="t0"] .fil-gl { display: none; }

/* ---- header: a 56px overlay (logo, theme, Menu); nav and footer links live in the Menu sheet. No backdrop-filter. */
.fil-top { position: fixed; left: 0; right: 0; top: 0; z-index: 30; height: var(--hd); display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 var(--g); color: var(--fg); pointer-events: none;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 72%, transparent), transparent); }
.fil-top > * { pointer-events: auto; }
.fil-top .logo { color: var(--fg); font-size: 16px; }
.fil-top .logo svg { width: 30px; height: 26px; }
.fil-top .logo svg path:first-child { fill: currentColor; }
.fil-tools { display: flex; gap: 10px; align-items: center; }
html.fil .fil-top .tgl { color: var(--fg); border-color: var(--line-f); background: var(--chip); }

/* ---- chapters, decks, panels */
main.fil { position: relative; display: block; }   /* no z-index: open sheets must rise above the scrim */
.ch { position: relative; height: 100svh; padding: 0; scroll-snap-align: start; scroll-snap-stop: always; overflow: hidden; }
.deck { display: flex; height: 100%; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; touch-action: pan-x pan-y;
  overscroll-behavior-x: contain; scrollbar-width: none; }
.deck::-webkit-scrollbar { display: none; }
.deck:focus-visible { outline-offset: -4px; }
.pn { flex: 0 0 100%; min-width: 0; height: 100%; position: relative; scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; flex-direction: column; align-items: flex-start; gap: 16px; overflow: hidden;
  padding: calc(var(--hd) + 44px) var(--g) var(--pb);
  /* until a poster or a live scene is there: a quiet gradient (posters: --pn / --pnd, step 13) */
  background: var(--pn, none) center / cover no-repeat, radial-gradient(110% 80% at 72% 34%, color-mix(in srgb, var(--acc) 13%, var(--bg)) 0%, var(--bg) 62%); }
html.fil[data-theme="light"] .pn { background-image: var(--pnd, none), radial-gradient(110% 80% at 72% 34%, color-mix(in srgb, var(--acc) 16%, var(--bg)) 0%, var(--bg) 62%); }
html.fil-live .pn:not(.pn-gen) { background: none; }     /* the engine sets html.fil-live while the canvas draws */
/* the scrim under the DOM line: on while the line is DOM text (T0, plain, before the glyphs) */
.pn::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 75%; pointer-events: none;
  background: linear-gradient(to top, var(--scrim), transparent); transition: opacity .25s; }
html.fil:not(.plain) .pn.gl:not(.plain)::before { opacity: 0; }
.pn > .txt { margin-top: auto; max-width: 60%; position: relative; }   /* no z-index: an open sheet inside must stack above the scrim */
.pn > .acts { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.say { font: var(--say); letter-spacing: -.03em; color: var(--fg); text-wrap: balance; overflow-wrap: break-word; max-width: 13em; }
.pn-h1 { font: 600 clamp(15px, 1.25vw, 19px)/1.3 var(--head); letter-spacing: 0; color: var(--fg2); margin-bottom: 14px; max-width: 32em; }
.pn-tease { margin-bottom: 8px; color: var(--acc); }
.pn-n { position: absolute; top: calc(var(--hd) + 12px); left: var(--g); z-index: 1; font: 600 12px/1 var(--head); letter-spacing: .14em; color: var(--fg2); }
html.fil .fil .btn { --ink: #0a0a0a; --paper: #f4eee4; }
html.fil .pn .btn { height: auto; min-height: 52px; padding-block: 6px; max-width: 100%; }
html.fil .pn .btn.orange { background: var(--acc); border-color: var(--acc); color: #0a0a0a; box-shadow: none; }
html.fil .pn .btn.orange:hover { box-shadow: 4px 4px 0 var(--fg); }
html.fil .pn .btn.orange i { background: #0a0a0a; color: var(--acc); }

/* ---- deck controls: prev/next (round, 48px, edges), dots (links), the counter sits in each panel */
.deck-ui { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.deck-ui > * { pointer-events: auto; }
.dk { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--line-f); background: var(--chip); color: var(--fg); cursor: pointer; transition: border-color .2s, opacity .2s; }
.dk:hover { border-color: var(--acc); }
.dk[aria-disabled="true"] { opacity: .3; cursor: default; }
.dk-prev { left: clamp(8px, 1.4vw, 20px); }
.dk-next { right: clamp(34px, 3.4vw, 52px); }
.dots { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--pb) + 22px); display: flex; gap: 8px; align-items: center; }
.dots a { position: relative; display: block; width: 8px; height: 8px; border-radius: 8px; background: color-mix(in srgb, var(--fg) 34%, transparent); transition: width .3s var(--ease), background .3s; }
.dots a::after { content: ""; position: absolute; inset: -12px -4px; }
.dots a[aria-current] { width: 26px; background: var(--acc); }

/* ---- the chapter rail (real links) */
.rail { position: fixed; right: clamp(8px, 1.2vw, 18px); top: 50%; transform: translateY(-50%); z-index: 25; display: grid; gap: 10px; }
.rail a { position: relative; display: block; width: 8px; height: 8px; border-radius: 8px; background: color-mix(in srgb, var(--fg) 30%, transparent); transition: height .3s var(--ease), background .3s; }
.rail a::after { content: ""; position: absolute; inset: -5px -12px; }
.rail a:hover { background: var(--fg); }
.rail a[aria-current] { height: 26px; background: var(--acc); }

/* ---- sheets: <details class="sheet">, the only long text. Closed: a « Lire » chip. Open: a fixed panel, 88svh. */
html.fil details.sheet { border: 0; padding: 0; }
html.fil details.sheet > summary { display: inline-flex; align-items: center; gap: 10px; height: 44px; padding: 0 16px 0 18px; border-radius: 999px; list-style: none;
  border: 1px solid var(--line-f); background: var(--chip); color: var(--fg); font: 600 14px/1 var(--head); cursor: pointer; }
html.fil details.sheet > summary::-webkit-details-marker { display: none; }
html.fil details.sheet > summary::after { font-size: 20px; color: var(--acc); }
html.fil details.sheet[open] { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; width: min(760px, 100%); margin-inline: auto; height: 88svh;
  overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--g) calc(32px + var(--sb)); border-radius: 22px 22px 0 0;
  background: var(--sheet); color: var(--fg); box-shadow: 0 -24px 60px rgba(0,0,0,.35); border: 1px solid var(--line-f); border-bottom: 0; }
html.fil details.sheet[open] > summary { position: sticky; top: 0; z-index: 1; display: flex; width: 100%; height: 60px; padding: 0; justify-content: space-between;
  border: 0; border-bottom: 1px solid var(--line-f); border-radius: 0; background: var(--sheet); font-size: 16px; }
html.fil details.sheet[open] > summary::after { font-size: 30px; }
.sheet-body { padding-top: 20px; font: 400 17px/1.6 var(--body); color: var(--fg); max-width: 44em; }
.sheet-body:focus { outline: none; }
.sheet-body p { color: var(--fg); } .sheet-body p + p { margin-top: 1em; }
.sheet-body h2, .sheet-body h3 { font: 700 22px/1.2 var(--head); margin: 22px 0 8px; }
.sheet-body ul { padding-left: 1.2em; } .sheet-body li + li { margin-top: .4em; }
.sheet-body details { border-color: var(--line-f); padding: 16px 0; }
.sheet-body details summary { font-size: 17px; }
.sheet-body details:not([open]) summary::after { transform: none; }   /* style.css turns « + » for any open ancestor */
.sheet-body details p { color: var(--fg2); margin-top: 10px; }
.fil-scrim { position: fixed; inset: 0; z-index: 28; background: var(--dim); }   /* under the header (Menu) and the sheets (60) */
.fil-scrim[hidden] { display: none; }
html.sheet-open { scroll-snap-type: none; overflow: hidden; }

/* the Menu: the same sheet, from the header */
html.fil details.menu > summary { height: 38px; padding: 0 16px; }
html.fil details.menu > summary::after { content: none; }
html.fil details.menu[open] > summary::after { content: "+"; transform: rotate(45deg); }
.menu-nav { display: grid; gap: 2px; margin-bottom: 18px; }
.menu-nav a { font: 700 clamp(24px, 3.4vw, 34px)/1.25 var(--head); letter-spacing: -.02em; text-decoration: none; color: var(--fg); padding: 4px 0; }
.menu-nav a:hover, .menu-nav a[aria-current] { color: var(--acc); }
.plain-tgl { display: inline-flex; align-items: center; gap: 10px; height: 44px; padding: 0 18px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-f); background: transparent; color: var(--fg); font: 600 14px/1 var(--head); }
.plain-tgl::before { content: ""; width: 30px; height: 16px; border-radius: 16px; background: var(--line-f); box-shadow: inset -14px 0 0 2px var(--fg2); transition: box-shadow .2s, background .2s; }
.plain-tgl[aria-pressed="true"]::before { background: var(--acc); box-shadow: inset 14px 0 0 2px var(--sheet); }
.plain-tgl[aria-disabled="true"] { opacity: .55; cursor: default; }
.menu-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line-f); }
.menu-cols a { display: block; padding: 5px 0; font-size: 15px; color: var(--fg2); text-decoration: none; overflow-wrap: anywhere; }
.menu-cols a:hover { color: var(--acc); }
.menu-h { font: 600 12px/1 var(--head); letter-spacing: .16em; text-transform: uppercase; color: var(--fg2); margin-bottom: 10px; opacity: .8; }
.menu-base { margin-top: 22px; font-size: 13px; } .menu-base a { color: var(--fg2); }

/* ---- the post-credit and the générique (the footer, on the Québec night poster; always night) */
.ch.gen { height: auto; min-height: 100svh; scroll-snap-stop: normal; }
.pn-gen { --fg: #f4eee4; --fg2: #b9b3a9; height: auto; min-height: 100svh; justify-content: flex-end; background: #070708; color: #f4eee4;
  padding-bottom: calc(28px + var(--sb)); }
.pn-gen::before { display: none; }
.pn-gen .gen-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 42%; opacity: .5; }
.pn-gen .gen-in { position: relative; z-index: 1; width: 100%; margin-top: auto; background: linear-gradient(to top, rgba(7,7,8,.92) 60%, rgba(7,7,8,0)); padding: 48px 0 0; }
html.fil .pn-gen footer { background: linear-gradient(to top, rgba(7,7,8,.94) 62%, rgba(7,7,8,0)); }

/* ---- phone portrait, and tablet portrait (the phone layout, larger line, prev/next kept) */
@media (max-width: 767px), (max-width: 1024px) and (orientation: portrait) {
  html.fil { --pb: calc(var(--sb) + 16px); --say: 700 clamp(31px, 8.4vw, 46px)/1.05 var(--head); }
  .pn > .txt { max-width: 100%; }
  .ch.multi .pn > .acts { min-height: 52px; }
  .ch.multi .pn > .txt { margin-bottom: 26px; }
  .ch.multi .pn:not(:has(.acts))::after { content: ""; height: 52px; flex: none; }   /* keep the dots' place */
  .dots { left: var(--g); transform: none; bottom: calc(var(--pb) + 52px + 18px); }
  /* one row: a long button wraps its own label instead of pushing « Lire » under it (the dots sit above the row) */
  .pn > .acts { flex-wrap: nowrap; }
  html.fil .pn .acts .btn { flex: 0 1 auto; min-width: 0; }
  .pn > .acts details.sheet:not([open]) { flex: none; }
}
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  html.fil { --say: 700 clamp(44px, 7vw, 64px)/1.04 var(--head); }
  .pn > .txt { max-width: 80%; }
}
@media (max-width: 767px) {
  .rail { display: none; }
  .fil-top .logo { font-size: 14px; gap: 8px; }
  .menu-cols { grid-template-columns: 1fr 1fr; }
  .menu-cols > :last-child { grid-column: 1 / -1; }
}
/* very narrow (a phone at 200% zoom): the logo keeps its mark, the word stays for readers */
@media (max-width: 359px) {
  html.fil { --g: 12px; }
  .fil-top .logo { font-size: 0; gap: 0; }
  .fil-tools { gap: 6px; }
}
/* prev/next: hidden on touch phones, still in the DOM and focusable (they show on focus) */
@media (max-width: 767px) and (pointer: coarse), (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  .dk:not(:focus-visible) { opacity: 0; pointer-events: none; }
}

/* ---- phone landscape: 44px header, the line in the left 55%, the button bottom-right, no rail, no dots */
@media (max-height: 500px) and (orientation: landscape) {
  html.fil { --hd: 44px; --pb: calc(var(--sb) + 14px); --say: 700 clamp(24px, 4.4vw, 36px)/1.05 var(--head); }
  .fil-top .tgl { width: 32px; height: 32px; }
  html.fil details.menu > summary { height: 32px; }
  .pn { padding-top: calc(var(--hd) + 34px); padding-right: calc(var(--g) + env(safe-area-inset-right, 0px)); }
  .pn > .txt { max-width: 55%; }
  .pn > .acts { position: absolute; right: calc(var(--g) + env(safe-area-inset-right, 0px)); bottom: var(--pb); justify-content: flex-end; max-width: 42%; }
  /* the page title stays left of the button column (42 % from the right), with a 16px gap */
  .pn > .txt .pn-h1 { max-width: calc(58vw - 2 * var(--g) - env(safe-area-inset-right, 0px) - 16px); }
  .pn-n { top: calc(var(--hd) + 8px); }
  .rail, .dots { display: none; }
  .ch.multi .pn > .txt { margin-bottom: 0; }
  /* the post-credit tease goes with its button (bottom-right) while the 3D line holds the left */
  .pn.gl:not(.plain) > .txt { position: static; }
  .pn.gl:not(.plain) .pn-tease { position: absolute; right: calc(var(--g) + env(safe-area-inset-right, 0px)); bottom: calc(var(--pb) + 60px); margin: 0; }
  /* the page title (h1 when it is not the line) on a board panel goes top-left: the board line holds the bottom-left */
  .pn[data-scene="board"].gl:not(.plain) .pn-h1 { position: absolute; left: var(--g); top: calc(var(--hd) + 26px); max-width: 52%; margin: 0; font-size: 14px;
    text-shadow: 0 1px 10px var(--bg), 0 0 3px var(--bg); }
  html.fil details.sheet[open] { height: 92svh; }
}

/* ---- too tall for one screen (plain text at 200% zoom, short landscape): reel-ui adds .tall, the chapter grows */
.ch.tall { height: auto; min-height: 100svh; scroll-snap-stop: normal; }
.ch.tall .deck { align-items: stretch; }
.ch.tall .pn { height: auto; min-height: 100svh; overflow: visible; }
.ch.tall .pn > .acts { position: relative; right: auto; bottom: auto; }

/* ---- the home hero (panel debut-1, scene « circuit »): hero.js draws in its own canvas behind the line (phase A).
   Its own scrim, because the panel's ::before would sit under it. T0 and no-GL keep the SVG poster. */
.pn-art::before { display: none; }
.fil-hx { position: absolute; inset: 0; height: auto; min-height: 0; padding: 0; background: #060607; overflow: hidden; }
.fil-hx .hx-poster { bottom: 4%; width: min(1500px, 150%); }
.fil-hx::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 75%; pointer-events: none;
  background: linear-gradient(to top, var(--scrim), transparent); }
html.fil[data-theme="light"] .fil-hx, html.fil[data-theme="light"] .fil-hx .hx-stage { background: var(--bg); }

/* ---- /adovic/: the Adovic sand accent and Lexend Exa line; Madelucid's own orange stays in its logo */
html.fil body.brand-adovic { --acc: #d9c19e; }
html.fil[data-theme="light"] body.brand-adovic { --acc: #b08a52; }
body.brand-adovic .say { font-family: "Lexend Exa", var(--head); font-weight: 600; letter-spacing: -.02em; }
.fil-top .blogo .bx { color: var(--fg2); }
html.fil[data-theme="light"] .fil-top .blogo img { filter: brightness(.5); }   /* the sand logo on paper (an image, not the canvas) */
.fil-top .blogo .bx svg path:first-child { fill: currentColor; }

/* ---- tiers. T0: posters + plain text, no canvas; the line fades in (200 ms) on the panel reel-ui marks .on */
html.t0 .pn::before { opacity: 1; }
html.t0.fil-ui .pn > .txt { transition: opacity .2s; }
html.t0.fil-ui .pn:not(.on) > .txt { opacity: 0; }
/* plain mode: the line is DOM text over the scrim, on every tier */
html.plain .pn.gl .say { position: static; }

/* ---- reduced motion: proximity snap, no smooth scroll, no tweens */
@media (prefers-reduced-motion: reduce) {
  html.fil { scroll-snap-type: y proximity; }
  .deck { scroll-behavior: auto; }
  .dots a, .rail a, .pn::before, .dk, html.t0.fil-ui .pn > .txt { transition: none; }
}
