@import url('https://fonts.googleapis.com/css2?family=Kalam:wght@300;400;700&family=Cinzel:wght@400;600;700&family=Cormorant+Garamond:wght@400;500;600&display=swap');

:root {
  color-scheme: dark;
  --bg: #0b0b0f;
  --bg-soft: #12121a;
  --ink: #f2ede3;
  --muted: #b7b1a6;
  --gold: #c9a44d;
  --gold-soft: rgba(201, 164, 77, 0.2);
  --temple: #8759ee;
  --court: #d7b75a;
  --vault: #f08cff;
  --stroke: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Cormorant Garamond', 'Times New Roman', serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(201, 164, 77, 0.08), transparent 60%),
    radial-gradient(circle at 20% 30%, rgba(135, 89, 238, 0.08), transparent 50%),
    linear-gradient(160deg, #0b0b0f 0%, #0f0f17 40%, #0b0b0f 100%);
  letter-spacing: 0.01em;
  scroll-behavior: smooth;
}

body.ritual-active {
  overflow: hidden;
}

.gate {
  max-width: 980px;
  margin: 0 auto;
  padding: 64px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 48px;
}

.crest {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.crest h1 {
  font-family: 'Cinzel', 'Times New Roman', serif;
  font-size: clamp(2rem, 4vw, 3.2rem);
  letter-spacing: 0.14em;
  margin: 0;
}

.crest-icon {
  width: 120px;
  height: 90px;
}

.crown-icon {
  width: 100%;
  height: 100%;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.crown--crest {
  stroke: var(--gold);
}

.crown--temple {
  stroke: var(--temple);
}

.crown--court {
  stroke: var(--court);
}

.crown--vault {
  stroke: var(--vault);
}

.inscription {
  text-align: center;
  font-size: 1.15rem;
  line-height: 1.7;
  color: var(--muted);
}

.inscription .lead {
  font-size: 1.4rem;
  color: var(--ink);
  letter-spacing: 0.06em;
}

.inscription .rule {
  font-size: 1.1rem;
  color: var(--gold);
  margin-top: 12px;
}

.inscription .triple {
  margin-top: 24px;
  font-size: 1.2rem;
  color: var(--ink);
}

.inscription .session {
  margin-top: 24px;
  font-family: 'Cinzel', 'Times New Roman', serif;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.9rem;
  color: var(--gold);
}

.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.6;
}

.chambers {
  text-align: center;
}

.chambers h2 {
  font-family: 'Cinzel', 'Times New Roman', serif;
  letter-spacing: 0.3em;
  font-size: 1rem;
  color: var(--gold);
  margin-bottom: 28px;
}

.chamber-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 24px;
}

.chamber {
  border: 1px solid var(--stroke);
  background: rgba(15, 15, 22, 0.65);
  padding: 24px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 270px;
}

.chamber-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chamber-head h3 {
  margin: 0;
  font-family: 'Cinzel', 'Times New Roman', serif;
  font-size: 1.2rem;
  color: var(--ink);
}

.chamber-copy {
  margin: 0;
  color: var(--muted);
  flex: 1;
}

.chamber-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--gold);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.8rem;
  font-family: 'Cinzel', 'Times New Roman', serif;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  background: transparent;
  cursor: pointer;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-temple {
  color: var(--temple);
  border-color: rgba(135, 89, 238, 0.5);
}

.btn-temple:hover {
  box-shadow: 0 0 16px rgba(135, 89, 238, 0.25);
}

.btn-court {
  color: var(--court);
  border-color: rgba(215, 183, 90, 0.5);
}

.btn-court:hover {
  box-shadow: 0 0 16px rgba(215, 183, 90, 0.25);
}

.btn-vault {
  color: var(--vault);
  border-color: rgba(240, 140, 255, 0.4);
}

.btn-vault:hover {
  box-shadow: 0 0 16px rgba(240, 140, 255, 0.25);
}

.chamber .btn {
  margin-top: auto;
  align-self: flex-start;
}

.btn-ghost {
  color: var(--muted);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-ghost:hover {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.1);
}

