:root {
  /* DESIGN typography: IBM Plex Mono sparingly for isotopic notation; IBM Plex Sans* Sans** for body explanations and interface labels. */
  --carbon-black: #070604;
  --graphite-sheen: #2E3132;
  --ash-vellum: #E7DDC7;
  --ember-ochre: #C46A2B;
  --diamond-blue: #9FD8E7;
  --biochar-moss: #586B3B;
  --carbonate-chalk: #F5F0E6;
  --serif: "Cormorant Garamond", "Lora", serif;
  --jp: "Noto Serif JP", serif;
  --sans: "IBM Plex Sans", "Inter", sans-serif;
  --mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--carbon-black);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--carbonate-chalk);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 18% 6%, rgba(196, 106, 43, 0.15), transparent 28rem),
    radial-gradient(circle at 84% 24%, rgba(159, 216, 231, 0.07), transparent 25rem),
    linear-gradient(180deg, #070604 0%, #11100d 42%, #070604 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.36;
  z-index: 1;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(245, 240, 230, 0.12) 0 1px, transparent 1.5px),
    radial-gradient(circle at 70% 40%, rgba(231, 221, 199, 0.09) 0 1px, transparent 1.4px),
    linear-gradient(115deg, transparent 0 47%, rgba(231, 221, 199, 0.05) 49%, transparent 53%);
  background-size: 37px 37px, 53px 53px, 220px 220px;
  mix-blend-mode: screen;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; }

.kiln-field {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse at center, transparent 0%, rgba(7, 6, 4, 0.35) 52%, rgba(7, 6, 4, 0.9) 100%);
}

.graphite-shimmer {
  position: absolute;
  inset: -20%;
  background: conic-gradient(from 20deg, transparent, rgba(46, 49, 50, 0.42), transparent, rgba(231, 221, 199, 0.04), transparent);
  animation: graphiteTurn 24s linear infinite;
  filter: blur(38px);
}

.soot-orbit span {
  position: fixed;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(231, 221, 199, 0.5);
  opacity: var(--o, 0.45);
  transform: translate3d(var(--x), var(--y), 0) scale(var(--s, 1));
  transition: transform 900ms ease-out;
}

.codex-spine {
  position: fixed;
  left: clamp(14px, 3vw, 42px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  display: grid;
  gap: 13px;
  padding: 14px 10px;
  border-left: 1px solid rgba(231, 221, 199, 0.17);
  background: linear-gradient(90deg, rgba(7, 6, 4, 0.72), transparent);
}

.spine-seal {
  width: 46px;
  min-height: 62px;
  display: grid;
  place-items: center;
  color: rgba(231, 221, 199, 0.46);
  border: 1px solid rgba(231, 221, 199, 0.16);
  background: rgba(46, 49, 50, 0.34);
  transition: color 420ms ease, border-color 420ms ease, transform 420ms ease, box-shadow 420ms ease;
}

.spine-seal span {
  font-family: var(--jp);
  font-size: 1.12rem;
}

.spine-seal em {
  font-family: var(--mono);
  font-size: 0.58rem;
  font-style: normal;
  letter-spacing: 0.1em;
}

.spine-seal.active {
  color: var(--ember-ochre);
  border-color: rgba(196, 106, 43, 0.8);
  box-shadow: 0 0 26px rgba(196, 106, 43, 0.28), inset 0 0 18px rgba(196, 106, 43, 0.1);
  transform: translateX(8px);
}

.carbon-codex {
  position: relative;
  z-index: 2;
}

.folio {
  min-height: 100vh;
  position: relative;
  display: grid;
  align-items: center;
  padding: clamp(80px, 10vw, 130px) clamp(24px, 7vw, 110px) clamp(80px, 9vw, 120px) clamp(98px, 15vw, 210px);
  isolation: isolate;
}

.folio::before {
  content: "";
  position: absolute;
  inset: 8% 7% 5% 12%;
  border: 1px solid rgba(231, 221, 199, 0.08);
  border-radius: 48% 52% 50% 45% / 3% 4% 2% 3%;
  transform: rotate(var(--tilt, -1deg));
  background: radial-gradient(circle at 30% 20%, rgba(231, 221, 199, 0.04), transparent 42%), rgba(46, 49, 50, 0.08);
  z-index: -1;
}

.entry-chamber {
  min-height: 112vh;
  place-items: center;
  text-align: center;
}

.domain-rubbing {
  width: min(960px, 88vw);
  padding: clamp(38px, 8vw, 82px) clamp(28px, 7vw, 84px);
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 14%, rgba(196, 106, 43, 0.18), transparent 20%),
    linear-gradient(135deg, rgba(231, 221, 199, 0.1), rgba(46, 49, 50, 0.22));
  border: 1px solid rgba(231, 221, 199, 0.22);
  clip-path: polygon(2% 4%, 97% 1%, 99% 92%, 94% 98%, 6% 96%, 0 88%);
  box-shadow: inset 0 0 60px rgba(7, 6, 4, 0.82), 0 40px 120px rgba(0, 0, 0, 0.52);
}

