/* ==========================================================================
   1. Self-Hosted Fonts & Design Tokens
   ========================================================================== */
@font-face {
  font-family: "OpenDyslexic";
  src: url("../fonts/opendyslexic/OpenDyslexic-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "OpenDyslexic";
  src: url("../fonts/opendyslexic/OpenDyslexic-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "OpenDyslexic";
  src: url("../fonts/opendyslexic/OpenDyslexic-Italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  /* Newspaper & Surface Palette */
  --bg-page: #f4f1ea;
  --bg-paper: #faf7f0;
  --bg-toolbar: #efeae0;
  --bg-control: #ffffff;
  --bg-active: #1d1d1b;

  /* Ink & Borders */
  --ink-primary: #1d1d1b;
  --ink-muted: #4b4944;
  --ink-on-active: #faf7f0;
  --rule-color: #2b2a27;
  --rule-subtle: #c8c1b4;
  --focus-ring: #0f4c81;

  /* Typefaces */
  --font-display: "Limelight", Georgia, serif;
  --font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-reading: "Old Standard TT", Georgia, "Times New Roman", serif;

  /* Reading Typography & Spacing (WCAG 1.4.12 resilient) */
  --body-size: 1.0625rem;
  --line-height: 1.6;
  --letter-spacing: 0em;
  --word-spacing: 0.04em;
  --paragraph-gap: 1rem;
}

/* ==========================================================================
   2. Font Presets (data-font on <html>)
   ========================================================================== */
html[data-font="newspaper"] {
  --font-reading: "Old Standard TT", Georgia, "Times New Roman", serif;
}

html[data-font="lexend"] {
  --font-reading: "Lexend", system-ui, -apple-system, sans-serif;
}

html[data-font="opendyslexic"] {
  --font-reading: "OpenDyslexic", "Lexend", Arial, sans-serif;
}

html[data-font="atkinson"] {
  --font-reading: "Atkinson Hyperlegible", Arial, sans-serif;
}

/* ==========================================================================
   3. Text Spacing Modes (data-spacing on <html>)
   ========================================================================== */
html[data-spacing="normal"] {
  --line-height: 1.6;
  --letter-spacing: 0em;
  --word-spacing: 0.04em;
  --paragraph-gap: 1rem;
  --article-para-gap: 1.15rem;
}

html[data-spacing="wide"] {
  /* Meets or exceeds WCAG 1.4.12 text spacing thresholds */
  --line-height: 1.8;
  --letter-spacing: 0.12em;
  --word-spacing: 0.16em;
  --paragraph-gap: 2em;
  --article-para-gap: 2em;
}

/* ==========================================================================
   4. Page Background Tints (data-tint on <html>)
   ========================================================================== */
html[data-tint="paper"] {
  --bg-page: #f4f1ea;
  --bg-paper: #faf7f0;
  --bg-toolbar: #efeae0;
  --bg-control: #ffffff;
}

html[data-tint="cream"] {
  --bg-page: #f5efe2;
  --bg-paper: #fcf8ef;
  --bg-toolbar: #f1e9d8;
  --bg-control: #fffdf8;
}

html[data-tint="sky"] {
  --bg-page: #e5eff7;
  --bg-paper: #f3f8fc;
  --bg-toolbar: #d8e6f2;
  --bg-control: #fafdff;
}

html[data-tint="mint"] {
  --bg-page: #e4f1ea;
  --bg-paper: #f3faf6;
  --bg-toolbar: #d6e8de;
  --bg-control: #fafdfb;
}

/* ==========================================================================
   5. Base Layout & Newspaper Structure
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 1rem;
  background-color: var(--bg-page);
  color: var(--ink-primary);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.5;
  overflow-x: hidden;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--bg-active);
  color: var(--ink-on-active);
  padding: 0.65rem 1rem;
  font-weight: 600;
  text-decoration: none;
  z-index: 200;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

:is(a, button, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.paper {
  max-width: 78rem;
  margin: 0 auto;
  background-color: var(--bg-paper);
  border: 1px solid var(--rule-color);
  box-shadow: 0 2px 12px rgba(29, 29, 27, 0.08);
  padding: clamp(1rem, 3vw, 2.25rem);
}

/* ==========================================================================
   6. Masthead & PWA Tools
   ========================================================================== */
.masthead {
  border-bottom: 3px double var(--rule-color);
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.edition-line,
.dateline {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
  border-top: 1px solid var(--rule-subtle);
  border-bottom: 1px solid var(--rule-subtle);
  padding: 0.45rem 0.25rem;
}

.masthead h1 {
  margin: 0.85rem 0 0.25rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.tagline {
  margin: 0.25rem 0 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.pwa-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.pwa-tools button {
  min-height: 2.35rem;
  padding: 0.4rem 0.85rem;
  border: 1.5px solid var(--rule-color);
  border-radius: 0.25rem;
  background-color: var(--bg-control);
  color: var(--ink-primary);
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.offline-note {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--rule-color);
  border-radius: 0.25rem;
  background-color: var(--bg-toolbar);
}

/* ==========================================================================
   7. Reading Preferences Toolbar
   ========================================================================== */
.reading-toolbar {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  text-align: left;
  background-color: var(--bg-toolbar);
  border: 1px solid var(--rule-color);
  border-radius: 0.375rem;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.9rem 1.35rem;
}

.control-group {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.control-label {
  display: block;
  margin-bottom: 0.35rem;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.button-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.pref-btn,
.reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.35rem;
  padding: 0.38rem 0.7rem;
  border: 1.5px solid var(--rule-color);
  border-radius: 0.25rem;
  background-color: var(--bg-control);
  color: var(--ink-primary);
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.pref-btn:hover,
.reset-btn:hover {
  background-color: var(--bg-paper);
}

.pref-btn[aria-pressed="true"] {
  background-color: var(--bg-active);
  border-color: var(--bg-active);
  color: var(--ink-on-active);
}

.swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(29, 29, 27, 0.35);
  flex-shrink: 0;
}

/* ==========================================================================
   13. Icon Toolbar (icons, font drop-down, colour swatches, hover labels)
   ========================================================================== */
.rt-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.rt-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

[data-tip] {
  position: relative;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 0.4rem);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
  background-color: var(--bg-active);
  color: var(--ink-on-active);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 10;
}

[data-tip]:hover::after,
[data-tip]:focus-visible::after {
  opacity: 1;
}

.rt-btn,
.rt-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border: 1.5px solid var(--rule-color);
  border-radius: 0.25rem;
  background-color: var(--bg-control);
  color: var(--ink-primary);
  cursor: pointer;
}

.rt-btn svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rt-btn:hover {
  background-color: var(--bg-paper);
}

.rt-btn[aria-pressed="true"] {
  background-color: var(--bg-active);
  border-color: var(--bg-active);
  color: var(--ink-on-active);
}

.rt-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.rt-btn .rt-a {
  font-family: var(--font-ui);
  font-weight: 700;
  line-height: 1;
}

.rt-btn .rt-a-small { font-size: 0.85rem; }
.rt-btn .rt-a-large { font-size: 1.2rem; }

.rt-glyph {
  font-family: var(--font-reading);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
}

/* Swatches: one colour per background shade, ringed when selected */
.rt-swatch {
  border-radius: 999px;
}

.rt-swatch[data-value="cream"] { background-color: #f5efe2; }
.rt-swatch[data-value="sky"]   { background-color: #e5eff7; }
.rt-swatch[data-value="mint"]  { background-color: #e4f1ea; }
.rt-swatch[data-value="paper"] { background-color: #f4f1ea; }

.rt-swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--bg-toolbar), 0 0 0 4px var(--ink-primary);
}

.rt-field {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

/* ==========================================================================
   14. Compact Article Masthead (collapses to a slim bar, see app.js 2b)
   ========================================================================== */
.article-masthead {
  transition: padding 0.3s, margin 0.3s;
}

.article-masthead.is-collapsed {
  padding-bottom: 0.4rem;
  margin-bottom: 0.6rem;
}

.article-masthead.is-collapsed > .edition-line,
.article-masthead.is-collapsed > .tagline,
.article-masthead.is-collapsed > .dateline,
.article-masthead.is-collapsed > .archive-nav {
  display: none;
}

.article-masthead.is-collapsed .masthead-title {
  font-size: 1.25rem;
}

.rt-select {
  min-height: 2.35rem;
  padding: 0.3rem 2rem 0.3rem 0.6rem;
  border: 1.5px solid var(--rule-color);
  border-radius: 0.25rem;
  background-color: var(--bg-control);
  color: var(--ink-primary);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  cursor: pointer;
}

.swatch-paper { background-color: #faf7f0; }
.swatch-cream { background-color: #fcf8ef; }
.swatch-sky   { background-color: #f3f8fc; }
.swatch-mint  { background-color: #f3faf6; }

.control-actions {
  margin-left: auto;
}

/* ==========================================================================
   8. Multi-Column Broadsheet & Typography Rules
   ========================================================================== */
.front-page {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.75rem;
  font-family: var(--font-reading);
  font-size: calc(var(--body-size) * var(--text-scale, 1));
  line-height: var(--line-height);
  letter-spacing: var(--letter-spacing);
  word-spacing: var(--word-spacing);
  text-align: left;
}

.column {
  min-width: 0;
}

.column + .column {
  border-left: 1px solid var(--rule-subtle);
  padding-left: 1.5rem;
}

.front-page article + article,
.front-page article + blockquote,
.front-page blockquote + article {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule-subtle);
}

.kicker {
  margin: 0 0 0.3rem;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.front-page h2,
.front-page h3 {
  margin: 0 0 0.45rem;
  line-height: 1.25;
  letter-spacing: normal;
}

.front-page h2 {
  font-size: 1.45rem;
}

.front-page h2.headline-secondary {
  font-size: 1.25rem;
}

.front-page h3 {
  font-size: 1.12rem;
}

.byline {
  margin: 0 0 0.85rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-style: italic;
  color: var(--ink-muted);
}

/* Never use fixed heights or overflow: hidden on text blocks */
.front-page p {
  margin-top: 0;
  margin-bottom: var(--paragraph-gap);
  overflow-wrap: break-word;
}

.front-page p:last-child {
  margin-bottom: 0;
}

.dropcap::first-letter {
  float: left;
  font-family: var(--font-display);
  font-size: 2.85rem;
  line-height: 0.85;
  padding: 0.15rem 0.45rem 0.05rem 0;
  color: var(--ink-primary);
}

/* Keep dropcap natural when switching to sans-serif/dyslexia fonts */
html[data-font="lexend"] .dropcap::first-letter,
html[data-font="opendyslexic"] .dropcap::first-letter,
html[data-font="atkinson"] .dropcap::first-letter {
  font-family: var(--font-reading);
  font-weight: 700;
}

.front-page blockquote {
  margin: 1.25rem 0;
  padding: 0.5rem 0 0.5rem 1rem;
  border-left: 3px solid var(--rule-color);
  font-style: italic;
}

figure {
  margin: 0 0 1rem;
}

figure img {
  display: block;
  max-width: 100%;
  height: auto;
  filter: grayscale(100%);
  border: 1px solid var(--rule-subtle);
}

figcaption {
  margin-top: 0.4rem;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  line-height: 1.4;
  letter-spacing: normal;
  word-spacing: normal;
  color: var(--ink-muted);
}

.photo-credit {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.72rem;
}

/* ==========================================================================
   9. Colophon & Responsive Breakpoints
   ========================================================================== */
.colophon {
  margin-top: 2.25rem;
  padding-top: 1.25rem;
  border-top: 3px double var(--rule-color);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--ink-muted);
}

.colophon h2 {
  font-size: 1rem;
  color: var(--ink-primary);
  margin: 1rem 0 0.4rem;
}

.colophon .credits {
  margin: 0.25rem 0 1rem;
  padding-left: 1.25rem;
}

.colophon a {
  color: var(--ink-primary);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 960px) {
  .front-page {
    grid-template-columns: 1fr;
  }

  .column + .column {
    border-left: 0;
    padding-left: 0;
    border-top: 2px solid var(--rule-subtle);
    padding-top: 1.5rem;
  }

  .control-actions {
    margin-left: 0;
  }
}

/* ==========================================================================
   TaygoTech content archive — site-specific components.
   Layered on top of the shared theme stylesheet (css/styles.css in the
   taygotech-site repo); theme tokens are used with fallbacks.
   ========================================================================== */

html { color-scheme: light; scroll-behavior: smooth; }
[hidden] { display: none !important; }

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}
a:hover { text-decoration-thickness: 2px; }
button, input { font: inherit; }
button { cursor: pointer; }

/* Keep the newspaper's serif voice on the paper; theme UI chrome stays sans. */
.paper {
  font-family: var(--font-reading, "Old Standard TT", Georgia, "Times New Roman", serif);
}

/* Masthead */
.masthead .masthead-title {
  display: block;
  margin: 0.22em 0 0.1em;
  font-family: var(--font-display, "Limelight", Georgia, serif);
  font-size: clamp(2.6rem, 6vw, 5.6rem);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: 0.01em;
  text-wrap: balance;
}
.site-home-link { text-decoration: none; }
.dateline a { text-decoration: none; }
.dateline a:hover { text-decoration: underline; }

/* Archive front page */
.archive-nav {
  margin: 0 0 0.7rem;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.archive-search {
  position: relative;
  max-width: 760px;
  margin: 1.25rem auto 2rem;
}
.archive-search label {
  display: block;
  margin-bottom: 0.35rem;
  font-family: var(--font-ui, system-ui, -apple-system, sans-serif);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.archive-search input {
  width: 100%;
  border: 1px solid var(--rule-color, #2b2a27);
  border-radius: 0;
  padding: 0.7rem 0.85rem;
  background: rgb(255 255 255 / 24%);
  color: var(--ink-primary, #1d1d1b);
}
.archive-search input::placeholder { color: var(--ink-muted, #4b4944); }
#search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1000;
  display: none;
  max-height: 420px;
  margin-top: 0.35rem;
  border: 1px solid var(--rule-color, #2b2a27);
  background: var(--bg-paper, #f4f0e6);
  box-shadow: 0 0.5rem 1rem rgb(0 0 0 / 15%);
  overflow-y: auto;
}
#search-results.show { display: block; }
.search-result {
  display: block;
  border-bottom: 1px solid var(--rule-subtle, #b5b0a5);
  padding: 0.8rem 1rem;
  text-decoration: none;
}
.search-result:last-child { border-bottom: 0; }
.search-result:hover { background: rgb(29 29 27 / 6%); }
.search-result-title { font-weight: 700; line-height: 1.25; }
.search-result-meta {
  margin-top: 0.2rem;
  color: var(--ink-muted, #4b4944);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.search-result-snippet { margin-top: 0.3rem; font-size: 0.9rem; }
.search-loading, .search-no-results {
  padding: 1rem;
  color: var(--ink-muted, #4b4944);
  font-style: italic;
  text-align: center;
}
.month-section { margin: 0 0 2rem; }
.month-section > h2 {
  margin: 0 0 0.65rem;
  border-top: 3px double var(--rule-color, #1d1d1b);
  border-bottom: 1px solid var(--rule-color, #1d1d1b);
  padding: 0.3rem 0;
  font-size: 1.35rem;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.article-list {
  line-height: var(--line-height, 1.6);
  letter-spacing: var(--letter-spacing, 0em);
  word-spacing: var(--word-spacing, 0em);
  columns: 3;
  column-gap: 2rem;
  column-rule: 1px solid var(--rule-subtle, #b5b0a5);
  margin: 0;
  padding: 0;
  list-style: none;
}
.article-item {
  break-inside: avoid;
  margin: 0;
  border-bottom: 1px solid var(--rule-subtle, #b5b0a5);
}
.article-link {
  display: block;
  padding: 0.65rem 0.35rem;
  color: inherit;
  text-decoration: none;
}
.article-link:hover { background: rgb(29 29 27 / 4%); }
.article-link time, .category-article time {
  display: block;
  margin-bottom: 0.18rem;
  color: var(--ink-muted, #4b4944);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}
.article-title {
  display: block;
  font-size: 1.03rem;
  font-weight: 700;
  line-height: 1.14;
  text-wrap: pretty;
}

/* Individual articles */
.article-paper { max-width: 1120px; }
.article-masthead .masthead-title { font-size: clamp(2rem, 4.5vw, 3.9rem); }
.article-nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
  border-top: 1px solid var(--rule-color, #1d1d1b);
  border-bottom: 1px solid var(--rule-color, #1d1d1b);
  padding: 0.65rem 0;
  font-size: 0.78rem;
  line-height: 1.25;
}
.article-nav a { text-decoration: none; }
.article-nav a:hover .nav-title { text-decoration: underline; }
.article-nav-left { text-align: left; }
.article-nav-center {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}
.article-nav-right { text-align: right; }
.nav-direction {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--ink-muted, #4b4944);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.nav-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.nav-placeholder { color: var(--ink-muted, #4b4944); font-style: italic; }
.article-header {
  max-width: 76ch;
  margin: 2.2rem auto 1.7rem;
  text-align: center;
}
.kicker, .byline {
  font-family: var(--font-ui, system-ui, -apple-system, sans-serif);
  color: var(--ink-muted, #4b4944);
  font-size: 0.72rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.kicker { margin: 0 0 0.65rem; font-weight: 700; }
.article-header h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  font-weight: 700;
  line-height: 1.04;
  text-wrap: balance;
}
.byline { margin: 0.85rem 0 0; }
.article-body {
  max-width: 74ch;
  margin: 0 auto;
  font-family: var(--font-reading, "Old Standard TT", Georgia, "Times New Roman", serif);
  font-size: calc(1.14rem * var(--text-scale, 1));
  line-height: var(--line-height, 1.58);
  letter-spacing: var(--letter-spacing, 0em);
  word-spacing: var(--word-spacing, 0em);
}
.article-body p { margin: 0 0 var(--article-para-gap, 1.15rem); text-align: justify; hyphens: auto; }
.article-body > p:first-child::first-letter {
  float: left;
  margin: 0.08em 0.09em 0 0;
  font-family: var(--font-display, "Limelight", Georgia, serif);
  font-size: 3.5em;
  line-height: 0.76;
}
/* Keep the dropcap natural when switching to sans-serif/dyslexia fonts */
html[data-font="lexend"] .article-body > p:first-child::first-letter,
html[data-font="opendyslexic"] .article-body > p:first-child::first-letter,
html[data-font="atkinson"] .article-body > p:first-child::first-letter {
  font-family: var(--font-reading, "Old Standard TT", Georgia, serif);
  font-weight: 700;
}
.article-body h1, .article-body h2, .article-body h3,
.article-body h4, .article-body h5, .article-body h6 {
  margin: 2.2rem 0 0.8rem;
  font-weight: 700;
  line-height: 1.12;
  text-wrap: balance;
}
.article-body h1 { font-size: 2rem; }
.article-body h2 {
  border-top: 3px double var(--rule-color, #1d1d1b);
  border-bottom: 1px solid var(--rule-color, #1d1d1b);
  padding: 0.35rem 0;
  font-size: 1.55rem;
}
.article-body h3 { font-size: 1.3rem; }
.article-body h4 { font-size: 1.12rem; }
.article-body a { overflow-wrap: anywhere; }
.article-body ul, .article-body ol {
  margin: 0 0 1.4rem;
  padding-left: 1.5rem;
}
.article-body li { margin-bottom: 0.35rem; padding-left: 0.15rem; }
.article-body blockquote {
  margin: 1.6rem 0;
  border-top: 3px double var(--rule-color, #1d1d1b);
  border-bottom: 3px double var(--rule-color, #1d1d1b);
  padding: 0.85rem 0.35rem;
  font-size: 1.3rem;
  font-style: italic;
  line-height: 1.3;
  text-align: center;
}
.article-body code {
  border: 1px solid var(--rule-subtle, #b5b0a5);
  padding: 0.08rem 0.28rem;
  background: rgb(29 29 27 / 5%);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.86em;
}
.article-body pre {
  max-width: 100%;
  margin: 1.5rem 0;
  border: 1px solid var(--rule-color, #1d1d1b);
  padding: 1rem;
  background: var(--bg-toolbar, #e8e3d8);
  overflow-x: auto;
}
.article-body pre code { border: 0; padding: 0; background: none; }
.article-body table {
  display: block;
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
  font-size: 0.92rem;
  overflow-x: auto;
}
.article-body th, .article-body td {
  border: 1px solid var(--rule-color, #78756d);
  padding: 0.5rem 0.65rem;
  text-align: left;
  vertical-align: top;
}
.article-body th { background: var(--bg-toolbar, #e8e3d8); }
.article-body hr {
  margin: 2rem 0;
  border: 0;
  border-top: 3px double var(--rule-color, #1d1d1b);
}
.article-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1rem auto;
  filter: grayscale(1) contrast(0.97);
}

/* Category index */
.category-section { margin: 1.5rem 0 2rem; }
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 3px double var(--rule-color, #1d1d1b);
  border-bottom: 1px solid var(--rule-color, #1d1d1b);
  padding: 0.35rem 0;
}
.section-heading h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-transform: uppercase;
}
.toggle-all {
  flex: none;
  border: 1px solid var(--rule-color, #1d1d1b);
  border-radius: 0;
  padding: 0.28rem 0.65rem;
  background: var(--ink-primary, #1d1d1b);
  color: var(--bg-paper, #f4f0e6);
  font-family: var(--font-ui, system-ui, sans-serif);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.toggle-all:hover { background: transparent; color: var(--ink-primary, #1d1d1b); }
.accordion { border-bottom: 1px solid var(--rule-subtle, #b5b0a5); }
.accordion-header {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 0;
  border-radius: 0;
  padding: 0.75rem 0.35rem;
  background: transparent;
  color: var(--ink-primary, #1d1d1b);
  text-align: left;
}
.accordion-header:hover { background: rgb(29 29 27 / 4%); }
.accordion-heading { font-size: 1.1rem; font-weight: 700; }
.accordion-count {
  margin-left: 0.5rem;
  color: var(--ink-muted, #4b4944);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.06em;
}
.accordion-arrow {
  color: var(--ink-muted, #4b4944);
  font-size: 0.75rem;
  transition: transform 150ms ease;
}
.accordion.open > .accordion-header .accordion-arrow { transform: rotate(90deg); }
.accordion-body { display: none; padding: 0 0.35rem 0.85rem; }
.accordion.open > .accordion-body { display: block; }
.category-articles { margin: 0; padding: 0; list-style: none; }
.category-article { border-top: 1px solid var(--rule-subtle, #b5b0a5); }
.category-article a {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.55rem 0.25rem;
  text-decoration: none;
}
.category-article a:hover .article-title { text-decoration: underline; }
.category-article time { padding-top: 0.15rem; }
.category-article .article-title { font-size: 1rem; font-weight: 400; line-height: 1.25; }
.accordion-subcategory { margin: 0.35rem 0 0.35rem 1rem; border: 1px solid var(--rule-subtle, #b5b0a5); }
.accordion-subcategory .accordion-header { padding: 0.5rem 0.65rem; }
.accordion-subcategory .accordion-heading { font-size: 1rem; }
.accordion-subcategory .accordion-body { padding: 0 0.65rem 0.55rem; }

/* Responsive breakpoints */
@media (max-width: 1050px) {
  .article-list { columns: 2; }
}
@media (max-width: 759.98px) {
  .paper {
    margin: 0;
    border-width: 0;
    box-shadow: none;
  }
  .edition-line, .dateline { flex-wrap: wrap; justify-content: center; text-align: center; }
  .edition-line span:nth-child(2) { display: none; }
  .masthead .masthead-title { font-size: clamp(2.35rem, 12vw, 4rem); }
  .article-masthead .masthead-title { font-size: clamp(2rem, 10vw, 3rem); }
  .article-list { columns: 1; column-rule: 0; }
  .article-title { font-size: 1.08rem; }
  .article-nav { grid-template-columns: 1fr 1fr; gap: 0.65rem; }
  .article-nav-center { grid-column: 1 / -1; grid-row: 1; }
  .article-nav-left, .article-nav-right { grid-row: 2; }
  .nav-title { -webkit-line-clamp: 3; }
  .article-header { margin-top: 1.5rem; }
  .article-header h1 { font-size: clamp(1.85rem, 8vw, 2.6rem); }
  .article-body { font-size: 1.1rem; }
  .article-body p { text-align: left; hyphens: none; }
  .section-heading { align-items: flex-start; }
  .section-heading h2 { font-size: 1.1rem; }
  .category-article a { grid-template-columns: 1fr; gap: 0; }
}
@media print {
  body { background: white; font-size: 10.5pt; }
  .paper {
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }
  .skip-link, .article-nav, .archive-search, .toggle-all, .archive-nav { display: none; }
  .article-list { columns: 2; }
  .article-body { max-width: 72ch; font-size: 11pt; }
  .article-body a { text-decoration: none; }
  .accordion-body { display: block; }
  .accordion { break-inside: avoid; }
}

/* ==========================================================================
   11. Text Size Steps (data-size on <html>, set by the reading toolbar)
   ========================================================================== */
html[data-size="-2"] { --text-scale: 0.85; }
html[data-size="-1"] { --text-scale: 0.92; }
html[data-size="0"]  { --text-scale: 1; }
html[data-size="1"]  { --text-scale: 1.12; }
html[data-size="2"]  { --text-scale: 1.25; }
html[data-size="3"]  { --text-scale: 1.4; }

/* ==========================================================================
   12. Light / Dark / System Theme (data-theme on <html>)
   Placed last so these colours win over the tint presets above.
   ========================================================================== */
html[data-theme="dark"] {
  --bg-page: #1a1916;
  --bg-paper: #22211d;
  --bg-toolbar: #2a2824;
  --bg-control: #2e2c28;
  --bg-active: #ece8df;
  --ink-primary: #ece8df;
  --ink-muted: #b5b0a5;
  --ink-on-active: #1a1916;
  --rule-color: #cfc8ba;
  --rule-subtle: #4a463e;
  --focus-ring: #7fb6e6;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --bg-page: #1a1916;
    --bg-paper: #22211d;
    --bg-toolbar: #2a2824;
    --bg-control: #2e2c28;
    --bg-active: #ece8df;
    --ink-primary: #ece8df;
    --ink-muted: #b5b0a5;
    --ink-on-active: #1a1916;
    --rule-color: #cfc8ba;
    --rule-subtle: #4a463e;
    --focus-ring: #7fb6e6;
    color-scheme: dark;
  }
}

/* ==========================================================================
   15. Compact Article Navigation and Header (placed last to override section 8)
   ========================================================================== */
.article-nav {
  gap: 0.6rem;
  margin: 0.35rem 0;
  padding: 0.3rem 0;
}

.article-nav .nav-direction {
  display: none;
}

.article-nav .nav-title {
  -webkit-line-clamp: 1;
  font-size: 0.8rem;
  line-height: 1.25;
}

.article-nav-center a {
  font-size: 0.8rem;
}

.article-header {
  margin: 0.9rem auto 0.9rem;
}

/* Article title: half the previous size, two lines maximum with an ellipsis.
   The full title is set as hover text by app.js (section 2b). */
.article-header h1 {
  font-size: clamp(1rem, 2vw, 1.8rem);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 759.98px) {
  .article-header h1 {
    font-size: clamp(0.925rem, 4vw, 1.3rem);
  }
}
