/* -------- Corruption in Context — editorial static dashboard -------- */

:root {
  /* Palette — warm off-white paper, deep ink, restrained accents */
  --paper: #f5f1ea;
  --paper-2: #efe9df;
  --ink: #1a1817;
  --ink-2: #3d3a35;
  --ink-3: #6b665e;
  --rule: #d9d1c2;
  --rule-strong: #a89f8d;

  --accent-actor: #8a2a2a;      /* muted brick — actor-side */
  --accent-process: #2f4a6b;    /* muted steel — process-side */
  --accent-warn: #b96e1a;       /* attention */
  --accent-moved: #6b3b91;      /* rescore movement */

  --tag-structural: #2f4a6b;
  --tag-mixed:      #6b3b91;
  --tag-personal:   #8a5a1a;

  /* Heat-map quadrant colors — must match those drawn in app.js chart */
  --quad-ll: #c4d8e6;   /* cool light blue      — little wrong, clean process */
  --quad-lr: #e39374;   /* hot red-orange       — real wrong, clean process */
  --quad-ur: #d3ac7c;   /* muted amber-brown    — real wrong, dirty process */
  --quad-ul: #c4d8e6;   /* cool base w/ striped overlay for opposition failure */

  --font-serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Consolas, monospace;

  --measure: 66ch;
  --wrap-max: 1240px;
  --wrap-narrow: 780px;

  --shadow-1: 0 1px 2px rgba(26, 24, 23, 0.04), 0 2px 4px rgba(26, 24, 23, 0.02);
  --shadow-2: 0 2px 6px rgba(26, 24, 23, 0.06), 0 8px 24px rgba(26, 24, 23, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  max-width: var(--wrap-max);
  margin: 0 auto;
  padding: 0 32px;
}
.wrap.narrow { max-width: var(--wrap-narrow); }

/* -------- Masthead -------- */
.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: saturate(1.2) blur(6px);
}
.masthead .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-top: 16px;
  padding-bottom: 16px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.masthead nav {
  display: flex;
  gap: 24px;
  font-size: 14px;
}
.masthead nav a {
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: color 120ms ease, border-color 120ms ease;
}
.masthead nav a:hover {
  color: var(--ink);
  border-bottom-color: var(--rule-strong);
}

/* -------- Hero -------- */
.hero { padding: 72px 0 40px; }
.hero h1 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(40px, 6vw, 68px);
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin: 0 0 24px;
  max-width: 18ch;
}
.hero .lede {
  font-family: var(--font-serif);
  font-size: clamp(19px, 1.6vw, 22px);
  line-height: 1.5;
  max-width: 62ch;
  color: var(--ink-2);
  margin: 0 0 18px;
  font-weight: 400;
}
.hero .byline {
  font-size: 14px;
  color: var(--ink-3);
  max-width: 62ch;
  margin: 0;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
}

/* -------- Frame disclosure -------- */
.frame-disclosure {
  background: var(--paper-2);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 56px 0;
  margin: 24px 0;
}
.frame-marker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-actor);
  margin-bottom: 12px;
}
.frame-disclosure h2 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(28px, 3.5vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 24px;
}
.frame-disclosure p {
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink-2);
  margin: 0 0 18px;
}
.frame-list {
  padding-left: 24px;
  margin: 24px 0 24px;
}
.frame-list li {
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 14px;
  color: var(--ink-2);
}
.frame-list li strong { color: var(--ink); }
.frame-footnote {
  font-size: 15px;
  color: var(--ink-3);
  padding-top: 18px;
  border-top: 1px dashed var(--rule);
  margin-top: 24px !important;
}

/* -------- Chart section -------- */
.chart-section { padding: 56px 0; }
.chart-head { max-width: 66ch; margin-bottom: 24px; }
.chart-head h2 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(28px, 3.5vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}
.chart-head p {
  font-size: 16px;
  color: var(--ink-2);
  line-height: 1.6;
  margin: 0;
}

