
/*
 * Editorial Design System (#144)
 * Magazine-style components inspired by handcrafted drop-ins
 * (mainframe-history, lepanto, robot-vacuum), re-skinned with brand
 * tokens (#145): Paper / Ink / Signature Blue.
 * Fonts: Source Serif 4 (body/display) + Source Code Pro (UI/meta only).
 */

/* ---------- Tokens (map to site brand) ---------- */
:root {
  --ed-max: 80rem;          /* room for 3 cols + gutters */
  --ed-measure: 38rem;      /* ~62–68ch reading measure */
  --ed-wide: 56rem;
  --ed-full: 100rem;
  --ed-col-min: 16.5rem;    /* min track width before wrapping */

  --ed-space-1: 0.35rem;
  --ed-space-2: 0.7rem;
  --ed-space-3: 1rem;
  --ed-space-4: 1.35rem;
  --ed-space-5: 2rem;
  --ed-space-6: 2.75rem;
  --ed-space-7: 4rem;
  --ed-space-8: 5.5rem;

  /* Inherit site brand tokens (dark mode remaps --brand-* / --color-*) */
  --ed-bg: var(--color-bg, #FAF9F6);
  --ed-surface: var(--color-surface, #FFFFFF);
  --ed-ink: var(--color-fg, #111C24);
  --ed-muted: var(--color-muted, #4A5560);
  --ed-charcoal: var(--brand-charcoal, #2F3A42);
  --ed-border: var(--color-border, #E8E6E1);
  --ed-accent: var(--color-accent, #0077A8);
  --ed-deep: var(--brand-deep-ocean, #00334D);
  --ed-ice: var(--brand-primary-10, #EEF7FA);
  --ed-sand: var(--brand-sand, #E9DCC8);
  --ed-seafoam: var(--brand-seafoam, #00A896);
  --ed-ochre: var(--brand-ochre, #C58B2A);
  --ed-terracotta: var(--brand-terracotta, #C85C4A);
  --ed-lavender: var(--brand-lavender, #7667A8);

  --ed-serif: var(--font-body, "Source Serif 4", Georgia, serif);
  --ed-ui: var(--font-ui, "Source Code Pro", system-ui, sans-serif);
  --ed-radius: 0.2rem;
}

/* ---------- Shell ---------- */
.editorial-main {
  flex: 1;
  width: 100%;
  background: var(--ed-bg);
  color: var(--ed-ink);
  font-family: var(--ed-serif);
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.125rem);
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
}

.editorial-main img {
  display: block;
  max-width: 100%;
  height: auto;
}

.editorial-main a {
  color: var(--ed-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.editorial-main a:hover,
.editorial-main a:focus-visible {
  color: var(--color-accent-hover, var(--ed-deep));
}

.editorial-page {
  width: 100%;
}

/*
  Layout model (no CSS multi-column fragmentation):
  - CSS Grid places whole components as grid items (never split mid-component).
  - 1 col → 2 col (≥900px) → 3 col (≥1200px).
  - Prose (p/ul/ol) always spans full grid width but is capped to --ed-measure
    so line length stays readable.
  - Compact components (definition, cards, callouts) occupy one track and can
    sit side-by-side when consecutive.
  - Wide components (header, figures, tables, composition grids) span all tracks.
*/
.editorial-article {
  --ed-cols: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  column-gap: var(--ed-space-5);
  row-gap: var(--ed-space-4);
  width: min(100% - 2.5rem, var(--ed-max));
  margin-inline: auto;
  padding-block: var(--ed-space-6) var(--ed-space-8);
  align-items: start;
}

/* Keep every direct child whole (no mid-component column breaks) */
.editorial-article > * {
  min-width: 0;
  break-inside: avoid;
  page-break-inside: avoid;
}

/* Prose: full-row span, constrained reading measure */
.editorial-article > p,
.editorial-article > ul,
.editorial-article > ol {
  grid-column: 1 / -1;
  width: 100%;
  max-width: var(--ed-measure);
  margin: 0 0 var(--ed-space-2);
}

.editorial-article > h2,
.editorial-article > h3 {
  grid-column: 1 / -1;
  width: 100%;
  max-width: var(--ed-measure);
  margin: 0;
}

/* Full-width / spanning components */
.editorial-article > .editorial-header,
.editorial-article > .metadata,
.editorial-article > .lead,
.editorial-article > .section-header,
.editorial-article > .subsection-header,
.editorial-article > .figure,
.editorial-article > .full-bleed,
.editorial-article > .stat-grid,
.editorial-article > .timeline,
.editorial-article > .data-table,
.editorial-article > .scorecard,
.editorial-article > .content-grid,
.editorial-article > .two-column,
.editorial-article > .comparison,
.editorial-article > .pros-cons,
.editorial-article > .figure-pair,
.editorial-article > .gallery,
.editorial-article > .quote,
.editorial-article > .editorial-break,
.editorial-article > .source-list,
.editorial-article > .related-reading,
.editorial-article > .editorial-list,
.editorial-article > .content-container {
  grid-column: 1 / -1;
  width: 100%;
  max-width: none;
  margin-inline: 0;
}

/* Compact components: one grid track — can sit next to peers */
.editorial-article > .definition,
.editorial-article > .aside,
.editorial-article > .info-callout,
.editorial-article > .fact-box,
.editorial-article > .takeaways,
.editorial-article > .recommendation,
.editorial-article > .forecast,
.editorial-article > .event-card,
.editorial-article > .entity-card,
.editorial-article > .source-note,
.editorial-article > .glossary {
  grid-column: auto;
  width: 100%;
  max-width: none;
  margin: 0;
  height: 100%;
}

/* Spanning components that still want a readable inner measure */
.editorial-article > .lead,
.editorial-article > .quote,
.editorial-article > .source-list,
.editorial-article > .related-reading,
.editorial-article > .editorial-list,
.editorial-article > .content-container {
  max-width: var(--ed-wide);
  justify-self: start;
}

.editorial-article > .editorial-header,
.editorial-article > .metadata,
.editorial-article > .section-header {
  max-width: none;
}

/* 2 columns: compact cards side-by-side; prose remains full-width + measure */
@media (min-width: 900px) {
  .editorial-article {
    --ed-cols: 2;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 2.5rem;
    row-gap: var(--ed-space-5);
    width: min(100% - 3rem, var(--ed-max));
  }
}

/* 3 columns on large screens */
@media (min-width: 1200px) {
  .editorial-article {
    --ed-cols: 3;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 2.75rem;
  }

  /* Medium-width cards can span 2 of 3 tracks when alone looks sparse */
  .editorial-article > .takeaways,
  .editorial-article > .recommendation,
  .editorial-article > .forecast {
    grid-column: span 2;
  }

  .stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  }

  .content-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 900px) and (max-width: 1199px) {
  .content-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- Header / hero ---------- */
.editorial-header {
  width: 100%;
  margin: 0 0 var(--ed-space-5);
  padding-bottom: var(--ed-space-5);
  border-bottom: 3px solid var(--ed-ink);
  color: var(--ed-ink);
}

.eyebrow {
  display: block;
  margin-bottom: var(--ed-space-3);
  font-family: var(--ed-ui);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1.35;
  text-transform: uppercase;
  color: var(--ed-accent);
}

.editorial-header h1 {
  margin: 0;
  max-width: 18ch;
  font-family: var(--ed-serif);
  font-size: clamp(2.5rem, 6.5vw, 4.6rem);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -0.03em;
  color: var(--ed-ink);
  text-wrap: balance;
}

.editorial-header > p,
.editorial-header .dek {
  margin: var(--ed-space-4) 0 0;
  max-width: 38rem;
  font-family: var(--ed-ui);
  font-size: clamp(1.05rem, 2vw, 1.28rem);
  font-weight: 400;
  line-height: 1.45;
  color: var(--ed-muted);
}

/* ---------- Metadata bar ---------- */
.metadata {
  width: 100%;
  margin: 0 0 var(--ed-space-5);
  padding: var(--ed-space-3) 0;
  border-bottom: 1px solid var(--ed-border);
  font-family: var(--ed-ui);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  line-height: 1.55;
  color: var(--ed-muted);
  text-transform: uppercase;
}

.metadata p {
  margin: 0;
}

.metadata strong {
  color: var(--ed-charcoal);
  font-weight: 600;
}

/* ---------- Lead ---------- */
.lead {
  width: 100%;
  max-width: var(--ed-measure);
  margin: 0 0 var(--ed-space-5);
  font-family: var(--ed-serif);
  font-size: clamp(1.15rem, 2.1vw, 1.35rem);
  font-weight: 400;
  line-height: 1.55;
  color: var(--ed-ink);
}

.lead::first-letter {
  font-weight: 600;
  color: var(--ed-deep);
}

/* ---------- Section headers ---------- */
.section-header {
  width: 100%;
  margin: var(--ed-space-6) 0 var(--ed-space-4);
  padding-top: var(--ed-space-4);
  border-top: 1px solid var(--ed-border);
  color: var(--ed-ink);
}

.section-header h2 {
  margin: 0;
  font-family: var(--ed-ui);
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ed-ink);
}

.section-header h2::before {
  content: "";
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.65rem;
  vertical-align: 0.15em;
  background: var(--ed-accent);
  border-radius: 1px;
}

.subsection-header {
  width: 100%;
  max-width: var(--ed-measure);
  margin: var(--ed-space-5) 0 var(--ed-space-3);
  color: var(--ed-ink);
}

.subsection-header h3 {
  margin: 0;
  font-family: var(--ed-ui);
  font-size: clamp(1.1rem, 1.8vw, 1.3rem);
  font-weight: 600;
  line-height: 1.25;
  color: var(--ed-deep);
}

/* ---------- Prose container ---------- */
.content-container,
.prose {
  width: min(100%, var(--ed-measure));
  margin-inline: auto;
}

.content-container {
  margin-block: var(--ed-space-5);
}

.prose p {
  margin: 0 0 var(--ed-space-4);
  max-width: 68ch;
}

/* ---------- Figures ---------- */
.figure {
  width: 100%;
  margin: var(--ed-space-5) 0;
  color: var(--ed-ink);
}

.figure img {
  width: 100%;
  border: 1px solid var(--ed-border);
  background: var(--ed-sand);
}

.figure p {
  margin: 0.65rem 0 0;
  max-width: 55ch;
}

.figure p:first-of-type strong,
.figure strong {
  display: inline;
  font-family: var(--ed-ui);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ed-ink);
}

.figure p:last-child {
  font-family: var(--ed-ui);
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--ed-muted);
  padding-left: 0.75rem;
  border-left: 2px solid var(--ed-accent);
}

.full-bleed {
  width: min(100vw, var(--ed-full));
  margin-inline: 50%;
  transform: translateX(-50%);
}

.figure.full-bleed,
.full-bleed .figure {
  width: 100%;
}

.full-bleed img {
  max-height: 70vh;
  object-fit: cover;
  object-position: center;
}

/* ---------- Quotes ---------- */
.quote {
  width: 100%;
  max-width: var(--ed-measure);
  margin: var(--ed-space-5) 0;
  padding: var(--ed-space-4) 0 var(--ed-space-4) var(--ed-space-5);
  border-left: 4px solid var(--ed-accent);
  background: transparent;
  color: var(--ed-ink);
}

.quote blockquote {
  margin: 0;
  border: 0;
  padding: 0;
  font-family: var(--ed-serif);
  font-size: clamp(1.45rem, 2.8vw, 2.15rem);
  font-weight: 500;
  font-style: italic;
  line-height: 1.28;
  letter-spacing: -0.02em;
  color: var(--ed-ink);
}

.quote p {
  margin: 0 0 var(--ed-space-2);
}

.quote p:last-child {
  margin-bottom: 0;
  font-family: var(--ed-ui);
  font-size: 0.82rem;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ed-muted);
}

/* ---------- Stats ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0;
  width: 100%;
  margin: var(--ed-space-5) 0;
  border-top: 1px solid var(--ed-border);
  border-bottom: 1px solid var(--ed-border);
  color: var(--ed-ink);
}

.stat-grid .stat,
.stat {
  min-width: 0;
  padding: var(--ed-space-5) var(--ed-space-4);
  background: var(--ed-surface);
  border-right: 1px solid var(--ed-border);
  color: var(--ed-ink);
}

.stat-grid .stat:last-child {
  border-right: 0;
}

.stat-value,
.stat .stat-value {
  display: block;
  font-family: var(--ed-serif);
  font-size: clamp(1.9rem, 4vw, 2.75rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ed-deep);
}

.stat-label,
.stat .stat-label {
  display: block;
  margin-top: var(--ed-space-2);
  font-family: var(--ed-ui);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ed-muted);
}

.stat-description {
  display: block;
  margin-top: var(--ed-space-2);
  font-family: var(--ed-ui);
  font-size: 0.8rem;
  color: var(--ed-muted);
}

/* ---------- Tables ---------- */
.data-table,
.scorecard {
  width: 100%;
  margin: var(--ed-space-5) 0;
  overflow-x: auto;
  color: var(--ed-ink);
}

.data-table table,
.scorecard table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--ed-ui);
  font-size: 0.92rem;
}

.data-table th,
.data-table td,
.scorecard th,
.scorecard td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--ed-border);
  text-align: left;
  vertical-align: top;
  color: var(--ed-ink);
  background: var(--ed-surface);
}

.data-table th,
.scorecard th {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ed-deep);
  background: var(--ed-ice);
  border-bottom-color: var(--ed-accent);
  border-bottom-width: 2px;
}

.data-table tr:hover td,
.scorecard tr:hover td {
  background: color-mix(in srgb, var(--ed-ice) 55%, var(--ed-surface));
}

/* ---------- Timeline ---------- */
.timeline {
  width: 100%;
  margin: var(--ed-space-5) 0;
  border-top: 1px solid var(--ed-border);
  color: var(--ed-ink);
}

.timeline-item {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: var(--ed-space-4);
  padding: var(--ed-space-4) 0;
  border-bottom: 1px solid var(--ed-border);
}

.timeline-date {
  grid-column: 1;
  grid-row: 1 / span 2;
  font-family: var(--ed-ui);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ed-accent);
}

.timeline-item h3 {
  grid-column: 2;
  margin: 0 0 var(--ed-space-2);
  font-family: var(--ed-ui);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ed-ink);
}

.timeline-item p {
  grid-column: 2;
  margin: 0;
  max-width: 55ch;
  color: var(--ed-charcoal);
}

/* ---------- Callouts / specialized boxes ---------- */
.info-callout,
.fact-box,
.takeaways,
.definition,
.recommendation,
.forecast,
.aside {
  box-sizing: border-box;
  width: 100%;
  max-width: var(--ed-measure);
  margin: var(--ed-space-5) auto;
  padding: var(--ed-space-5) var(--ed-space-5) var(--ed-space-5) calc(var(--ed-space-5) + 0.35rem);
  position: relative;
  background: var(--ed-ice);
  border: 1px solid var(--ed-border);
  border-radius: var(--ed-radius);
  color: var(--ed-ink);
}

.info-callout::before,
.fact-box::before,
.takeaways::before,
.definition::before,
.recommendation::before,
.forecast::before,
.aside::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  background: var(--ed-accent);
  border-radius: var(--ed-radius) 0 0 var(--ed-radius);
}

.definition::before { background: var(--ed-lavender); }
.recommendation::before { background: var(--ed-seafoam); }
.takeaways::before { background: var(--ed-ochre); }
.aside::before { background: var(--ed-deep); }
.forecast::before { background: var(--ed-terracotta); }

.info-callout p:last-child,
.fact-box p:last-child,
.takeaways p:last-child,
.definition p:last-child,
.recommendation p:last-child,
.forecast p:last-child,
.aside p:last-child {
  margin-bottom: 0;
}

.info-callout strong:first-child,
.fact-box strong:first-child,
.definition strong:first-child,
.aside strong:first-child {
  display: block;
  margin-bottom: var(--ed-space-2);
  font-family: var(--ed-ui);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ed-accent);
}

.definition strong:first-child {
  color: var(--ed-lavender);
}

.takeaways h3,
.recommendation h3,
.forecast h3,
.source-list h3,
.related-reading h3 {
  margin: 0 0 var(--ed-space-3);
  font-family: var(--ed-ui);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ed-deep);
}

/* Nested blocks inside wrapped components */
.takeaways ul,
.recommendation ul,
.forecast ul,
.fact-box ul,
.aside ul,
.definition p,
.takeaways p,
.recommendation p,
.forecast p {
  margin: 0 0 var(--ed-space-3);
}

.takeaways ul,
.recommendation ul,
.forecast ul {
  padding-left: 1.25rem;
}

.takeaways li,
.recommendation li,
.forecast li {
  margin-bottom: 0.45rem;
}

.event-card p,
.entity-card p,
.definition p:last-child,
.takeaways > *:last-child,
.recommendation > *:last-child,
.forecast > *:last-child,
.fact-box > *:last-child,
.aside > *:last-child,
.info-callout > *:last-child {
  margin-bottom: 0;
}

.fact-box {
  background: var(--ed-surface);
  color: var(--ed-ink);
}

/* Ensure nested text inherits readable ink (dark-mode safe) */
.info-callout p,
.fact-box p,
.takeaways p,
.definition p,
.recommendation p,
.forecast p,
.aside p,
.takeaways li,
.recommendation li,
.forecast li {
  color: var(--ed-ink);
}

/* ---------- Composition grids ---------- */
.content-grid,
.two-column,
.comparison,
.pros-cons,
.figure-pair {
  width: 100%;
  margin: var(--ed-space-5) 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--ed-space-5) var(--ed-space-6);
  color: var(--ed-ink);
}

