/* ==========================================================================
   addrproxy.com — A scholarly treatise on the art of correspondence
   obfuscation. Design: 19th-century postal cartography crossed with cold-war
   cryptographic manuals. Sepia palette, verdigris accent, editorial grid.
   ========================================================================== */

:root {
  /* Palette (exact hex from DESIGN.md) */
  --parchment:   #F2E8D5; /* Aged cream background */
  --deep-ink:    #2B2118; /* Primary text */
  --iron-gall:   #5C3D2E; /* Headings & accents (oxidized brown) */
  --verdigris:   #4A7C6F; /* Interactive / links (oxidized copper) */
  --foxing:      #C4A882; /* Secondary accents (aged paper spot tone) */
  --red-wax:     #8B3A3A; /* Sparse highlight / drop-caps / current section */
  --margin-rule: #A89B8C; /* Structural lines / footnote text */

  /* Typography */
  --font-display: "Cormorant Garamond", Cormorant, Lora, Georgia, serif;
  --font-sc:      "Cormorant SC", "Cormorant Garamond", Georgia, serif;
  --font-body:    "Lora", Georgia, "Times New Roman", serif;
  --font-mono:    "IBM Plex Mono", "Space Mono", "Courier New", monospace;
  --font-ui:      "Inter", "Helvetica Neue", Arial, sans-serif;

  /* Structural */
  --gutter-left:  260px;
  --main-max:     680px;
  --page-pad-x:   72px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  background-color: var(--parchment);
}

body {
  background-color: var(--parchment);
  color: var(--deep-ink);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.75;
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
}

/* Parchment noise texture overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
  opacity: 0.55;
}

/* Subtle vignette */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 98;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(92,61,46,0.08) 100%);
}

/* Background circuit watermark (very faint) */
.watermark-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.04;
}
.watermark-layer svg {
  width: 100%;
  height: 100%;
}

/* Page edge decorations (book gutter shading) */
.page-edge-left,
.page-edge-right {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 18px;
  z-index: 97;
  pointer-events: none;
}
.page-edge-left {
  left: 0;
  background: linear-gradient(to right, rgba(92,61,46,0.18), transparent);
}
.page-edge-right {
  right: 0;
  background: linear-gradient(to left, rgba(92,61,46,0.18), transparent);
}

/* ==========================================================================
   Colophon Bar (running header)
   ========================================================================== */

.colophon-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: rgba(242, 232, 213, 0.92);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-bottom: 1px solid rgba(92,61,46,0.25);
  opacity: 0;
  transform: translateY(-100%);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.colophon-bar.visible {
  opacity: 1;
  transform: translateY(0);
}
.colophon-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 28px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-mono);
  font-weight: 300;
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--iron-gall);
  white-space: nowrap;
  overflow-x: auto;
}
.colophon-mark {
  font-family: var(--font-display);
  font-weight: 600;
  font-style: italic;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: none;
  color: var(--iron-gall);
  padding-right: 6px;
  border-right: 1px solid rgba(92,61,46,0.3);
  margin-right: 4px;
}
.colo-link {
  color: var(--iron-gall);
  text-decoration: none;
  padding: 4px 6px;
  border-bottom: 1px solid transparent;
  transition: color 0.3s ease, border-color 0.3s ease;
}
.colo-link:hover {
  color: var(--verdigris);
  border-bottom-color: var(--verdigris);
}
.colo-link.active {
  color: var(--red-wax);
  border-bottom-color: var(--red-wax);
}
.colo-sep {
  color: var(--margin-rule);
  opacity: 0.6;
  font-size: 0.7rem;
}

/* ==========================================================================
   Side Navigation (Table of Contents)
   ========================================================================== */

.side-nav {
  position: fixed;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.side-nav.visible {
  opacity: 1;
}
.nav-label {
  font-family: var(--font-sc);
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--margin-rule);
  margin-bottom: 14px;
  padding-left: 14px;
}
.side-nav ul {
  list-style: none;
}
.side-nav li {
  margin-bottom: 4px;
}
.nav-link {
  display: block;
  font-family: var(--font-mono);
  font-weight: 300;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--margin-rule);
  text-decoration: none;
  padding: 4px 0 4px 14px;
  border-left: 2px solid transparent;
  transition: color 0.3s ease, border-color 0.3s ease, padding-left 0.3s ease;
}
.nav-link:hover {
  color: var(--verdigris);
  border-left-color: var(--verdigris);
  padding-left: 18px;
}
.nav-link.active {
  color: var(--red-wax);
  border-left-color: var(--red-wax);
}
.nav-ornament {
  margin-top: 18px;
  padding-left: 14px;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--foxing);
}

