/* base.css — the few rules the engine relies on. Design tokens and everything visual live in the
   site's own stylesheet; nothing here sets a look. */

/* The world: one fixed canvas behind the page. Sections above it keep transparent grounds wherever
   the scene should show through, and take a solid ground where reading needs calm. */
#world { position: fixed; inset: 0; width: 100%; height: 100lvh; z-index: 0; display: block; pointer-events: none; }
main, header, footer { position: relative; z-index: 1; }

/* Poster: what the page shows before the first frame, and for good when WebGL is missing.
   Give .world-poster a real picture or a composed CSS ground that already looks finished. */
.world-poster { position: fixed; inset: 0; z-index: 0; background-size: cover; background-position: center; transition: opacity 900ms cubic-bezier(.16, 1, .3, 1); }
.world-ready .world-poster { opacity: 0; }
.no-webgl #world { display: none; }
.no-webgl .world-poster { opacity: 1; }

/* Lenis */
html.lenis, html.lenis body { height: auto; }
.lenis:not(.lenis-autoToggle).lenis-stopped { overflow: clip; }
.lenis [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-smooth iframe { pointer-events: none; }

/* Curtain (openCurtain): lifts once fonts and the first frame are in */
[data-curtain] { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; transition: clip-path 1100ms cubic-bezier(.76, 0, .24, 1), visibility 0s 1100ms; clip-path: inset(0 0 0 0); }
.is-open [data-curtain] { clip-path: inset(0 0 100% 0); visibility: hidden; }
@media (prefers-reduced-motion: reduce) { [data-curtain] { transition: opacity 300ms, visibility 0s 300ms; } .is-open [data-curtain] { clip-path: none; opacity: 0; } }
html:not(.js) [data-curtain] { display: none; } /* add class "js" to <html> from an inline script */

/* Sideways chapter (data-pin-x) */
[data-pin-x] { overflow: clip; min-width: 0; max-width: 100vw; }
[data-pin-x] [data-track] { display: flex; width: max-content; will-change: transform; }
[data-pin-x].is-unpinned { overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
[data-pin-x].is-unpinned [data-track] > * { scroll-snap-align: start; }

/* Marquee (data-marquee) */
[data-marquee] { display: flex; overflow: clip; white-space: nowrap; min-width: 0; max-width: 100%; } /* min-width: a clipped grid/flex child still sizes to its content otherwise */
[data-marquee] > * { flex: none; }

/* Custom cursor (optional): only where there is a real pointer, and the native cursor stays */
[data-cursor-el] { position: fixed; left: 0; top: 0; z-index: 90; pointer-events: none; display: none; }
.has-cursor [data-cursor-el] { display: grid; place-items: center; }

/* Reading line (data-progress) */
[data-progress] { transform-origin: 0 50%; }

/* Split text: keep descenders inside line masks */
[data-split] { text-wrap: balance; }
[data-split] > div { padding-bottom: 0.08em; margin-bottom: -0.08em; }

/* Veil (data-veil): a soft patch of the ground colour behind a text block, for chapters where the
   words have to cross the scene. Set --veil to the section's ground if it differs from --ground. */
[data-veil] { position: relative; isolation: isolate; }
[data-veil]::before { content: ""; position: absolute; inset: -14% -10%; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--veil, var(--ground, #000)) 90%, transparent) 55%, transparent); }