.content-grid > div,
.two-column > div,
.comparison > div,
.pros-cons > div,
.figure-pair > div {
  min-width: 0;
  padding: var(--ed-space-4);
  background: var(--ed-surface);
  border: 1px solid var(--ed-border);
  border-top: 3px solid var(--ed-accent);
  color: var(--ed-ink);
}

.comparison > div:last-child,
.pros-cons > div:last-child {
  border-top-color: var(--ed-terracotta);
}

.content-grid h3,
.two-column h3,
.comparison h3,
.pros-cons h3 {
  margin: 0 0 var(--ed-space-3);
  font-family: var(--ed-ui);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ed-deep);
}

.content-grid p:last-child,
.two-column p:last-child,
.comparison p:last-child,
.pros-cons p:last-child {
  margin-bottom: 0;
}

/* ---------- Lists ---------- */
.editorial-list {
  width: 100%;
  max-width: var(--ed-measure);
  margin: var(--ed-space-4) 0;
  padding-left: 0;
  list-style: none;
  color: var(--ed-ink);
}

.editorial-list li {
  margin: 0 0 var(--ed-space-4);
  padding: 0 0 var(--ed-space-3) var(--ed-space-4);
  border-bottom: 1px solid var(--ed-border);
  border-left: 2px solid var(--ed-accent);
}