.chambers-note {
  margin-top: 24px;
  font-size: 0.9rem;
  color: var(--muted);
}

.court-callout {
  border: 1px solid var(--gold-soft);
  padding: 24px;
  text-align: center;
  background: rgba(12, 12, 18, 0.65);
}

.court-title {
  margin: 0 0 8px;
  font-family: 'Cinzel', 'Times New Roman', serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  font-size: 0.9rem;
}

.court-body {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.gate-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.gate-footer .copy {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--gold);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
  isolation: isolate;
}

.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(1200px 700px at 50% 25%, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.68) 45%, rgba(0, 0, 0, 0.92) 100%);
  opacity: 0;
  transition: opacity 0.8s ease;
}

.overlay.active .veil {
  opacity: 1;
}

.stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  perspective: 1200px;
  perspective-origin: 50% 52%;
}

.scene {
  position: relative;
  width: min(1100px, 96vw);
  height: min(720px, 80vh);
  transform-style: preserve-3d;
  transform: translateZ(0) scale(0.98);
  opacity: 0;
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.overlay.active .scene {
  opacity: 1;
  transform: translateZ(0) scale(1);
}

.void {
  position: absolute;
  inset: 0;
  border-radius: 26px;
  overflow: hidden;
  background:
    radial-gradient(900px 520px at 50% 40%, rgba(233, 237, 242, 0.06) 0%, rgba(233, 237, 242, 0) 60%),
    radial-gradient(1200px 720px at 50% 30%, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.9) 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
  border: 1px solid rgba(233, 237, 242, 0.1);
  transform: translateZ(-420px);
}

.fog {
  position: absolute;
  inset: -25%;
  pointer-events: none;
  mix-blend-mode: screen;
  filter: blur(18px);
  opacity: 0;
  transition: opacity 1.2s ease;
}

.overlay.active .fog {
  opacity: 0.55;
}

.fog::before,
.fog::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(240px 160px at 18% 40%, rgba(233, 237, 242, 0.16), rgba(233, 237, 242, 0) 72%),
    radial-gradient(280px 190px at 70% 35%, rgba(233, 237, 242, 0.12), rgba(233, 237, 242, 0) 76%),
    radial-gradient(360px 230px at 45% 70%, rgba(233, 237, 242, 0.1), rgba(233, 237, 242, 0) 80%),
    radial-gradient(300px 210px at 84% 78%, rgba(233, 237, 242, 0.08), rgba(233, 237, 242, 0) 82%);
  animation: fogDrift 14s ease-in-out infinite;
}

.fog::after {
  animation-duration: 20s;
  animation-direction: reverse;
  transform: scale(1.08);
  opacity: 0.75;
}

.frame {
  position: absolute;
  inset: 0;
  border-radius: 26px;
  overflow: hidden;
  transform-style: preserve-3d;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(233, 237, 242, 0.12);
}

.portal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transform-style: preserve-3d;
}

.portal-hole {
  width: min(720px, 86vw);
  height: min(520px, 64vh);
  border-radius: 20px;
  border: 1px solid rgba(233, 237, 242, 0.08);
  background: rgba(0, 0, 0, 0.55);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.55),
    inset 0 0 60px rgba(0, 0, 0, 0.75);
  transform: translateZ(-60px);
  z-index: 1;
}

.door {
  position: absolute;
  top: 50%;
  width: 50%;
  height: min(520px, 64vh);
  transform-style: preserve-3d;
  transform-origin: left center;
  transform: translateY(-50%);
  will-change: transform;
  transition: transform 1.9s cubic-bezier(0.18, 0.95, 0.08, 1);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(233, 237, 242, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02)),
    linear-gradient(180deg, rgba(16, 18, 26, 0.98), rgba(8, 9, 12, 0.98)),
    radial-gradient(900px 700px at 30% 25%, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 55%),
    radial-gradient(700px 600px at 70% 80%, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0) 60%);
  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.7),
    inset 0 0 12px rgba(255, 255, 255, 0.16),
    0 0 0 1px rgba(233, 237, 242, 0.2);
  z-index: 30;
  backface-visibility: hidden;
}

