/* ------------------------------------------------------------------ *
 *  Rumora — design tokens
 * ------------------------------------------------------------------ */
:root {
  --bg: #0a0c12;
  --panel: #0d1017;
  --raised: #131826;
  --line: rgba(146, 163, 199, 0.14);
  --line-soft: rgba(146, 163, 199, 0.075);
  --text: #e6ebf5;
  --dim: #8b96ad;
  --faint: #5d6779;

  --amber: #ff7a3c;
  --cyan: #37d6d0;
  --violet: #7a6aa8;
  --slate: #3b4356;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --r: 8px;
  --pad: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ *
 *  Header
 * ------------------------------------------------------------------ */
.masthead {
  padding: 12px 20px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0d1119, var(--bg));
}
.mast-top {
  display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.mast-top nav { margin-left: auto; }
/* The finding is the hook, not the mechanics. A visitor decides in seconds,
   and "two contagions race across one network" describes the machinery
   without ever saying what it found. */
.lede-line {
  margin: 0 0 4px; font-size: 16px; font-weight: 600;
  letter-spacing: -0.01em; max-width: 760px; line-height: 1.35;
}
.nav-play { color: var(--believer) !important; }
.nav-play:hover { color: #ff9c6b !important; }
.wordmark {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: 0;
}
.wordmark span { color: var(--amber); }
.tagline {
  color: var(--dim);
  font-size: 12.5px;
  max-width: 720px;
  margin: 0;
}
.masthead nav { display: flex; gap: 16px; font-size: 12.5px; }
.masthead nav a { color: var(--dim); }
.masthead nav a:hover { color: var(--text); }

/* ------------------------------------------------------------------ *
 *  Three-pane workspace
 * ------------------------------------------------------------------ */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 620px;
}

.workspace {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) 310px;
  flex: 1;
  min-height: 0;
}

.pane { overflow-y: auto; background: var(--panel); }
.pane--left { border-right: 1px solid var(--line); }
.pane--right { border-left: 1px solid var(--line); }

.pane::-webkit-scrollbar { width: 9px; }
.pane::-webkit-scrollbar-thumb { background: rgba(146,163,199,0.2); border-radius: 9px; }

.stage {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* The canvas is taken out of flow entirely: a canvas element's intrinsic size
   comes from its width/height attributes, and since we set those from the
   measured box on every resize, leaving it in flow creates a feedback loop
   that inflates the grid row. */
.canvas-wrap { position: relative; flex: 1; min-height: 0; }
#network {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
#network.dragging { cursor: grabbing; }

/* ------------------------------------------------------------------ *
 *  Sections & controls
 * ------------------------------------------------------------------ */
.section { border-bottom: 1px solid var(--line); padding: 14px var(--pad); }
.section:last-child { border-bottom: none; }

.section-title {
  font-size: 10.5px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 12px;
  font-weight: 600;
}

.control { margin-bottom: 13px; }
.control:last-child { margin-bottom: 2px; }
.control-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
}
.control-label { font-size: 12.5px; color: var(--text); }
.control-value {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}
.control-hint {
  font-size: 11px;
  color: var(--faint);
  line-height: 1.35;
  margin-top: 4px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 3px;
  background: rgba(146, 163, 199, 0.22);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--bg);
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(146,163,199,0.5);
}
input[type="range"]::-moz-range-thumb {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--bg);
  cursor: pointer;
}
input[type="range"]:disabled { opacity: 0.35; }

select {
  width: 100%;
  background: var(--raised);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: var(--sans);
  font-size: 12.5px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 12.5px;
  user-select: none;
}
.toggle input { display: none; }
.toggle .box {
  width: 15px; height: 15px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--raised);
  flex-shrink: 0;
  position: relative;
}
.toggle input:checked + .box { background: var(--cyan); border-color: var(--cyan); }
.toggle input:checked + .box::after {
  content: "";
  position: absolute; left: 4.5px; top: 1.5px;
  width: 4px; height: 8px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(43deg);
}

