/* Compliance lexicon: (Google Interactive Voice: Voice:** used verdicts IntersectionObserver trigger staggered (`opacity: 1` character */
:root {
  --deep: #1a120a;
  --surface: #2c1e14;
  --parchment: #d4c5b0;
  --ivory: #f5ece0;
  --copper: #b87333;
  --teal: #2a9d8f;
  --amber: #ffa726;
  --ink: #a89279;
  --aqua: #00e5cc;
  --leather: #5a3e28;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--deep);
  color: var(--parchment);
  font-family: "Fira Sans", Inter, Arial, sans-serif;
  font-size: clamp(1rem, 1.8vw, 1.15rem);
  line-height: 1.72;
  letter-spacing: 0.01em;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  top: 12vh;
  width: 28vw;
  height: 76vh;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(circle at 50% 22%, rgba(255, 167, 38, 0.04), transparent 62%);
  animation: marginCandle 12s ease-in-out infinite;
}

body::before { left: 2vw; }
body::after { right: 2vw; animation-delay: -6s; }

.ambient-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 167, 38, 0.06) 0%, transparent 60%),
    radial-gradient(circle at 18% 70%, rgba(42, 157, 143, 0.055), transparent 28%),
    radial-gradient(circle at 82% 18%, rgba(184, 115, 51, 0.045), transparent 30%);
  animation: candleFlicker 4s ease-in-out infinite;
}

.bubble-field {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.bubble {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.06);
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.15) 0%, transparent 50%),
    radial-gradient(circle at 70% 70%, rgba(0,229,204,0.08) 0%, transparent 60%),
    radial-gradient(circle at 45% 45%, rgba(255,167,38,0.035), transparent 68%);
  backdrop-filter: blur(2px);
  box-shadow: inset 10px 10px 28px rgba(245,236,224,0.035), inset -16px -12px 34px rgba(0,229,204,0.035);
  animation-name: bubbleDrift;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-direction: alternate;
}

.margin-rule {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 1px;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(transparent, rgba(184,115,51,0.45) 12%, rgba(90,62,40,0.75) 50%, rgba(184,115,51,0.45) 88%, transparent);
}

.margin-rule::before,
.margin-rule::after {
  content: "✦";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: var(--copper);
  font-family: "Cormorant Garamond", serif;
  opacity: 0.65;
}

.margin-rule::before { top: 24%; }
.margin-rule::after { top: 68%; }
.margin-rule-left { left: 20%; }
.margin-rule-right { right: 20%; }

.parchment-column {
  position: relative;
  z-index: 2;
  max-width: 680px;
  margin: 0 auto;
  padding: 3.2rem 2.4rem;
  background:
    linear-gradient(90deg, rgba(90,62,40,0.22), transparent 7%, transparent 93%, rgba(90,62,40,0.22)),
    radial-gradient(circle at 50% 0%, rgba(184,115,51,0.08) 0%, transparent 38%),
    var(--surface);
  box-shadow: 0 0 80px rgba(26, 18, 10, 0.3), inset 0 0 0 1px rgba(90,62,40,0.8), inset 0 0 42px rgba(26,18,10,0.4);
}

.chapter {
  position: relative;
  min-height: 88vh;
  padding: 4.2rem 0 3.6rem;
}

.chapter::before {
  content: "";
  position: absolute;
  inset: 0 -1.1rem auto;
  height: 240px;
  background: radial-gradient(circle at 50% 0%, rgba(184,115,51,0.08) 0%, transparent 50%);
  pointer-events: none;
}

.opening { padding-top: 12vh; }

.folio-mark {
  margin: 0 0 1.5rem;
  color: var(--ink);
  font-family: "Special Elite", Courier, monospace;
  font-size: clamp(0.85rem, 1.4vw, 1rem);
  text-transform: lowercase;
}

h1, h2 {
  margin: 0 0 1.35rem;
  color: var(--ivory);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: clamp(2rem, 4.5vw, 3.4rem);
  line-height: 1.15;
  letter-spacing: 0.03em;
}

h1 { font-size: clamp(2.8rem, 7vw, 5.8rem); }

p { margin: 0 0 1.45rem; }

.lead {
  color: var(--ivory);
  font-size: clamp(1.12rem, 2vw, 1.35rem);
}

.chapter-number {
  position: absolute;
  top: 1.8rem;
  right: -0.25rem;
  z-index: -1;
  color: var(--copper);
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(3rem, 8vw, 7rem);
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  opacity: 0.12;
}

.ornament-divider {
  width: min(300px, 72%);
  margin: 1rem auto 0;
}

.ornament-divider svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.ornament-divider path,
.compass-button path,
.compass-button circle {
  fill: none;
  stroke: var(--copper);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ornament-divider path {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  transition: stroke-dashoffset 1.5s ease-out;
}

.ornament-divider.is-drawn path { stroke-dashoffset: 0; }

.ledger {
  margin: 2.2rem 0;
  border: 1px solid var(--leather);
  border-radius: 2px;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.05), 0 18px 34px rgba(26,18,10,0.18);
  position: relative;
}

.ledger::before,
.ledger::after {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  border-color: var(--copper);
  opacity: 0.7;
}

.ledger::before { top: 8px; left: 8px; border-top: 1px solid; border-left: 1px solid; }
.ledger::after { right: 8px; bottom: 8px; border-right: 1px solid; border-bottom: 1px solid; }

.ledger-entry {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.25rem 1.15rem 2.15rem;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 500ms ease, transform 500ms ease;
}

.ledger-entry.is-visible { opacity: 1; transform: translateY(0); }

