/* app.css — night-exhibit chrome */
@font-face {
  font-family: 'Fraunces';
  src: url('fonts/fraunces-var.woff2') format('woff2-variations');
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Fraunces';
  src: url('fonts/fraunces-var-italic.woff2') format('woff2-variations');
  font-weight: 100 900; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Instrument';
  src: url('fonts/instrument-400.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Instrument';
  src: url('fonts/instrument-500.woff2') format('woff2');
  font-weight: 500; font-display: swap;
}
@font-face {
  font-family: 'Instrument';
  src: url('fonts/instrument-600.woff2') format('woff2');
  font-weight: 600; font-display: swap;
}

:root {
  --ink: #e9e4d8;
  --ink-dim: #b3ac9c;
  --ink-faint: #7e7868;
  --panel: rgba(10, 14, 18, 0.72);
  --panel-solid: #0d1116;
  --edge: rgba(233, 228, 216, 0.14);
  --accent: #d8b26a;
  --accent-dim: #9c7f4a;
  --cool: #8fb6d8;
  --us: #7fd0ff;
  --warn: #d88a7a;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Instrument', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: auto; }
html, body { margin: 0; padding: 0; background: #05080d; }
body {
  font-family: var(--sans); color: var(--ink);
  font-size: 15.5px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: rgba(216, 178, 106, 0.35); }

#app { position: fixed; inset: 0; z-index: 0; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
#gl:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

#scrolltrack { position: relative; z-index: -1; pointer-events: none; }

/* ---------- veil / loading ---------- */
#veil {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 90% at 50% 60%, #0a1119 0%, #05080d 70%);
  transition: opacity 1.1s ease, visibility 1.1s;
  text-align: center; padding: 24px;
}
#veil.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.veil-kicker { font-family: var(--sans); font-size: 13px; letter-spacing: 0.42em; text-transform: uppercase; color: var(--accent); }
.veil-title { font-family: var(--serif); font-weight: 300; font-size: clamp(56px, 12vw, 128px); letter-spacing: 0.08em; margin: 10px 0 4px; color: var(--ink); }
.veil-sub { font-family: var(--serif); font-style: italic; font-size: clamp(16px, 2.6vw, 22px); color: var(--ink-dim); margin-bottom: 34px; }
.veil-load { font-size: 13px; color: var(--ink-faint); letter-spacing: 0.06em; min-height: 20px; }
.veil-load .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 8px; animation: pulse 1.4s infinite; vertical-align: 1px; }
@keyframes pulse { 0%,100% { opacity: 0.25; } 50% { opacity: 1; } }
.enter-btn {
  font-family: var(--serif); font-size: 19px; font-style: italic;
  color: var(--ink); background: transparent; border: 1px solid var(--edge);
  padding: 13px 34px; border-radius: 40px; cursor: pointer; margin-top: 8px;
  transition: border-color .3s, background .3s, transform .3s;
}
.enter-btn:hover, .enter-btn:focus-visible { border-color: var(--accent); background: rgba(216,178,106,0.08); transform: translateY(-1px); }
.veil-hint { margin-top: 30px; font-size: 12px; letter-spacing: 0.14em; color: var(--ink-faint); }

/* ---------- nofx fallback ---------- */
#nofx { position: fixed; inset: 0; z-index: 70; overflow: auto; background: #05080d; padding: 6vh 6vw; }
.nofx-card { max-width: 720px; margin: 0 auto; }
.nofx-card h2 { font-family: var(--serif); font-weight: 400; }
.nofx-card p, .nofx-card li { color: var(--ink-dim); }

/* ---------- trail nav ---------- */
#trail {
  position: fixed; left: 18px; top: 50%; transform: translateY(-50%);
  z-index: 30; display: flex; flex-direction: column; gap: 2px;
}
.trail-dot {
  display: flex; align-items: center; gap: 9px; border: 0; background: none;
  padding: 5px 6px; cursor: pointer; text-align: left; color: var(--ink-faint);
  font-family: var(--sans); font-size: 11.5px; letter-spacing: 0.08em;
  transition: color .25s;
  -webkit-tap-highlight-color: transparent;
}
.trail-dot .pip {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  border: 1px solid var(--ink-faint); background: transparent; transition: all .3s;
}
.trail-dot .nm { opacity: 0; transform: translateX(-4px); transition: all .25s; white-space: nowrap; }
.trail-dot:hover .nm, .trail-dot:focus-visible .nm, .trail-dot.on .nm { opacity: 1; transform: none; }
.trail-dot.on { color: var(--accent); }
.trail-dot.on .pip { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 10px rgba(216,178,106,0.5); }
.trail-dot:focus-visible { outline: 1px solid var(--accent); border-radius: 4px; }

