/* Research site style: three directions on one page structure (research-flowershow-theme/).
   Selectors follow Flowershow's markup (.page-header-*, .rendered-mdx, .toc, GFM footnotes), so a chosen
   direction moves into a site's custom.css as is. Each direction is a block of tokens on [data-dir], plus a
   few treatments of its own at the end. Fonts: the bespoke SoR faces from this repo; Google Fonts in the page. */

@font-face { font-family: "Polyamine"; font-weight: 400; font-display: swap; src: url("../../sor-design-system/system/fonts/Polyamine-Regular.woff2") format("woff2"); }
@font-face { font-family: "Apfel Grotezk"; font-weight: 500; font-display: swap; src: url("../../sor-design-system/system/fonts/ApfelGrotezk-Mittel.otf") format("opentype"); }
@font-face { font-family: "Restora"; font-weight: 300; font-display: swap; src: url("../../fonts/restora/webfonts/RestoraLight/font.woff2") format("woff2"); }
@font-face { font-family: "Restora"; font-weight: 300; font-style: italic; font-display: swap; src: url("../../fonts/restora/webfonts/RestoraLightItalic/font.woff2") format("woff2"); }
@font-face { font-family: "Restora"; font-weight: 400; font-display: swap; src: url("../../fonts/restora/webfonts/RestoraRegular/font.woff2") format("woff2"); }
@font-face { font-family: "Restora"; font-weight: 400; font-style: italic; font-display: swap; src: url("../../fonts/restora/webfonts/RestoraItalic/font.woff2") format("woff2"); }
@font-face { font-family: "Restora"; font-weight: 500; font-display: swap; src: url("../../fonts/restora/webfonts/RestoraMedium/font.woff2") format("woff2"); }

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --ink: #1b1916;
  --muted: #5d584f;
  --rule: #e0dacf;
  --red: #e5201c;
  --label: "Apfel Grotezk", "Hanken Grotesk", system-ui, sans-serif;
  --gutter: clamp(16px, 4vw, 56px);
}

/* A · SoR kit: the wisdomandai.org look, as in projects/flowershow/sor-flowershow.css. */
[data-dir="a"] {
  --ground: #fbfaf6;
  --title: "Polyamine", "Fraunces", Georgia, serif;   --title-weight: 400; --title-size: clamp(44px, 6vw, 66px); --title-lh: 1; --title-track: 0;
  --dek: "Restora", "Fraunces", Georgia, serif;       --dek-weight: 300; --dek-size: clamp(20px, 2.2vw, 26px);
  --head: "Restora", "Fraunces", Georgia, serif;
  --h2: clamp(32px, 4vw, 42px); --h2-weight: 400; --h3: 26px; --h3-weight: 500; --h3-font: var(--head);
  --body: "Bricolage Grotesque", system-ui, sans-serif; --size: 19px; --lh: 1.65; --measure: 43rem;
  --quote: "Restora", Georgia, serif; --quote-weight: 300; --quote-size: 24px;
  --space-h2: 80px;
}

/* B · SoR quiet: bespoke faces, no Polyamine in the page; a little denser. */
[data-dir="b"] {
  --ground: #fbfaf6;
  --title: "Restora", "Fraunces", Georgia, serif;     --title-weight: 500; --title-size: clamp(36px, 4.8vw, 54px); --title-lh: 1.06; --title-track: -.015em;
  --dek: "Bricolage Grotesque", system-ui, sans-serif; --dek-weight: 400; --dek-size: clamp(18px, 1.8vw, 21px);
  --head: "Restora", "Fraunces", Georgia, serif;
  --h2: clamp(28px, 3.2vw, 34px); --h2-weight: 500; --h3: 22px; --h3-weight: 500; --h3-font: var(--head);
  --body: "Bricolage Grotesque", system-ui, sans-serif; --size: 17.5px; --lh: 1.6; --measure: 40rem;
  --quote: "Restora", Georgia, serif; --quote-weight: 400; --quote-size: 22px;
  --space-h2: 64px;
}

/* C · Web serif: Google Fonts only for reading (Newsreader display, Source Serif text), Apfel (OFL) for labels. */
[data-dir="c"] {
  --ground: #fbfaf6;
  --title: "Newsreader", Georgia, serif;              --title-weight: 500; --title-size: clamp(40px, 5.6vw, 62px); --title-lh: 1.04; --title-track: -.02em;
  --dek: "Newsreader", Georgia, serif;                --dek-weight: 400; --dek-size: clamp(20px, 2.1vw, 24px);
  --head: "Newsreader", Georgia, serif;
  --h2: clamp(30px, 3.6vw, 38px); --h2-weight: 500; --h3: 23px; --h3-weight: 600; --h3-font: var(--head);
  --body: "Source Serif 4", Georgia, serif; --size: 18.5px; --lh: 1.62; --measure: 41rem;
  --quote: "Newsreader", Georgia, serif; --quote-weight: 400; --quote-size: 23px;
  --space-h2: 72px;
}

