/* SLOT — style.css
   The Lab · retro-arcade / CRT slot + math lab. Dark only.
   Pixel type (Press Start 2P) drives the wordmark, HUD labels, section
   kickers and reels; working controls stay clean and legible. */

/* ---------- fonts (self-hosted, shared with the lab root) ---------- */

@font-face { font-family: "Press Start 2P"; font-style: normal; font-weight: 400; font-display: swap; src: url("/press-start-2p.woff2") format("woff2"); }
@font-face { font-family: "Press Start 2P Fallback"; src: local("Courier New"); size-adjust: 166.64%; ascent-override: 60%; descent-override: 0%; line-gap-override: 0%; }

/* ---------- tokens ---------- */

:root {
  --bg: #0a0a12;
  --surface: #12121d;
  --surface-2: #1a1a2a;
  --surface-3: #202036;
  --line: #28283c;
  --control-line: #5e5e80; /* >=3:1 against --surface for form-field boundaries */
  --text: #e9e9f2;
  --dim: #9aa0b5;
  --cyan: #45f0ff;
  --magenta: #ff3d8b;
  --gold: #ffc857;
  --green: #41ff8b;
  --red: #ff5560;

  --pixel: "Press Start 2P", "Press Start 2P Fallback", "Courier New", monospace;
  --body: -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;

  --radius: 8px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --glow-cyan: 0 0 14px rgba(69, 240, 255, 0.35);
  --glow-gold: 0 0 14px rgba(255, 200, 87, 0.4);
  --space-gutter: clamp(16px, 4vw, 48px);
}

/* ---------- base ---------- */

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

html {
  min-width: 320px;
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 520px at 50% -8%, rgba(69, 240, 255, 0.06), transparent 70%),
    radial-gradient(900px 480px at 100% 0%, rgba(255, 61, 139, 0.05), transparent 65%),
    var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* subtle CRT scanline veil over the whole page */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
  opacity: 0.5;
}

::selection { background: rgba(69, 240, 255, 0.3); }

[hidden] { display: none !important; }

button, input { font: inherit; }

a { color: var(--cyan); }

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

code {
  font-family: var(--mono);
  font-size: 0.9em;
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--cyan);
}

/* ---------- focus / skip link ---------- */

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(69, 240, 255, 0.15);
  border-radius: 3px;
}

.skip-link {
  position: absolute;
  left: 12px; top: -56px;
  z-index: 200;
  background: var(--cyan);
  color: #05050d;
  padding: 10px 16px;
  border-radius: 6px;
  font-family: var(--mono);
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.2s var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(68px); }

/* ---------- fixed "THE LAB" link ---------- */

.lab-link {
  position: fixed;
  left: 14px; top: 14px;
  z-index: 150;
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--dim);
  text-decoration: none;
  padding: 8px 10px;
  background: rgba(10, 10, 18, 0.7);
  border: 1px solid var(--line);
  border-radius: 6px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: color 0.15s, border-color 0.15s, text-shadow 0.15s, transform 0.15s var(--ease-out);
}
.lab-link:hover,
.lab-link:focus-visible {
  color: var(--cyan);
  border-color: var(--cyan);
  text-shadow: var(--glow-cyan);
  transform: translateX(-2px);
}

/* ---------- header ---------- */

.page-header {
  position: relative;
  z-index: 2;
  width: min(100%, 1160px);
  margin: 0 auto;
  padding: clamp(64px, 9vw, 96px) var(--space-gutter) 8px;
}

.eyebrow {
  margin: 0;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--gold);
  text-shadow: var(--glow-gold);
}

.wordmark {
  margin: 12px 0 6px;
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(24px, 6vw, 52px);
  line-height: 1.1;
  letter-spacing: 2px;
  color: var(--text);
  text-shadow: 0 0 18px rgba(69, 240, 255, 0.5), 3px 3px 0 var(--magenta);
}

.lede {
  margin: 8px 0 0;
  max-width: 60ch;
  color: var(--dim);
  font-size: clamp(0.95rem, 0.9rem + 0.3vw, 1.1rem);
}

