/*
 * Article layout — editorial long-read styling for `layout: article`.
 * Self-contained: loaded only on article pages via the `css` front-matter hook.
 * Navy editorial palette, matching the in-article figures (distinct from the
 * site's purple brand, which is retained in the shared navigation/footer).
 */

.article-mode {
  --art-navy: #11365A;
  --art-navy-deep: #0C2740;
  --art-navy-soft: #2E5C8A;
  --art-ink: #1f2a33;
  --art-muted: #4A5562;
  --art-line: #e4e9f0;
  --art-tint: #EAF1F8;
  --art-tint-line: #B9C8D8;
  --art-green: #2E7D4F;
  --art-red: #C0392B;
  --art-gold: #C79A3A;
  --art-serif: Georgia, Cambria, "Times New Roman", serif;
  --art-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --art-measure: 38rem; /* ~608px reading column */
}

/* ---- Skip link (keyboard accessibility) ---- */
.article-skiplink {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--art-navy);
  color: #fff;
  padding: 0.6rem 0.9rem;
  font-family: var(--art-sans);
  font-size: 0.9rem;
  z-index: 2000;
  border-radius: 0 0 6px 0;
}
.article-skiplink:focus { left: 0; outline: 2px solid var(--art-gold); }

/* ---- Reading-progress bar ---- */
.article-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: transparent;
  z-index: 1080;
  pointer-events: none;
}
.article-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--art-navy) 0%, var(--art-navy-soft) 100%);
  transition: width 0.08s linear;
}

/* ---- Reset the constrained page wrapper for full-bleed editorial layout ---- */
.article-page {
  color: var(--art-ink);
  font-family: var(--art-serif);
}
.article-page .wrapper { max-width: none; } /* defensive */

/* ---- Hero ---- */
.article-hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1200px 380px at 78% -10%, rgba(46, 92, 138, 0.55), transparent 60%),
    linear-gradient(160deg, var(--art-navy) 0%, var(--art-navy-deep) 100%);
  color: #fff;
  padding: clamp(2.6rem, 7vw, 5.5rem) 1.4rem clamp(2.4rem, 6vw, 4.5rem);
  margin-bottom: clamp(2rem, 5vw, 3.5rem);
  border-bottom: 3px solid var(--art-gold);
}
.article-hero-motif {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 60%;
  max-width: 720px;
  height: 100%;
  pointer-events: none;
  opacity: 0.85;
}
.article-hero-inner {
  position: relative;
  max-width: 50rem;
  margin: 0 auto;
}
.article-eyebrow {
  font-family: var(--art-sans);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
  font-weight: 700;
  color: #E9C877;
  margin: 0 0 1rem;
}
.article-title {
  font-family: var(--art-serif);
  color: #fff;
  font-weight: 700;
  line-height: 1.08;
  font-size: clamp(2rem, 5.2vw, 3.4rem);
  margin: 0 0 1.1rem;
  letter-spacing: -0.01em;
}
.article-page .article-title { color: #fff; } /* override .page-content h1 site rule */
.article-dek {
  font-family: var(--art-serif);
  font-style: italic;
  font-size: clamp(1.1rem, 2.2vw, 1.4rem);
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.92);
  margin: 0 0 1.6rem;
  max-width: 40rem;
}
.article-byline {
  font-family: var(--art-sans);
  font-size: 0.86rem;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.78);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.article-byline-sep { opacity: 0.5; }

/* ---- Body shell with optional sticky TOC rail ---- */
.article-shell {
  position: relative;
  max-width: 84rem;
  margin: 0 auto;
}
.article-toc-rail {
  display: none; /* hidden until viewport is wide enough */
}

/*
 * Body uses a 3-column "breakout" grid:
 *   [1fr gutter] [reading column = 38rem] [1fr gutter]
 * Prose stays in the reading column for comfortable line length, while
 * figures and wide tables break out across all three columns to use the
 * full body width — keeping cards visually generous without making body
 * text uncomfortably long.
 */