.editorial-list li:last-child {
  border-bottom: 0;
}

.editorial-list strong {
  font-family: var(--ed-ui);
  font-weight: 600;
  color: var(--ed-deep);
}

/* ---------- Glossary / sources ---------- */
.glossary,
.source-list,
.source-note,
.related-reading {
  width: 100%;
  max-width: var(--ed-measure);
  margin: var(--ed-space-5) auto;
  color: var(--ed-ink);
}

.glossary {
  padding: var(--ed-space-4);
  background: var(--ed-surface);
  border: 1px solid var(--ed-border);
  color: var(--ed-ink);
}

.glossary p,
.glossary dt {
  font-family: var(--ed-ui);
  font-weight: 700;
  color: var(--ed-deep);
  margin: 0 0 0.2rem;
}

.glossary dd,
.glossary p + p {
  margin: 0 0 var(--ed-space-3);
  color: var(--ed-charcoal);
}

.source-list h3,
.related-reading h3 {
  margin: 0 0 var(--ed-space-3);
  font-family: var(--ed-ui);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ed-muted);
}

.source-list ol {
  padding-left: 1.25rem;
  margin: 0;
}

.source-list li {
  margin-bottom: 0.45rem;
  font-family: var(--ed-ui);
  font-size: 0.9rem;
  color: var(--ed-charcoal);
}

