:root {
  /* Compliance lexicon: (Google IntersectionObserver at `threshold: 0.15`. ornamental dividers draw themselves (SVG path animation (serif typewriter = deliberate friction */
  --paper: #e8eaed;
  --paper-alt: #d4d6d9;
  --ink: #1c1f26;
  --slate: #5c6370;
  --red: #8b2f3a;
  --copper: #4a7c6f;
  --iron: #3d4150;
  --ghost: #c2c5cc;
  --gilt: #b8a88a;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.05rem, 1.3vw, 1.25rem);
  line-height: 1.75;
  text-rendering: optimizeLegibility;
  font-variant-ligatures: common-ligatures;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background:
    repeating-linear-gradient(90deg, transparent 0 34px, rgba(61,65,80,0.06) 35px 36px),
    repeating-linear-gradient(0deg, transparent 0 42px, rgba(255,255,255,0.18) 43px 44px);
  mix-blend-mode: multiply;
  z-index: 0;
}

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

.chapter {
  min-height: 100vh;
  position: relative;
  display: grid;
  place-items: center;
  padding: 7rem 15%;
  overflow: hidden;
  opacity: 0;
  transition: opacity 600ms ease;
}

.chapter.is-visible { opacity: 1; }
.chapter:nth-of-type(even) { background: var(--paper-alt); }
.chapter:nth-of-type(even)::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.04;
  pointer-events: none;
  background:
    repeating-conic-gradient(from 45deg, var(--iron) 0 8deg, transparent 8deg 18deg),
    repeating-linear-gradient(135deg, transparent 0 16px, var(--iron) 17px 18px);
  background-size: 96px 96px, 42px 42px;
}

.chapter__inner { width: min(100%, 980px); position: relative; z-index: 2; }
.chapter__number {
  font-family: "IBM Plex Mono", monospace;
  color: var(--slate);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.78rem;
  margin: 0 0 0.7rem;
}

h1, h2, h3 {
  font-family: "Playfair Display", serif;
  font-weight: 700;
  font-feature-settings: 'liga' 1, 'swsh' 1;
  color: var(--ink);
}

h1 {
  font-size: clamp(3rem, 9vw, 8rem);
  letter-spacing: 0.04em;
  margin: 0;
  line-height: 0.95;
  text-align: center;
  font-variant: small-caps;
}

h2 {
  font-size: clamp(2.5rem, 6vw, 5rem);
  letter-spacing: 0.04em;
  line-height: 0.98;
  margin: 0 0 2rem;
  font-variant: small-caps;
}

h2 > span {
  font-family: "Cinzel Decorative", serif;
  color: var(--red);
  text-shadow: 1px 1px 0 var(--gilt);
}

h3 { font-size: clamp(1.8rem, 3vw, 3rem); margin: 0 0 1rem; }
p { margin: 0 0 1.35rem; }
strong, .red { color: var(--red); font-weight: 700; }
em { font-style: italic; }
code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85em;
  color: var(--copper);
}

.bokeh {
  position: absolute;
  inset: -12%;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 22%, rgba(194,197,204,0.25) 0 8%, transparent 18%),
    radial-gradient(circle at 72% 18%, rgba(184,168,138,0.18) 0 9%, transparent 19%),
    radial-gradient(circle at 78% 72%, rgba(194,197,204,0.21) 0 10%, transparent 21%),
    radial-gradient(circle at 28% 82%, rgba(184,168,138,0.15) 0 7%, transparent 17%);
  filter: blur(40px);
  animation: drift 30s ease-in-out infinite alternate;
  will-change: transform;
}

.bokeh--red {
  background:
    radial-gradient(circle at 15% 18%, rgba(139,47,58,0.08) 0 13%, transparent 24%),
    radial-gradient(circle at 70% 30%, rgba(184,168,138,0.22) 0 11%, transparent 22%),
    radial-gradient(circle at 50% 80%, rgba(139,47,58,0.08) 0 15%, transparent 28%);
}