.article-body {
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 1.4rem;
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    minmax(0, var(--art-measure))
    minmax(0, 1fr);
  column-gap: 0;
}
.article-body > * {
  grid-column: 2;
  min-width: 0;
  max-width: 100%;
}
.article-body > .article-figure,
.article-body > table.is-wide,
.article-body > figure,
.article-body > .references {
  grid-column: 1 / -1;
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
}
.article-body p {
  font-size: 1.16rem;
  line-height: 1.72;
  color: var(--art-ink);
  margin: 0 0 1.35rem;
}
.article-body p a,
.article-body li a {
  color: var(--art-navy);
  text-decoration: underline;
  text-decoration-color: rgba(17, 54, 90, 0.35);
  text-underline-offset: 2px;
}
.article-body p a:hover,
.article-body li a:hover {
  color: var(--art-navy-soft);
  text-decoration-color: var(--art-navy-soft);
}
.article-body ul,
.article-body ol {
  font-size: 1.16rem;
  line-height: 1.7;
  margin: 0 auto 1.35rem;
  padding-left: 1.3rem;
}
.article-body li { margin-bottom: 0.5rem; }
.article-body strong { color: var(--art-navy-deep); }

/* Drop cap on the opening paragraph */
.article-body > .lead::first-letter,
.article-body > p.lead:first-letter {
  initial-letter: 3;
  -webkit-initial-letter: 3;
  font-family: var(--art-serif);
  font-weight: 700;
  color: var(--art-navy);
  margin-right: 0.6rem;
  float: left;
  font-size: 3.4rem;
  line-height: 0.82;
  padding-top: 0.2rem;
}

/* ---- Part headings ---- */
.part-head {
  position: relative;
  margin: clamp(3.2rem, 7vw, 4.8rem) auto clamp(1.4rem, 3vw, 2rem);
  text-align: left;
  padding-top: 1.4rem;
  border-top: 2px solid var(--art-navy);
}
.part-head::after {
  content: "";
  position: absolute;
  top: -2px; left: 0;
  width: 4rem;
  height: 2px;
  background: var(--art-gold);
}
.part-kicker {
  display: inline-block;
  font-family: var(--art-sans);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--art-gold);
  margin-bottom: 0.5rem;
}
.part-head h2 {
  font-family: var(--art-serif);
  font-size: clamp(1.6rem, 3.4vw, 2.3rem);
  line-height: 1.14;
  color: var(--art-navy);
  margin: 0;
  padding: 0;
  border: 0;
  font-weight: 700;
}
.article-body h3 {
  font-family: var(--art-serif);
  font-size: clamp(1.2rem, 2.2vw, 1.45rem);
  line-height: 1.25;
  color: var(--art-navy);
  margin: 2rem auto 0.7rem;
  font-weight: 700;
}
.article-body h4 {
  font-family: var(--art-sans);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.92rem;
  color: var(--art-navy-soft);
  margin: 1.6rem auto 0.6rem;
}

