/* Riemann Zeta Visualizer — layout & theme
   Palette follows the dataviz skill's validated categorical/chrome set.
   Slot 7 (violet) is reserved for the critical-line animation. */

:root {
  color-scheme: light;
  --surface: #fcfcfb;
  --page: #f9f9f7;
  --ink: #0b0b0b;
  --ink-secondary: #52514e;
  --ink-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --strip-fill: rgba(74, 58, 167, 0.06);
  --critical-line: #4a3aa7;
  --good: #0ca30c;
  --critical: #d03b3b;
  --border: rgba(11, 11, 11, 0.10);
  --btn-bg: #ffffff;
  --btn-border: rgba(11, 11, 11, 0.14);

  --series-1: #2a78d6;
  --series-2: #008300;
  --series-3: #e87ba4;
  --series-4: #eda100;
  --series-5: #1baf7a;
  --series-6: #eb6834;
  --series-8: #e34948;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface: #1a1a19;
    --page: #0d0d0d;
    --ink: #ffffff;
    --ink-secondary: #c3c2b7;
    --ink-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --strip-fill: rgba(144, 133, 233, 0.12);
    --critical-line: #9085e9;
    --good: #0ca30c;
    --critical: #e66767;
    --border: rgba(255, 255, 255, 0.10);
    --btn-bg: #232322;
    --btn-border: rgba(255, 255, 255, 0.14);

    --series-1: #3987e5;
    --series-2: #008300;
    --series-3: #d55181;
    --series-4: #c98500;
    --series-5: #199e70;
    --series-6: #d95926;
    --series-8: #e66767;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.math {
  font-style: italic;
  font-variant-numeric: tabular-nums;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}

.topbar .subtitle {
  margin: 0 0 24px;
  color: var(--ink-secondary);
  max-width: 68ch;
  line-height: 1.5;
  font-size: 0.95rem;
}

/* ---- stage: the two plane panels ---- */

.stage {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.panel-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-muted);
  white-space: nowrap;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  flex: 1 1 auto;
}

#wrap-input {
  aspect-ratio: 0.62;
  max-height: 72vh;
  cursor: crosshair;
}

#wrap-output {
  aspect-ratio: 1;
  max-height: 72vh;
}

.canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.stage-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--ink-muted);
  padding: 0 2px;
}

.stage-arrow .arrow-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.stage-arrow .arrow-col { display: none; }

.stage-arrow .arrow-label {
  font-style: italic;
  font-size: 0.95rem;
}

/* ---- controls ---- */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 16px;
}

.control-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}

.control-group h3 {
  margin: 0 0 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

.control-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1 1 380px;
}

.control-group-anim,
.control-group-vlines {
  flex: none;
}

.vlines-hint {
  margin: 10px 0 0;
}

.btn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--ink);
  cursor: pointer;
}

.btn:hover { filter: brightness(1.06); }
.btn:active { filter: brightness(0.96); }

.btn-primary {
  background: var(--critical-line);
  border-color: var(--critical-line);
  color: #ffffff;
}

.btn-play-toggle {
  width: 84px;
  text-align: center;
}

.anim-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-bottom: 10px;
}

.anim-buttons {
  display: flex;
  gap: 8px;
}

.speed-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 180px;
  min-width: 160px;
}

.speed-control label {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.speed-control input[type="range"] {
  width: 100%;
  accent-color: var(--critical-line);
}

.anim-readout {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.82rem;
  color: var(--ink-secondary);
}

.t-readout {
  font-variant-numeric: tabular-nums;
  min-width: 6.5ch;
}

.zero-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}

.zero-track {
  display: flex;
  gap: 4px;
}

.zero-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--grid);
  border: 1px solid var(--axis);
  transition: background 0.25s, border-color 0.25s, transform 0.25s;
}

.zero-dot.crossed {
  background: var(--good);
  border-color: var(--good);
  transform: scale(1.15);
}

#zero-count {
  font-variant-numeric: tabular-nums;
}

.footnote {
  margin-top: 22px;
  color: var(--ink-muted);
  font-size: 0.8rem;
  line-height: 1.55;
  max-width: 78ch;
}

.footnote p { margin: 0; }

.footnote p.credit {
  margin-top: 10px;
}

.credit a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-muted);
  text-decoration: none;
}

.credit a:hover { text-decoration: underline; }

.credit img { border-radius: 3px; }

/* ---- mobile: stack input on top, output below ---- */

@media (max-width: 800px) {
  .stage {
    grid-template-columns: 1fr;
  }

  .stage-arrow {
    flex-direction: row;
    padding: 2px 0;
  }

  .stage-arrow .arrow-row { display: none; }
  .stage-arrow .arrow-col { display: inline; }

  #wrap-input {
    aspect-ratio: 0.9;
    max-height: 46vh;
    max-width: 420px;
    margin: 0 auto;
  }

  #wrap-output {
    max-height: 60vh;
    max-width: 480px;
    margin: 0 auto;
  }

  .page {
    padding: 20px 14px 32px;
  }
}
