/* ------------------------------------------------------------------ tokens */
:root {
  --ink:      #14101a;  /* background */
  --raised:   #1c1522;  /* raised surface — reel bed, inputs */
  --tile-bed: #251c2c;  /* 3rd surface step, tile background before art loads */
  --hairline: #3a2e42;
  --bone:     #f4ecdf;  /* text */
  --muted:    #a595a8;  /* muted text */

  --accent:   #e8a33d;  /* brass/gold — swap this line to retheme (rose #e8617a, teal #4fb3a9, indigo #7c8cf0) */
  --accent-2: #e8617a;  /* secondary accent, eyebrow only */
  --error:    #ff9d8a;
  --live:     #8fd6a0;

  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body: "Sora", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  --v: 0;        /* reel velocity 0..1, written by app.js */
  --reel-x: 0px; /* reel offset, drives the sprocket scroll */
}

/* ------------------------------------------------------------------- base */
* { box-sizing: border-box; }

/* .load/.stage/.result all set their own `display` below, which otherwise
   beats the UA stylesheet's [hidden] rule (equal specificity, later in the
   cascade) and leaves "hidden" elements visible. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100dvh; overflow-x: hidden; }

main {
  max-width: 1160px;
  margin: 0 auto;
  padding: clamp(20px, 6vw, 56px) clamp(16px, 5vw, 32px) 96px;
}

a { color: var(--accent); }
a:hover { color: var(--bone); }

/* -------------------------------------------------------------------- bar */
.bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: clamp(14px, 3vw, 18px) clamp(16px, 5vw, 32px);
  border-bottom: 1px solid var(--hairline);
}

/* Quincunx logomark: 3 dots over 2, each row centered independently so the
   bottom pair sits offset in the gaps of the top row. */
