/* Pagepurr blog. Layout follows reading research (sources in tools/blog/README.md):
   warm single-colour page, big sans text, short lines, 1.6+ line height, roomy paragraphs,
   no italics / caps / underline for emphasis, one plain column, one main button.
   Fonts come from /styles.css. Classes start with b- where the app uses the plain name. */
:root {
  /* same page colours as the Pagepurr app (styles.css themes) */
  --pg-bg: var(--bg); --pg-text: var(--text); --pg-muted: var(--muted); --pg-line: var(--line); --pg-soft: var(--surface);
  --pg-hl: #ffd978; --pg-accent: #a9dfbf; --ink: #0a0a0a;
  --read-size: 22px;
  --read-font: "Aros Gothic", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --read-leading: 1.65;
  --read-letter: 0;
  --read-wsp: 0;
  color-scheme: light;
}
:root[data-page="dark"]  { --pg-hl: rgba(255, 217, 120, .38); color-scheme: dark; }
:root[data-font="lexend"] { --read-font: Lexend, Verdana, sans-serif; }
:root[data-font="atkinson"] { --read-font: "Atkinson Hyperlegible", Verdana, sans-serif; }
:root[data-font="opendyslexic"] { --read-font: OpenDyslexic, Verdana, sans-serif; }
/* extra letter + word spacing (Zorzi et al. 2012) */
:root[data-spacing="wide"] { --read-leading: 1.9; --read-letter: .08em; --read-wsp: .2em; }

html, body { height: auto; overflow: visible; }
html { scroll-behavior: smooth; scroll-padding-top: 90px; }
body { background: var(--pg-bg); color: var(--pg-text); font-family: var(--read-font); margin: 0; -webkit-font-smoothing: antialiased; }
em, i { font-style: normal; font-weight: 700; }
a { color: inherit; text-underline-offset: 4px; text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--pg-text); outline-offset: 3px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--pg-text); color: var(--pg-bg); padding: 12px 18px; border-radius: 999px; font-weight: 700; text-decoration: none; }
.skip:focus { top: 12px; }

/* progress */
.b-progress { position: fixed; inset: 0 0 auto 0; height: 5px; z-index: 40; }
.b-progress span { display: block; height: 100%; width: 0; background: var(--pg-accent); }

