/* Pay Deal Explained: base styles.
   Colour meanings used everywhere: teal = a percentage rise, amber = a flat minimum,
   red = prices, grey = where you start. */

:root {
  --paper: #fbfaf7;
  --ink: #1d2433;
  --muted: #5b6475;
  --line: #e4e1d8;
  --card: #ffffff;
  --teal: #0f766e;
  --teal-soft: #d1efe9;
  --teal-ink: #115e59;     /* teal text on --teal-soft (AA) */
  --amber: #b45309;
  --amber-soft: #fdecc8;
  --amber-ink: #92400e;    /* amber text on --amber-soft (AA) */
  --red: #b42318;
  --on-teal: #ffffff;
  --grey-bar: #bcd9d4;
  --field-border: #8a93a3; /* 3:1 against white cards (WCAG 1.4.11) */

  /* chart marks: validated with the dataviz palette checker (light, on #ffffff) */
  --mark-pct: #00897b;
  --mark-flat: #b45309;
  --mark-price: #b42318;
  --mark-earlier: #c9ced6;       /* a light fill keeps it well apart from the caps... */
  --mark-earlier-edge: #8a93a3;  /* ...and this 1px edge gives the shape 3:1 (WCAG 1.4.11) */
  --mark-prev: #8a93a3;
  --grid: #e7e4dc;
  --chart-text: 12px;            /* axis label size; Present mode raises it */

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --measure: 40rem;
  --wide: 60rem;
  --gutter: 1rem;
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12161f;
    --ink: #ecebe6;
    --muted: #a3aab8;
    --line: #2a3140;
    --card: #1a2030;
    --teal: #3fb3a2;
    --teal-soft: #12322e;
    --teal-ink: #7fd6c8;
    --amber: #f0b46a;
    --amber-soft: #3a2a12;
    --amber-ink: #f5c992;
    --red: #f28b82;
    --on-teal: #0b1a18;
    --grey-bar: #2f4c48;
    --field-border: #6b7489;
    /* validated on the dark card #1a2030 */
    --mark-pct: #26a392;
    --mark-flat: #c97e33;
    --mark-price: #e0675c;
    --mark-earlier: #3a4256;
    --mark-earlier-edge: #66708a;
    --mark-prev: #7c869b;
    --grid: #283041;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Links land just below the sticky header. header.js measures it into --header-h;
     the fallbacks are its usual heights, for when JavaScript has not run. */
  scroll-padding-top: calc(var(--header-h, 3.75rem) + 0.5rem);
}

@media (max-width: 420px) {
  html { scroll-padding-top: calc(var(--header-h, 5.6rem) + 0.5rem); }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 0.5rem;
}

h1 { font-size: clamp(2.1rem, 1.3rem + 3.6vw, 3.4rem); letter-spacing: -0.01em; max-width: 21ch; }
h2 { font-size: clamp(1.65rem, 1.25rem + 1.6vw, 2.3rem); letter-spacing: -0.005em; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.1rem; }

p { margin: 0 0 1rem; }
a { color: var(--teal); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }
strong { font-weight: 650; }

:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
  border-radius: 3px;
}

.num, .money { font-variant-numeric: tabular-nums; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  z-index: 50;
  background: var(--card);
  color: var(--ink);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
}
.skip-link:focus { left: 0.75rem; }

/* ---------- tables ---------- */

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
}

caption {
  text-align: left;
  color: var(--muted);
  font-size: 0.9rem;
  padding-bottom: 0.5rem;
}

th, td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th { font-weight: 650; }
td.r, th.r { text-align: right; }

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  padding: 0.55rem var(--gutter);
  background: var(--paper);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.site-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
  text-decoration: none;
}

.status-chip {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--amber-ink);
  background: var(--amber-soft);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  white-space: nowrap;
}

.present-btn {
  margin-left: auto;
  min-height: 2.5rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  color: var(--paper);
  background: var(--ink);
  border: 0;
  border-radius: 6px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
}

