:root {
  color-scheme: dark;
  --paper: #efeee7;
  --muted: #a8acae;
  --accent: #ff865b;
  --background: #07090d;
  font-family: 'Space Grotesk', sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scrollbar-color: #555b61 var(--background); }
body { margin: 0; color: var(--paper); background: var(--background); }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
a { color: inherit; text-underline-offset: 6px; }
button:disabled { opacity: .3; cursor: default; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }
::selection { background: var(--accent); color: var(--background); }
[hidden] { display: none !important; }
.skip-link { position: fixed; top: -100px; left: 24px; z-index: 100; padding: 14px; background: var(--paper); color: var(--background); }
.skip-link:focus { top: 16px; }

.universe { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#universe-canvas { width: 100%; height: 100%; display: block; opacity: .98; }
.universe-shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(7,9,13,.36), transparent 58%), linear-gradient(0deg, #07090d 0%, transparent 20%, transparent 90%, #07090d 100%); }
.universe-grain { position: absolute; inset: 0; opacity: .035; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath fill='%23fff' filter='url(%23n)' d='M0 0h180v180H0z'/%3E%3C/svg%3E"); }
.orbit-label { position: absolute; bottom: 20%; left: 65%; max-width: 28%; display: flex; align-items: flex-start; gap: 12px; color: #aeb4ba; font: 11px/1.7 'DM Mono', monospace; letter-spacing: .02em; }
.orbit-cross { color: var(--accent); font-size: 20px; line-height: 1; }

.story-header { position: fixed; z-index: 20; top: 0; left: 0; right: 0; min-height: 100px; padding: 20px 4.5vw; display: flex; align-items: center; gap: 36px; background: linear-gradient(#07090df0, #07090d00); }
.wordmark { font-size: 28px; font-weight: 600; letter-spacing: -2px; text-decoration: none; }
.wordmark span { color: var(--accent); }
.header-note { color: #939a9f; font: 11px/1.5 'DM Mono', monospace; }
.header-actions { display: flex; align-items: center; gap: 28px; margin-left: auto; }
.header-actions a, .header-actions button { font-size: 12px; text-decoration: none; }
.header-actions button { background: transparent; border: 0; border-bottom: 1px solid #606467; padding: 7px 0; color: #b4b9bd; cursor: pointer; }
.exit-link span { display: inline-block; margin-left: 10px; color: var(--accent); }

.chapter { position: relative; min-height: max(800px, 110svh); display: flex; flex-direction: column; justify-content: center; padding: 150px 8vw 180px; isolation: isolate; }
.chapter-content { width: min(100%, 680px); }
.chapter-content > * { position: relative; }
.eyebrow { margin: 0 0 30px; color: var(--accent); font: 11px/1.6 'DM Mono', monospace; letter-spacing: .09em; text-transform: uppercase; }
.live-dot { display: inline-block; width: 6px; height: 6px; margin-right: 9px; margin-bottom: 1px; border-radius: 50%; background: currentColor; box-shadow: 0 0 15px currentColor; }
h1, h2 { margin: 0; font-size: clamp(64px, 6.8vw, 110px); line-height: 1.02; font-weight: 400; letter-spacing: -.065em; }
h1 { font-size: clamp(80px, 8.6vw, 140px); }
h1 em, h2 em { font-family: 'Instrument Serif', Georgia, serif; font-weight: 400; letter-spacing: -.045em; }
.chapter-prose { max-width: 460px; margin-top: 32px; }
.chapter-prose p { margin: 0 0 14px; color: #b5b9bb; font-size: 17px; line-height: 1.75; font-weight: 400; letter-spacing: -.015em; }
.chapter-prose p:last-child { margin-bottom: 0; }
.chapter-prose .aside-note { font-size: 15px; color: #a9a5a0; }
.handwritten { margin: 24px 0 0; color: var(--accent); font: italic 27px/1.3 'Instrument Serif', Georgia, serif; }
.begin-link { display: inline-flex; align-items: center; gap: 24px; margin-top: 38px; text-decoration: none; font-size: 13px; }
.begin-link span { display: grid; width: 37px; height: 37px; place-items: center; border: 1px solid #77736c; border-radius: 50%; color: var(--accent); transition: transform .2s; }
.begin-link:hover span { transform: translateY(4px); }
.inline-link { display: inline-flex; gap: 24px; margin-top: 25px; font-size: 13px; text-decoration: none; border-bottom: 1px solid #5f6365; padding-bottom: 8px; }
.inline-link span { color: var(--accent); }
.scene-footnote { position: absolute; left: 8vw; bottom: 110px; color: #8b9399; font: 10px/1.6 'DM Mono', monospace; letter-spacing: .02em; }
.course-notes { display: flex; flex-wrap: wrap; gap: 8px 18px; max-width: 430px; margin-top: 26px; font: 11px/1.5 'DM Mono', monospace; color: var(--accent); }
.course-notes span::before { content: '↳'; margin-right: 6px; opacity: .55; }
.signature { display: flex; align-items: center; gap: 17px; margin-top: 28px; }
.signature img { border-radius: 50%; object-fit: cover; filter: grayscale(1); }
.signature > span { font: italic 27px/1.1 'Instrument Serif', Georgia, serif; }
.signature > span > span { display: block; margin-top: 6px; font: 11px/1.5 'DM Mono', monospace; color: #979d9e; }
.closing-links { display: flex; flex-wrap: wrap; gap: 0 25px; }

.journey-dock { position: fixed; z-index: 30; left: 4.5vw; right: 4.5vw; bottom: 0; height: 86px; display: flex; align-items: center; gap: 42px; border-top: 1px solid #ffffff24; background: linear-gradient(#07090d99, #07090df0 60%); backdrop-filter: blur(12px); }
.journey-status { flex-shrink: 0; display: flex; align-items: center; gap: 8px; font: 11px/1.5 'DM Mono', monospace; color: #939b9f; }
#chapter-number { color: var(--accent); }
#chapter-name { min-width: 100px; margin-left: 24px; color: #c6c8c6; }
.status-divider { color: #767e84; }
.journey-stops { display: flex; align-items: center; justify-content: space-between; flex: 1; margin: 0; padding: 0; list-style: none; }
.journey-stops li { position: relative; flex: 1; }
.journey-stops li:not(:last-child)::after { content: ''; position: absolute; top: 50%; left: 50%; width: 100%; height: 1px; background: #4e586144; pointer-events: none; }
.journey-stops a { position: relative; z-index: 1; display: grid; min-width: 30px; height: 44px; place-items: center; text-decoration: none; }
.journey-stops a > span { width: 5px; height: 5px; border-radius: 50%; background: #7e898f; transition: background .4s, box-shadow .4s, transform .4s; }
.journey-stops a.visited > span { background: var(--accent); opacity: .7; }
.journey-stops a[aria-current] > span { background: var(--accent); box-shadow: 0 0 0 5px #07090d, 0 0 0 6px var(--accent), 0 0 22px var(--accent); transform: scale(1.15); }
.journey-stops a::after { content: attr(data-label); position: absolute; bottom: 46px; left: 50%; transform: translate(-50%, 4px); padding: 5px 8px; opacity: 0; white-space: nowrap; font: 10px/1.5 'DM Mono', monospace; background: #11161d; color: var(--paper); pointer-events: none; transition: .2s; }
.journey-stops a:hover::after, .journey-stops a:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
.journey-arrows { display: flex; gap: 8px; }
.journey-arrows button { border: 1px solid #58616970; border-radius: 50%; width: 39px; height: 39px; background: transparent; font-size: 18px; cursor: pointer; }
.journey-arrows button:not(:disabled):hover { color: var(--accent); border-color: var(--accent); }

/* The complete story remains readable if JavaScript or canvas is unavailable. */
body:not(.has-canvas) .universe { background: radial-gradient(ellipse at 80% 40%, #34465550, transparent 50%); }
body:not(.has-canvas) .orbit-label { display: none; }
.reading-view .universe { display: none; }
.reading-view .chapter { min-height: 0; padding: 70px 24px; max-width: 790px; margin: 0 auto; border-bottom: 1px solid #ffffff14; }
.reading-view .chapter:first-child { padding-top: 170px; }
.reading-view .chapter:last-child { padding-bottom: 150px; }
.reading-view h1 { font-size: clamp(54px, 9vw, 90px); }
.reading-view h2 { font-size: clamp(44px, 7vw, 68px); }
.reading-view .chapter-prose { max-width: 590px; }
.reading-view .scene-footnote { position: static; display: block; margin-top: 34px; }
.reading-view .eyebrow { margin-bottom: 18px; }
.reading-view .story-header { background: #07090df5; }

@media (min-width: 1800px) { .chapter { padding-left: calc((100vw - 1510px) / 2); } }
@media (max-width: 1100px) {
  .header-note { display: none; }
  .chapter { padding-left: 6vw; }
  .chapter-content { max-width: 610px; }
  .scene-footnote { left: 6vw; }
  .journey-dock { gap: 20px; }
  #chapter-name { display: none; }
  .orbit-label { left: 68%; font-size: 10px; }
}
@media (max-width: 760px) {
  .story-header { min-height: 76px; padding: 16px 6vw; gap: 12px; }
  .wordmark { font-size: 25px; }
  .header-actions { gap: 20px; }
  .header-actions a, .header-actions button { font-size: 11px; }
  .exit-link { font-size: 0 !important; }
  .exit-link span { font-size: 20px; margin: 0; }
  .chapter { min-height: max(860px, 115svh); justify-content: flex-end; padding: 330px 7vw 160px; }
  .chapter-opening { min-height: max(820px, 108svh); }
  h1 { font-size: clamp(65px, 16vw, 108px); }
  h2 { font-size: clamp(52px, 12.8vw, 82px); }
  .chapter-content { max-width: 590px; }
  .chapter-prose { max-width: 470px; margin-top: 25px; }
  .chapter-prose p { font-size: 16px; line-height: 1.7; }
  .eyebrow { font-size: 10px; margin-bottom: 22px; }
  .handwritten { font-size: 24px; }
  .universe-shade { background: linear-gradient(0deg, #07090d 0%, #07090dee 35%, #07090d80 65%, transparent 85%, #07090d88 100%); }
  .orbit-label { display: none; }
  .scene-footnote { bottom: 94px; left: 7vw; right: 7vw; font-size: 9px; }
  .journey-dock { left: 6vw; right: 6vw; height: 68px; gap: 12px; }
  .journey-status { font-size: 10px; gap: 4px; }
  .journey-stops a { min-width: 0; height: 42px; }
  .journey-stops a > span { width: 3px; height: 3px; }
  .journey-stops a[aria-current] > span { box-shadow: 0 0 0 4px #07090d, 0 0 0 5px var(--accent); }
  .journey-stops a::after { display: none; }
  .journey-arrows { gap: 5px; }
  .journey-arrows button { width: 30px; height: 30px; font-size: 15px; }
  .journey-arrows #previous-chapter { display: none; }
  .reading-view .chapter { padding-left: 7vw; padding-right: 7vw; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
@media print {
  :root { color-scheme: light; }
  body { background: white; color: black; }
  .universe, .story-header, .journey-dock, .skip-link, .begin-link { display: none !important; }
  .chapter { min-height: 0 !important; padding: 30px 0 !important; break-inside: avoid; }
  h1, h2 { font-size: 38pt !important; }
  .chapter-prose p, .eyebrow, .handwritten { color: #333; }
  .scene-footnote { position: static; display: block; margin-top: 20px; color: #555; }
}