.door.right {
  right: 50%;
  transform-origin: right center;
}

.door.left {
  left: 50%;
}

.door::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 14px;
  right: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.6));
  opacity: 0.85;
}

.door.right::after {
  left: 0;
  right: auto;
}

.overlay.opening .door.left {
  transform: translateY(-50%) rotateY(-110deg) translateZ(40px);
}

.overlay.opening .door.right {
  transform: translateY(-50%) rotateY(110deg) translateZ(40px);
}

.overlay.passed .door {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s linear;
}

.overlay.passed .door.left {
  transform: translateY(-50%) rotateY(-110deg) translateZ(40px) translateX(-1200px);
}

.overlay.passed .door.right {
  transform: translateY(-50%) rotateY(110deg) translateZ(40px) translateX(1200px);
}

.overlay.walking .scene {
  transform: translateZ(140px) scale(1.02);
  transition: transform 2.1s cubic-bezier(0.18, 0.95, 0.08, 1);
}

.oath {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  transform: translateY(6px);
  opacity: 0;
  transition: opacity 0.9s ease, transform 0.9s ease;
  pointer-events: none;
  z-index: 3;
}

.overlay.revealed .oath {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.oath-card {
  width: min(760px, 92vw);
  background: rgba(12, 13, 18, 0.78);
  border: 1px solid rgba(233, 237, 242, 0.14);
  border-radius: 18px;
  padding: 22px 22px 18px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.62);
}

.oath-card h2 {
  margin: 0 0 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: rgba(233, 237, 242, 0.88);
}

.oath-rule {
  height: 1px;
  background: linear-gradient(90deg, rgba(233, 237, 242, 0), rgba(233, 237, 242, 0.14), rgba(233, 237, 242, 0));
  margin: 10px 0 14px;
}

.oath-text {
  display: grid;
  gap: 10px;
  line-height: 1.6;
  color: rgba(246, 241, 235, 0.98);
  min-height: 220px;
  font-size: 1.75rem;
  font-family: 'Kalam', 'Cormorant Garamond', serif;
  letter-spacing: 0.01em;
  text-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
}

.oath-line {
  opacity: 0;
  display: block;
  font-weight: 400;
  -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 60%, transparent 100%);
  mask-image: linear-gradient(90deg, #000 0%, #000 60%, transparent 100%);
  -webkit-mask-size: 0% 100%;
  mask-size: 0% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  animation: writeLine var(--duration) linear forwards;
  animation-delay: var(--delay);
}

.oath-gap {
  height: 12px;
}

.actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.actions.ready {
  opacity: 1;
  transform: translateY(0);
}

.actions button {
  appearance: none;
  border: 1px solid rgba(233, 237, 242, 0.22);
  background: rgba(0, 0, 0, 0.22);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.7rem;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.actions button:hover {
  transform: translateY(-1px);
  border-color: rgba(233, 237, 242, 0.4);
  background: rgba(0, 0, 0, 0.3);
}

.actions button:active {
  transform: translateY(0);
}

@keyframes fogDrift {
  0% {
    transform: translate3d(-2%, -1%, 0) scale(1.02);
  }
  50% {
    transform: translate3d(2%, 2%, 0) scale(1.06);
  }
  100% {
    transform: translate3d(-2%, -1%, 0) scale(1.02);
  }
}

@keyframes writeLine {
  0% {
    opacity: 0;
    -webkit-mask-size: 0% 100%;
    mask-size: 0% 100%;
  }
  12% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
  }
}

@media (max-width: 640px) {
  .gate {
    padding-top: 48px;
  }

  .chamber {
    text-align: center;
  }

  .chamber-head {
    justify-content: center;
  }

  .oath-text {
    font-size: 1.3rem;
  }

  .chamber .btn {
    align-self: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fog::before,
  .fog::after,
  .door,
  .scene,
  .veil,
  .oath {
    animation: none !important;
    transition: none !important;
  }
}