/* ---- In-article contents ---- */
.article-contents {
  border: 1px solid var(--art-line);
  border-left: 3px solid var(--art-navy);
  border-radius: 8px;
  background: #fff;
  padding: 1.1rem 1.3rem;
  margin: 0 auto 2.4rem;
}
.article-contents p {
  font-family: var(--art-sans);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--art-muted);
  margin: 0 0 0.6rem;
}
.article-contents ol {
  font-family: var(--art-sans);
  font-size: 0.98rem;
  list-style: none;
  padding: 0;
  margin: 0;
  columns: 2;
  column-gap: 1.6rem;
}
.article-contents li { margin-bottom: 0.35rem; break-inside: avoid; }
.article-contents a {
  color: var(--art-ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.article-contents a:hover { color: var(--art-navy); border-bottom-color: var(--art-navy); }
@media (max-width: 560px) { .article-contents ol { columns: 1; } }

/* ---- TL;DR list ---- */
.tldr {
  margin: 0 auto 1.4rem;
  padding: 0;
  list-style: none;
}
.tldr > li {
  position: relative;
  padding-left: 1.6rem;
  margin-bottom: 0.9rem;
  font-size: 1.1rem;
  line-height: 1.6;
}
.tldr > li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.55em;
  width: 0.5rem; height: 0.5rem;
  border-radius: 50%;
  background: var(--art-navy);
}

/* ---- Callouts ---- */
.callout {
  border: 1px solid var(--art-tint-line);
  background: var(--art-tint);
  border-radius: 10px;
  padding: 1.2rem 1.4rem;
  margin: 1.8rem auto;
}
.callout p { font-size: 1.04rem; line-height: 1.6; margin: 0 0 0.7rem; }
.callout p:last-child { margin-bottom: 0; }
.callout-label {
  font-family: var(--art-sans);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--art-navy);
  display: block;
  margin-bottom: 0.4rem;
}
.callout.is-bottomline { border-color: var(--art-navy); border-left-width: 4px; background: #F4F8FC; }
.callout.is-action { background: #F1F8F3; border-color: #BcdCc6; border-left: 4px solid var(--art-green); }
.callout.is-action .callout-label { color: var(--art-green); }

/* ---- Pull quote ---- */
.pull-quote {
  font-family: var(--art-serif);
  font-style: italic;
  font-size: clamp(1.3rem, 2.6vw, 1.7rem);
  line-height: 1.35;
  color: var(--art-navy);
  border: 0;
  border-top: 2px solid var(--art-gold);
  border-bottom: 2px solid var(--art-gold);
  padding: 1.2rem 0;
  margin: 2.2rem auto;
  text-align: center;
}

/* ---- Tables ---- */
.article-body table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--art-sans);
  font-size: 0.96rem;
  margin: 1.8rem auto;
}
.article-body table.is-wide {
  max-width: 60rem;
  width: 100%;
}
.article-body th {
  background: var(--art-navy);
  color: #fff;
  text-align: left;
  padding: 0.6rem 0.8rem;
  font-weight: 600;
  border: 1px solid var(--art-navy);
}
.article-body td {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--art-line);
  vertical-align: top;
  line-height: 1.45;
}
.article-body tbody tr:nth-child(odd) td { background: #F7FAFD; }

/* ---- Figures ---- */
.article-figure {
  max-width: 62rem;
  margin: clamp(1.8rem, 4vw, 2.8rem) auto;
  width: 100%;
}
.article-figure svg { width: 100%; height: auto; display: block; }
.article-figure figcaption {
  font-family: var(--art-sans);
  font-size: 0.82rem;
  color: var(--art-muted);
  margin-top: 0.7rem;
  text-align: center;
  line-height: 1.45;
}

/* ---- References ---- */
.references {
  margin: clamp(2.4rem, 5vw, 3.4rem) auto 0;
  padding-top: 1.4rem;
  border-top: 2px solid var(--art-navy);
  max-width: 50rem;
}
.references h2 {
  font-family: var(--art-serif);
  color: var(--art-navy);
  border: 0;
  padding: 0;
  font-size: 1.5rem;
  margin: 0 0 1rem;
}
.references ol {
  font-family: var(--art-sans);
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--art-muted);
  padding-left: 1.6rem;
  margin: 0;
}
.references li { margin-bottom: 0.5rem; }
.references li a { color: var(--art-navy); word-break: break-word; }
.article-end-note {
  margin: 1.4rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--art-line);
  font-family: var(--art-sans);
  font-size: 0.74rem;
  font-style: italic;
  color: var(--art-muted);
  line-height: 1.5;
}

