:root {
  /* Design typography tokens: Space Grotesk** and IBM Plex Mono** */
  --cave-black: #07060A;
  --wet-moss: #1F3B2D;
  --poison-lichen: #B6FF5C;
  --aurora-green: #35F2A0;
  --witch-violet: #9B5CFF;
  --deep-peacock: #102A44;
  --tarnished-gold: #C89B3C;
  --bone-vellum: #F3E6C8;
  --mushroom-rust: #A14F2B;
  --display: "Unbounded", system-ui, sans-serif;
  --serif: "Fraunces", Georgia, serif;
  --body: "Space Grotesk", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { background: var(--cave-black); color: var(--bone-vellum); scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--body);
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 18%, rgba(155, 92, 255, .18), transparent 30rem),
    radial-gradient(circle at 50% 65%, rgba(31, 59, 45, .72), transparent 36rem),
    linear-gradient(180deg, #07060A 0%, #102A44 46%, #07060A 100%);
}

.cave-grain,
.taxonomy-grid,
.side-vine { position: fixed; inset: 0; pointer-events: none; }

.cave-grain {
  z-index: 4;
  opacity: .2;
  background-image:
    radial-gradient(circle, rgba(243, 230, 200, .18) 0 1px, transparent 1px),
    radial-gradient(circle, rgba(200, 155, 60, .16) 0 1px, transparent 1px);
  background-size: 23px 29px, 37px 41px;
  mix-blend-mode: screen;
}

.taxonomy-grid {
  z-index: 0;
  background-image:
    linear-gradient(rgba(200, 155, 60, .13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(200, 155, 60, .11) 1px, transparent 1px),
    linear-gradient(90deg, transparent calc(50% - 1px), rgba(53, 242, 160, .42) 50%, transparent calc(50% + 1px));
  background-size: 72px 72px, 72px 72px, 100% 100%;
  mask-image: radial-gradient(ellipse at center, black 0 68%, transparent 92%);
}

.taxonomy-grid::before,
.taxonomy-grid::after {
  content: "";
  position: absolute;
  top: 8vh;
  bottom: 8vh;
  width: min(18vw, 230px);
  border: 1px solid rgba(200, 155, 60, .42);
  border-left: 0;
  opacity: .65;
}

.taxonomy-grid::before { left: calc(50% - min(42vw, 520px)); }
.taxonomy-grid::after { right: calc(50% - min(42vw, 520px)); transform: scaleX(-1); }

.side-vine {
  z-index: 1;
  width: 22vw;
  opacity: .5;
  background:
    radial-gradient(ellipse at 15% 20%, rgba(161, 79, 43, .5), transparent 22%),
    radial-gradient(ellipse at 35% 58%, rgba(31, 59, 45, .75), transparent 32%),
    linear-gradient(105deg, transparent 44%, rgba(182, 255, 92, .2) 45%, transparent 47%);
  filter: blur(.2px);
}

.vine-left { right: auto; clip-path: polygon(0 0, 72% 12%, 44% 45%, 88% 67%, 28% 100%, 0 100%); }
.vine-right { left: auto; transform: scaleX(-1); clip-path: polygon(0 0, 72% 12%, 44% 45%, 88% 67%, 28% 100%, 0 100%); }

.archive { position: relative; z-index: 2; }

.chamber {
  min-height: 100vh;
  position: relative;
  display: grid;
  place-items: center;
  padding: 6rem 1.2rem;
  isolation: isolate;
}

.chamber::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 12vh;
  width: min(78vw, 860px);
  height: 76vh;
  transform: translateX(-50%);
  border: 1px solid rgba(200, 155, 60, .25);
  border-radius: 48% 52% 50% 49% / 3% 4% 5% 3%;
  background: radial-gradient(ellipse at center, rgba(7, 6, 10, .14), rgba(7, 6, 10, .62));
  box-shadow: inset 0 0 70px rgba(53, 242, 160, .08), 0 0 80px rgba(155, 92, 255, .07);
  z-index: -1;
}

.coordinates,
.archive-label {
  position: absolute;
  top: 2rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: .74rem;
  letter-spacing: .18em;
  color: rgba(243, 230, 200, .62);
  text-transform: uppercase;
  white-space: nowrap;
}

.altar,
.relic-card,
.constellation {
  position: relative;
  width: min(92vw, 820px);
  min-height: 34rem;
  display: grid;
  place-items: center;
  text-align: center;
}