.domain-rubbing::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(7, 6, 4, 0.98) 0%, rgba(7, 6, 4, 0.9) var(--ash-cover, 86%), transparent calc(var(--ash-cover, 86%) + 18%));
  transition: opacity 1000ms ease;
  pointer-events: none;
}

body.revealed .domain-rubbing::after { opacity: 0; }

.kicker, .folio-number, .specimen-strip, .index-tabs, .note-list, .chalk-captions, .correction-slips, .marginalia, .hidden-index {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.13em;
}

.kicker {
  color: var(--ember-ochre);
  font-family: var(--jp);
  font-size: 0.9rem;
  margin: 0 0 14px;
}

h1, h2 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 0.9;
  margin: 0;
}

h1 {
  font-size: clamp(5rem, 16vw, 14rem);
  color: var(--ash-vellum);
  letter-spacing: -0.06em;
  text-shadow: 0 0 30px rgba(196, 106, 43, 0.18);
}

h1 i {
  color: var(--ember-ochre);
  font-style: normal;
}

h2 {
  font-size: clamp(4rem, 11vw, 11rem);
  color: var(--ash-vellum);
  max-width: 850px;
  text-shadow: 0 16px 36px rgba(7, 6, 4, 0.55);
}

.declaration {
  max-width: 760px;
  margin: 32px auto 0;
  font-size: clamp(1.1rem, 2vw, 1.55rem);
  line-height: 1.65;
  color: rgba(245, 240, 230, 0.78);
}

.ash-prompt {
  margin-top: 28px;
  color: var(--ash-vellum);
  background: transparent;
  border: 1px solid rgba(196, 106, 43, 0.58);
  padding: 13px 20px;
  cursor: pointer;
  box-shadow: inset 0 0 18px rgba(196, 106, 43, 0.08), 0 0 20px rgba(196, 106, 43, 0.13);
  transition: transform 320ms ease, background 320ms ease;
}

.ash-prompt:hover { transform: translateY(-3px); background: rgba(196, 106, 43, 0.12); }

.ember-stylus {
  position: absolute;
  width: 20vw;
  height: 2px;
  top: 38%;
  left: 18%;
  background: linear-gradient(90deg, transparent, var(--ember-ochre), transparent);
  box-shadow: 0 0 24px var(--ember-ochre);
  animation: emberTrace 4.8s ease-in-out infinite;
}

.hidden-index {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 860px;
  margin-top: 26px;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 700ms ease, transform 700ms ease;
  font-size: 0.68rem;
  color: var(--carbonate-chalk);
}

.hidden-index span {
  border: 1px solid rgba(231, 221, 199, 0.2);
  padding: 10px 12px;
  background: rgba(7, 6, 4, 0.45);
}

body.revealed .hidden-index { opacity: 1; transform: translateY(0); }

.lattice-reveal {
  position: absolute;
  inset: auto 6vw 8vh auto;
  width: min(52vw, 720px);
  opacity: 0.06;
  fill: none;
  stroke: var(--carbonate-chalk);
  stroke-width: 2;
}

.lattice-reveal path, .lattice-reveal circle, .drawn-spine path, .facet-map path, .facet-map polygon {
  vector-effect: non-scaling-stroke;
}

body.revealed .lattice-reveal {
  opacity: 0.42;
}

.folio-sheet {
  position: relative;
  width: min(980px, 86vw);
  min-height: 62vh;
  padding: clamp(30px, 6vw, 76px);
  border: 1px solid rgba(231, 221, 199, 0.22);
  background:
    radial-gradient(circle at 14% 18%, rgba(245, 240, 230, 0.09), transparent 22%),
    linear-gradient(140deg, rgba(231, 221, 199, 0.12), rgba(46, 49, 50, 0.34) 60%, rgba(7, 6, 4, 0.76));
  box-shadow: inset 0 0 70px rgba(7, 6, 4, 0.72), 0 34px 120px rgba(0, 0, 0, 0.45);
  clip-path: polygon(1% 2%, 96% 0, 100% 9%, 98% 96%, 86% 100%, 4% 97%, 0 84%);
  transform: translateY(40px) rotate(var(--paper-tilt, -0.8deg));
  opacity: 0.42;
  transition: opacity 900ms ease, transform 900ms ease, filter 900ms ease;
  filter: blur(2px) saturate(0.82);
}

