/* Guide library: hub and article pages. Builds on tokens.css, styles.css and landing.css; see DESIGN.md. */

html:has(body.guide-page) { scroll-padding-top: 24px; }
.guide-page main { width: min(100%, calc(var(--content-max) + 2 * var(--pad-x))); margin: 0 auto; padding: 0 var(--pad-x); }

/* The landing navigation, drawn in the page flow instead of over the hero. */
.guide-nav { position: relative; }
.nav-guides { grid-column: 1; grid-row: 1; justify-self: start; }
.guide-nav .nav-contact { grid-column: 3; grid-row: 1; }

/* Ruled line with end ticks, the same mark that opens every landing section. */
.guide-layout::before, .guide-enquiry::before, .related::before, .subject::before, .hub-using::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 7px;
  border-left: 1px solid var(--hairline); border-right: 1px solid var(--hairline);
  background: linear-gradient(var(--hairline), var(--hairline)) center / 100% 1px no-repeat;
}

/* ---------- Page header ---------- */
.guide-head { max-width: 880px; padding: clamp(40px, 6vw, 80px) 0 clamp(40px, 5vw, 64px); }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; column-gap: 10px; row-gap: 4px; }
.crumbs li { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--graphite-dim); }
.crumbs li + li::before { content: "/"; margin-right: 10px; color: var(--track); }
.crumbs a { color: var(--graphite-dim); text-decoration: none; padding: 12px 0; }
.crumbs a:hover { color: var(--graphite); text-decoration: underline; text-underline-offset: 3px; }
.crumbs [aria-current] { color: var(--graphite); }
.guide-label { margin-top: clamp(28px, 4vw, 44px); font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--graphite-dim); }
.guide-head h1 { margin-top: 14px; font-size: clamp(34px, 4.2vw, 56px); line-height: 1.06; letter-spacing: -0.018em; text-wrap: balance; }
.hub-head h1 { margin-top: clamp(28px, 4vw, 44px); }
.guide-head .standfirst { margin-top: 20px; max-width: 38em; font-size: 18px; line-height: 1.6; color: var(--graphite); text-wrap: pretty; }
.byline { margin-top: 20px; font-size: 13.5px; line-height: 1.6; color: var(--graphite-dim); }
.byline a { color: var(--graphite); text-decoration: underline; text-decoration-color: var(--track); text-underline-offset: 3px; }

/* ---------- Reading layout ---------- */
.guide-layout { position: relative; padding-top: clamp(40px, 5vw, 64px); }
.guide-layout.has-toc { display: grid; grid-template-columns: 220px minmax(0, 1fr); column-gap: clamp(40px, 6vw, 96px); align-items: start; }
.toc { position: sticky; top: 24px; }
.toc-title { padding-bottom: 10px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--graphite-dim); }
.toc ol { list-style: none; border-bottom: 1px solid var(--hairline); }
.toc li { border-top: 1px solid var(--hairline); }
.toc a { display: block; padding: 9px 0; font-size: 14px; line-height: 1.4; color: var(--graphite-dim); text-decoration: none; }
.toc a:hover { color: var(--graphite); }
.guide-body { max-width: 820px; min-width: 0; }

/* Article text: a comfortable measure for prose; tables, figures and worked examples use the full body width. */
.guide-body { font-size: 16.5px; line-height: 1.7; color: var(--graphite); }
.guide-body p, .guide-body li, .guide-body h2, .guide-body h3, .guide-body dl { max-width: 680px; }
.guide-body p, .guide-body li { text-wrap: pretty; }
.guide-body > :first-child, .guide-body section:first-child > :first-child { margin-top: 0; }
.guide-body p + p, .guide-body ul + p, .guide-body ol + p, .guide-body p + ul, .guide-body p + ol { margin-top: 16px; }
.guide-body h2 {
  margin: clamp(48px, 5vw, 64px) 0 16px; font-family: var(--serif); font-weight: 300;
  font-size: clamp(26px, 2.6vw, 34px); line-height: 1.15; letter-spacing: -0.012em; text-wrap: balance;
}
.guide-body h3 { margin: 32px 0 8px; font-family: var(--serif); font-weight: 400; font-size: 21px; line-height: 1.3; }
.guide-body strong { font-weight: 500; }
.guide-body ul, .guide-body ol { margin-top: 16px; padding-left: 1.3em; }
.guide-body li + li { margin-top: 8px; }
.guide-body li::marker { color: var(--graphite-dim); }
.guide-body a, .guide-enquiry a, .hub-using a {
  color: var(--graphite); text-decoration: underline; text-decoration-color: var(--track);
  text-decoration-thickness: 1px; text-underline-offset: 3px; transition: text-decoration-color .3s;
}
.guide-body a:hover, .guide-enquiry a:hover, .hub-using a:hover { text-decoration-color: var(--graphite); }
.guide-body sup { font-size: 0.7em; line-height: 0; }
.guide-body sup a { text-decoration: none; padding: 0 2px; }
.guide-body hr { margin: 48px 0 24px; border: 0; border-top: 1px solid var(--hairline); }
.guide-body em { font-style: italic; }

