/*
 * Component styles. Component classes are prefixed `c-` to keep them
 * distinguishable from layout primitives and utilities.
 */

/* ---- Site header --------------------------------------------- */
.c-site-header {
  border-bottom: var(--rule-hair);
  padding-block: var(--space-4);
  background: var(--color-bg);
}

.c-site-header__inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-6);
}

.c-brand {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-headline);
  font-variation-settings: "opsz" 24, "SOFT" 30;
  color: var(--color-ink);
}

.c-brand:hover {
  color: var(--color-ink);
}

.c-nav {
  display: flex;
  gap: var(--space-5);
  align-items: baseline;
}

.c-nav a {
  color: var(--color-ink-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.c-nav a:hover,
.c-nav a[aria-current="page"] {
  color: var(--color-ink);
}

/* ---- Site footer --------------------------------------------- */
.c-site-footer {
  border-top: var(--rule-hair);
  padding-block: var(--space-8) var(--space-7);
  margin-top: var(--space-10);
  color: var(--color-ink-muted);
  font-size: var(--text-sm);
}

.c-site-footer a {
  color: var(--color-ink-muted);
}

.c-site-footer a:hover { color: var(--color-ink); }

/* ---- Metric — the canonical headline-number block ------------ */
/* Usage:
 *   <div class="c-metric">
 *     <div class="eyebrow">annual decay rate</div>
 *     <div class="c-metric__value display-monument">3.24%</div>
 *     <div class="c-metric__caption">National · May 2026</div>
 *   </div>
 */
.c-metric {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.c-metric__value {
  color: var(--color-ink);
}

.c-metric__caption {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-ink-subtle);
  letter-spacing: var(--tracking-mono);
}

/* ---- Disclosure — the "data + methodology + sources" primitive */
/* Usage:
 *   {% call disclosure("Show methodology") %}
 *     <p>The annual decay rate is computed as…</p>
 *   {% endcall %}
 *
 * Native <details>/<summary>, no JS required. Accessible by default.
 */
.c-disclosure {
  border-top: var(--rule-hair);
  border-bottom: var(--rule-hair);
}

.c-disclosure + .c-disclosure {
  border-top: 0;
}

.c-disclosure__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-block: var(--space-4);
  cursor: pointer;
  list-style: none;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--color-ink);
}

.c-disclosure__summary::-webkit-details-marker {
  display: none;
}

.c-disclosure__summary::after {
  content: "+";
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: var(--weight-regular);
  color: var(--color-ink-subtle);
  transition: transform var(--duration-base) var(--ease-out);
}

.c-disclosure[open] .c-disclosure__summary::after {
  content: "−";
}

.c-disclosure__body {
  padding-bottom: var(--space-5);
  color: var(--color-ink-muted);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
}

.c-disclosure__body > * + * {
  margin-top: var(--space-3);
}

/* ---- Panel — soft-divided editorial container ---------------- */
/* Each top-level section on a content page sits inside a panel:
 * white surface on the warm off-white page background, hairline
 * border, generous interior padding. Gives the page rhythm and
 * visual containment without going full card-shadow.
 *
 * Usage:
 *   <article class="c-panel" id="anchor">
 *     <h2>Section title</h2>
 *     <div class="prose">…</div>
 *   </article>
 */
.c-panel {
  background: var(--color-bg-elevated);
  border: var(--rule-hair);
  border-radius: var(--radius-md);
  padding: var(--space-7);
}

.c-panel + .c-panel {
  margin-top: var(--space-5);
}

.c-panel > :first-child {
  margin-top: 0;
}

.c-panel > :last-child {
  margin-bottom: 0;
}

/* When a panel has a single h2 lede, hold the title close to top. */
.c-panel > h2:first-child {
  margin-top: 0;
  margin-bottom: var(--space-5);
}

/* Small / compact panel — for the TOC and other narrow blocks. */
.c-panel--compact {
  padding: var(--space-5) var(--space-5);
}

/* Sunken panel — for subordinate or recessed content (excluded
 * categories, "what's not in the basket"). */
.c-panel--sunken {
  background: var(--color-bg-sunken);
}

@media (max-width: 768px) {
  .c-panel {
    padding: var(--space-5) var(--space-4);
    border-radius: var(--radius-sm);
  }
  .c-panel + .c-panel {
    margin-top: var(--space-4);
  }
}

/* Panel stack — vertical rhythm container for a sequence of panels. */
.c-panel-stack > * + * {
  margin-top: var(--space-5);
}

@media (max-width: 768px) {
  .c-panel-stack > * + * {
    margin-top: var(--space-4);
  }
}

