:root {
  --parchment: #F6EEDC;
  --teal: #2F8C8A;
  --ink: #17313A;
  --leather: #7A4A2A;
  --glass: #9CCFD1;
  --coral: #FF6B5F;
  --cream: #FFF9EA;
  --mono: "IBM Plex Mono", "Courier New", monospace;
  --space: "Space Mono", "Courier New", monospace;
  --serif: "Cormorant Garamond", Georgia, serif;
  --typography-audit: "IBM Plex Mono** Space Mono**";
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--mono);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(156, 207, 209, .55), transparent 24rem),
    linear-gradient(115deg, var(--cream), var(--parchment) 42%, #eadabd);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .24;
  background-image:
    linear-gradient(90deg, rgba(23,49,58,.05) 1px, transparent 1px),
    linear-gradient(rgba(122,74,42,.04) 1px, transparent 1px);
  background-size: 38px 38px, 22px 22px;
  mix-blend-mode: multiply;
  z-index: 3;
}

.archive-tabs {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.archive-tab {
  width: 7.5rem;
  padding: .85rem .7rem .85rem 1rem;
  color: var(--cream);
  background:
    linear-gradient(90deg, rgba(255,249,234,.16), transparent),
    repeating-linear-gradient(0deg, rgba(255,255,255,.05), rgba(255,255,255,.05) 2px, transparent 2px, transparent 7px),
    var(--leather);
  text-decoration: none;
  font-family: var(--space);
  font-size: .72rem;
  letter-spacing: .18em;
  border: 1px solid rgba(255,249,234,.38);
  border-right: 0;
  border-radius: 16px 0 0 16px;
  box-shadow: inset 0 0 0 1px rgba(23,49,58,.22), -7px 8px 18px rgba(23,49,58,.14);
  transition: transform .35s ease, background-color .35s ease;
}

.archive-tab:hover, .archive-tab.is-active {
  transform: translateX(-1.15rem);
  background-color: var(--teal);
  color: var(--cream);
}

.scene {
  position: relative;
  min-height: 100vh;
  padding: clamp(4rem, 8vw, 8rem) clamp(2rem, 7vw, 7rem);
  isolation: isolate;
}

.scene::after {
  content: "";
  position: absolute;
  left: -8vw;
  right: -8vw;
  bottom: -4rem;
  height: 9rem;
  background: var(--parchment);
  clip-path: ellipse(54% 36% at 45% 45%);
  z-index: -1;
}

.scene-hero {
  display: grid;
  align-items: center;
  grid-template-columns: minmax(18rem, .8fr) minmax(20rem, 1.1fr);
  overflow: hidden;
  background: linear-gradient(128deg, rgba(255,249,234,.8), rgba(246,238,220,.94));
}

.tide-curve {
  position: absolute;
  width: 115vw;
  height: 32vh;
  left: -15vw;
  top: 37%;
  transform: rotate(-7deg);
  background: linear-gradient(90deg, transparent, rgba(47,140,138,.88), rgba(156,207,209,.55), transparent);
  clip-path: polygon(0 43%, 12% 32%, 25% 48%, 38% 28%, 55% 42%, 71% 22%, 88% 45%, 100% 31%, 100% 76%, 0 82%);
  animation: tideSlide 8s ease-in-out infinite alternate;
  z-index: -1;
}

.folio-stage { perspective: 1200px; min-height: 28rem; display: grid; place-items: center; }

.folio-book {
  position: relative;
  width: min(34vw, 28rem);
  min-width: 18rem;
  height: 24rem;
  transform-style: preserve-3d;
}

.folio-cover, .folio-page {
  position: absolute;
  inset: 0;
  border-radius: 18px 26px 26px 18px;
  box-shadow: 0 34px 70px rgba(23,49,58,.22);
}

.folio-cover {
  width: 51%;
  background:
    radial-gradient(circle at 28% 18%, rgba(255,249,234,.14), transparent 7rem),
    repeating-linear-gradient(82deg, rgba(255,255,255,.05), rgba(255,255,255,.05) 1px, transparent 1px, transparent 8px),
    linear-gradient(135deg, #915d38, var(--leather) 58%, #583018);
  border: 2px solid rgba(23,49,58,.25);
  transform-origin: right center;
  transition: transform 1.6s cubic-bezier(.2,.8,.12,1);
  z-index: 2;
}

.cover-right { left: 49%; transform-origin: left center; border-radius: 26px 18px 18px 26px; }
.folio-book.is-open .cover-left { transform: rotateY(-72deg); }
.folio-book.is-open .cover-right { transform: rotateY(72deg); }

.folio-page {
  inset: 1.35rem 2.2rem;
  background: linear-gradient(145deg, var(--cream), #e6d4b6);
  border: 1px solid rgba(122,74,42,.28);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 2rem;
  font-family: var(--space);
  color: var(--teal);
}

.folio-page strong { display: block; margin-top: .6rem; color: var(--ink); }
.stitched-edge { position: absolute; top: .8rem; bottom: .8rem; width: 10px; border-left: 2px dashed rgba(255,249,234,.45); }
.cover-left .stitched-edge { right: .65rem; }
.cover-right .stitched-edge { left: .65rem; }
.embossed-mark, .seal-mark { position: absolute; inset: 38% 10%; color: rgba(255,249,234,.58); letter-spacing: .18em; text-align: center; }
.seal-mark { font-size: 4rem; font-family: var(--serif); }

.hero-copy { position: relative; z-index: 2; }
.case-label, .folio-number, .scene-heading p {
  font-family: var(--space);
  color: var(--teal);
  letter-spacing: .22em;
  font-size: .78rem;
  text-transform: uppercase;
}

.glitch-title {
  position: relative;
  margin: .2rem 0 1.2rem;
  font-family: var(--mono);
  font-weight: 600;
  font-size: clamp(4.3rem, 12vw, 11.5rem);
  letter-spacing: -.08em;
  line-height: .82;
}

.glitch-title::before, .glitch-title::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}
.glitch-title::before { color: var(--coral); transform: translate(5px, 2px); }
.glitch-title::after { color: var(--glass); transform: translate(-4px, -2px); }
.glitch-title.is-glitching::before, .glitch-title.is-glitching::after { opacity: .68; clip-path: inset(18% 0 54% 0); }

.hero-deck { max-width: 40rem; font-size: clamp(1.05rem, 2vw, 1.45rem); line-height: 1.65; }
.margin-code { position: absolute; font-family: var(--space); color: rgba(23,49,58,.48); font-size: .75rem; letter-spacing: .16em; }
.code-one { left: 7vw; bottom: 11vh; transform: rotate(-8deg); }
.code-two { right: 13vw; top: 18vh; transform: rotate(7deg); }
.code-three { left: 30vw; top: 7vh; transform: rotate(-2deg); color: rgba(255,107,95,.55); }

.scene-manuscript { min-height: 110vh; }
.shore-band { position: absolute; inset: 18% -10vw auto -10vw; height: 18rem; background: rgba(156,207,209,.62); transform: rotate(-10deg); clip-path: polygon(0 30%, 14% 18%, 27% 40%, 43% 20%, 61% 38%, 76% 16%, 100% 31%, 100% 72%, 0 84%); z-index: -1; }

.leather-panel {
  background:
    radial-gradient(circle at 20% 10%, rgba(255,249,234,.2), transparent 8rem),
    repeating-linear-gradient(98deg, rgba(255,255,255,.055), rgba(255,255,255,.055) 1px, transparent 1px, transparent 6px),
    linear-gradient(135deg, #8f5c37, var(--leather));
  color: var(--cream);
  border: 2px solid rgba(23,49,58,.2);
  box-shadow: inset 0 0 0 8px rgba(255,249,234,.08), 0 35px 80px rgba(23,49,58,.22);
}

.sloped-table {
  position: relative;
  width: min(60rem, 70vw);
  padding: clamp(2rem, 5vw, 5rem);
  border-radius: 38px 18px 46px 22px;
  transform: rotate(-4deg);
}
.sloped-table h2, .scene-heading h2, .map-chamber h2, .terrace-copy h2 { font-family: var(--serif); font-size: clamp(2.6rem, 6vw, 5.8rem); line-height: .95; margin: .5rem 0 1rem; font-weight: 600; }
.sloped-table p { max-width: 36rem; line-height: 1.7; }
.manuscript-lines i { display: block; height: 10px; margin: 1.1rem 0; background: rgba(255,249,234,.22); border-radius: 999px; }
.manuscript-lines i:nth-child(2n) { width: 74%; }

.lens {
  position: absolute;
  width: 9rem;
  height: 9rem;
  right: 11%;
  top: 12%;
  border-radius: 50%;
  border: 2px solid var(--glass);
  background: radial-gradient(circle, rgba(255,249,234,.34), rgba(156,207,209,.32));
  display: grid;
  place-items: center;
  font-family: var(--space);
  color: var(--ink);
  box-shadow: 0 0 0 10px rgba(156,207,209,.16);
  transition: transform .25s ease;
}

.note-card {
  position: absolute;
  width: 15rem;
  padding: 1.1rem;
  background: var(--cream);
  border: 1px solid rgba(122,74,42,.28);
  box-shadow: 0 18px 45px rgba(23,49,58,.16);
  font-family: var(--space);
  clip-path: polygon(0 7%, 92% 0, 100% 88%, 8% 100%);
  offset-rotate: 0deg;
}
.note-card b { display: block; color: var(--coral); margin-bottom: .4rem; }
.card-a { left: 58vw; top: 34vh; offset-path: path("M0,0 C40,-45 110,55 180,-15"); animation: cardDrift 7s ease-in-out infinite alternate; }
.card-b { left: 15vw; top: 66vh; offset-path: path("M0,0 C-30,60 80,85 145,12"); animation: cardDrift 8.5s ease-in-out infinite alternate-reverse; }
.ceramic-shard { position: absolute; right: 18vw; bottom: 10vh; font-family: var(--serif); font-size: 9rem; color: rgba(47,140,138,.34); transform: rotate(23deg); }

.scene-evidence { background: linear-gradient(180deg, transparent, rgba(255,249,234,.58)); }
.scene-heading { max-width: 48rem; margin-left: 6vw; }
.evidence-wall { position: relative; min-height: 56vh; margin-top: 3rem; }
.evidence-item {
  position: absolute;
  width: clamp(16rem, 24vw, 24rem);
  padding: 1.45rem;
  background: var(--cream);
  border: 1px solid rgba(23,49,58,.14);
  border-left: 12px solid var(--leather);
  box-shadow: 0 24px 60px rgba(23,49,58,.13);
  transition: transform .35s ease, box-shadow .35s ease;
}
.evidence-item::after { content: attr(data-clue); position: absolute; right: .8rem; bottom: .5rem; color: rgba(255,107,95,.28); font-family: var(--space); letter-spacing: .2em; }
.evidence-item:hover { transform: translate(-3px, -7px) rotate(0deg) !important; box-shadow: 8px 28px 70px rgba(23,49,58,.18); }
.evidence-item:hover h3 { text-shadow: 2px 0 var(--coral), -2px 0 var(--glass); }
.stamp { color: var(--teal); font-family: var(--space); letter-spacing: .2em; font-size: .75rem; }
.evidence-item h3 { margin: .7rem 0; font-size: 1.35rem; transition: text-shadow .18s steps(2); }
.evidence-item p { line-height: 1.55; }
.item-one { left: 10vw; top: 4vh; transform: rotate(-5deg); }
.item-two { left: 42vw; top: 0; transform: rotate(7deg); }
.item-three { left: 24vw; top: 32vh; transform: rotate(4deg); }
.item-four { right: 8vw; top: 24vh; transform: rotate(-8deg); }

.scene-map { display: grid; place-items: center; background: radial-gradient(circle at 80% 20%, rgba(156,207,209,.54), transparent 25rem); }
.map-chamber { width: min(72rem, 86vw); padding: clamp(2rem, 5vw, 4rem); border-radius: 28px; background: rgba(255,249,234,.62); border: 1px solid rgba(47,140,138,.24); box-shadow: inset 0 0 80px rgba(156,207,209,.2); }
.coast-map { width: 100%; height: auto; margin-top: 1rem; overflow: visible; }
.map-line { fill: none; stroke-width: 5; stroke-linecap: round; stroke-dasharray: 1200; stroke-dashoffset: 1200; transition: stroke-dashoffset 2.2s cubic-bezier(.2,.7,.1,1); }
.map-line.primary { stroke: var(--teal); }
.map-line.secondary { stroke: var(--glass); stroke-width: 4; }
.map-line.coral { stroke: var(--coral); stroke-width: 3; }
.scene-map.is-visible .map-line { stroke-dashoffset: 0; }
.map-points circle { fill: var(--cream); stroke: var(--leather); stroke-width: 4; }
.coordinate-strip { margin-top: 1rem; padding: 1rem; border: 1px dashed var(--teal); color: var(--leather); font-family: var(--space); letter-spacing: .15em; }

.scene-terrace { display: grid; grid-template-columns: 1fr 1fr; align-items: center; overflow: hidden; background: linear-gradient(160deg, rgba(156,207,209,.38), var(--cream)); }
.terrace-light { position: absolute; inset: -25% -10% auto auto; width: 55vw; height: 55vw; border-radius: 50%; background: radial-gradient(circle, rgba(255,249,234,.9), rgba(255,249,234,0) 65%); }
.sigil { position: relative; width: min(36rem, 76vw); aspect-ratio: 1; margin-left: 3vw; border-radius: 50%; background: radial-gradient(circle, rgba(47,140,138,.16), transparent 57%); animation: sigilTurn 24s linear infinite; }
.sigil span { position: absolute; left: 50%; top: 50%; width: 46%; height: 2px; background: var(--ink); transform-origin: left center; }
.sigil span:nth-child(1) { transform: rotate(0deg); background: var(--teal); }
.sigil span:nth-child(2) { transform: rotate(72deg); background: var(--leather); }
.sigil span:nth-child(3) { transform: rotate(144deg); background: var(--coral); }
.sigil span:nth-child(4) { transform: rotate(216deg); background: var(--glass); }
.sigil span:nth-child(5) { transform: rotate(288deg); background: var(--ink); }
.sigil::before, .sigil::after { content: ""; position: absolute; inset: 18%; border: 2px dashed var(--teal); border-radius: 42% 58% 48% 52%; }
.sigil::after { inset: 32%; border-color: var(--coral); transform: rotate(28deg); }
.terrace-copy { max-width: 41rem; position: relative; z-index: 2; }
.terrace-copy p:last-child { font-size: 1.12rem; line-height: 1.7; }
.final-annotations { position: absolute; right: 8vw; bottom: 8vh; display: flex; gap: .7rem; flex-wrap: wrap; max-width: 34rem; }
.final-annotations span { padding: .55rem .75rem; background: rgba(255,249,234,.74); border: 1px solid rgba(122,74,42,.24); font-family: var(--space); color: var(--leather); font-size: .8rem; }

@keyframes tideSlide { from { transform: translateX(-4vw) rotate(-7deg); } to { transform: translateX(6vw) rotate(-5deg); } }
@keyframes cardDrift { from { offset-distance: 0%; } to { offset-distance: 100%; } }
@keyframes sigilTurn { to { transform: rotate(360deg); } }

@media (max-width: 850px) {
  .archive-tabs { top: auto; bottom: 0; left: 0; right: 0; transform: none; flex-direction: row; overflow-x: auto; background: rgba(246,238,220,.85); }
  .archive-tab { min-width: 6rem; border-radius: 14px 14px 0 0; border-right: 1px solid rgba(255,249,234,.38); }
  .archive-tab:hover, .archive-tab.is-active { transform: translateY(-.5rem); }
  .scene-hero, .scene-terrace { grid-template-columns: 1fr; }
  .folio-stage { order: 2; }
  .sloped-table { width: 88vw; transform: rotate(-2deg); }
  .note-card, .evidence-item { position: relative; left: auto !important; right: auto !important; top: auto !important; margin: 1rem 0; transform: none !important; }
  .evidence-wall { min-height: auto; }
  .final-annotations { position: relative; right: auto; bottom: auto; margin-top: 2rem; }
}
