/*
 * article.css – long-form reading: the article page and the legal pages.
 * Loaded after site.css; uses the tokens from tokens.css.
 */

html.page-doc, .page-doc body { background: var(--surface-solid); }

.reading-progress {
  position: fixed;
  inset: var(--header-h) 0 auto;
  z-index: 18;
  height: 2px;
  pointer-events: none;
}
.reading-progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
}
.no-js .reading-progress { display: none; }

/* ------------------------------------------------------------ article hero */

.article-hero, .article-layout {
  width: min(100% - 2 * var(--margin), 1120px);
  margin-inline: auto;
}

.article-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  align-items: end;
  gap: var(--space-8);
  padding: calc(var(--header-h) + var(--space-8)) 0 var(--space-8);
}
.article-hero__copy > * + * { margin-top: var(--space-4); }
.article-hero h1 {
  max-width: 15ch;
  margin-top: var(--space-5);
  font-size: clamp(2.5rem, 1.55rem + 3.4vw, 4.5rem);
  line-height: 1.02;
}
.article-deck {
  max-width: 38ch;
  margin-top: var(--space-5) !important;
  color: var(--text-muted);
  font-size: var(--fs-lead);
  font-weight: var(--fw-lead);
  line-height: var(--lh-lead);
}
.byline {
  color: var(--text-muted);
  font-size: var(--fs-small);
  font-weight: var(--fw-small);
}
.article-language {
  max-width: 44ch;
  padding-left: var(--space-3);
  border-left: 2px solid var(--accent);
  font-size: var(--fs-small);
  line-height: var(--lh-small);
}
.article-hero .actions { margin-top: var(--space-6); }
.edition {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
}

.cover-link {
  display: block;
  color: var(--text-muted);
  font-size: var(--fs-small);
  text-decoration: none;
}
.cover-link img {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-media);
  box-shadow: 0 18px 40px -28px rgba(7, 33, 72, 0.45);
}
.cover-link__caption { display: block; margin-top: var(--space-3); font-size: 0.875rem; }
.cover-link:hover { color: var(--accent); }

/* --------------------------------------------------------- layout and TOC */

.article-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: var(--space-8);
  padding: var(--space-8) 0 var(--space-9);
  border-top: 1px solid var(--hairline);
}

.toc {
  position: sticky;
  top: calc(var(--header-h) + var(--space-6));
  max-height: calc(100vh - var(--header-h) - var(--space-8));
  overflow-y: auto;
  scrollbar-width: thin;
}
.toc > summary {
  min-height: 48px;
  font-size: var(--fs-small);
  font-weight: 650;
}
.toc__label {
  margin-bottom: var(--space-4);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: var(--fw-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}
.toc__list { margin: 0; padding: 0; list-style: none; }
.toc__list li + li { margin-top: 2px; }
.toc__list a {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  padding: 5px 0 5px 12px;
  border-left: 1px solid var(--hairline);
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.45;
  text-decoration: none;
  transition: color var(--dur-micro) var(--ease-standard), border-color var(--dur-micro) var(--ease-standard);
}
.toc__list a:hover { color: var(--text); }
.toc__list a[aria-current="location"] {
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.toc__num {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding-top: 0.15em;
  font-variant-numeric: tabular-nums;
}
.toc__download { margin-top: var(--space-5); }

@media (min-width: 1024px) {
  .toc > summary { display: none; }
}

/* ----------------------------------------------------- reading typography */

.article-body {
  min-width: 0;
  font-size: 1.125rem;
  line-height: 1.7;
  hyphens: auto;
}
.article-body > :where(p, ul, ol, blockquote, h2, h3, .article-intro, .article-end) { max-width: 66ch; }
.article-body p { margin: 0 0 1.15em; }
.article-body strong { font-weight: 680; }
/* A11Y-01: prose links only – `.article-body a` outranked .button--primary */
.article-body a:not(.button, .text-link) { color: var(--accent); }

.article-intro {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--hairline);
}
.article-intro .eyebrow { margin-bottom: var(--space-3); }
.article-intro p:not(.eyebrow) {
  hyphens: manual;
  color: var(--text-muted);
  font-size: var(--fs-lead);
  line-height: var(--lh-lead);
}

.article-body h2 {
  margin: 4.5rem 0 1.25rem;
  font-size: clamp(1.875rem, 1.45rem + 1.3vw, 2.5rem);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: -0.012em;
  text-wrap: balance;
}
.chapter-number {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: var(--fw-label);
  letter-spacing: var(--ls-label);
}
.chapter-number::before {
  content: "";
  width: 24px;
  height: 1px;
  background: var(--accent);
}

.article-body h3 {
  margin: 2.5rem 0 0.9rem;
  font-size: 1.25rem;
  font-weight: 650;
}

.article-body blockquote {
  margin: 0 0 2rem;
  padding: 2px 0 2px var(--space-5);
  border-left: 2px solid var(--accent);
  font-family: var(--font-serif);
  font-size: clamp(1.25rem, 1.1rem + 0.5vw, 1.5rem);
  font-weight: 400;
  line-height: 1.38;
  font-optical-sizing: auto;
  hyphens: manual;
}
.article-body blockquote p { margin: 0; }

.article-body ul, .article-body ol { margin: 0 0 1.4em; padding-left: 1.3em; }
.article-body li { margin-bottom: 0.45em; padding-left: 0.2em; }
.article-body li::marker { color: var(--accent); }

.table-scroll {
  margin: 1.75rem 0 2.25rem;
  overflow-x: auto;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-media);
  background: var(--surface-solid);
  hyphens: manual;
}
.table-scroll table {
  width: 100%;
  min-width: 36rem;
  border-collapse: collapse;
  font-size: 0.875rem;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}