/* When the TOC sits as a panel above content, it should feel tighter. */
.c-panel .c-toc {
  border-left: 0;
  padding: 0;
  position: static;
}

/* ---- Auto panel stack — apply panel styling to child sections --- */
/* Saves wrapping every section by hand. Add this class to a wrapper
 * div and any direct-child <section id> or <article id> automatically
 * gets the panel treatment. <hr> dividers are hidden since panels
 * carry the visual separation. The TOC gets compact-panel treatment.
 *
 * Usage:
 *   <div class="container container--text c-panel-stack--auto">
 *     {{ toc(...) }}
 *     <section id="x">…</section>
 *     <section id="y">…</section>
 *   </div>
 */
.c-panel-stack--auto > section[id],
.c-panel-stack--auto > article[id] {
  background: var(--color-bg-elevated);
  border: var(--rule-hair);
  border-radius: var(--radius-md);
  padding: var(--space-7);
}

.c-panel-stack--auto > * + * {
  margin-top: var(--space-5);
}

.c-panel-stack--auto > hr {
  display: none;
}

.c-panel-stack--auto > section[id] > h2:first-child,
.c-panel-stack--auto > article[id] > h2:first-child {
  margin-top: 0;
}

/* TOC inside an auto-stack reads as a compact panel above content,
 * overriding the default left-rule treatment that c-toc carries for
 * stand-alone use. */
.c-panel-stack--auto > .c-toc {
  background: var(--color-bg-elevated);
  border: var(--rule-hair);
  border-radius: var(--radius-md);
  border-left: var(--rule-hair);
  padding: var(--space-5) var(--space-6);
  position: static;
}

@media (max-width: 768px) {
  .c-panel-stack--auto > section[id],
  .c-panel-stack--auto > article[id] {
    padding: var(--space-5) var(--space-4);
    border-radius: var(--radius-sm);
  }
  .c-panel-stack--auto > * + * {
    margin-top: var(--space-4);
  }
}

/* Subordinate sub-sections inside a panel (e.g., the Geography and
 * Calibration blocks that live under the same panel) get a slim
 * top-border separator so they stay visually grouped but distinct. */
.c-panel-stack--auto section[id] section[id] {
  padding-top: var(--space-6);
  margin-top: var(--space-6);
  border-top: var(--rule-hair);
}

/* ---- Section numbering — editorial publication marker --------- */
/* Each panel in an auto-stack is auto-numbered "§ 01", "§ 02", etc.
 * via CSS counter. Reads as a serious-publication structure element
 * and helps the eye locate position on long pages. The TOC and any
 * non-section direct children don't increment.
 */
.c-panel-stack--auto {
  counter-reset: panel-section;
}

.c-panel-stack--auto > section[id],
.c-panel-stack--auto > article[id] {
  position: relative;
}

.c-panel-stack--auto > section[id]::before,
.c-panel-stack--auto > article[id]::before {
  counter-increment: panel-section;
  content: "§\00a0" counter(panel-section, decimal-leading-zero);
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-accent);
  font-weight: var(--weight-medium);
  margin-bottom: var(--space-3);
}

/* ---- Drop cap — classical editorial first paragraph -----------
 * Only the first paragraph of the first section gets the drop cap.
 * Over-using it would feel decorative; one per page gives presence. */
.c-panel-stack--auto > section[id]:first-of-type .prose > p:first-of-type::first-letter,
.c-panel-stack--auto > article[id]:first-of-type .prose > p:first-of-type::first-letter {
  font-family: var(--font-serif);
  font-size: 4.2em;
  line-height: 0.85;
  float: left;
  padding-right: 0.12em;
  padding-top: 0.08em;
  font-weight: var(--weight-regular);
  font-variation-settings: "opsz" 144, "SOFT" 20;
  color: var(--color-ink);
}

/* ---- Stat grid — feature numbers under a hero -----------------
 * Renders a horizontal grid of (label, big number) pairs. Used in
 * page heroes to give a real visual hook before the body content.
 */
.c-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-5) var(--space-6);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: var(--rule-strong);
}

.c-stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.c-stat__label {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-ink-subtle);
  font-weight: var(--weight-medium);
}

.c-stat__value {
  font-family: var(--font-serif);
  font-size: var(--text-3xl);
  line-height: 0.95;
  font-variation-settings: "opsz" 48, "SOFT" 25;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: var(--tracking-headline);
  color: var(--color-ink);
}

.c-stat__caption {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-ink-subtle);
  letter-spacing: var(--tracking-mono);
  margin-top: var(--space-1);
}

