/* America is Not That Bad — "The Rebuttal" broadsheet */

:root {
  color-scheme: light;
  --paper:      #f3ede1;
  --paper-2:    #ebe3d3;
  --ink:        #16130f;
  --ink-2:      #4a443b;
  --muted:      #81796b;
  --grid:       #ddd4c3;
  --axis:       #b5aa95;
  --rule:       #16130f;
  --hover:      rgba(22, 19, 15, 0.05);

  --red:        #c8102e;
  --navy:       #1d3461;
  --link:       #1d3461;

  /* Data colors, validated for CVD on --paper. US is always series 1. */
  --series-1:   #c8102e;
  --series-2:   #3d5fb8;
  --series-3:   #1f9a8a;
  --series-4:   #d49a00;
  --bar-other:  #c9bfac;

  --display: "Big Shoulders", "Impact", "Arial Narrow", sans-serif;
  --serif:   "Newsreader", Georgia, "Times New Roman", serif;
  --mono:    "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --paper-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.09 0 0 0 0 0.07 0 0 0 0 0.05 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper:     #10151f;
    --paper-2:   #171e2c;
    --ink:       #f1e9d8;
    --ink-2:     #c4bba8;
    --muted:     #8a8576;
    --grid:      #252d3c;
    --axis:      #3a4356;
    --rule:      #f1e9d8;
    --hover:     rgba(241, 233, 216, 0.06);
    --red:       #e23b52;
    --navy:      #9db5ea;
    --link:      #9db5ea;
    --series-1:  #e23b52;
    --series-2:  #6a8ee0;
    --series-3:  #21a08e;
    --series-4:  #b98400;
    --bar-other: #3b4456;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper:     #10151f;
  --paper-2:   #171e2c;
  --ink:       #f1e9d8;
  --ink-2:     #c4bba8;
  --muted:     #8a8576;
  --grid:      #252d3c;
  --axis:      #3a4356;
  --rule:      #f1e9d8;
  --hover:     rgba(241, 233, 216, 0.06);
  --red:       #e23b52;
  --navy:      #9db5ea;
  --link:      #9db5ea;
  --series-1:  #e23b52;
  --series-2:  #6a8ee0;
  --series-3:  #21a08e;
  --series-4:  #b98400;
  --bar-other: #3b4456;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background-color: var(--paper);
  background-image: var(--paper-grain);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--red); }

.masthead, main, .corrections {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px;
}
@media (max-width: 600px) {
  .masthead, main, .corrections { padding: 0 16px; }
}

/* ------------------------------------------------------------- masthead */

.dateline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--rule);
  font: 500 0.72rem/1.3 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.dateline span { white-space: nowrap; }
@media (max-width: 600px) {
  .hide-sm { display: none; }
  .dateline { font-size: 0.62rem; letter-spacing: 0.04em; }
}

.nameplate {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(3rem, 12.4vw, 9.6rem);
  line-height: 0.86;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  text-align: center;
  padding: 18px 0 14px;
  font-variation-settings: "opsz" 72;
}
.nameplate .not { color: var(--red); }
.subhead {
  position: relative;
  border-top: 4px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 14px 0;
  margin-top: 6px;
  text-align: center;
}
.subhead::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 2px;
  border-top: 1px solid var(--rule);
}
.tagline {
  font-style: italic;
  font-size: clamp(1.15rem, 2.6vw, 1.6rem);
  line-height: 1.3;
}

.stamp {
  position: absolute;
  right: 4px;
  top: -64px;
  width: 104px;
  height: 104px;
  border: 3px double var(--red);
  border-radius: 50%;
  color: var(--red);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: rotate(-14deg);
  font-family: var(--mono);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  line-height: 1.1;
  font-size: 0.68rem;
  background: var(--paper);
  opacity: 0.92;
}
.stamp span:first-child { font-family: var(--display); font-size: 1.9rem; letter-spacing: 0; }
@media (max-width: 760px) { .stamp { display: none; } }

/* ticker */
.ticker {
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  margin: 18px 0 0;
  font: 500 0.8rem/1 var(--mono);
  letter-spacing: 0.02em;
}
.ticker-track {
  display: flex;
  width: max-content;
  gap: 32px;
  padding: 11px 0;
  animation: ticker 60s linear infinite;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker s {
  white-space: nowrap;
  text-decoration-color: var(--red);
  text-decoration-thickness: 2px;
}
.ticker-label {
  white-space: nowrap;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--paper);
  background: var(--red);
  padding: 4px 8px;
  margin: -4px 0;
}
@keyframes ticker { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; flex-wrap: wrap; width: auto; padding: 11px 12px; gap: 12px 24px; }
  .ticker-track > [aria-hidden="true"] { display: none; }
}

