/* ===================================================
   UVSM Publications — Site Stylesheet
   Adapted from Essay Voice One canonical stylesheet
   =================================================== */

/* ===  Web Fonts  === */

@font-face {
  font-family: 'TeX Gyre Pagella';
  src: url('/fonts/TeXGyrePagella-Regular.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'TeX Gyre Pagella';
  src: url('/fonts/TeXGyrePagella-Italic.woff2') format('woff2');
  font-weight: normal;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'TeX Gyre Pagella';
  src: url('/fonts/TeXGyrePagella-Bold.woff2') format('woff2');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'TeX Gyre Pagella';
  src: url('/fonts/TeXGyrePagella-BoldItalic.woff2') format('woff2');
  font-weight: bold;
  font-style: italic;
  font-display: swap;
}

/* ===  Color Variables  === */

:root {
  --bg:              #faf9f6;
  --bg-alt:          #f7f6f3;
  --bg-box:          #fafafa;
  --bg-box-green:    #f5faf6;
  --bg-box-grey:     #fcfcfc;
  --bg-header:       #f0efec;
  --text:            #1a1a1a;
  --text-mid:        #333;
  --text-muted:      #555;
  --text-faint:      #666;
  --text-nav:        #444;
  --border:          #ccc;
  --border-dark:     #aaa;
  --border-darker:   #888;
  --border-faint:    #eee;
  --border-ddd:      #ddd;
  --link-underline:  #888;
  --blockquote-bg:   #f7f6f3;
  --blockquote-border: #bbb;
  --abstract-border: #666;
  --method-border:   #3a7;
  --sidebar-border:  #aaa;
  --example-border:  #ddd;
  --example-good:    #3a7;
  --example-bad:     #c55;
  --pattern-border:  #888;
  --pattern-bg:      #f9f8f5;
  --code-bg:         #f4f4f4;
  --glyph-stroke:    black;
  --toggle-bg:       #ddd;
  --toggle-knob:     #fff;
  --placeholder-bg:  #fff3cd;
  --placeholder-border: #d4a017;
  --placeholder-text: #856404;
}

[data-theme="dark"] {
  --bg:              #1a1a1a;
  --bg-alt:          #242424;
  --bg-box:          #222;
  --bg-box-green:    #1e2a1f;
  --bg-box-grey:     #252525;
  --bg-header:       #2a2a2a;
  --text:            #d8d4cf;
  --text-mid:        #bbb;
  --text-muted:      #999;
  --text-faint:      #888;
  --text-nav:        #aaa;
  --border:          #444;
  --border-dark:     #555;
  --border-darker:   #777;
  --border-faint:    #333;
  --border-ddd:      #444;
  --link-underline:  #666;
  --blockquote-bg:   #242424;
  --blockquote-border: #555;
  --abstract-border: #888;
  --method-border:   #2a8a4a;
  --sidebar-border:  #666;
  --example-border:  #444;
  --example-good:    #2a8a4a;
  --example-bad:     #b44;
  --pattern-border:  #666;
  --pattern-bg:      #252525;
  --code-bg:         #2a2a2a;
  --glyph-stroke:    #d8d4cf;
  --toggle-bg:       #555;
  --toggle-knob:     #1a1a1a;
  --placeholder-bg:  #3a3020;
  --placeholder-border: #8a7030;
  --placeholder-text: #d4b060;
}

/* ===  Global Box Model  === */

*, *::before, *::after {
  box-sizing: border-box;
}

/* ===  Skip Link (accessibility)  === */

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--bg);
  color: var(--text);
  padding: 0.4em 1em;
  z-index: 200;
  font-size: 0.85em;
  text-decoration: none;
  border: 1px solid var(--border);
}

.skip-link:focus {
  top: 0;
}

/* ===  Focus-visible (keyboard accessibility)  === */

:focus-visible {
  outline: 2px solid var(--text-muted);
  outline-offset: 2px;
}

button:focus-visible,
.cite-btn:focus-visible,
.theme-toggle:focus-visible,
.search-btn:focus-visible,
.print-pdf-btn:focus-visible {
  outline: 2px solid var(--text-muted);
  outline-offset: 2px;
}

a:focus:not(:focus-visible) {
  outline: none;
}

/* ===  Screen: Wide (desktop / tablet landscape)  === */

@media screen and (min-width: 576px) {
  html {
    font-size: 15px;
  }
  body {
    max-width: 5in;
    margin: 1in auto;
    padding: 0 0.5in;
  }
}

/* ===  Screen: Narrow (portrait phone, < 576px)  === */

@media screen and (max-width: 575px) {
  html {
    font-size: 15px;
  }
  body {
    margin: 0.4em;
    padding: 0.3em;
  }
  p {
    text-indent: 1em;
  }
  blockquote {
    margin-left: 0.3em;
    margin-right: 0.3em;
    padding: 0.4em 0.6em;
  }
  .abstract,
  .method-note,
  .sidebar {
    margin-left: 0;
    margin-right: 0;
    padding: 0.4em 0.6em;
  }
  .example,
  .elimination {
    margin-left: 0;
    margin-right: 0;
    padding: 0.4em 0.6em;
  }
  .pattern {
    margin-left: 0;
    margin-right: 0;
    padding: 0.4em 0.6em;
  }
  .concept-list {
    padding: 0.4em 0.6em;
  }
  .concept-list ul {
    padding-left: 1em;
  }
  .references p {
    text-indent: -1.2em;
    padding-left: 1.2em;
  }
  .index p {
    text-indent: -1em;
    padding-left: 1em;
  }
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  pre {
    font-size: 0.8em;
    padding: 0.5em;
  }
  .glyph svg,
  .glyph-wrap svg {
    width: 56px;
    height: 56px;
  }
  .site-header nav {
    flex-direction: column;
    gap: 0.3em;
  }
  h1 {
    font-size: 1.4em;
  }
  h2 {
    font-size: 1.15em;
  }
}

