/* Documentation pages. Share the site tokens from ../css/style.css, then take
   over the reading layout: a chapter rail on the left, one measured column. */

body {
  background: var(--paper);
}

.doc-skip {
  position: absolute;
  left: -9999px;
}

.doc-skip:focus {
  left: 16px;
  top: 12px;
  z-index: 50;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
}

/* ---------- Top bar ---------- */

.doc-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: 0 var(--s-4);
  height: 56px;
  background: rgba(255, 248, 243, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.doc-home {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--ink);
}

.doc-home img {
  height: 20px;
  width: auto;
}

.doc-top-sep {
  color: var(--ink-2);
  font-size: 14px;
}

.doc-top-cta {
  margin-left: auto;
  font-size: 14px;
  color: var(--ink-2);
  text-decoration: none;
}

.doc-top-cta:hover {
  color: var(--ink);
}

/* ---------- Shell ---------- */

.doc-shell {
  max-width: 1080px;
  margin-inline: auto;
  padding: var(--s-8) var(--s-4) var(--s-12);
}

@media (min-width: 960px) {
  .doc-shell {
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr);
    gap: 72px;
    padding-inline: var(--s-6);
  }
}

/* ---------- Chapter rail ---------- */

.doc-rail {
  display: none;
}

@media (min-width: 960px) {
  .doc-rail {
    display: block;
    position: sticky;
    top: 88px;
    align-self: start;
    font-size: 14px;
  }
}

.doc-rail p {
  margin: 0 0 var(--s-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.doc-rail ol {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.doc-rail a {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 6px;
  padding: 7px 0;
  color: var(--ink-2);
  text-decoration: none;
  line-height: 1.35;
}

.doc-rail .n {
  font-variant-numeric: tabular-nums;
  color: rgba(24, 24, 24, 0.62);
}

.doc-rail a:hover {
  color: var(--ink);
}

.doc-rail a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
}

.doc-rail a[aria-current="page"] .n {
  color: var(--violet-dark);
}

/* ---------- Article ---------- */

.doc-main {
  max-width: 700px;
}

.kicker {
  display: block;
  margin-bottom: var(--s-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--violet-dark);
}

.doc-main h1 {
  margin: 0 0 var(--s-4);
  font-size: clamp(32px, 5vw, 46px);
  line-height: 1.04;
  letter-spacing: -0.032em;
}

.doc-lead {
  margin: 0 0 var(--s-7);
  font-size: 19px;
  line-height: 1.58;
  color: var(--ink-2);
}

.doc-main h2 {
  margin: var(--s-10) 0 var(--s-3);
  font-size: clamp(21px, 2.4vw, 25px);
  line-height: 1.2;
  letter-spacing: -0.018em;
}

.doc-main p {
  margin: 0 0 var(--s-4);
  font-size: 17px;
  line-height: 1.68;
}

.doc-main p strong {
  font-weight: 600;
}

.doc-main a {
  color: var(--violet-dark);
  text-underline-offset: 3px;
}

.doc-main ul,
.doc-main ol {
  margin: 0 0 var(--s-4);
  padding-left: 1.1em;
  font-size: 17px;
  line-height: 1.68;
}

.doc-main li {
  margin-bottom: 6px;
}

.doc-main li::marker {
  color: var(--violet);
}

/* ---------- Stats ---------- */

.stats {
  display: grid;
  gap: var(--s-4);
  margin: var(--s-7) 0;
  padding: var(--s-5) 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

@media (min-width: 560px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-5) var(--s-7);
  }
}

.stats div {
  display: grid;
  gap: 2px;
}

.stats b {
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--violet-dark);
  font-variant-numeric: tabular-nums;
}

.stats span {
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-2);
}

/* ---------- Figures ---------- */

.fig {
  margin: var(--s-8) 0;
}

.fig img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  background: var(--screen-grad);
}

.fig figcaption {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 60ch;
}

.fig-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-4);
  margin: var(--s-8) 0;
}

.fig-row .fig {
  margin: 0;
}

.fig-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-3);
  margin: var(--s-8) 0;
}

.fig-strip img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
}

@media (min-width: 700px) {
  .fig-strip {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* ---------- Notes ---------- */

.note {
  margin: var(--s-7) 0;
  padding: 0 0 0 var(--s-4);
  border-left: 2px solid var(--violet);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-2);
}

.note strong {
  color: var(--ink);
}

/* ---------- Table ---------- */

.doc-table {
  width: 100%;
  margin: var(--s-6) 0;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.5;
}

.doc-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 0 12px 8px 0;
  border-bottom: 1px solid var(--line);
}