/* front page: lede + contents */
.front {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 40px;
  padding: 36px 0 12px;
}
@media (max-width: 760px) { .front { grid-template-columns: 1fr; gap: 28px; padding-top: 28px; } }

.lede { font-size: 1.2rem; line-height: 1.55; }
.lede::first-letter {
  float: left;
  font-family: var(--display);
  font-weight: 900;
  font-size: 5.2em;
  line-height: 0.78;
  margin: 0.06em 0.08em 0 0;
  color: var(--red);
}

.contents {
  border-left: 1px solid var(--rule);
  padding-left: 28px;
}
@media (max-width: 760px) { .contents { border-left: 0; padding-left: 0; border-top: 4px solid var(--rule); padding-top: 12px; } }
.contents h2 {
  font: 700 0.72rem/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.contents ol { list-style: none; }
.contents li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  border-bottom: 1px dotted var(--axis);
  padding: 9px 0;
}
.contents a {
  flex: 1;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.45rem;
  line-height: 1.1;
  text-transform: uppercase;
}
.contents a:hover { color: var(--red); }
.contents a span {
  display: inline-block;
  min-width: 2.2em;
  color: var(--red);
}
.contents em { font: 500 0.75rem var(--mono); font-style: normal; color: var(--muted); }

/* ------------------------------------------------------------- parts */

.part { padding-top: 40px; scroll-margin-top: 0; }

.part-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: end;
  gap: 4px 20px;
  background: var(--ink);
  color: var(--paper);
  padding: 18px 22px 16px;
}
.part-head h2 {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2.2rem, 6vw, 4rem);
  line-height: 0.9;
  text-transform: uppercase;
  font-variation-settings: "opsz" 72;
}
.part-num, .part-range {
  font: 700 0.72rem/1.4 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.part-num { color: var(--paper); background: var(--red); padding: 3px 8px; align-self: center; }
.part-range { opacity: 0.7; }
@media (max-width: 600px) {
  .part-head { grid-template-columns: 1fr; padding: 14px 16px; }
  .part-num { justify-self: start; }
  .part-range { display: none; }
}

/* ------------------------------------------------------------- exhibits */

.exhibit {
  padding: 36px 0 28px;
  border-bottom: 1px solid var(--rule);
  scroll-margin-top: 12px;
}
.exhibit:last-child { border-bottom: 0; }

.complaint {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
  margin-bottom: 18px;
}
.complaint .label {
  font: 700 0.7rem/1.4 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.complaint s {
  font-style: italic;
  font-size: 1.2rem;
  color: var(--ink-2);
  text-decoration-color: var(--red);
  text-decoration-thickness: 2px;
}

.ex-body {
  display: grid;
  grid-template-columns: minmax(180px, 250px) 1fr;
  gap: 28px;
  align-items: start;
}
@media (max-width: 760px) { .ex-body { grid-template-columns: 1fr; gap: 14px; } }

.stat {
  border-top: 4px solid var(--red);
  padding-top: 10px;
}
.stat strong {
  display: block;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(3.6rem, 9vw, 5.4rem);
  line-height: 0.85;
  color: var(--red);
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 72;
}
.stat span {
  display: block;
  margin-top: 8px;
  font: 500 0.75rem/1.4 var(--mono);
  color: var(--ink-2);
  max-width: 26ch;
}

.ex-text h3 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.7rem, 3.6vw, 2.6rem);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.002em;
  text-wrap: balance;
  font-variation-settings: "opsz" 48;
}
.ex-text .dek {
  margin-top: 12px;
  color: var(--ink-2);
  max-width: 62ch;
}

.source {
  margin-top: 10px;
  font: 400 0.72rem/1.5 var(--mono);
  color: var(--muted);
}
.source a { color: var(--muted); }
.source a:hover { color: var(--red); }

/* ------------------------------------------------------------- charts */