/* header */
.top { position: sticky; top: 0; z-index: 30; background: var(--pg-bg); border-bottom: 1px solid var(--pg-line); }
.top-in { max-width: 1000px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { width: 36px; height: 36px; border-radius: 10px; }
.wordmark { font-family: "Fredoka", sans-serif; font-weight: 500; font-size: 23px; line-height: 1; color: #0a0a0a; -webkit-text-stroke: 6px #fff; paint-order: stroke fill; }
.spacer { flex: 1; }
.toplink { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font: 600 17px/1 var(--read-font); text-decoration: none; color: var(--pg-muted); }
.toplink:hover { color: var(--pg-text); text-decoration: underline; }
.toplink svg { width: 18px; height: 18px; }
@media (max-width: 560px) { .toplink.blog { display: none; } }

/* one column, short lines (Schneps et al. 2013; WCAG 1.4.8 max 80 characters) */
.wrap { max-width: 34em; margin: 0 auto; padding: 0 22px; font-size: var(--read-size); }

/* hero */
.b-hero { padding: 1.6em 0 .2em; }
.kicker { font: 600 .72em/1.4 var(--read-font); color: var(--pg-muted); margin: 0 0 .7em; }
h1.title { font: 700 clamp(1.7em, 5vw, 2.2em)/1.15 var(--read-font); letter-spacing: -.01em; margin: 0 0 .45em; text-wrap: balance; }
.meta { display: flex; flex-wrap: wrap; gap: 0 .9em; color: var(--pg-muted); font-size: .72em; margin: 0 0 1.2em; }

/* the one big button + quiet settings */
.b-bar { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.listen { display: inline-flex; align-items: center; gap: 12px; min-height: 58px; padding: 0 26px 0 9px; border-radius: 999px; border: 0; background: var(--ink); color: #fff; font: 700 18px/1 var(--read-font); cursor: pointer; }
:root[data-page="dark"] .listen { background: var(--pg-accent); color: var(--ink); }
.listen .b-dot { width: 40px; height: 40px; border-radius: 50%; background: var(--pg-accent); color: var(--ink); display: grid; place-items: center; }
:root[data-page="dark"] .listen .b-dot { background: var(--ink); color: #fff; }
.listen .b-dot svg { width: 18px; height: 18px; }
.quiet { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 2px; border: 0; background: none; color: var(--pg-muted); font: 600 17px/1 var(--read-font); cursor: pointer; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 4px; }
.quiet:hover, .quiet[aria-expanded="true"] { color: var(--pg-text); text-decoration-color: currentColor; }
.quiet svg { width: 20px; height: 20px; }
.status { min-height: 1.3em; font-size: 16px; color: var(--pg-muted); margin: 8px 0 0; }

.settings-panel { background: var(--pg-soft); border-radius: 18px; padding: 18px; margin: 8px 0 4px; font-size: 16px; }
.settings-panel[hidden] { display: none; }
.set-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 16px; }
.set-row:last-child { margin: 0; }
.set-row > .lbl { width: 100%; font-weight: 700; font-size: 15px; color: var(--pg-muted); }
.b-chip { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 14px; border-radius: 999px; border: 2px solid var(--pg-line); background: var(--pg-bg); color: var(--pg-text); font: 600 16px/1 var(--read-font); cursor: pointer; }
.b-chip[aria-pressed="true"] { border-color: var(--pg-text); box-shadow: inset 0 0 0 1px var(--pg-text); }
.b-chip.now { border-color: transparent; background: none; cursor: default; min-width: 64px; }
.b-swatch { gap: 8px; }
.b-swatch span { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); }

/* article text: big, roomy, left aligned (Rello et al. 2016; WCAG 1.4.8; BDA) */
.article { font-family: var(--read-font); line-height: var(--read-leading); letter-spacing: var(--read-letter); word-spacing: var(--read-wsp); }
.article p, .article li { margin: 0 0 1.1em; text-align: left; }
.article ul, .article ol { padding-left: 1.2em; }
.article li { margin-bottom: .6em; }
.article h2 { font: 700 1.25em/1.25 var(--read-font); margin: 0 0 .5em; text-wrap: balance; letter-spacing: 0; }
.article h3 { font-size: 1.05em; margin: 1.2em 0 .3em; }
.article strong { font-weight: 700; }
.lede { font-size: 1.05em; }

/* summary first (W3C COGA: put the aim at the start) */
.tldr { background: var(--pg-soft); border-radius: 20px; padding: 1em 1.1em .3em; margin: 1.6em 0 2em; line-height: 1.5; }
.tldr h2 { font: 700 .8em/1.2 var(--read-font); color: var(--pg-muted); margin: 0 0 .6em; }
.tldr ul { margin: 0; padding-left: 1.1em; }
.tldr li { margin: 0 0 .7em; }

/* contents */
.toc { margin: .4em 0 2.2em; }
.toc h2 { font: 700 .8em/1.2 var(--read-font) !important; color: var(--pg-muted); margin: 0 0 .5em !important; }
.toc ol { margin: 0; padding-left: 1.3em; font-size: .85em; line-height: 1.5; }
.toc li { margin: 0 0 .35em; }

/* sections: plain, numbered, divided by a line */
.sec { margin: 0 0 2em; }
.tip { border-top: 1px solid var(--pg-line); padding-top: 1.4em; }
.tip-head { display: flex; align-items: flex-start; gap: .55em; margin: 0 0 .5em; }
.tip-head h2 { margin: 0; }
.tip .num { flex: none; width: 1.55em; height: 1.55em; margin-top: -.08em; border-radius: 50%; display: grid; place-items: center; background: var(--pg-accent); color: var(--ink); font: 700 1em/1 var(--read-font); }

/* read more */
.tip.folded .tip-more { display: none; }
.more-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin: -.4em 0 0; padding: 0; border: 0; background: none; color: var(--pg-text); font: 700 18px/1 var(--read-font); text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 2px; cursor: pointer; }
.more-btn svg { width: 18px; height: 18px; transition: transform .15s; }
.more-btn[aria-expanded="true"] svg { transform: rotate(180deg); }

/* a number from a study */
.stat { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; align-items: center; background: var(--pg-soft); border-radius: 18px; padding: 14px 18px; margin: .2em 0 1.2em; }
.stat b { font: 700 2em/1 var(--read-font); }
.stat p { margin: 0 !important; font-size: .85em; line-height: 1.45; }
.stat small { grid-column: 1 / -1; font-size: .65em; color: var(--pg-muted); }

/* end card */
.endcard { background: var(--pg-accent); color: var(--ink); border-radius: 24px; padding: 1.2em 1.2em 1.3em; margin: 2.4em 0 2em; display: grid; gap: .6em; }
.endcard img { width: 48px; height: 48px; border-radius: 13px; box-shadow: 0 0 0 3px #fff; }
.endcard h2 { font: 700 1.25em/1.2 var(--read-font); margin: 0; }
.endcard p { margin: 0; font-size: .85em; line-height: 1.55; }
.endcard .cta { justify-self: start; display: inline-flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 22px; border-radius: 999px; background: var(--ink); color: #fff; font: 700 17px/1 var(--read-font); text-decoration: none; }
.endcard .cta svg { width: 20px; height: 20px; }

/* faq + sources */
.faq h2, .sources h2 { font: 700 1.1em/1.25 var(--read-font); margin: 0 0 .3em; }
.faq details { border-bottom: 1px solid var(--pg-line); }
.faq summary { cursor: pointer; list-style: none; padding: .7em 2em .7em 0; font: 700 .85em/1.4 var(--read-font); position: relative; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: ""; position: absolute; right: 6px; top: 50%; width: 9px; height: 9px; border-right: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; transform: translateY(-70%) rotate(45deg); }
.faq details[open] summary::after { transform: translateY(-30%) rotate(-135deg); }
.faq details p { padding: 0 0 .8em; margin: 0; font-size: .9em; }
.sources { margin: 2em 0 0; }
.sources ol { font-size: .7em; line-height: 1.5; padding-left: 1.3em; color: var(--pg-muted); }
.sources li { margin: 0 0 10px; }

/* read-aloud highlight */
.b-w { border-radius: 4px; }
.b-w.on { background: var(--pg-hl); box-shadow: 0 0 0 2px var(--pg-hl); }

/* focus mode: dim everything but the paragraph you are on (for ADHD) */
:root[data-focus="on"] .article :is(p, li, h2, h3, .stat), :root[data-focus="on"] .tldr li { opacity: .3; transition: opacity .2s; }
:root[data-focus="on"] .article .is-focus, :root[data-focus="on"] .tldr .is-focus, :root[data-focus="on"] .article .is-focus :is(p, li) { opacity: 1; }
.reading-block { opacity: 1 !important; }

/* footer */
.foot { border-top: 1px solid var(--pg-line); margin-top: 3em; }
.foot-in { max-width: 1000px; margin: 0 auto; padding: 24px 20px 44px; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 16px; color: var(--pg-muted); }

/* blog front page */
.ix-hero { padding: 1.8em 0 1em; }
.ix-hero h1 { font: 700 clamp(1.9em, 7vw, 2.6em)/1.1 var(--read-font); margin: 0 0 .4em; }
.ix-hero p { margin: 0 0 .6em; line-height: 1.55; }
.b-cards { list-style: none; padding: 0; margin: 1em 0 0; display: grid; gap: 0; }
.b-cards li { border-top: 1px solid var(--pg-line); }
.b-card { display: block; padding: 1em 0 1.1em; text-decoration: none; color: inherit; }
.b-card .kicker { margin: 0 0 .3em; }
.b-card h2 { font: 700 1.2em/1.25 var(--read-font); margin: 0 0 .3em; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 5px; }
.b-card:hover h2, .b-card:focus-visible h2 { text-decoration-color: currentColor; }
.b-card p { margin: 0 0 .4em; font-size: .85em; line-height: 1.55; }
.b-card .go { font-size: .72em; color: var(--pg-muted); font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.b-card .go svg { width: 18px; height: 18px; }
.soon { padding: 1em 0; color: var(--pg-muted); font-size: .8em; }

@media (max-width: 560px) {
  :root { --read-size: 20px; }
  .wrap { padding: 0 18px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media (forced-colors: active) {
  .listen, .b-chip, .endcard .cta { border: 2px solid ButtonText; }
  .b-w.on { background: Highlight; color: HighlightText; }
}