@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to { transform: translate3d(3%, 2%, 0) scale(1.08); }
}

.chapter--hero { text-align: center; }
.cartouche {
  position: absolute;
  width: min(84vw, 980px);
  aspect-ratio: 2.5 / 1;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -56%);
  opacity: 0.95;
}
.cartouche__svg { width: 100%; height: 100%; fill: none; stroke: var(--iron); stroke-width: 3; }
.draw {
  stroke-dasharray: 2200;
  stroke-dashoffset: 2200;
  animation: path-draw 2s ease forwards;
}
.draw.delay { animation-delay: 0.25s; }
.draw.delay2 { animation-delay: 0.55s; stroke: var(--copper); }

@keyframes path-draw { to { stroke-dashoffset: 0; } }

.typewriter {
  width: min(780px, 86vw);
  margin: 3rem auto 0;
  color: var(--red);
  font-family: "Playfair Display", serif;
  font-size: clamp(1.5rem, 3vw, 2.8rem);
  line-height: 1.18;
  overflow: hidden;
  white-space: nowrap;
  border-right: 2px solid var(--copper);
  animation: typing 4.2s steps(74, end) 1s both, caret 800ms step-end infinite;
}

@keyframes typing { from { width: 0; } }
@keyframes caret { 50% { border-color: transparent; } }

.ornament {
  height: 86px;
  display: grid;
  place-items: center;
  background: linear-gradient(90deg, transparent, rgba(61,65,80,0.04), transparent);
}
.ornament svg { width: min(86vw, 1120px); height: 100%; fill: none; stroke: var(--iron); stroke-width: 2.2; }
.ornament path { stroke-dasharray: 1400; stroke-dashoffset: 1400; transition: stroke-dashoffset 800ms ease; }
.ornament.is-visible path { stroke-dashoffset: 0; }
.ornament--grand { height: 130px; background: var(--paper-alt); }
.ornament--grand svg { width: 94vw; stroke-width: 2; }

.dropcap {
  float: left;
  font-family: "Cinzel Decorative", serif;
  font-weight: 700;
  font-size: 4em;
  line-height: 0.85;
  margin-right: 0.15em;
  color: var(--iron);
  background: radial-gradient(circle, rgba(184,168,138,0.45), transparent 62%);
}

.lock-motif {
  position: absolute;
  right: -8rem;
  top: 7rem;
  width: 130px;
  color: var(--copper);
  cursor: pointer;
}
.lock-motif svg { width: 100%; fill: none; stroke: currentColor; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.lock-shackle { transform-origin: 68px 92px; transition: transform 600ms ease; }
.lock-motif.is-unlocked .lock-shackle { transform: rotate(-28deg) translate(-8px, -3px); color: var(--red); }

.duel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5rem;
  position: relative;
}
.duel::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 18px;
  transform: translateX(-50%);
  background: repeating-linear-gradient(0deg, var(--iron) 0 12px, transparent 12px 21px);
  mask: radial-gradient(circle, black 34%, transparent 36%) center/18px 34px repeat-y;
  opacity: 0.55;
}
.duel ul { list-style: none; padding: 0; margin: 0; }
.duel li { margin: 0 0 1rem; color: var(--ink); }
.duel li span { font-family: "Cinzel Decorative", serif; color: var(--copper); margin-right: 0.4rem; }

