/* THRESHOLD ROOM — the palette turns as you descend. */

@property --t {
  syntax: '<number>';
  inherits: true;
  initial-value: 0;
}

:root {
  --drab-bg: #c9be8c;
  --drab-ink: #3a3624;
  --neon-a: #ff2fd6;
  --neon-b: #2fe0ff;
  --neon-c: #ffe62f;
}

html { scroll-behavior: smooth; }

body.threshold {
  margin: 0;
  min-height: 400vh; /* room to scroll through the turn */
  color: color-mix(in oklch, var(--drab-ink) calc((1 - var(--t)) * 100%), white calc(var(--t) * 100%));
  background: color-mix(in oklch, var(--drab-bg) calc((1 - var(--t)) * 100%), #100014 calc(var(--t) * 100%));

  /* the whole point: one scroll-linked variable driving every color on the page */
  animation: turn linear;
  animation-timeline: scroll(root);
  animation-range: 0% 100%;
}

@keyframes turn {
  from { --t: 0; }
  to   { --t: 1; }
}

.threshold-track {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* the arch itself — a doorway whose glow ramps with --t */
.arch {
  width: min(60vw, 420px);
  aspect-ratio: 2 / 3;
  border-radius: 50% 50% 8px 8px / 30% 30% 4px 4px;
  border: 6px solid color-mix(in oklch, var(--drab-ink) calc((1 - var(--t)) * 100%), var(--neon-a) calc(var(--t) * 100%));
  background:
    radial-gradient(ellipse at 50% 30%,
      color-mix(in oklch, transparent calc((1 - var(--t)) * 100%), var(--neon-b) calc(var(--t) * 60%)) 0%,
      transparent 70%),
    color-mix(in oklch, #00000022 calc((1 - var(--t)) * 100%), #1a0022 calc(var(--t) * 100%));
  box-shadow:
    0 0 calc(var(--t) * 80px) calc(var(--t) * 20px) var(--neon-a),
    inset 0 0 calc(var(--t) * 60px) var(--neon-b);
  position: relative;
  transition: box-shadow 0.1s linear;
}

/* click the arch, it answers with a brief overexposed flash — the door
   doesn't care what --t currently is */
.arch { cursor: pointer; }
.arch.arch-knock {
  animation: knock 0.5s ease-out;
}
@keyframes knock {
  0%   { filter: brightness(1) saturate(1); }
  30%  { filter: brightness(2.4) saturate(2.2); }
  100% { filter: brightness(1) saturate(1); }
}

.arch::after {
  content: 'STEP THROUGH';
  position: absolute;
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  opacity: calc(var(--t) * 1.2);
  color: var(--neon-c);
  text-shadow: 0 0 12px var(--neon-c);
}

.threshold-copy {
  position: fixed;
  top: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  text-align: center;
  max-width: 30ch;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  opacity: 0.8;
}

.threshold-copy .placard {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 0.4rem;
  display: block;
}

/* scroll cue */
.scroll-cue {
  position: fixed;
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.7;
  animation: bob 2s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, 6px); }
}

/* a mark that only exists at the exact midpoint of the scroll —
   opacity peaks at --t: 0.5 and falls away on either side */
.midpoint-mark {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 3rem;
  color: var(--neon-c);
  text-shadow: 0 0 20px var(--neon-c);
  opacity: clamp(0, calc(1 - 6 * abs(var(--t) - 0.5)), 1);
  pointer-events: none;
  z-index: 3;
}

/* floating specks that gain saturation with --t, drifting past the arch */
.speck {
  position: absolute;
  border-radius: 50%;
  width: 6px;
  height: 6px;
  background: color-mix(in oklch, #8a7a38 calc((1 - var(--t)) * 100%), var(--neon-a) calc(var(--t) * 100%));
  filter: blur(0.5px);
  opacity: 0.7;
}