/* ===  Base Typography  === */

body {
  font-family: 'TeX Gyre Pagella', Palatino, 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
  line-height: 1.56;
  color: var(--text);
  background: var(--bg);
  -webkit-hyphens: auto;
  hyphens: auto;
  text-rendering: optimizeLegibility;
  transition: background 0.2s ease, color 0.2s ease;
}

/* ===  Headings  === */

h1 {
  font-size: 1.65em;
  line-height: 1.2;
  margin: 1.8em 0 0.2em;
  text-align: center;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.25em;
  margin: 2em 0 0.6em;
  line-height: 1.25;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.2em;
}

h3 {
  font-size: 1.08em;
  margin: 1.5em 0 0.4em;
  line-height: 1.3;
}

h4 {
  font-size: 1em;
  font-weight: bold;
  font-style: italic;
  margin: 1.2em 0 0.3em;
}

.pub-landing h4 {
  font-size: 0.98em;
  font-style: normal;
}

/* ===  Hyphenation Control  === */

.center,
p.center,
h1,
h1.part-title,
.subtitle,
.part-label,
.part-number,
.chapter-label,
.chapter-subtitle,
.chapter-header,
.title-page,
.title-page p {
  -webkit-hyphens: manual;
  hyphens: manual;
}

/* ===  Paragraphs  === */

p {
  margin: 0.1em 0;
  text-indent: 1.5em;
  text-align: justify;
}

.pub-landing p {
  margin: 0.6em 0;
  text-indent: 0;
}

/* ===  Links  === */

a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration-color: var(--text);
}

/* ===  Block Quotes  === */

blockquote {
  margin: 1em 1.5em;
  padding: 0.6em 1em;
  border-left: 3px solid var(--blockquote-border);
  background: var(--blockquote-bg);
  font-size: 0.94em;
}

blockquote p {
  margin: 0.3em 0;
  text-indent: 0;
}

/* ===  Abstract  === */

.abstract {
  border-left: 3px solid var(--abstract-border);
  padding: 0.5em 1em;
  margin: 1.5em 0;
  background: var(--bg-box);
}

.abstract h3 {
  font-size: 0.95em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0;
}

.abstract p {
  font-size: 0.94em;
  margin: 0.3em 0;
  text-indent: 0;
}

/* ===  Method Note (green border)  === */

.method-note {
  border-left: 3px solid var(--method-border);
  padding: 0.5em 1em;
  margin: 1em 0;
  background: var(--bg-box-green);
  font-size: 0.94em;
}

.method-note p {
  margin: 0.3em 0;
  text-indent: 0;
}

.method-note-title {
  font-weight: bold;
  font-size: 0.95em;
  margin-bottom: 0.2em;
}

/* ===  Sidebar (grey border)  === */

.sidebar {
  border-left: 3px solid var(--sidebar-border);
  padding: 0.5em 1em;
  margin: 1em 0;
  background: var(--bg-box-grey);
  font-size: 0.94em;
}

.sidebar p {
  margin: 0.3em 0;
  text-indent: 0;
}

.sidebar-title {
  font-weight: bold;
  font-size: 0.95em;
  margin-bottom: 0.2em;
}

/* ===  Key Concepts Box  === */

.concept-list {
  border: 1px solid var(--border);
  padding: 0.5em 1em;
  margin: 1.5em 0;
  background: var(--bg-box);
}

.concept-list h3 {
  font-size: 0.95em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0;
}

.concept-list ul {
  margin: 0.3em 0;
  padding-left: 1.2em;
}

.concept-list li {
  margin-bottom: 0.35em;
  font-size: 0.94em;
}

/* ===  Example Boxes (do / don't)  === */

.example {
  margin: 1em 0;
  padding: 0.6em 1em;
  border: 1px solid var(--example-border);
  background: var(--bg-alt);
  font-size: 0.94em;
}

.example p {
  margin: 0.3em 0;
  text-indent: 0;
}

.example-label {
  font-weight: bold;
  font-size: 0.9em;
  margin-bottom: 0.3em;
}

.example-good {
  border-left: 3px solid var(--example-good);
}

.example-bad {
  border-left: 3px solid var(--example-bad);
}

/* ===  Pattern / Verdict  === */

.pattern {
  margin: 1em 1em;
  padding: 0.6em 1em;
  border-left: 3px solid var(--pattern-border);
  background: var(--pattern-bg);
  font-size: 0.94em;
}

.pattern h3 {
  font-size: 0.95em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0;
}

.pattern p {
  text-indent: 0;
  margin: 0.3em 0;
}

.verdict {
  margin: 1em 0;
  padding: 0.6em 0.9em;
  border-left: 3px solid #2c3e50;
  background: var(--bg-alt);
  font-size: 0.94em;
}

[data-theme="dark"] .verdict {
  border-left-color: #85929e;
}

/* ===  Elimination Table  === */

.elimination {
  margin: 1em 0;
  padding: 0.5em 1em;
  border: 1px solid var(--border-ddd);
  background: var(--bg-box);
  font-size: 0.94em;
}

.elimination h3 {
  font-size: 0.95em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0;
}

.elimination p {
  text-indent: 0;
  margin: 0.3em 0;
}

/* ===  Figures  === */

.figure {
  margin: 1.5em auto;
  text-align: center;
}

.figure svg,
.figure img {
  max-width: 100%;
  height: auto;
}

.figure-caption {
  font-size: 0.82em;
  color: var(--text-muted);
  margin-top: 0.5em;
  text-align: center;
  line-height: 1.45;
  text-indent: 0;
}

/* ===  References / Citations  === */

.references {
  font-size: 0.88em;
  margin-top: 2em;
  border-top: 1px solid var(--border);
  padding-top: 1em;
}

