:root {
  color-scheme: dark;
  --black: #020506;
  --panel: rgba(3, 8, 9, 0.9);
  --ink: #d6d7d5;
  --muted: #a5aaa8;
  --gold: #c89432;
  --gold-bright: #e0ae4d;
  --gold-dim: rgba(200, 148, 50, 0.35);
  --cyan: #00c9d2;
  --cyan-dim: rgba(0, 201, 210, 0.28);
  --violet: #7134a1;
  font-family: "Avenir Next", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 35%, rgba(61, 21, 92, 0.22), transparent 32rem),
    #010303;
}

button,
a {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

.codex {
  position: relative;
  width: min(100%, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 10px;
  overflow: hidden;
  background:
    radial-gradient(circle at 48% 38%, rgba(73, 31, 111, 0.25), transparent 17rem),
    radial-gradient(circle at 16% 77%, rgba(0, 201, 210, 0.08), transparent 22rem),
    linear-gradient(rgba(200, 148, 50, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 201, 210, 0.018) 1px, transparent 1px),
    #020505;
  background-size: auto, auto, 28px 28px, 28px 28px, auto;
  box-shadow: 0 0 80px #000;
}

.codex::before,
.codex::after {
  content: "";
  position: absolute;
  z-index: 8;
  pointer-events: none;
  inset: 7px;
  border: 1px solid rgba(200, 148, 50, 0.42);
  clip-path: polygon(0 0, 18% 0, 20% 7px, 80% 7px, 82% 0, 100% 0, 100% 100%, 0 100%);
}

.codex::after {
  inset: 15px;
  border-color: rgba(0, 201, 210, 0.22);
  clip-path: polygon(0 0, 14% 0, 17% 9px, 83% 9px, 86% 0, 100% 0, 100% 100%, 0 100%);
}

.frame,
.panel,
.seal-stage {
  position: relative;
  border: 1px solid rgba(200, 148, 50, 0.62);
  background:
    linear-gradient(135deg, rgba(0, 201, 210, 0.04), transparent 20%, transparent 80%, rgba(200, 148, 50, 0.055)),
    rgba(2, 6, 7, 0.88);
  box-shadow:
    inset 0 0 0 4px #020506,
    inset 0 0 0 5px rgba(200, 148, 50, 0.2),
    0 0 20px rgba(0, 0, 0, 0.72);
}

.frame::before,
.panel::before,
.seal-stage::before {
  content: "";
  position: absolute;
  inset: 7px;
  pointer-events: none;
  border: 1px solid rgba(0, 201, 210, 0.18);
  clip-path: polygon(0 0, 22px 0, 32px 10px, calc(100% - 32px) 10px, calc(100% - 22px) 0, 100% 0, 100% 100%, 0 100%);
}

.hero {
  min-height: 240px;
  display: grid;
  grid-template-columns: 205px minmax(0, 1fr) 205px;
  align-items: center;
  gap: 14px;
  padding: 18px 24px;
  clip-path: polygon(0 0, 18% 0, 20% 11px, 80% 11px, 82% 0, 100% 0, 100% 100%, 0 100%);
}

.hero-copy {
  min-width: 0;
}

.hero-copy .micro {
  display: none;
}

.hero h1,
.final-seal h2 {
  margin: 0;
  color: var(--gold-bright);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-shadow: 0 0 18px rgba(200, 148, 50, 0.25);
}

.hero h1 {
  font-size: clamp(4rem, 9.5vw, 8rem);
  line-height: 0.82;
  text-align: center;
}

.hero-copy .rule {
  width: 100%;
  height: 1px;
  margin: 18px 0 12px;
  background: linear-gradient(90deg, var(--gold-bright), var(--gold-dim) 70%, transparent);
}

.hero-copy p,
.hero-copy strong {
  display: block;
  margin: 5px 0;
  font-size: clamp(0.74rem, 1.35vw, 1rem);
  letter-spacing: 0.075em;
  white-space: nowrap;
}

.hero-copy i,
.final-copy i {
  color: var(--cyan);
  font-family: Georgia, serif;
  font-style: normal;
}

.hero-copy strong {
  color: var(--gold);
  font-weight: 500;
}

.hero-seal {
  position: relative;
  display: grid;
  place-items: center;
  width: 164px;
  aspect-ratio: 1;
  margin: auto;
  border: 1px solid rgba(200, 148, 50, 0.72);
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle, transparent 0 19%, rgba(200, 148, 50, 0.32) 19.5% 20%),
    conic-gradient(from 45deg, transparent 0 8%, rgba(200, 148, 50, 0.35) 8.5%, transparent 9% 24%);
  box-shadow:
    inset 0 0 28px rgba(200, 148, 50, 0.08),
    0 0 22px rgba(0, 0, 0, 0.8);
}

.hero-seal::before,
.hero-seal::after {
  content: "";
  position: absolute;
  inset: 22%;
  border: 1px solid rgba(200, 148, 50, 0.6);
  transform: rotate(45deg);
}

.hero-seal::after {
  inset: 32%;
  border-radius: 50%;
  transform: none;
}

.hero-seal b {
  position: absolute;
  bottom: 12px;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.2em;
}

.seal-glyph {
  z-index: 1;
  color: var(--gold-bright);
  font-family: Georgia, serif;
  font-size: 3rem;
  line-height: 1;
}

.seal-glyph small {
  color: var(--cyan);
  font-size: 0.38em;
}

.orbit-copy {
  position: absolute;
  top: 10px;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 0.52rem;
  letter-spacing: 0.13em;
}

.side-switch {
  position: absolute;
  z-index: 12;
  top: 155px;
  display: grid;
  gap: 4px;
}

.side-switch-left {
  left: 5px;
}

.side-switch-right {
  right: 5px;
}

.side-switch button,
.side-switch a {
  display: grid;
  place-items: center;
  width: 30px;
  height: 34px;
  border: 1px solid rgba(0, 201, 210, 0.48);
  background: rgba(0, 10, 11, 0.9);
  color: var(--cyan);
  text-decoration: none;
}

.plate-grid {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.plate-grid-top {
  grid-template-columns: 1.08fr 0.84fr 1.28fr;
}

.plate-grid-middle {
  grid-template-columns: 1fr 0.84fr 1.18fr;
}

.plate-grid-bottom {
  grid-template-columns: 1.02fr 0.94fr 1.14fr;
}

.panel {
  min-width: 0;
  padding: 13px 15px 15px;
  overflow: hidden;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.panel:hover,
.panel:focus-visible,
.panel.is-active {
  border-color: var(--cyan);
  outline: none;
  box-shadow:
    inset 0 0 0 4px #020506,
    inset 0 0 0 5px rgba(0, 201, 210, 0.24),
    0 0 22px rgba(0, 201, 210, 0.1);
}

.panel h2 {
  position: relative;
  z-index: 1;
  margin: 0 0 13px;
  color: var(--gold-bright);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(0.86rem, 1.75vw, 1.2rem);
  font-weight: 500;
  letter-spacing: 0.035em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

.panel h2 span {
  color: var(--gold);
}

.panel p {
  margin: 5px 0;
  color: var(--ink);
  font-size: clamp(0.59rem, 1.13vw, 0.79rem);
  line-height: 1.34;
  letter-spacing: 0.015em;
}

.panel hr {
  height: 1px;
  margin: 11px 0;
  border: 0;
  background: linear-gradient(90deg, transparent, rgba(200, 148, 50, 0.75), transparent);
}

.panel-body {
  position: relative;
  z-index: 1;
}

.centered-list {
  text-align: center;
}

.cyan-line {
  color: var(--cyan) !important;
  font-weight: 500;
}

.master-panel,
.tongue-panel,
.docusite-panel {
  min-height: 318px;
}

.framework-panel,
.image-panel,
.seal-stage {
  min-height: 355px;
}

.equation-panel,
.law-panel,
.declaration-panel {
  min-height: 330px;
}

.process {
  display: grid;
  gap: 2px;
  margin: 7px 0 11px;
}

.process-line {
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 8px;
  font-size: clamp(0.6rem, 1.12vw, 0.78rem);
  line-height: 1.25;
}

.process-line i {
  position: relative;
  color: var(--cyan);
  font-family: Georgia, serif;
  font-size: 1.15rem;
  font-style: normal;
  text-align: center;
}

.process-line i::after {
  content: "";
  position: absolute;
  top: 18px;
  left: 50%;
  width: 1px;
  height: 13px;
  background: rgba(0, 201, 210, 0.42);
}

.process-line:last-child i::after {
  display: none;
}

.tongue-panel .cyan-line {
  padding-left: 47px;
}

.docusite-panel {
  padding-left: 68px;
}

.icon-column,
.image-icons {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  color: var(--cyan);
  font-family: Georgia, serif;
  line-height: 2.1;
  text-align: center;
}

.icon-column {
  top: 50px;
  bottom: 13px;
  left: 15px;
  width: 34px;
  border-right: 1px solid rgba(0, 201, 210, 0.3);
}

.rail-glyphs {
  position: absolute;
  z-index: 1;
  top: 47px;
  bottom: 15px;
  left: 15px;
  width: 35px;
  border-right: 1px solid rgba(0, 201, 210, 0.2);
  color: var(--cyan);
  font-family: Georgia, serif;
  line-height: 2.23;
  text-align: center;
}

.framework-panel {
  padding-left: 66px;
}

.framework-panel .cyan-line,
.image-panel .cyan-line {
  display: block;
  margin-top: 14px;
}

.seal-stage {
  position: relative;
  min-width: 0;
  aspect-ratio: 0.86;
  overflow: hidden;
  background:
    radial-gradient(circle, rgba(81, 32, 122, 0.32), transparent 45%),
    #020506;
}

.seal-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.seal-trigger {
  position: absolute;
  z-index: 4;
  inset: 50% auto auto 50%;
  display: grid;
  place-items: center;
  width: 27%;
  aspect-ratio: 1;
  border: 1px solid rgba(200, 148, 50, 0.78);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200, 148, 50, 0.16), rgba(1, 4, 5, 0.96) 68%);
  color: var(--gold-bright);
  transform: translate(-50%, -50%);
  box-shadow:
    0 0 18px rgba(200, 148, 50, 0.2),
    inset 0 0 18px rgba(200, 148, 50, 0.12);
}

.seal-trigger span {
  font-family: Georgia, serif;
  font-size: clamp(2rem, 5vw, 4rem);
}

.seal-trigger:hover,
.seal-trigger:focus-visible {
  border-color: var(--cyan);
  outline: none;
}

.axis {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0.66;
}

.axis-x {
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
}

.axis-y {
  top: 0;
  left: 50%;
  width: 1px;
  height: 100%;
  background: linear-gradient(transparent, var(--cyan), transparent);
}

.image-panel {
  padding-right: 61px;
}

.image-icons {
  top: 47px;
  right: 15px;
  bottom: 15px;
  width: 32px;
  border-left: 1px solid rgba(0, 201, 210, 0.2);
}

.formula {
  color: var(--cyan) !important;
  font-family: Georgia, serif;
  font-size: clamp(0.8rem, 1.55vw, 1.1rem) !important;
  text-align: center;
}

.equation-body {
  display: grid;
  grid-template-columns: 43% 1fr;
  gap: 12px;
  align-items: center;
}

.nested-glyph {
  position: relative;
  height: 205px;
  border: 1px solid rgba(0, 201, 210, 0.5);
}

.nested-glyph span {
  position: absolute;
  border-top: 1px solid rgba(0, 201, 210, 0.72);
  border-left: 1px solid rgba(0, 201, 210, 0.72);
  color: var(--cyan);
  font-family: Georgia, serif;
  font-size: 0.68rem;
}

.nested-glyph span:nth-child(1) { inset: 14px; }
.nested-glyph span:nth-child(2) { inset: 37px 24px 24px; }
.nested-glyph span:nth-child(3) { inset: 61px 34px 34px; }
.nested-glyph span:nth-child(4) { inset: 86px 44px 44px; }
.nested-glyph span:nth-child(5) { inset: 111px 54px 54px; }

.nested-glyph b {
  position: absolute;
  right: 8px;
  bottom: 7px;
  color: var(--gold);
  font-family: Georgia, serif;
}

.law-body {
  position: relative;
  display: grid;
  grid-template-columns: 52px 1fr;
}

.law-body .rail-glyphs {
  position: relative;
  inset: auto;
  line-height: 2.15;
}

.route-line {
  border-top: 1px solid rgba(200, 148, 50, 0.42);
  border-bottom: 1px solid rgba(200, 148, 50, 0.42);
  padding: 8px 0;
}

.law-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.law-foot p:first-child {
  border-right: 1px solid rgba(200, 148, 50, 0.36);
}

.law-foot p:last-child {
  padding-left: 12px;
}

.declaration-body {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 10px;
}

.declaration-sigil {
  display: grid;
  place-items: center;
  align-self: stretch;
  border-right: 1px solid rgba(200, 148, 50, 0.36);
  color: var(--gold-bright);
  font-family: Georgia, serif;
  font-size: 2rem;
}

.declaration-body p {
  margin: 3px 0;
  font-family: Georgia, serif;
  font-size: clamp(0.59rem, 1.05vw, 0.76rem);
}

.declaration-body p:last-child {
  margin-top: 8px;
}

.final-seal {
  min-height: 292px;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 220px;
  gap: 14px;
  align-items: center;
  margin-top: 8px;
  padding: 15px 20px;
}

.final-copy {
  text-align: center;
}

.final-seal h2 {
  font-size: clamp(1.8rem, 4vw, 3.1rem);
}

.final-lines {
  display: inline-block;
  margin-top: 8px;
  text-align: left;
}

.final-lines p {
  margin: 3px 0;
  font-size: clamp(0.68rem, 1.25vw, 0.9rem);
  letter-spacing: 0.075em;
}

.final-lines strong {
  display: block;
  margin-top: 8px;
  color: var(--gold);
  font-weight: 500;
  letter-spacing: 0.14em;
}

#stateOutput {
  display: block;
  margin-top: 10px;
  color: var(--cyan);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
}

.footer-nav {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-top: 9px;
}

.footer-nav button {
  min-width: 50px;
  border: 1px solid rgba(200, 148, 50, 0.44);
  background: rgba(0, 11, 12, 0.8);
  color: var(--cyan);
  font-family: Georgia, serif;
  font-size: 1.1rem;
}

.terminal-card {
  height: 245px;
  display: grid;
  place-items: center;
  align-content: space-around;
  border: 1px solid rgba(200, 148, 50, 0.48);
  padding: 12px;
  color: var(--gold);
  font-family: Georgia, serif;
  text-align: center;
}

.terminal-card p,
.terminal-card b {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  line-height: 1.6;
}

.terminal-orbit {
  position: relative;
  display: grid;
  place-items: center;
  width: 116px;
  aspect-ratio: 1;
  border: 1px solid rgba(200, 148, 50, 0.72);
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle, transparent 0 18%, rgba(200, 148, 50, 0.32) 19% 20%),
    conic-gradient(from 45deg, transparent, rgba(0, 201, 210, 0.24), transparent, rgba(200, 148, 50, 0.3), transparent);
  color: var(--gold-bright);
  font-size: 2.2rem;
}

