/* Lumenhold — visual reaction time test
   Darkroom / viewfinder. Copper hold, acid flare. No purple slop. */

:root {
  --ink: #100e0c;
  --ink-2: #1c1814;
  --ink-3: #2a241c;
  --paper: #f4ede3;
  --paper-dim: #cfc4b6;
  --muted: #9a8f82;
  --copper: #d4723a;
  --copper-deep: #8a4a28;
  --flare: #d8f54a;
  --flare-ink: #1a2208;
  --danger: #e24a2f;
  --danger-ink: #2a0c08;
  --line: rgba(244, 237, 227, 0.1);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 22px;
  --font-ui: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --space: clamp(1.1rem, 3vw, 2rem);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-optical-sizing: auto;
  background: var(--ink);
  color: var(--paper);
  line-height: 1.55;
  letter-spacing: -0.011em;
}

body::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(1200px 700px at 12% -10%, rgba(212, 114, 58, 0.16), transparent 55%),
    radial-gradient(900px 500px at 110% 10%, rgba(216, 245, 74, 0.06), transparent 50%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(255, 255, 255, 0.012) 3px,
      rgba(255, 255, 255, 0.012) 4px
    );
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 20;
  background: var(--flare);
  color: var(--flare-ink);
  padding: 0.5rem 0.8rem;
  font-weight: 700;
  text-decoration: none;
  border-radius: 8px;
}
.skip:focus { top: 1rem; }

.wrap {
  position: relative;
  z-index: 1;
  width: min(1080px, calc(100% - 1.5rem));
  margin-inline: auto;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 8;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--ink) 78%, transparent);
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: inherit;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -0.04em;
  font-size: 1.05rem;
}

.brand svg { display: block; }

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1rem;
  font-size: 0.88rem;
}

.nav a {
  color: var(--paper-dim);
  text-decoration: none;
  font-weight: 500;
}
.nav a:hover { color: var(--flare); }
.nav a[aria-current="page"] { color: var(--flare); }

.best-chip {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--copper);
  border: 1px solid color-mix(in srgb, var(--copper) 45%, transparent);
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

/* Hero / play */
.hero {
  padding: 2.2rem 0 1.2rem;
}

.kicker {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--copper);
}

h1 {
  margin: 0;
  font-size: clamp(2.05rem, 5.6vw, 3.6rem);
  line-height: 0.95;
  letter-spacing: -0.055em;
  font-weight: 800;
  max-width: 14ch;
}

.lede {
  margin: 1rem 0 0;
  max-width: 42rem;
  color: var(--paper-dim);
  font-size: 1.05rem;
}

.play-grid {
  display: grid;
  gap: 1.1rem;
  margin-top: 1.6rem;
}

@media (min-width: 860px) {
  .play-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(240px, 0.7fr);
    align-items: stretch;
  }
}

.stage-shell {
  position: relative;
  border-radius: var(--radius);
  padding: 10px;
  background: linear-gradient(180deg, #242018, #14110e);
  box-shadow: var(--shadow);
  border: 1px solid var(--ink-3);
}

.stage-shell::before,
.stage-shell::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--copper);
  border-style: solid;
  pointer-events: none;
  z-index: 2;
}
.stage-shell::before {
  top: 18px;
  left: 18px;
  border-width: 2px 0 0 2px;
}
.stage-shell::after {
  bottom: 18px;
  right: 18px;
  border-width: 0 2px 2px 0;
}

.ticks {
  position: absolute;
  inset: 18px;
  pointer-events: none;
  z-index: 2;
}
.ticks span {
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--copper);
  border-style: solid;
}
.ticks .tr { top: 0; right: 0; border-width: 2px 2px 0 0; }
.ticks .bl { bottom: 0; left: 0; border-width: 0 0 2px 2px; }

#stage {
  --stage-bg: #16130f;
  --stage-fg: var(--paper);
  appearance: none;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: min(62vh, 460px);
  margin: 0;
  padding: 1.5rem;
  border: 0;
  border-radius: 14px;
  background: var(--stage-bg);
  color: var(--stage-fg);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
  font: inherit;
  text-align: center;
  transition: background 80ms linear, color 80ms linear;
}

#stage:focus-visible {
  outline: 2px solid var(--flare);
  outline-offset: 3px;
}

.aperture {
  position: absolute;
  width: min(46vw, 210px);
  height: min(46vw, 210px);
  inset: 0;
  margin: auto;
  clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  border: 2px solid color-mix(in srgb, var(--copper) 70%, transparent);
  background: transparent;
  opacity: 0.85;
  transition: transform 180ms ease, background 80ms linear, opacity 80ms linear, clip-path 160ms ease;
}

#stage[data-state="idle"] .aperture,
#stage[data-state="hit"] .aperture,
#stage[data-state="done"] .aperture {
  opacity: 0.28;
}
#stage[data-state="miss"] .aperture {
  opacity: 0.15;
}

#stage[data-state="waiting"] .aperture {
  animation: hold-spin 9s linear infinite;
  box-shadow: inset 0 0 40px rgba(212, 114, 58, 0.18);
}

#stage[data-state="go"] .aperture {
  background: color-mix(in srgb, var(--flare-ink) 35%, transparent);
  border-color: var(--flare-ink);
  transform: scale(1.18);
  animation: none;
}

#stage[data-mode="glyph"][data-state="go"] .aperture {
  clip-path: polygon(50% 6%, 94% 50%, 50% 94%, 6% 50%);
  background: var(--flare-ink);
}

#stage[data-mode="pulse"] .aperture {
  clip-path: none;
  border-radius: 50%;
  width: 72px;
  height: 72px;
  background: var(--copper);
  opacity: 0.35;
}