.chart { margin-top: 26px; }
.chart-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 20px;
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--grid);
}
.chart-unit {
  font: 500 0.7rem/1.3 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  list-style: none;
  font: 500 0.72rem/1.3 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.legend .key { width: 16px; height: 3px; }
.legend .key.bar { width: 10px; height: 10px; }

.plot { position: relative; }
.plot svg { display: block; width: 100%; overflow: visible; }
.plot svg:focus { outline: none; }
.plot svg:focus-visible { outline: 2px solid var(--red); outline-offset: 6px; }
.plot text { font-family: var(--mono); }

.tick text { fill: var(--muted); font-size: 11px; }
.gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.axisline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.baseline-rule { stroke: var(--ink-2); stroke-width: 1; shape-rendering: crispEdges; }
.series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series-line.us { stroke-width: 3; }
.series-area { stroke: none; opacity: 0.12; }
.end-dot, .hover-dot { stroke: var(--paper); stroke-width: 2; }
.leader { stroke: var(--axis); stroke-width: 1; fill: none; }
.end-label .val { fill: var(--ink); font-weight: 700; font-size: 12px; }
.end-label .name { fill: var(--ink-2); font-size: 10.5px; letter-spacing: 0.04em; }
.crosshair { stroke: var(--ink); stroke-width: 1; shape-rendering: crispEdges; }
.note-line { stroke: var(--ink-2); stroke-width: 1; shape-rendering: crispEdges; }
.note-text { fill: var(--ink-2); font-size: 10px; font-weight: 700; letter-spacing: 0.08em; }

.bar-row .hit { fill: transparent; }
.bar-row:hover .hit, .bar-row.active .hit { fill: var(--hover); }
.bar-row:focus { outline: none; }
.bar-row:focus-visible .hit { stroke: var(--red); stroke-width: 1.5; }
.bar-label { fill: var(--ink-2); font-size: 11px; letter-spacing: 0.04em; }
.bar-label.hl { fill: var(--ink); font-weight: 700; }
.bar-value { fill: var(--ink-2); font-size: 12px; }
.bar-value.hl { fill: var(--ink); font-weight: 700; }
.bar-note { fill: var(--muted); font-size: 10px; font-weight: 400; }

.tooltip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  min-width: 150px;
  max-width: 280px;
  padding: 9px 12px 10px;
  background: var(--ink);
  color: var(--paper);
  font: 400 0.75rem/1.45 var(--mono);
  box-shadow: 4px 4px 0 var(--red);
}
.tooltip .tt-head {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid currentColor;
  padding-bottom: 4px;
  margin-bottom: 5px;
}
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.tooltip .tt-row .key { width: 10px; height: 3px; flex: none; }
.tooltip .tt-row .nm { flex: 1; opacity: 0.8; }
.tooltip .tt-row .v { font-weight: 700; }

/* ------------------------------------------------------------- data table */

.data-table { margin-top: 14px; }
.data-table summary {
  cursor: pointer;
  width: max-content;
  font: 700 0.72rem/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  padding: 7px 10px;
  border: 1px solid var(--rule);
  list-style: none;
}
.data-table summary::-webkit-details-marker { display: none; }
.data-table summary::before { content: "+ "; color: var(--red); }
.data-table[open] summary::before { content: "− "; }
.data-table summary:hover { background: var(--ink); color: var(--paper); }
.data-table .scroll {
  margin-top: 10px;
  max-height: 340px;
  overflow: auto;
  border-top: 2px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.data-table table { border-collapse: collapse; width: 100%; font: 400 0.78rem/1.4 var(--mono); }
.data-table th, .data-table td { padding: 5px 10px; text-align: right; white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table thead th {
  position: sticky; top: 0;
  background: var(--paper-2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.7rem;
}
.data-table tbody tr + tr td { border-top: 1px dotted var(--grid); }

/* ------------------------------------------------------------- footer */

.corrections { padding-top: 32px; padding-bottom: 72px; }
.corrections-box {
  border: 1px solid var(--rule);
  outline: 1px solid var(--rule);
  outline-offset: 4px;
  padding: 24px 26px;
  margin: 8px 4px 0;
  max-width: 720px;
}
.corrections-box h2 {
  font-family: var(--display);
  font-weight: 900;
  font-size: 1.8rem;
  line-height: 1;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.corrections-box p + p { margin-top: 10px; }
.sign-off {
  margin-top: 40px;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  text-transform: uppercase;
  color: var(--red);
}

@media print {
  .ticker, .data-table summary, .tooltip, .stamp { display: none; }
  .exhibit { break-inside: avoid; }
  body { background-image: none; }
}