.source-note {
  font-family: var(--ed-ui);
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--ed-muted);
  padding-left: 0.75rem;
  border-left: 2px solid var(--ed-border);
}

.related-reading {
  padding-top: var(--ed-space-4);
  border-top: 1px solid var(--ed-border);
}

.related-reading ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.related-reading li {
  margin: 0 0 0.55rem;
  font-family: var(--ed-ui);
}

/* ---------- Cards ---------- */
.event-card,
.entity-card {
  box-sizing: border-box;
  width: 100%;
  max-width: var(--ed-measure);
  margin: var(--ed-space-4) auto;
  padding: var(--ed-space-5);
  background: var(--ed-surface);
  border: 1px solid var(--ed-border);
  border-left: 4px solid var(--ed-accent);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--ed-ink) 4%, transparent);
  color: var(--ed-ink);
}

.event-date {
  display: block;
  margin-bottom: var(--ed-space-2);
  font-family: var(--ed-ui);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ed-accent);
}

.event-card h3,
.entity-card h3 {
  margin: 0 0 var(--ed-space-2);
  font-family: var(--ed-serif);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ed-ink);
}

.entity-card p {
  margin: 0 0 0.4rem;
  font-family: var(--ed-ui);
  font-size: 0.9rem;
  color: var(--ed-charcoal);
}