.aurora-halo {
  position: absolute;
  width: min(78vw, 650px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(135deg, #35F2A0 0%, #102A44 38%, #9B5CFF 70%, #C89B3C 100%);
  filter: blur(24px) saturate(1.25);
  opacity: .45;
  animation: breathe 7s ease-in-out infinite;
  mask-image: radial-gradient(circle, black 0 32%, transparent 63%);
}

.grid-circle {
  position: absolute;
  width: min(82vw, 690px);
  aspect-ratio: 1;
  border: 1px solid rgba(200, 155, 60, .78);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(53, 242, 160, .14), 0 0 45px rgba(200, 155, 60, .12);
}

.ring {
  position: absolute;
  inset: 8%;
  border: 1px dashed rgba(182, 255, 92, .32);
  border-radius: 50%;
  animation: rotateRing 28s linear infinite;
}

.ring-two { inset: 20%; border-color: rgba(155, 92, 255, .38); animation-duration: 37s; animation-direction: reverse; }
.radial { position: absolute; left: 50%; top: -4%; bottom: -4%; width: 1px; background: rgba(200, 155, 60, .35); transform-origin: center; }
.radial-a { transform: rotate(36deg); }
.radial-b { transform: rotate(-48deg); }

.line-creatures,
.relic-svg {
  position: relative;
  z-index: 2;
  fill: none;
  stroke: var(--bone-vellum);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 10px rgba(53, 242, 160, .22));
}

.mushrooms {
  position: absolute;
  width: min(80vw, 560px);
  bottom: 2rem;
  stroke: rgba(243, 230, 200, .58);
  stroke-dasharray: 900;
  stroke-dashoffset: 900;
  animation: drawLine 3.8s ease forwards, crawl 10s ease-in-out infinite alternate;
}

h1 {
  position: relative;
  z-index: 3;
  margin: 0;
  max-width: 11ch;
  font-family: var(--display);
  font-size: clamp(3rem, 10vw, 8.7rem);
  line-height: .86;
  letter-spacing: -.08em;
  text-transform: lowercase;
  color: var(--bone-vellum);
  text-shadow: 0 0 1px #C89B3C, 0 0 34px rgba(155, 92, 255, .42), 0 12px 0 rgba(7, 6, 10, .45);
}

.incantation {
  position: absolute;
  z-index: 3;
  bottom: 6.7rem;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.1rem, 2vw, 1.65rem);
  color: var(--poison-lichen);
}

.marginalia,
.annotation {
  position: absolute;
  top: 50%;
  width: min(19rem, 24vw);
  padding: 1rem;
  border: 1px solid rgba(200, 155, 60, .35);
  background: rgba(7, 6, 10, .42);
  color: rgba(243, 230, 200, .68);
  font-family: var(--mono);
  font-size: .72rem;
  line-height: 1.55;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.left-note { right: calc(50% + min(25vw, 330px)); transform: translateY(-50%) rotate(-1.4deg); }
.right-note { left: calc(50% + min(25vw, 330px)); transform: translateY(-50%) rotate(1.6deg); }

.annotation { opacity: 0; transition: opacity .8s ease, transform .8s ease; }
.annotation b { display: block; color: var(--tarnished-gold); font-family: var(--serif); font-size: 1rem; text-transform: none; letter-spacing: 0; }
.annotation span { display: block; margin-top: .4rem; }

.relic-card {
  width: min(88vw, 520px);
  min-height: 38rem;
  padding: 3rem 2rem;
  border: 1px solid rgba(200, 155, 60, .5);
  background:
    radial-gradient(circle at 50% 34%, rgba(53, 242, 160, .16), transparent 28%),
    linear-gradient(180deg, rgba(16, 42, 68, .44), rgba(7, 6, 10, .82));
  box-shadow: inset 0 0 50px rgba(31, 59, 45, .6), 0 0 80px rgba(7, 6, 10, .8);
  clip-path: polygon(3% 0, 96% 2%, 100% 35%, 97% 100%, 5% 98%, 0 62%);
  opacity: .42;
  transform: translateY(42px) scale(.94) rotate(.7deg);
  transition: opacity .9s ease, transform .9s ease, filter .9s ease;
}

.chamber.is-active .relic-card { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); filter: drop-shadow(0 0 28px rgba(53, 242, 160, .22)); }
.chamber.is-active .annotation { opacity: 1; }
.chamber.is-active .left-note.annotation { transform: translateY(-50%) rotate(-2.4deg); }
.chamber.is-active .right-note.annotation { transform: translateY(-50%) rotate(2.2deg); }