/* ---- Strategic accent for comparison-table DecayStats column --
 * One single point of color emphasis: the "DecayStats" column header
 * in any c-table--compare. Reads as "this is the column to read first."
 */
.c-table--compare thead th:nth-child(2) {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font-weight: var(--weight-semibold);
}

/* ---- Override default hero title for more presence -----------
 * Push the display title up to 120px on wide screens with tighter
 * tracking and more aggressive optical-size variation. This is the
 * single biggest "presence" lever and the user said the prior
 * version felt boring. */
.c-hero__title {
  font-size: clamp(2.75rem, 8vw, 7.25rem);
  line-height: 0.95;
  letter-spacing: -0.035em;
  font-variation-settings: "opsz" 144, "SOFT" 20;
}

.c-hero__topline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: baseline;
  margin-bottom: var(--space-5);
}

.c-hero__topline .eyebrow + .eyebrow {
  border-left: var(--rule-strong);
  padding-left: var(--space-4);
}

/* ---- Provenance pill ---------------------------------------- */
/* Stamped at the foot of every page that serves data. */
.c-provenance {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-ink-subtle);
  letter-spacing: var(--tracking-mono);
  display: inline-flex;
  gap: var(--space-3);
  align-items: center;
}

.c-provenance__sep {
  color: var(--color-rule-strong);
}

/* ---- Pillar — methodology principle block ------------------- */
/* Each load-bearing methodology pillar gets its own block:
 * number + title + body prose + optional formula + sources disclosure.
 */
.c-pillar {
  padding-block: var(--space-7);
  border-top: var(--rule-hair);
}

.c-pillar:first-child {
  border-top: 0;
  padding-top: 0;
}

.c-pillar__number {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
  color: var(--color-ink-subtle);
  text-transform: uppercase;
}

.c-pillar__title {
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  font-weight: var(--weight-regular);
  letter-spacing: var(--tracking-headline);
  line-height: var(--leading-tight);
  font-variation-settings: "opsz" 36, "SOFT" 40;
  margin-top: var(--space-2);
  margin-bottom: var(--space-4);
  max-width: var(--measure-prose);
}

.c-pillar__body {
  max-width: var(--measure-prose);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--color-ink);
}

.c-pillar__body > * + * {
  margin-top: var(--space-3);
}

.c-pillar__formula {
  margin-block: var(--space-5);
  max-width: var(--measure-wide);
}

.c-pillar__sources {
  margin-top: var(--space-4);
  max-width: var(--measure-wide);
}

/* ---- Formula block — displayed equation with caption -------- */
/* MathJax renders into .c-formula__math; the caption sits beneath. */
.c-formula {
  background: var(--color-bg-sunken);
  padding: var(--space-5) var(--space-6);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--color-rule-strong);
}

.c-formula__math {
  font-size: var(--text-lg);
  text-align: center;
  margin-block: var(--space-2);
  overflow-x: auto;
}

.c-formula__caption {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-ink-muted);
  text-align: center;
  margin-top: var(--space-3);
  line-height: var(--leading-snug);
}

.c-formula__caption .term {
  font-family: var(--font-mono);
  font-size: 0.92em;
  color: var(--color-ink);
}

/* ---- Data table — clean editorial table --------------------- */
/* Used for the basket weights table, methodology comparison table,
 * per-stratum source map, archetype comparison, etc. */
.c-table {
  width: 100%;
  font-size: var(--text-base);
  border-collapse: collapse;
}

.c-table th,
.c-table td {
  text-align: left;
  padding: var(--space-3) var(--space-4) var(--space-3) 0;
  border-bottom: var(--rule-hair);
  vertical-align: baseline;
}

.c-table th {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-ink-subtle);
  border-bottom: var(--rule-strong);
  padding-block: var(--space-3);
}

.c-table tbody tr:hover {
  background: var(--color-bg-sunken);
}

.c-table td.num,
.c-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums lining-nums;
  padding-right: var(--space-5);
}

.c-table td.mono,
.c-table .mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-mono);
}

.c-table--compact th,
.c-table--compact td {
  padding-block: var(--space-2);
  font-size: var(--text-sm);
}

.c-table caption {
  caption-side: bottom;
  text-align: left;
  padding-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-ink-subtle);
}

/* ---- Source citation — small reference pill ----------------- */
/* Inline citation block, used below tables, formulas, and data points. */
.c-source {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-mono);
  color: var(--color-ink-subtle);
}

.c-source__label {
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  font-weight: var(--weight-medium);
  color: var(--color-ink-subtle);
}