/* ---------- Gallery / pairs ---------- */
.gallery {
  width: 100%;
  margin: var(--ed-space-5) 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--ed-space-3);
}

.gallery img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--ed-border);
  background: var(--ed-sand);
}

.figure-pair img {
  width: 100%;
  border: 1px solid var(--ed-border);
  margin-bottom: var(--ed-space-2);
}

.figure-pair strong {
  font-family: var(--ed-ui);
  font-size: 0.85rem;
  color: var(--ed-deep);
}

/* ---------- Break ---------- */
.editorial-break {
  width: min(20%, 5.5rem);
  margin: var(--ed-space-8) auto;
  border: 0;
  border-top: 2px solid var(--ed-accent);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .editorial-article {
    width: min(100% - 1.5rem, var(--ed-max));
    padding-block: var(--ed-space-5) var(--ed-space-7);
  }

  .stat-grid,
  .content-grid,
  .two-column,
  .comparison,
  .pros-cons,
  .figure-pair,
  .gallery {
    grid-template-columns: 1fr;
  }

  .stat-grid .stat,
  .stat {
    border-right: 0;
    border-bottom: 1px solid var(--ed-border);
  }

  .stat-grid .stat:last-child {
    border-bottom: 0;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: var(--ed-space-2);
  }

  .timeline-date,
  .timeline-item h3,
  .timeline-item p {
    grid-column: 1;
    grid-row: auto;
  }

  .full-bleed {
    width: 100%;
    margin-inline: 0;
    transform: none;
  }

  .editorial-header h1 {
    max-width: none;
  }
}