/* ---------- chapter panel ---------- */
#chapter-panel {
  position: fixed; z-index: 25;
  right: clamp(14px, 3.5vw, 54px); top: 50%; transform: translateY(-50%);
  width: min(400px, 42vw);
  max-height: 82vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--edge); border-radius: 14px;
  padding: 26px 26px 20px;
  opacity: 0; transition: opacity .5s ease;
  scrollbar-width: thin; scrollbar-color: var(--edge) transparent;
}
#chapter-panel.show { opacity: 1; }
#chapter-panel .kicker { font-size: 11px; letter-spacing: 0.34em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
#chapter-panel h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(24px, 3vw, 32px); line-height: 1.15; margin: 0 0 14px; }
#chapter-panel h2 em { font-style: italic; color: var(--accent); }
#chapter-panel p { margin: 0 0 12px; color: var(--ink-dim); }
#chapter-panel p b, #chapter-panel li b { color: var(--ink); font-weight: 600; }
#chapter-panel .fine { font-size: 12.5px; color: var(--ink-faint); }
#chapter-panel ul { margin: 0 0 12px; padding-left: 18px; color: var(--ink-dim); }
#chapter-panel li { margin-bottom: 6px; }
#chapter-panel em { color: var(--ink); }

.stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.stat {
  border: 1px solid var(--edge); border-radius: 10px; padding: 8px 12px;
  background: rgba(255,255,255,0.02); min-width: 30%;
}
.stat .v { font-family: var(--serif); font-size: 21px; color: var(--ink); line-height: 1.15; }
.stat .k { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); margin-top: 2px; }

.fn { display: inline-block; font-size: 10px; color: var(--accent); vertical-align: super; cursor: pointer; padding: 1px 3px; border-radius: 3px; line-height: 1; }
.fn:hover, .fn:focus-visible { background: rgba(216,178,106,0.2); outline: none; }

.fieldnote { margin: 12px 0; border-left: 2px solid var(--accent-dim); padding: 2px 0 2px 14px; }
.fieldnote summary { cursor: pointer; font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent-dim); }
.fieldnote summary:hover, .fieldnote summary:focus-visible { color: var(--accent); }
.fieldnote p { font-size: 13.5px; margin-top: 8px; }

/* in-panel interactive controls */
.ctl { margin: 16px 0 6px; }
.ctl-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.act {
  font-family: var(--sans); font-size: 13px; letter-spacing: 0.04em;
  color: var(--ink); background: rgba(255,255,255,0.04); border: 1px solid var(--edge);
  padding: 9px 16px; border-radius: 24px; cursor: pointer;
  transition: all .25s; -webkit-tap-highlight-color: transparent;
}
.act:hover { border-color: var(--accent); background: rgba(216,178,106,0.10); }
.act:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.act:active { transform: scale(0.97); }
.act[disabled] { opacity: 0.4; cursor: default; }
.act.on { border-color: var(--accent); color: var(--accent); background: rgba(216,178,106,0.12); }
.act.us { border-color: rgba(127,208,255,0.4); }
.act.us:hover, .act.us.on { border-color: var(--us); color: var(--us); background: rgba(127,208,255,0.10); }

