:root {
  --carbon-black: #0D0B08;
  --library-umber: #2B1D14;
  --verdigris: #2F6F5E;
  --parchment: #D8C7A3;
  --copper: #B56A3A;
  --bone: #F1E6CF;
  --wine: #3A1622;
  --display: "Cormorant Garamond", Cormorant, Georgia, serif;
  --body: "Libre Baskerville", Georgia, serif;
  --annotation: "EB Garamond", Garamond, Georgia, serif;
  --Interaction: hover;
  --include: evidence;
  --hovering: marginalia;
  --annotations: notes;
  --tiny: small;
  --footnotes: exposed;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--parchment);
  background:
    radial-gradient(circle at 50% 16%, rgba(47,111,94,.22), transparent 34rem),
    radial-gradient(circle at 10% 80%, rgba(58,22,34,.55), transparent 28rem),
    linear-gradient(135deg, var(--carbon-black), var(--library-umber) 56%, var(--carbon-black));
  font-family: var(--body);
  overflow-x: hidden;
}

.grain, .motes {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.grain {
  opacity: .18;
  background-image: radial-gradient(rgba(241,230,207,.22) 1px, transparent 1px), radial-gradient(rgba(13,11,8,.75) 1px, transparent 1px);
  background-size: 21px 19px, 13px 17px;
  mix-blend-mode: overlay;
}
.mote {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: rgba(241,230,207,.55);
  opacity: var(--o);
  transform: translate3d(var(--x), var(--y), 0);
  animation: dust var(--d) linear infinite;
}

.folio-index {
  position: fixed;
  right: 1.35rem;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  gap: .55rem;
  z-index: 20;
}
.folio-tab {
  width: 2.3rem;
  height: 2.9rem;
  border: 1px solid rgba(216,199,163,.34);
  border-left-color: var(--copper);
  background: rgba(43,29,20,.72);
  color: var(--parchment);
  font-family: var(--annotation);
  font-size: .82rem;
  letter-spacing: .1em;
  cursor: pointer;
  transition: transform .5s ease, background .5s ease, color .5s ease;
}
.folio-tab.active, .folio-tab:hover {
  background: rgba(47,111,94,.8);
  color: var(--bone);
  transform: translateX(-.35rem);
}

.scene {
  min-height: 100vh;
  position: relative;
  display: grid;
  place-items: center;
  padding: 6rem 2rem;
  isolation: isolate;
}
.scene::before {
  content: attr(data-chapter);
  position: absolute;
  left: 2rem;
  top: 2rem;
  font: 700 8rem/1 var(--display);
  color: rgba(216,199,163,.045);
}
.glass-plate {
  transform-style: preserve-3d;
  border: 1px solid rgba(216,199,163,.18);
  box-shadow: 0 28px 80px rgba(0,0,0,.48), inset 0 0 80px rgba(241,230,207,.025);
  backdrop-filter: blur(2px);
}

.title-plate {
  width: min(760px, 88vw);
  text-align: center;
  padding: 4rem 2rem;
  background: radial-gradient(circle at 50% 50%, rgba(43,29,20,.88), rgba(13,11,8,.75));
  z-index: 4;
}
.overline, .caption, .chamber-mark {
  font-family: var(--annotation);
  font-variant: small-caps;
  letter-spacing: .18em;
  color: var(--copper);
}
h1, h2 {
  font-family: var(--display);
  color: var(--bone);
  letter-spacing: -.035em;
  margin: 0;
}
h1 { font-size: clamp(4rem, 12vw, 11rem); line-height: .8; }
h2 { font-size: clamp(2.6rem, 6vw, 6.5rem); line-height: .9; }
p { font-size: clamp(1rem, 1.45vw, 1.25rem); line-height: 1.85; }
.thesis { max-width: 34rem; margin: 1.5rem auto 0; color: var(--parchment); }

.carbon-ring {
  position: absolute;
  width: min(72vw, 720px);
  aspect-ratio: 1;
  opacity: .7;
  filter: drop-shadow(0 0 35px rgba(47,111,94,.45));
  animation: orbit 48s linear infinite;
}
.carbon-ring svg { width: 100%; height: 100%; fill: none; stroke: var(--verdigris); stroke-width: 1.5; stroke-dasharray: 820; stroke-dashoffset: 820; animation: draw 4s ease forwards; }
.carbon-ring circle:not(:first-child) { fill: var(--verdigris); stroke: none; }

.scrap {
  position: absolute;
  min-width: 10rem;
  min-height: 2.5rem;
  padding: .8rem 1rem;
  font-family: var(--annotation);
  color: var(--library-umber);
  background: rgba(216,199,163,.82);
  box-shadow: 0 15px 35px rgba(0,0,0,.42);
  animation: drift 8s ease-in-out infinite alternate;
}
.paper::after, .vellum::after { content: ""; position: absolute; inset: .5rem; border: 1px solid rgba(43,29,20,.22); }
.one { left: 8vw; top: 22vh; transform: rotate(-8deg); }
.two { right: 10vw; top: 18vh; transform: rotate(9deg); }
.three { left: 15vw; bottom: 17vh; width: 13rem; border-radius: 48% 52% 42% 58%; background: rgba(47,111,94,.28); }
.four { right: 14vw; bottom: 21vh; transform: rotate(-4deg); }
.five { left: 27vw; top: 72vh; }
.six { right: 26vw; top: 68vh; }
.skeleton, .loading-band {
  overflow: hidden;
  background: rgba(216,199,163,.12);
  border: 1px solid rgba(241,230,207,.12);
}
.skeleton::before, .loading-band::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(241,230,207,.42), rgba(47,111,94,.22), transparent);
  transform: translateX(-100%);
  animation: shimmer 3.8s ease-in-out infinite;
}

