:root {
  --bg: #fafaf8;
  --surface: #f2f2ee;
  --border: #ddddd8;
  --text: #1a1a18;
  --muted: #6b6b66;
  --accent: #1a4cc8;
  --accent-hover: #1440aa;
  --accent-bg: #eef2fc;
  --die: #c9c9c2;
  --die-text: #86867e;
  --law: #1f9d55;
  --veto: #c0392b;
  --die-introduced: #e3e3dd;
  --die-referred: #c9c9c2;
  --die-committee: #a8a89f;
  --die-passed-one: #d9922e;
  --passed-both: #4f7dd6;
  --presented: #2f5fc7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

.header-inner,
.methodology-section,
.site-footer {
  max-width: 760px;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}

.site-header {
  padding: 40px 0 24px;
  border-bottom: 1px solid var(--border);
}

/* ─── Site nav (matches the main Spooner Labs site) ──────── */
.site-nav {
  background: #ffffff;
  padding: 24px 0;
}

.site-nav__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-nav__logo {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.site-nav__logo img {
  display: block;
  height: 36px;
  width: auto;
}

.site-nav__links {
  list-style: none;
  display: flex;
  gap: 24px;
  margin: 0;
  padding: 0;
}

.site-nav__links a {
  font-size: 0.875rem;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.site-nav__links a:hover,
.site-nav__links a[aria-current="page"] {
  color: #3663c1;
}

.site-nav__toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0 8px;
  flex-shrink: 0;
}

.site-nav__toggle span {
  display: block;
  height: 2px;
  width: 22px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.site-nav__toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.site-nav__toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.site-nav__toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 640px) {
  .site-nav__toggle { display: flex; }

  .site-nav {
    position: relative;
  }

  .site-nav__links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    padding: 8px 16px 16px;
    gap: 0;
    z-index: 100;
  }

  .site-nav__links.is-open {
    display: flex;
  }

  .site-nav__links li a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 12px 0;
    font-size: 1rem;
    border-bottom: 1px solid var(--border);
  }

  .site-nav__links li:last-child a {
    border-bottom: none;
  }
}

.header-eyebrow {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent);
}

.site-title {
  margin: 0 0 12px;
  font-size: 2rem;
  font-weight: 600;
}

.site-subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 60ch;
}

/* ── View toggle ─────────────────────────────────────────── */

