/* Editorial palette + theme tokens. Light is the lecture default. */
:root,
:root[data-theme="light"] {
  --bg: #f9f7f1;
  --ink: #1a1a1a;
  --ink-secondary: #6b6b6b;
  --rule: #d8d4ca;
  --card-bg: #ffffff;

  --fit: #2f6cb1;             /* blue */
  --kink: #c08a3e;             /* amber (legacy single-color kink) */
  --fires-right: #2f6cb1;      /* blue: w1 > 0, ReLU fires for x > kink */
  --fires-left: #c08a3e;       /* amber: w1 < 0, ReLU fires for x < kink */
  --ghost: #6b6b6b;            /* per-neuron contribution lines */
  --focus: #b8323a;            /* deep red, reserved for the *focused* neuron's contribution */
  --truth: #6b6b6b;
  --data: #1a1a1a;
  --grid: #ece8de;
  --axis: #b8b3a6;
}

:root[data-theme="dark"] {
  --bg: #181612;
  --ink: #ece7d9;
  --ink-secondary: #8a8579;
  --rule: #383530;
  --card-bg: #211e19;

  --fit: #6ea3dc;
  --kink: #d6a766;
  --fires-right: #6ea3dc;
  --fires-left: #d6a766;
  --ghost: #8a8579;
  --focus: #d77078;
  --truth: #8a8579;
  --data: #ece7d9;
  --grid: #2a2722;
  --axis: #4d4942;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.55;
}

/* ---------------------------------------------------------------------------
   Topbar
   --------------------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-secondary);
}

.topbar .brand { font-weight: 600; }
.topbar .scene-title {
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-style: italic;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-secondary);
}

.theme-toggle {
  background: transparent;
  color: var(--ink-secondary);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 5px 10px;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease;
}
.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--ink-secondary);
}

/* ---------------------------------------------------------------------------
   Stage
   --------------------------------------------------------------------------- */

.stage {
  max-width: 820px;
  margin: 10px auto 32px;
  padding: 0 28px;
}

.hero h1 {
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-weight: 500;
  font-size: 24px;
  margin: 0 0 4px;
  letter-spacing: -0.005em;
}

.hero .subtitle {
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-style: italic;
  font-size: 14px;
  color: var(--ink-secondary);
  margin: 0 0 8px;
}

/* ---------------------------------------------------------------------------
   Plot card
   --------------------------------------------------------------------------- */

.plot-card {
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 10px 14px 4px;
  margin-bottom: 6px;
}

/* Encoding key for the strip + architecture diagram. Sits between the
   plot card and the strip so the reader knows what the dots and edges
   mean before encountering them. */
.strip-caption {
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-style: italic;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-secondary);
  margin: 0 14px 4px;
  text-align: center;
}
.strip-caption sub {
  font-size: 0.78em;
}

#plot {
  width: 100%;
  height: auto;
  display: block;
}

#plot .axis line,
#plot .axis path {
  stroke: var(--axis);
  fill: none;
}

#plot .axis text {
  fill: var(--ink-secondary);
  font-size: 11px;
  font-family: "SF Mono", Menlo, monospace;
}

#plot .grid line {
  stroke: var(--grid);
  stroke-dasharray: 1 3;
}

#plot .data-point {
  fill: var(--data);
  fill-opacity: 0.55;
}

#plot .truth-curve {
  fill: none;
  stroke: var(--truth);
  stroke-width: 1.4;
  stroke-dasharray: 4 4;
  opacity: 0.7;
}

#plot .fit-curve {
  fill: none;
  stroke: var(--fit);
  stroke-width: 2.4;
  stroke-linejoin: round;
}

#plot .kink-tick {
  stroke-width: 1.6;
  stroke-linecap: round;
}
#plot .kink-tick.fires-right { stroke: var(--fires-right); }
#plot .kink-tick.fires-left  { stroke: var(--fires-left); }

#plot .kink-dot.fires-right { fill: var(--fires-right); }
#plot .kink-dot.fires-left  { fill: var(--fires-left); }

/* Add-on layers (ghost shape functions, neuron strip) declare their own
   styles in css/ghost-functions.css and css/neuron-strip.css. The CSS
   variables above are the only contract. */

/* ---------------------------------------------------------------------------
   Controls
   --------------------------------------------------------------------------- */

/* The neuron-strip's full styling lives in css/neuron-strip.css. Reserve
   layout space here so the page doesn't jump when that module loads. The
   horizontal padding matches .plot-card so the strip's SVG renders at the
   same on-page width as the plot's SVG -- kink x-positions align. */
.neuron-strip {
  position: relative;
  padding: 0 14px;
  margin-bottom: 2px;
}
#strip {
  width: 100%;
  height: auto;
  display: block;
}

/* Architecture diagram section. Same horizontal padding as plot-card and
   neuron-strip so the input/hidden/output nodes line up vertically with
   the kink ticks above. The architecture module owns its visual styling
   in css/architecture.css; here we just reserve the layout box. */
.architecture {
  position: relative;
  padding: 0 14px;
  margin-bottom: 4px;
}
#arch-svg {
  width: 100%;
  height: auto;
  display: block;
}

.controls {
  margin-bottom: 6px;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 4px 4px 8px;
  border-bottom: 1px solid var(--rule);
}

.slider-label {
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-secondary);
  min-width: 110px;
}

#width {
  flex: 1 1 auto;
  accent-color: var(--fit);
  height: 4px;
}

#width-value {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  min-width: 38px;
  text-align: right;
}

.caption {
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-style: italic;
  font-size: 15px;
  color: var(--ink-secondary);
  margin: 6px 4px 0;
  min-height: 1.55em;
}

/* ---------------------------------------------------------------------------
   Legend + footnote
   --------------------------------------------------------------------------- */

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  display: inline-block;
  width: 22px;
  height: 8px;
  border-radius: 1px;
}
.swatch-fit { background: var(--fit); }
.swatch-truth {
  background: linear-gradient(
    to right,
    var(--truth) 0 4px,
    transparent 4px 8px,
    var(--truth) 8px 12px,
    transparent 12px 16px,
    var(--truth) 16px 22px
  );
  height: 2px;
}
.swatch-data {
  background: var(--data);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  opacity: 0.6;
}
.swatch-fires-right {
  background: var(--fires-right);
  width: 2px;
  height: 12px;
  border-radius: 0;
}
.swatch-fires-left {
  background: var(--fires-left);
  width: 2px;
  height: 12px;
  border-radius: 0;
}

.footnote {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--ink-secondary);
  border-top: 1px solid var(--rule);
  padding-top: 8px;
  margin-top: 8px;
}

.footnote-meta {
  flex: 1 1 auto;
  text-align: right;
  font-style: italic;
  min-width: 220px;
}

.footnote kbd {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0 5px;
  background: var(--card-bg);
  color: var(--ink);
}

.footnote code {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--ink);
}