.references h2 {
  border-bottom: none;
}

.references p {
  text-indent: -1.8em;
  padding-left: 1.8em;
  margin: 0.4em 0;
  text-align: left;
}

/* ===  Index  === */

.index p {
  text-indent: -1.5em;
  padding-left: 1.5em;
  margin: 0.2em 0;
  text-align: left;
}

/* ===  Book-Specific Elements  === */

.subtitle {
  text-align: center;
  font-style: italic;
  font-size: 0.95em;
  color: var(--text-nav);
  margin: 0.2em 0 0.3em;
  line-height: 1.35;
  text-indent: 0;
}

.author {
  text-align: center;
  font-size: 0.95em;
  margin: 0.2em 0;
  text-indent: 0;
}

.date {
  text-align: center;
  font-size: 0.88em;
  color: var(--text-muted);
  margin: 0.2em 0 1.5em;
  text-indent: 0;
}

.byline {
  text-align: center;
  font-style: italic;
  font-size: 0.88em;
  color: var(--text-muted);
  margin: 0.2em 0;
  text-indent: 0;
}

.title-page {
  text-align: center;
  margin-top: 4em;
}

.part-header {
  text-align: center;
  margin-top: 3em;
}

.part-label {
  font-size: 1em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 0.3em;
  text-indent: 0;
}

h1.part-title {
  font-size: 1.5em;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-align: center;
  margin-top: 3em;
  margin-bottom: 0.3em;
  border-bottom: none;
  color: var(--text-mid);
}

.chapter-header {
  text-align: center;
  margin-top: 2em;
}

.chapter-label {
  font-size: 0.95em;
  font-variant: small-caps;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  text-indent: 0;
  text-align: center;
  margin: 0.6em 0 0.3em;
}

.chapter-subtitle,
p.chapter-subtitle {
  text-align: center;
  font-style: italic;
  font-size: 0.92em;
  color: var(--text-muted);
  margin: 0.3em 1.5em 0.8em;
  text-indent: 0;
  line-height: 1.45;
}

/* ===  Table of Contents  === */

.toc {
  margin: 1em 0;
}

.toc p {
  text-indent: 0;
  margin: 0.12em 0;
  text-align: left;
}

.toc-part {
  font-weight: bold;
  margin-top: 0.8em !important;
  font-size: 1.02em;
}

.toc-sec {
  margin-left: 1em;
  font-style: italic;
  color: var(--text-muted);
  margin-top: 0.4em !important;
  font-size: 0.95em;
}

.toc-ch {
  margin-left: 1.8em;
  font-size: 0.95em;
}

/* ===  Colophon  === */

.colophon {
  margin-top: 3em;
  padding-top: 1em;
  border-top: 1px solid var(--border);
  font-size: 0.82em;
  color: var(--text-faint);
  text-align: center;
}

/* ===  Page Breaks  === */

.page-break {
  break-before: page;
}

/* ===  Lists  === */

ul, ol {
  margin: 0.6em 0;
  padding-left: 1.5em;
}

li {
  margin-bottom: 0.3em;
}

/* ===  Tables  === */

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.2em 0;
  font-size: 0.88em;
}

th, td {
  border: 1px solid var(--border-dark);
  padding: 0.45em 0.7em;
  text-align: left;
  vertical-align: top;
  line-height: 1.4;
}

th {
  background: var(--bg-header);
  font-weight: bold;
}

/* ===  Code  === */

code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.1em 0.3em;
}

pre {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85em;
  background: var(--bg-alt);
  padding: 0.8em 1em;
  border: 1px solid var(--border-ddd);
  overflow-x: auto;
  margin: 1em 0;
  line-height: 1.35;
  white-space: pre;
}

/* ===  Horizontal Rules  === */

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

/* ===  Utility  === */

.center {
  text-align: center;
  text-indent: 0;
}

.noindent,
p.noindent {
  text-indent: 0;
}

/* ===  Print / Page Break Control  === */

h2, h3, h4 {
  break-after: avoid;
}

.abstract,
.method-note,
.sidebar,
.concept-list,
.example,
.elimination,
.pattern,
blockquote {
  break-inside: avoid;
}

.chapter-header {
  break-before: page;
  break-after: avoid;
  break-inside: avoid;
}

.glyph-wrap + .chapter-header {
  break-before: auto;
}

.part-header {
  break-before: page;
  break-inside: avoid;
}

.glyph-wrap {
  text-align: center;
  margin: 1.2em auto 0.4em;
  break-after: avoid;
  break-inside: avoid;
}

.glyph-wrap svg {
  display: inline-block;
  width: 1.49in;
  height: 1.49in;
}

h2 + p,
h3 + p {
  break-before: avoid;
}

/* ===================================================
   SITE-SPECIFIC STYLES
   =================================================== */

/* ===  Site Header  === */

.site-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1em;
  margin-bottom: 2em;
}

.site-header .site-title {
  text-align: center;
  font-size: 1.3em;
  margin: 0 0 0.3em;
  letter-spacing: 0.02em;
}

.site-header .site-title a {
  text-decoration: none;
  color: var(--text);
}

.site-header .site-subtitle {
  text-align: center;
  font-size: 0.85em;
  color: var(--text-muted);
  margin: 0 0 0.8em;
  text-indent: 0;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.4em 1.2em;
  font-size: 0.85em;
}

.site-header nav a {
  text-decoration: none;
  color: var(--text-nav);
}

.site-header nav a:hover {
  color: var(--text);
  text-decoration: underline;
}

/* ===  Site Footer  === */

.site-footer {
  margin-top: 3em;
  padding-top: 1em;
  border-top: 1px solid var(--border);
  font-size: 0.82em;
  color: var(--text-faint);
  text-align: center;
}