/* ==========================================================================
   Manuscript layout scaffolding
   ========================================================================== */

.manuscript {
  position: relative;
  z-index: 1;
}

.chapter-section {
  position: relative;
  padding: 120px var(--page-pad-x) 100px;
  min-height: 100vh;
}
.chapter-section.chapter {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity 1.1s cubic-bezier(0.4,0,0.2,1),
              transform 1.1s cubic-bezier(0.4,0,0.2,1);
}
.chapter-section.chapter.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Frontispiece
   ========================================================================== */

.frontispiece {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 40px 80px;
  position: relative;
}
.frontispiece::before,
.frontispiece::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  max-width: 900px;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(92,61,46,0.4), transparent);
}
.frontispiece::before { top: 40px; }
.frontispiece::after  { bottom: 40px; }

.frontispiece-inner {
  max-width: 720px;
  width: 100%;
}
.frontispiece-overhead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 24px;
}
.imprint-line {
  font-family: var(--font-sc);
  font-size: 0.7rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--iron-gall);
}
.imprint-sub {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 0.85rem;
  color: var(--margin-rule);
}
.frontispiece-ornament {
  width: min(320px, 80%);
  margin: 18px auto;
}
.ornament-svg {
  width: 100%;
  height: auto;
}
.frontispiece-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(3.5rem, 11vw, 9rem);
  letter-spacing: 0.08em;
  line-height: 0.95;
  color: var(--deep-ink);
  margin: 12px 0 4px;
}
.title-part { font-weight: 600; }
.title-accent {
  font-weight: 300;
  font-style: italic;
  color: var(--iron-gall);
}
.frontispiece-subtitle {
  font-family: var(--font-display);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  line-height: 1.55;
  color: var(--iron-gall);
  margin: 24px 0 36px;
  letter-spacing: 0.03em;
}
.frontispiece-subtitle em {
  color: var(--red-wax);
  font-style: italic;
}
.frontispiece-device {
  margin: 28px auto 32px;
  max-width: 520px;
  will-change: transform;
}
.device-illustration {
  width: 100%;
  height: auto;
}
.frontispiece-imprint {
  font-family: var(--font-sc);
  font-size: 0.72rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--margin-rule);
  margin-top: 8px;
}
.scroll-indicator {
  position: absolute;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: scrollBob 2.6s ease-in-out infinite;
  transition: opacity 0.4s ease;
}
.scroll-indicator span {
  font-family: var(--font-sc);
  font-size: 0.65rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--margin-rule);
}
@keyframes scrollBob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(8px); }
}

/* ==========================================================================
   Chapter editorial grid: margin column + main content column
   ========================================================================== */

.chapter-layout {
  max-width: 1160px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--gutter-left) minmax(0, 1fr);
  gap: 60px;
  position: relative;
}
/* Decorative vertical rule between margin and main column */
.chapter-layout::before {
  content: "";
  position: absolute;
  left: calc(var(--gutter-left) + 10px);
  top: 40px;
  bottom: 40px;
  width: 1px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(92,61,46,0.35) 0px,
    rgba(92,61,46,0.35) 4px,
    transparent 4px,
    transparent 10px
  );
  opacity: 0.6;
}