.doc-table td {
  padding: 12px 12px 12px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.doc-table td:first-child {
  white-space: nowrap;
  font-weight: 600;
}

.doc-table small {
  display: block;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 400;
}

/* ---------- Cover (index) ---------- */

.doc-cover {
  padding-bottom: var(--s-7);
  border-bottom: 1px solid var(--line);
}

.doc-meta {
  display: grid;
  gap: var(--s-2) var(--s-6);
  margin: var(--s-6) 0 0;
  font-size: 14px;
  line-height: 1.5;
}

@media (min-width: 560px) {
  .doc-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.doc-meta div {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: var(--s-3);
  padding: 6px 0;
  border-top: 1px solid var(--line);
}

.doc-meta dt {
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-top: 2px;
}

.doc-meta dd {
  margin: 0;
}

/* ---------- Contents ---------- */

.toc {
  margin: var(--s-5) 0 var(--s-8);
  padding: 0;
  list-style: none;
  font-size: 16px;
}

.toc > li {
  padding: var(--s-4) 0;
  border-top: 1px solid var(--line);
}

.toc > li:last-child {
  border-bottom: 1px solid var(--line);
}

.toc-ch {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  padding-block: 9px 7px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.toc-ch:hover .toc-t {
  color: var(--violet-dark);
}

.toc-num {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--violet-dark);
  min-width: 14px;
}

.toc-dots {
  flex: 1;
  border-bottom: 1px dotted rgba(24, 24, 24, 0.28);
  transform: translateY(-4px);
}

.toc-count {
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.toc-sub {
  margin: 6px 0 0;
  padding: 0 0 0 28px;
  list-style: none;
  display: grid;
  gap: 2px;
  font-size: 14.5px;
  line-height: 1.45;
}

.toc-sub a {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 4px;
  padding: 3px 0;
  color: var(--ink-2);
  text-decoration: none;
}

.toc-sub a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.toc-sub span {
  font-variant-numeric: tabular-nums;
  color: rgba(24, 24, 24, 0.64);
}

/* ---------- Section numbers ---------- */

.doc-main h2 .sec {
  display: inline-block;
  min-width: 2.9em;
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--violet-dark);
  font-variant-numeric: tabular-nums;
  vertical-align: 0.14em;
}

.fig-n {
  font-weight: 600;
  color: var(--ink);
}

/* ---------- Timeline ---------- */

.timeline {
  list-style: none;
  margin: var(--s-7) 0;
  padding: 0;
  display: grid;
  gap: var(--s-4);
}

.timeline li {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: var(--s-4);
  font-size: 15px;
  line-height: 1.5;
}

.timeline time {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  padding-top: 2px;
}

/* ---------- Pager ---------- */

.pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--s-4);
  margin-top: var(--s-11);
  padding-top: var(--s-5);
  border-top: 1px solid var(--line);
  font-size: 15px;
}

.pager a {
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
}

.pager a:hover {
  color: var(--violet-dark);
}

.pager span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 2px;
}

.doc-foot {
  margin-top: var(--s-9);
  font-size: 13px;
  color: var(--ink-2);
}


/* Below 720 the table cannot hold prose, so each row becomes a block with its
   own labels. Same markup, no duplicate content. */
@media (max-width: 719px) {
  .toc-sub a {
    padding-block: 9px;
  }

  .doc-table,
  .doc-table tbody,
  .doc-table tr,
  .doc-table td {
    display: block;
    width: 100%;
  }

  .doc-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .doc-table tr {
    padding: var(--s-4) 0;
    border-bottom: 1px solid var(--line);
  }

  .doc-table td {
    border: 0;
    padding: 0 0 var(--s-3);
    white-space: normal;
  }

  .doc-table td:last-child {
    padding-bottom: 0;
  }

  .doc-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-2);
  }

  .doc-table td:first-child {
    font-size: 17px;
    padding-bottom: var(--s-2);
  }
}

@media (prefers-reduced-motion: reduce) {
  .doc-top {
    backdrop-filter: none;
    background: var(--paper);
  }
}

/* ---------- Print: the same pages as an A4 report ---------- */

@media print {
  @page {
    size: A4;
    margin: 20mm 18mm 18mm;
  }

  body {
    background: #fff;
  }

  .doc-top,
  .doc-rail,
  .doc-skip,
  .pager,
  .doc-top-cta {
    display: none !important;
  }

  .doc-shell {
    display: block;
    max-width: none;
    padding: 0;
  }

  .doc-main {
    max-width: none;
  }

  .doc-main h1 {
    font-size: 26pt;
  }

  .doc-main h2 {
    font-size: 13pt;
    margin-top: 14pt;
    break-after: avoid;
  }

  .doc-main p,
  .doc-main ul,
  .doc-main ol {
    font-size: 10.5pt;
    line-height: 1.5;
    orphans: 2;
    widows: 2;
  }

  .doc-cover,
  .fig,
  .stats,
  .doc-table {
    break-inside: avoid;
  }

  .fig img {
    max-height: 110mm;
    width: auto;
    margin-inline: auto;
  }

  .note {
    border-left-color: #000;
  }

  .stats b,
  .sec,
  .toc-num,
  .kicker,
  .doc-main a {
    color: #000 !important;
  }

  .toc > li,
  .doc-meta div,
  .stats,
  .pager {
    border-color: #bbb !important;
  }
}
