/* Final public-site layer. Load after all existing public stylesheets.
   Theme hook: html[data-theme="light" | "dark"].
   Header hook: .theme-control > select, or select.theme-select.
   Motion hook: add .reveal-in only when a node enters the viewport.
   The private editor is intentionally outside this stylesheet's scope. */

:root {
  color-scheme: light;
  --paper: #f8f9fc;
  --ink: #1b2435;
  --muted: #59667d;
  --blue: #314ac1;
  --wash: #eef1f8;
  --line: #dce2ee;
  --line-strong: #bdc8dd;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-hover: #f0f3fc;
  --accent-soft: #e9eefc;
  --on-blue: #ffffff;
  --focus: #526de0;
  --mat: #f0f2f7;
  --figure-mat: #ffffff;
  --chart-grid: #dce2ee;
  --chart-axis: #94a1b8;
  --chart-muted: #59667d;
  --chart-empty: #e7ebf3;
  --chart-wash: #e9eefc;
  --chart-secondary: #596f82;
  --heat-strong-ink: var(--on-blue);
  --rainbow-lightness: 43%;
  --github-0: #e7ebf3;
  --github-1: #d1dbf6;
  --github-2: #9aafe7;
  --github-3: #627ed2;
  --github-4: #314ac1;
  --header-bg: rgb(248 249 252 / 92%);
  --edge-glow: rgb(91 119 229 / 6%);
  --hero-glow: rgb(91 119 229 / 7%);
  --shadow-soft: 0 12px 35px rgb(29 47 87 / 4%);
  --shadow-dialog: 0 24px 90px rgb(13 26 53 / 22%);
  --backdrop: rgb(14 22 37 / 62%);
  --motion-fast: 180ms;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #111722;
  --ink: #e9edf5;
  --muted: #aeb9cc;
  --blue: #a8b9ff;
  --wash: #1a2332;
  --line: #303c51;
  --line-strong: #596b88;
  --surface: #18202e;
  --surface-raised: #1d2738;
  --surface-hover: #222f45;
  --accent-soft: #263454;
  --on-blue: #111722;
  --focus: #b8c7ff;
  --chart-grid: #354258;
  --chart-axis: #7f90ae;
  --chart-muted: #aeb9cc;
  --chart-empty: #263246;
  --chart-wash: #263654;
  --chart-secondary: #a6becc;
  --heat-strong-ink: var(--on-blue);
  --rainbow-lightness: 68%;
  --github-0: #263246;
  --github-1: #33426e;
  --github-2: #576ba4;
  --github-3: #8ca4e1;
  --github-4: #a8b9ff;
  --header-bg: rgb(17 23 34 / 92%);
  --edge-glow: rgb(110 139 245 / 5%);
  --hero-glow: rgb(110 139 245 / 7%);
  --shadow-soft: 0 12px 35px rgb(0 0 0 / 12%);
  --shadow-dialog: 0 24px 90px rgb(0 0 0 / 50%);
  --backdrop: rgb(4 9 17 / 76%);
}