/* Sources and review notes */
.seo-citations { list-style: none; max-width: 680px; margin-top: 20px; padding-left: 0 !important; border-top: 1px solid var(--hairline); }
.guide-body .seo-citations li { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--hairline); font-size: 13.5px; line-height: 1.5; color: var(--graphite-dim); }
.guide-body .sources { margin-top: 24px; font-size: 13.5px; line-height: 1.6; color: var(--graphite-dim); }
.guide-body .checked-note { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--hairline); font-size: 13.5px; line-height: 1.6; color: var(--graphite-dim); }
.guide-body .next-step { margin-top: 28px; }
.source-notes { margin-top: 56px; padding-top: 8px; border-top: 1px solid var(--hairline); }
.guide-body .source-notes h2 { margin-top: 16px; font-size: 22px; }
.guide-body .source-notes li, .guide-body .source-notes p { font-size: 14px; line-height: 1.6; color: var(--graphite-dim); }
.source-notes :target { background: var(--panel); }

/* Questions: native disclosure with a drawn plus/minus. */
.qa { max-width: 680px; border-top: 1px solid var(--hairline); }
.qa:last-of-type { border-bottom: 1px solid var(--hairline); }
.qa summary {
  position: relative; list-style: none; cursor: pointer; padding: 16px 40px 16px 0; min-height: 44px;
  font-family: var(--serif); font-size: 19px; line-height: 1.35;
}
.qa summary::-webkit-details-marker { display: none; }
.qa summary::before, .qa summary::after { content: ""; position: absolute; right: 8px; top: 50%; width: 12px; height: 1px; background: var(--graphite); }
.qa summary::after { transform: rotate(90deg); transition: transform .3s var(--ease); }
.qa[open] summary::after { transform: rotate(0deg); }
.qa summary:focus-visible { outline-offset: 2px; }
.qa > p { padding-bottom: 18px; color: var(--graphite-dim); }
.qa + h2 { margin-top: 56px; }

/* ---------- Tables ---------- */
.guide-body figure { margin: 36px 0; }
.guide-body figcaption, .guide-body caption { font-size: 13.5px; line-height: 1.5; color: var(--graphite-dim); text-align: left; }
.seo-table-figure > figcaption { margin-bottom: 10px; }
.guide-body caption { caption-side: top; padding-bottom: 10px; }
.table-scroll { margin: 32px 0; overflow-x: auto; overscroll-behavior-x: contain; }
.seo-table-figure .table-scroll, .mi-reader-summary .table-scroll { margin: 0; }
.table-scroll:focus-visible { outline-offset: 4px; }
.table-hint { display: none; margin: 24px 0 8px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--graphite-dim); }
.seo-table-figure .table-hint { margin-top: 0; }
.table-hint + .table-scroll { margin-top: 0; }
.table-hint.is-needed { display: block; }
.table-hint[hidden] { display: none !important; }
.guide-body table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.guide-body table[data-cols="3"] { min-width: 560px; }
.guide-body table[data-cols="4"], .guide-body table[data-cols="5"] { min-width: 680px; }
.guide-body th, .guide-body td { padding: 11px 16px 11px 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--hairline); }
.guide-body th:last-child, .guide-body td:last-child { padding-right: 0; }
.guide-body thead th { padding-top: 8px; font-family: var(--mono); font-size: 11px; font-weight: 400; letter-spacing: 0.06em; text-transform: uppercase; color: var(--graphite-dim); border-bottom-color: var(--track); vertical-align: bottom; }
.guide-body tbody th, .guide-body tfoot th { font-weight: 400; }
.guide-body .num { text-align: right; white-space: nowrap; }
.guide-body tr.total th, .guide-body tr.total td, .guide-body tfoot th, .guide-body tfoot td { font-weight: 500; border-top: 1px solid var(--graphite); }

