/* China page · chart-specific styles, layered on top of /styles.css */

:root {
  /* Chart palette — keyed to MCNAIR tokens.
     CN (the focus) gets brat-deep so it pops without failing contrast;
     US gets a neutral ink-mute; the gap line is plain ink. */
  --c-gap: var(--ink);
  --c-us: #6E6E6E;            /* matches --ink-mute */
  --c-cn: #6FA600;            /* matches --brat-deep */
  --c-cn-soft: rgba(138, 206, 0, 0.22);
}

body {
  font-feature-settings: "ss01", "cv11", "tnum";
}

/* Card-axis links match the shared .page-head__lede a treatment. */
.card-axis a {
  color: var(--ink);
  border-bottom: 1px solid var(--brat);
  transition: background var(--t-fast);
}
.card-axis a:hover { background: rgba(138, 206, 0, 0.18); }

/* ---------- Commentary section (between the main chart and the timeline) ---------- */
.commentary {
  margin-top: clamp(56px, 6vw, 88px);
  margin-bottom: clamp(56px, 6vw, 88px);
}
.commentary__title {
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.08;
  font-size: clamp(26px, 3.4vw, 36px);
  margin: 0 0 24px;
}
.commentary__prose {
  column-count: 2;
  column-gap: clamp(28px, 3vw, 44px);
}
.commentary__prose p {
  font-size: clamp(16px, 1.1vw, 17px);
  line-height: 1.65;
  color: var(--ink);
  margin: 0 0 1em;
  break-inside: avoid;
}
.commentary__prose p:last-child { margin: 0; }
@media (max-width: 720px) {
  .commentary__prose { column-count: 1; }
}
.commentary__prose a {
  color: var(--ink);
  border-bottom: 1px solid var(--brat);
  transition: background var(--t-fast);
}
.commentary__prose a:hover { background: rgba(138, 206, 0, 0.18); }

.commentary__figures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(16px, 2vw, 24px);
  margin-top: clamp(28px, 3vw, 40px);
}
@media (max-width: 720px) {
  .commentary__figures { grid-template-columns: 1fr; }
}

.commentary__fig {
  margin: 0;
  border: 1px solid var(--rule);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  transition: border-color var(--t-med);
}
.commentary__fig:hover { border-color: var(--ink); }

.commentary__fig-link {
  display: block;
  background: var(--paper-soft);
  border-bottom: 1px solid var(--rule);
}
.commentary__fig-link img {
  width: 100%;
  height: auto;
  display: block;
}

.commentary__fig figcaption {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
  letter-spacing: -0.005em;
  padding: 14px 18px 16px;
}
.commentary__src {
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  margin-right: 6px;
}

/* ---------- Card overrides for this page ---------- */
/* The base .card has flex-direction: column; we want block-level
   children for the chart and timeline cards instead. */
.card.chart-card,
.card.timeline-card {
  display: block;
  padding: 24px 26px 22px;
}
.card.chart-card:hover,
.card.timeline-card:hover { border-color: var(--rule); }

.card.chart-card { padding-bottom: 14px; }
.card.timeline-card { margin-top: 24px; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.card-title {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.card-axis {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-mute);
  letter-spacing: -0.005em;
  font-variant-numeric: tabular-nums;
}

.card-axis--methodology {
  text-align: right;
  max-width: 28ch;
}

.cite-link {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: -0.005em;
  color: var(--ink);
  border-bottom: 1px solid var(--brat);
  transition: background var(--t-fast);
}
.cite-link:hover { background: rgba(138, 206, 0, 0.18); }

.chart-card__title {
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-size: clamp(20px, 2.4vw, 28px);
  color: var(--ink);
  margin: 0 0 12px;
  max-width: 28ch;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}

.chart-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: -0.005em;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule-strong);
  padding: 7px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
}
.chart-download:hover {
  border-color: var(--ink);
  background: var(--brat);
  color: var(--ink);
}
.chart-download:disabled {
  opacity: 0.6;
  cursor: progress;
}
.chart-download__arrow {
  font-weight: 600;
  font-size: 13px;
  line-height: 1;
}

#legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.swatch {
  display: inline-block;
  width: 14px;
  height: 2px;
  background: var(--ink);
}
.swatch-line { background: var(--c-gap); height: 2px; }
.swatch-cn { background: var(--c-cn); width: 9px; height: 9px; border-radius: 50%; }
.swatch-us { background: var(--c-us); width: 9px; height: 9px; border-radius: 50%; }

/* ---------- Chart ---------- */
#chart-wrap {
  width: 100%;
  overflow: visible;
  position: relative;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  padding: 12px 14px;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.5;
  box-shadow: 0 8px 22px -10px rgba(0, 0, 0, 0.22);
  min-width: 220px;
  font-variant-numeric: tabular-nums;
  z-index: 5;
  transform: translate(-50%, -100%);
}
.tooltip[hidden] { display: none; }
.tt-head {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink);
  margin-bottom: 2px;
}
.tt-date {
  font-size: 11.5px;
  color: var(--ink-mute);
  letter-spacing: -0.005em;
  margin-bottom: 10px;
}
.tt-row {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 6px 0;
  border-top: 1px solid var(--rule);
}
.tt-row .tt-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-top: 5px;
}
.tt-row .tt-swatch.us { background: var(--c-us); }
.tt-row .tt-swatch.cn { background: var(--c-cn); }
.tt-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
}
.tt-name { color: var(--ink); font-weight: 500; }
.tt-meta { color: var(--ink-soft); font-size: 11.5px; }

.chart {
  display: block;
  width: 100%;
  height: auto;
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
}
.chart .grid-line { stroke: var(--rule); stroke-width: 1; }
.chart .axis { stroke: var(--rule-strong); stroke-width: 1; }
.chart .axis-label { fill: var(--ink-soft); font-size: 12.5px; }
.chart .axis-title {
  fill: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.chart .gap-line { stroke: var(--c-gap); stroke-width: 1.75; fill: none; }
.chart .gap-area { fill: var(--c-cn-soft); }
.chart .cn-dot { fill: var(--c-cn); stroke: var(--paper); stroke-width: 1.5; }
.chart .us-tick { stroke: var(--c-us); stroke-width: 2; }
.chart .label-cn {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.chart .label-cn-gap {
  fill: var(--ink-soft);
  font-size: 11.5px;
  letter-spacing: -0.005em;
}
.chart .label-us {
  fill: var(--ink-mute);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.chart .label-us-box { fill: var(--paper); }
.chart .label-stub { stroke: var(--ink-mute); stroke-width: 0.75; }
.chart .hover-line {
  stroke: var(--ink-mute);
  stroke-width: 1;
  stroke-dasharray: 2 3;
  opacity: 0;
}
.chart .hover-line.is-active { opacity: 1; }
.chart .hover-target { fill: transparent; }

/* ---------- Timeline ---------- */
.timeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}
.tl-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tl-col h3 {
  margin: 0 0 10px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
}
.tl-col h3 .country-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}
.tl-row {
  display: grid;
  grid-template-columns: 80px 1fr 56px;
  gap: 12px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: -0.005em;
}
.tl-row:last-child { border-bottom: none; }
.tl-date {
  color: var(--ink-mute);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}
.tl-model { color: var(--ink); }
.tl-eci {
  color: var(--ink-soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .card.chart-card,
  .card.timeline-card {
    padding: 20px 18px 16px;
  }
  .tl-row { grid-template-columns: 70px 1fr 48px; }
}