.chapter--fork { background: var(--paper); text-align: center; }
.fork-word {
  font-size: clamp(6rem, 15vw, 12rem);
  color: var(--red);
  line-height: 0.82;
  margin: 0 0 2rem;
  cursor: pointer;
}
.fork-word:hover { animation: shake 300ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
.manifesto { font-size: 1.15em; text-align: left; }
.code-line {
  display: inline-block;
  margin-top: 1rem;
  padding: 1rem 1.3rem;
  border: 1px solid var(--iron);
  box-shadow: inset 0 0 0 6px rgba(194,197,204,0.38);
  background: rgba(232,234,237,0.72);
}

.closing-frame {
  text-align: center;
  padding: 3rem;
  border: 2px solid var(--iron);
  outline: 1px solid var(--gilt);
  outline-offset: -14px;
  background: rgba(232,234,237,0.64);
}
.date { font-family: "IBM Plex Mono", monospace; color: var(--copper); letter-spacing: 0.08em; }
.final-line { font-family: "Playfair Display", serif; font-size: clamp(2rem, 5vw, 4.8rem); line-height: 1.08; }
.quiet { color: var(--slate); }

.compass {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 10;
  border: 1px solid var(--iron);
  color: var(--copper);
  background: rgba(232,234,237,0.76);
  width: 78px;
  height: 78px;
  border-radius: 50%;
  font-family: "IBM Plex Mono", monospace;
  cursor: pointer;
  mix-blend-mode: multiply;
  transition: color 250ms ease, border-color 250ms ease, box-shadow 250ms ease;
}
.compass:hover, .compass.is-pulsing { color: var(--gilt); border-color: var(--gilt); box-shadow: 0 0 0 7px rgba(184,168,138,0.16); }
.compass__rose { display: block; font-size: 2rem; line-height: 1; animation: rotate-slow 18s linear infinite; }
.compass__label { display: block; font-size: 0.62rem; letter-spacing: 0.12em; margin-top: 0.18rem; }
@keyframes rotate-slow { to { transform: rotate(360deg); } }

.toc {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(430px, 88vw);
  z-index: 9;
  transform: translateX(105%);
  transition: transform 420ms ease;
  background: rgba(212,214,217,0.96);
  border-left: 2px solid var(--iron);
  padding: 7rem 2rem 2rem;
}
.toc.is-open { transform: translateX(0); }
.toc__frame { border: 1px solid var(--iron); padding: 2rem; min-height: 65vh; background: rgba(232,234,237,0.55); }
.toc__kicker { font-family: "IBM Plex Mono", monospace; color: var(--slate); text-transform: uppercase; letter-spacing: 0.18em; font-size: 0.75rem; }
.toc a {
  display: block;
  color: var(--copper);
  text-decoration: none;
  font-family: "Playfair Display", serif;
  font-size: 1.35rem;
  margin: 1.35rem 0;
  transition: color 180ms ease;
}
.toc a:hover { color: var(--gilt); animation: shake-subtle 320ms ease both; }

.shake-now { animation: shake-subtle 320ms ease both; }
@keyframes shake-subtle {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-2px) rotate(-0.5deg); }
  40% { transform: translateX(2px) rotate(0.5deg); }
  60% { transform: translateX(-1px) rotate(-0.3deg); }
  80% { transform: translateX(1px) rotate(0.3deg); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-4px); }
  30% { transform: translateX(4px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

@media (max-width: 768px) {
  .chapter { padding: 5rem 8%; }
  .typewriter { white-space: normal; border-right: 0; animation: fade-in 900ms ease 800ms both; }
  .duel { grid-template-columns: 1fr; gap: 2.5rem; }
  .duel::before { display: none; }
  .lock-motif { position: relative; right: auto; top: auto; margin: 0 0 1rem auto; width: 92px; }
  .compass { top: auto; right: 1rem; bottom: 1rem; width: 62px; height: 62px; }
  .compass__rose { font-size: 1.55rem; }
  .compass__label { font-size: 0.52rem; }
  .toc { padding-top: 4rem; }
  .closing-frame { padding: 2rem 1.4rem; }
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@media print {
  body { font-size: 11pt; background: #e8eaed; }
  .chapter { min-height: auto; padding: 1in 0.75in; opacity: 1; break-inside: avoid; }
  .bokeh, .compass, .toc { display: none; }
  .ornament path, .draw { stroke-dashoffset: 0; }
}
