/* Shared stylesheet for the generated /learn pages (build.cjs copies it to public/assets/learn.css).
   The tokens, header, buttons and footer repeat index.html's inline styles (the 2026-10-10 redesign);
   change both together. Everything under "Article" is specific to the guides.
   One fixed look on every device: no dark-mode media queries or theme switching (Will, 2026-10-10). */

:root {
  color-scheme: only light;
  --deep: #0F2038;        /* header, dark panels */
  --deepest: #0A1729;     /* footer */
  --navy: #16304E;        /* Peak Navy: brand colour and body ink */
  --paper: #FFFFFF;
  --canvas: #F4F6F8;
  --wash: #E7ECF1;
  --rule: #D8DEE3;
  --ink-muted: #5A6B76;   /* Slate Deep */
  --blue: #0B7A82;        /* Peak Teal, on white */
  --tint: #22C1C3;        /* Peak Teal tint, on navy */
  --on-dark: #FFFFFF;
  --on-dark-muted: #C3CEDA;
  --display: 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --gutter: clamp(16px, 4vw, 48px);
  --max: 1180px;

  /* Code-drawn figures (inline SVG) are coloured through these. */
  --fig-bg: #FFFFFF; --fig-panel: #F4F6F8; --fig-ink: #16304E; --fig-muted: #5A6B76;
  --fig-line: #D8DEE3; --fig-stroke: #73838D; --fig-accent: #0B7A82; --fig-accent-wash: #E0F3F3; --fig-warn: #B6452D;
  --fig-h1: #EEF2F5; --fig-h2: #F7EDE6; --fig-h3: #F2D6CB; --fig-h4: #E8B5A5; --fig-h5: #DB8E7A;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; }
body { margin: 0; background: var(--paper); color: var(--navy); font: 400 17px/1.6 var(--display); -webkit-font-smoothing: antialiased; }
img { max-width: 100%; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--tint); outline-offset: 3px; }
.wrap { max-width: var(--max); margin: 0 auto; padding-inline: var(--gutter); }
.eyebrow { font: 500 0.8rem/1.4 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--blue); margin: 0; }
.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { text-decoration: underline; text-underline-offset: 3px; }
.sr-only, .visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* --- Buttons (as index.html) ------------------------------------------------- */
.btn { display: inline-flex; align-items: center; gap: 10px; font: 600 1.05rem/1 var(--display); padding: 18px 28px; border-radius: 4px; text-decoration: none; border: 2px solid transparent; cursor: pointer; transition: transform .15s ease, background-color .15s ease, border-color .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .7; cursor: default; transform: none; }
.btn-primary { background: var(--tint); color: var(--deep); }
.btn-primary:hover { background: #8BB6EA; }

/* --- Header (as index.html) -------------------------------------------------- */
.site-header { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--deep); color: var(--on-dark); border-bottom: 1px solid rgba(255,255,255,.08); }
.header-row { display: flex; align-items: center; gap: 32px; min-height: 72px; }
.brand { display: flex; align-items: center; text-decoration: none; margin-right: auto; }
.brand img { display: block; height: 40px; width: auto; }
.site-nav { display: flex; gap: 28px; }
.site-nav a { font: 500 1rem/1 var(--display); text-decoration: none; color: var(--on-dark); opacity: .9; padding-block: 8px; }
.site-nav a:hover, .site-nav a[aria-current] { opacity: 1; box-shadow: inset 0 -2px 0 var(--tint); }
.header-cta { padding: 11px 18px; font-size: .95rem; }

/* --- Footer (as index.html) -------------------------------------------------- */
.site-footer { background: var(--deepest); color: var(--on-dark-muted); padding-block: 56px 32px; font-size: .95rem; }
.footer-cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 32px 48px; }
.footer-cols h2 { font: 500 .75rem/1.3 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--tint); margin: 0 0 14px; }
.footer-cols p { margin: 0 0 12px; max-width: 52ch; }
.footer-cols ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.footer-cols a { color: var(--on-dark); text-decoration: none; }
.footer-cols a:hover { text-decoration: underline; text-underline-offset: 4px; }
.footer-base a, .signup-consent a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.footer-logo { display: block; height: 34px; width: auto; opacity: .9; margin-bottom: 18px; }
.footer-base { margin-top: 44px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.1); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 32px; font: 400 .74rem/1.6 var(--mono); color: #8696A8; }