.plaque {
  font-family: var(--mono);
  color: var(--aurora-green);
  letter-spacing: .18em;
  text-transform: uppercase;
  font-size: .72rem;
  border: 1px solid rgba(53, 242, 160, .38);
  padding: .45rem .75rem;
  background: rgba(7, 6, 10, .5);
}

.relic-svg {
  width: min(66vw, 320px);
  stroke: var(--tarnished-gold);
  stroke-dasharray: 1200;
  stroke-dashoffset: 1200;
  transition: stroke-dashoffset 1.8s ease .18s, stroke .8s ease;
}

.chamber.is-active .relic-svg { stroke-dashoffset: 0; stroke: var(--bone-vellum); }

.relic-card h2,
.constellation h2 {
  margin: .4rem 0 0;
  font-family: var(--serif);
  font-size: clamp(3rem, 7vw, 5.8rem);
  line-height: .9;
  color: var(--bone-vellum);
  text-shadow: 0 0 18px rgba(200, 155, 60, .3);
}

.relic-card p,
.constellation p {
  max-width: 33rem;
  margin: 1rem auto 0;
  color: rgba(243, 230, 200, .78);
  font-size: clamp(1rem, 1.8vw, 1.2rem);
  line-height: 1.65;
}

.moth-card { clip-path: polygon(1% 3%, 100% 0, 95% 58%, 100% 100%, 6% 96%, 0 41%); }
.factory-card { clip-path: polygon(5% 1%, 93% 0, 100% 50%, 91% 100%, 1% 96%, 0 34%); }
.adapter-card { clip-path: polygon(0 7%, 96% 0, 100% 94%, 61% 100%, 4% 92%); }

.constellation {
  width: min(92vw, 680px);
  min-height: 42rem;
  border-radius: 50%;
  border: 1px solid rgba(200, 155, 60, .7);
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), rgba(53, 242, 160, .33), transparent calc(50% + 1px)),
    linear-gradient(rgba(200, 155, 60, .14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(200, 155, 60, .14) 1px, transparent 1px),
    rgba(7, 6, 10, .44);
  background-size: 100% 100%, 56px 56px, 56px 56px, 100% 100%;
  box-shadow: inset 0 0 80px rgba(155, 92, 255, .18), 0 0 90px rgba(53, 242, 160, .1);
}

.sigil {
  position: absolute;
  display: grid;
  place-items: center;
  width: 7.8rem;
  height: 7.8rem;
  border-radius: 50%;
  border: 1px solid rgba(200, 155, 60, .78);
  color: var(--poison-lichen);
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: radial-gradient(circle, rgba(31, 59, 45, .95), rgba(7, 6, 10, .82));
  box-shadow: 0 0 26px rgba(53, 242, 160, .22);
  opacity: 0;
  transform: scale(.72);
  transition: opacity .8s ease, transform .8s ease;
}

.chamber.is-active .sigil { opacity: 1; transform: scale(1); }
.s1 { top: 7%; left: 50%; margin-left: -3.9rem; transition-delay: .05s; }
.s2 { top: 28%; right: 5%; transition-delay: .16s; }
.s3 { bottom: 16%; right: 14%; transition-delay: .28s; }
.s4 { bottom: 16%; left: 14%; transition-delay: .4s; }
.s5 { top: 28%; left: 5%; transition-delay: .52s; }
.s6 { bottom: 4%; left: 50%; margin-left: -3.9rem; transition-delay: .64s; }

.constellation h2,
.constellation p { position: relative; z-index: 2; max-width: 24rem; }
.final-halo { width: 36rem; opacity: .32; }
.archive-label { top: auto; bottom: 2rem; color: var(--tarnished-gold); }

@keyframes breathe { 0%, 100% { transform: scale(.9) rotate(0deg); opacity: .35; } 50% { transform: scale(1.06) rotate(8deg); opacity: .58; } }
@keyframes rotateRing { to { transform: rotate(360deg); } }
@keyframes drawLine { to { stroke-dashoffset: 0; } }
@keyframes crawl { from { transform: translateX(-12px); } to { transform: translateX(12px); } }

@media (max-width: 980px) {
  .marginalia,
  .annotation { position: relative; inset: auto; transform: none !important; width: min(88vw, 28rem); margin: 1rem auto 0; }
  .chamber { padding-block: 5rem; }
  .relic-card { min-height: auto; }
  .incantation { bottom: 4rem; }
}

@media (max-width: 620px) {
  .altar { min-height: 32rem; }
  .grid-circle { width: 96vw; }
  .aurora-halo { width: 92vw; }
  .constellation { min-height: 37rem; border-radius: 34%; }
  .sigil { width: 6rem; height: 6rem; font-size: .58rem; }
}