/* The date sits under the site name, so it adds no width and fits the row's height. */
.brand { display: flex; flex-direction: column; line-height: 1.25; }
.header-updated {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

@media (max-width: 420px) {
  .status-chip { order: 3; }
}

/* ---------- buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  font: inherit;
  font-weight: 650;
  color: var(--on-teal);
  background: var(--teal);
  border: 0;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  text-decoration: none;
  cursor: pointer;
}

.button-quiet {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  color: var(--teal);
  background: none;
  border: 0;
  padding: 0.35rem 0.2rem;
  min-height: 2.25rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* ---------- hero ---------- */

.hero {
  padding: clamp(2.25rem, 7vw, 5rem) var(--gutter) clamp(2.5rem, 6vw, 4rem);
}

.hero-inner { max-width: var(--wide); margin: 0 auto; }

.hero-status {
  display: flex;
  gap: 0.55rem;
  align-items: baseline;
  max-width: var(--measure);
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 1.25rem;
}

.status-dot {
  flex: none;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--amber);
}

.hero-lede {
  max-width: var(--measure);
  font-size: 1.2rem;
  color: var(--muted);
}

.hero-ruler { margin: 2.25rem 0 0.5rem; min-height: 132px; }

.ruler-svg { display: block; width: 100%; height: auto; overflow: visible; }
.ruler-axis { stroke: var(--ink); stroke-width: 1.5; }
.ruler-tick { stroke: var(--muted); stroke-width: 1; }
.ruler-year { fill: var(--muted); font: 12px var(--sans); }
.ruler-bar {
  fill: var(--mark-pct);
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.ruler-bar.lb { fill: url(#hatch-ruler); }
.hatch-line { stroke: var(--mark-pct); stroke-width: 2; }
.ruler-pct {
  fill: var(--ink);
  font: 650 13px var(--sans);
  transition: opacity 0.4s ease;
}
.ruler-svg.pre .ruler-bar { transform: scaleY(0); }
.ruler-svg.pre .ruler-pct { opacity: 0; }

.ruler-caption {
  max-width: var(--measure);
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.75rem;
}

.hero-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem 2rem;
  margin: 2rem 0 2.25rem;
}

@media (min-width: 760px) {
  .hero-facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.hero-facts div {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
  border-top: 2px solid var(--ink);
  padding-top: 0.6rem;
}

.hero-facts dd {
  margin: 0;
  font-family: var(--sans);
  font-size: clamp(2rem, 1.5rem + 2vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-variant-numeric: lining-nums proportional-nums;
}

.hero-facts dt {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
  margin-top: 0.35rem;
}

/* ---------- chapters ---------- */

.chapter {
  padding: clamp(3rem, 8vw, 5.5rem) var(--gutter);
  border-top: 1px solid var(--line);
}

.chapter-head, .chapter-body { max-width: var(--wide); margin: 0 auto; }
.chapter-head { position: relative; }

.chapter-num {
  display: block;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--teal);
  margin-bottom: 0.2rem;
  font-variant-numeric: lining-nums;
}

@media (min-width: 1180px) {
  .chapter-num {
    position: absolute;
    right: calc(100% + 1.5rem);
    top: 0.1rem;
    font-size: 2.2rem;
    line-height: 1;
  }
}

.chapter-lede {
  max-width: var(--measure);
  font-size: 1.15rem;
  color: var(--muted);
  margin-bottom: 0;
}

.chapter-body { margin-top: 2rem; }
.prose { max-width: var(--measure); }
.note { color: var(--muted); font-size: 0.92rem; max-width: var(--measure); }

/* glossary-linked terms (enhanced into buttons by glossary.js) */
[data-term] {
  text-decoration: underline dotted;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
}

/* ---------- plates (demo containers) ---------- */

.plate {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1rem, 3vw, 1.75rem);
}

details.data {
  margin-top: 1rem;
  font-size: 0.92rem;
}
details.data summary {
  cursor: pointer;
  color: var(--teal);
  font-weight: 650;
  min-height: 2.25rem;
  display: flex;
  align-items: center;
}

/* ---------- footer, noscript ---------- */

.site-footer {
  padding: 2.5rem var(--gutter) 3.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer > * { max-width: var(--wide); margin-left: auto; margin-right: auto; }

.noscript {
  max-width: var(--wide);
  margin: 0 auto 2rem;
  padding: 0 var(--gutter);
}
.load-failed > [role="alert"] {
  max-width: var(--wide);
  margin: 0 auto 1rem;
  padding: 0 var(--gutter);
  font-weight: 650;
}

/* ---------- print: always show final states ---------- */

@media print {
  .site-header { position: static; }
  .pre * { transform: none !important; opacity: 1 !important; }
  details.data { display: none; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