/* --- Sign-up box: a dark panel like the home page's sign-up band -------------- */
.signup-box { background: var(--deep); color: var(--on-dark); border-radius: 6px; padding: clamp(24px, 4vw, 40px); margin: 2.6em 0; }
.signup-box .eyebrow { color: var(--tint); }
.signup-box .signup-line { font-size: 1.15rem; font-weight: 500; line-height: 1.45; margin: 10px 0 18px; }
.signup-form { display: flex; gap: 10px; flex-wrap: wrap; }
.signup-form input[type="email"] { flex: 1 1 240px; min-width: 0; font: 400 1.05rem/1 var(--display); color: var(--navy); background: var(--paper); border: 2px solid var(--paper); border-radius: 4px; padding: 16px 18px; }
.signup-form input[type="email"]:focus { outline: none; border-color: var(--tint); }
.signup-consent { margin: 14px 0 0; font-size: .85rem; line-height: 1.55; color: var(--on-dark-muted); }
.signup-status { margin: 10px 0 0; min-height: 1.5em; font: 500 .9rem/1.5 var(--mono); color: var(--tint); }
.signup-status[data-state="err"] { color: #FF8A7A; }

/* --- Article -------------------------------------------------------------- */
.article { max-width: 720px; margin: 0 auto; padding-block: clamp(36px, 6vw, 72px) clamp(56px, 8vw, 104px); }
.article h1 {
  font-size: clamp(2rem, 4.2vw, 2.9rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 14px 0 12px;
  text-wrap: balance;
}
.article .meta { font: 400 0.82rem/1.5 var(--mono); color: var(--ink-muted); margin: 0 0 32px; }
.prose { font-size: 1.06rem; line-height: 1.72; overflow-wrap: break-word; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.1em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin-bottom: 0.45em; }
.prose h2 {
  font-size: clamp(1.4rem, 2.6vw, 1.75rem);
  font-weight: 700;
  line-height: 1.25;
  margin: 2.2em 0 0.6em;
  padding-top: 1.2em;
  border-top: 1px solid var(--rule);
  text-wrap: balance;
}
.prose h3 { font-size: 1.2rem; font-weight: 700; margin: 1.8em 0 0.5em; }
.prose b, .prose strong { font-weight: 600; }
.prose sub, .prose sup { line-height: 0; }
.prose blockquote { margin: 1.4em 0; padding: 4px 0 4px 20px; border-left: 3px solid var(--rule); color: var(--ink-muted); font-style: italic; }
.prose .formula { margin: 1.4em 0; padding: 14px 18px; background: var(--canvas); border: 1px solid var(--rule); border-radius: 6px; text-align: center; font-size: 1.1rem; overflow-x: auto; }

.toc { background: var(--canvas); border: 1px solid var(--rule); border-radius: 6px; padding: 18px 22px; margin: 2em 0; }
.toc ol { margin: 10px 0 0; padding-left: 1.3em; font-size: 0.98rem; line-height: 1.6; }
.toc li { margin: 0.15em 0; }
.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; }

.video { margin: 1.8em 0; }
.video iframe { display: block; border: 0; border-radius: 6px; background: var(--canvas); }
.video-short iframe { width: min(100%, 340px); aspect-ratio: 9 / 16; margin: 0 auto; }
.video-long iframe { width: 100%; aspect-ratio: 16 / 9; }

.figure { margin: 1.8em 0; }
.figure img { display: block; max-width: 100%; height: auto; border: 1px solid var(--rule); border-radius: 4px; background: #FFFFFF; }
.figure figcaption { font-size: 0.9rem; color: var(--ink-muted); margin-top: 8px; }

/* Code-drawn figures: inline SVG (build.cjs inlines <!-- SVG file.svg -->), coloured through the
   --fig-* tokens. They shrink to fit the column (no sideways scroll, Will 2026-10-09); the page
   script makes each one open full-screen in .lightbox when selected.
   .figure-wide breaks out of the text column for wide tables. */
.figure .fig { background: var(--fig-bg); border: 1px solid var(--rule); border-radius: 4px; padding: 10px; }
.figure .fig svg { display: block; width: 100%; height: auto; }
.figure .fig[role="button"] { cursor: zoom-in; transition: border-color 0.15s ease; }
.figure .fig[role="button"]:hover { border-color: var(--blue); }
.figure .fig[role="button"]:focus-visible { outline: 3px solid var(--tint); outline-offset: 3px; }
.fig[role="button"] + figcaption::before { content: 'Click to enlarge. '; font-weight: 500; color: var(--blue); }
@media (hover: none) { .fig[role="button"] + figcaption::before { content: 'Tap to enlarge. '; } }
.figure-wide { width: min(1080px, calc(100vw - 32px)); margin-left: calc(50% - min(540px, calc(50vw - 16px))); }
.figure-wide figcaption { max-width: 720px; margin-left: auto; margin-right: auto; }

/* The enlarged view. The page script sizes the figure to fill .lightbox-body, never below a
   readable size; on an upright phone that overflows and .lightbox-body pans (Will, 2026-10-09:
   "people can rotate their phone if they want to"). Always upright. margin:auto centres a figure
   smaller than the space without clipping the start of one that is larger. */
.lightbox {
  width: min(96vw, 1600px); max-width: none; height: 94vh; height: 94dvh; max-height: none;
  padding: 0; border: 1px solid var(--rule); border-radius: 6px;
  background: var(--fig-bg); color: var(--navy);
}
.lightbox[open] { display: flex; flex-direction: column; }
.lightbox::backdrop { background: rgba(10, 23, 41, 0.85); }
.lightbox-bar { display: flex; justify-content: flex-end; padding: 10px 12px 0; }
.lightbox-close {
  font: 500 0.82rem var(--mono); color: var(--navy);
  background: transparent; border: 1px solid var(--rule); border-radius: 4px; padding: 7px 14px; cursor: pointer;
}
.lightbox-close:hover { border-color: var(--blue); color: var(--blue); }
.lightbox-body { flex: 1; min-height: 0; display: flex; overflow: auto; margin: 8px 12px 12px; }
@media (max-width: 700px), (max-height: 500px) { .lightbox-body { margin: 6px 4px; } }
.lightbox-body svg { display: block; flex: none; margin: auto; }
.lightbox-caption { font-size: 0.9rem; color: var(--ink-muted); margin: 0 auto 16px; padding: 0 16px; max-width: 820px; }
@media (max-height: 500px) { .lightbox-caption { display: none; } }
@media (max-width: 700px), (max-height: 500px) { .lightbox { width: 100vw; height: 100vh; height: 100dvh; border: 0; border-radius: 0; } }

.related ul { list-style: none; padding: 0; }
.related li { margin-bottom: 0.4em; }

/* The sources list is reference material, so it is set smaller. */
.prose h2#sources + ul { font-size: 0.94rem; line-height: 1.6; }

/* --- Guide index ------------------------------------------------------------ */
.lede { font-size: clamp(1.08rem, 1.7vw, 1.25rem); color: var(--ink-muted); margin: 0 0 36px; }
.guide-list { list-style: none; padding: 0; margin: 0; border-top: 2px solid var(--navy); }
.guide-list li { border-bottom: 1px solid var(--rule); padding: 24px 0; }
.guide-list a { font-size: 1.3rem; font-weight: 700; line-height: 1.25; text-decoration: none; color: var(--navy); }
.guide-list a:hover { color: var(--blue); }
.guide-list p { margin: 8px 0 0; color: var(--ink-muted); }
.guide-list .date { font: 500 .72rem/1.3 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--blue); margin-top: 10px; }

/* --- News articles and the /news/ index ----------------------------------------- */
.news-tags { font: 500 .74rem/1.3 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-muted); margin: 10px 0 0; }
.news-article .meta a { color: inherit; }
.news-hero { margin: 0 0 2em; }
.news-hero img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: var(--canvas); }
.news-hero figcaption { font: 400 .68rem/1.4 var(--mono); color: var(--ink-muted); margin-top: 6px; opacity: .8; }
.draft-flag { display: inline-block; margin: 14px 0 0; padding: 6px 12px; border-radius: 4px; background: #FBE9E4; color: var(--fig-warn); font: 600 .8rem/1.3 var(--mono); }
.news-index-list { list-style: none; padding: 0; margin: 0; border-top: 2px solid var(--navy); }
.news-index-list li { border-bottom: 1px solid var(--rule); }
.news-index-list a { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; padding: 24px 0; text-decoration: none; color: var(--navy); }
.news-index-list img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: var(--canvas); }
.news-index-text { display: grid; gap: 8px; }
.news-index-text .news-tags { margin: 0; }
.news-index-title { font-size: 1.3rem; font-weight: 700; line-height: 1.25; }
.news-index-list a:hover .news-index-title { color: var(--blue); }
.news-index-teaser { color: var(--ink-muted); }
.news-index-text .date { font: 500 .72rem/1.3 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--blue); }

/* --- Tablet and phone (as index.html) ----------------------------------------- */
@media (max-width: 900px) {
  .footer-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .footer-cols > div:first-child { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  html { scroll-padding-top: 128px; }
  body { font-size: 16px; }
  .header-row { flex-wrap: wrap; gap: 0 16px; min-height: 0; padding-block: 12px 0; }
  .brand img { height: 34px; }
  .site-nav { order: 3; width: 100%; gap: 0; justify-content: space-between; border-top: 1px solid rgba(255,255,255,.1); margin-top: 12px; }
  .site-nav a { padding-block: 12px; flex: 1; text-align: center; font-size: .95rem; }
  .signup-form .btn { width: 100%; justify-content: center; }
  .footer-cols { grid-template-columns: minmax(0, 1fr); }
  .news-index-list a { grid-template-columns: minmax(0, 1fr); gap: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .figure .fig[role="button"] { transition: none; }
}
