/*
  Article system — scoped under .article-page so these rules cannot
  leak onto calculator / index / result pages.

  Fonts: SIL OFL 1.1
    Literata — Google Fonts
    IBM Plex Sans — IBM
  Self-hosted woff2; do not load Google Fonts (or any font CDN) at runtime.
*/

@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/literata-latin-400.woff2") format("woff2");
}

@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/literata-latin-600.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-sans-latin-500.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-sans-latin-600.woff2") format("woff2");
}

/* base.html constrains <main> to max-w-4xl. Widen article pages only so
   the prose column + outside TOC can sit side by side at >=1100px. */
body:has(.article-page) {
  background-color: #FCFCFA;
}

body:has(.article-page) > main {
  max-width: 76rem; /* prose + wider TOC + larger gap */
  background-color: #FCFCFA;
}

.article-page {
  --paper: #FCFCFA;
  --ink: #1A1F24;
  --muted: #5C6670;
  --rule: #E4E7E5;
  --accent: #0F5E4A;
  --accent-tint: #EBF2EF;
  --row-alt: #F7F8F7;
  /* One measure for titles + body. Do not use `ch` on headings — ch is
     relative to each element's font, so h1 68ch is much wider than body
     68ch and the text looks indented under the title. */
  --prose-max: 56rem; /* ~896px; titles, body, and tables share this */

  color: var(--ink);
  background-color: var(--paper);
  font-family: "Literata", "Georgia", serif;
  font-size: 20px;
  font-weight: 400;
  line-height: 1.65;
  text-align: left;
}

.article-page .article-shell {
  position: relative;
}

.article-page .article-main {
  min-width: 0;
}

.article-page h1,
.article-page h2,
.article-page h3,
.article-page .article-toc-panel,
.article-page .article-toc-inline,
.article-page table,
.article-page .article-cta {
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

.article-page h1,
.article-page h2,
.article-page h3 {
  font-weight: 600;
  color: var(--ink);
  text-wrap: balance;
  scroll-margin-top: 1.25rem;
}

.article-page h1 {
  font-size: clamp(1.75rem, 5vw, 2.5rem); /* ~28px → 40px */
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin: 2.75rem 0 0.45em;
  max-width: var(--prose-max);
}

.article-page h2 {
  font-size: clamp(1.45rem, 3.2vw, 1.875rem); /* ~23px → 30px */
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin: 2em 0 0.6em;
  max-width: var(--prose-max);
}

.article-page h3 {
  font-size: clamp(1.2rem, 2.4vw, 1.4375rem); /* ~19px → 23px */
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin: 1.6em 0 0.5em;
  max-width: var(--prose-max);
}

.article-page .article-intro,
.article-page .article-body > p,
.article-page .article-body > ul,
.article-page .article-body > ol,
.article-page .article-body > .article-cta,
.article-page .article-body > .article-score-cta,
.article-page .article-body > .article-faq,
.article-page .article-body > .article-note,
.article-page .article-end {
  max-width: var(--prose-max);
}

.article-page p {
  margin: 0 0 1em;
}

.article-page .article-intro {
  margin-bottom: 0.5em;
}

.article-page .article-byline {
  max-width: var(--prose-max);
  margin: 0 0 1.75em;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--muted);
}

.article-page strong,
.article-page b {
  font-weight: 600;
}

.article-page a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

.article-page a:focus-visible,
.article-page button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.article-page ul,
.article-page ol {
  margin: 0 0 1em;
  padding-left: 1.5em;
  list-style-type: disc;
}

.article-page .article-toc-list,
.article-page .article-part-links {
  list-style: none;
  padding-left: 0;
}

.article-page li + li {
  margin-top: 0.25em;
}

.article-page .article-part-links {
  max-width: var(--prose-max);
  margin: 0.75em 0 1.35em;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.article-page .article-part-links li + li {
  margin-top: 0;
}

.article-page .article-part-links a {
  display: block;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #ffffff;
  text-decoration: none;
}

.article-page .article-part-links a:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
}

/* ----- TOC: desktop floating panel ----- */