/* ------------------------------------------------------------------ *
 *  Buttons & transport
 * ------------------------------------------------------------------ */
button {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--text);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.13s, border-color 0.13s;
}
button:hover { background: #1a2132; border-color: rgba(146,163,199,0.3); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--amber); border-color: var(--amber); color: #14100c; font-weight: 600; }
button.primary:hover { background: #ff8f5b; }

.transport {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
}
.transport .spacer { flex: 1; }
.clock {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.clock b { color: var(--text); font-weight: 600; }
.speed { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--faint); }
.speed input[type="range"] { width: 92px; }

/* ------------------------------------------------------------------ *
 *  Presets
 * ------------------------------------------------------------------ */
.preset {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--dim);
  font-size: 12.5px;
}
.preset:hover { background: var(--raised); border-color: var(--line); color: var(--text); }
.preset[aria-pressed="true"] {
  background: var(--raised);
  border-color: rgba(255,122,60,0.5);
  color: var(--text);
}
.preset-blurb {
  font-size: 11px;
  color: var(--faint);
  line-height: 1.45;
  padding: 2px 2px 4px;
  margin-bottom: 8px;
}

/* ------------------------------------------------------------------ *
 *  Readout
 * ------------------------------------------------------------------ */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat {
  background: var(--raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 9px 10px;
}
.stat-label {
  font-size: 9.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 3px;
}
.stat-value {
  font-family: var(--mono);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.stat-sub { font-size: 10.5px; color: var(--faint); font-family: var(--mono); }
.stat--wide { grid-column: 1 / -1; }

.legend { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.legend-row { display: flex; align-items: center; gap: 9px; font-size: 11.5px; color: var(--dim); }
.swatch { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-row .count {
  margin-left: auto;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-size: 11.5px;
}

canvas.chart { width: 100%; display: block; border-radius: 6px; background: #0b0e15; }
#timechart { height: 132px; }
#histogram { height: 96px; }

.sweep-summary {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  line-height: 1.7;
  margin-top: 9px;
}
.sweep-summary b { color: var(--text); font-weight: 600; }
.sweep-row { display: flex; gap: 8px; align-items: center; }

/* inspector floating over the canvas */
.inspector {
  position: absolute;
  pointer-events: none;
  background: rgba(13, 16, 23, 0.94);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  line-height: 1.55;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 5;
  backdrop-filter: blur(6px);
}
.inspector.on { opacity: 1; }
.inspector b { color: var(--text); font-weight: 600; }

.stage-hint {
  position: absolute;
  left: 14px; bottom: 12px;
  font-size: 10.5px;
  color: var(--faint);
  pointer-events: none;
}

/* ------------------------------------------------------------------ *
 *  Essay
 * ------------------------------------------------------------------ */
.essay {
  max-width: 720px;
  margin: 0 auto;
  padding: 72px 24px 96px;
  border-top: 1px solid var(--line);
}
.essay h2 {
  font-size: 22px;
  letter-spacing: -0.01em;
  margin: 56px 0 14px;
  font-weight: 620;
}
.essay h2:first-child { margin-top: 0; }
.essay h3 { font-size: 15px; margin: 30px 0 8px; font-weight: 620; }
.essay p { color: #c3ccdc; margin: 0 0 15px; line-height: 1.68; }
.essay li { color: #c3ccdc; margin-bottom: 7px; line-height: 1.6; }
.essay code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--raised);
  padding: 1.5px 5px;
  border-radius: 4px;
  color: var(--cyan);
}
.lede { font-size: 16px !important; color: var(--text) !important; }

.finding {
  border-left: 2px solid var(--amber);
  background: linear-gradient(90deg, rgba(255,122,60,0.06), transparent 70%);
  padding: 14px 18px;
  margin: 22px 0;
  border-radius: 0 var(--r) var(--r) 0;
}
.finding p { margin: 0; }
.finding .k {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
  display: block;
  margin-bottom: 6px;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12px;
  margin: 18px 0 22px;
}
table.data th, table.data td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-soft);
}
table.data th {
  color: var(--faint);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
table.data td { color: #c3ccdc; font-variant-numeric: tabular-nums; }
table.data td.num { color: var(--text); }

.footer {
  border-top: 1px solid var(--line);
  padding: 22px 24px 40px;
  text-align: center;
  color: var(--faint);
  font-size: 11.5px;
}

/* ------------------------------------------------------------------ *
 *  Responsive
 * ------------------------------------------------------------------ */
@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 62vh auto auto;
    height: auto;
  }
  .app { height: auto; }
  .pane--left { border-right: none; border-top: 1px solid var(--line); order: 2; }
  .pane--right { border-left: none; border-top: 1px solid var(--line); order: 3; }
  .stage { order: 1; height: 70vh; min-height: 420px; }
}


/* ---------------- what the run just showed ---------------- */
.outcome-line {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%) translateY(8px);
  width: min(560px, 88%); margin: 0; z-index: 6;
  background: rgba(13,17,25,.96); border: 1px solid rgba(255,122,60,.4);
  border-radius: 9px; padding: 11px 15px;
  font-size: 12.5px; line-height: 1.55; color: var(--dim);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  backdrop-filter: blur(8px);
}
.outcome-line.on { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.outcome-line b { color: var(--text); }
.linkish {
  background: none; border: none; padding: 0; font: inherit;
  color: var(--believer); text-decoration: underline; cursor: pointer;
}
.linkish:hover { color: var(--text); }

/* ---------------- play call to action ---------------- */
.play-cta {
  display: block; margin: 22px 0 26px; padding: 16px 20px;
  border-radius: 10px; text-decoration: none;
  background: linear-gradient(135deg, rgba(255,122,60,.14), rgba(255,122,60,.05));
  border: 1px solid rgba(255,122,60,.45);
  transition: border-color .15s, background .15s;
}
.play-cta:hover {
  text-decoration: none;
  border-color: rgba(255,122,60,.8);
  background: linear-gradient(135deg, rgba(255,122,60,.2), rgba(255,122,60,.07));
}
.play-cta-main {
  display: block; font-size: 17px; font-weight: 650; color: var(--believer);
}
.play-cta-sub {
  display: block; font-size: 11.5px; color: var(--faint); margin-top: 3px;
  font-family: var(--mono);
}

/* ------------------------------------------------------------------ *
 *  Phones
 * ------------------------------------------------------------------ */
.controls-toggle { display: none; }

@media (max-width: 1080px) {
  /* The masthead was taking a quarter of the screen before anything moved. */
  .masthead { padding: 10px 14px 12px; }
  .lede-line { font-size: 14.5px; }
  .tagline { font-size: 11.5px; }
  .mast-top nav { margin-left: 0; gap: 12px; flex-wrap: wrap; }
  .masthead nav { font-size: 11.5px; }

  .workspace { grid-template-rows: 58vh auto auto; }
  .stage { height: 58vh; min-height: 340px; }

  /* Controls collapse behind a toggle, so the reading order on a phone is
     the finding, then the simulation running, then the findings — instead of
     eighteen hundred pixels of sliders in between. */
  .controls-toggle {
    display: block; width: 100%; order: 2;
    border-radius: 0; border-left: none; border-right: none;
    padding: 11px; font-size: 12.5px; color: var(--dim);
    background: var(--panel); border-top: 1px solid var(--line);
  }
  .pane--left { display: none; }
  body.controls-open .pane--left { display: block; }

  .outcome-line { width: calc(100% - 24px); font-size: 12px; padding: 9px 12px; }
}

@media (max-width: 600px) {
  /* The lede already carries the message; the tagline underneath it is a
     second explanation competing for the only screen a phone has. */
  .masthead .tagline { display: none; }
  .lede-line { font-size: 15px; margin-bottom: 0; }
  .masthead nav a:not(.nav-play) { font-size: 11px; }
}
