/* Printed-sheet look: warm white paper, near-black architectural ink, oxidized red for annotations.
   Layout: fixed full-bleed canvas; masthead top-left, sheet box top-right, note bottom-left; the page scroll is the timeline.
   The page is a drawing on paper in both colour schemes, so it stays light (the sheet is the subject). */
:root {
  --paper: #f3efe7; --paper-2: #ebe6dc; --ink: #17181a; --ink-soft: #55565a; --oxide: #9c3a22; --card: #f8f6f1ee; --rule: #17181a33;
  --f-serif: "Instrument Serif", "Iowan Old Style", Georgia, serif; --f-ui: "Instrument Sans", "Helvetica Neue", Arial, sans-serif; --f-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --card: #f8f6f1f4; } }
:root[data-theme="dark"] { --card: #f8f6f1f4; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--paper); }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 15px/1.5 var(--f-ui); overflow-x: hidden; }
#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
#track { position: relative; width: 1px; pointer-events: none; }
#grain { position: fixed; inset: 0; pointer-events: none; z-index: 2; opacity: .14; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .33 0 0 0 0 .3 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E"); }

#sheet { position: fixed; inset: 0; pointer-events: none; z-index: 5;
  padding: calc(18px + env(safe-area-inset-top, 0px)) max(18px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  display: grid; grid-template: "mast box" auto "note ." 1fr / minmax(0, 1fr) auto; gap: 14px; }
.mast { grid-area: mast; align-self: start; min-width: 0; text-shadow: 0 0 6px var(--paper), 0 0 12px var(--paper), 0 0 2px var(--paper); }
.mast h1 { font: 400 clamp(34px, 5.6vw, 66px)/.92 var(--f-serif); letter-spacing: -.01em; margin: 0; }
.mast h1 i { color: var(--oxide); }
.mast p { font: 500 10.5px/1.55 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); margin: 10px 0 0; }
.box { grid-area: box; align-self: start; pointer-events: auto; border: 1px solid var(--ink); background: var(--card); width: min(224px, 46vw); }
.box .no { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 10px; border-bottom: 1px solid var(--ink); font: 500 10.5px var(--f-mono); letter-spacing: .1em; text-transform: uppercase; }
#navBtn { display: none; }
.box .no b { font: 400 22px/1 var(--f-serif); letter-spacing: 0; color: var(--oxide); }
.box ol { list-style: none; margin: 0; padding: 4px 0; }
.box button, .box a { all: unset; box-sizing: border-box; display: flex; gap: 10px; width: 100%; padding: 4px 10px; cursor: pointer; font: 500 12.5px/1.3 var(--f-ui); color: var(--ink); }
.box li span { font: 400 10.5px/1.5 var(--f-mono); color: var(--ink-soft); width: 2ch; }
.box button:hover, .box a:hover, .box button:focus-visible, .box a:focus-visible { background: #17181912; }
.box button:focus-visible, .box a:focus-visible, button:focus-visible { outline: 2px solid var(--oxide); outline-offset: -2px; }
.box button[aria-current="true"], .box button[aria-current="true"] span { color: var(--oxide); }
.box .ctl { border-top: 1px solid var(--rule); padding: 4px 0; }
.box .ctl button { font: 500 10.5px var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
.box .ctl button::before { content: ""; width: 9px; height: 9px; border: 1px solid currentColor; margin-top: 2px; flex: none; }
.box .ctl button[aria-pressed="true"] { color: var(--oxide); }
.box .ctl button[aria-pressed="true"]::before { background: currentColor; }
#note { grid-area: note; align-self: end; pointer-events: auto; max-width: min(410px, 100%); background: var(--card); border-left: 2px solid var(--oxide); padding: 14px 16px 15px; transition: opacity .3s, transform .3s; }
#note[data-off="true"] { opacity: 0; transform: translateY(8px); pointer-events: none; }
#note .idx, dialog .idx { font: 500 10.5px var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--oxide); }
#note h2 { font: 400 31px/1.04 var(--f-serif); margin: 6px 0 6px; text-wrap: balance; }
#note p { font: 400 14px/1.5 var(--f-ui); color: var(--ink-soft); margin: 0; max-width: 46ch; }
.file { margin-top: 10px; font: 500 11px var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink); background: none; border: 1px solid var(--ink); padding: 6px 10px; cursor: pointer; }
.file:hover { background: var(--ink); color: var(--paper); }
#fine { position: fixed; right: max(18px, env(safe-area-inset-right, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 5; font: 400 10px/1.4 var(--f-mono); letter-spacing: .05em; color: var(--ink-soft); text-align: right; max-width: 42ch; pointer-events: none; text-shadow: 0 0 3px var(--paper), 0 0 6px var(--paper); }

#marks { position: fixed; z-index: 4; right: max(18px, env(safe-area-inset-right, 0px)); bottom: 92px; display: flex; align-items: end; gap: 18px; color: var(--ink); transition: opacity .3s; pointer-events: none; }
#marks[data-on="false"] { opacity: 0; }
#north { display: block; transition: transform .1s linear; }
.scale { display: grid; gap: 4px; font: 400 10px var(--f-mono); letter-spacing: .06em; white-space: pre; }
#scaleBar { height: 6px; border: 1px solid var(--ink); display: grid; grid-template-columns: 1fr 1fr; }
#scaleBar i:first-child { background: var(--ink); }

#slow { position: fixed; z-index: 9; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--card); border: 1px solid var(--ink); padding: 18px 20px; display: grid; gap: 10px; justify-items: start; font: 400 14px var(--f-ui); max-width: calc(100vw - 32px); }
#slow p { margin: 0; }
#slow button, #slow a, #reloadBtn, dialog button { font: 500 11px var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink); background: none; border: 1px solid var(--ink); padding: 7px 10px; cursor: pointer; text-decoration: none; }

dialog { border: 1px solid var(--ink); background: var(--paper); color: var(--ink); padding: 20px 22px; max-width: min(460px, calc(100vw - 32px)); width: 100%; }
dialog::backdrop { background: #17181a55; }
dialog h2 { font: 400 30px/1.05 var(--f-serif); margin: 6px 0 12px; }
dialog dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 14px; font-size: 14px; }
dialog dt { font: 500 10.5px/1.9 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
dialog dd { margin: 0; }
dialog .src { font-size: 12px; color: var(--ink-soft); margin: 0 0 14px; }

/* static reading (stills): reduced motion, no WebGL, or lost context */
#static { display: none; }
body[data-mode="stills"] #gl, body[data-mode="stills"] #note, body[data-mode="stills"] #marks, body[data-mode="stills"] #track, body[data-mode="stills"] .ctl { display: none; }
body[data-mode="stills"] #sheet { position: relative; grid-template: "mast box" auto / minmax(0, 1fr) auto; }
body[data-mode="stills"] .box { position: sticky; top: 18px; }
body[data-mode="stills"] #static { display: block; padding: 0 max(18px, env(safe-area-inset-left, 0px)) 80px; max-width: 1100px; margin: 0 auto; position: relative; z-index: 3; }
#stillsMsg { font: 500 11px var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--oxide); }
#stills { list-style: none; margin: 0; padding: 0; display: grid; gap: 48px; }
#stills figure { margin: 0; display: grid; gap: 14px; }
#stills img { width: 100%; height: auto; display: block; border: 1px solid var(--rule); background: var(--paper-2); }
#stills .noimg img { display: none; }
#stills figcaption span { font: 500 10.5px var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--oxide); }
#stills h3 { font: 400 30px/1.05 var(--f-serif); margin: 4px 0 6px; }
#stills p { margin: 0; color: var(--ink-soft); max-width: 60ch; }
#stills dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 10px 0 0; font-size: 14px; }
#stills dt { font: 500 10.5px/1.9 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
#stills dd { margin: 0; }
.nojs { position: relative; z-index: 9; padding: 120px 18px; }

@media (max-width: 640px) {
  #sheet { grid-template: "mast" auto "box" auto "note" 1fr / minmax(0, 1fr); gap: 10px; }
  .box { width: 100%; }
  .box ol { display: none; flex-wrap: wrap; }
  .box[data-open="true"] ol { display: flex; }
  .box .ctl { display: none; } .box[data-open="true"] .ctl { display: block; }
  #navBtn { display: inline-flex; width: auto; padding: 2px 8px; border: 1px solid var(--ink); font: 500 10px var(--f-mono); letter-spacing: .1em; text-transform: uppercase; margin-left: auto; margin-right: 10px; }
  body[data-mode="stills"] .box ol { display: flex; }
  .box button, .box a { width: auto; padding: 4px 7px; font-size: 12px; }
  .box li span { display: none; }
  #fine { display: none; }
  #marks { bottom: auto; top: 50%; }
  #note h2 { font-size: 26px; }
  body[data-mode="stills"] #sheet { grid-template: "mast" auto "box" auto / minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { #note, #marks { transition: none; } }

body[data-clean] #sheet, body[data-clean] #fine, body[data-clean] #marks, body[data-clean] #slow { display: none !important; }

/* photographs */
.thumbs { display: flex; gap: 6px; margin-top: 10px; }
.thumbs:empty { display: none; }
.thumbs button, .gal button { padding: 0; border: 1px solid var(--ink); background: none; cursor: zoom-in; line-height: 0; }
.thumbs img { width: 76px; height: 51px; object-fit: cover; display: block; }
.thumbs button:focus-visible, .gal button:focus-visible { outline: 2px solid var(--oxide); outline-offset: 2px; }
.gal { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0 0 14px; }
.gal:empty { display: none; }
.gal img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; display: block; }
dialog.lb { max-width: min(1100px, calc(100vw - 24px)); padding: 12px; }
.lb figure { margin: 0; }
.lb img { display: block; width: 100%; max-height: calc(100vh - 140px); object-fit: contain; background: #e9e4da; }
.lb figcaption { font: 400 14px/1.4 var(--f-ui); color: var(--ink-soft); margin: 8px 2px 10px; }
.lbnav { display: flex; gap: 8px; justify-content: flex-end; }
@media (max-width: 640px) { .thumbs img { width: 60px; height: 40px; } .gal { grid-template-columns: repeat(2, 1fr); } }
