/* ============================================================
   atlvibe — structured post blocks
   Charts, stat tiles, evidence panels, fact callouts, tables.
   Extends styles.css / blog.css (same "Atlanta, after dark" system).

   Colour decisions (validated, not eyeballed) against --ink #100b0d:
     peach  #ff8a5b  8.40:1   bar fill        (marks need >= 3:1)
     faint  #8c7a74  4.79:1   de-emphasis bar
     muted  #b6a49b  8.16:1   secondary text  (WCAG normal text >= 4.5:1)
     cream  #f6ede6 16.90:1   primary text
     line   #3a2c31  1.47:1   gridlines — deliberately recessive chrome,
                              not a mark, so the 3:1 mark floor doesn't apply
   ============================================================ */

.prose-chunk > * + * { margin-top: 1.15em; }

/* Blocks sit in the reading column and share the prose rhythm. */
.chart, .stats, .fact, .evidence, .pullquote, .datatable {
  margin-top: clamp(2rem, 5vh, 3rem);
  margin-bottom: clamp(2rem, 5vh, 3rem);
}

/* ============================================================
   Chart — horizontal bars
   ============================================================ */
.chart {
  --label-w: 7.5rem;
  --value-w: 4.25rem;
  --bar-h: 18px;              /* <= 24px: the band keeps its leftover as air */
  padding: clamp(1.1rem, 3vw, 1.6rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(27, 20, 24, 0.45);
  backdrop-filter: blur(8px);
}

.chart__title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.22rem;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--cream);
}
.chart__subtitle {
  margin-top: 0.4rem;
  font-size: 0.94rem;
  line-height: 1.5;
  color: var(--muted);
}

.chart__body {
  position: relative;
  margin-top: 1.4rem;
  /* The axis band is INSIDE the body, so the container always includes its
     own tick labels and can never produce a nested scrollbar. */
  padding-bottom: 1.6rem;
}

/* ---- gridlines: recessive hairlines, solid (never dashed) ---- */
.chart__grid {
  position: absolute;
  top: 0;
  bottom: 1.6rem;             /* stop at the axis band */
  left: var(--label-w);
  right: var(--value-w);
  pointer-events: none;
}
.chart__gridline {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line);
  transform: translateX(-0.5px);
}
/* The zero baseline is the one gridline that carries meaning. */
.chart__gridline:first-child { background: rgba(182, 164, 155, 0.34); }

.chart__rows {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;                  /* >= the 2px surface gap; bars never touch */
}

.chart__row {
  display: grid;
  grid-template-columns: var(--label-w) 1fr var(--value-w);
  align-items: center;
  gap: 0.6rem;
  min-height: 24px;           /* comfortable hover/hit target */
}

.chart__label {
  font-size: 0.9rem;
  color: var(--cream);        /* text tokens — never the data colour */
  text-align: right;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.chart__track {
  position: relative;
  display: block;
  height: var(--bar-h);
}

.chart__bar {
  display: block;
  height: 100%;
  background: var(--peach);
  /* 4px rounded data-end, square at the baseline */
  border-radius: 0 4px 4px 0;
  transition: filter 0.2s var(--ease);
}
.chart__row.is-dim .chart__bar { background: var(--faint); }
.chart__row:hover .chart__bar { filter: brightness(1.12); }

.chart__value {
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;   /* a column of numbers — align them */
  color: var(--cream);
  text-align: right;
}
.chart__row.is-dim .chart__label,
.chart__row.is-dim .chart__value { color: var(--muted); }

/* ---- axis ---- */
.chart__axis {
  position: absolute;
  left: var(--label-w);
  right: var(--value-w);
  bottom: 0;
  height: 1.6rem;
}
.chart__tick {
  position: absolute;
  top: 0.45rem;
  transform: translateX(-50%);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
  white-space: nowrap;
}

/* ---- notes, provenance, data twin ---- */
.chart__note {
  margin-top: 1rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--muted);
}
.chart__prov {
  margin-top: 0.55rem;
  font-size: 0.78rem;
  color: var(--faint);
}
.chart__prov code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.94em;
  color: var(--gold);
}

.chart__data { margin-top: 1rem; }
.chart__data > summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  display: inline-block;
  list-style: none;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.chart__data > summary::-webkit-details-marker { display: none; }
.chart__data > summary:hover {
  color: var(--cream);
  border-color: rgba(255, 138, 91, 0.45);
}
.chart__data[open] > summary { margin-bottom: 0.9rem; }
.chart__data-inner { overflow-x: auto; }

.chart__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.chart__table th {
  text-align: left;
  font-family: var(--display);
  font-weight: 600;
  color: var(--cream);
  padding: 0.45rem 0.8rem 0.45rem 0;
  border-bottom: 1px solid rgba(244, 197, 107, 0.3);
  white-space: nowrap;
}
.chart__table td {
  padding: 0.45rem 0.8rem 0.45rem 0;
  border-bottom: 1px solid var(--line);
  color: #ece0d8;
  font-variant-numeric: tabular-nums;
}
.chart__table tbody tr:last-child td { border-bottom: 0; }
.chart__method {
  margin-top: 0.9rem;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--faint);
}
.chart__method b { color: var(--muted); }

