/* Llum — the temple.
   Layers, bottom to top: chamber, session orb, gates, light beams, dust,
   crystals, text, light flood, controls. The current state lives in
   #app[data-state] and every screen is styled from it. */

/* Colour of the selected crystal. Registered so the whole temple can glide
   from one colour to the next. */
@property --c1 { syntax: '<color>'; inherits: true; initial-value: #c8142f; }
@property --c2 { syntax: '<color>'; inherits: true; initial-value: #e0303f; }

:root {
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "Noto Serif", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --ink: #070504;
  --ivory: #f2e8d5;
  --gold: #f1d29a;
  --gold-deep: #c99a4e;

  /* Stone textures: fine grain + large mottling (SVG turbulence, data URIs). */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n' filterUnits='userSpaceOnUse' x='0' y='0' width='180' height='180'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .75 0 0 0 -.2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --mottle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420'%3E%3Cfilter id='m' filterUnits='userSpaceOnUse' x='0' y='0' width='420' height='420'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012' numOctaves='3' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.4 0 0 0 -.5'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3C/svg%3E");

  --slot: clamp(40px, calc((100dvh - 340px) / 9), 62px);
  --root-y: calc(100% - 190px - env(safe-area-inset-bottom, 0px));
  --breath: 10s;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #050403;
  color: var(--ivory);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  /* Wide screens: the temple stays a phone-width column on dark stone. */
  background:
    radial-gradient(60% 50% at 50% 45%, #1b130d 0%, transparent 70%),
    var(--grain),
    #050403;
}

p { margin: 0; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  isolation: isolate;
  background: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  container-type: size;
  transition:
    --c1 var(--colour-ms, 1800ms) ease,
    --c2 var(--colour-ms, 1800ms) ease;
}

@media (min-width: 520px) {
  .app { box-shadow: 0 0 80px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(241, 210, 154, 0.05); }
}

.app > * { position: absolute; }

/* ======================================================================
   CHAMBER — the inner sanctuary walls, tinted by the selected crystal.
   ====================================================================== */

.chamber {
  inset: 0;
  z-index: 0;
  background:
    var(--grain),
    var(--mottle),
    radial-gradient(130% 75% at 50% 52%,
      color-mix(in oklab, var(--c1) 26%, #110c09) 0%,
      color-mix(in oklab, var(--c1) 9%, #0b0806) 45%,
      #050403 100%);
  transition: filter 2s ease;
}

.chamber > * { position: absolute; }

.chamber-glow {
  inset: -10%;
  background:
    radial-gradient(42% 34% at 50% 50%, color-mix(in oklab, var(--c2) 40%, transparent) 0%, transparent 70%),
    radial-gradient(70% 55% at 50% 58%, color-mix(in oklab, var(--c1) 30%, transparent) 0%, transparent 72%);
  opacity: calc(0.55 + var(--p, 0) * 0.45);
  mix-blend-mode: screen;
}

.chamber-pillar {
  top: 0;
  bottom: 0;
  width: 13%;
  background:
    linear-gradient(180deg, #050403 0%, transparent 18%, transparent 80%, #050403 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.35) 45%, color-mix(in oklab, var(--c2) 17%, transparent) 78%, rgba(0, 0, 0, 0.7) 100%),
    var(--grain),
    linear-gradient(180deg, #1c1510, #120d0a);
  opacity: 0.9;
  transition: opacity 2s ease;
}
.chamber-pillar--l { left: 0; }
.chamber-pillar--r { right: 0; transform: scaleX(-1); }

.chamber-mandala {
  left: 50%;
  top: calc(var(--root-y) - 4 * var(--slot));
  width: min(118cqw, 560px);
  height: min(118cqw, 560px);
  translate: -50% -50%;
  stroke: color-mix(in oklab, var(--c2) 55%, var(--gold));
  stroke-width: 0.45;
  opacity: 0.11;
  transition: opacity 2.4s ease;
  animation: turn 360s linear infinite;
}

.niche {
  left: 50%;
  width: 124px;
  translate: -50% 0;
  top: calc(var(--root-y) - 8 * var(--slot) - 52px);
  bottom: calc(100% - var(--root-y) - 34px);
  border-radius: 62px 62px 10px 10px;
  background:
    linear-gradient(180deg,
      color-mix(in oklab, var(--c2) 16%, #0a0705) 0%,
      color-mix(in oklab, var(--c1) 12%, #070504) 55%,
      color-mix(in oklab, var(--c1) 24%, #0a0705) 100%);
  box-shadow:
    inset 0 0 34px rgba(0, 0, 0, 0.85),
    inset 0 1px 0 rgba(255, 230, 190, 0.1),
    0 0 0 1px rgba(255, 230, 190, 0.04),
    0 0 60px color-mix(in oklab, var(--c1) 22%, transparent);
  transition: opacity 2s ease;
}

.niche-light {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(40% 60% at 50% 45%, color-mix(in oklab, var(--c2) 30%, transparent), transparent 70%);
  opacity: calc(0.6 + var(--p, 0) * 0.8);
}

.chamber-floor {
  left: -20%;
  right: -20%;
  bottom: -14%;
  height: 34%;
  border-radius: 50%;
  background: radial-gradient(50% 50% at 50% 50%, color-mix(in oklab, var(--c1) 30%, transparent), transparent 70%);
  opacity: 0.8;
}

/* ======================================================================
   GATES — massive carved stone doors between two pillars.
   ====================================================================== */

.gates {
  inset: 0;
  z-index: 2;
  transform-origin: 50% 46%;
}

.gates > * { position: absolute; }

.wall {
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.25) 26%, rgba(0, 0, 0, 0.1) 60%, rgba(0, 0, 0, 0.75) 100%),
    var(--grain),
    var(--mottle),
    repeating-linear-gradient(180deg, transparent 0 52px, rgba(0, 0, 0, 0.42) 52px 54px, rgba(255, 225, 180, 0.04) 54px 55px),
    linear-gradient(180deg, #2a2119 0%, #241c15 100%);
}

/* Fluted pillars */
.pillar {
  top: 5%;
  bottom: 6%;
  width: 11%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.pillar--l { left: 2%; }
.pillar--r { right: 2%; }

.pillar .shaft {
  flex: 1;
  width: 78%;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.05) 30%, rgba(255, 220, 170, 0.14) 48%, rgba(0, 0, 0, 0.18) 66%, rgba(0, 0, 0, 0.78) 100%),
    var(--grain),
    repeating-linear-gradient(90deg, #3e3228 0 3px, #261d16 3px 5px, #4a3c30 5px 8px),
    #34291f;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.6);
}
.pillar .capital,
.pillar .base {
  width: 100%;
  height: 26px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.55), rgba(255, 220, 170, 0.12) 45%, rgba(0, 0, 0, 0.6)),
    var(--grain),
    linear-gradient(180deg, #4d3f33, #2b2219);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 225, 180, 0.15);
}
.pillar .capital { border-radius: 2px 2px 6px 6px; clip-path: polygon(0 0, 100% 0, 92% 100%, 8% 100%); }
.pillar .base { height: 30px; clip-path: polygon(10% 0, 90% 0, 100% 100%, 0 100%); }

/* The arched stone frame around the doors */
.arch {
  left: calc(16% - 13px);
  right: calc(16% - 13px);
  top: calc(14% - 13px);
  bottom: calc(11% - 2px);
  border-top-left-radius: 50% 19%;
  border-top-right-radius: 50% 19%;
  background:
    var(--grain),
    linear-gradient(90deg, rgba(0, 0, 0, 0.45), rgba(255, 220, 170, 0.1) 50%, rgba(0, 0, 0, 0.45)),
    linear-gradient(180deg, #514234 0%, #3a2e24 40%, #2b2219 100%);
  box-shadow:
    0 0 40px rgba(0, 0, 0, 0.75),
    inset 0 1px 0 rgba(255, 230, 190, 0.2),
    inset 0 0 0 4px rgba(0, 0, 0, 0.15);
}
/* Keystone */
.arch::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -6px;
  width: 30px;
  height: 34px;
  translate: -50% 0;
  clip-path: polygon(0 0, 100% 0, 78% 100%, 22% 100%);
  background:
    var(--grain),
    linear-gradient(180deg, #5c4b3b, #3a2e24);
}

.doorway {
  left: 16%;
  right: 16%;
  top: 14%;
  bottom: 11%;
  overflow: hidden;
  border-top-left-radius: 50% 18%;
  border-top-right-radius: 50% 18%;
  container-type: size;
  background: #1a120c;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6);
}

/* Warm light waiting behind the doors */
.spill {
  inset: 0;
  position: absolute;
  background:
    radial-gradient(60% 45% at 50% 42%, #fff7e4 0%, #ffe2a8 22%, #f0b061 48%, #9a5525 78%, #3a1d0c 100%);
}

.door {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50.5%;
  overflow: hidden;
  z-index: 1;
  background:
    radial-gradient(90% 55% at 70% 38%, rgba(255, 214, 150, 0.12), transparent 70%),
    var(--grain),
    var(--mottle),
    linear-gradient(180deg, #4e3f32 0%, #3d3127 42%, #2a2119 100%);
  transition: transform var(--door-ms, 2600ms) cubic-bezier(0.6, 0.02, 0.22, 1) var(--hum-lead, 500ms);
  will-change: transform;
}
.door--l {
  left: 0;
  border-top-left-radius: 100% 18%;
  box-shadow:
    inset -2px 0 0 rgba(0, 0, 0, 0.75),
    inset -10px 0 18px rgba(0, 0, 0, 0.35),
    inset 18px 0 30px rgba(0, 0, 0, 0.45);
}
.door--r {
  right: 0;
  border-top-right-radius: 100% 18%;
  background:
    radial-gradient(90% 55% at 30% 38%, rgba(255, 214, 150, 0.12), transparent 70%),
    var(--grain),
    var(--mottle),
    linear-gradient(180deg, #4e3f32 0%, #3d3127 42%, #2a2119 100%);
  box-shadow:
    inset 2px 0 0 rgba(0, 0, 0, 0.75),
    inset 10px 0 18px rgba(0, 0, 0, 0.35),
    inset -18px 0 30px rgba(0, 0, 0, 0.45);
}

/* Carved border line following each door's edge */
.door::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: inherit;
  border: 1px solid rgba(0, 0, 0, 0.5);
  box-shadow: 0 1px 0 rgba(255, 225, 180, 0.08), inset 0 1px 0 rgba(255, 225, 180, 0.07);
}
.door--l::before { right: 7px; }
.door--r::before { left: 7px; }

/* The mandala is carved across the seam: half on each door. */
.engraving {
  position: absolute;
  width: 94cqw;
  height: 94cqw;
  top: calc(41cqh - 47cqw);
  overflow: visible;
}
.door--l .engraving { left: calc(100% - 47cqw); }
.door--r .engraving { left: -47cqw; }
.engraving use { stroke-width: 0.9; }
.engraving .cut-shadow { stroke: rgba(0, 0, 0, 0.6); transform: translateY(-0.7px); }
.engraving .cut-light { stroke: rgba(255, 222, 170, 0.15); transform: translateY(0.7px); }

/* Recessed panels low on each door */
.panel {
  position: absolute;
  left: 18%;
  right: 18%;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.12);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.6),
    inset 0 -1px 0 rgba(255, 225, 180, 0.08),
    0 1px 0 rgba(255, 225, 180, 0.07);
}
.panel--a { top: 70%; height: 10%; }
.panel--b { top: 84%; height: 9%; }

/* Light leaking through the closed seam */
.seam {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 2%;
  bottom: 0;
  width: 2px;
  translate: -50% 0;
  background: linear-gradient(180deg, transparent 0%, rgba(255, 220, 150, 0.9) 18%, rgba(255, 236, 196, 1) 45%, rgba(255, 210, 140, 0.85) 82%, transparent 100%);
  box-shadow: 0 0 10px 2px rgba(255, 190, 100, 0.45), 0 0 34px 6px rgba(255, 170, 80, 0.18);
  animation: seam 7s ease-in-out infinite;
}

.steps {
  left: 0;
  right: 0;
  bottom: 0;
  height: 12%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.steps i {
  display: block;
  flex: 1;
  background:
    var(--grain),
    linear-gradient(180deg, #43362b 0%, #2b2219 22%, #1d1610 100%);
  box-shadow: inset 0 1px 0 rgba(255, 225, 180, 0.12), 0 -2px 8px rgba(0, 0, 0, 0.5);
}
.steps i:nth-child(1) { width: 74%; }
.steps i:nth-child(2) { width: 86%; }
.steps i:nth-child(3) { width: 100%; }

/* Warm light from the crystals falling on the closed doors */
.gates::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  background:
    radial-gradient(34% 20% at 50% 45%, rgba(255, 200, 140, 0.16), transparent 70%),
    radial-gradient(22% 9% at 50% 55%, rgba(220, 40, 60, 0.12), transparent 70%),
    radial-gradient(26% 10% at 50% 37%, rgba(140, 110, 255, 0.1), transparent 70%);
}

/* ======================================================================
   LIGHT — beams from above, dust, and the flood when the doors open.
   ====================================================================== */

.beams {
  inset: 0;
  z-index: 3;
  pointer-events: none;
  mix-blend-mode: screen;
  transition: opacity 2s ease;
}
.beams i {
  position: absolute;
  top: -8%;
  height: 100%;
  width: 34%;
  transform-origin: 50% 0;
  background: linear-gradient(180deg, rgba(255, 226, 168, 0.3) 0%, rgba(255, 210, 140, 0.1) 50%, transparent 88%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.6) 30%, #000 50%, rgba(0, 0, 0, 0.6) 70%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.6) 30%, #000 50%, rgba(0, 0, 0, 0.6) 70%, transparent 100%);
  animation: beam 13s ease-in-out infinite;
}
.beams i:nth-child(1) { left: 14%; rotate: -16deg; animation-delay: -3s; }
.beams i:nth-child(2) { left: 36%; rotate: -9deg; width: 40%; animation-delay: -8s; }
.beams i:nth-child(3) { left: 58%; rotate: -4deg; width: 26%; animation-delay: -1s; opacity: 0.7; }

.dust {
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
  mix-blend-mode: screen;
  transition: opacity 2s ease;
}

.flood {
  inset: 0;
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(70% 60% at 50% 46%, rgba(255, 246, 225, 0.98) 0%, rgba(255, 216, 150, 0.8) 35%, rgba(200, 120, 50, 0.35) 70%, rgba(80, 40, 10, 0) 100%);
}

/* ======================================================================
   CRYSTALS
   ====================================================================== */

.constellation {
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
.crystals { position: absolute; inset: 0; }

.spine {
  position: absolute;
  left: 50%;
  width: 1px;
  translate: -50% 0;
  top: calc(var(--root-y) - 8 * var(--slot));
  height: calc(8 * var(--slot));
  background: linear-gradient(180deg, transparent, color-mix(in oklab, var(--c2) 55%, var(--gold)) 15%, color-mix(in oklab, var(--c1) 70%, var(--gold)) 85%, transparent);
  box-shadow: 0 0 8px color-mix(in oklab, var(--c1) 60%, transparent);
  opacity: 0;
  transition: opacity 1.6s ease;
}

.crystal {
  --gw: 20px;
  --gh: 36px;
  position: absolute;
  left: 50%;
  width: 66px;
  height: max(44px, var(--slot));
  translate: -50% -50%;
  pointer-events: auto;
  touch-action: none;
  border-radius: 16px;
  outline: none;
  /* Sanctuary position: a vertical column, Root at the base. */
  top: calc(var(--root-y) - var(--i) * var(--slot));
  transform: translateY(0) scale(1);
  opacity: 0;
  transition:
    top 1.4s cubic-bezier(0.3, 0.1, 0.2, 1),
    left 1.4s cubic-bezier(0.3, 0.1, 0.2, 1),
    transform 1.4s cubic-bezier(0.3, 0.1, 0.2, 1),
    opacity 1.1s ease;
}
.crystal:focus-visible {
  box-shadow: 0 0 0 2px rgba(241, 210, 154, 0.75);
}

.crystal-glow,
.gem-wrap,
.ring {
  position: absolute;
  left: 50%;
  top: 50%;
  pointer-events: none;
}

.crystal-glow {
  width: 64px;
  height: 64px;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in oklab, var(--cc2) 70%, transparent) 0%, color-mix(in oklab, var(--cc) 35%, transparent) 30%, transparent 68%);
  opacity: 0.55;
  transition: opacity 0.8s ease, transform 0.8s ease;
  animation: shimmer 5.5s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.7s);
}

.gem-wrap {
  width: var(--gw);
  height: var(--gh);
  translate: -50% -50%;
  filter: drop-shadow(0 0 5px var(--cc)) drop-shadow(0 0 12px color-mix(in oklab, var(--cc) 55%, transparent));
  transition: transform 0.8s cubic-bezier(0.3, 0.1, 0.2, 1), opacity 0.8s ease;
  opacity: 0.82;
}

.gem {
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 0, 100% 27%, 100% 73%, 50% 100%, 0 73%, 0 27%);
  background:
    linear-gradient(90deg, transparent 49%, rgba(255, 255, 255, 0.45) 50%, transparent 51%),
    linear-gradient(162deg, rgba(255, 255, 255, 0.75) 0%, rgba(255, 255, 255, 0) 30%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.28) 0%, rgba(255, 255, 255, 0.04) 48%, rgba(0, 0, 0, 0.26) 52%, rgba(0, 0, 0, 0.06) 100%),
    linear-gradient(180deg, color-mix(in oklab, var(--cc2) 55%, white) 0%, var(--cc2) 26%, var(--cc) 62%, color-mix(in oklab, var(--cc) 62%, black) 100%);
  overflow: hidden;
}
/* A slow sheen that passes over each crystal */
.gem::after {
  content: "";
  position: absolute;
  inset: -20% -60%;
  background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, 0.65) 50%, transparent 60%);
  transform: translateX(-70%);
  animation: sheen 9s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.55s);
}

.ring {
  width: 60px;
  height: 60px;
  translate: -50% -50%;
  rotate: -90deg;
  overflow: visible;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.ring circle { fill: none; }
.ring-track { stroke: rgba(242, 232, 213, 0.12); stroke-width: 1; }
.ring-fill {
  stroke: color-mix(in oklab, var(--cc2) 60%, white);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 100px 100px;
  stroke-dashoffset: calc((1 - var(--p, 0)) * 100px);
  filter: drop-shadow(0 0 3px var(--cc));
}

/* Selected crystal */
.crystal[aria-pressed="true"] .gem-wrap {
  opacity: 1;
  transform: scale(calc(1.3 + var(--p, 0) * 0.4));
  filter:
    brightness(calc(1 + var(--p, 0) * 0.7))
    drop-shadow(0 0 6px var(--cc))
    drop-shadow(0 0 18px var(--cc));
}
.crystal[aria-pressed="true"] .crystal-glow {
  opacity: 1;
  transform: scale(calc(1.35 + var(--p, 0) * 1.4));
}

/* Ascend All */
.ascend {
  position: absolute;
  left: 50%;
  top: calc(var(--root-y) + max(44px, var(--slot)) / 2 + 10px);
  translate: -50% 0;
  min-height: 44px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(242, 232, 213, 0.6);
  white-space: nowrap;
  border-radius: 22px;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 1.2s ease, color 0.4s ease;
}
.ascend::before,
.ascend::after {
  content: "";
  width: 22px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(241, 210, 154, 0.55));
}
.ascend::after { transform: scaleX(-1); }
.ascend:hover { color: rgba(242, 232, 213, 0.9); }
.ascend:focus-visible { outline: 2px solid rgba(241, 210, 154, 0.7); outline-offset: 2px; }

/* ======================================================================
   TEXT
   ====================================================================== */

.caption {
  z-index: 6;
  left: 24px;
  right: 24px;
  top: calc(34px + env(safe-area-inset-top, 0px));
  text-align: center;
  opacity: 0;
  transition: opacity 0.9s ease;
  pointer-events: none;
}
.caption-name,
.caption-meta,
.caption-meaning { transition: opacity 0.28s ease; }
.caption.is-swapping p { opacity: 0; }

.caption-name {
  font-family: var(--serif);
  font-size: 24px;
  letter-spacing: 0.08em;
  color: var(--ivory);
  text-shadow: 0 0 18px color-mix(in oklab, var(--c1) 70%, transparent), 0 0 2px rgba(0, 0, 0, 0.8);
}
.caption-meta {
  margin-top: 6px;
  font-size: 12.5px;
  letter-spacing: 0.16em;
  color: color-mix(in oklab, var(--c2) 45%, var(--ivory));
  opacity: 0.85;
}
.caption-meaning {
  margin: 12px auto 0;
  max-width: 30ch;
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  line-height: 1.45;
  color: rgba(242, 232, 213, 0.5);
}
.caption.is-swapping .caption-meaning { opacity: 0; }

.welcome {
  z-index: 9;
  left: 32px;
  right: 32px;
  top: 50%;
  translate: 0 -50%;
  text-align: center;
  font-family: var(--serif);
  color: #fff8ea;
  text-shadow: 0 0 24px rgba(255, 200, 120, 0.55), 0 0 2px rgba(80, 40, 10, 0.6);
  opacity: 0;
  pointer-events: none;
}
.welcome span { display: block; }
.welcome-a {
  font-size: 34px;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.welcome-b {
  font-size: 19px;
  font-style: italic;
  letter-spacing: 0.03em;
  line-height: 1.4;
  color: rgba(255, 244, 222, 0.85);
}

.hint {
  z-index: 6;
  left: 0;
  right: 0;
  bottom: calc(30px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  font-size: 11.5px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(242, 232, 213, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.2s ease;
}
.hint--gates {
  bottom: calc(3.4% + env(safe-area-inset-bottom, 0px));
  color: rgba(255, 236, 200, 0.62);
  text-shadow: 0 0 10px rgba(255, 190, 110, 0.5), 0 1px 2px rgba(0, 0, 0, 0.9);
}

/* ======================================================================
   SESSION — the orb, breathing waves, pause.
   ====================================================================== */

.session-layer {
  inset: 0;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 2.4s ease;
}
.session-layer > * { position: absolute; }

.orb-anchor {
  left: 50%;
  top: calc(46% - var(--rise, 0) * 1.4%);
  width: 0;
  height: 0;
  transition: top 4s cubic-bezier(0.4, 0, 0.2, 1);
}
.orb-anchor > * {
  position: absolute;
  left: 0;
  top: 0;
  translate: -50% -50%;
  border-radius: 50%;
}

.halo {
  width: 190cqw;
  height: 190cqw;
  background: radial-gradient(circle, color-mix(in oklab, var(--c1) 50%, transparent) 0%, color-mix(in oklab, var(--c1) 16%, transparent) 30%, color-mix(in oklab, var(--c2) 5%, transparent) 50%, transparent 66%);
  animation: breathe var(--breath) ease-in-out infinite;
}

.orb {
  width: min(64cqw, 300px);
  height: min(64cqw, 300px);
  animation: orb-pulse var(--breath) ease-in-out infinite;
}
.orb-core {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 46%,
    #fffdf7 0%,
    color-mix(in oklab, var(--c2) 35%, white) 10%,
    color-mix(in oklab, var(--c2) 80%, white) 22%,
    var(--c1) 40%,
    color-mix(in oklab, var(--c1) 55%, transparent) 52%,
    color-mix(in oklab, var(--c1) 18%, transparent) 62%,
    transparent 71%);
  filter: blur(1.5px);
}

.ripples i {
  position: absolute;
  left: 0;
  top: 0;
  width: min(64cqw, 300px);
  height: min(64cqw, 300px);
  translate: -50% -50%;
  border-radius: 50%;
  border: 1px solid color-mix(in oklab, var(--c2) 65%, transparent);
  box-shadow: 0 0 14px color-mix(in oklab, var(--c1) 40%, transparent), inset 0 0 14px color-mix(in oklab, var(--c1) 30%, transparent);
  opacity: 0;
  animation: ripple calc(var(--breath) * 1.5) linear infinite;
}
.ripples i:nth-child(2) { animation-delay: calc(var(--breath) * -0.5); }
.ripples i:nth-child(3) { animation-delay: calc(var(--breath) * -1); }

.waves {
  left: 0;
  bottom: 9%;
  width: 200%;
  height: 120px;
  overflow: visible;
  animation: wave-drift calc(var(--breath) * 2.6) linear infinite;
}
.wave {
  fill: none;
  stroke-width: 1.2px;
  vector-effect: non-scaling-stroke;
}
.wave--a { stroke: color-mix(in oklab, var(--c2) 70%, transparent); opacity: 0.35; animation: wave-rise var(--breath) ease-in-out infinite; }
.wave--b { stroke: color-mix(in oklab, var(--c1) 80%, transparent); opacity: 0.25; animation: wave-rise var(--breath) ease-in-out infinite reverse; }

.pause-zone {
  z-index: 10;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(72px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 1.5s ease, visibility 0s linear 1.5s;
}
.pause-handle {
  width: 44px;
  height: 3px;
  border-radius: 3px;
  background: rgba(242, 232, 213, 0.32);
  box-shadow: 0 0 10px color-mix(in oklab, var(--c1) 60%, transparent);
}
.pause-zone:focus-visible .pause-handle { background: rgba(241, 210, 154, 0.9); width: 64px; }
.pause-zone:focus-visible { outline: none; }

.pause-controls {
  z-index: 10;
  left: 0;
  right: 0;
  bottom: calc(44px + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
  gap: 14px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.9s ease, visibility 0s linear 0.9s;
}
.ctl {
  min-width: 112px;
  min-height: 46px;
  padding: 0 22px;
  border-radius: 23px;
  font-size: 12px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  text-indent: 0.28em;
  color: rgba(242, 232, 213, 0.85);
  border: 1px solid rgba(242, 232, 213, 0.18);
  background: rgba(10, 7, 5, 0.35);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.ctl--resume {
  border-color: color-mix(in oklab, var(--c2) 55%, rgba(242, 232, 213, 0.4));
  box-shadow: 0 0 18px color-mix(in oklab, var(--c1) 30%, transparent);
  color: var(--ivory);
}
.ctl:focus-visible { outline: 2px solid rgba(241, 210, 154, 0.8); outline-offset: 3px; }

.enter {
  z-index: 11;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
}
.enter:focus-visible { outline: 2px solid rgba(241, 210, 154, 0.5); outline-offset: -8px; border-radius: 24px; }

/* ======================================================================
   STATES
   ====================================================================== */

/* --- gates: the sealed temple --------------------------------------- */
.app[data-state="gates"] .crystal,
.app[data-state="opening"] .crystal {
  /* A grouped constellation floating over the centre seam. */
  top: calc(45% + var(--gy) * 31px);
  left: calc(50% + var(--gx) * 33px);
  transform: scale(0.74);
}
.app[data-state="gates"] .crystal {
  opacity: 1;
  transition-delay: 0s;
}
.app[data-state="gates"] .crystal-glow { opacity: 0.85; }
.app[data-state="gates"] .gem-wrap {
  opacity: 1;
  animation: float 6s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.9s);
}
.app[data-state="gates"] .hint--gates {
  animation: fade-in 2.4s ease var(--hint-delay, 3500ms) forwards;
}
.app[data-state="gates"] .constellation { pointer-events: none; }
.app[data-state="gates"] .crystal { pointer-events: none; }

/* --- opening: the doors part, light pours out ------------------------ */
.app[data-state="opening"] .door--l { transform: translateX(-101%); }
.app[data-state="opening"] .door--r { transform: translateX(101%); }
.app[data-state="opening"] .seam { animation: none; opacity: 0; transition: opacity 0.8s ease var(--hum-lead, 500ms); }
.app[data-state="opening"] .gates { animation: push-in calc(var(--door-ms, 2600ms) + var(--hum-lead, 500ms)) cubic-bezier(0.5, 0, 0.3, 1) forwards; }
.app[data-state="opening"] .flood { animation: flood-in calc(var(--door-ms, 2600ms) + var(--hum-lead, 500ms)) ease-in forwards; }
.app[data-state="opening"] .crystal {
  opacity: 0;
  transform: translateY(-40px) scale(0.5);
  transition: opacity 1.6s ease, transform 2.4s ease;
  transition-delay: calc(var(--hum-lead, 500ms) + var(--i) * 60ms);
}
.app[data-state="opening"] .beams { opacity: 1; }

/* --- welcome: the line appears in the light --------------------------- */
.app[data-state="welcome"] .gates { animation: gates-out 2.6s ease forwards; }
.app[data-state="welcome"] .door--l { transform: translateX(-101%); transition: none; }
.app[data-state="welcome"] .door--r { transform: translateX(101%); transition: none; }
.app[data-state="welcome"] .flood { animation: flood-out 4.6s ease-in-out forwards; }
.app[data-state="welcome"] .welcome {
  animation: welcome var(--welcome-total, 5300ms) ease forwards;
}
.app[data-state="welcome"] .welcome-b { animation: welcome-late var(--welcome-total, 5300ms) ease forwards; }
.app[data-state="welcome"] .beams { opacity: 0.55; }
.app[data-state="welcome"] .niche { opacity: 0; }
.app[data-state="welcome"] .chamber-mandala { opacity: 0.06; }

/* After the gates: they are gone for good. */
.app:not([data-state="gates"]):not([data-state="opening"]):not([data-state="welcome"]) .gates {
  visibility: hidden;
}

/* --- sanctuary & igniting ------------------------------------------- */
.app[data-state="sanctuary"] .crystal,
.app[data-state="igniting"] .crystal {
  opacity: 1;
  transition-delay: calc(var(--i) * 90ms), calc(var(--i) * 90ms), calc(var(--i) * 90ms), calc(var(--i) * 110ms + 150ms);
}
.app[data-state="sanctuary"] .spine,
.app[data-state="igniting"] .spine { opacity: 0.4; }
.app[data-state="sanctuary"] .ascend { opacity: 1; transition-delay: 1.2s; }
.app[data-state="sanctuary"] .caption,
.app[data-state="igniting"] .caption { opacity: 1; }
.app[data-state="sanctuary"] .hint--sanctuary { opacity: 1; transition-delay: 1.6s; }
.app[data-state="sanctuary"] .beams,
.app[data-state="igniting"] .beams { opacity: 0.3; }
.app[data-state="sanctuary"] .dust,
.app[data-state="igniting"] .dust { opacity: 0.55; }

.app[data-state="igniting"] .crystal[aria-pressed="false"] { opacity: calc(1 - var(--p, 0) * 0.7); transition: opacity 0.3s ease; }
.app[data-state="igniting"] .crystal[aria-pressed="true"] .ring { opacity: 1; }
.app[data-state="igniting"] .ascend { opacity: calc(0.6 - var(--p, 0) * 0.6); }
.app[data-state="igniting"] .chamber { filter: brightness(calc(1 + var(--p, 0) * 0.45)); }

/* --- session ---------------------------------------------------------- */
.app[data-state="session"] .session-layer { opacity: 1; }
.app[data-state="session"] .niche,
.app[data-state="complete"] .niche { opacity: 0; }
.app[data-state="session"] .chamber-pillar,
.app[data-state="complete"] .chamber-pillar { opacity: 0.15; }
.app[data-state="session"] .chamber-mandala { opacity: 0.045; }
.app[data-state="session"] .chamber { background-color: #000; }
.app[data-state="session"] .beams,
.app[data-state="session"] .dust,
.app[data-state="complete"] .beams { opacity: 0; }
.app[data-state="session"] .crystal {
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 1.4s ease, transform 1.4s ease, top 1.4s ease;
}
.app[data-state="session"] .crystal[aria-pressed="true"] { transform: scale(1.6); }
.app[data-state="session"] .pause-zone {
  opacity: 1;
  visibility: visible;
  transition: opacity 2s ease 2.5s, visibility 0s;
}
.app[data-state="session"][data-paused] .pause-zone {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0s linear 0.6s;
}
.app[data-state="session"][data-paused] .pause-controls {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.9s ease, visibility 0s;
}
.app[data-state="session"][data-paused] .session-layer { opacity: 0.45; transition-duration: 1.2s; }
.app[data-state="session"][data-paused] .session-layer *,
.app[data-state="session"][data-paused] .session-layer { animation-play-state: paused; }

/* Once the fade finishes, hide the idle layers so they cost nothing. */
.app[data-state="session"] .constellation {
  visibility: hidden;
  transition: visibility 0s linear 1.5s;
}
.app[data-state="session"] .beams {
  visibility: hidden;
  transition: opacity 2s ease, visibility 0s linear 2s;
}

/* --- complete: the orb fades, the constellation returns ---------------- */
.app[data-state="complete"] .session-layer { opacity: 0; transition-duration: 3.2s; }
.app[data-state="complete"] .crystal {
  opacity: 1;
  transition-delay: calc(1.2s + var(--i) * 120ms);
  transition-duration: 1.4s, 1.4s, 1.4s, 2s;
}
.app[data-state="complete"] .spine { opacity: 0.4; transition-delay: 2s; }
.app[data-state="complete"] .dust { opacity: 0.4; }

/* Hidden layers ignore taps. */
.app:not([data-state="gates"]) .enter { display: none; }
.app:not([data-state="sanctuary"]):not([data-state="igniting"]) .crystal,
.app:not([data-state="sanctuary"]) .ascend { pointer-events: none; }

/* ======================================================================
   KEYFRAMES
   ====================================================================== */

@keyframes turn { to { rotate: 360deg; } }

@keyframes seam {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

@keyframes beam {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

@keyframes float {
  0%, 100% { transform: translateY(-2px); }
  50% { transform: translateY(3px); }
}

@keyframes shimmer {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.35); }
}

@keyframes sheen {
  0%, 70% { transform: translateX(-70%); }
  100% { transform: translateX(70%); }
}

@keyframes fade-in { to { opacity: 1; } }

@keyframes push-in {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

@keyframes flood-in {
  0%, 30% { opacity: 0; }
  100% { opacity: 0.92; }
}

@keyframes flood-out {
  0% { opacity: 0.92; }
  100% { opacity: 0; }
}

@keyframes gates-out {
  0% { opacity: 1; transform: scale(1.06); }
  100% { opacity: 0; transform: scale(1.22); }
}

@keyframes welcome {
  0% { opacity: 0; filter: blur(6px); }
  26% { opacity: 1; filter: blur(0); }
  74% { opacity: 1; filter: blur(0); }
  100% { opacity: 0; filter: blur(4px); }
}
@keyframes welcome-late {
  0%, 10% { opacity: 0; }
  34% { opacity: 1; }
  100% { opacity: 1; }
}

@keyframes breathe {
  0%, 100% { transform: scale(0.82); opacity: 0.7; }
  50% { transform: scale(1.08); opacity: 1; }
}

@keyframes orb-pulse {
  0%, 100% { transform: scale(0.94); }
  50% { transform: scale(1.04); }
}

@keyframes ripple {
  0% { transform: scale(0.85); opacity: 0; }
  12% { opacity: 0.5; }
  100% { transform: scale(2.8); opacity: 0; }
}

@keyframes wave-drift {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

@keyframes wave-rise {
  0%, 100% { transform: translateY(10px) scaleY(0.7); }
  50% { transform: translateY(-10px) scaleY(1.15); }
}

/* ======================================================================
   REDUCED MOTION — fades instead of movement.
   ====================================================================== */

@media (prefers-reduced-motion: reduce) {
  .door { transition: opacity var(--door-ms, 2600ms) ease var(--hum-lead, 500ms); }
  .app[data-state="opening"] .door--l,
  .app[data-state="opening"] .door--r,
  .app[data-state="welcome"] .door--l,
  .app[data-state="welcome"] .door--r { transform: none; opacity: 0; }
  .app[data-state="opening"] .gates { animation: none; }
  @keyframes gates-out { from { opacity: 1; } to { opacity: 0; } }

  .crystal { transition-property: opacity; }
  .app[data-state="opening"] .crystal { transform: scale(0.74); }
  .app[data-state="gates"] .gem-wrap { animation: none; }
  .gem::after { animation: none; opacity: 0; }
  .chamber-mandala { animation: none; }

  .orb { animation: orb-glow var(--breath) ease-in-out infinite; }
  .halo { animation: halo-glow var(--breath) ease-in-out infinite; }
  .ripples { display: none; }
  .waves { animation: none; }
  .wave--a, .wave--b { animation: wave-glow var(--breath) ease-in-out infinite; }
  .orb-anchor { transition: top 0s; }

  @keyframes orb-glow { 0%, 100% { opacity: 0.75; } 50% { opacity: 1; } }
  @keyframes halo-glow { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
  @keyframes wave-glow { 0%, 100% { opacity: 0.12; } 50% { opacity: 0.35; } }
}