.site-footer p {
  text-indent: 0;
  text-align: center;
  margin: 0.3em 0;
}

.site-footer a {
  color: var(--text-faint);
}

/* ===  Glyph  === */

.glyph {
  text-align: center;
  margin: 1.2em auto 0.4em;
}

.glyph svg {
  display: inline-block;
  width: 72px;
  height: 72px;
}

.glyph svg g {
  stroke: var(--glyph-stroke);
}

/* ===  Publication Cards (list pages)  === */

.publication-list {
  list-style: none;
  padding: 0;
  margin: 1.5em 0;
}

.publication-list li {
  margin-bottom: 1.5em;
  padding-bottom: 1em;
  border-bottom: 1px solid var(--border-faint);
}

.publication-list .pub-title {
  font-size: 1.05em;
  font-weight: bold;
  margin: 0;
  text-indent: 0;
}

.publication-list .pub-title a {
  text-decoration: none;
}

.publication-list .pub-meta {
  font-size: 0.85em;
  color: var(--text-muted);
  margin: 0.2em 0;
  text-indent: 0;
}

.publication-list .pub-abstract {
  font-size: 0.92em;
  margin: 0.4em 0 0;
  text-indent: 0;
  text-align: left;
}

.publication-list .pub-questions {
  font-size: 0.85em;
  color: var(--text-muted);
  margin: 0.3em 0 0;
  text-indent: 0;
  font-style: italic;
}

/* ===  Publication Landing Page  === */

.pub-landing .pub-header {
  text-align: center;
  margin-bottom: 2em;
}

.pub-landing .pub-header h1 {
  margin-bottom: 0.2em;
}

.pub-landing .pub-authors {
  font-size: 0.95em;
  color: var(--text-mid);
  margin: 0.3em 0;
  text-indent: 0;
  text-align: center;
}

.pub-landing .pub-date {
  font-size: 0.88em;
  color: var(--text-muted);
  text-indent: 0;
  text-align: center;
}

.pub-status-banner {
  background: var(--placeholder-bg);
  border: 1px solid var(--placeholder-border);
  color: var(--placeholder-text);
  padding: 0.6em 1em;
  margin: 1em 0;
  font-size: 0.9em;
  text-indent: 0;
}

.pub-status-banner p {
  text-indent: 0;
  margin: 0;
  text-align: left;
}

.pub-landing .pub-identifiers {
  font-size: 0.85em;
  margin: 1em 0;
  text-indent: 0;
}

.pub-landing .pub-identifiers p {
  text-indent: 0;
  text-align: left;
  margin: 0.2em 0;
}

/* ===  Core Questions Box  === */

.core-questions {
  border: 1px solid var(--border);
  padding: 0.6em 1em;
  margin: 1.5em 0;
  background: var(--bg-box);
}

.core-questions h3 {
  font-size: 0.95em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.4em;
  color: var(--text-muted);
}

.core-questions ol {
  margin: 0;
  padding-left: 1.3em;
}

.core-questions li {
  font-size: 0.94em;
  font-style: italic;
  margin-bottom: 0.25em;
}

.core-questions li a {
  font-style: italic;
  color: var(--text);
}

/* ===  Browse / Taxonomy  === */

.browse-section {
  margin: 1.5em 0;
}

.browse-section h2 {
  font-size: 1.1em;
  border-bottom: none;
  margin-bottom: 0.4em;
}

.tag-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em;
}

.tag-list li a {
  display: inline-block;
  padding: 0.2em 0.7em;
  border: 1px solid var(--border);
  font-size: 0.85em;
  text-decoration: none;
  color: var(--text-mid);
}

.tag-list li a:hover {
  background: var(--bg-header);
  border-color: var(--border-darker);
}

/* ===  Placeholder Marker  === */

.placeholder {
  background: var(--placeholder-bg);
  border: 1px dashed var(--placeholder-border);
  padding: 0.3em 0.6em;
  font-size: 0.85em;
  color: var(--placeholder-text);
  display: inline-block;
  margin: 0.3em 0;
}

/* ===  Navigation Dropdown  === */

.nav-dropdown {
  position: relative;
  display: inline-block;
}

/* Invisible hover bridge — fills the gap between the toggle and the
   dropdown panel so the cursor can cross it without :hover flickering off. */
.nav-dropdown::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 0.4em;
}

.nav-dropdown-content {
  display: none;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.4em 0;
  min-width: 10em;
  z-index: 10;
  margin-top: 0.2em;
}

.nav-dropdown:hover .nav-dropdown-content,
.nav-dropdown:focus-within .nav-dropdown-content,
.nav-dropdown.open .nav-dropdown-content {
  display: block;
}

.nav-dropdown-content a {
  display: block;
  padding: 0.3em 1em;
  text-decoration: none;
  color: var(--text-nav);
  font-size: 0.85em;
  white-space: nowrap;
}

.nav-dropdown-content a:hover {
  background: var(--bg-header);
  color: var(--text);
}

/* ===  Footer Navigation  === */

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4em 1.2em;
  margin-bottom: 1em;
  font-size: 0.85em;
}

.footer-nav a {
  color: var(--text-faint);
  text-decoration: none;
}

.footer-nav a:hover {
  color: var(--text);
  text-decoration: underline;
}

/* ===  Photo Gallery  === */

.photo-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
  justify-content: center;
  margin: 2em 0;
}

.photo-gallery figure {
  margin: 0;
  flex: 1 1 200px;
  max-width: 300px;
}

.photo-gallery img {
  width: 100%;
  height: auto;
  display: block;
}

.photo-gallery figcaption {
  font-size: 0.78em;
  color: var(--text-faint);
  text-align: center;
  margin-top: 0.3em;
  text-indent: 0;
  font-style: italic;
}