.ledger-entry + .ledger-entry {
  background-image: linear-gradient(90deg, transparent, var(--leather), transparent);
  background-repeat: no-repeat;
  background-size: 100% 1px;
  background-position: top center;
}

.ledger-entry::before {
  content: "◆";
  position: absolute;
  top: -0.8rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--copper);
  font-size: 0.75rem;
}

.entry-name {
  color: var(--ivory);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.45rem;
  font-style: italic;
  line-height: 1.2;
}

.entry-value {
  color: var(--ink);
  font-family: "Special Elite", Courier, monospace;
  font-size: clamp(0.85rem, 1.4vw, 1rem);
  text-align: right;
}

.type-note,
.marginalia {
  color: var(--ink);
  font-family: "Special Elite", Courier, monospace;
  font-size: clamp(0.85rem, 1.4vw, 1rem);
  line-height: 1.65;
  min-height: 2.5em;
}

.marginalia {
  margin: 2.2rem -5.5rem 0 auto;
  max-width: 260px;
  padding-left: 1rem;
  border-left: 1px solid var(--copper);
  transform: rotate(-1.5deg);
}

.char { opacity: 0; transition: opacity 120ms ease; }
.char.visible { opacity: 1; }
.cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: var(--aqua);
  animation: blink 0.8s step-end infinite;
}

.pull-quote {
  margin: 2rem 0;
  padding: 1.2rem 0 1.2rem 1.4rem;
  color: var(--ivory);
  border-left: 1px solid var(--copper);
  font-family: "Special Elite", Courier, monospace;
  font-size: clamp(1rem, 1.8vw, 1.15rem);
}

.candle-progress {
  position: fixed;
  left: 2rem;
  top: 9vh;
  width: 18px;
  height: 84vh;
  z-index: 4;
  pointer-events: none;
}

.flame {
  position: absolute;
  top: 0;
  left: 3px;
  width: 12px;
  fill: var(--amber);
  filter: drop-shadow(0 0 12px rgba(255,167,38,0.65));
  animation: flameFlicker 1.25s ease-in-out infinite;
}

.flame .inner { fill: var(--aqua); opacity: 0.55; }

.wick-line {
  position: absolute;
  top: 28px;
  left: 8px;
  width: 1px;
  height: 80vh;
  background: linear-gradient(var(--copper), rgba(184,115,51,0.2));
  transform-origin: top;
}

.compass-button {
  position: fixed;
  right: 2rem;
  bottom: 2rem;
  z-index: 6;
  width: 58px;
  height: 58px;
  padding: 9px;
  border: 1px solid rgba(184,115,51,0.78);
  border-radius: 50%;
  background: rgba(44,30,20,0.74);
  backdrop-filter: blur(7px);
  cursor: pointer;
  transition: transform 240ms ease, border-color 240ms ease;
}

.compass-button:hover,
.compass-button.is-open { transform: rotate(22deg) scale(1.05); border-color: var(--aqua); }
.compass-button:hover path,
.compass-button.is-open path { stroke: var(--aqua); }

.toc-overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(26,18,10,0.62);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease;
}

.toc-overlay.is-open { opacity: 1; pointer-events: auto; }

.toc-panel {
  width: min(520px, calc(100vw - 3rem));
  padding: 2rem;
  border: 1px solid var(--leather);
  background: rgba(44,30,20,0.95);
  box-shadow: 0 0 80px rgba(26,18,10,0.55), inset 1px 1px 0 rgba(255,255,255,0.05);
}

.toc-panel p {
  color: var(--ink);
  font-family: "Special Elite", Courier, monospace;
  margin-bottom: 1.4rem;
}

.toc-panel a {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  color: var(--ivory);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.55rem;
  text-decoration: none;
  margin: 0.6rem 0;
}

.toc-panel a i {
  flex: 1;
  border-bottom: 1px dotted var(--leather);
}

.toc-panel a em {
  color: var(--copper);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.05rem;
}

.toc-panel a:hover span,
.toc-panel a:hover em { color: var(--aqua); }

@keyframes candleFlicker {
  0% { opacity: 0.06; }
  30% { opacity: 0.075; }
  50% { opacity: 0.055; }
  70% { opacity: 0.08; }
  100% { opacity: 0.06; }
}

@keyframes marginCandle {
  0%, 100% { transform: translateY(-14px); opacity: 0.8; }
  50% { transform: translateY(18px); opacity: 1; }
}

@keyframes bubbleDrift {
  from { transform: translate3d(-12px, var(--drift-start), 0) scale(0.95); }
  to { transform: translate3d(18px, var(--drift-end), 0) scale(1.05); }
}

@keyframes blink { 50% { opacity: 0; } }

@keyframes flameFlicker {
  0%, 100% { transform: scaleX(1) translateY(0); }
  35% { transform: scaleX(0.82) translateY(1px); }
  70% { transform: scaleX(1.16) translateY(-1px); }
}

@media (max-width: 980px) {
  .margin-rule-left { left: 5%; }
  .margin-rule-right { right: 5%; }
  .marginalia { margin-right: 0; }
  .candle-progress { left: 0.7rem; }
}

@media (max-width: 640px) {
  .parchment-column { padding: 2.6rem 1.35rem; }
  .chapter { min-height: auto; padding: 3.4rem 0; }
  .ledger-entry { display: block; padding-left: 1.15rem; }
  .entry-value { display: block; margin-top: 0.45rem; text-align: left; }
  .compass-button { right: 1rem; bottom: 1rem; }
  .margin-rule { display: none; }
}