/* System mode also works before or without the theme script. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --paper: #111722;
    --ink: #e9edf5;
    --muted: #aeb9cc;
    --blue: #a8b9ff;
    --wash: #1a2332;
    --line: #303c51;
    --line-strong: #596b88;
    --surface: #18202e;
    --surface-raised: #1d2738;
    --surface-hover: #222f45;
    --accent-soft: #263454;
    --on-blue: #111722;
    --focus: #b8c7ff;
    --chart-grid: #354258;
    --chart-axis: #7f90ae;
    --chart-muted: #aeb9cc;
    --chart-empty: #263246;
  --chart-wash: #263654;
  --chart-secondary: #a6becc;
  --heat-strong-ink: var(--on-blue);
  --rainbow-lightness: 68%;
  --github-0: #263246;
  --github-1: #33426e;
  --github-2: #576ba4;
  --github-3: #8ca4e1;
  --github-4: #a8b9ff;
    --header-bg: rgb(17 23 34 / 92%);
    --edge-glow: rgb(110 139 245 / 5%);
    --hero-glow: rgb(110 139 245 / 7%);
    --shadow-soft: 0 12px 35px rgb(0 0 0 / 12%);
    --shadow-dialog: 0 24px 90px rgb(0 0 0 / 50%);
    --backdrop: rgb(4 9 17 / 76%);
  }
}

html { scroll-padding-top: calc(var(--header-height, 80px) + 20px); }
body {
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse 22rem 38rem at 0 18rem, var(--edge-glow), transparent 74%),
    radial-gradient(ellipse 22rem 38rem at 100% 30rem, var(--edge-glow), transparent 74%);
  -webkit-font-smoothing: antialiased;
}
::selection { color: var(--ink); background: var(--accent-soft); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}
button, input, select, textarea { color: var(--ink); }
input, select, textarea { accent-color: var(--blue); }
.skip { background: var(--surface-raised); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; }
.skip:focus { top: 12px; }

body > header {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  max-width: none;
  padding: 15px max(48px, calc((100vw - 1204px) / 2));
  gap: 24px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
body > header .wordmark { min-height: 44px; display: inline-flex; align-items: center; }
body > header nav { gap: 23px; }
body > header nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 0 6px;
  border-bottom: 2px solid transparent;
  transition: color var(--motion-fast), border-color var(--motion-fast);
}
body > header nav a:hover,
body > header nav a[aria-current="page"] { color: var(--blue); border-bottom-color: var(--blue); }
body > header .contact { display: inline-flex; align-items: center; min-height: 44px; padding-left: 22px; }
.theme-control { display: inline-flex; align-items: center; flex: 0 0 auto; }
.theme-control select, select.theme-select {
  min-height: 44px;
  max-width: 135px;
  padding: 9px 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  font: 14px/1.4 var(--sans);
  cursor: pointer;
}
.theme-control select:hover, select.theme-select:hover { border-color: var(--line-strong); }
.visually-hidden, .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

body > main { width: calc(100% - 96px); max-width: 1204px; margin-inline: auto; padding-bottom: 84px; }
.hero { padding: 76px 0 64px; background: radial-gradient(ellipse at 88% 25%, var(--hero-glow), transparent 68%); }
.hero h1 { max-width: 1050px; font-size: clamp(43px, 5.5vw, 76px); line-height: 1.12; letter-spacing: -.025em; margin: 24px 0 31px; overflow-wrap: break-word; }
.hero-bottom { gap: 48px; }
.hero-bottom p { max-width: 610px; font-size: 19px; line-height: 1.75; }
.eyebrow { font-size: 12px; line-height: 1.65; letter-spacing: .12em; }
.page-head { padding: 67px 0 46px; }
.page-head h1 { font-size: clamp(43px, 5.4vw, 72px); line-height: 1.12; letter-spacing: -.025em; }
.page-head p { max-width: 700px; font-size: 19px; line-height: 1.8; }
.text-links { flex-wrap: wrap; gap: 12px 26px; white-space: normal; }
.text-links a, .underlined { display: inline-flex; align-items: center; min-height: 44px; padding-bottom: 2px; }
.section-heading { margin: 65px 0 28px; gap: 24px; }
.section-heading h2 { font-size: clamp(29px, 3.2vw, 38px); line-height: 1.2; }
.section-heading > a { flex-shrink: 0; }
.featured { padding: 42px; gap: 42px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-soft); }
.feature-copy h2 { font-size: clamp(30px, 3.5vw, 40px); line-height: 1.22; }
.feature-copy p { line-height: 1.8; }
.featured .original-figure { background: none; }
.research-grid article { padding-top: 30px; padding-bottom: 24px; }
.research-grid h3 { font-size: 21px; }
.research-grid p, .writing-teasers p { line-height: 1.8; }
.writing-teasers { gap: 28px; }
.writing-teasers > a { padding-top: 25px; }
.writing-teasers h3 { margin-top: 15px; font-size: 21px; }
.news { margin-top: 70px; }
.news-row h3 { line-height: 1.55; }
body > footer { max-width: 1204px; width: calc(100% - 96px); padding: 28px 0; margin-inline: auto; gap: 18px; align-items: center; font-size: 13px; }
body > footer a { display: inline-flex; align-items: center; min-height: 44px; }

.toolbar input, .toolbar select, .quote-controls input, .quote-controls select,
.plot-period select { min-height: 44px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.quiet-button { min-height: 44px; padding: 9px 16px; background: var(--surface); color: var(--blue); border-color: var(--line); border-radius: 8px; transition: background var(--motion-fast), border-color var(--motion-fast); }
.quiet-button:hover { background: var(--surface-hover); border-color: var(--line-strong); }
.topic-tabs { gap: 8px 28px; padding-bottom: 2px; }
.topic-tabs button { min-height: 44px; padding: 12px 0; }
.series-intro, .publication-detail, .essay-contents { background: var(--wash); border-radius: 0 12px 12px 0; }
.series-intro { padding: 30px 34px; }
.publication { padding: 32px 0; }
.publication h2 { line-height: 1.5; }
.publication summary, .essay-contents summary, .quote-provenance summary, .rainbow-range summary { min-height: 44px; display: list-item; align-content: center; }
.in-preparation { padding: 28px 32px; background: var(--surface); border-radius: 12px; }
.essay-row { padding: 31px 0; }
.essay-row h2 { font-size: clamp(28px, 3vw, 34px); line-height: 1.26; }
.essay-row p { line-height: 1.8; }
.essay { max-width: 760px; padding-top: 42px; }
.essay h1 { font-size: clamp(38px, 4.8vw, 62px); line-height: 1.17; letter-spacing: -.02em; }
.essay .deck { font-size: 22px; line-height: 1.65; }
.essay section { scroll-margin-top: 16px; margin: 40px 0; }
.essay section p { font-size: 18px; line-height: 1.9; }
.back-link, .reading-nav a { min-height: 44px; display: inline-flex; align-items: center; }
.essay-contents nav { gap: 3px; }
.essay-contents nav a { min-height: 44px; display: flex; align-items: center; }
.original-figure { padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.original-figure > a { display: block; background: var(--figure-mat); border-radius: 6px; }
.original-figure img { background: var(--figure-mat); border-radius: 6px; }
.original-figure figcaption { color: var(--muted); font-size: 14px; line-height: 1.75; }
.concept-sequence span { border-bottom-color: var(--line); }
.model-key, .slider-label { flex-wrap: wrap; }
.model-key i { flex-shrink: 0; }
.slider-label input { min-height: 44px; }
.takeaway { padding: 13px 26px; font-size: 28px; line-height: 1.55; }
.about-layout { gap: 74px; }
.about-text > p { line-height: 1.85; }

.art-grid { gap: 36px 28px; }
.art-image { background: var(--mat); border: 1px solid rgb(27 36 53 / 7%); border-radius: 10px; }
.art-image img { transition: transform 220ms ease; }
.art-card:hover img { transform: scale(1.018); }
.art-card:focus-visible { border-radius: 10px; }
.art-label { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; align-items: start; margin-top: 15px; font-size: 15px; }
.art-label > span:first-child { grid-column: 1; grid-row: 1; }
.art-label > i { grid-column: 2; grid-row: 1; font-size: 12px; margin-top: 2px; }
.art-label > .art-context { grid-column: 1 / -1; margin-top: 2px; font-size: 14px; line-height: 1.65; max-height: 4.95em; }
.art-teasers img { background: var(--mat); border-radius: 10px; }
.art-teasers span { font-size: 15px; margin-top: 14px; }
.film-card video { border-radius: 10px; }
.art-dialog { color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0 28px 22px; box-shadow: var(--shadow-dialog); }
.art-dialog::backdrop, .literary-dialog::backdrop, .quote-reader::backdrop { background: var(--backdrop); }
.art-dialog figure img { background: var(--mat); border-radius: 8px; }
.art-dialog figcaption span { color: var(--muted); font-size: 14px; line-height: 1.7; }
.viewer-toolbar button, .viewer-bottom button { min-height: 44px; }
.viewer-bottom button { padding: 10px 8px; }

.literary-intro p { color: var(--muted); line-height: 1.85; }
.literary-card { background: var(--surface); border-color: var(--line); border-radius: 12px; padding: 32px; gap: 22px; transition: background var(--motion-fast), border-color var(--motion-fast); }
.literary-card:hover, .literary-card:focus-visible { background: var(--surface-hover); border-color: var(--line-strong); }
.literary-preview { font-size: 21px; line-height: 1.8; }
.literary-read { min-height: 44px; align-items: center; }
.literary-dialog { background: var(--surface); color: var(--ink); border-color: var(--line); border-radius: 14px; box-shadow: var(--shadow-dialog); padding: 24px 46px 32px; }
.literary-full { font-size: 22px; line-height: 1.9; }
.literary-reader-nav button { min-height: 44px; padding: 10px 8px; }
.literary-gates > a { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 30px; }
.thought-dates { background: var(--surface); border-color: var(--line); border-radius: 12px; }
.thought-year button { width: 44px; height: 44px; color: var(--blue); background: var(--accent-soft); border-color: var(--line); }
.thought-year button:hover, .thought-year button:focus-visible { color: var(--on-blue); background: var(--blue); }

.quote-explorer .quote-visual { background: var(--surface); border-color: var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow-soft); }
.quote-controls label { min-width: 0; }
.theme-chips { gap: 8px; }
.theme-chips button { min-height: 44px; padding: 8px 14px; border-radius: 8px; background: var(--surface); color: var(--muted); border-color: var(--line); }
.theme-chips button:hover { background: var(--surface-hover); color: var(--ink); }
.theme-chips button[aria-pressed="true"] { color: var(--on-blue); background: var(--blue); border-color: var(--blue); }
.results-head { gap: 15px; }
.results-head button, .quote-tags button, .thread-legend button, .inline-action, .quote-read-link { min-height: 44px; }
.quote-card { padding: 32px 0; }
.quote-card blockquote, .quote-card.long-quote blockquote { line-height: 1.8; }
.selected-quote { background: var(--surface); }
.close-selection { width: 44px; height: 44px; }
.bar-chart button, .author-bars button { min-height: 44px; color: var(--ink); }
.quote-heatmap td span { color: var(--muted); }
.quote-heatmap th button, .quote-heatmap td button { min-height: 44px; }
.quote-heatmap td button { min-width: 44px; }
.quote-heatmap thead th, .quote-heatmap tbody th { background: var(--surface); }
.quote-visual svg text { fill: var(--chart-muted); }
.quote-node:hover, .quote-node:focus { stroke: var(--surface); }
.rainbow-selects select { background: var(--surface-raised); min-height: 44px; border-radius: 8px; }
.rainbow-zoom-button, .rainbow-legend button { min-height: 44px; }
.rainbow-legend button { padding: 8px 11px; border-radius: 7px; }
.rainbow-legend button:hover, .rainbow-legend button:focus-visible { background: var(--surface-hover); border-color: var(--line-strong); }
.rainbow-range input { min-height: 44px; }
.quote-reader { background: var(--surface); color: var(--ink); border-color: var(--line); border-radius: 14px; box-shadow: var(--shadow-dialog); }
.quote-reader-bar { background: var(--surface); }
.quote-reader .quote-tags button, .quote-reader-nav button { min-height: 44px; }
.quote-explorer button:focus-visible, .quote-explorer select:focus-visible,
.quote-explorer input:focus-visible, .quote-explorer summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }

.github-projects { gap: 24px; }
.github-project { background: var(--surface); border-color: var(--line); border-radius: 12px; padding: 27px; transition: background var(--motion-fast), border-color var(--motion-fast); }
.github-project:hover, .github-project:focus-visible { background: var(--surface-hover); border-color: var(--line-strong); }
.github-project h3 { font-size: 28px; }
.github-calendar-heading a { min-height: 44px; display: inline-flex; align-items: center; }
.github-calendar-scroll { background: var(--surface); border-color: var(--line); border-radius: 10px; padding: 15px 18px; }
.github-calendar-scroll svg text { fill: var(--muted); }
.github-calendar-footer { line-height: 1.7; }

/* Content is visible at rest. This animation starts only after a trigger.
   Never establish a transformed ancestor around a native dialog. */
