@font-face { font-family: "Plex"; src: url("assets/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex"; src: url("assets/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex"; src: url("assets/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Atlas"; src: url("assets/fonts/eb-garamond-latin-400-italic.woff2") format("woff2"); font-style: italic; font-weight: 400; font-display: swap; }
@font-face { font-family: "Atlas"; src: url("assets/fonts/eb-garamond-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --void: #03040a;
  --plate: rgba(10, 16, 32, 0.78);
  --plate-solid: #0a1020;
  --edge: rgba(150, 175, 255, 0.16);
  --starlight: #ece6d9;
  --dim: #8d96ab;
  --near: #6fa8ff;
  --mid: #fff3dc;
  --far: #ffae4a;
  --edge-of-time: #ff4d6d;
  --spectrum: linear-gradient(90deg, var(--near) 0%, var(--mid) 33%, var(--far) 66%, var(--edge-of-time) 100%);
  --accent: var(--mid);
  --sans: "Plex", system-ui, sans-serif;
  --atlas: "Atlas", Georgia, serif;
  --gutter: max(16px, env(safe-area-inset-left));
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--void); color: var(--starlight); font: 400 15px/1.5 var(--sans); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--mid); outline-offset: 2px; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.select-ring { position: fixed; left: 0; top: 0; width: 34px; height: 34px; margin: -17px 0 0 -17px; border: 1.5px solid var(--accent); border-radius: 50%; pointer-events: none; box-shadow: 0 0 12px var(--accent); }
.map-label { position: absolute; left: 0; top: 0; font: italic 400 17px/1.1 var(--atlas); color: rgba(236, 230, 217, 0.82); white-space: nowrap; text-shadow: 0 0 8px #000, 0 0 2px #000; transform-origin: 0 50%; will-change: transform; }
.map-label.field { color: #ffd2a6; }
.map-label.planet { font-size: 16px; color: #e8f0ff; pointer-events: auto; cursor: pointer; }
.map-label.star { font-size: 15px; color: #fff1d6; }
.map-label.famous { color: #cfe2ff; pointer-events: auto; cursor: pointer; }
.map-label small { font: 400 11px var(--sans); font-style: normal; color: var(--dim); margin-left: 6px; }

.bar { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: max(12px, env(safe-area-inset-top)) var(--gutter) 12px; pointer-events: none; }
.bar > * { pointer-events: auto; }
.title { margin: 0; font: 500 24px/1 var(--atlas); letter-spacing: 0.01em; }
.bar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip { background: var(--plate); border: 1px solid var(--edge); border-radius: 999px; padding: 7px 14px; cursor: pointer; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-size: 14px; }
.chip:hover { border-color: rgba(236, 230, 217, 0.45); }
.chip[aria-pressed="true"], .chip[aria-expanded="true"] { background: var(--starlight); color: var(--void); border-color: var(--starlight); }

.panel { position: fixed; top: 64px; right: var(--gutter); width: min(320px, calc(100vw - 2 * var(--gutter))); max-height: calc(100vh - 200px); overflow: auto; background: var(--plate); border: 1px solid var(--edge); border-radius: 14px; padding: 16px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.panel h2 { font: 500 19px/1.2 var(--atlas); margin: 0 40px 8px 0; }
.panel section + section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--edge); }
.panel label { display: flex; align-items: center; gap: 10px; padding: 4px 0; cursor: pointer; }
.panel .count { margin-left: auto; color: var(--dim); font-size: 13px; }
.swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.seg { display: flex; border: 1px solid var(--edge); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; background: none; border: 0; padding: 7px 4px; cursor: pointer; font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--starlight); color: var(--void); }
.famous-list { list-style: none; margin: 0; padding: 0; }
.famous-list button { width: 100%; text-align: left; background: none; border: 0; padding: 6px 0; cursor: pointer; display: grid; gap: 1px; }
.famous-list button:hover .fname { text-decoration: underline; }
.fname { font: italic 400 17px/1.2 var(--atlas); }
.fmeta { color: var(--dim); font-size: 13px; }
.credits { color: var(--dim); font-size: 13px; }
.credits p { margin: 0 0 8px; }
.credits a { color: var(--starlight); }

.journey { position: fixed; left: var(--gutter); bottom: calc(var(--hud-h, 104px) + 12px); width: min(440px, calc(100vw - 2 * var(--gutter))); }
.journey-text { font: 400 16px/1.55 var(--sans); background: var(--plate); border: 1px solid var(--edge); border-radius: 14px; padding: 16px 18px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.journey-text h2 { font: italic 400 26px/1.15 var(--atlas); margin: 0 0 8px; }
.journey-text p { margin: 0; max-width: 62ch; }
.journey-nav { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.journey-nav .step { color: var(--dim); font-size: 13px; margin-right: auto; }

.card { position: fixed; right: var(--gutter); top: 64px; width: min(340px, calc(100vw - 2 * var(--gutter))); background: var(--plate); border: 1px solid var(--edge); border-top: 3px solid var(--accent); border-radius: 14px; padding: 16px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.card h2 { font: italic 400 23px/1.15 var(--atlas); margin: 0 30px 2px 0; }
.card .sub { color: var(--dim); font-size: 13px; margin: 0 0 12px; }
.panel .close, .card .close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 50%; background: none; border: 1px solid var(--edge); cursor: pointer; font-size: 18px; line-height: 1; }
.card figure { margin: 0 0 12px; aspect-ratio: 1; background: #000; border-radius: 10px; overflow: hidden; display: grid; place-items: center; }
.card figure img { width: 100%; height: 100%; object-fit: cover; image-rendering: auto; }
.card figure figcaption { color: var(--dim); font-size: 13px; padding: 16px; text-align: center; }
.card .credit { color: var(--dim); font-size: 11px; margin: -8px 0 10px; }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 12px; font-size: 14px; }
.card dt { color: var(--dim); }
.card dd { margin: 0; }
.card .lede { font: 400 15px/1.5 var(--sans); margin: 0 0 12px; }
.card .links { display: flex; gap: 8px; flex-wrap: wrap; }
.card .links a { color: var(--starlight); font-size: 14px; }

.scale { position: fixed; right: var(--gutter); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.scale button { position: relative; background: none; border: 0; padding: 5px 16px 5px 6px; font-size: 13px; color: var(--dim); cursor: pointer; text-shadow: 0 0 6px #000, 0 0 2px #000; }
.scale button::after { content: ""; position: absolute; right: 2px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--dim); opacity: 0.6; }
.scale button:hover { color: var(--starlight); }
.scale button[aria-current="true"] { color: var(--starlight); }
.scale button[aria-current="true"]::after { background: var(--starlight); opacity: 1; box-shadow: 0 0 8px var(--starlight); }
.field-chip { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); background: var(--plate); border: 1px solid rgba(255, 176, 112, 0.4); color: #ffd2a6; border-radius: 999px; padding: 6px 14px; font-size: 13px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); pointer-events: none; }
.hud { position: fixed; left: 0; right: 0; bottom: 0; padding: 0 var(--gutter) max(14px, env(safe-area-inset-bottom)); pointer-events: none; }
.hud-readout { display: flex; gap: 22px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; text-shadow: 0 0 10px #000; }
.hud-readout .big { font: 500 22px/1.1 var(--sans); }
.hud-readout .lbl { color: var(--dim); font-size: 13px; }
.ribbon { position: relative; height: 26px; }
.ribbon-track { position: absolute; left: 0; right: 0; top: 4px; height: 4px; border-radius: 2px; background: var(--spectrum); opacity: 0.9; }
.ribbon-marker, .ribbon-select { position: absolute; top: -2px; width: 2px; height: 16px; background: var(--starlight); transform: translateX(-1px); box-shadow: 0 0 8px #fff; transition: left 0.15s linear; }
.ribbon-select { background: var(--accent); box-shadow: 0 0 10px var(--accent); height: 20px; top: -4px; }
.ribbon-end { position: absolute; top: 12px; font-size: 12px; color: var(--dim); }
.ribbon-end.now { left: 0; }
.ribbon-end.bang { right: 0; }
.hud-status { position: absolute; right: var(--gutter); bottom: calc(max(14px, env(safe-area-inset-bottom)) + 36px); color: var(--dim); font-size: 12px; text-align: right; }

.loading { position: fixed; inset: 0; display: grid; place-items: center; font: italic 400 22px var(--atlas); color: var(--dim); pointer-events: none; transition: opacity 0.8s; }
.loading.done { opacity: 0; }
.fallback { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; }

@media (max-width: 700px) {
  .bar { gap: 8px; }
  .title { font-size: 17px; line-height: 1.1; max-width: 9.5em; }
  .bar-actions { gap: 6px; flex-wrap: nowrap; }
  .chip { padding: 6px 10px; font-size: 13px; white-space: nowrap; }
  .panel, .card { top: auto; bottom: 0; right: 0; left: 0; width: 100%; max-height: 62vh; border-radius: 16px 16px 0 0; padding-bottom: max(16px, env(safe-area-inset-bottom)); z-index: 5; }
  .journey-text { padding: 12px 14px; font-size: 15px; }
  .journey-text h2 { font-size: 22px; }
  .hud-readout { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .hud-readout .big { font-size: 14px; line-height: 1.2; }
  .hud-readout .lbl { font-size: 11px; line-height: 1.25; }
  .hud-status { display: none; }
  .scale { top: 38%; }
  .scale button { font-size: 11px; padding: 4px 14px 4px 4px; }
}
@media (prefers-reduced-motion: reduce) { .ribbon-marker, .ribbon-select, .loading { transition: none; } }