/* ---------- Diagrams (drawn at their final frame; no animation) ---------- */
.diagram { max-width: 520px; }
.diagram svg { display: block; width: 100%; height: auto; font-family: var(--sans); }
.diagram figcaption { margin-top: 10px; }
.dg-card { fill: #f6f6f5; stroke: rgba(30, 33, 36, 0.22); stroke-width: 1.5; }
.dg-hi { fill: #dfe1e3; stroke: #1e2124; stroke-width: 1.5; }
.dg-label { font-size: 12px; fill: rgba(30, 33, 36, 0.68); font-weight: 500; }
.dg-amt { font-size: 15px; fill: #1e2124; font-weight: 500; letter-spacing: -0.01em; }
.dg-big { font-size: 18px; }
.dg-green { fill: #1e2124; }
.dg-seg-a { fill: #3d4247; }
.dg-seg-b { fill: #c4c7cb; }
.dg-seglabel { font-size: 12px; font-weight: 500; fill: #f1f1f0; }
.dg-seg-b + .dg-seglabel { fill: #1e2124; }
.dg-line { fill: none; stroke: #1e2124; stroke-width: 2; stroke-linecap: round; }
.dg-rule { stroke: rgba(30, 33, 36, 0.22); stroke-width: 1.5; }
.dg-tick circle { fill: #1e2124; }
.dg-tick path { fill: none; stroke: #f1f1f0; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

.guide-body picture img, .guide-body figure > img { display: block; width: 100%; height: auto; }
.guide-body figure:has(picture) figcaption { margin-top: 12px; }

/* ---------- Worked examples, equations and timelines ---------- */
.guide-body math { font-family: var(--serif); font-size: 1.12em; }
.guide-body math[display="block"] { font-size: 22px; text-align: left; margin-left: 0; margin-right: auto; }
.guide-body mstyle[mathcolor] { color: var(--graphite); }
.equation, .seo-equation {
  margin: 36px 0; padding: 20px clamp(18px, 2.4vw, 28px) 22px; background: var(--panel); border: 1px solid var(--hairline);
}
.equation math, .seo-equation math { margin: 14px 0; overflow-x: auto; max-width: 100%; }
.equation-heading, .eq-label, .seo-equation figcaption {
  display: flex; justify-content: space-between; gap: 16px; font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--graphite-dim);
}
.eq-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.eq-number, .equation-number { font-family: var(--mono); font-size: 12px; color: var(--graphite-dim); }
.guide-body .equation p, .guide-body .seo-equation p { margin-top: 8px; font-size: 14.5px; color: var(--graphite-dim); }
.guide-body .equation .numeric { font-family: var(--serif); font-size: 24px; line-height: 1.3; color: var(--graphite); }
.guide-body .equation .numeric strong { font-weight: 400; border-bottom: 1px solid var(--graphite); }
.guide-body .seo-equation-result strong { color: var(--graphite); }

.seo-timeline ol { list-style: none; padding-left: 0 !important; margin-top: 16px; }
.guide-body .seo-timeline li { position: relative; margin: 0; padding: 0 0 22px 28px; }
.seo-timeline li::before { content: ""; position: absolute; left: 4px; top: 10px; bottom: -10px; width: 1px; background: var(--track); }
.seo-timeline li:last-child::before { display: none; }
.seo-timeline li::after {
  content: ""; position: absolute; left: 0; top: 6px; width: 9px; height: 9px; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #fff 0 12%, #c9ccd2 34%, #6b7078 78%, #3a3e44 100%);
}
.seo-timeline li > span { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--graphite-dim); }
.seo-timeline li > strong { display: block; font-family: var(--serif); font-size: 19px; font-weight: 400; }
.guide-body .seo-timeline li > p { margin-top: 2px; color: var(--graphite-dim); font-size: 15px; }

.seo-answer, .quick, .work-context {
  max-width: 680px; margin: 28px 0; padding: 16px 0 18px 20px; border-left: 1px solid var(--graphite);
}
.quick-title, .work-context-date { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--graphite-dim); }
.guide-body .quick ol { margin-top: 8px; }
.guide-body .work-context p:not(.work-context-date) { margin-top: 8px; }

.guide-intro p:first-child { font-size: 17.5px; }

/* Settlement worksheet download */
.worksheet { margin: 40px 0; padding: clamp(20px, 3vw, 32px); background: var(--panel); border: 1px solid var(--hairline); }
.settlement-worksheet__eyebrow, .settlement-worksheet__provenance { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--graphite-dim); }
.guide-body .worksheet h2 { margin-top: 8px; font-size: clamp(24px, 2.4vw, 30px); }
.settlement-worksheet__example { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--hairline); }
.settlement-worksheet__figures { margin-top: 12px; border-bottom: 1px solid var(--hairline); }
.settlement-worksheet__figures > div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-top: 1px solid var(--hairline); font-size: 15px; }
.settlement-worksheet__figures dd { font-variant-numeric: tabular-nums; white-space: nowrap; }
.settlement-worksheet__difference { font-weight: 500; }
.settlement-worksheet__explanation { margin-top: 16px; }
.guide-body .settlement-worksheet__explanation p { font-size: 15px; }
.settlement-worksheet__actions { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px 32px; margin-top: 24px; }
.guide-body .settlement-worksheet__download { font-weight: 500; }
.settlement-worksheet__download span { font-weight: 400; color: var(--graphite-dim); }
.guide-body .settlement-worksheet__note { margin-top: 16px; font-size: 13.5px; color: var(--graphite-dim); }

/* ---------- Month-end report example ---------- */
.mi-reader-summary { padding: clamp(20px, 3vw, 32px); background: var(--panel); border: 1px solid var(--hairline); }
.guide-body .mi-reader-summary h2 { margin-top: 0; }
.mi-reader-summary .table-scroll { margin: 20px 0; }
.mi-tools { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 12px 24px; margin-top: 40px; padding: 14px 0; border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); }
.guide-body .mi-tools p { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--graphite-dim); }
.guide-body .mi-tools a { font-weight: 500; }
.mi-contents { margin-top: 32px; }
.mi-contents > p { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--graphite-dim); }
.guide-body .mi-contents ol { list-style: none; padding-left: 0; columns: 2; column-gap: 32px; }
.guide-body .mi-contents li { margin: 0; break-inside: avoid; border-top: 1px solid var(--hairline); }
.guide-body .mi-contents a { display: block; padding: 8px 0; font-size: 14.5px; text-decoration: none; color: var(--graphite-dim); }
.guide-body .mi-contents a:hover { color: var(--graphite); }
.mi-page { position: relative; margin-top: clamp(48px, 6vw, 72px); padding-top: 20px; border-top: 1px solid var(--hairline); }
.guide-body .mi-accessible-title { margin: 0 0 16px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--graphite-dim); }
.guide-body .mi-page-image { display: block; max-width: 620px; outline: 1px solid var(--hairline); transition: outline-color .3s; background: #fff; }
.guide-body .mi-page-image:hover { outline-color: var(--graphite); }
.mi-page-image img { display: block; width: 100%; height: auto; }
.mi-page-options { max-width: 620px; margin-top: 12px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 24px; }
.mi-page-text { flex: 1 1 100%; order: 2; }
.mi-page-text summary { cursor: pointer; padding: 10px 0; font-size: 14.5px; color: var(--graphite-dim); }
.mi-page-text[open] summary { color: var(--graphite); }
.mi-open-page { order: 1; font-size: 14.5px; }
.mi-text-scroll { max-height: 440px; overflow: auto; padding: 16px; background: var(--panel); border: 1px solid var(--hairline); }
.mi-text-scroll pre { font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--graphite); }

/* ---------- Closing enquiry and related pages ---------- */
.guide-enquiry, .related, .hub-using {
  position: relative; display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); column-gap: clamp(40px, 7vw, 120px);
  margin-top: clamp(72px, 8vw, 112px); padding-top: clamp(40px, 5vw, 64px); align-items: start;
}
.guide-enquiry h2, .related h2, .hub-using h2 { font-family: var(--serif); font-weight: 300; font-size: clamp(26px, 2.8vw, 38px); line-height: 1.12; letter-spacing: -0.014em; text-wrap: balance; }
.guide-enquiry-text p, .hub-using-text p { max-width: 36em; font-size: 16px; line-height: 1.65; color: var(--graphite-dim); text-wrap: pretty; }
.guide-enquiry-text p + p, .hub-using-text p + p { margin-top: 14px; }
.guide-enquiry .race { margin-top: 24px; text-align: left; }
.guide-enquiry .caption { margin-top: 10px; font-size: 13px; }
.related-list { list-style: none; border-bottom: 1px solid var(--hairline); }
.related-list li { padding: 18px 0 20px; border-top: 1px solid var(--hairline); }
.related-list a { display: inline-flex; flex-wrap: wrap; align-items: baseline; column-gap: 12px; font-family: var(--serif); font-size: 20px; line-height: 1.3; color: var(--graphite); text-decoration: none; }
.related-list a:hover .related-name { text-decoration: underline; text-decoration-color: var(--track); text-underline-offset: 4px; }
.related-where { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--graphite-dim); }
.related-list p { margin-top: 6px; max-width: 40em; font-size: 14.5px; line-height: 1.6; color: var(--graphite-dim); }

