:root {
  /* DESIGN typography tokens: Space Grotesk* Grotesk** for the main wordmark, Inter* Inter** for body text, IBM Plex Mono* Mono** for coordinates. */
  --palace-black: #050505;
  --lacquer-charcoal: #11100D;
  --archive-gold: #D6A84A;
  --old-parchment: #F2E6C8;
  --oxidized-bronze: #7A5A22;
  --ink-gray: #6C695F;
  --vermilion-seal: #B23A2E;
  --grid-gap: clamp(10px, 1.25vw, 20px);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--palace-black);
  color: var(--old-parchment);
  font-family: "Inter", sans-serif;
  overflow-x: hidden;
}

body.focus-mode .focusable:not(.is-focused) {
  opacity: .23;
  filter: saturate(.35);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(circle at 50% 20%, rgba(214, 168, 74, .07), transparent 36%),
    repeating-linear-gradient(0deg, rgba(242, 230, 200, .025) 0 1px, transparent 1px 12px),
    repeating-linear-gradient(90deg, rgba(214, 168, 74, .018) 0 1px, transparent 1px 16px);
  mix-blend-mode: screen;
}

.top-ruler {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 42px;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 34px 0 82px;
  border-bottom: 1px solid rgba(214, 168, 74, .45);
  background: rgba(5, 5, 5, .78);
  color: var(--archive-gold);
  font: 500 11px/1 "IBM Plex Mono", monospace;
  letter-spacing: .12em;
}

.folio-strip {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 54px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 26px;
  border-right: 1px solid rgba(214, 168, 74, .36);
  background: #050505;
}

.folio-strip a {
  color: var(--ink-gray);
  text-decoration: none;
  font: 500 11px/1 "IBM Plex Mono", monospace;
  writing-mode: vertical-rl;
  margin: 0 auto;
  transition: color .5s ease, transform .5s ease;
}

.folio-strip a.active, .folio-strip a:hover {
  color: var(--archive-gold);
  transform: translateX(2px);
}

