/* The Firmament: a fixed scene behind a tall page. Scrolling the page is what tells the story.
   Colours and faces are the landing page's (night.css): near-black, bone, gold. */
:root {
  --bg: #06050a; --text: #e9e3d5; --muted: #a8a091; --gold: #c8a45c; --gold-soft: #e6cf98;
  --display: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', 'Source Serif Pro', Georgia, 'Times New Roman', serif;
  --ui: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--display); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: var(--gold); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 6px; }

.fm-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.fm-vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, transparent 50%, rgba(0, 0, 0, 0.62) 100%), linear-gradient(180deg, rgba(6, 5, 10, 0.5) 0%, transparent 14%, transparent 52%, rgba(6, 5, 10, 0.9) 100%); }

.fm-top { position: fixed; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: max(1rem, env(safe-area-inset-top)) 1.25rem 0; }
.fm-brand { margin: 0; font-weight: 400; font-size: 0.72rem; letter-spacing: 0.42em; text-transform: uppercase; color: var(--muted); font-family: var(--ui); }
.fm-link { font-family: var(--ui); font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); text-decoration: none; border-bottom: 1px solid transparent; padding-bottom: 2px; transition: color 0.3s, border-color 0.3s; white-space: nowrap; }
.fm-link:hover { color: var(--gold); border-color: rgba(200, 164, 92, 0.5); }

/* The rail: where in the story you are. */
.fm-rail { position: fixed; z-index: 3; right: 1.1rem; top: 50%; transform: translateY(-50%); }
.fm-rail ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; position: relative; }
.fm-rail a { display: grid; place-items: center; width: 1.5rem; height: 1.5rem; }
.fm-rail a::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); opacity: 0.6; transition: transform 0.4s, background 0.4s, opacity 0.4s, box-shadow 0.4s; }
.fm-rail a:hover::before { opacity: 1; background: var(--gold-soft); }
.fm-rail a[aria-current='true']::before { background: var(--gold-soft); opacity: 1; transform: scale(1.8); box-shadow: 0 0 12px rgba(230, 207, 152, 0.9); }
.fm-rail-line { position: absolute; left: 50%; top: 0.75rem; bottom: 0.75rem; width: 1px; margin-left: -0.5px; background: rgba(168, 160, 145, 0.25); }
.fm-rail-line i { position: absolute; inset: 0; background: var(--gold); transform-origin: top; transform: scaleY(0); }

/* Chapters. Each is a tall stretch of page; its words ride along at the same height while it passes. */
.ch { position: relative; height: 170vh; pointer-events: none; }
.ch:last-child { height: 100vh; height: 100svh; }
.ch-text { position: sticky; top: 69vh; max-width: 33rem; margin: 0 auto; padding: 0 3rem 0 1.5rem; text-align: center; opacity: var(--o, 1); transform: translateY(calc((1 - var(--o, 1)) * 14px)); }
.ch.on .ch-text { pointer-events: auto; }
.ch-num { margin: 0; font-family: var(--ui); font-size: 0.7rem; letter-spacing: 0.4em; color: var(--gold); }
.ch h2 { margin: 0.4rem 0 0.4rem; font-weight: 400; font-size: clamp(1.9rem, 5.4vw, 3rem); line-height: 1.08; letter-spacing: 0.01em; text-shadow: 0 2px 30px rgba(0, 0, 0, 0.9), 0 0 30px rgba(200, 164, 92, 0.2); }
.ch-line { margin: 0; font-style: italic; font-size: clamp(1.02rem, 2.4vw, 1.2rem); line-height: 1.5; color: #cfc7b6; text-wrap: balance; text-shadow: 0 1px 14px rgba(0, 0, 0, 0.95); }
.ch-cta { margin: 1.1rem 0 0; }
.ch-cta a { display: inline-block; font-family: var(--ui); font-size: 0.78rem; letter-spacing: 0.24em; text-transform: uppercase; text-decoration: none; color: #14110c; background: var(--gold); padding: 0.75rem 1.6rem; border-radius: 9999px; transition: background 0.3s, box-shadow 0.3s, transform 0.3s; }
.ch-cta a:hover { background: var(--gold-soft); box-shadow: 0 0 34px -4px rgba(230, 207, 152, 0.7); transform: translateY(-2px); }

.fm-hint { position: fixed; z-index: 3; left: 50%; bottom: max(1.2rem, env(safe-area-inset-bottom)); transform: translateX(-50%); margin: 0; font-family: var(--ui); font-size: 0.66rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); display: grid; justify-items: center; gap: 0.5rem; transition: opacity 0.8s; }
.fm-hint span { width: 1px; height: 26px; background: linear-gradient(var(--gold), transparent); animation: fm-drip 1.8s ease-in-out infinite; transform-origin: top; }
@keyframes fm-drip { 0% { transform: scaleY(0); } 60% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }
.fm-hint.gone { opacity: 0; }

/* Without WebGL (or without JavaScript) the chapters are simply a page to read. */
html.fm-flat .fm-canvas, html:not(.js) .fm-canvas { display: none; }
html.fm-flat body, html:not(.js) body { background: radial-gradient(ellipse at 50% 0%, #17130e, var(--bg) 60%) fixed; }
html.fm-flat .ch, html:not(.js) .ch, html.fm-flat .ch:last-child, html:not(.js) .ch:last-child { height: auto; padding: 5rem 0; pointer-events: auto; }
html.fm-flat .ch-text, html:not(.js) .ch-text { position: static; }
html.fm-flat .fm-hint, html:not(.js) .fm-hint, html.fm-flat .fm-rail-line, html:not(.js) .fm-rail-line { display: none; }

@media (max-width: 600px) {
  .fm-brand { display: none; }
  .fm-rail { right: 0.35rem; }
  .ch-text { top: 66vh; padding: 0 2.4rem 0 1.2rem; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .fm-hint span { animation: none; } }