/* ---------- Hub ---------- */
.subjects { margin-top: 8px; }
.subject {
  position: relative; display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); column-gap: clamp(40px, 7vw, 120px);
  padding-top: clamp(36px, 4.4vw, 56px); align-items: start;
}
.subject + .subject { margin-top: clamp(56px, 6vw, 88px); }
.subject h2 { font-family: var(--serif); font-weight: 300; font-size: clamp(24px, 2.4vw, 32px); line-height: 1.15; letter-spacing: -0.012em; max-width: 11em; text-wrap: balance; }
.subject-list { list-style: none; border-bottom: 1px solid var(--hairline); }
.subject-list li { padding: 20px 0 22px; border-top: 1px solid var(--hairline); scroll-margin-top: 24px; }
.subject-list li:first-child { border-top: 0; padding-top: 2px; }
.subject-list a { font-family: var(--serif); font-size: clamp(20px, 1.8vw, 23px); line-height: 1.25; color: var(--graphite); text-decoration: none; text-wrap: balance; }
.subject-list a:hover { text-decoration: underline; text-decoration-color: var(--track); text-underline-offset: 4px; }
.subject-list li:target a { text-decoration: underline; text-decoration-color: var(--graphite); text-underline-offset: 4px; }
.subject-list p { margin-top: 8px; max-width: 40em; font-size: 15px; line-height: 1.6; color: var(--graphite-dim); text-wrap: pretty; }