.chapter {
  position: relative;
  min-height: 100vh;
  padding: clamp(70px, 8vw, 110px) clamp(24px, 5vw, 72px) clamp(34px, 5vw, 70px) clamp(76px, 8vw, 126px);
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: minmax(72px, auto);
  gap: var(--grid-gap);
  background:
    radial-gradient(circle at 82% 18%, rgba(122, 90, 34, .16), transparent 30%),
    linear-gradient(115deg, rgba(17, 16, 13, .78), #050505 48%);
}

.chapter::after {
  content: "";
  position: absolute;
  inset: 42px 0 0 54px;
  pointer-events: none;
  opacity: .14;
  background-image:
    linear-gradient(rgba(214, 168, 74, .28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(214, 168, 74, .22) 1px, transparent 1px);
  background-size: calc((100vw - 54px) / 12) 72px;
}

.chamber, .reading-panel {
  position: relative;
  z-index: 2;
  background:
    linear-gradient(135deg, rgba(214, 168, 74, .055), transparent 45%),
    var(--lacquer-charcoal);
  border: 1px solid rgba(214, 168, 74, .48);
  box-shadow: inset 0 0 0 1px rgba(5, 5, 5, .75), 0 24px 80px rgba(0, 0, 0, .42);
  padding: clamp(18px, 2vw, 32px);
  overflow: hidden;
  transition: opacity .55s ease, filter .55s ease, transform .65s ease, border-color .55s ease;
}

.chamber::before, .reading-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .12;
  background:
    repeating-linear-gradient(135deg, transparent 0 8px, rgba(214, 168, 74, .22) 8px 9px, transparent 9px 18px),
    radial-gradient(circle at top right, rgba(242, 230, 200, .16), transparent 35%);
  pointer-events: none;
}

.chamber.is-visible { transform: translateY(0); opacity: 1; }
.chapter:not(.active-room) .chamber, .chapter:not(.active-room) .reading-panel { transform: translateY(22px); opacity: .78; }

.coord {
  display: block;
  margin-bottom: 18px;
  color: var(--archive-gold);
  font: 500 11px/1.2 "IBM Plex Mono", monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1, h2, strong {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  text-transform: uppercase;
  letter-spacing: -.045em;
}

p { margin: 0; color: rgba(242, 230, 200, .82); line-height: 1.68; }

.hero-wordmark {
  grid-column: 2 / 12;
  grid-row: 2 / 6;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 47vh;
}

.hero-wordmark h1 {
  color: var(--old-parchment);
  font-size: clamp(58px, 12vw, 190px);
  line-height: .78;
  letter-spacing: -.085em;
}

.hero-wordmark p {
  margin-top: 24px;
  color: var(--archive-gold);
  font: 500 clamp(13px, 1.2vw, 18px)/1 "IBM Plex Mono", monospace;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.hero-note strong { color: var(--archive-gold); font-size: clamp(20px, 2.2vw, 34px); }
.hero-note p { margin-top: 18px; font-size: 14px; }
.note-one { grid-column: 2 / 5; grid-row: 6 / 8; }
.note-two { grid-column: 5 / 9; grid-row: 6 / 8; }
.note-three { grid-column: 9 / 12; grid-row: 6 / 8; }

.seal-mark {
  position: absolute;
  z-index: 3;
  right: 10vw;
  top: 17vh;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: var(--vermilion-seal);
  color: var(--old-parchment);
  font-family: "IBM Plex Mono", monospace;
  transform: rotate(-4deg);
}

.knowledge-map {
  position: absolute;
  z-index: 2;
  inset: 72px 5vw auto auto;
  width: min(54vw, 900px);
  height: auto;
  pointer-events: none;
}

.observatory-map { position: relative; inset: auto; width: 100%; pointer-events: auto; }
.trace { fill: none; stroke: var(--archive-gold); stroke-width: 1.4; stroke-linecap: square; opacity: .76; stroke-dasharray: 1; stroke-dashoffset: 1; }
.trace.slow { stroke: var(--oxidized-bronze); stroke-width: 1; }
.trace.drawn { animation: drawTrace 4.8s ease forwards; }
@keyframes drawTrace { to { stroke-dashoffset: 0; } }
.node { fill: var(--palace-black); stroke: var(--archive-gold); stroke-width: 2; cursor: crosshair; pointer-events: auto; transform-origin: center; }
.node.breathe { animation: nodeBreath 3.8s ease-in-out infinite; }
@keyframes nodeBreath { 50% { filter: drop-shadow(0 0 12px rgba(214, 168, 74, .7)); } }

.chapter-title { grid-column: 2 / 6; grid-row: 2 / 4; }
.chapter-title h2 { color: var(--old-parchment); font-size: clamp(42px, 7vw, 118px); line-height: .88; }
.wide-text { grid-column: 6 / 12; grid-row: 2 / 5; display: flex; flex-direction: column; justify-content: flex-end; }
.wide-text p { font-size: clamp(25px, 3.2vw, 52px); line-height: 1.12; font-family: "Space Grotesk", sans-serif; color: var(--old-parchment); }
.corridor { grid-column: 2 / 9; grid-row: 5 / 7; }
.corridor-line { height: 1px; margin: 30px 0; background: linear-gradient(90deg, var(--archive-gold), var(--oxidized-bronze), transparent); transform-origin: left; animation: openLine 7s ease-in-out infinite; }
@keyframes openLine { 0%, 100% { transform: scaleX(.18); } 45%, 70% { transform: scaleX(1); } }
.small-cell { grid-column: 9 / 12; grid-row: 5 / 7; }
.red-seal { width: 64px; height: 64px; margin: 18px 0; background: var(--vermilion-seal); clip-path: polygon(0 0, 92% 4%, 100% 88%, 12% 100%); }

.index-well { grid-column: 2 / 4; grid-row: 4 / 9; }
.index-well ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 18px; font: 500 12px/1 "IBM Plex Mono", monospace; color: var(--ink-gray); text-transform: uppercase; letter-spacing: .14em; }
.floor-plan { grid-column: 4 / 12; grid-row: 2 / 8; }
.plan-cells { height: 100%; min-height: 390px; display: grid; grid-template-columns: 1.4fr .8fr 1fr; grid-template-rows: .8fr 1.2fr .9fr; gap: 14px; }
.plan-cells i { border: 1px solid rgba(214, 168, 74, .56); background: rgba(5, 5, 5, .4); transform: scale(.86); opacity: .48; transition: transform 1.5s ease, opacity 1.5s ease, background 1.5s ease; }
.plan-cells i.open { transform: scale(1); opacity: 1; background: rgba(214, 168, 74, .09); }
.scroll-room { grid-column: 4 / 12; grid-row: 8 / 10; }
.scroll-room p { font: 600 clamp(26px, 4vw, 70px)/1 "Space Grotesk", sans-serif; letter-spacing: -.05em; color: var(--archive-gold); }

.graph-chamber { grid-column: 2 / 11; grid-row: 4 / 10; min-height: 540px; }
.citation-thread { grid-column: 11 / 13; grid-row: 4 / 10; writing-mode: vertical-rl; }
.citation-thread p { max-height: 420px; }
.ticks line { stroke: rgba(122, 90, 34, .55); stroke-width: 1; }
.node-label { position: absolute; right: 28px; bottom: 24px; padding: 12px 14px; border: 1px solid rgba(214, 168, 74, .5); background: var(--old-parchment); color: var(--palace-black); font: 500 11px/1 "IBM Plex Mono", monospace; text-transform: uppercase; letter-spacing: .12em; }

.rings-panel { grid-column: 2 / 7; grid-row: 4 / 10; display: grid; place-items: center; }
.revision-rings { width: min(88%, 520px); }
.ring { fill: none; stroke: var(--archive-gold); stroke-width: 1; opacity: .65; stroke-dasharray: 1280; stroke-dashoffset: 1280; }
.ring.drawn { animation: ringDraw 5.2s ease forwards; }
@keyframes ringDraw { to { stroke-dashoffset: 0; } }
.revision-text { grid-column: 7 / 12; grid-row: 5 / 8; }
.revision-text p { font-size: clamp(22px, 2.8vw, 44px); line-height: 1.18; font-family: "Space Grotesk", sans-serif; color: var(--old-parchment); }

.alcove-chapter { place-items: center; }
.reading-panel { grid-column: 3 / 11; max-width: 980px; min-height: 58vh; display: flex; flex-direction: column; justify-content: center; background: var(--old-parchment); color: var(--palace-black); border-color: var(--archive-gold); }
.reading-panel .coord { color: var(--oxidized-bronze); }
.reading-panel h2 { color: var(--palace-black); font-size: clamp(38px, 6.5vw, 104px); line-height: .9; }
.reading-panel p { margin-top: 28px; color: #11100D; font-size: clamp(19px, 2vw, 28px); max-width: 760px; }
.reading-panel small { margin-top: 46px; color: var(--vermilion-seal); font: 500 12px/1 "IBM Plex Mono", monospace; letter-spacing: .14em; text-transform: uppercase; }

.focus-caption {
  position: fixed;
  right: 28px;
  bottom: 24px;
  z-index: 8;
  color: var(--archive-gold);
  font: 500 10px/1 "IBM Plex Mono", monospace;
  letter-spacing: .16em;
  text-transform: uppercase;
  opacity: .72;
}

@media (max-width: 820px) {
  .top-ruler span:nth-child(2) { display: none; }
  .chapter { padding-left: 70px; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .hero-wordmark, .note-one, .note-two, .note-three, .chapter-title, .wide-text, .corridor, .small-cell, .index-well, .floor-plan, .scroll-room, .graph-chamber, .citation-thread, .rings-panel, .revision-text, .reading-panel { grid-column: 1 / -1; grid-row: auto; }
  .knowledge-map { width: 86vw; opacity: .38; }
  .citation-thread { writing-mode: horizontal-tb; }
}
