/* ═══════════════════════════════════════════════════════════
   AI REWORK LAB
   Eight SVG charts examining how AI-generated code rework
   costs compound across engineering organizations.
   Data-journalism page. Vanilla JS. Static snapshot.
   ═══════════════════════════════════════════════════════════ */

.rw-main {
  background: var(--paper);
  color: var(--ink);
}

/* Local palette — chart-line and bar colors only.
   Site vocabulary (--paper, --ink, --accent) used everywhere else. */
.rw-main {
  --rw-positive: oklch(0.72 0.13 155);
  --rw-negative: var(--accent);
  --rw-neutral:  oklch(0.66 0.04 80);
  --rw-ai:       oklch(0.65 0.14 230);
  --rw-human:    oklch(0.75 0.12 85);
  --rw-grid:     color-mix(in oklab, var(--ink) 12%, transparent);
  --rw-soft:     color-mix(in oklab, var(--paper) 80%, var(--ink) 4%);
}

/* ── Hero ───────────────────────────────────────────────────── */
.rw-hero {
  padding: 120px 48px 60px;
  max-width: 1280px;
  margin: 0 auto;
}
.rw-title { margin-top: 22px; }
.rw-kicker {
  margin-top: 24px;
  max-width: 740px;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.rw-dateline {
  margin-top: 56px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
  max-width: 1000px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.rw-dateline .label { color: var(--ink-dim); }
.rw-dateline .value {
  color: var(--ink);
  margin-top: 4px;
  text-transform: none;
  letter-spacing: 0.04em;
  font-size: 12px;
}

/* ── Section wrapper ───────────────────────────────────────── */
.rw-section {
  padding: 72px 48px;
  max-width: 1280px;
  margin: 0 auto;
}
.rw-section .section-label { margin-bottom: 26px; }

/* ── Prose ──────────────────────────────────────────────────── */
.rw-prose { max-width: 760px; }
.rw-prose p {
  margin-top: 18px;
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
}
.rw-lede {
  font-family: "Newsreader", Georgia, serif;
  font-style: italic;
  font-size: 24px !important;
  line-height: 1.4 !important;
  color: var(--ink) !important;
}
.rw-note {
  max-width: 820px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-soft);
  margin-bottom: 28px;
}

/* ── Callout box ────────────────────────────────────────────── */
.rw-callout {
  margin-top: 32px;
  padding: 18px 22px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  max-width: 760px;
}
.rw-callout strong {
  color: var(--accent);
  font-weight: 500;
  font-size: 14px;
}

/* ── Controls ─────────────────────────────────────────────── */
.rw-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
  padding: 14px 18px;
  border: 1px solid var(--ink);
  background: var(--paper);
}
.rw-filter-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-right: 8px;
}
.rw-filter-divider {
  width: 1px;
  height: 16px;
  background: var(--ink-dim);
  margin: 0 12px;
  opacity: 0.5;
}
.rw-pill {
  appearance: none;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 6px 12px;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, transform 120ms ease;
}
.rw-pill:hover { transform: translateY(-1px); }
.rw-pill.active,
.rw-pill[data-active="true"] {
  background: var(--ink);
  color: var(--paper);
}

/* ── Chart wrapper ──────────────────────────────────────────── */
.rw-chart-wrap {
  position: relative;
  margin-top: 8px;
  border: 1px solid var(--ink);
  background: var(--paper);
  padding: 14px;
  overflow: hidden;
}
.rw-chart-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