.margin-column {
  position: relative;
  padding-top: 30px;
  padding-right: 12px;
}
.margin-annotation {
  position: relative;
  margin-bottom: 34px;
  padding-left: 14px;
  border-left: 1px solid var(--foxing);
  opacity: 0;
  transform: translateX(-18px);
  transition: opacity 0.65s cubic-bezier(0.4,0,0.2,1),
              transform 0.65s cubic-bezier(0.4,0,0.2,1),
              border-color 0.4s ease;
}
.chapter-section.visible .margin-annotation {
  opacity: 1;
  transform: translateX(0);
}
/* Stagger the annotations */
.chapter-section.visible .margin-annotation:nth-child(2) {
  transition-delay: 160ms;
}
.chapter-section.visible .margin-annotation:nth-child(3) {
  transition-delay: 320ms;
}
.chapter-section.visible .margin-annotation:nth-child(4) {
  transition-delay: 480ms;
}
.margin-annotation:hover {
  border-left-color: var(--verdigris);
}
.annotation-marker {
  display: block;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--verdigris);
  line-height: 1;
  margin-bottom: 6px;
}
.annotation-text {
  font-family: var(--font-mono);
  font-weight: 300;
  font-size: 0.72rem;
  line-height: 1.65;
  color: var(--iron-gall);
}
.annotation-text em {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--iron-gall);
}
.margin-illustration {
  margin: 20px 0 34px;
  opacity: 0;
  transform: translateX(-18px);
  transition: opacity 0.8s cubic-bezier(0.4,0,0.2,1) 240ms,
              transform 0.8s cubic-bezier(0.4,0,0.2,1) 240ms;
}
.chapter-section.visible .margin-illustration {
  opacity: 1;
  transform: translateX(0);
}
.margin-illustration svg {
  width: 100%;
  height: auto;
  max-width: 180px;
  display: block;
}

/* ==========================================================================
   Chapter content column
   ========================================================================== */

.chapter-content {
  max-width: var(--main-max);
  padding-top: 20px;
}
.chapter-header {
  margin-bottom: 44px;
  position: relative;
}
.chapter-numeral {
  display: block;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(3.4rem, 6vw, 5rem);
  line-height: 1;
  color: var(--iron-gall);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1s ease, transform 1s ease;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  font-style: italic;
}
.chapter-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 3.4vw, 3.3rem);
  line-height: 1.15;
  letter-spacing: 0.02em;
  color: var(--deep-ink);
  margin-top: 4px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1s ease 200ms, transform 1s ease 200ms;
}
.chapter-title em {
  font-style: italic;
  font-weight: 400;
  color: var(--iron-gall);
}
.chapter-section.visible .chapter-numeral,
.chapter-section.visible .chapter-title {
  opacity: 1;
  transform: translateY(0);
}
.chapter-rule {
  margin-top: 20px;
  width: 160px;
  height: 8px;
  opacity: 0.75;
}
.chapter-rule svg {
  width: 100%;
  height: 8px;
}

/* Body text — justified editorial */
.chapter-body {
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.85;
  color: var(--deep-ink);
  margin-bottom: 22px;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.chapter-body em {
  font-style: italic;
  color: var(--iron-gall);
}
.chapter-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: var(--verdigris);
  background: rgba(74,124,111,0.09);
  padding: 1px 5px;
  border-radius: 2px;
  font-weight: 400;
}
.chapter-body strong {
  font-weight: 600;
  color: var(--iron-gall);
}

/* Drop caps — first letter of first paragraph per chapter */
.drop-cap {
  float: left;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 4.4rem;
  line-height: 0.85;
  padding: 8px 10px 0 0;
  color: var(--deep-ink);
  position: relative;
  transition: color 0.8s cubic-bezier(0.4,0,0.2,1);
}
.chapter-section.visible .drop-cap {
  color: var(--red-wax);
  transition: color 0.8s cubic-bezier(0.4,0,0.2,1) 300ms;
}
/* Miniature circuit-trace border behind the drop-cap */
.drop-cap::before {
  content: "";
  position: absolute;
  left: -6px;
  top: -2px;
  width: calc(100% - 4px);
  height: calc(100% - 6px);
  border-left: 1px solid var(--foxing);
  border-top: 1px solid var(--foxing);
  opacity: 0.6;
  pointer-events: none;
}

/* Lists */
.chapter-list {
  margin: 18px 0 28px 28px;
  padding-left: 8px;
}
.chapter-list li {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.7;
  margin-bottom: 12px;
  color: var(--deep-ink);
}
.chapter-list li::marker {
  color: var(--verdigris);
  font-family: var(--font-display);
}
.chapter-list li strong {
  font-weight: 600;
  color: var(--iron-gall);
}