/* Quadrant labels floating above the chart */
.axes-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  margin: 32px 0 0;
  border-radius: 4px;
  overflow: hidden;
}
.quad-label {
  padding: 12px 16px;
  background: var(--paper);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink);
}
.quad-label span {
  display: block;
  margin-top: 4px;
  font-family: var(--font-serif);
  font-weight: 400;
  font-style: italic;
  font-size: 13px;
  color: var(--ink-3);
  text-transform: none;
  letter-spacing: 0;
}
/* Legend quad chips — use lighter tints of the heat-map colors so text stays readable */
.q-ul {
  background-color: #dde8f0;
  background-image: repeating-linear-gradient(
    45deg,
    transparent 0,
    transparent 8px,
    rgba(227, 147, 116, 0.32) 8px,
    rgba(227, 147, 116, 0.32) 16px
  );
}
.q-ur { background: #e7d5b8; }
.q-ll { background: #dde8f0; }
.q-lr { background: #f0c2ae; }

/* Chart + detail split */
.chart-and-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr);
  gap: 24px;
  margin-top: 0;
  border: 1px solid var(--rule);
  border-top: 0;
  border-radius: 0 0 4px 4px;
  background: var(--paper);
  overflow: hidden;
}
.chart-wrap {
  position: relative;
  padding: 24px;
  border-right: 1px solid var(--rule);
  min-height: 640px;
}
#scatter {
  width: 100%;
  height: 640px;
  display: block;
}

/* Detail panel */
.detail-panel {
  padding: 28px;
  background: var(--paper-2);
  max-height: 688px;
  overflow-y: auto;
  font-size: 14px;
}
.detail-empty {
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1.55;
}
.detail-empty-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink);
  margin-bottom: 12px;
}
.detail-empty p { margin: 0 0 14px; }
.detail-empty-hint { font-style: italic; }

/* Detail panel — populated state */
.detail .d-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.detail .d-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0 0 6px;
}
.detail .d-sub {
  font-size: 13px;
  color: var(--ink-3);
  margin: 0 0 14px;
}
.detail .d-summary {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  border-left: 3px solid var(--rule-strong);
  padding: 12px 16px;
  border-radius: 0 3px 3px 0;
  margin: 0 0 18px;
}
.detail .d-note {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-2);
  padding: 14px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin: 0 0 20px;
  font-style: italic;
}
.detail .d-section-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink);
  margin: 20px 0 10px;
}
.axis-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.axis-table tr { border-bottom: 1px dotted var(--rule); }
.axis-table tr:last-child { border-bottom: 0; }
.axis-table td {
  padding: 6px 0;
  vertical-align: baseline;
}
.axis-table .axis-name {
  color: var(--ink-2);
  width: 60%;
}
.axis-table .axis-def {
  font-size: 11.5px;
  color: var(--ink-3);
  font-style: italic;
  display: block;
  margin-top: 2px;
  line-height: 1.4;
}
.axis-table .axis-score {
  text-align: right;
  width: 40%;
  padding-left: 12px;
  white-space: nowrap;
}
.axis-bar {
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
  width: 60px;
  height: 8px;
  background: var(--rule);
  position: relative;
  border-radius: 1px;
}
.axis-bar-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: var(--ink);
  border-radius: 1px;
}
.axis-bar-fill.actor { background: var(--accent-actor); }
.axis-bar-fill.process { background: var(--accent-process); }
.axis-value {
  display: inline-block;
  vertical-align: middle;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  min-width: 12px;
}
.axis-table tr.sum-row {
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}
.axis-table tr.sum-row td {
  padding: 8px 0;
  font-weight: 600;
  color: var(--ink);
}
.tag-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: white;
  vertical-align: middle;
  margin-left: 8px;
}
.tag-badge.tag-structural { background: var(--tag-structural); }
.tag-badge.tag-mixed { background: var(--tag-mixed); }
.tag-badge.tag-personal { background: var(--tag-personal); }

.d-sources {
  margin: 10px 0 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.d-sources li { margin-bottom: 6px; line-height: 1.45; }
.d-sources a {
  color: var(--accent-process);
  text-decoration: underline;
  text-decoration-color: rgba(47, 74, 107, 0.4);
  text-underline-offset: 2px;
}
.d-sources a:hover { text-decoration-color: currentColor; }

.d-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
  font-size: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
  margin-top: 20px;
  color: var(--ink-3);
}
.d-meta strong { color: var(--ink); font-weight: 600; }

/* -------- Chart tooltip -------- */
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: var(--paper);
  padding: 8px 12px;
  border-radius: 3px;
  font-size: 12px;
  line-height: 1.4;
  max-width: 260px;
  opacity: 0;
  transition: opacity 120ms ease;
  box-shadow: var(--shadow-2);
  z-index: 10;
}
.chart-tooltip.show { opacity: 1; }
.chart-tooltip .tt-title { font-weight: 600; margin-bottom: 2px; }
.chart-tooltip .tt-sub { color: rgba(245, 241, 234, 0.7); font-size: 11px; }

/* -------- Controls -------- */
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin: 32px 0 16px;
  padding: 20px 24px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.control-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  font-family: var(--font-sans);
  font-size: 12.5px;
  padding: 5px 10px;
  border: 1px solid var(--rule-strong);
  background: var(--paper);
  color: var(--ink-2);
  cursor: pointer;
  border-radius: 3px;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