/* ---------- layout shell ---------- */

.app-shell {
  position: relative;
  z-index: 2;
  flex: 1;
  display: grid;
  width: min(100%, 1160px);
  margin: 0 auto;
  gap: clamp(16px, 2.5vw, 24px);
  padding: clamp(16px, 3vw, 28px) var(--space-gutter) 64px;
}

/* ---------- panels ---------- */

.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface-2), var(--surface) 70%);
  padding: clamp(16px, 2.5vw, 24px);
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta) 55%, var(--gold));
  opacity: 0.7;
}

.panel-heading {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}

.section-kicker {
  margin: 0 0 0.4rem;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 2.5px;
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
}

h2 {
  margin: 0;
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(13px, 2.2vw, 17px);
  line-height: 1.45;
  letter-spacing: 1px;
  color: var(--text);
}

.status-pill {
  width: max-content;
  max-width: 100%;
  margin: 0;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 1px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: rgba(255, 200, 87, 0.08);
  color: var(--gold);
  padding: 0.5rem 0.85rem;
  box-shadow: 0 0 12px rgba(255, 200, 87, 0.15);
}

/* ---------- slot machine ---------- */

.slot-machine {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  border: 4px solid var(--surface-3);
  border-radius: 12px;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(69, 240, 255, 0.08), transparent 70%),
    #07070f;
  padding: 0.7rem;
  box-shadow:
    inset 0 0 30px rgba(0, 0, 0, 0.7),
    0 0 0 2px var(--line),
    0 14px 40px rgba(0, 0, 0, 0.55);
}

.reel {
  position: relative;
  display: grid;
  min-height: 7.5rem;
  place-items: center;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #15151f 0%, #0c0c14 50%, #15151f 100%);
  text-align: center;
}

/* glass payline shimmer across the reel window */
.reel::before {
  content: "";
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 38%;
  transform: translateY(-50%);
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.05) 50%, transparent);
  pointer-events: none;
}

.reel.is-spinning {
  border-color: var(--cyan);
  box-shadow: inset 0 0 18px rgba(69, 240, 255, 0.2);
}

.reel.is-spinning .reel-symbol {
  transform: translateY(0.1rem) scale(0.96);
  filter: blur(1.5px);
  opacity: 0.85;
}

.reel-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 4rem;
  padding: 0.4rem;
  overflow-wrap: anywhere;
  font-family: var(--pixel);
  font-size: 0.72rem;
  line-height: 1.4;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold);
  border-bottom: 3px solid transparent;
  text-shadow: 0 0 10px rgba(255, 200, 87, 0.35);
  transition: transform 120ms ease, filter 120ms ease, opacity 120ms ease;
}

/* ---------- buttons ---------- */

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.1rem;
}

.primary-button,
.secondary-button,
.remove-button {
  min-height: 2.85rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--pixel);
  letter-spacing: 0.5px;
  transition: transform 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out),
    background-color 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
}

.primary-button {
  font-size: 11px;
  padding: 0.85rem 1.2rem;
  border: 0;
  color: #05050d;
  background: var(--cyan);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--cyan), 0 0 22px rgba(69, 240, 255, 0.35);
}
.primary-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--cyan), 0 0 32px rgba(69, 240, 255, 0.6);
}
.primary-button:active:not(:disabled) { transform: translateY(1px); }

.secondary-button,
.remove-button {
  font-size: 10px;
  padding: 0.8rem 1.1rem;
  border: 1px solid var(--control-line);
  background: var(--surface);
  color: var(--text);
}
.secondary-button:hover:not(:disabled),
.remove-button:hover:not(:disabled) {
  border-color: var(--magenta);
  color: var(--magenta);
  transform: translateY(-2px);
}
.secondary-button:active:not(:disabled),
.remove-button:active:not(:disabled) { transform: translateY(1px); }

.remove-button { width: 100%; }

button:disabled { cursor: not-allowed; opacity: 0.45; transform: none; }