.marks { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
.marks-row { display: flex; gap: 5px; }
.marks i { width: 7px; height: 7px; border-radius: 50%; display: block; background: var(--accent); }

.wordmark {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(16px, 2vw, 19px);
  letter-spacing: -0.02em;
  color: var(--bone);
}

.readout {
  margin: 0 0 0 auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: -0.01em;
}
.readout[data-state="live"] { color: var(--live); }
.readout[data-state="working"] { color: var(--accent); }

/* ------------------------------------------------------------------- load */
.load-grid {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(28px, 6vw, 56px);
  align-items: center;
}

.load-copy { flex: 1 1 420px; max-width: 600px; }

.eyebrow {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.lede {
  margin: 0 0 16px;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(32px, 6.4vw, 54px);
  line-height: 1.03;
  letter-spacing: -0.03em;
  color: var(--bone);
  text-wrap: balance;
}
.lede em { font-style: normal; color: var(--accent); }

.sub {
  margin: 0 0 28px;
  max-width: 46ch;
  font-size: 16px;
  line-height: 1.6;
  color: var(--muted);
}

.field-label {
  display: block;
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6d5f70;
}

.field { display: flex; flex-wrap: wrap; gap: 10px; }

.field input {
  flex: 1 1 240px;
  min-height: 52px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--hairline);
  background: var(--raised);
  color: var(--bone);
  font-family: var(--body);
  font-size: 15px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.field input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.field input::placeholder { color: #5a4d5e; }

.go {
  min-height: 52px;
  padding: 0 24px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #1c1000;
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: filter .16s ease, transform .16s ease;
}
.go:hover { filter: brightness(1.08); }
.go:active { transform: translateY(1px); }
.go[disabled] { opacity: .45; cursor: not-allowed; filter: none; }

.ghost {
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid var(--hairline);
  background: transparent;
  color: var(--muted);
  font-family: var(--body);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: color .16s ease, border-color .16s ease;
}
.ghost:hover { color: var(--bone); border-color: #55475a; }

.note {
  margin: 16px 0 0;
  min-height: 20px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}
.note[data-tone="bad"] { color: var(--error); }

/* Decorative poster stack — desktop flourish, no real data. */
.poster-stack {
  position: relative;
  flex: 1 1 300px;
  min-width: 260px;
  max-width: 440px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stack-card {
  position: absolute;
  width: clamp(88px, 16vw, 128px);
  aspect-ratio: 2 / 3;
  border-radius: 6px;
  display: block;
}
.stack-1 {
  background: linear-gradient(150deg, #3a2447, #1c1522);
  transform: rotate(-14deg) translate(-70px, 10px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, .45);
}
.stack-2 {
  background: linear-gradient(150deg, #4a2f24, #1c1522);
  transform: rotate(-4deg) translate(-10px, -30px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, .45);
}
.stack-3 {
  width: clamp(98px, 18vw, 144px);
  background: linear-gradient(150deg, #5c3a1f, #1c1522);
  transform: rotate(6deg) translate(58px, -10px);
  box-shadow: 0 26px 50px rgba(0, 0, 0, .5);
  z-index: 2;
}
.stack-4 {
  background: linear-gradient(150deg, #234034, #1c1522);
  transform: rotate(12deg) translate(88px, 40px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, .45);
}

/* ------------------------------------------------- the reel (the signature) */
.stage { margin-top: clamp(20px, 5vh, 48px); }

.reel {
  position: relative;
  overflow: hidden;
  padding: clamp(16px, 3vw, 22px) 0;
  background: linear-gradient(180deg, #0e0a13 0%, #1c1522 50%, #0e0a13 100%);
  border-block: 1px solid var(--hairline);
  border-radius: 6px;
  isolation: isolate;
}

/* Sprocket perforations. They scroll with the reel, so the strip reads as one
   continuous piece of film rather than a row of cards on a conveyor. */
.perf {
  position: absolute;
  left: 0; right: 0;
  height: clamp(12px, 2.4vw, 18px);
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0 10px,
    rgba(244, 236, 223, .6) 10px 24px,
    transparent 24px 34px
  );
  background-position-x: var(--reel-x);
  opacity: .5;
  z-index: 3;
  pointer-events: none;
}
.perf-top { top: 0; }
.perf-bot { bottom: 0; }

.track {
  display: flex;
  gap: clamp(6px, 1.5vw, 14px);
  will-change: transform;
  transform: translate3d(0, 0, 0);
  position: relative;
  z-index: 1;
}

.tile {
  position: relative;
  flex: 0 0 clamp(92px, 24vw, 168px);
  width: clamp(92px, 24vw, 168px);
  aspect-ratio: 2 / 3;
  border-radius: 5px;
  overflow: hidden;
  background: var(--tile-bed);
  box-shadow: inset 0 0 0 1px rgba(244, 236, 223, .08);
}
.tile-bg {
  position: absolute;
  inset: 0;
}
.tile img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity .35s ease;
}
.tile img.on { opacity: 1; }

.tile-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 10px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.3;
  color: rgba(244, 236, 223, .82);
}
.tile-overlay span:last-child { opacity: .6; }

/* Motion blur scaled to actual reel speed. */
.track { filter: blur(calc(var(--v) * 2.2px)); }

/* The gate: where the film is held still in front of the lamp. */
.gate {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  z-index: 4;
  pointer-events: none;
}
.lamp {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: clamp(140px, 30vw, 220px);
  transform: translateX(-50%);
  background: radial-gradient(
    ellipse at center,
    color-mix(in srgb, var(--accent) 28%, transparent) 0%,
    transparent 72%
  );
  opacity: calc(.5 + var(--v) * .5);
  filter: blur(calc(18px + var(--v) * 30px));
  z-index: 2;
  pointer-events: none;
}

.vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    var(--ink) 0%, rgba(20, 16, 26, 0) 14%,
    rgba(20, 16, 26, 0) 86%, var(--ink) 100%
  );
}

/* --------------------------------------------------------------- controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 24px;
}
.spin { min-width: 150px; }

/* ----------------------------------------------------------------- result */
.result {
  display: flex;
  flex-wrap: wrap;
  gap: 26px;
  align-items: center;
  margin-top: 38px;
  padding-top: 30px;
  border-top: 1px solid var(--hairline);
  animation: wl-rise .5s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes wl-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.result-poster {
  flex: 0 0 auto;
  width: clamp(130px, 26vw, 168px);
  aspect-ratio: 2 / 3;
  border-radius: 5px;
  overflow: hidden;
  background: var(--tile-bed);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .5);
}
.result-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }

.result-body { flex: 1 1 260px; }

.result .eyebrow { color: var(--accent); }

.title {
  margin: 0 0 10px;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(26px, 4.6vw, 42px);
  line-height: 1.06;
  letter-spacing: -0.03em;
  color: var(--bone);
  text-wrap: balance;
}
.odds {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}

/* -------------------------------------------------------------- a11y floor */
:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .track { transition: none !important; filter: none !important; }
  .perf { background-position-x: 0 !important; }
  .lamp { opacity: .5 !important; filter: blur(18px) !important; }
  .result { animation: none; }
}