.guide-footer { margin-top: clamp(72px, 8vw, 120px); }

/* ---------- Narrow screens ---------- */
@media (max-width: 959px) {
  .guide-layout.has-toc { grid-template-columns: minmax(0, 1fr); }
  .toc { position: static; margin-bottom: 40px; }
  .guide-enquiry, .related, .hub-using, .subject { grid-template-columns: minmax(0, 1fr); row-gap: 20px; }
}

@media (max-width: 759px) {
  .nav-guides { grid-column: 3; }
  .guide-nav .nav-contact { grid-column: 4; }
  .guide-head { padding-top: 28px; }
  .guide-head h1 { font-size: clamp(30px, 8.6vw, 40px); }
  .guide-head .standfirst { font-size: 16.5px; }
  .guide-body { font-size: 16px; }
  .guide-body table { font-size: 14px; }
  .table-hint { display: block; }
  .table-scroll { margin-right: calc(-1 * var(--pad-x)); padding-right: var(--pad-x); }
  .guide-body table[data-cols="3"] th:first-child, .guide-body table[data-cols="4"] th:first-child, .guide-body table[data-cols="5"] th:first-child {
    position: sticky; left: 0; z-index: 1; background: var(--studio); box-shadow: inset -1px 0 0 var(--hairline); padding-right: 12px;
    width: 9.5rem; min-width: 8rem; max-width: 40vw;
  }
  .guide-body th:first-child + td, .guide-body th:first-child + th { padding-left: 12px; }
  .guide-body .mi-reader-summary table th:first-child { background: var(--panel); }
  .guide-body .mi-contents ol { columns: 1; }
  .equation, .seo-equation, .worksheet, .mi-reader-summary { margin-left: calc(-1 * var(--pad-x) + 8px); margin-right: calc(-1 * var(--pad-x) + 8px); }
  .subject-list li:first-child { padding-top: 18px; border-top: 1px solid var(--hairline); }
}