/* ---------- stat grid (HUD readouts) ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 1.1rem 0 0;
}

.stat-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(7, 7, 15, 0.5);
  padding: 0.8rem;
}

.stat-grid dt {
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 1px;
  color: var(--dim);
}

.stat-grid dd {
  margin: 0.45rem 0 0;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
}

.model-stats dd { color: var(--gold); text-shadow: var(--glow-gold); }
.simulation-stats dd { color: var(--green); text-shadow: 0 0 14px rgba(65, 255, 139, 0.35); }

/* ---------- text lines ---------- */

.result-line {
  margin: 1.1rem 0 0;
  max-width: 70ch;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text);
}

.privacy-line,
.model-note {
  margin: 0.85rem 0 0;
  max-width: 70ch;
  color: var(--dim);
  font-size: 0.92rem;
}

.error-text {
  min-height: 1.5rem;
  margin: 0.85rem 0 0;
  max-width: 70ch;
  color: var(--red);
  font-family: var(--mono);
  font-weight: 700;
}

/* ---------- table ---------- */

.table-wrap {
  width: 100%;
  margin-top: 1.1rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.symbol-table {
  width: 100%;
  min-width: 46rem;
  border-collapse: collapse;
  background: rgba(7, 7, 15, 0.4);
}

.symbol-table caption {
  padding: 0.85rem;
  font-family: var(--mono);
  text-align: left;
  color: var(--dim);
}

.symbol-table th,
.symbol-table td {
  border-top: 1px solid var(--line);
  padding: 0.6rem;
  text-align: left;
  vertical-align: middle;
}

.symbol-table th {
  background: var(--surface-3);
  color: var(--text);
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

input {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--control-line);
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:hover { border-color: var(--cyan); }
input:focus-visible { border-color: var(--cyan); }

.symbol-table input { min-width: 6.5rem; }
.symbol-name { min-width: 8.5rem; }

.numeric-cell {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text);
}

/* ---------- simulation form ---------- */

.simulation-form {
  display: grid;
  gap: 0.85rem;
}

.simulation-form label {
  display: grid;
  gap: 0.4rem;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--dim);
}

/* ---------- charts ---------- */

.chart-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1.1rem;
}

.chart-card {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(7, 7, 15, 0.5);
  padding: 0.85rem;
}

.chart-card figcaption {
  margin-bottom: 0.6rem;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
}

.chart-canvas {
  display: block;
  width: 100%;
  height: 18rem;
  border-radius: 6px;
  background: #07070f;
}

.histogram-wrap { margin-top: 1.1rem; }

/* ---------- explanation panel ---------- */

.explanation-panel h2 { margin-bottom: 0.5rem; }
.explanation-panel p { margin: 0.85rem 0 0; color: var(--dim); max-width: 72ch; }

/* ---------- footer ---------- */

.site-footer {
  position: relative;
  z-index: 2;
  width: min(100%, 1160px);
  margin: 0 auto;
  padding: 0 var(--space-gutter) 40px;
  display: grid;
  gap: 0.5rem;
  text-align: center;
  color: var(--dim);
}

.site-footer p { margin: 0; }

.footer-flavor {
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 2px;
  color: var(--gold);
}

/* ---------- responsive ---------- */

@media (min-width: 640px) {
  .panel-heading {
    align-items: flex-start;
    flex-direction: row;
    justify-content: space-between;
  }

  .simulation-form {
    align-items: end;
    grid-template-columns: minmax(12rem, 1fr) auto auto;
  }

  .reel { min-height: 9rem; }
  .reel-symbol { font-size: 0.82rem; }
}

@media (min-width: 768px) {
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .model-stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .app-shell { grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr); }
  .simulation-panel,
  .explanation-panel { grid-column: 1 / -1; }
  .chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reel-symbol,
  .reel.is-spinning .reel-symbol { filter: none; }
  .lab-link:hover,
  .primary-button:hover:not(:disabled),
  .secondary-button:hover:not(:disabled),
  .remove-button:hover:not(:disabled) { transform: none; }
}