/* ── Frame ──────────────────────────────────────────────── */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--body); }
a { color: inherit; }
img { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.site-navbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 10px 24px; max-width: 1180px; margin: 0 auto; padding: 22px var(--gutter); border-bottom: 1px solid var(--rule); }
.site-navbar-site-title { font-family: var(--title); font-weight: var(--title-weight); font-size: 22px; text-decoration: none; }
.site-navbar-links { display: flex; flex-wrap: wrap; gap: 18px; }
.site-navbar-link, .site-footer, .page-header-breadcrumbs, .page-header-reading-time, .sor-paper-meta, .sor-label, .toc-title {
  font-family: var(--label); font-weight: 500; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; text-decoration: none; }

.page-main { max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter); }
.page-header { max-width: var(--measure); padding: clamp(40px, 7vw, 88px) 0 clamp(28px, 4vw, 44px); }
.page-header-breadcrumbs { color: var(--muted); margin-bottom: 18px; }
.page-header-breadcrumb-link { text-decoration: none; }
.page-header-title { font-family: var(--title); font-weight: var(--title-weight); font-size: var(--title-size); line-height: var(--title-lh); letter-spacing: var(--title-track); margin: 0 0 18px; text-wrap: balance; }
.page-header-description { font-family: var(--dek); font-weight: var(--dek-weight); font-size: var(--dek-size); line-height: 1.35; margin: 0 0 22px; color: var(--ink); text-wrap: balance; }
.sor-paper-meta { color: var(--muted); line-height: 1.8; margin: 0; }
.sor-paper-meta a { text-decoration: none; border-bottom: 1px solid var(--rule); }
.page-header-reading-time { white-space: nowrap; }

/* Contents on the right from 1100px, as Flowershow places it; hidden below. */
.layout-inner { display: block; }
.toc { display: none; }
@media (min-width: 1100px) {
  .layout-inner.has-toc { display: grid; grid-template-columns: minmax(0, var(--measure)) 230px; justify-content: space-between; gap: 48px; }
  .toc { display: block; position: sticky; top: 24px; align-self: start; max-height: calc(100vh - 48px); overflow: auto; padding-left: 16px; border-left: 1px solid var(--rule); }
}
.toc-title { color: var(--muted); margin: 4px 0 10px; }
.toc ul { list-style: none; margin: 0; padding: 0; font-size: 14px; line-height: 1.35; }
.toc li { margin: 0 0 8px; }
.toc li.toc-l3 { padding-left: 12px; font-size: 13px; color: var(--muted); }
.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; text-decoration-color: var(--red); }

.site-footer { max-width: 1180px; margin: 96px auto 0; padding: 28px var(--gutter) 48px; border-top: 1px solid var(--rule); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; }
.sor-built { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--muted); }
.sor-built img { height: 30px; width: auto; display: block; }
.site-footer-copyright { color: var(--muted); margin: 0; }

/* ── Reading ────────────────────────────────────────────── */
.rendered-mdx { font-size: var(--size); line-height: var(--lh); max-width: var(--measure); hyphens: auto; hyphenate-limit-chars: 7 3 3; overflow-wrap: break-word; font-variant-numeric: oldstyle-nums proportional-nums; }
.rendered-mdx > :first-child { margin-top: 0; }
.rendered-mdx :is(p, ul, ol) { margin-block: 1.1em; }
.rendered-mdx p { text-wrap: pretty; }
.rendered-mdx :is(strong, b) { font-weight: 600; hyphens: manual; }
.rendered-mdx :is(ul, ol) { padding-left: 1.5em; }
.rendered-mdx li { margin-block: .45em; padding-left: .3em; }
.rendered-mdx a { font-weight: 500; text-decoration-line: underline; text-decoration-color: var(--red); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.rendered-mdx :is(h2, h3, h4) { hyphens: manual; text-wrap: balance; color: var(--ink); font-variant-numeric: lining-nums; }
.rendered-mdx :is(h2, h3, h4) + * { margin-top: 0; }
.rendered-mdx h2 { font-family: var(--head); font-weight: var(--h2-weight); font-size: var(--h2); line-height: 1.1; letter-spacing: -.015em; margin: var(--space-h2) 0 18px; }
.rendered-mdx h3 { font-family: var(--h3-font); font-weight: var(--h3-weight); font-size: var(--h3); line-height: 1.2; letter-spacing: -.01em; margin: 44px 0 10px; }
.rendered-mdx h4 { font-family: var(--label); font-weight: 500; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; margin: 32px 0 6px; }
.rendered-mdx blockquote { margin: 32px 0; padding: 0; border: 0; font-family: var(--quote); font-style: italic; font-weight: var(--quote-weight); font-size: var(--quote-size); line-height: 1.32; hyphens: manual; }
.rendered-mdx blockquote p { margin: 0; }
.rendered-mdx hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5em 0; }