/* Optional long-form composition: readable prose with an editorial side rail. */
@media (min-width: 900px) {
  .editorial-article--sidebar {
    grid-template-columns: minmax(0, var(--ed-measure)) minmax(14rem, 22rem);
    column-gap: clamp(1.5rem, 3vw, 2.5rem);
    justify-content: start;
  }

  .editorial-article--sidebar > p,
  .editorial-article--sidebar > ul,
  .editorial-article--sidebar > ol {
    grid-column: 1;
  }

  .editorial-article--sidebar > .editorial-sidebar {
    grid-column: 2;
    width: 100%;
    max-width: none;
    margin: 0;
    align-self: start;
  }

  .editorial-spread {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, var(--ed-measure)) minmax(14rem, 22rem);
    column-gap: clamp(1.5rem, 3vw, 2.5rem);
    align-items: start;
    width: 100%;
  }

  .editorial-spread > .content-container {
    width: 100%;
    max-width: var(--ed-measure);
  }

  .timeline--compact {
    margin: 0;
  }

  .timeline--compact .timeline-item {
    grid-template-columns: 1fr;
    gap: 0.25rem;
    padding: var(--ed-space-3) 0;
  }

  .timeline--compact .timeline-date,
  .timeline--compact .timeline-item h3,
  .timeline--compact .timeline-item p {
    grid-column: 1;
    grid-row: auto;
  }

  .timeline--compact .timeline-item h3 {
    margin-bottom: 0.2rem;
    font-size: 0.95rem;
  }

  .timeline--compact .timeline-item p {
    font-size: 0.88rem;
    line-height: 1.5;
  }
}