.reveal-in:not(dialog):not(:has(dialog)) { animation: editorial-reveal 340ms ease-out both; animation-delay: var(--reveal-delay, 0ms); }
@keyframes editorial-reveal {
  from { opacity: .65; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1080px) {
  body > header { gap: 20px; }
  body > header nav { gap: 20px; }
  body > header .contact { display: none; }
  .about-layout { gap: 44px; }
}
@media (max-width: 850px) {
  body > header { padding-inline: 26px; }
  body > main, body > footer { width: calc(100% - 52px); }
  .hero { padding-top: 56px; }
  .hero-bottom p { font-size: 18px; }
  .featured { padding: 30px; gap: 28px; }
}
@media (max-width: 760px) {
  html { scroll-padding-top: calc(var(--header-height, 120px) + 20px); }
  body > header { flex-wrap: wrap; justify-content: space-between; gap: 8px 18px; padding-block: 10px; }
  body > header .wordmark { margin-right: auto; }
  body > header .theme-control { margin-left: auto; }
  body > header nav { order: 3; flex: 1 1 100%; width: 100%; margin: 0; justify-content: space-between; gap: 12px; font-size: 13px; }
  body > header nav a { justify-content: center; }
  .theme-control select, select.theme-select { max-width: 125px; }
  .page-head { padding: 45px 0 31px; }
  .page-head p { font-size: 17px; }
  .section-heading { margin-top: 48px; }
  .section-heading h2 { font-size: 30px; }
  .essay section { scroll-margin-top: 16px; }
  .essay .deck { font-size: 20px; }
  .about-layout { gap: 32px; }
  .art-label { grid-template-columns: 1fr; gap: 4px; }
  .art-label > i { grid-column: 1; grid-row: 2; margin-top: 0; }
  .art-label > .art-context { grid-column: 1; grid-row: 3; }
  .literary-card { padding: 26px; }
  .literary-dialog { padding: 18px 25px 28px; }
  .literary-full { font-size: 20px; line-height: 1.85; }
  .github-project { padding: 24px; }
}
@media (max-width: 600px) {
  body > header { padding-inline: 20px; }
  body > main, body > footer { width: calc(100% - 40px); }
  body > main { padding-bottom: 56px; }
  body > footer { padding-block: 22px; flex-wrap: wrap; gap: 6px 18px; }
  .hero { padding: 45px 0; }
  .hero h1 { font-size: clamp(36px, 10.5vw, 49px); line-height: 1.2; }
  .hero-bottom p { font-size: 17px; }
  .featured { grid-template-columns: 1fr; border-radius: 12px; padding: 25px 22px; }
  .feature-copy h2 { font-size: 32px; }
  .section-heading { gap: 16px; }
  .section-heading h2 { font-size: 28px; }
  .section-heading > a { font-size: 13px; }
  .topic-tabs { gap: 4px 22px; }
  .series-intro, .in-preparation { padding: 24px; }
  .essay { padding-top: 28px; }
  .essay h1 { font-size: 38px; }
  .essay section p { font-size: 17px; line-height: 1.85; }
  .essay-row h2 { font-size: 29px; }
  .original-figure { padding: 10px; }
  .takeaway { font-size: 25px; padding-inline: 20px; }
  .art-grid { gap: 28px 16px; }
  .art-label { font-size: 14px; }
  .art-label > .art-context { font-size: 13px; }
  .art-dialog { width: calc(100vw - 24px); padding: 0 16px 18px; }
  .quote-explorer .quote-visual { padding: 22px 14px; }
  .quote-explorer .quote-card blockquote { font-size: 19px; }
  .quote-reader { padding-inline: 22px; }
  .rainbow-legend button { padding: 8px; font-size: 12px; }
  .results-head { align-items: center; }
}
@media (max-width: 380px) {
  body > header nav { gap: 8px; font-size: 12px; }
  .hero h1 { font-size: 35px; }
  .section-heading { flex-wrap: wrap; gap: 4px 16px; }
  .theme-control select, select.theme-select { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
  .reveal-in:not(dialog):not(:has(dialog)) { opacity: 1; transform: none; }
  .art-card:hover img { transform: none; }
}

.reading-progress { position: absolute; inset: auto 0 -1px; height: 2px; pointer-events: none; overflow: hidden; }
.reading-progress span { display: block; width: 100%; height: 100%; background: var(--blue); transform-origin: left center; transform: scaleX(0); }
@media (max-width: 340px) { body > header nav { flex-wrap: wrap; justify-content: flex-start; gap: 0 18px; } }