/* Footnote marks and notes (GFM, as Flowershow renders [^1]). */
.rendered-mdx sup { line-height: 0; }
.rendered-mdx sup a { font-family: var(--label); font-size: 12px; font-weight: 500; text-decoration: none; color: var(--red); padding: 0 3px; }
.rendered-mdx .footnotes { margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--rule); font-size: 14px; line-height: 1.5; color: var(--muted); font-family: var(--body); }
.rendered-mdx .footnotes::before { content: "Notes"; display: block; font: 500 12px var(--label); letter-spacing: .14em; text-transform: uppercase; color: var(--ink); margin-bottom: 10px; }
.rendered-mdx .footnotes ol { padding-left: 1.4em; }
.rendered-mdx .footnotes li { margin-block: .6em; }
.rendered-mdx .footnotes li::marker { font-family: var(--label); font-size: 12px; color: var(--ink); }
.rendered-mdx .footnotes a { font-weight: 400; overflow-wrap: anywhere; }
.rendered-mdx .data-footnote-backref { text-decoration: none; }

/* Tables: hairlines, label-face heads, scroll on narrow screens. */
.rendered-mdx table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: .84em; line-height: 1.45; margin: 20px 0 28px; font-variant-numeric: lining-nums tabular-nums; }
.rendered-mdx th { font: 500 11px var(--label); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 0 16px 8px 0; border-bottom: 1px solid var(--ink); vertical-align: bottom; }
.rendered-mdx td { padding: 10px 16px 10px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.rendered-mdx td:first-child { font-weight: 600; white-space: nowrap; }

/* Figures, callouts, cite block. */
.sor-fig { margin: 36px 0; }
.sor-fig img { display: block; width: 100%; height: auto; }
.sor-fig figcaption { font-size: 14px; line-height: 1.45; color: var(--muted); margin-top: 10px; }
.rendered-mdx .callout { margin: 32px 0; padding: 18px 22px; background: #f4eee2; border: 0; }
.rendered-mdx .callout-title { font: 500 12px var(--label); letter-spacing: .14em; text-transform: uppercase; margin-bottom: 6px; }
.rendered-mdx .callout-content p { margin: 0; font-size: .9em; line-height: 1.55; }
.sor-cite { margin: 56px 0 0; padding: 18px 0 0; border-top: 1px solid var(--ink); }
.sor-cite .sor-label { color: var(--muted); margin: 0 0 8px; }
.sor-cite p:last-child { margin: 0; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }

/* ── Direction treatments ───────────────────────────────── */
/* A: the kit's executive-summary standfirst. */
[data-dir="a"] .rendered-mdx h2#executive-summary + p { font-family: var(--dek); font-weight: 300; font-size: clamp(19px, 4.5vw, 22px); line-height: 1.5; }

/* B: section heads under a hairline; summary as a plain lead; callout as a ruled box on white. */
[data-dir="b"] .rendered-mdx h2 { padding-top: 22px; border-top: 1px solid var(--rule); }
[data-dir="b"] .rendered-mdx h2#executive-summary + p { font-size: clamp(18.5px, 2vw, 19.5px); line-height: 1.55; }
[data-dir="b"] .rendered-mdx .callout { background: transparent; border: 1px solid var(--rule); border-left: 3px solid var(--ink); }
[data-dir="b"] .rendered-mdx > h2:first-child { padding-top: 0; border-top: 0; }

/* C: a short red rule above each section (the Reading System's chapter mark, without the label); a larger summary lead. */
[data-dir="c"] .rendered-mdx h2::before { content: ""; display: block; width: 36px; height: 2px; background: var(--red); margin-bottom: 18px; }
[data-dir="c"] .rendered-mdx h2#executive-summary + p { font-family: var(--head); font-size: 21px; line-height: 1.5; }
[data-dir="c"] .rendered-mdx h3 { font-style: normal; }

@media (max-width: 640px) {
  .rendered-mdx { font-size: max(17px, calc(var(--size) - .5px)); }
  .rendered-mdx td:first-child { white-space: normal; }
  .site-navbar-links { gap: 14px; }
}

/* Body-face trials on B (b-*.html): the same page with another reading face; sizes set to match x-heights. */
[data-body="inter"] { --body: "Inter", system-ui, sans-serif; --size: 17px; --lh: 1.62; }
[data-body="source-serif"] { --body: "Source Serif 4", Georgia, serif; --size: 18.5px; --lh: 1.6; }
[data-body="literata"] { --body: "Literata", Georgia, serif; --size: 18px; --lh: 1.62; }
[data-body]:not([data-body=""]) .page-header-description { font-family: var(--body); }
