/* I Wish I Knew - site stylesheet. One theme throughout (plan D5).
   Ported from prototype/styles.css.
   ------------------------------------------------------------------ */

/* Fonts: self-hosted, Latin subset only, from the @fontsource packages (jsDelivr), all under
   the SIL Open Font License (public/fonts/LICENSES.txt). No third-party font request, so
   nothing leaves the site before the visitor has chosen on the cookie banner. The fallback
   stacks in --f-* below show until a file arrives (font-display: swap). */
@font-face { font-family: 'Fraunces'; font-weight: 700; font-style: normal; font-display: swap; src: url('/fonts/fraunces-700.woff2') format('woff2'); }
@font-face { font-family: 'Fraunces'; font-weight: 800; font-style: normal; font-display: swap; src: url('/fonts/fraunces-800.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 400; font-style: normal; font-display: swap; src: url('/fonts/inter-400.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-style: normal; font-display: swap; src: url('/fonts/inter-500.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-style: normal; font-display: swap; src: url('/fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 700; font-style: normal; font-display: swap; src: url('/fonts/inter-700.woff2') format('woff2'); }
@font-face { font-family: 'Source Serif 4'; font-weight: 400; font-style: normal; font-display: swap; src: url('/fonts/source-serif-4-400.woff2') format('woff2'); }
@font-face { font-family: 'Source Serif 4'; font-weight: 400; font-style: italic; font-display: swap; src: url('/fonts/source-serif-4-400-italic.woff2') format('woff2'); }
@font-face { font-family: 'Source Serif 4'; font-weight: 600; font-style: normal; font-display: swap; src: url('/fonts/source-serif-4-600.woff2') format('woff2'); }
@font-face { font-family: 'Oswald'; font-weight: 600; font-style: normal; font-display: swap; src: url('/fonts/oswald-600.woff2') format('woff2'); }
@font-face { font-family: 'Caveat'; font-weight: 600; font-style: normal; font-display: swap; src: url('/fonts/caveat-600.woff2') format('woff2'); }

:root {
  /* Core palette */
  --ink: #14213D;          /* navy: text, outlines */
  --ink-2: #3D4863;        /* secondary text */
  --ink-3: #6B7389;        /* muted (large text and meta only) */
  --paper: #FBF8F2;        /* warm off-white ground */
  --card: #FFFFFF;
  --line: #E7E1D5;
  --sun: #F5C542;          /* signature yellow */
  --sun-soft: #FDF1C7;
  --night: #16213A;        /* dark panels */

  /* Subject palette: tint (background) + deep (text, AA on tint and white) */
  --world: #DCEBF7;   --world-d: #1F5F8B;
  --science: #F6EEDC; --science-d: #8A5A12;
  --how: #E3EDDF;     --how-d: #3C6B35;
  --everyday: #F8E4D6;--everyday-d: #A2461C;
  --finance: #F7DDE2; --finance-d: #A12F4F;
  --tech: #DEE5F7;    --tech-d: #3149A0;
  --history: #F1E7D8; --history-d: #7A5530;
  --body: #ECE2F3;    --body-d: #6B3C8F;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20,33,61,.06), 0 6px 20px rgba(20,33,61,.06);
  --shadow-lg: 0 2px 4px rgba(20,33,61,.06), 0 18px 40px rgba(20,33,61,.10);

  --f-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --f-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-read: 'Source Serif 4', Georgia, serif;
  --f-mark: 'Oswald', 'Arial Narrow', Impact, sans-serif;
  --f-hand: 'Caveat', 'Comic Sans MS', cursive;

  --wrap: 1180px;
  --gutter: clamp(16px, 4vw, 40px);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 16px/1.6 var(--f-ui); -webkit-font-smoothing: antialiased;
  /* A short page still ends with the footer at the bottom of the window (no empty strip under it). */
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
}
main { flex: 1 0 auto; }
img, svg { max-width: 100%; }
img { height: auto; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding-inline: var(--gutter); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--sun); padding: 8px 14px; border-radius: 8px; z-index: 100; font-weight: 600; }
.skip:focus { left: 8px; }
.icon { flex: none; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(251,248,242,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: 28px; height: 68px; position: relative; }
.logo { font: 600 28px/1 var(--f-mark); letter-spacing: .5px; text-decoration: none; text-transform: uppercase; white-space: nowrap; }
.logo span { background: linear-gradient(transparent 62%, var(--sun) 62%); padding: 0 2px; }
.nav { display: flex; gap: 4px; }
.nav a { text-decoration: none; font-weight: 500; padding: 8px 12px; border-radius: 8px; color: var(--ink-2); }
.nav a:hover { background: #F1ECE1; color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -3px 0 var(--sun); border-radius: 0; }
.nav .nav-text { padding: 8px 12px; font-weight: 500; color: var(--ink-3); }   /* a Links entry of type "text": a label, not a link */
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; border: 0; background: transparent; cursor: pointer; color: var(--ink); text-decoration: none; }
.icon-btn:hover { background: #F1ECE1; }
.menu-toggle { display: none; }
@media (max-width: 760px) {
  .nav { display: none; position: absolute; top: 68px; left: 0; right: 0; flex-direction: column; background: var(--paper); border-bottom: 1px solid var(--line); padding: 8px var(--gutter) 16px; }
  .nav.open { display: flex; }
  .nav a { padding: 14px 4px; font-size: 18px; }
  .menu-toggle { display: grid; }
  .btn.surprise .lbl { display: none; }
  .btn.surprise { padding: 11px; }
  .logo { font-size: 23px; }
}

/* ---------- Buttons and chips ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer;
  font: 600 15px/1 var(--f-ui); padding: 12px 18px; border-radius: 999px; text-decoration: none;
  background: var(--sun); color: var(--ink); transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(245,197,66,.45); }
.btn.ghost { background: transparent; border: 1.5px solid var(--ink); }
.btn.ghost:hover { box-shadow: none; background: #fff; }
.btn.dark { background: var(--ink); color: #fff; }
.btn.dark:hover { box-shadow: 0 6px 16px rgba(20,33,61,.3); }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-decoration: none; }
.linklike:hover { text-decoration: underline; }

/* ---------- Common headings ---------- */
.eyebrow { font: 700 12px/1 var(--f-ui); letter-spacing: 1.2px; text-transform: uppercase; }
.page-head { padding-block: 48px 24px; }
.page-head h1 { font: 800 clamp(36px, 5vw, 56px)/1.05 var(--f-display); margin: 0 0 12px; letter-spacing: -1px; }
.page-head .lede { font: 400 20px/1.5 var(--f-read); color: var(--ink-2); margin: 0; max-width: 40ch; }
.page-head.maintenance { padding-block: 96px; }
.page-head.maintenance .eyebrow { margin: 0 0 16px; color: var(--ink-2); }

/* ---------- Breadcrumbs ---------- */
.crumbs { font-size: 13.5px; color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 28px; padding: 0; list-style: none; }
.crumbs li + li::before { content: '/'; margin-right: 8px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs [aria-current] { color: var(--ink-2); }

/* ---------- Article header ---------- */
.a-head { padding-block: 28px 56px; background: radial-gradient(800px 380px at 80% 40%, #FFF6D6, transparent 70%); }
.a-head .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: center; }
.a-head .grid2.no-hero { grid-template-columns: 1fr; }
.a-head .eyebrow { color: var(--deep, var(--how-d)); }
/* Article title. Size: 5% of the window width, between 34px and 64px. A title longer than 28
   characters gets the class "long" (templates/sections.php) and is smaller again. */
.a-head h1 {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(34px, 5vw, 64px);
  line-height: 1.05;
  letter-spacing: -1px;
  text-wrap: balance;
  overflow-wrap: anywhere;
  margin: 12px 0 20px;
}
.a-head h1.long { font-size: clamp(28px, 3.6vw, 44px); }
.a-head .intro { font: italic 400 clamp(19px, 2vw, 23px)/1.45 var(--f-read); color: var(--ink-2); max-width: 30ch; margin: 0 0 26px; }
.a-meta { display: flex; flex-wrap: wrap; gap: 10px 18px; font-size: 13.5px; color: var(--ink-2); align-items: center; }
.a-meta span { display: inline-flex; gap: 6px; align-items: center; }
.a-hero img { width: 100%; border-radius: var(--radius); }
@media (max-width: 900px) { .a-head .grid2 { grid-template-columns: 1fr; } }

/* ---------- Subject page header: coloured band, picture left, article count right ---------- */
.a-head.a-head--subject, .a-head.a-head--tone { background: var(--tint, var(--sun-soft)); padding-block: 28px 44px; }
.a-head--subject .grid2 { grid-template-columns: auto minmax(0, 1fr) auto; gap: clamp(20px, 4vw, 40px); }
.a-head--subject .grid2.no-hero { grid-template-columns: minmax(0, 1fr) auto; }
.a-head--subject .a-hero { order: -1; }
.a-head--subject .a-hero-icon img { width: clamp(100px, 12vw, 150px); }
.a-head--subject .intro { font: 400 19px/1.55 var(--f-ui); font-style: normal; max-width: 52ch; margin: 0; }
.s-count { text-align: right; font: 400 14px/1.3 var(--f-ui); color: var(--ink-2); }
.s-count b { display: block; font: 800 44px/1 var(--f-display); color: var(--ink); }
@media (max-width: 760px) {
  .a-head--subject .grid2, .a-head--subject .grid2.no-hero { grid-template-columns: 1fr; gap: 16px; }
  .a-head--subject .a-hero-icon img { margin-inline: 0; }
  .s-count { text-align: left; }
}

/* A "child-pages" or "all-articles" section runs the full width of the page instead of the 720px column
   (only when there is no contents list beside it). */
.a-layout.no-toc { container-type: inline-size; }
.a-layout.no-toc .block--child-pages, .a-layout.no-toc .block--all-articles { width: 100cqw; margin-left: 50%; transform: translateX(-50%); }
/* The Explore page (all-articles) is three cards wide on large screens. */
@media (min-width: 900px) { .block--all-articles .card-grid { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Article layout: contents list + reading column ---------- */
.a-layout { display: grid; grid-template-columns: 220px minmax(0, 720px); gap: 56px; justify-content: center; padding-block: 48px 24px; }
.a-layout.no-toc { grid-template-columns: minmax(0, 720px); }
.toc { position: sticky; top: 92px; align-self: start; font-size: 14px; }
.toc h2 { font: 700 12px/1 var(--f-ui); letter-spacing: 1.2px; text-transform: uppercase; color: var(--ink-3); margin: 0 0 14px; }
.toc ol { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.toc a { display: block; padding: 7px 0 7px 14px; margin-left: -2px; border-left: 2px solid transparent; text-decoration: none; color: var(--ink-2); }
.toc a:hover { color: var(--ink); }
.toc a.on { border-color: var(--ink); color: var(--ink); font-weight: 600; }
@media (max-width: 1000px) { .a-layout { grid-template-columns: minmax(0, 1fr); } .toc { display: none; } }

/* ---------- Reading typography (the editor's own text inside a block) ---------- */
.prose { font: 400 19px/1.7 var(--f-read); color: #1E2A45; }
.prose p { margin: 0 0 1.1em; }
.prose h2 { font: 700 clamp(28px, 3.2vw, 36px)/1.15 var(--f-display); margin: 0 0 18px; letter-spacing: -.4px; scroll-margin-top: 90px; color: var(--ink); }
.prose h2::before { content: ''; display: block; width: 40px; height: 5px; background: var(--sun); border-radius: 3px; margin-bottom: 14px; }
.prose h3 { font: 700 21px/1.3 var(--f-ui); margin: 32px 0 10px; color: var(--ink); }
.prose strong { color: var(--ink); }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.1em; }
.prose img { border-radius: var(--radius-sm); margin-block: 8px; }
.prose a { text-underline-offset: 3px; }
.prose a:not([class]):hover { background: var(--sun-soft); }  /* plain text links only: cards, chips and buttons have their own hover */

/* ---------- Blocks (one per section; the CSS class says which) ---------- */
.block { margin: 56px 0; }
.block:first-child { margin-top: 0; }

/* Short version: the dark panel at the top */
.block--short-version { background: var(--night); color: #E6E9F0; border-radius: 20px; padding: clamp(24px, 4vw, 40px); font-family: var(--f-ui); }
.block--short-version h2 { color: #fff; font-size: 28px; margin-top: 0; }
.block--short-version h2::before { margin-bottom: 12px; }
.block--short-version p { font-size: 17.5px; line-height: 1.6; margin: 0; color: #E6E9F0; }
.block--short-version strong { color: #fff; }

/* The bit I didn't understand: all paragraphs, the last is the punchline.
   Editor types: a heading-less section of 2 to 3 short paragraphs. */
.block--bit { position: relative; background: #FFFBEA; border: 2px solid var(--ink); border-radius: 18px; padding: 36px 28px 24px; box-shadow: 6px 6px 0 var(--sun); margin-top: 64px; }
.block--bit::before { content: "The bit I didn't understand"; position: absolute; top: -20px; left: 20px; background: var(--sun); border: 2px solid var(--ink); border-radius: 999px; padding: 4px 16px 6px; font: 600 24px/1 var(--f-hand); transform: rotate(-2deg); }
.block--bit p { margin: 8px 0 0; }
.block--bit p:last-child { font: 700 26px/1.2 var(--f-display); color: var(--ink); margin-top: 14px; }

/* Comparison: key ideas side by side (renderer: sections/comparison.php) */
.ideas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; font-family: var(--f-ui); margin-top: 20px; }
.ideas-2 { grid-template-columns: repeat(2, 1fr); }
.ideas-3 { grid-template-columns: repeat(3, 1fr); }
.idea { background: #fff; border-radius: 16px; padding: 18px 14px; text-align: center; border: 1px solid var(--line); }
.idea h3 { margin: 0; font: 700 17px/1.2 var(--f-ui); }
.idea .unit { font-size: 13px; color: var(--ink-2); }
.idea-img img { width: 76px; height: 76px; object-fit: contain; margin: 10px auto; display: block; border-radius: 0; }
.idea .nick { display: inline-block; font: 700 14px/1.25 var(--f-ui); padding: 6px 12px; border-radius: 14px; margin: 8px 0; background: var(--sun-soft); }
.idea:nth-child(1) .nick { background: var(--tech); }
.idea:nth-child(2) .nick { background: var(--world); }
.idea:nth-child(3) .nick { background: var(--everyday); }
.idea p { font-size: 13.5px; line-height: 1.45; color: var(--ink-2); margin: 0; }
@media (max-width: 900px) { .ideas, .ideas-3, .ideas-4 { grid-template-columns: repeat(2, 1fr); } }

/* Fact: first paragraph is the big statement ("40%"), the rest is the explanation */
.block--fact { font-family: var(--f-ui); background: var(--sun-soft); border-radius: 18px; padding: 24px 28px; }
.block--fact::before { content: 'Did you know?'; display: block; font: 700 12px/1 var(--f-ui); letter-spacing: 1.2px; text-transform: uppercase; color: var(--ink-2); margin-bottom: 10px; }
.block--fact p { margin: 0 0 .5em; font-size: 17px; line-height: 1.55; }
.block--fact p:first-of-type { font: 800 clamp(34px, 5vw, 52px)/1.05 var(--f-display); letter-spacing: -1px; color: var(--ink); }

/* Myth: first paragraph is the myth, second the reality */
.block--myth { display: grid; grid-template-columns: 1fr 1fr; border-radius: 18px; overflow: hidden; border: 1.5px solid var(--ink); font-family: var(--f-ui); }
.block--myth p { margin: 0; padding: 22px; font-size: 16.5px; line-height: 1.55; }
.block--myth p::before { display: block; font: 700 12px/1 var(--f-ui); letter-spacing: 1.2px; text-transform: uppercase; margin-bottom: 10px; }
.block--myth p:nth-of-type(1) { background: #FBE3E0; font: 700 20px/1.3 var(--f-display); }
.block--myth p:nth-of-type(1)::before { content: 'The myth'; font-family: var(--f-ui); }
.block--myth p:nth-of-type(2) { background: #E3EDDF; }
.block--myth p:nth-of-type(2)::before { content: 'The reality'; }
@media (max-width: 640px) { .block--myth { grid-template-columns: 1fr; } }

/* Definition: first paragraph is the term (bold, optional pronunciation in italics), then the meaning */
.block--definition { border-left: 5px solid var(--sun); padding: 6px 0 6px 20px; font-family: var(--f-ui); }
.block--definition p { margin: 0; font-size: 17px; line-height: 1.5; }
.block--definition p:first-of-type { font: 700 30px/1.1 var(--f-display); margin-bottom: 6px; }
.block--definition p:first-of-type em { font: italic 400 14px/1 var(--f-ui); color: var(--ink-2); margin-left: 8px; }

/* Callout: any highlighted note */
.block--callout { background: #fff; border: 1.5px solid var(--ink); border-radius: 14px; padding: 18px 22px; font-family: var(--f-ui); }
.block--callout > :last-child { margin-bottom: 0; }

/* Image + text: images float beside the text; a blockquote is the "slightly more complicated" aside */
.block--image-text::after { content: ''; display: block; clear: both; }
.block--image-text img { float: left; width: min(46%, 320px); margin: 4px 24px 12px 0; }
.block--image-text blockquote { clear: both; margin: 20px 0 0; background: var(--sun-soft); border-left: 5px solid var(--sun); border-radius: 0 12px 12px 0; padding: 14px 18px; font: 400 16px/1.55 var(--f-ui); }
.block--image-text blockquote p { margin: 0; }
@media (max-width: 560px) { .block--image-text img { float: none; width: 100%; margin: 0 0 12px; } }

/* Technical detail: collapsible deeper explanation (renderer: sections/technical-detail.php) */
.tech { border: 1.5px solid var(--line); border-radius: 14px; background: #fff; font-family: var(--f-ui); }
.tech summary { cursor: pointer; padding: 16px 20px; font: 600 16px/1.3 var(--f-ui); list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.tech summary::-webkit-details-marker { display: none; }
.tech summary::after { content: '+'; font: 700 22px/1 var(--f-ui); }
.tech[open] summary::after { content: '\2212'; }
.tech-body { padding: 0 20px 8px; font: 400 17px/1.65 var(--f-read); }

/* Key takeaways: heading and a list */
.block--takeaways { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 24px 28px; font-family: var(--f-ui); }
.block--takeaways h2 { font-size: 26px; margin-top: 0; }
.block--takeaways ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.block--takeaways li { position: relative; padding-left: 32px; font-size: 17px; line-height: 1.5; }
.block--takeaways li::before { content: ''; position: absolute; left: 0; top: .15em; width: 20px; height: 20px; border-radius: 50%; background: var(--sun) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2314213D' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12 4 4 8-8'/%3E%3C/svg%3E") center / 14px no-repeat; }

/* Now you know: a heading, then each line on its own; <strong> is the highlighted word */
.block--now-you-know { background: var(--night); color: #E6E9F0; border-radius: 22px; padding: clamp(28px, 5vw, 56px); font-family: var(--f-display); }
.block--now-you-know h2 { color: #fff; font-size: clamp(34px, 5vw, 48px); margin-top: 0; }
.block--now-you-know p { font: 500 clamp(21px, 2.6vw, 28px)/1.3 var(--f-display); margin: 0 0 .7em; color: #E6E9F0; }
.block--now-you-know strong { color: var(--sun); font-weight: 700; }

/* Scale: bars (renderer: sections/scale.php) */
.scale { font-family: var(--f-ui); background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 20px 24px; margin-top: 16px; }
.srow { display: grid; grid-template-columns: 140px 1fr 90px; gap: 12px; align-items: center; margin: 10px 0; font-size: 14.5px; }
.srow .bar { height: 22px; background: var(--paper); border-radius: 6px; overflow: hidden; }
.srow .bar i { display: block; height: 100%; background: var(--sun); border-right: 2px solid var(--ink); border-radius: 6px; }
.srow b { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .srow { grid-template-columns: 96px 1fr 70px; font-size: 13px; } }

/* Timeline: events along a line, scrolls sideways on a phone (renderer: sections/timeline.php) */
.timeline-scroll { overflow-x: auto; padding-bottom: 8px; margin-top: 16px; }
.timeline { list-style: none; margin: 0; padding: 16px 0 0; display: flex; gap: 16px; width: max-content; min-width: 100%; border-top: 3px solid var(--ink); font-family: var(--f-ui); }
.timeline li { position: relative; flex: 0 0 200px; padding-top: 16px; }
.timeline li::before { content: ''; position: absolute; top: -26px; left: 0; width: 16px; height: 16px; border-radius: 50%; background: var(--sun); border: 3px solid var(--ink); }
.timeline b { display: block; font: 700 20px/1.1 var(--f-display); margin-bottom: 6px; }
.timeline span { font-size: 14.5px; line-height: 1.45; color: var(--ink-2); }

/* "Last reviewed" note at the foot of an article (the last edit date) */
.reviewed { display: flex; align-items: center; gap: 8px; font: 600 14px/1.4 var(--f-ui); color: var(--how-d); margin: 48px 0 0; padding-top: 20px; border-top: 1px solid var(--line); }

/* ---------- Homepage hero ---------- */
/* Space above the title: 3% of the window width, between 16px and 40px (was up to 88px). */
.home-hero {
  padding-top: clamp(16px, 3vw, 40px);
  padding-bottom: 24px;
  background: radial-gradient(900px 400px at 85% 30%, #FFF6D6, transparent 70%);
}
.home-hero-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: clamp(24px, 5vw, 64px); align-items: center; }
.hero-art { margin: 0; }
.hero-art svg, .hero-art img { display: block; width: 100%; height: auto; max-width: 540px; margin-inline: auto; }
/* minmax(0, 1fr), not 1fr: a plain 1fr will not shrink below its content, and the search box's
   own width pushed the column (and the page) wider than a phone. */
@media (max-width: 900px) { .home-hero-grid { grid-template-columns: minmax(0, 1fr); } .hero-art svg, .hero-art img { max-width: 360px; } }
/* Phones: no hero picture, so the title and the search box are what you see first. */
@media (max-width: 700px) { .hero-art { display: none; } }
/* Homepage title. Size: 4.2% of the window width, but never smaller than 34px or bigger than 58px.
   No max-width: the column sets the line length, and text-wrap: balance evens the lines out. */
.home-hero h1 {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(34px, 4.2vw, 58px);
  line-height: 1.08;
  letter-spacing: -1px;
  text-wrap: balance;
  margin: 0 0 18px;
}
/* An emphasised word in a title: typed as [span]word[/span] in the admin, turned into <span> by
   clean($title, true). Yellow behind the lower part of the line only, like the logo's "WISH":
   a gradient that is clear for the top 58% of the line and yellow for the rest (change both 58%
   to move the edge). box-decoration-break keeps it on every line if the phrase wraps. */
.home-hero h1 span,
.a-head h1 span {
  background: linear-gradient(transparent 58%, var(--sun) 58%);
  padding: 0 .06em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.home-hero .lede { font: 400 clamp(18px, 2vw, 22px)/1.5 var(--f-read); color: var(--ink-2); max-width: 40ch; margin: 32px 0; }
.search-bar { display: flex; align-items: center; gap: 10px; background: #fff; border: 1.5px solid #D9D2C3; border-radius: 999px; padding: 6px 6px 6px 22px; box-shadow: var(--shadow); max-width: 720px; }
.search-bar:focus-within { border-color: var(--ink); }
.search-bar input { flex: 1; min-width: 0; border: 0; outline: 0; font: 400 18px/1.4 var(--f-ui); background: transparent; color: var(--ink); padding: 10px 0; }
.search-bar input::placeholder { color: var(--ink-3); }
.search-bar .btn { padding: 14px 26px; font-size: 16px; }
.home-blocks { padding-block: 32px; }

/* ---------- Subject colour tones (one per colour class, set on the subject's category as its CSS class; IwikPages::subjects()) ---------- */
.tone-blue { --tint: var(--world); --deep: var(--world-d); }
.tone-amber { --tint: var(--science); --deep: var(--science-d); }
.tone-green { --tint: var(--how); --deep: var(--how-d); }
.tone-orange { --tint: var(--everyday); --deep: var(--everyday-d); }
.tone-rose { --tint: var(--finance); --deep: var(--finance-d); }
.tone-indigo { --tint: var(--tech); --deep: var(--tech-d); }
.tone-brown { --tint: var(--history); --deep: var(--history-d); }
.tone-purple { --tint: var(--body); --deep: var(--body-d); }
.a-head { background: radial-gradient(800px 380px at 80% 40%, color-mix(in srgb, var(--tint, #FDF1C7) 70%, transparent), transparent 70%); }

/* ---------- Article cards (subject pages, later the homepage and "Where next?") ---------- */
/* Unused since the subject page lists children through a "child-pages" section (kept for reference)
.subject-list { padding-block: 24px 64px; }
.subject-list .h2 { font: 700 clamp(26px, 3vw, 34px)/1.1 var(--f-display); letter-spacing: -.5px; margin: 0 0 28px; }
.subject-list .h2::before { content: ''; display: block; width: 40px; height: 5px; background: var(--sun); border-radius: 3px; margin-bottom: 14px; }
*/
.card-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
/* Homepage featured: the 4th card (random) only where four fit in a row. */
.card-grid--featured li:nth-child(4) { display: none; }
@media (min-width: 1100px) { .card-grid--featured { grid-template-columns: repeat(4, 1fr); } .card-grid--featured li:nth-child(4) { display: block; } }
.article-card { position: relative; display: flex; flex-direction: column; height: 100%; background: var(--card); border-radius: var(--radius); overflow: hidden; text-decoration: none; box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s; }
.article-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); background: color-mix(in srgb, var(--card) 94%, #000); }
.article-card .thumb { display: grid; position: relative; place-items: center; aspect-ratio: 4 / 3; flex: none; background: var(--tint, var(--sun-soft)); overflow: hidden; }
/* The article pictures have rounded, transparent corners: sit them on their own cream so none of the tint shows. */
.article-card .thumb:has(> img:not(.thumb-icon)) { background: #FDF6E6; }
.article-card .thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; margin: 0; }
.article-card .thumb img.thumb-icon { position: static; width: 96px; height: 96px; object-fit: contain; }
.a-hero-icon img { width: min(240px, 60%); height: auto; margin-inline: auto; display: block; border-radius: 0; }
.result-thumb img.thumb-icon { width: 64px; height: 64px; object-fit: contain; }
.article-card .thumb-initial { font: 800 64px/1 var(--f-display); color: var(--deep, var(--ink)); opacity: .55; }
.article-card .body { display: flex; flex-direction: column; flex: 1; padding: 18px 20px 20px; }
.article-card .eyebrow { color: var(--deep, var(--ink-2)); }
.article-card h3 { font: 700 20px/1.25 var(--f-display); margin: 8px 0; letter-spacing: -.2px; }
.article-card p { margin: 0 0 16px; color: var(--ink-2); font-size: 14.5px; line-height: 1.5; }
.article-card .meta { display: flex; align-items: center; gap: 14px; color: var(--ink-2); font-size: 13px; margin-top: auto; }
.article-card .meta > span:first-child { display: inline-flex; align-items: center; gap: 5px; }
.article-card .go { margin-left: auto; width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--ink); display: grid; place-items: center; }
.flag-badge { position: absolute; top: 12px; right: 12px; z-index: 2; background: var(--sun); color: var(--ink); font: 600 11.5px/1 var(--f-ui); padding: 6px 10px; border-radius: 999px; }
.read-badge { position: absolute; top: 12px; left: 12px; z-index: 2; background: var(--ink); color: #fff; font: 600 11.5px/1 var(--f-ui); padding: 6px 10px 6px 8px; border-radius: 999px; display: inline-flex; align-items: center; gap: 5px; }

/* "Where next?" at the foot of an article (from the page tree) */
.where-next { padding-block: 32px 64px; background: linear-gradient(transparent, color-mix(in srgb, var(--tint, #FDF1C7) 45%, transparent)); }
.where-next .h2 { font: 700 clamp(26px, 3vw, 34px)/1.1 var(--f-display); letter-spacing: -.5px; margin: 0 0 24px; }
.where-next .h2::before { content: ''; display: block; width: 40px; height: 5px; background: var(--sun); border-radius: 3px; margin-bottom: 14px; }
.where-label { font: 700 12px/1 var(--f-ui); letter-spacing: 1.2px; text-transform: uppercase; color: var(--ink-2); margin: 32px 0 14px; }
.where-label:first-of-type { margin-top: 0; }

/* Search page (renderer: sections/search.php) */
.block--search .search-bar { max-width: none; margin-top: 8px; }
.result-count, .result-hint { font: 500 15px/1.4 var(--f-ui); color: var(--ink-2); margin: 24px 0 16px; }
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.prose .results { padding-left: 0; }
.result { position: relative; display: flex; gap: 18px; align-items: center; background: var(--card); border-radius: var(--radius); padding: 14px 52px 14px 14px; text-decoration: none; box-shadow: var(--shadow); font-family: var(--f-ui); transition: transform .18s, box-shadow .18s; }
.result:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); background: color-mix(in srgb, var(--card) 94%, #000); }
.result-thumb { flex: none; width: 112px; aspect-ratio: 4 / 3; border-radius: 12px; background: var(--tint, var(--sun-soft)); display: grid; place-items: center; overflow: hidden; }
.result-thumb img { width: 100%; height: 100%; object-fit: cover; margin: 0; border-radius: 0; }
.result-thumb .thumb-initial { font: 800 40px/1 var(--f-display); color: var(--deep, var(--ink)); opacity: .55; }
.result-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.result .eyebrow { color: var(--deep, var(--ink-2)); }
.result h3 { font: 700 20px/1.25 var(--f-display); margin: 0; letter-spacing: -.2px; color: var(--ink); }
.result p { margin: 0; font-size: 14.5px; line-height: 1.45; color: var(--ink-2); }
.result .why { display: inline-flex; align-items: center; gap: 6px; font: 600 12.5px/1.3 var(--f-ui); color: var(--how-d); }
.result .meta { display: flex; gap: 14px; color: var(--ink-2); font-size: 13px; }
.result .meta span { display: inline-flex; align-items: center; gap: 5px; }
.result .go { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--ink); display: grid; place-items: center; }
mark { background: var(--sun-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.no-results { margin-top: 32px; }
.no-results h2 { margin-bottom: 10px; }
.try-again { margin-top: 28px; text-align: center; }
@media (max-width: 560px) { .result { align-items: flex-start; } .result-thumb { width: 84px; } .result h3 { font-size: 18px; } }

/* Explore page: one group per subject */
.explore-group { margin: 40px 0 56px; }
.explore-group h3 { font: 700 26px/1.1 var(--f-display); letter-spacing: -.4px; margin: 0 0 18px; }
.explore-group h3 a { text-decoration: none; color: var(--deep, var(--ink)); }
.explore-group h3 a:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- Subject grid (homepage, Subjects page; renderer: sections/subject-grid.php) ---------- */
.subject-grid { list-style: none; margin: 24px 0 0; padding: 0; display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
/* Each card spans three grid rows (head: picture + name; text: description, the full width of the
   card; foot: article count + arrow). The card and its <li> use the grid's own rows ("subgrid"),
   so in every line of cards the three rows are the same height in all of them, even when a name
   or a description wraps. */
.subject-grid > li { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 0; }
.subject-card { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 0; padding: 18px 20px; border-radius: var(--radius); background: var(--tint, var(--sun-soft)); border: 1px solid rgba(20,33,61,.05); text-decoration: none; font-family: var(--f-ui); transition: transform .18s, box-shadow .18s; }
.subject-grid .subject-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); background: color-mix(in srgb, var(--tint, var(--sun-soft)) 88%, #000); }  /* beats ".prose a:hover" (yellow) */
.subject-head { display: flex; align-items: center; gap: 14px; min-width: 0; padding-bottom: 12px; }
.subject-head b { font: 700 18px/1.2 var(--f-ui); color: var(--ink); min-width: 0; }
.subject-card img { width: 64px; height: 64px; object-fit: contain; flex: none; margin: 0; border-radius: 0; }
.subject-initial { flex: none; width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; background: #fff; font: 800 28px/1 var(--f-display); color: var(--deep, var(--ink)); }
.subject-text { min-width: 0; padding-bottom: 12px; font-size: 13.5px; line-height: 1.45; color: var(--ink-2); }   /* its own row: the whole card width */
.subject-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.subject-count { font: 600 12.5px/1.3 var(--f-ui); color: var(--deep, var(--ink-2)); }
.subject-card .go { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--ink); display: grid; place-items: center; }

/* Chips (popular searches; renderer: sections/popular-searches.php) */
.prose .chips, .prose .subject-grid, .prose .card-grid { padding-left: 0; }
.chips { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; font-family: var(--f-ui); }
.chip { display: inline-block; font: 500 14px/1 var(--f-ui); padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; text-decoration: none; color: var(--ink-2); }
.chip:hover { border-color: var(--ink); color: var(--ink); background: #fff; }
.block--popular { margin: 0 0 8px; }
.block--popular p { font: 500 14px/1.4 var(--f-ui); margin: 0 0 4px; color: var(--ink-2); }

/* Homepage blocks: sections sit in the wrap, headings as in an article */
.home-blocks .block { margin: 48px 0; }
.home-blocks .block:first-child { margin-top: 0; }

/* ---------- Subject and list pages (basic; built out in Phase 4) ---------- */
.card-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card-list a { display: block; background: var(--card); border-radius: var(--radius); padding: 20px; text-decoration: none; box-shadow: var(--shadow); }
.card-list a:hover { box-shadow: var(--shadow-lg); }
.card-list h3 { font: 700 20px/1.25 var(--f-display); margin: 0 0 6px; }
.card-list p { margin: 0; color: var(--ink-2); font-size: 14.5px; }

/* ---------- Footer ---------- */
.site-footer { background: var(--night); color: #C9CEDA; margin-top: 40px; }
.site-footer .wrap { padding-block: 56px 40px; display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; }
.site-footer .logo { color: #fff; }
.site-footer .logo span { background: linear-gradient(transparent 62%, rgba(245,197,66,.55) 62%); }
.site-footer .tagline { margin: 14px 0 0; max-width: 28ch; }
.site-footer h4 { color: #fff; font: 600 14px/1 var(--f-ui); margin: 6px 0 14px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.site-footer a, .site-footer .linklike { text-decoration: none; }
.site-footer a:hover, .site-footer .linklike:hover { color: #fff; text-decoration: underline; }
.site-footer .cms-link { margin-left: auto; opacity: .25; }
.site-footer .cms-link:hover, .site-footer .cms-link:focus-visible { opacity: 1; text-decoration: none; }
.site-footer .fine { grid-column: 1 / -1; border-top: 1px solid #2C3854; padding-top: 20px; font-size: 13px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
@media (max-width: 760px) { .site-footer .wrap { grid-template-columns: 1fr 1fr; } .site-footer .wrap > :first-child { grid-column: 1 / -1; } }

/* ---------- Cookie banner ---------- */
.cookie-banner { position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -8px 30px rgba(20,33,61,.12); }
.cookie-banner .wrap { display: flex; gap: 24px; align-items: center; justify-content: space-between; padding-block: 18px; }
.cookie-text p { margin: 4px 0 0; font-size: 14.5px; color: var(--ink-2); max-width: 70ch; }
.cookie-actions { display: flex; gap: 10px; flex: none; }
@media (max-width: 700px) { .cookie-banner .wrap { flex-direction: column; align-items: stretch; } .cookie-actions .btn { flex: 1; justify-content: center; } }

/* Maintenance banner (core include, shown to a logged-in admin while maintenance mode is on) */
#maintenanceBanner { background: var(--sun-soft); color: var(--ink); border-bottom: 2px solid var(--sun); text-align: center; padding: 10px var(--gutter); font: 400 14px/1.5 var(--f-ui); }
#maintenanceBanner strong { font-weight: 800; letter-spacing: .5px; }