#president-filter {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--rule-strong);
  background: var(--paper);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink);
  border-radius: 3px;
}
.reset-btn {
  font-family: var(--font-sans);
  font-size: 12.5px;
  padding: 6px 14px;
  border: 1px solid var(--rule-strong);
  background: var(--paper);
  color: var(--ink-2);
  cursor: pointer;
  border-radius: 3px;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
  align-self: flex-start;
}
.reset-btn:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.chart-status {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 12px;
  min-height: 1.4em;
}

/* -------- Reading notes -------- */
.reading-notes {
  padding: 56px 0;
  border-top: 1px solid var(--rule);
  background: var(--paper-2);
}
.reading-notes h2 {
  font-family: var(--font-serif);
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 24px;
}
.reading-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 32px;
  margin: 24px 0 24px;
}
.reading-grid h3 {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--ink);
}
.reading-grid ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-2);
}
.reading-grid li { margin-bottom: 10px; line-height: 1.5; }
.shape-key, .size-key, .fill-key {
  display: inline-block;
  width: 12px;
  height: 12px;
  vertical-align: middle;
  margin-right: 6px;
}
.shape-circle { border: 1.5px solid var(--ink); border-radius: 50%; background: transparent; }
.shape-square { border: 1.5px solid var(--ink); background: transparent; }
.shape-diamond {
  border: 1.5px solid var(--ink);
  background: transparent;
  transform: rotate(45deg);
  width: 9px; height: 9px;
  margin-left: 2px; margin-right: 8px;
}
.size-key { border: 1.5px solid var(--ink); border-radius: 50%; background: transparent; }
.size-L { width: 6px; height: 6px; margin: 0 9px 0 3px; }
.size-M { width: 10px; height: 10px; margin: 0 7px 0 1px; }
.size-H { width: 14px; height: 14px; margin: 0 5px 0 -1px; }
.fill-solid { background: var(--ink); border: 1.5px solid var(--ink); border-radius: 50%; }
.fill-hollow { border: 1.5px solid var(--ink); background: transparent; border-radius: 50%; }
.reading-caveat {
  font-size: 14px;
  color: var(--ink-3);
  font-style: italic;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  margin: 24px 0 0;
}

/* -------- Methodology teaser -------- */
.methodology-teaser {
  padding: 56px 0;
  border-top: 1px solid var(--rule);
  background: var(--paper-2);
}
.methodology-teaser h2 {
  font-family: var(--font-serif);
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 20px;
}
.methodology-teaser p {
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-2);
  margin: 0 0 16px;
}
.methodology-teaser ul {
  padding-left: 24px;
  margin: 12px 0 16px;
}
.methodology-teaser li {
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--ink-2);
  margin-bottom: 12px;
}

/* -------- Footer -------- */
footer {
  padding: 40px 0 60px;
  border-top: 1px solid var(--rule);
  background: var(--paper);
}
footer p {
  font-size: 13px;
  color: var(--ink-3);
  margin: 0;
  line-height: 1.55;
}

/* -------- Chart SVG styling -------- */
.axis path, .axis line {
  stroke: var(--rule-strong);
  shape-rendering: crispEdges;
}
.axis text {
  fill: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 11px;
}
.axis-title {
  fill: var(--ink);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.gridline {
  stroke: var(--rule);
  stroke-dasharray: 2 2;
  fill: none;
}
.gridline.major {
  stroke: var(--rule-strong);
  stroke-dasharray: none;
}
.point {
  cursor: pointer;
  transition: stroke-width 100ms ease, opacity 150ms ease;
}
.point:hover {
  stroke-width: 2.5px !important;
}
.point.dimmed {
  opacity: 0.12;
  pointer-events: none;
}
.point.selected {
  stroke: var(--ink) !important;
  stroke-width: 3px !important;
}
/* -------- Responsive -------- */
@media (max-width: 900px) {
  .wrap { padding: 0 20px; }
  .masthead nav { display: none; }
  .hero { padding: 48px 0 32px; }
  .frame-disclosure { padding: 40px 0; }
  .axes-legend { grid-template-columns: 1fr; }
  .chart-and-detail {
    grid-template-columns: 1fr;
  }
  .chart-wrap {
    border-right: 0;
    border-bottom: 1px solid var(--rule);
    min-height: 480px;
    padding: 16px;
  }
  #scatter { height: 480px; }
  .detail-panel { max-height: 480px; padding: 20px; }
  .controls { padding: 16px; gap: 16px; }
  .reading-grid { grid-template-columns: 1fr; gap: 24px; }
  .d-meta { grid-template-columns: 1fr; }
}