.table-scroll th, .table-scroll td {
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
}
.table-scroll th {
  background: var(--surface-2);
  font-weight: 650;
  border-bottom: 1px solid var(--hairline);
}
.table-scroll td { border-top: 1px solid var(--hairline); }
.table-scroll tbody tr:first-child td { border-top: 0; }
.table-scroll tbody tr:nth-child(even) { background: rgba(var(--text-rgb), 0.025); }

.article-source {
  margin-top: var(--space-8);
  max-width: 66ch;
  padding: var(--space-5) var(--space-5) var(--space-4);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-panel);
  background: var(--bg);
  font-size: var(--fs-small);
  line-height: var(--lh-small);
}
.article-source h2 {
  margin: 0 0 var(--space-3);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: 0;
}
.article-source p:last-child { margin-bottom: 0; }

.article-end {
  margin-top: var(--space-8);
  padding-top: var(--space-7);
  border-top: 1px solid var(--hairline);
}
.article-end__question {
  max-width: 24ch;
  margin-bottom: var(--space-5) !important;
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
  line-height: 1.2;
  text-wrap: balance;
  hyphens: manual;
}

@media (max-width: 1023px) {
  .article-layout {
    display: block;
    padding-top: var(--space-5);
  }
  .article-aside { margin-bottom: var(--space-6); }
  .toc {
    position: static;
    max-height: none;
    /* the focus ring of the summary must not be clipped (WCAG 2.4.7) */
    overflow: visible;
    border-bottom: 1px solid var(--hairline);
  }
  .toc__label { display: none; }
  .toc__list { padding-bottom: var(--space-4); }
}

@media (max-width: 759px) {
  .article-hero {
    display: block;
    padding: calc(var(--header-h) + var(--space-7)) 0 var(--space-7);
  }
  .cover-link { display: none; }
  .article-body { font-size: 1.0625rem; line-height: 1.68; }
  .article-body h2 { margin-top: 3.5rem; }
}

/* PRIV-09: the no-JS header is in the flow below 1200 px (site.css) */
@media (max-width: 1199px) {
  .no-js .doc, .no-js .article-hero { padding-top: var(--space-8); }
}
@media (max-width: 759px) {
  .no-js .article-hero { padding-top: var(--space-7); }
}

/* A11Y-13: short viewports – the header scrolls away (site.css) */
@media (max-height: 420px) {
  .reading-progress { display: none; }
  .toc { top: var(--space-5); max-height: calc(100vh - var(--space-7)); }
}

/* ---------------------------------------------------------------- legal */

.doc {
  width: min(100% - 2 * var(--margin), 1120px);
  margin-inline: auto;
  padding: calc(var(--header-h) + var(--space-8)) 0 var(--space-9);
}
.doc > .legal-language { max-width: 66ch; margin-bottom: var(--space-6); }
.legal-language {
  padding-left: var(--space-3);
  border-left: 2px solid var(--accent);
  font-size: var(--fs-small);
}

.legal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
}
.legal {
  max-width: 68ch;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  hyphens: auto;
}
.legal h1 {
  margin-bottom: var(--space-6);
  font-size: clamp(2.5rem, 1.7rem + 3vw, 4rem);
  line-height: 1.04;
}
.legal h2 {
  margin: 3rem 0 1rem;
  font-size: clamp(1.5rem, 1.25rem + 0.9vw, 2rem);
  line-height: 1.15;
}
.legal h3 {
  margin: 2.25rem 0 0.75rem;
  font-size: 1.1875rem;
  font-weight: 650;
  line-height: 1.35;
}
.legal h4 {
  margin: 1.5rem 0 0.5rem;
  font-size: var(--fs-body);
  font-weight: 650;
}
.legal p, .legal ul { margin: 0 0 1em; }
.legal ul { padding-left: 1.3em; }
.legal li { margin-bottom: 0.3em; }
.legal li::marker { color: var(--accent); }
.legal code {
  padding: 1px 5px;
  border-radius: var(--radius-chip);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 0.875em;
  overflow-wrap: anywhere;
}
.legal a { overflow-wrap: anywhere; }

/* the full crest, only on the legal notice; never inverted */
.crest { width: 120px; margin: 0; align-self: start; }
.crest__frame {
  width: 120px;
  aspect-ratio: 755 / 949;
  overflow: hidden;
}
.crest img {
  width: 135.63%;
  max-width: none;
  height: auto;
  margin: -5.03% 0 0 -17.88%;
}
:root[data-theme="dark"] .crest {
  box-sizing: content-box;
  padding: 12px;
  border-radius: var(--radius-media);
  background: var(--ink-50);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .crest {
    box-sizing: content-box;
    padding: 12px;
    border-radius: var(--radius-media);
    background: var(--ink-50);
  }
}

@media (min-width: 900px) {
  .legal-layout--imprint {
    grid-template-columns: minmax(0, 68ch) 144px;
    justify-content: space-between;
    gap: var(--space-8);
  }
  .legal-layout--imprint .crest { grid-column: 2; grid-row: 1; margin-top: var(--space-3); }
  .legal-layout--imprint .legal { grid-row: 1; }
}

/* ---------------------------------------------------------------- print */

@media print {
  .reading-progress, .article-aside, .cover-link, .article-end .actions, .article-hero .actions { display: none !important; }
  html.page-doc, .page-doc body { background: #fff; }
  .article-hero, .article-layout, .doc { display: block; width: auto; padding: 0; border: 0; }
  .article-hero { margin-bottom: 18pt; }
  .article-body { font-size: 10.5pt; }
  .table-scroll { overflow: visible; border: 0; }
  .table-scroll table { min-width: 0; font-size: 8.5pt; }
  .article-body h2, .article-body h3 { break-after: avoid; }
  .table-scroll tr { break-inside: avoid; }
}