.ledger-page {
  width: min(720px, 86vw);
  padding: clamp(2rem, 5vw, 5rem);
  background: linear-gradient(150deg, rgba(43,29,20,.92), rgba(13,11,8,.78));
  position: relative;
}
.drop { float: left; font: 700 8rem/.68 var(--display); color: var(--copper); margin: .2rem .7rem 0 0; }
.divider { height: 1px; margin: 2rem 0; background: linear-gradient(90deg, transparent, var(--copper), var(--parchment), transparent); }
.page-corner { position: absolute; right: 0; top: 0; border-top: 52px solid rgba(241,230,207,.22); border-left: 52px solid transparent; }
.marginalia {
  position: absolute;
  max-width: 10rem;
  padding: .9rem;
  border-top: 1px solid var(--copper);
  color: var(--parchment);
  font: italic 1rem/1.35 var(--annotation);
  cursor: crosshair;
}
.marginalia.left { left: 8vw; top: 38%; }
.marginalia.right { right: 9vw; top: 30%; }
.ruler { position: absolute; bottom: 8rem; width: min(620px, 70vw); height: 1px; background: repeating-linear-gradient(90deg, var(--copper) 0 1px, transparent 1px 18px); opacity: .65; }

.specimen-wall { position: relative; width: min(980px, 90vw); min-height: 72vh; display: grid; place-items: center; }
.ink-blob { position: absolute; border-radius: 50% 45% 60% 40%; filter: blur(.2px); mix-blend-mode: screen; animation: breathe 7s ease-in-out infinite alternate; }
.blob-a { width: 25rem; height: 20rem; left: 0; top: 3rem; background: radial-gradient(circle, rgba(47,111,94,.45), rgba(58,22,34,.2) 58%, transparent); }
.blob-b { width: 20rem; height: 24rem; right: 0; bottom: 0; background: radial-gradient(circle, rgba(181,106,58,.28), rgba(43,29,20,.18) 56%, transparent); animation-delay: -2s; }
.blob-c { width: 17rem; height: 14rem; right: 20%; top: 2rem; background: radial-gradient(circle, rgba(216,199,163,.15), rgba(47,111,94,.18), transparent 62%); animation-delay: -4s; }
.specimen-card { width: min(650px, 86vw); padding: 3rem; background: rgba(13,11,8,.76); z-index: 3; text-align: center; transition: transform .35s ease; }
.seal, .wax-seal { display: inline-grid; place-items: center; border-radius: 50%; background: radial-gradient(circle, var(--copper), #7d3c22); color: var(--bone); font-family: var(--annotation); }
.seal { width: 4rem; height: 4rem; margin-bottom: 1rem; }
.evidence-toggle { margin-top: 1rem; padding: .9rem 1.2rem; border: 1px solid var(--copper); background: transparent; color: var(--bone); font-family: var(--annotation); letter-spacing: .12em; cursor: pointer; }
.evidence-layer { max-height: 0; overflow: hidden; color: var(--verdigris); transition: max-height .6s ease; }
.evidence-layer.open { max-height: 10rem; }
.leaf { position: absolute; width: 9rem; height: 18rem; border-radius: 100% 0 100% 0; border: 1px solid rgba(47,111,94,.6); opacity: .45; }
.leaf::before { content:""; position:absolute; left:50%; top:5%; bottom:5%; width:1px; background: var(--verdigris); }
.leaf-one { left: 7%; bottom: 4%; transform: rotate(-28deg); }
.leaf-two { right: 10%; top: 6%; transform: rotate(36deg); }
.band-one { position: absolute; left: 5%; top: 45%; width: 15rem; height: 2rem; }
.band-two { position: absolute; right: 2%; top: 62%; width: 12rem; height: 1.5rem; }

.observatory-table { width: min(860px, 88vw); padding: clamp(2.2rem, 6vw, 5rem); text-align: center; background: radial-gradient(circle at 50% 0%, rgba(47,111,94,.18), rgba(43,29,20,.9)); transition: transform .35s ease; }
.final-diagram { width: min(520px, 82vw); height: auto; margin-bottom: 2rem; fill: none; stroke: var(--verdigris); stroke-width: 2; stroke-dasharray: 900; stroke-dashoffset: 900; }
.scene-observatory.in-view .final-diagram { animation: draw 3s ease forwards; }
.final-diagram circle { fill: var(--copper); stroke: none; }
.wax-seal { position: absolute; right: 13vw; bottom: 16vh; width: 7rem; height: 7rem; text-align: center; background: radial-gradient(circle, var(--wine), var(--copper)); box-shadow: 0 0 30px rgba(181,106,58,.22); }
.footnote { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%) translateY(1rem); max-width: 32rem; padding: .9rem 1.2rem; background: rgba(13,11,8,.92); border: 1px solid rgba(181,106,58,.55); color: var(--bone); font: italic 1rem/1.4 var(--annotation); opacity: 0; pointer-events: none; transition: opacity .35s ease, transform .35s ease; z-index: 30; }
.footnote.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@keyframes shimmer { 0%, 35% { transform: translateX(-100%); } 70%, 100% { transform: translateX(100%); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes orbit { to { transform: rotate(360deg); } }
@keyframes drift { to { translate: 0 12px; rotate: 2deg; } }
@keyframes breathe { to { transform: scale(1.08) rotate(4deg); border-radius: 42% 58% 45% 55%; } }
@keyframes dust { to { transform: translate3d(calc(var(--x) + 18px), calc(var(--y) - 60px), 0); } }

@media (max-width: 760px) {
  .folio-index { right: .5rem; }
  .scrap, .marginalia, .ruler { display: none; }
  .scene { padding: 5rem 1rem; }
  .title-plate, .specimen-card, .observatory-table, .ledger-page { padding: 2rem 1.25rem; }
}