.folio.in-view .folio-sheet {
  opacity: 1;
  transform: translateY(0) rotate(var(--paper-tilt, -0.8deg));
  filter: blur(0) saturate(1);
}

.folio:nth-of-type(even) .folio-sheet { margin-left: auto; --paper-tilt: 0.9deg; }
.folio:nth-of-type(odd) .folio-sheet { margin-right: auto; }

.folio-number {
  color: var(--ember-ochre);
  font-size: 0.72rem;
  margin-bottom: 18px;
}

.folio p {
  font-size: clamp(1.05rem, 1.7vw, 1.32rem);
  line-height: 1.75;
  max-width: 650px;
  color: rgba(245, 240, 230, 0.77);
}

.large-inscription {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 3vw, 3.1rem) !important;
  line-height: 1.16 !important;
  color: var(--ash-vellum) !important;
}

.specimen-strip, .index-tabs, .chalk-captions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
  font-size: 0.68rem;
}

.specimen-strip span, .index-tabs span, .chalk-captions span {
  padding: 9px 11px;
  border: 1px solid rgba(231, 221, 199, 0.21);
  background: rgba(7, 6, 4, 0.32);
}

.soot-title {
  position: absolute;
  right: 6%;
  bottom: 7%;
  display: flex;
  gap: 7px;
  font-family: var(--serif);
  font-size: clamp(2.4rem, 7vw, 6rem);
  opacity: 0.12;
}

.folio.in-view .soot-title b {
  animation: sootGather 1600ms ease forwards;
  animation-delay: calc(var(--i, 0) * 90ms);
}

.soot-title b:nth-child(1) { --i: 1; } .soot-title b:nth-child(2) { --i: 2; } .soot-title b:nth-child(3) { --i: 3; }
.soot-title b:nth-child(4) { --i: 4; } .soot-title b:nth-child(5) { --i: 5; } .soot-title b:nth-child(6) { --i: 6; }

.drawn-spine, .facet-map {
  width: min(620px, 100%);
  margin-top: 24px;
  fill: none;
  stroke: var(--carbonate-chalk);
  stroke-width: 1.5;
  opacity: 0.74;
}

.drawn-spine path, .facet-map path, .facet-map polygon {
  stroke-dasharray: 900;
  stroke-dashoffset: 900;
}

.folio.in-view .drawn-spine path, .folio.in-view .facet-map path, .folio.in-view .facet-map polygon {
  animation: pathDraw 2200ms ease forwards;
}