/* ===  Dark Mode Toggle  === */

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.3em;
  font-family: inherit;
  font-size: 0.85em;
  color: var(--text-nav);
}

.theme-toggle:hover {
  color: var(--text);
}

.toggle-track {
  width: 2.2em;
  height: 1.2em;
  background: var(--toggle-bg);
  border-radius: 0.6em;
  position: relative;
  transition: background 0.2s ease;
}

.toggle-knob {
  width: 0.9em;
  height: 0.9em;
  background: var(--toggle-knob);
  border-radius: 50%;
  position: absolute;
  top: 0.15em;
  left: 0.15em;
  transition: transform 0.2s ease;
}

[data-theme="dark"] .toggle-knob {
  transform: translateX(1em);
}

.toggle-label {
  font-size: 0.9em;
}

/* ===  Search Button  === */

.search-btn {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 0.15em 0.7em;
  font-family: inherit;
  font-size: 0.85em;
  color: var(--text-nav);
  border-radius: 0.3em;
}

.search-btn:hover {
  color: var(--text);
  border-color: var(--border-darker);
}

/* ===  Search Overlay  === */

.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 100;
  justify-content: center;
  align-items: flex-start;
  padding-top: 10vh;
}

[data-theme="dark"] .search-overlay {
  background: rgba(0, 0, 0, 0.75);
}