@media (min-width: 1200px) {
  .editorial-article--sidebar > p,
  .editorial-article--sidebar > ul,
  .editorial-article--sidebar > ol {
    grid-column: 1;
  }

  .editorial-article--sidebar > .editorial-sidebar {
    grid-column: 2;
  }
}

@media (max-width: 520px) {
  .editorial-main {
    font-size: 1.02rem;
  }

  .info-callout,
  .fact-box,
  .takeaways,
  .definition,
  .recommendation,
  .forecast,
  .aside,
  .event-card,
  .entity-card {
    padding: var(--ed-space-4);
  }
}

/* ---------- Component library (design-system page, #155) ---------- */
.editorial-article > .component-index,
.editorial-article > .component-doc,
.editorial-article > .authoring-note {
  grid-column: 1 / -1;
  width: 100%;
  max-width: none;
  margin-inline: 0;
}

.authoring-note {
  margin: 0 0 var(--ed-space-5);
  padding: var(--ed-space-4) var(--ed-space-5);
  background: var(--ed-ice);
  border: 1px solid var(--ed-border);
  border-left: 4px solid var(--ed-accent);
  color: var(--ed-ink);
  max-width: var(--ed-wide);
}

.authoring-note p {
  margin: 0 0 var(--ed-space-2);
  max-width: 48rem;
}

.authoring-note p:last-child {
  margin-bottom: 0;
}

.authoring-note code {
  font-family: var(--ed-ui);
  font-size: 0.88em;
}

.component-index {
  margin: 0 0 var(--ed-space-6);
  padding: var(--ed-space-5);
  background: var(--ed-surface);
  border: 1px solid var(--ed-border);
  color: var(--ed-ink);
}

.component-index h2 {
  margin: 0 0 var(--ed-space-3);
  font-family: var(--ed-ui);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ed-muted);
}

.component-index h3 {
  margin: var(--ed-space-4) 0 var(--ed-space-2);
  font-family: var(--ed-ui);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ed-deep);
}

.component-index h3:first-of-type {
  margin-top: 0;
}

.component-index ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.65rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.component-index li {
  margin: 0;
}

.component-index a {
  display: inline-block;
  padding: 0.28em 0.65em;
  font-family: var(--ed-ui);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--ed-charcoal);
  background: var(--ed-ice);
  border: 1px solid var(--ed-border);
  border-radius: var(--ed-radius);
}

.component-index a:hover,
.component-index a:focus-visible {
  color: var(--ed-accent);
  border-color: var(--ed-accent);
  text-decoration: none;
}

.component-doc {
  margin: 0 0 var(--ed-space-6);
  padding: 0 0 var(--ed-space-6);
  border-bottom: 1px solid var(--ed-border);
  color: var(--ed-ink);
}

.component-doc > h3 {
  margin: 0 0 var(--ed-space-2);
  max-width: none;
  font-family: var(--ed-serif);
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--ed-ink);
}

.component-doc > .component-class {
  display: block;
  margin: 0 0 var(--ed-space-3);
  font-family: var(--ed-ui);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ed-accent);
}

.component-doc > .component-desc {
  max-width: var(--ed-measure);
  margin: 0 0 var(--ed-space-4);
  color: var(--ed-charcoal);
}

.component-doc > .component-label {
  margin: var(--ed-space-4) 0 var(--ed-space-2);
  font-family: var(--ed-ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ed-muted);
}

.component-doc .component-example {
  margin: 0 0 var(--ed-space-4);
  padding: var(--ed-space-4);
  background: color-mix(in srgb, var(--ed-bg) 70%, var(--ed-surface));
  border: 1px dashed var(--ed-border);
  border-radius: var(--ed-radius);
}

.component-doc .component-example > *:first-child {
  margin-top: 0;
}

.component-doc .component-example > *:last-child {
  margin-bottom: 0;
}

.component-doc pre,
.component-doc .code-block,
.component-doc .highlighter-rouge,
.component-doc .highlight {
  max-width: 100%;
}

.component-doc .code-block {
  margin: 0;
}

@media (max-width: 640px) {
  .component-index {
    padding: var(--ed-space-4);
  }

  .component-doc .component-example {
    padding: var(--ed-space-3);
  }
}