.dial-wrap { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.dial { position: relative; width: 84px; height: 84px; border-radius: 50%; border: 1px solid var(--edge); flex: none; }
.dial .needle { position: absolute; left: 50%; top: 50%; width: 2px; height: 34px; background: var(--accent); transform-origin: 50% 0; }
.dial .zero { position: absolute; left: 50%; top: 4px; width: 1px; height: 8px; background: var(--ink-faint); transform: translateX(-50%); }
.dial .lab { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font-size: 10.5px; color: var(--ink-faint); letter-spacing: 0.1em; }
input[type="range"].slide {
  -webkit-appearance: none; appearance: none; flex: 1; height: 26px; background: transparent; cursor: pointer;
}
.slide::-webkit-slider-runnable-track { height: 2px; background: var(--edge); border-radius: 2px; }
.slide::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); margin-top: -8px; border: 3px solid #141a20;
}
.slide::-moz-range-track { height: 2px; background: var(--edge); }
.slide::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid #141a20; }
.slide:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }

.seg { display: flex; border: 1px solid var(--edge); border-radius: 10px; overflow: hidden; margin-top: 10px; }
.seg button {
  flex: 1; background: none; border: 0; color: var(--ink-faint); font-family: var(--sans);
  font-size: 11.5px; letter-spacing: 0.05em; padding: 9px 4px; cursor: pointer; transition: all .25s;
}
.seg button + button { border-left: 1px solid var(--edge); }
.seg button.on { background: rgba(216,178,106,0.14); color: var(--accent); }
.seg button:focus-visible { outline: 1px solid var(--accent); outline-offset: -2px; }

/* spectrum chart */
.spectrum { width: 100%; height: 150px; display: block; margin-top: 10px; border: 1px solid var(--edge); border-radius: 10px; background: rgba(0,0,0,0.3); }

/* timeline */
.timeline { margin-top: 10px; }
.tl-track { position: relative; height: 54px; border: 1px solid var(--edge); border-radius: 10px; background: linear-gradient(90deg, #1a1e2e 0%, #0b1020 35%, #060a14 55%, #0b1020 80%, #262031 100%); overflow: hidden; }
.tl-mark { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--edge); }
.tl-dot { position: absolute; top: 50%; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); transform: translate(-50%,-50%); box-shadow: 0 0 8px rgba(216,178,106,0.7); }
.tl-cap { position: absolute; bottom: 5px; transform: translateX(-50%); font-size: 9.5px; letter-spacing: .06em; color: var(--ink-faint); white-space: nowrap; }
.tl-cap.above { bottom: auto; top: 5px; }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: .8; }

/* map */
.islemap { width: 100%; height: auto; display: block; margin-top: 12px; }
.islemap .isle { fill: #2c3a2a; stroke: #57704e; stroke-width: 1.2; cursor: pointer; transition: fill .25s; }
.islemap .isle:hover, .islemap .isle:focus-visible { fill: #41573c; outline: none; }
.islemap .isle.hot { fill: #4d6a41; stroke: var(--accent); }
.islemap text { font-family: var(--sans); font-size: 8.5px; fill: var(--ink-dim); letter-spacing: .08em; pointer-events: none; }
.islemap .cap { font-size: 7.5px; fill: var(--ink-faint); }

/* ---------- 3D labels ---------- */
#labels { position: fixed; inset: 0; z-index: 20; pointer-events: none; overflow: hidden; }
#leaders { position: fixed; inset: 0; z-index: 19; pointer-events: none; }
.tag {
  position: absolute; transform: translate(-50%, -50%);
  background: rgba(8, 12, 16, 0.82); border: 1px solid var(--edge);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-radius: 8px; padding: 6px 10px; max-width: 210px;
  font-size: 11.5px; line-height: 1.35; color: var(--ink-dim);
  opacity: 0; transition: opacity .4s ease;
  pointer-events: auto; cursor: pointer;
}
.tag.vis { opacity: 1; }
.tag .t { display: block; font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); margin-bottom: 2px; }
.tag .more { display: none; margin-top: 5px; font-size: 11px; color: var(--ink-faint); }
.tag.open .more { display: block; }
.tag:hover, .tag:focus-visible { border-color: var(--accent-dim); }
.tag b { color: var(--ink); font-weight: 600; }

/* ---------- hud ---------- */
#hud { position: fixed; top: 16px; right: 16px; z-index: 40; display: flex; gap: 8px; }
.hud-btn {
  display: flex; align-items: center; gap: 7px;
  background: var(--panel); border: 1px solid var(--edge); color: var(--ink-dim);
  border-radius: 20px; padding: 8px 14px; font-family: var(--sans); font-size: 12px;
  letter-spacing: 0.06em; cursor: pointer; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: all .25s;
}
.hud-btn .ic { font-size: 14px; }
.hud-btn:hover { color: var(--ink); border-color: var(--accent-dim); }
.hud-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent-dim); background: rgba(216,178,106,0.10); }
.hud-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#controls-pop {
  position: fixed; top: 62px; right: 16px; z-index: 41; width: 300px;
  background: var(--panel-solid); border: 1px solid var(--edge); border-radius: 12px;
  padding: 18px 20px; backdrop-filter: blur(14px);
}
#controls-pop h3 { font-family: var(--serif); font-weight: 400; font-size: 18px; margin: 0 0 10px; }
#controls-pop ul { margin: 0; padding-left: 16px; }
#controls-pop li { font-size: 12.5px; color: var(--ink-dim); margin-bottom: 6px; }
#controls-pop b { color: var(--ink); font-weight: 500; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  z-index: 45; background: rgba(10,14,18,0.9); border: 1px solid var(--edge);
  color: var(--ink-dim); font-size: 12.5px; letter-spacing: 0.04em;
  padding: 10px 18px; border-radius: 24px; opacity: 0; transition: all .4s ease;
  pointer-events: none; max-width: 84vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- progress ---------- */
#progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 50; background: rgba(255,255,255,0.04); }
#progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-dim), var(--accent)); }

/* ---------- scroll cue ---------- */
.scroll-cue {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 30; display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--ink-faint); font-size: 10.5px; letter-spacing: 0.22em; text-transform: uppercase;
  pointer-events: none; transition: opacity .6s ease;
}
.scroll-cue i {
  width: 1px; height: 26px; background: linear-gradient(var(--accent), transparent);
  animation: cueDrop 2.2s ease-in-out infinite;
}
@keyframes cueDrop { 0% { transform: scaleY(0); transform-origin: top; } 55% { transform: scaleY(1); transform-origin: top; } 100% { opacity: 0; } }
body.scrolled .scroll-cue { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .scroll-cue i { animation: none; } }

/* ---------- footnote popover ---------- */
.src-pop {
  position: fixed; z-index: 55; max-width: 300px;
  background: var(--panel-solid); border: 1px solid var(--edge); border-radius: 10px;
  padding: 12px 14px; font-size: 12px; color: var(--ink-dim); line-height: 1.45;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.src-pop .st { color: var(--accent); font-size: 10px; letter-spacing: .2em; text-transform: uppercase; display: block; margin-bottom: 4px; }

.skip { position: fixed; left: -999px; top: 8px; z-index: 80; background: var(--panel-solid); color: var(--ink); padding: 10px 16px; border-radius: 8px; border: 1px solid var(--accent); }
.skip:focus { left: 8px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  body { font-size: 15px; }
  #trail { left: 8px; gap: 0; }
  .trail-dot { padding: 7px 5px; }
  .trail-dot .nm { display: none; }
  #chapter-panel {
    right: 10px; left: 10px; top: auto; bottom: calc(10px + env(safe-area-inset-bottom));
    transform: none; width: auto; max-height: 46vh; padding: 18px 18px 14px;
  }
  #hud { top: 10px; right: 10px; }
  .hud-btn .lbl { display: none; }
  .hud-btn { padding: 9px 11px; }
  .tag { max-width: 160px; font-size: 10.5px; }
  #controls-pop { right: 10px; left: 10px; width: auto; top: 56px; }
}
@media (max-width: 760px) and (orientation: landscape) {
  #chapter-panel { max-height: 58vh; width: min(420px, 52vw); left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  #veil { transition: none; }
  .veil-load .dot { animation: none; }
}