.view-toggle {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.view-toggle__btn {
  font: inherit;
  font-weight: 500;
  font-size: 0.92rem;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.view-toggle__btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.view-toggle__btn:hover:not([aria-pressed="true"]) {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Full-bleed visualization area ──────────────────────────── */

.viz-main {
  width: 100%;
  padding: 24px 16px 8px;
}

.viz-view {
  width: 100%;
}

.sankey {
  width: 100%;
  height: 78vh;
  min-height: 560px;
}

.sankey svg {
  width: 100%;
  height: 100%;
  display: block;
}

.sankey-node rect {
  cursor: pointer;
}

.sankey-node text {
  font-size: 13px;
  fill: var(--text);
  font-weight: 500;
}

.sankey-node .sankey-node__count {
  font-size: 11.5px;
  fill: var(--muted);
  font-weight: 400;
}

/* ── Impact view ─────────────────────────────────────────── */

.impact-caption {
  max-width: 760px;
  margin: 0 auto 16px;
  padding: 0 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.impact-caption--cost {
  font-size: 0.82rem;
  margin-top: -8px;
}

.impact-caption--cost:empty {
  display: none;
}

.impact-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.impact-map {
  width: 100%;
  height: 62vh;
  min-height: 420px;
}

.impact-map svg {
  width: 100%;
  height: 100%;
  display: block;
}

.impact-map .state {
  stroke: var(--bg);
  stroke-width: 1;
  cursor: pointer;
}

.impact-map .state:hover {
  stroke: var(--accent);
  stroke-width: 1.5;
}

.impact-legend text {
  font-size: 11px;
  fill: var(--muted);
}

.impact-side {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.impact-panel h3 {
  margin: 0 0 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.impact-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.impact-bar-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 0.85rem;
}

button.impact-bar-row {
  width: 100%;
  font: inherit;
  background: none;
  border: none;
  padding: 3px 0;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
}

button.impact-bar-row:hover {
  background: var(--accent-bg);
}

button.impact-bar-row[aria-pressed="true"] {
  background: var(--selected-bg, var(--accent-bg));
  box-shadow: inset 0 0 0 1px var(--selected-color, var(--accent));
}

.impact-bar-row__pct {
  color: var(--muted);
  font-weight: 400;
}

.law-tag {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  flex-shrink: 0;
}

.law-groups {
  margin-top: 10px;
}

.law-group__heading {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin: 14px 0 6px;
}

.law-group__heading:first-child {
  margin-top: 4px;
}

.law-group__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.law-item {
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 7px;
}

.law-item__title-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.law-item__title {
  flex: 1;
}

.law-item__meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 2px;
}

.law-item__goal {
  margin: 5px 0 0;
  font-size: 0.83rem;
  color: var(--text);
  line-height: 1.45;
}

.law-item__riders {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.4;
}

.law-badge {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-radius: 3px;
  padding: 1px 5px;
  flex-shrink: 0;
  white-space: nowrap;
}

.law-badge--funded {
  color: var(--law);
  border: 1px solid var(--law);
}

.impact-bar-row__label {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.impact-bar-row__track {
  height: 6px;
  background: var(--surface);
  border-radius: 3px;
  overflow: hidden;
}

.impact-bar-row__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}

.impact-bar-row__count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.impact-territories {
  max-width: 760px;
  margin: 16px auto 0;
  padding: 0 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 900px) {
  .impact-layout {
    grid-template-columns: 1fr;
  }
  .impact-map {
    height: 48vh;
  }
}

/* ── Time-to-resolution histogram ───────────────────────────── */

.timing-chart {
  width: 100%;
  height: 62vh;
  min-height: 420px;
  max-width: 1100px;
  margin: 0 auto;
}

.timing-chart svg {
  width: 100%;
  height: 100%;
  display: block;
}

.timing-chart .bar-seg {
  cursor: pointer;
}

.timing-chart .axis text {
  font-size: 11px;
  fill: var(--muted);
}

.timing-chart .axis path,
.timing-chart .axis line {
  stroke: var(--border);
}

.timing-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  max-width: 900px;
  margin: 12px auto 0;
  padding: 0 16px;
}

.timing-legend__item {
  display: flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 3px 7px;
  cursor: pointer;
}

.timing-legend__item:hover {
  border-color: var(--border);
  background: var(--surface);
}

.timing-legend__item[aria-pressed="false"] {
  color: var(--muted);
  opacity: 0.55;
}

.timing-legend__swatch {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}

.timing-subhead {
  max-width: 1100px;
  margin: 32px auto 8px;
  padding: 0 16px;
  font-size: 0.95rem;
  font-weight: 600;
}

.timing-scatter-wrap {
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
}

.timing-scatter {
  display: block;
  width: 100%;
  height: 340px;
  cursor: grab;
}

.timing-scatter:active {
  cursor: grabbing;
}

.scatter-popup {
  position: absolute;
  z-index: 5;
  max-width: 320px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: 12px 14px;
  font-size: 0.85rem;
  pointer-events: none;
}

.scatter-popup__title {
  font-weight: 600;
  margin: 0 0 4px;
}

.scatter-popup__meta {
  color: var(--muted);
  margin: 0;
}

.timing-pareto-header {
  max-width: 1100px;
  margin: 32px auto 0;
  padding: 0 16px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.timing-pareto-header .timing-subhead {
  margin: 0;
  padding: 0;
}

.btn-toggle {
  font: inherit;
  font-size: 0.82rem;
  color: var(--accent);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
}

.btn-toggle:hover {
  border-color: var(--accent);
}

.scatter-zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-zoom {
  width: 28px;
  padding: 5px 0;
  text-align: center;
  font-weight: 600;
  line-height: 1;
}

.timing-pareto {
  width: 100%;
  height: 320px;
  max-width: 1100px;
  margin: 8px auto 0;
}

.timing-pareto svg {
  width: 100%;
  height: 100%;
  display: block;
}

.timing-pareto .axis text {
  font-size: 11px;
  fill: var(--muted);
}

.timing-pareto .axis path,
.timing-pareto .axis line {
  stroke: var(--border);
}

.timing-pareto .pareto-line {
  fill: none;
  stroke: var(--veto);
  stroke-width: 2;
}

.timing-pareto .pareto-dot {
  fill: var(--veto);
}

.cumulative-flow {
  width: 100%;
  height: 320px;
  max-width: 1100px;
  margin: 8px auto 0;
}

.cumulative-flow svg {
  width: 100%;
  height: 100%;
  display: block;
}

.cumulative-flow .axis text {
  font-size: 11px;
  fill: var(--muted);
}

.cumulative-flow .axis path,
.cumulative-flow .axis line {
  stroke: var(--border);
}

.cumulative-flow .flow-band {
  cursor: pointer;
}

.cumulative-flow .flow-band:hover {
  opacity: 0.8;
}

.sankey-link {
  fill: none;
  stroke-opacity: 0.35;
  transition: stroke-opacity 0.15s ease;
  cursor: pointer;
}

.sankey-link:hover {
  stroke-opacity: 0.6;
}

.sankey-link--continue { stroke: var(--accent); }
.sankey-link--die { stroke: var(--die); }
.sankey-link--law { stroke: var(--law); }
.sankey-link--veto { stroke: var(--veto); }

.viz-hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 4px 0 0;
}

.detail {
  max-width: 760px;
  max-height: 70vh;
  overflow-y: auto;
  margin: 16px auto 0;
  background: var(--accent-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
}

.detail h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.detail p {
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
}

/* ── Methodology / footer ────────────────────────────────── */

.methodology-section {
  padding: 32px 24px 56px;
  border-top: 1px solid var(--border);
  margin-top: 24px;
  color: var(--muted);
  font-size: 0.88rem;
}

.methodology-section h2 {
  color: var(--text);
  font-size: 1rem;
  margin: 24px 0 8px;
}

.site-footer {
  padding: 24px 24px 48px;
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .sankey-node text { font-size: 11px; }
  .sankey-node .sankey-node__count { font-size: 10px; }
}