.c-source a {
  color: var(--color-ink-muted);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.c-source a:hover {
  color: var(--color-ink);
}

.c-source-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* ---- Inline ToC — page-section index ------------------------ */
/* Sits in the right rail of a 12-col grid on wide screens; folds
 * inline above the content on narrow screens. */
.c-toc {
  border-left: 2px solid var(--color-rule);
  padding: var(--space-3) 0 var(--space-3) var(--space-4);
  position: sticky;
  top: var(--space-5);
}

.c-toc__label {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-ink-subtle);
  font-weight: var(--weight-medium);
  margin-bottom: var(--space-3);
}

.c-toc__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.c-toc a {
  color: var(--color-ink-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.c-toc a:hover,
.c-toc a[aria-current="true"] {
  color: var(--color-ink);
}

@media (max-width: 1024px) {
  .c-toc {
    position: static;
    border-left: 0;
    border-top: var(--rule-hair);
    padding: var(--space-4) 0;
    margin-bottom: var(--space-5);
  }
}

/* ---- Hero — a large display block with eyebrow + headline --- */
/* Used for the home page lede, per-page intros. */
.c-hero {
  padding-block: var(--space-9) var(--space-7);
}

.c-hero__eyebrow {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-ink-subtle);
  font-weight: var(--weight-medium);
  margin-bottom: var(--space-4);
}

.c-hero__title {
  font-family: var(--font-serif);
  font-size: var(--text-display);
  font-weight: var(--weight-regular);
  line-height: 0.98;
  letter-spacing: var(--tracking-display);
  font-variation-settings: "opsz" 100, "SOFT" 25;
  max-width: var(--measure-wide);
  margin-bottom: var(--space-5);
}

.c-hero__lede {
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
  color: var(--color-ink-muted);
  max-width: var(--measure-prose);
}

@media (max-width: 768px) {
  .c-hero__title {
    font-size: var(--text-4xl);
  }
  .c-hero {
    padding-block: var(--space-7) var(--space-5);
  }
}

/* ---- Comparison table modifier — methodology vs CPI vs PCE -- */
/* A wider 4-column layout, with the first column as a row label. */
.c-table--compare th:first-child,
.c-table--compare td:first-child {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-transform: none;
  letter-spacing: 0;
  color: var(--color-ink-muted);
  width: 28%;
}

.c-table--compare td {
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.c-table--compare th:not(:first-child) {
  text-align: left;
}

.c-table--compare td.highlight {
  background: var(--color-accent-soft);
  font-weight: var(--weight-medium);
  color: var(--color-ink);
}

/* ---- Code sample block — for the API page ------------------- */
.c-code {
  background: var(--color-ink);
  color: var(--color-bg);
  padding: var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  overflow-x: auto;
}

.c-code__caption {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-ink-subtle);
  margin-bottom: var(--space-2);
}

.c-code .comment { color: #8a8d8f; }
.c-code .string  { color: #c8d3a6; }
.c-code .key     { color: #a8b8d8; }
.c-code .num     { color: #d8b890; }

/* ---- Form controls — for auth + portal ---------------------- */
.c-input,
.c-select {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font: inherit;
  font-size: var(--text-base);
  background: var(--color-bg-elevated);
  color: var(--color-ink);
  border: 1px solid var(--color-rule-strong);
  border-radius: var(--radius-md);
  margin-top: var(--space-2);
  transition: border-color var(--duration-fast) var(--ease-out);
}

.c-input:focus,
.c-select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.c-button {
  display: inline-block;
  padding: var(--space-3) var(--space-5);
  font: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  background: var(--color-accent);
  color: var(--color-bg);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-out);
}

.c-button:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  color: var(--color-bg);
}

.c-button--ghost {
  background: transparent;
  color: var(--color-ink);
  border-color: var(--color-rule-strong);
}

.c-button--ghost:hover {
  background: var(--color-bg-sunken);
  color: var(--color-ink);
  border-color: var(--color-rule-strong);
}

/* Flash messages (auth.flash, etc.) — minimal styling. */
.c-flash {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  margin: var(--space-4) 0;
}

/* ---- Endpoint row — for the API reference ------------------- */
.c-endpoint {
  padding-block: var(--space-5);
  border-top: var(--rule-hair);
}

.c-endpoint__method {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-label);
  padding: 0.2em 0.5em;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  border-radius: var(--radius-sm);
  margin-right: var(--space-3);
  vertical-align: middle;
}

.c-endpoint__path {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  color: var(--color-ink);
  letter-spacing: var(--tracking-mono);
}

.c-endpoint__desc {
  margin-top: var(--space-2);
  color: var(--color-ink-muted);
  max-width: var(--measure-prose);
}