.search-container {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1.5em;
  width: 90%;
  max-width: 36em;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.search-close {
  position: absolute;
  top: 0.5em;
  right: 0.8em;
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.search-close:hover {
  color: var(--text);
}

/* Pagefind UI overrides to match site theme */
.pagefind-ui {
  --pagefind-ui-font: 'TeX Gyre Pagella', Palatino, 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
  --pagefind-ui-text: var(--text);
  --pagefind-ui-background: var(--bg);
  --pagefind-ui-border: var(--border);
  --pagefind-ui-tag: var(--bg-header);
  --pagefind-ui-primary: var(--text);
}

/* ===  Download Actions  === */

.download-actions {
  margin: 1.5em 0;
  text-align: center;
}

.download-actions a {
  display: inline-block;
  padding: 0.3em 1em;
  border: 1px solid var(--border);
  text-decoration: none;
  font-size: 0.85em;
  margin: 0.2em;
  color: var(--text-nav);
}

.download-actions a:hover {
  background: var(--bg-header);
  border-color: var(--border-darker);
  color: var(--text);
}

.download-actions .btn-disabled {
  display: inline-block;
  padding: 0.3em 1em;
  border: 1px solid var(--border);
  font-size: 0.85em;
  margin: 0.2em;
  color: var(--text-nav);
  opacity: 0.45;
  cursor: default;
}

/* ===  Reading Time  === */

.reading-time {
  font-size: 0.88em;
  color: var(--text-muted);
}

/* ===  Citation Export  === */

.citation-export {
  margin: 2em 0;
  border-top: 1px solid var(--border);
  padding-top: 1em;
}

.citation-export h3 {
  font-size: 0.95em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0;
}

.cite-buttons {
  display: flex;
  gap: 0.4em;
  margin-bottom: 0.6em;
}

.cite-btn {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 0.2em 0.8em;
  font-family: inherit;
  font-size: 0.85em;
  color: var(--text-nav);
}

.cite-btn:hover,
.cite-btn.active {
  background: var(--bg-header);
  border-color: var(--border-darker);
  color: var(--text);
}

.cite-output {
  font-size: 0.8em;
  background: var(--bg-alt);
  border: 1px solid var(--border-ddd);
  padding: 0.6em 0.8em;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 15em;
  overflow-y: auto;
}

/* ===  Related Publications  === */

.related-publications {
  margin: 2em 0;
  border-top: 1px solid var(--border);
  padding-top: 1em;
}

.related-publications h3 {
  font-size: 0.95em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0;
}

.related-publications ul {
  list-style: none;
  padding: 0;
}

.related-publications li {
  margin-bottom: 0.6em;
}

.related-publications .related-meta {
  font-size: 0.82em;
  color: var(--text-muted);
  display: block;
  text-indent: 0;
}

/* ===  Errata  === */

.errata {
  margin: 2em 0;
  border-top: 1px solid var(--border);
  padding-top: 1em;
}

.errata h3 {
  font-size: 0.95em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0;
}

.errata dl {
  margin: 0;
}

.errata dt {
  font-weight: bold;
  font-size: 0.88em;
  margin-top: 0.8em;
  text-indent: 0;
}

.errata dd {
  margin-left: 0;
  font-size: 0.92em;
  text-indent: 0;
}

.errata-type {
  font-weight: normal;
  font-size: 0.85em;
  padding: 0.1em 0.4em;
  border: 1px solid var(--border);
}

.errata-type.errata-correction {
  color: var(--text-muted);
}

.errata-type.errata-retraction {
  color: var(--example-bad);
  border-color: var(--example-bad);
}

.errata-type.errata-addendum {
  color: var(--method-border);
  border-color: var(--method-border);
}

/* ===  Table of Contents (publication)  === */

.pub-toc {
  border: 1px solid var(--border);
  padding: 0.6em 1em;
  margin: 1.5em 0;
  background: var(--bg-box);
  font-size: 0.92em;
}

.pub-toc summary {
  cursor: pointer;
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: bold;
  text-indent: 0;
}

.pub-toc nav ul {
  margin: 0.4em 0;
  padding-left: 1.2em;
}

.pub-toc nav li {
  margin-bottom: 0.2em;
  font-size: 0.94em;
}

.pub-toc nav a {
  text-decoration: none;
  color: var(--text);
}

.pub-toc nav a:hover {
  text-decoration: underline;
}

/* ===  Page-specific Layout  === */

.home-glyph {
  margin-top: 2em;
}

.home-title {
  margin-top: 0.5em;
}

.home-subtitle {
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 2em;
}

.not-found-title {
  margin-top: 3em;
}

.not-found-text {
  color: var(--text-muted);
}

.not-found-links {
  margin-top: 1.5em;
}

.section-intro {
  color: var(--text-muted);
  font-size: 0.92em;
}

.author-identifiers {
  margin-top: 2em;
}

/* ===  Author Profile  === */

.author-profile .author-meta {
  margin: 1em 0;
  font-size: 0.92em;
}

.author-profile .author-meta p {
  margin: 0.3em 0;
}

/* ===  Series List  === */

.series-list {
  padding-left: 1.5em;
  margin: 1.5em 0;
}

.series-list li {
  margin-bottom: 1.2em;
  padding-bottom: 0.8em;
  border-bottom: 1px solid var(--border-faint);
}

.series-list .pub-title {
  font-size: 1.05em;
  font-weight: bold;
  margin: 0;
  text-indent: 0;
}

.series-list .pub-title a {
  text-decoration: none;
}

.series-list .pub-meta {
  font-size: 0.85em;
  color: var(--text-muted);
  margin: 0.2em 0;
  text-indent: 0;
}

.series-list .pub-abstract {
  font-size: 0.92em;
  margin: 0.4em 0 0;
  text-indent: 0;
  text-align: left;
}

.pub-status {
  font-size: 0.85em;
  padding: 0.1em 0.4em;
  border: 1px solid var(--border);
}

.pub-status-forthcoming {
  color: var(--text-muted);
  font-style: italic;
}

.pub-status-published {
  color: var(--method-border);
  border-color: var(--method-border);
}

/* ===  Footnotes  === */

.footnotes {
  margin-top: 2em;
  border-top: 1px solid var(--border);
  padding-top: 1em;
  font-size: 0.88em;
}

.footnotes hr {
  display: none;
}

.footnotes ol {
  padding-left: 1.5em;
}

.footnotes li {
  margin-bottom: 0.4em;
}

.footnotes li p {
  text-indent: 0;
  text-align: left;
  margin: 0.2em 0;
}

.footnote-ref {
  font-size: 0.75em;
  vertical-align: super;
  text-decoration: none;
  line-height: 0;
}

.footnote-backref {
  text-decoration: none;
  font-size: 0.85em;
}

/* ===  Print-to-PDF Button  === */

.print-pdf-btn {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 0.3em 1em;
  font-family: inherit;
  font-size: 0.85em;
  color: var(--text-nav);
  display: inline-block;
  margin: 0.2em;
}

.print-pdf-btn:hover {
  background: var(--bg-header);
  border-color: var(--border-darker);
  color: var(--text);
}

/* ===  Publication-Specific Styles (Book Content)  === */

/* --- TOC Page --- */
.toc-page {
  min-height: 6in;
}

.toc-page h2 {
  text-align: center;
  font-size: 1.4em;
  margin-bottom: 1.5em;
  letter-spacing: 0.05em;
  font-variant: small-caps;
  border-bottom: none;
}

.toc-part {
  margin: 1.2em 0 0.3em;
  font-weight: bold;
  font-size: 0.95em;
  font-variant: small-caps;
  letter-spacing: 0.04em;
}

.toc-part a,
.toc-part-link {
  color: var(--text);
  text-decoration: none;
  display: block;
}

.toc-chapter {
  margin: 0.25em 0 0.25em 1.5em;
  font-size: 0.92em;
  line-height: 1.45;
}

.toc-chapter a {
  color: var(--text);
  text-decoration: none;
  display: block;
}

.toc-chapter a:hover {
  text-decoration: underline;
}

.toc-ch-num {
  font-variant: small-caps;
  letter-spacing: 0.03em;
  margin-right: 0.4em;
  font-weight: bold;
  font-size: 0.92em;
}

/* --- Part Divider Pages --- */
.part-number {
  font-size: 0.9em;
  font-variant: small-caps;
  letter-spacing: 0.15em;
  color: var(--text-faint);
  margin-bottom: 0.5em;
  text-indent: 0;
}

/* --- Chapter Opening --- */
.chapter-container {
  break-before: page;
}

.chapter-num {
  text-align: center;
  font-size: 0.88em;
  font-variant: small-caps;
  letter-spacing: 0.15em;
  color: var(--text-faint);
  margin-top: 2.5em;
  margin-bottom: 0.3em;
  text-indent: 0;
}

h1.chapter-title {
  font-size: 1.65em;
  line-height: 1.2;
  margin: 0 0 0.2em;
  text-align: center;
  letter-spacing: -0.01em;
}

.chapter-epigraph {
  text-align: center;
  font-size: 0.88em;
  color: var(--text-muted);
  margin: 1.5em 3em 2.5em;
  font-style: italic;
  line-height: 1.45;
  text-indent: 0;
}

.chapter-epigraph .attribution {
  display: block;
  margin-top: 0.4em;
  font-style: normal;
  font-size: 0.9em;
  color: #777;
}

/* --- Chapter Abstract (Summary) --- */
.pub-landing h2 {
  border-bottom: none;
  padding-bottom: 0;
}

.pub-landing .abstract {
  margin: 1.5em 2em;
  font-size: 0.92em;
  line-height: 1.48;
  border-left: none;
  background: none;
  padding: 0;
}

.pub-landing .abstract p:first-of-type::before {
  content: "Chapter Summary — ";
  font-weight: bold;
  font-style: italic;
}

/* --- Chapter TOC (within chapters) --- */
.chapter-toc {
  margin: 1.5em 0 2em;
  padding: 0.8em 1.2em;
  background: var(--bg-alt);
  border: 1px solid var(--border-ddd);
  font-size: 0.88em;
  line-height: 1.5;
  break-inside: avoid;
}

.chapter-toc-title {
  font-weight: bold;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  margin-bottom: 0.4em;
  text-indent: 0;
}

/* --- Section Numbers --- */
.sec-num {
  font-weight: bold;
  margin-right: 0.3em;
}

/* --- Formal Blocks (Definition, Theorem, Lemma, etc.) --- */
.definition,
.theorem,
.lemma,
.corollary,
.proposition,
.remark {
  margin: 1.2em 0;
  padding: 0.6em 1em;
  border-left: 3px solid var(--blockquote-border);
  background: var(--bg-alt);
  font-size: 0.94em;
  break-inside: avoid;
}

.definition { border-left-color: #1a5276; }
.theorem { border-left-color: #7b241c; }
.lemma { border-left-color: #6c3483; }
.corollary { border-left-color: #1e8449; }
.proposition { border-left-color: #a04000; }
.remark { border-left-color: var(--border-darker); }

[data-theme="dark"] .definition { border-left-color: #5dade2; }
[data-theme="dark"] .theorem { border-left-color: #ec7063; }
[data-theme="dark"] .lemma { border-left-color: #bb8fce; }
[data-theme="dark"] .corollary { border-left-color: #58d68d; }
[data-theme="dark"] .proposition { border-left-color: #e59866; }

.definition p,
.theorem p,
.lemma p,
.corollary p,
.proposition p,
.remark p {
  text-indent: 0;
  margin: 0.3em 0;
}

.block-label {
  font-weight: bold;
  font-style: italic;
  display: inline;
  margin-right: 0.3em;
}

.block-name {
  font-style: italic;
  font-weight: normal;
}

/* --- Proofs --- */
.proof {
  margin: 0.8em 0 1.2em 0;
  font-size: 0.95em;
}

.proof p {
  margin: 0.3em 0;
  text-indent: 0;
}

.proof-label {
  font-style: italic;
  font-weight: normal;
  margin-right: 0.3em;
}

.qed {
  float: right;
  font-size: 0.9em;
  line-height: 1;
}

/* --- Math --- */
.math-block {
  display: block;
  text-align: center;
  margin: 1em 0;
  font-family: "Cambria Math", "Latin Modern Math", "STIX Two Math", Georgia, serif;
  font-size: 1.02em;
  line-height: 1.7;
  break-inside: avoid;
  text-indent: 0;
}

.math-block .eq-num {
  float: right;
  color: var(--text-faint);
  font-size: 0.88em;
}

.mi {
  font-family: "Cambria Math", "Latin Modern Math", "STIX Two Math", Georgia, serif;
  font-style: italic;
  white-space: nowrap;
}

var {
  font-family: "Cambria Math", "Latin Modern Math", "STIX Two Math", Georgia, serif;
  font-style: italic;
}

/* --- Key Insight Boxes --- */
.key-insight {
  margin: 1em 0;
  padding: 0.8em 1em;
  background: #f0efe8;
  border-left: 3px solid #666;
  font-size: 0.94em;
  break-inside: avoid;
}

[data-theme="dark"] .key-insight {
  background: var(--bg-alt);
  border-left-color: #999;
}

.key-insight p {
  text-indent: 0;
  margin: 0.3em 0;
}

.key-insight-label {
  font-weight: bold;
  font-variant: small-caps;
  display: block;
  margin-bottom: 0.3em;
  text-indent: 0;
}

/* --- Formal Tables --- */
table.formal {
  border-collapse: collapse;
  margin: 1em auto;
  font-size: 0.9em;
}

table.formal th,
table.formal td {
  padding: 0.3em 0.7em;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

table.formal th {
  font-weight: 700;
  border-bottom: 2px solid var(--border-darker);
  font-size: 0.9em;
  font-variant: small-caps;
  letter-spacing: 0.04em;
}

table.formal tr:last-child td {
  border-bottom: 2px solid var(--border-darker);
}

/* --- Endnotes --- */
.endnotes {
  font-size: 0.88em;
  margin-top: 2em;
  border-top: 1px solid var(--border);
  padding-top: 0.5em;
}

.endnote-item {
  margin: 0.5em 0;
  padding-left: 1.8em;
  text-indent: -1.8em;
  text-align: left;
}

/* --- Section Breaks --- */
hr.section-break {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5em 3em;
}

/* --- Dialogue Boxes (Review chapters) --- */
.dialogue-box {
  margin: 1em 0;
  padding: 0.7em 1em;
  font-size: 0.94em;
  break-inside: avoid;
}

.dialogue-box p {
  text-indent: 0;
  margin: 0.3em 0;
}

.reviewer-box {
  border-left: 3px solid #c0392b;
  background: #fdf2f2;
}

.author-box {
  border-left: 3px solid #27ae60;
  background: #f2fdf5;
}

[data-theme="dark"] .reviewer-box {
  border-left-color: #ec7063;
  background: #2a1a1a;
}

[data-theme="dark"] .author-box {
  border-left-color: #58d68d;
  background: #1a2a1e;
}

.dialogue-label {
  font-weight: bold;
  font-variant: small-caps;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 0.3em;
  text-indent: 0;
}

/* --- Dialogue Turns --- */
.dialogue {
  margin: 1em 0;
}

.dialogue-turn {
  margin: 0.8em 0;
  padding: 0.6em 0.9em;
  font-size: 0.94em;
  break-inside: avoid;
}

.dialogue-turn p {
  text-indent: 0;
  margin: 0.3em 0;
}

.dialogue-turn.objector {
  border-left: 3px solid #c0392b;
  background: #fdf2f2;
}

.dialogue-turn.author {
  border-left: 3px solid #27ae60;
  background: #f2fdf5;
}

[data-theme="dark"] .dialogue-turn.objector {
  border-left-color: #ec7063;
  background: #2a1a1a;
}

[data-theme="dark"] .dialogue-turn.author {
  border-left-color: #58d68d;
  background: #1a2a1e;
}

.dialogue-speaker {
  font-weight: bold;
  font-variant: small-caps;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 0.3em;
  font-size: 0.92em;
  color: var(--text-nav);
  text-indent: 0;
}

.dialogue-turn.objector .dialogue-speaker {
  color: #a0302a;
}

.dialogue-turn.author .dialogue-speaker {
  color: #1e8449;
}

[data-theme="dark"] .dialogue-turn.objector .dialogue-speaker {
  color: #ec7063;
}

[data-theme="dark"] .dialogue-turn.author .dialogue-speaker {
  color: #58d68d;
}

.verdict-label {
  font-weight: bold;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 0.3em;
  font-size: 0.95em;
  color: var(--text-mid);
  text-indent: 0;
}

/* --- Figure Labels --- */
.fig-label {
  font-weight: bold;
  font-variant: small-caps;
  letter-spacing: 0.03em;
}

/* --- Diagram Containers --- */
.diagram-container {
  margin: 1.4em 0;
  text-align: center;
  break-inside: avoid;
}

/* --- Index Section --- */
.index-section {
  column-count: 2;
  column-gap: 2em;
  font-size: 0.85em;
}

.index-section h1 {
  column-span: all;
  text-align: center;
}

.index-letter {
  font-size: 1.1em;
  font-weight: bold;
  margin: 0.8em 0 0.2em;
  border-bottom: 1px solid var(--border-darker);
  padding-bottom: 0.1em;
  break-after: avoid;
}

.index-entry {
  text-indent: -1em;
  padding-left: 1em;
  margin: 0.15em 0;
  text-align: left;
  line-height: 1.35;
}

.idx-ref {
  text-decoration: none;
  color: inherit;
}

/* --- Preface --- */
.preface {
  font-size: 0.96em;
}

.preface h2 {
  text-align: center;
  font-variant: small-caps;
  letter-spacing: 0.06em;
}

/* --- Word Count --- */
.wordcount {
  font-size: 0.8em;
  color: var(--text-faint);
  margin-top: 1em;
  text-indent: 0;
}

/* --- Chapter Attribution --- */
.ch-attribution {
  -webkit-hyphens: manual;
  hyphens: manual;
}

/* ===  Print Stylesheet  === */

@media print {
  html { font-size: 9.5pt; }
  body {
    margin: 0;
    padding: 0;
    max-width: none;
    background: #fff;
    color: #000;
  }

  /* --- Hide site-template chrome (not part of book content) --- */
  .site-header,
  .site-footer,
  .search-overlay,
  .skip-link,
  .theme-toggle,
  .search-btn,
  .nav-dropdown-content,
  .pub-header,
  .pub-landing > .core-questions,
  .pub-landing > .abstract,
  .pub-toc,
  .pub-status-banner,
  .pub-identifiers,
  .author-identifiers,
  .download-actions,
  .citation-export,
  .related-publications,
  .print-pdf-btn,
  .no-print { display: none !important; }

  /* --- Typography --- */
  h1.chapter-title { font-size: 17pt; }
  h2 { font-size: 12.5pt; break-before: auto; break-after: avoid; }
  h3 { font-size: 10.5pt; break-after: avoid; }
  h4 { font-size: 9.5pt; break-after: avoid; }
  h2 + p, h3 + p { break-before: avoid; }
  p { orphans: 2; widows: 2; }
  a { color: #000; text-decoration: none; }

  /* --- Page breaks --- */
  .page-break { break-before: page; page-break-before: always; }
  .title-page {
    padding-top: 3in;
    min-height: 7in;
  }
  .part-page {
    padding-top: 3in;
    min-height: 5in;
    text-align: center;
  }
  .part-number { color: #666; }
  h1.part-title { color: #1a1a1a; }

  /* --- Box elements: flatten backgrounds for print --- */
  .abstract,
  .method-note,
  .sidebar,
  .concept-list,
  .example,
  .elimination,
  .pattern,
  .chapter-header {
    break-inside: avoid;
    background: #fff;
    border-color: #999;
  }
  .abstract { border-left-color: #999; }
  blockquote { border-left-color: #999; background: #fff; }
  .definition,
  .theorem,
  .lemma,
  .corollary,
  .proposition,
  .remark { background: #fff; }
  .key-insight { background: #fff; border-left-color: #666; }
  .dialogue-box,
  .dialogue-turn { background: #fff; }
  .reviewer-box { background: #fff; border-left-color: #c0392b; }
  .author-box { background: #fff; border-left-color: #27ae60; }
  .dialogue-turn.objector { background: #fff; }
  .dialogue-turn.author { background: #fff; }
  .verdict { background: #fff; }
  .chapter-toc { background: #fff; border-color: #999; }
  .core-questions { background: #fff; border-color: #999; }
  .pub-status-banner { background: #fff3cd; border-color: #999; color: #333; }
  code { background: #f4f4f4; }
  pre { background: #f4f4f4; border-color: #999; }
  th { background: #eee; }

  /* --- WeasyPrint TOC page numbers --- */
  .toc-chapter a::after,
  .toc-part a::after {
    content: target-counter(attr(href url), page);
    float: right;
    font-style: normal;
    font-variant: normal;
  }
  .toc-chapter a,
  .toc-part a {
    display: block;
    text-decoration: none;
    color: inherit;
    border-bottom: none;
  }
  .toc-chapter a::after { font-size: 0.9em; }
  .idx-ref::after {
    content: target-counter(attr(href url), page);
  }
}

@page {
  size: 6in 9in;
  margin: 0.75in 0.65in 0.85in 0.8in;
  @bottom-center {
    content: counter(page);
    font-family: 'TeX Gyre Pagella', Palatino, 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
    font-size: 9pt;
    color: #555;
  }
}

@page :first {
  @bottom-center { content: none; }
}