#stage[data-mode="pulse"][data-state="waiting"] .aperture {
  animation: pulse-breathe 1.4s ease-in-out infinite;
}

#stage[data-mode="pulse"][data-state="go"] .aperture {
  width: min(52vw, 240px);
  height: min(52vw, 240px);
  background: transparent;
  border: 10px solid var(--flare-ink);
  opacity: 1;
  animation: none;
  transform: none;
}

.stage-copy {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.35rem;
  justify-items: center;
}

.stage-msg {
  margin: 0;
  font-size: clamp(1.7rem, 5vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
}

.stage-sub {
  margin: 0;
  color: color-mix(in srgb, var(--stage-fg) 72%, transparent);
  font-size: 0.95rem;
  max-width: 26ch;
}

.ms-readout {
  font-variant-numeric: tabular-nums;
  font-size: clamp(3.2rem, 10vw, 5.2rem);
  font-weight: 800;
  letter-spacing: -0.07em;
  line-height: 0.9;
}

/* Stage skins */
#stage[data-state="idle"] {
  --stage-bg: #17140f;
  --stage-fg: var(--paper);
}
#stage[data-state="waiting"] {
  --stage-bg: #1a120c;
  --stage-fg: #e7c3a4;
}
#stage[data-state="go"] {
  --stage-bg: var(--flare);
  --stage-fg: var(--flare-ink);
}
#stage[data-state="miss"] {
  --stage-bg: var(--danger);
  --stage-fg: var(--danger-ink);
}
#stage[data-state="hit"] {
  --stage-bg: #221c16;
  --stage-fg: var(--paper);
}
#stage[data-state="done"] {
  --stage-bg: #14110e;
  --stage-fg: var(--paper);
}

#stage[data-mode="glyph"][data-state="waiting"] {
  --stage-bg: #12151a;
  --stage-fg: #c9d4e2;
}
#stage[data-mode="glyph"][data-state="go"] {
  --stage-bg: #f3efe6;
  --stage-fg: #16120c;
}
#stage[data-mode="pulse"][data-state="waiting"] {
  --stage-bg: #0f1412;
  --stage-fg: #b7d8c8;
}
#stage[data-mode="pulse"][data-state="go"] {
  --stage-bg: #7cffd0;
  --stage-fg: #06241a;
}

@keyframes hold-spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse-breathe {
  0%, 100% { transform: scale(0.86); opacity: 0.28; }
  50% { transform: scale(1.08); opacity: 0.5; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  #stage[data-state="waiting"] .aperture,
  #stage[data-mode="pulse"][data-state="waiting"] .aperture {
    animation: none;
  }
}

/* Side panel */
.panel {
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
}

.panel h2 {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.modes {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.mode {
  appearance: none;
  font: inherit;
  text-align: left;
  color: var(--paper);
  background: transparent;
  border: 1px solid var(--ink-3);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
}
.mode:hover { border-color: var(--copper-deep); }
.mode[aria-pressed="true"] {
  background: color-mix(in srgb, var(--copper) 16%, transparent);
  border-color: var(--copper);
}
.mode strong { display: block; font-size: 0.95rem; letter-spacing: -0.03em; }
.mode span { display: block; color: var(--muted); font-size: 0.78rem; margin-top: 0.12rem; }

.pips {
  display: flex;
  gap: 0.4rem;
}
.pips i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--copper-deep);
  display: block;
}
.pips i.ok { background: var(--flare); border-color: var(--flare); }
.pips i.bad { background: var(--danger); border-color: var(--danger); }

.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.stat {
  background: #14110e;
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
}
.stat b {
  display: block;
  font-variant-numeric: tabular-nums;
  font-size: 1.25rem;
  letter-spacing: -0.04em;
}
.stat small {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

/* Article */
.prose {
  padding: 2.4rem 0 3.2rem;
  display: grid;
  gap: 2.4rem;
}

.prose section {
  max-width: 42rem;
}

.prose h2 {
  margin: 0 0 0.8rem;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(1.55rem, 3vw, 2rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.prose p { margin: 0 0 0.9rem; color: var(--paper-dim); }
.prose a { color: var(--copper); }
.prose a:hover { color: var(--flare); }
.prose p:last-child { margin-bottom: 0; }

.prose ol {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--paper-dim);
}
.prose li { margin-bottom: 0.45rem; }

.related {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.8rem;
}
.related a {
  color: var(--ink);
  background: var(--paper);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.38rem 0.7rem;
  border-radius: 999px;
}
.related a:hover { background: var(--flare); }

.faq details {
  border-top: 1px solid var(--ink-3);
  padding: 0.85rem 0;
}
.faq details:last-child { border-bottom: 1px solid var(--ink-3); }
.faq summary {
  cursor: pointer;
  font-weight: 700;
  letter-spacing: -0.02em;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before {
  content: "+";
  color: var(--copper);
  margin-right: 0.55rem;
  font-weight: 800;
}
.faq details[open] summary::before { content: "–"; }
.faq details p { margin: 0.55rem 0 0.15rem 1.15rem; }

.note {
  font-size: 0.88rem;
  color: var(--muted);
  border-left: 3px solid var(--copper);
  padding-left: 0.85rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.6rem 0 2.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.site-footer .wrap { display: grid; gap: 0.55rem; }
.site-footer a { color: var(--paper-dim); }

::selection {
  background: var(--copper);
  color: #1a0d08;
}

/* Aperture centering without fighting rotate/scale transforms */
.aperture {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
}

@media (max-width: 720px) {
  .site-header .wrap {
    flex-wrap: wrap;
  }
  .nav {
    order: 3;
    width: 100%;
    justify-content: flex-start;
  }
  .best-chip { margin-left: auto; }
  h1 { max-width: none; }
  #stage { min-height: min(58vh, 420px); }
}