.glossary-rub {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.glossary-rub div {
  padding: 15px;
  background: rgba(7, 6, 4, 0.3);
  border-left: 2px solid var(--ember-ochre);
}

.glossary-rub dt {
  font-family: var(--jp);
  color: var(--ash-vellum);
}

.glossary-rub dd {
  margin: 5px 0 0;
  color: rgba(245, 240, 230, 0.65);
}

.diamond-tray { background: radial-gradient(circle at 60% 25%, rgba(159, 216, 231, 0.13), transparent 24%), linear-gradient(140deg, rgba(231, 221, 199, 0.1), rgba(46, 49, 50, 0.3), rgba(7, 6, 4, 0.82)); }
.facet-map { stroke: var(--diamond-blue); filter: drop-shadow(0 0 16px rgba(159, 216, 231, 0.26)); }
.facet-map circle { fill: var(--diamond-blue); stroke: none; }

.field-note { background: radial-gradient(circle at 24% 30%, rgba(88, 107, 59, 0.2), transparent 28%), linear-gradient(140deg, rgba(231, 221, 199, 0.12), rgba(46, 49, 50, 0.36), rgba(7, 6, 4, 0.72)); }
.pressed-leaf { position: absolute; right: 9%; top: 18%; width: 190px; height: 300px; opacity: 0.42; }
.pressed-leaf span { position: absolute; left: 88px; bottom: 0; width: 2px; height: 280px; background: var(--biochar-moss); transform-origin: bottom; }
.pressed-leaf span::after { content: ""; position: absolute; top: 26px; left: 0; width: 76px; height: 34px; border-radius: 100% 0; background: #070604; border: 1px solid rgba(88, 107, 59, 0.72); transform: rotate(-28deg); }
.pressed-leaf span:nth-child(2) { transform: rotate(23deg); } .pressed-leaf span:nth-child(3) { transform: rotate(-34deg) scale(.82); } .pressed-leaf span:nth-child(4) { transform: rotate(42deg) scale(.68); }
.note-list { max-width: 520px; padding-left: 18px; color: rgba(231, 221, 199, 0.7); font-size: 0.74rem; line-height: 2; }

.chalk-archive { background: radial-gradient(circle at 65% 35%, rgba(245, 240, 230, 0.18), transparent 22%), linear-gradient(140deg, rgba(231, 221, 199, 0.18), rgba(46, 49, 50, 0.27), rgba(7, 6, 4, 0.72)); }
.carbonate-diagram { position: relative; width: 280px; height: 220px; margin-top: 28px; display: grid; place-items: center; color: var(--carbonate-chalk); font-family: var(--mono); font-size: 2.4rem; }
.carbonate-diagram::before { content: ""; position: absolute; inset: 18px; border: 1px dashed rgba(245, 240, 230, 0.55); border-radius: 50%; animation: chalkBloom 5s ease-in-out infinite; }
.carbonate-diagram i { position: absolute; width: 62px; height: 62px; border: 1px solid rgba(245, 240, 230, 0.38); border-radius: 50%; }
.carbonate-diagram i:nth-of-type(1) { top: 16px; } .carbonate-diagram i:nth-of-type(2) { bottom: 20px; left: 34px; } .carbonate-diagram i:nth-of-type(3) { bottom: 20px; right: 34px; }

.errata-cloud { background: radial-gradient(circle at 70% 10%, rgba(159, 216, 231, 0.09), transparent 27%), linear-gradient(140deg, rgba(231, 221, 199, 0.09), rgba(46, 49, 50, 0.32), rgba(7, 6, 4, 0.78)); }
.correction-slips { position: relative; min-height: 260px; margin-top: 28px; }
.correction-slips span { position: absolute; display: inline-block; padding: 13px 15px; color: var(--graphite-sheen); background: var(--ash-vellum); box-shadow: 0 14px 30px rgba(0,0,0,.34); font-size: .72rem; animation: slipFloat 7s ease-in-out infinite; }
.correction-slips span:nth-child(1) { left: 4%; top: 12%; transform: rotate(-4deg); } .correction-slips span:nth-child(2) { left: 42%; top: 2%; transform: rotate(5deg); animation-delay: -1s; } .correction-slips span:nth-child(3) { left: 14%; top: 56%; transform: rotate(3deg); animation-delay: -2s; } .correction-slips span:nth-child(4) { left: 52%; top: 48%; transform: rotate(-2deg); animation-delay: -3s; }
.closing-mark { font-family: var(--jp); color: var(--ember-ochre) !important; }

.marginalia {
  position: absolute;
  max-width: 230px !important;
  font-size: 0.68rem !important;
  color: rgba(231, 221, 199, 0.46) !important;
  border-top: 1px solid rgba(196, 106, 43, 0.42);
  padding-top: 12px;
}
.marginalia.right { right: clamp(20px, 5vw, 70px); top: 24%; }
.marginalia.left { left: clamp(98px, 13vw, 170px); bottom: 18%; }

.cursor-brush {
  position: fixed;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 20;
  background: radial-gradient(circle, rgba(196, 106, 43, 0.16), rgba(231, 221, 199, 0.06) 38%, transparent 70%);
  mix-blend-mode: screen;
  transform: translate3d(-200px, -200px, 0);
}

@keyframes graphiteTurn { to { transform: rotate(360deg); } }
@keyframes emberTrace { 0%, 100% { transform: translateX(-30vw) rotate(-3deg); opacity: 0; } 35%, 65% { opacity: 1; } 50% { transform: translateX(48vw) rotate(2deg); } }
@keyframes sootGather { from { opacity: 0; filter: blur(12px); transform: translateY(24px) scale(1.8); } to { opacity: 1; filter: blur(0); transform: translateY(0) scale(1); } }
@keyframes pathDraw { to { stroke-dashoffset: 0; } }
@keyframes chalkBloom { 0%,100% { transform: scale(.92); opacity: .35; } 50% { transform: scale(1.06); opacity: .85; } }
@keyframes slipFloat { 0%,100% { margin-top: 0; } 50% { margin-top: -16px; } }

@media (max-width: 760px) {
  .codex-spine { left: 6px; gap: 7px; padding: 8px 5px; }
  .spine-seal { width: 34px; min-height: 46px; }
  .folio { padding-left: 58px; padding-right: 14px; }
  .folio-sheet { width: 100%; min-height: auto; }
  .glossary-rub { grid-template-columns: 1fr; }
  .marginalia { display: none; }
  .pressed-leaf { opacity: .16; right: 0; }
  .correction-slips span { position: relative; left: auto !important; top: auto !important; margin: 8px; }
}