@media (max-width: 33rem) {
  .chart { --label-w: 5.4rem; --value-w: 3.5rem; }
  .chart__label { font-size: 0.82rem; }
  .chart__value { font-size: 0.82rem; }
}

/* ============================================================
   Stat tiles (KPI row)
   ============================================================ */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.9rem;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1.1rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(27, 20, 24, 0.45);
}
.stat__label {
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.stat__value {
  /* Sans, not the display serif — a display face on a figure reads as
     decoration. Proportional figures: tabular-nums makes a big number
     look loose at this size. */
  font-family: var(--sans);
  font-weight: 600;
  font-size: clamp(1.5rem, 4vw, 1.9rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--cream);
}
.stat__note {
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--faint);
}

/* ============================================================
   Fact callout
   ============================================================ */
.fact {
  padding: 1.2rem 1.35rem;
  border: 1px solid rgba(244, 197, 107, 0.28);
  border-radius: var(--radius);
  background: rgba(244, 197, 107, 0.06);
}
.fact__kicker {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--gold);
}
.fact__title {
  margin-top: 0.5rem;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.12rem;
  line-height: 1.3;
  color: var(--cream);
}
.fact__body { margin-top: 0.45rem; font-size: 0.98rem; line-height: 1.65; color: #ece0d8; }
.fact__body > * + * { margin-top: 0.8em; }
.fact__body p:first-child { margin-top: 0; }

/* ============================================================
   Evidence panel
   ============================================================ */
.evidence {
  padding: 1.2rem 1.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 11, 13, 0.5);
}
.evidence__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.evidence__kicker {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
.evidence__conf {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: var(--pill);
  border: 1px solid currentColor;
  text-transform: lowercase;
}
/* Status colours are reserved for state and always ship with a text label. */
.evidence__conf--high   { color: #7bc47f; }
.evidence__conf--medium { color: var(--gold); }
.evidence__conf--low    { color: var(--magenta); }

.evidence__claim {
  margin-top: 0.6rem;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--cream);
}
.evidence__list {
  margin-top: 0.8rem;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.evidence__list li { font-size: 0.9rem; line-height: 1.5; }
.evidence__list li::marker { color: var(--peach); }
.evidence__list a {
  color: var(--peach);
  text-decoration: underline;
  text-decoration-color: rgba(255, 138, 91, 0.4);
  text-underline-offset: 3px;
}
.evidence__meta { display: block; font-size: 0.78rem; color: var(--faint); margin-top: 0.15rem; }

/* ============================================================
   Pull quote
   ============================================================ */
.pullquote { text-align: center; }
.pullquote blockquote {
  font-family: var(--display);
  font-size: clamp(1.25rem, 3.2vw, 1.6rem);
  line-height: 1.35;
  letter-spacing: -0.015em;
  color: var(--cream);
  font-style: italic;
}
.pullquote__cite { margin-top: 0.8rem; font-size: 0.85rem; color: var(--muted); }
.pullquote__cite a { color: var(--peach); }

/* ============================================================
   Roundup — clustered conversation (city_pulse template)
   ============================================================ */
.roundup__title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.22rem;
  letter-spacing: -0.015em;
  color: var(--cream);
}
.roundup__window {
  margin-top: 0.3rem;
  font-size: 0.85rem;
  color: var(--faint);
}
.roundup__group { margin-top: 1.9rem; }
.roundup__topic {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.12rem;
  letter-spacing: -0.015em;
  color: var(--cream);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}
.roundup__count {
  flex: none;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--faint);
  white-space: nowrap;
}
.roundup__summary {
  margin-top: 0.7rem;
  font-size: 0.98rem;
  line-height: 1.6;
  color: #ece0d8;
}
.roundup__list {
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  list-style: none;
  padding: 0;
}
.roundup__item {
  padding-left: 0.9rem;
  border-left: 2px solid var(--line);
  transition: border-color 0.2s var(--ease);
}
.roundup__item:hover { border-left-color: var(--peach); }
.roundup__link {
  font-weight: 600;
  font-size: 0.98rem;
  line-height: 1.4;
  color: var(--cream);
  text-decoration: underline;
  text-decoration-color: rgba(255, 138, 91, 0.35);
  text-underline-offset: 3px;
}
.roundup__link:hover { text-decoration-color: var(--peach); }
.roundup__meta {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.76rem;
  color: var(--faint);
}
.roundup__snip {
  margin-top: 0.35rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--muted);
}

/* ============================================================
   Standalone table
   ============================================================ */
.datatable__cap {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--cream);
  margin-bottom: 0.7rem;
}
.datatable__scroll { overflow-x: auto; }
.datatable table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.datatable th {
  text-align: left;
  font-family: var(--display);
  font-weight: 600;
  color: var(--cream);
  padding: 0.55rem 0.9rem 0.55rem 0;
  border-bottom: 1px solid rgba(244, 197, 107, 0.3);
  white-space: nowrap;
}
.datatable td {
  padding: 0.55rem 0.9rem 0.55rem 0;
  border-bottom: 1px solid var(--line);
  color: #ece0d8;
}
.datatable tbody tr:last-child td { border-bottom: 0; }

/* Respect reduced-motion for the only transition that moves. */
@media (prefers-reduced-motion: reduce) {
  .chart__bar { transition: none; }
}