/* Pull quote */
.pull-quote {
  font-family: var(--font-display);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(1.25rem, 2vw, 1.75rem);
  line-height: 1.45;
  color: var(--iron-gall);
  border-left: 2px solid var(--verdigris);
  padding: 12px 0 12px 26px;
  margin: 38px 0 38px 4px;
  max-width: 620px;
  position: relative;
}
.pull-quote::before {
  content: "";
  position: absolute;
  left: -2px;
  top: 0;
  width: 2px;
  height: 12px;
  background: var(--red-wax);
}
.pull-quote::after {
  content: "";
  position: absolute;
  left: -2px;
  bottom: 0;
  width: 2px;
  height: 12px;
  background: var(--red-wax);
}
.pull-quote strong {
  font-weight: 500;
  font-style: italic;
  color: var(--deep-ink);
}

/* Inline diagram inside a chapter */
.inline-diagram {
  margin: 36px 0;
  padding: 22px 20px 16px;
  border: 1px solid rgba(92,61,46,0.18);
  background: rgba(196,168,130,0.06);
  border-radius: 2px;
  position: relative;
}
.inline-diagram::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  width: 14px;
  height: 14px;
  border-top: 2px solid var(--iron-gall);
  border-left: 2px solid var(--iron-gall);
}
.inline-diagram::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 14px;
  height: 14px;
  border-bottom: 2px solid var(--iron-gall);
  border-right: 2px solid var(--iron-gall);
}
.inline-diagram svg {
  width: 100%;
  height: auto;
  display: block;
  max-width: 620px;
  margin: 0 auto;
}

/* ==========================================================================
   Interstitial plate sections (parallax-eligible)
   ========================================================================== */

.plate-section {
  position: relative;
  min-height: 80vh;
  padding: 80px 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: start;
  background: linear-gradient(
    to bottom,
    rgba(92,61,46,0.03) 0%,
    rgba(92,61,46,0.06) 50%,
    rgba(92,61,46,0.03) 100%
  );
  border-top: 1px solid rgba(92,61,46,0.15);
  border-bottom: 1px solid rgba(92,61,46,0.15);
}
.plate-inner {
  max-width: 960px;
  width: 100%;
  will-change: transform;
}
.plate-figure {
  text-align: center;
}
.plate-svg {
  width: 100%;
  height: auto;
  max-width: 820px;
  margin: 0 auto;
  display: block;
}
.plate-caption {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--iron-gall);
  margin-top: 20px;
  max-width: 620px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 16px;
}
.plate-caption em {
  color: var(--red-wax);
  font-weight: 500;
}

/* ==========================================================================
   SVG path-draw animation (stroke-dasharray/dashoffset)
   ========================================================================== */

/* Drawable SVGs start hidden; JS populates dash lengths and reveals on
   intersection. */
.drawable .draw-path {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  transition: stroke-dashoffset 2.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.drawable.drawn .draw-path {
  stroke-dashoffset: 0;
}

/* Text inside drawable SVGs should fade in after paths draw */
.drawable text {
  opacity: 0;
  transition: opacity 1s ease 1.2s;
}
.drawable.drawn text {
  opacity: 1;
}

/* ==========================================================================
   Endnotes / Colophon
   ========================================================================== */

.endnotes-section {
  background: linear-gradient(to bottom, var(--parchment), #E8DCC0);
  padding-top: 100px;
  padding-bottom: 120px;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 1s ease, transform 1s ease;
  min-height: auto;
}
.endnotes-section.visible {
  opacity: 1;
  transform: translateY(0);
}
.endnotes-layout {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 40px;
}
.endnotes-header {
  text-align: center;
  margin-bottom: 54px;
}
.endnotes-ornament {
  width: 280px;
  height: auto;
  margin: 0 auto 18px;
  display: block;
}
.endnotes-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-style: italic;
  font-size: 2.1rem;
  letter-spacing: 0.03em;
  color: var(--iron-gall);
}
.endnotes-body {
  margin-bottom: 54px;
}
.endnote-entry {
  display: flex;
  gap: 14px;
  margin-bottom: 18px;
  align-items: baseline;
}
.endnote-num {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--verdigris);
  flex-shrink: 0;
  min-width: 24px;
}
.endnote-entry p {
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--deep-ink);
}
.endnote-entry em {
  font-style: italic;
  color: var(--iron-gall);
}
.colophon {
  text-align: center;
  padding-top: 44px;
  border-top: 1px solid rgba(92,61,46,0.25);
}
.colophon p {
  font-family: var(--font-mono);
  font-weight: 300;
  font-size: 0.78rem;
  line-height: 1.9;
  color: var(--iron-gall);
  letter-spacing: 0.04em;
}
.colophon p strong {
  color: var(--deep-ink);
  font-weight: 500;
}
.colophon-year {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.25rem;
  color: var(--red-wax);
  margin-top: 20px;
  letter-spacing: 0.12em;
}