/* ---- Reveal-on-scroll (toned-down) ---- */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.is-revealed { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ---- page-meta spacing inside article ---- */
.article-page .page-meta { max-width: var(--art-measure); margin-left: auto; margin-right: auto; }

@media (max-width: 900px) {
  .article-figure { width: 100%; max-width: 100%; }
  .article-body table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .article-body table.is-wide { width: 100%; }
}

/* On narrow viewports, fade the hero motif so it doesn't compete with text. */
@media (max-width: 720px) {
  .article-hero-motif { width: 80%; opacity: 0.35; }
}
@media (max-width: 480px) {
  .article-hero-motif { display: none; }
  .article-body { padding: 0 1.1rem; }
  .article-body p, .article-body ul, .article-body ol { font-size: 1.08rem; }
}

/* ---- Figure helper palette classes (used inside SVG/HTML figures) ---- */
.fig-card {
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
}

/* ---- Figure caption polish: bold "Figure N — " prefix ---- */
.article-figure figcaption {
  font-style: italic;
}
.article-figure figcaption strong,
.article-figure figcaption b {
  font-style: normal;
  font-weight: 700;
  color: var(--art-navy);
  margin-right: 0.3rem;
}

/* ---- Sticky desktop TOC rail (≥1280px) ---- */
@media (min-width: 1280px) {
  .article-shell {
    display: grid;
    grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
    column-gap: 3rem;
    padding: 0 2rem;
  }
  .article-toc-rail {
    display: block;
    position: sticky;
    top: 2rem;
    align-self: start;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    padding: 0.6rem 0 0.6rem 0.8rem;
    border-left: 2px solid var(--art-line);
    font-family: var(--art-sans);
    font-size: 0.86rem;
  }
  .article-toc-rail-label {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--art-muted);
    margin: 0 0 0.7rem;
  }
  .article-toc-rail ol {
    list-style: none;
    padding: 0;
    margin: 0;
  }
  .article-toc-rail li { margin-bottom: 0.55rem; line-height: 1.35; }
  .article-toc-rail a {
    color: var(--art-muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    margin-left: -0.85rem;
    padding-left: 0.7rem;
    display: block;
    transition: color 0.15s ease, border-color 0.15s ease;
  }
  .article-toc-rail a:hover { color: var(--art-navy); }
  .article-toc-rail a.is-current {
    color: var(--art-navy);
    border-left-color: var(--art-gold);
    font-weight: 600;
  }
  /* On wide screens, hide the inline contents block since the rail covers it. */
  .article-contents { display: none; }
  /* Centre the body within its grid cell while preserving the measure. */
  .article-body { margin-left: auto; margin-right: auto; }
}

/* ---- End-of-article navigation: back-to-articles + share ---- */
.article-end-nav {
  max-width: 50rem;
  margin: clamp(2.4rem, 5vw, 3.4rem) auto 0;
  padding: 1.4rem 1.4rem 0;
  border-top: 1px solid var(--art-line);
}
.article-end-nav-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.article-end-back {
  font-family: var(--art-sans);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--art-navy);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.article-end-back:hover { color: var(--art-navy-soft); text-decoration: underline; }
.article-share {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--art-sans);
  font-size: 0.86rem;
}
.article-share-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--art-muted);
  margin-right: 0.2rem;
}
.article-share-btn {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--art-line);
  background: #fff;
  border-radius: 999px;
  color: var(--art-navy);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.article-share-btn:hover {
  background: var(--art-navy);
  color: #fff;
  border-color: var(--art-navy);
}

/* ---- Print stylesheet ---- */
@media print {
  .article-progress,
  .article-skiplink,
  .article-toc-rail,
  .article-end-nav,
  .site-header,
  .site-footer,
  .article-hero-motif { display: none !important; }
  .article-mode { color: #000; background: #fff; }
  .article-hero {
    background: none;
    color: #000;
    padding: 0 0 1rem;
    border-bottom: 1px solid #000;
  }
  .article-page .article-title,
  .article-dek,
  .article-byline,
  .article-eyebrow { color: #000 !important; }
  .article-body { max-width: none; }
  .article-body p, .article-body li { font-size: 11pt; line-height: 1.45; }
  .article-figure { break-inside: avoid; page-break-inside: avoid; }
  .reveal { opacity: 1 !important; transform: none !important; }
  a { color: #000; text-decoration: underline; }
  .callout, .pull-quote { break-inside: avoid; }
}

/* ---- Markdown utility grids used inside articles ---- */
.three-up,
.four-up {
  display: grid;
  gap: 1.1rem;
  margin: 1.4rem 0 1.8rem;
}
.three-up { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.four-up  { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.three-up > p,
.four-up > p {
  margin: 0;
  padding: 1.1rem 1.2rem;
  background: #F7FAFD;
  border: 1px solid #E2EAF3;
  border-radius: 12px;
  font-size: 0.97rem;
  line-height: 1.5;
}
.three-up > p strong:first-child,
.four-up > p strong:first-child {
  display: block;
  color: #11365A;
  font-size: 1.02rem;
  margin-bottom: 0.35rem;
}
.three-up > p em,
.four-up > p em {
  color: #5B6573;
  font-style: normal;
  font-weight: 600;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