.terminal-orbit::before {
  content: "";
  position: absolute;
  inset: 23%;
  border: 1px solid rgba(200, 148, 50, 0.62);
  transform: rotate(45deg);
}

[data-state="body"] {
  --cyan: #44dba2;
  --cyan-dim: rgba(68, 219, 162, 0.28);
}

[data-state="return"] {
  --cyan: #bb70ff;
  --cyan-dim: rgba(187, 112, 255, 0.28);
}

@media (max-width: 940px) {
  .codex {
    width: 100%;
  }

  .hero {
    grid-template-columns: 140px minmax(0, 1fr) 140px;
  }

  .hero-seal {
    width: 124px;
  }

  .hero-copy p,
  .hero-copy strong {
    white-space: normal;
  }

  .plate-grid-top,
  .plate-grid-middle,
  .plate-grid-bottom {
    grid-template-columns: 1fr 1fr;
  }

  .docusite-panel,
  .image-panel,
  .declaration-panel {
    grid-column: span 2;
  }

  .final-seal {
    grid-template-columns: 170px minmax(0, 1fr) 170px;
  }

  .terminal-card {
    height: 220px;
  }

  .terminal-orbit {
    width: 96px;
  }
}

@media (max-width: 680px) {
  .codex {
    padding: 6px;
  }

  .hero {
    min-height: 270px;
    grid-template-columns: 1fr 1fr;
    padding: 17px 14px;
  }

  .hero-copy {
    grid-column: span 2;
    grid-row: 1;
  }

  .hero h1 {
    font-size: 4.2rem;
  }

  .hero-copy p,
  .hero-copy strong {
    font-size: 0.67rem;
    text-align: center;
  }

  .hero-seal {
    display: none;
  }

  .side-switch {
    display: none;
  }

  .plate-grid-top,
  .plate-grid-middle,
  .plate-grid-bottom,
  .final-seal {
    grid-template-columns: 1fr;
  }

  .docusite-panel,
  .image-panel,
  .declaration-panel {
    grid-column: auto;
  }

  .panel {
    min-height: auto;
  }

  .seal-stage {
    min-height: 380px;
    aspect-ratio: 0.86;
  }

  .final-seal {
    padding: 17px;
  }

  .terminal-card {
    height: auto;
    grid-template-columns: 1fr 1fr 1fr;
  }

  .terminal-orbit {
    width: 82px;
  }
}