/* ==========================================================================
   Footnote overlay (mobile — when a margin note becomes a tap target)
   ========================================================================== */

.footnote-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(43,33,24,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 20px;
}
.footnote-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
.footnote-card {
  background: var(--parchment);
  border: 1px solid rgba(92,61,46,0.4);
  max-width: 420px;
  width: 100%;
  padding: 30px 30px 24px;
  box-shadow: 0 14px 50px rgba(43,33,24,0.3);
  position: relative;
  transform: translateY(16px) scale(0.98);
  transition: transform 0.3s ease;
}
.footnote-overlay.visible .footnote-card {
  transform: translateY(0) scale(1);
}
.footnote-card::before {
  content: "";
  position: absolute;
  left: 10px; top: 10px; right: 10px; bottom: 10px;
  border: 1px solid rgba(92,61,46,0.25);
  pointer-events: none;
}
.footnote-card .footnote-marker {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--red-wax);
  margin-bottom: 8px;
}
.footnote-card .footnote-body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--deep-ink);
}
.footnote-card .footnote-body em {
  font-style: italic;
  color: var(--iron-gall);
}
.footnote-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--iron-gall);
  cursor: pointer;
  padding: 6px 10px;
  line-height: 1;
}
.footnote-close:hover { color: var(--red-wax); }

/* ==========================================================================
   Responsive behaviour
   ========================================================================== */

@media (max-width: 1100px) {
  :root {
    --gutter-left: 220px;
    --page-pad-x: 48px;
  }
  .side-nav { display: none; }
}

@media (max-width: 900px) {
  :root { --page-pad-x: 32px; }
  .chapter-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .chapter-layout::before { display: none; }
  .margin-column {
    padding-top: 0;
    padding-right: 0;
    order: 2;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid rgba(92,61,46,0.2);
  }
  .chapter-content { order: 1; }
  .margin-annotation { margin-bottom: 0; }
  .margin-illustration {
    margin: 0;
    display: flex;
    justify-content: center;
  }
  .margin-illustration svg { max-width: 140px; }
  .frontispiece-title { letter-spacing: 0.05em; }
}

@media (max-width: 640px) {
  :root { --page-pad-x: 22px; }
  .chapter-section { padding: 90px 22px 70px; }
  .chapter-body { text-align: left; }
  .pull-quote { padding-left: 18px; }
  .drop-cap { font-size: 3.4rem; padding: 6px 8px 0 0; }
  .chapter-list { margin-left: 20px; }
  .colophon-bar-inner {
    gap: 8px;
    font-size: 0.58rem;
    padding: 8px 16px;
  }
  .colophon-mark { font-size: 0.72rem; padding-right: 4px; margin-right: 2px; }
  .plate-section { padding: 50px 18px; min-height: 60vh; }
}

@media (max-width: 480px) {
  .frontispiece { padding: 50px 18px 70px; }
  .frontispiece-title { font-size: 3rem; letter-spacing: 0.04em; }
  .frontispiece-subtitle { font-size: 1rem; }
  .chapter-title { font-size: 1.6rem; }
  .chapter-numeral { font-size: 2.8rem; }
  .pull-quote { font-size: 1.15rem; margin: 26px 0; }
}

/* ==========================================================================
   Reduced motion accommodation
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .chapter-section.chapter,
  .chapter-section.chapter.visible,
  .margin-annotation,
  .margin-illustration,
  .chapter-numeral,
  .chapter-title,
  .endnotes-section {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  .drawable .draw-path {
    stroke-dashoffset: 0 !important;
    transition: none !important;
  }
  .drawable text { opacity: 1 !important; }
  .scroll-indicator { animation: none; }
  .drop-cap { transition: none; }
}