.article-page .article-toc-panel {
  display: none;
  width: 15.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #ffffff;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

.article-page .article-toc-kicker {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.article-page .article-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.article-page .article-toc-list a {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.32rem 0;
  color: var(--muted);
  text-decoration: none;
}

.article-page .article-toc-list a::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: 0.45em;
  border-radius: 50%;
  background: transparent;
  flex-shrink: 0;
}

.article-page .article-toc-panel a.is-active,
.article-page .article-toc-inline a.is-active {
  color: var(--accent);
}

.article-page .article-toc-panel a.is-active::before {
  background: var(--accent);
}

.article-page .article-toc-panel a:hover {
  color: var(--ink);
}

/* ----- TOC: mobile inline index ----- */

.article-page .article-toc-inline {
  max-width: var(--prose-max);
  margin: 0 0 2em;
  padding: 0.85rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #ffffff;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
}

.article-page .article-toc-inline a::before {
  display: none;
}

/* ----- Reading progress (mobile only) ----- */

.article-page .article-progress {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 50;
  background: transparent;
  pointer-events: none;
}

.article-page .article-progress-bar {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
}

/* ----- Tables ----- */

.article-page .table-wrap {
  width: 100%;
  max-width: var(--prose-max);
  margin: 0 0 1.25em;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.article-page table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #C5CCC9;
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
}

.article-page thead th {
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 600;
  text-align: left;
  padding: 0.65rem 0.85rem;
  border: 0;
  border-bottom: 1px solid #C5CCC9;
}

.article-page tbody td {
  padding: 0.6rem 0.85rem;
  border: 0;
  vertical-align: top;
}

.article-page tbody tr:nth-child(odd) {
  background: #ffffff;
}

.article-page tbody tr:nth-child(even) {
  background: var(--row-alt);
}

.article-page th:last-child,
.article-page td:last-child,
.article-page .num {
  text-align: center;
  width: 22%;
  min-width: 8.5rem;
}

.article-page td:last-child,
.article-page .num {
  white-space: nowrap;
}

.article-page tr.bonus td:first-child {
  padding-left: 2rem;
}

.article-page table.cols-center {
  table-layout: fixed;
}

.article-page table.cols-center th,
.article-page table.cols-center td {
  text-align: center;
  vertical-align: middle;
}

.article-page table.cols-center th:last-child,
.article-page table.cols-center td:last-child {
  width: 40%;
}

.article-page table.draw-grid th,
.article-page table.draw-grid td {
  text-align: center;
  width: auto;
  min-width: 6.5rem;
  white-space: normal;
  vertical-align: top;
  border-left: 1px solid #C5CCC9;
}

.article-page table.draw-grid th:first-child,
.article-page table.draw-grid td:first-child {
  text-align: left;
  white-space: nowrap;
  min-width: 0;
  width: auto;
  border-left: 0;
}

.article-page table.draw-grid .draw-invites {
  display: block;
  margin-top: 0.2em;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.article-page tr.maximum {
  font-weight: 600;
}

/* ----- Contact + CTA ----- */

.article-page .article-end {
  margin-top: 2.5em;
  padding-top: 1.5em;
  border-top: 1px solid var(--rule);
}

.article-page .article-meta {
  color: var(--muted);
  font-size: 0.95em;
}

.article-page .article-score-cta {
  margin-top: 2.5em;
  padding-top: 1.5em;
  border-top: 1px solid var(--rule);
}

.article-page .article-score-cta .article-meta {
  color: var(--muted);
  font-size: 0.95em;
}

.article-page .article-cta {
  margin: 1.25em 0 1.75em;
}

.article-page .article-cta a {
  display: inline-block;
  padding: 0.65rem 1.15rem;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
}

.article-page .article-cta a:hover {
  filter: brightness(1.08);
}

.article-page .article-cta a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.article-page .article-support {
  color: var(--muted);
  font-size: 0.95em;
}

.article-page .article-note {
  color: var(--muted);
  font-size: 0.95em;
}

.article-page .article-anchor {
  display: block;
  height: 0;
  overflow: hidden;
}

@media (min-width: 1100px) {
  .article-page .article-shell {
    display: grid;
    grid-template-columns: minmax(0, var(--prose-max)) 15.25rem;
    column-gap: 2.75rem;
    align-items: start;
    justify-content: start;
  }

  .article-page .article-toc-panel {
    display: block;
    position: sticky;
    top: 1.5rem;
  }

  .article-page .article-toc-inline,
  .article-page .article-progress {
    display: none;
  }
}

@media (max-width: 1099.98px) {
  .article-page .article-faq,
  .article-page .toc-faq {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .article-page .article-progress-bar,
  .article-page .article-cta a {
    transition: none;
  }
}