/* ── Chart internals (SVG styled via CSS) ───────────────────── */
.rw-axis {
  stroke: var(--ink);
  stroke-width: 1;
}
.rw-grid {
  stroke: var(--rw-grid);
  stroke-width: 1;
}
.rw-axis-label {
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  fill: var(--ink-dim);
}
.rw-axis-title {
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  fill: var(--ink-soft);
}
.rw-bar-label {
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.04em;
  fill: var(--ink);
}
.rw-bar-value {
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  fill: var(--ink);
}
.rw-series-label {
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.04em;
  fill: var(--ink);
}
.rw-annotation {
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 10px;
  font-style: italic;
  letter-spacing: 0.04em;
  fill: var(--ink-soft);
}
.rw-line {
  fill: none;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.rw-line-ai    { stroke: var(--rw-ai); }
.rw-line-human { stroke: var(--rw-human); }

.rw-dot {
  r: 4;
  fill: var(--paper);
  stroke-width: 1.4;
}
.rw-dot-ai    { stroke: var(--rw-ai); }
.rw-dot-human { stroke: var(--rw-human); }

.rw-ci-line {
  stroke: var(--ink-dim);
  stroke-width: 1.5;
  fill: none;
}
.rw-ref-line {
  stroke: var(--ink-dim);
  stroke-width: 1.2;
  stroke-dasharray: 6 4;
  fill: none;
}
.rw-ref-label {
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
  fill: var(--ink-dim);
  font-style: italic;
}

.rw-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 8px 10px;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.04em;
  color: var(--ink);
  box-shadow: 0 6px 24px -10px rgba(0, 0, 0, 0.4);
  z-index: 10;
  white-space: nowrap;
}
.rw-tooltip strong { color: var(--accent); font-weight: 500; }
.rw-tooltip-dim { color: var(--ink-dim); }

/* ── Diverging bar chart (Faros) ───────────────────────────── */
.rw-bar-positive { fill: var(--rw-positive); }
.rw-bar-negative { fill: var(--rw-negative); }

/* ── Stacked bar chart (rebuilt dollar) ────────────────────── */
.rw-stack-rework  { fill: var(--rw-negative); }
.rw-stack-review  { fill: oklch(0.70 0.10 50); }
.rw-stack-other   { fill: var(--rw-neutral); }
.rw-stack-feature { fill: var(--rw-positive); }

/* ── Receipts grid ──────────────────────────────────────────── */
.rw-receipts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}
.rw-receipt {
  padding: 16px;
  border: 1px solid var(--ink-dim);
  background: var(--rw-soft);
}
.rw-receipt-label {
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 8px;
}
.rw-receipt-value {
  font-family: "Newsreader", Georgia, serif;
  font-size: 26px;
  line-height: 1.1;
  color: var(--ink);
}
.rw-receipt-value .small {
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  margin-left: 4px;
  text-transform: lowercase;
}

/* ── Figcaption ─────────────────────────────────────────────── */
.rw-figcaption {
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 11px;
  font-style: italic;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  margin-top: 10px;
  max-width: 760px;
}

/* ── Colophon ───────────────────────────────────────────────── */
.rw-colophon-section { padding-bottom: 80px; }
.rw-method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}
.rw-method-grid p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft);
  margin-top: 8px;
}
.rw-method-head {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--ink-dim);
}
.rw-method-ctas {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 26px;
}

/* ── Related labs aside ─────────────────────────────────────── */
.rw-related {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 48px 110px;
}
.rw-related .section-label { margin-bottom: 24px; }
.rw-related-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.rw-related-card {
  padding: 18px;
  border-top: 2px solid var(--ink);
  background: var(--rw-soft);
}
.rw-related-card .rw-card-kicker {
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}
.rw-related-card h3 {
  font-family: "Newsreader", Georgia, serif;
  font-size: 19px;
  margin: 8px 0 6px;
}
.rw-related-card h3 a {
  color: var(--ink);
  border-bottom: 1px solid var(--ink-dim);
}
.rw-related-card h3 a:hover { color: var(--accent); }
.rw-related-card p {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .rw-hero,
  .rw-section,
  .rw-related { padding-left: 24px; padding-right: 24px; }
  .rw-dateline { grid-template-columns: 1fr; }
  .rw-receipts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rw-related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rw-controls { padding: 10px 12px; gap: 4px; }
  .rw-pill { padding: 5px 9px; font-size: 10px; }
}
@media (max-width: 540px) {
  .rw-hero { padding-top: 90px; }
  .rw-receipts { grid-template-columns: 1fr; }
  .rw-related-grid { grid-template-columns: 1fr; }
  .rw-receipt-value { font-size: 22px; }
}
