/* endresen.ai — Modernist tokens + page chrome.
   Derived from the Modernist design system (flat, architectural, Archivo,
   one red accent, zero radius, 2px rules). Self-hosted variable font. */

@font-face {
  font-family: "Archivo";
  src: url("assets/fonts/archivo-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --color-bg: #f3f2f2;
  --color-surface: #eae9e9;
  --color-text: #201e1d;
  --color-accent: #ec3013;
  --color-divider: color-mix(in srgb, #201e1d 40%, transparent);

  --color-neutral-100: #f8f4f4;
  --color-neutral-300: #d7d3d3;
  --color-neutral-500: #9b9797;
  --color-neutral-700: #605d5d;
  --color-neutral-900: #2d2b2b;

  --color-accent-100: #fff2ef;
  --color-accent-300: #ffc4b8;
  --color-accent-400: #ff9783;
  --color-accent-500: #ff563c;
  --color-accent-600: #dd2b0f;
  --color-accent-700: #ae1800;
  --color-accent-800: #7c1405;

  --font-heading: "Archivo", system-ui, sans-serif;
  --font-heading-weight: 800;
  --font-body: "Archivo", system-ui, sans-serif;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
}

/* ── base ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 400;
}
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 var(--space-2);
}
h3 { font-size: 25px; }
h6 { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }
p { margin: 0 0 var(--space-3); }
a { color: var(--color-accent); text-underline-offset: 3px; }
a:hover { color: var(--color-accent-600); }
img { display: block; max-width: 100%; }
figure { margin: 0; }
.text-muted { color: color-mix(in srgb, var(--color-text) 55%, transparent); }
.grayscale { filter: grayscale(1) contrast(1.08); }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }

/* Keyboard focus must survive the chrome's inline `all: unset` buttons. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--color-accent) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 5px color-mix(in srgb, #f3f2f2 60%, transparent) !important;
}

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

/* ── stage ────────────────────────────────────────────────────────────── */
#stage {
  position: fixed; inset: 0; overflow: hidden;
  font-family: var(--font-body);
}
#stage-fx { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
#stage-gl { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; display: none; background: #0b0a09; }
#chrome { position: absolute; inset: 0; z-index: 2; }

/* Thin, on-brand scrollbars inside the card and story panel. */
.era-card, .more-panel { scrollbar-width: thin; scrollbar-color: var(--color-accent) transparent; }
.era-card::-webkit-scrollbar, .more-panel::-webkit-scrollbar { width: 6px; }
.era-card::-webkit-scrollbar-thumb, .more-panel::-webkit-scrollbar-thumb { background: var(--color-accent); }
.era-card::-webkit-scrollbar-track, .more-panel::-webkit-scrollbar-track { background: transparent; }

/* ── animation vocabulary (referenced inline by the chrome) ───────────── */
@keyframes riseIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes wipeIn { from { opacity: 0; clip-path: inset(0 100% 0 0); } to { opacity: 1; clip-path: inset(0 0 0 0); } }
@keyframes cardIn { from { opacity: 0; transform: translateX(26px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes hintBob { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-3px); } }
.scroll-hint-arrow { animation: hintBob 1.6s ease-in-out infinite; }

/* ── SOTA story panel (1992 era) ──────────────────────────────────────── */
.sota-panel {
  position: absolute; left: 44px; top: 150px; width: 430px; z-index: 4;
  display: flex; flex-direction: column; gap: 11px;
  background: rgba(16, 14, 13, 0.74);
  border: 1px solid rgba(243, 242, 242, 0.34);
  box-shadow: 0 10px 44px rgba(0, 0, 0, 0.5);
  padding: 18px 20px;
  max-height: min(540px, calc(100vh - 300px)); overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--color-accent) transparent;
  animation: riseIn 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) 0.1s both;
  color: #f3f2f2;
}
.sota-panel::-webkit-scrollbar { width: 6px; }
.sota-panel::-webkit-scrollbar-thumb { background: var(--color-accent); }
.sota-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.sota-file { font: 800 11.5px var(--font-heading); letter-spacing: 0.12em; color: #ff9783; }
.sota-sound {
  all: unset; cursor: pointer; font: 800 11px var(--font-heading); letter-spacing: 0.1em;
  color: #f3f2f2; background: var(--color-accent); padding: 4px 9px;
}
.sota-sound:hover { background: var(--color-accent-600); }
.sota-sound[aria-pressed="true"] { background: #f3f2f2; color: #1c1a19; }
.sota-tracks { display: flex; gap: 5px; flex-wrap: wrap; }
.sota-trk {
  all: unset; cursor: pointer; font: 700 10px "Courier New", monospace; letter-spacing: 0.06em;
  color: rgba(243, 242, 242, 0.66); border: 1px solid rgba(243, 242, 242, 0.3); padding: 3px 7px;
}
.sota-trk:hover { border-color: #ff9783; color: #ff9783; }
.sota-trk.on { background: var(--color-accent); border-color: var(--color-accent); color: #f3f2f2; }
.sota-progress { height: 3px; background: rgba(243, 242, 242, 0.18); flex: none; }
#sota-bar { height: 100%; width: 0; background: var(--color-accent); transition: width 0.14s linear; }
#sota-title { margin: 2px 0 0; color: #ff9783; font-size: 13px; letter-spacing: 0.08em; }
#sota-story { margin: 0; font-size: 14.5px; line-height: 1.62; color: rgba(248, 246, 244, 0.96); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55); }
#sota-asm {
  margin: 0; font: 12.5px/1.55 "Courier New", monospace; color: #ffb3a1; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  white-space: pre; overflow-x: hidden; min-height: 10.5em;
  border-top: 1px solid rgba(243, 242, 242, 0.16); padding-top: 8px;
}
#sota-regs { font: 10px/1.4 "Courier New", monospace; color: rgba(243, 242, 242, 0.5); letter-spacing: 0.04em; white-space: pre; overflow: hidden; }
.sota-foot { display: flex; gap: 16px; border-top: 1px solid rgba(243, 242, 242, 0.16); padding-top: 9px; }
.sota-link { all: unset; cursor: pointer; font: 800 11px var(--font-heading); letter-spacing: 0.1em; color: #ff9783; }
.sota-link:hover { color: #f3f2f2; }
.pouet-link:hover { color: #f3f2f2 !important; }

/* On desktop the era card (right) already offers the longer story — the
   panel-footer copy of the link only exists for phones, where the card hides. */
@media (min-width: 881px) {
  .sota-more-link { display: none; }
}

/* ── noscript fallback ────────────────────────────────────────────────── */
.noscript-fallback {
  position: fixed; inset: 0; z-index: 50; overflow: auto;
  background: var(--color-bg); padding: 48px clamp(20px, 8vw, 120px);
  border-top: 4px solid var(--color-accent);
}
.noscript-fallback li { margin-bottom: 10px; }

/* ── small screens ────────────────────────────────────────────────────── */
@media (max-width: 880px) {
  .site-header { left: 16px !important; right: 16px !important; top: 14px !important; }
  .site-header > div { gap: 14px !important; }
  .era-nav-btns { left: 8px !important; top: 46px !important; }
  .era-kicker { left: 16px !important; right: 16px !important; bottom: auto !important; top: 112px !important; font-size: 10px !important; }
  .era-kicker > span:first-child { width: 18px !important; }
  .era-card {
    left: 16px !important; right: 28px !important; top: auto !important;
    bottom: 96px !important; width: auto !important; max-height: 36vh !important;
    padding: 14px 16px !important;
  }
  .era-prints { left: 16px !important; top: 148px !important; gap: 8px !important; }
  .era-prints figure { width: 88px !important; margin-top: 0 !important; padding: 5px !important; }
  .era-rail { right: 4px !important; }
  /* float the era year above the card zone instead of hiding behind it */
  .era-year { left: 16px !important; bottom: calc(96px + 37vh) !important; }
  .era-year-ghost { left: 28px !important; bottom: calc(96px + 37vh - 10px) !important; }
  .era-strap { left: 16px !important; right: 28px !important; bottom: 8px !important; gap: 10px !important; }
  .era-strap > div:first-child { font-size: 11px !important; padding: 5px 8px !important; letter-spacing: 0.04em !important; }
  .era-strap > div:last-child { font-size: 10px !important; padding: 5px 8px !important; letter-spacing: 0.08em !important; }
  .scroll-hint { display: none !important; }
  /* 1992: the story panel becomes the era's card on phones */
  .sota-panel { left: 16px !important; right: 28px !important; top: auto !important; bottom: 102px !important; width: auto !important; max-height: 44vh !important; }
  #chrome:has(.sota-panel) .era-card { display: none !important; }
  #sota-asm { min-height: 0 !important; }
  .more-panel { padding: 24px 20px !important; }
  .pouet-marquee { height: 30px !important; }
  /* the dancers era owns the bottom edge with the marquee — lift the strap clear of it */
  #chrome:has(.pouet-marquee) .era-strap { bottom: 44px !important; }
}

/* ── narrow or portrait: the visual is the point, text stays a caption ── */
@media (max-width: 880px), (orientation: portrait) {
  /* one smaller type scale for every era card */
  .era-card {
    right: 16px !important; bottom: 84px !important;
    max-height: 38vh !important; padding: 15px 16px 13px !important;
    gap: 8px !important;
  }
  .era-card h2 { font-size: 19px !important; line-height: 1.22 !important; }
  .era-card p {
    font-size: 13.5px !important; line-height: 1.5 !important;
    display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
    overflow: hidden;
  }
  /* the facts table is detail: keep two rows, drop the rest */
  .era-card > div:last-child > div:nth-child(n+3) { display: none !important; }
  .era-card > div:last-child > div { padding: 6px 0 !important; }
  .era-card > div:last-child span { font-size: 11.5px !important; }

  /* the story panel becomes a compact strip so the reel keeps the screen */
  .sota-panel {
    left: 12px !important; right: 12px !important; top: auto !important;
    bottom: 78px !important; max-height: 33vh !important;
    padding: 12px 14px !important; gap: 7px !important;
  }
  /* one reading surface at a time: the story panel is the card here */
  #chrome:has(.sota-panel) .era-card { display: none !important; }
  .sota-file { font-size: 10px !important; letter-spacing: 0.1em !important; }
  .sota-sound { font-size: 10px !important; padding: 3px 7px !important; }
  .sota-trk { font-size: 9px !important; padding: 2px 5px !important; }
  #sota-title { font-size: 11px !important; }
  #sota-story {
    font-size: 13px !important; line-height: 1.45 !important;
    display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
    overflow: hidden;
  }
  /* the 68000 listing and register readout are desktop detail */
  #sota-asm, #sota-regs { display: none !important; }
  .sota-foot { padding-top: 7px !important; }
  .sota-link { font-size: 10px !important; }

  /* year numerals sit above whichever panel is showing */
  .era-year { bottom: calc(84px + 39vh) !important; }
  .era-year-ghost { bottom: calc(84px + 39vh - 8px) !important; }
  #chrome:has(.sota-panel) .era-year {
    top: 104px !important; bottom: auto !important; left: 14px !important;
    font-size: 62px !important; opacity: 0.7;
  }
  #chrome:has(.sota-panel) .era-year-ghost { display: none !important; }

  .era-prints { display: none !important; }
  .pouet-marquee { height: 26px !important; font-size: 11px !important; }
  .era-strap > div:last-child { font-size: 9px !important; }
}

/* very small phones: trim one more line of prose */
@media (max-width: 430px) {
  .era-card p { -webkit-line-clamp: 3; }
  #sota-story { -webkit-line-clamp: 3; }
  .era-card h2 { font-size: 18px !important; }
}

/* ── reduced motion ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #chrome *, .scroll-hint-arrow {
    animation: none !important;
    transition: none !important;
  }
}
