:root {
  --archive: #130e17;
  --archive-deep: #08070b;
  --limestone: #efe6d0;
  --copper: #c98c5a;
  --lichen: #91b47a;
  --rain-glass: #6fb9c8;
  --ember: #efb36a;
  --muted: #c8bea9;
  --panel: #211923;
  --focus: #ffe071;
  --display: Georgia, "Times New Roman", serif;
  --body: Verdana, Geneva, sans-serif;
  --utility: Menlo, "Courier New", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: 20px; scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 20% -10%, rgba(111, 185, 200, 0.16), transparent 34rem),
    radial-gradient(circle at 90% 20%, rgba(201, 140, 90, 0.1), transparent 28rem),
    var(--archive);
  color: var(--limestone);
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.6;
}

a { color: var(--limestone); }
button { font: inherit; }
button,
.dream-nav a {
  min-width: 48px;
  min-height: 48px;
}
button {
  border: 2px solid var(--copper);
  border-radius: 0.2rem;
  padding: 0.65rem 1rem;
  background: rgba(19, 14, 23, 0.94);
  color: var(--limestone);
  font-weight: 700;
  cursor: pointer;
}
button:hover { background: var(--limestone); color: var(--archive-deep); }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 5px; }

.skip-link {
  position: fixed;
  z-index: 100;
  left: 1rem;
  top: 1rem;
  transform: translateY(-180%);
  padding: 0.8rem 1rem;
  background: var(--focus);
  color: #111;
  font-weight: 700;
}
.skip-link:focus { transform: none; }

.dream-masthead,
.dream-nav,
.dream-main,
.dream-footer {
  width: min(92vw, 1280px);
  margin-inline: auto;
}
.dream-masthead { padding: clamp(2.5rem, 8vw, 6rem) 0 2rem; }
.room-kicker,
.instrument-label,
.threshold-index,
.exact-label {
  margin: 0 0 0.65rem;
  color: var(--ember);
  font: 700 0.9rem/1.35 var(--utility);
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.dream-masthead h1,
.dream-heading h1 {
  max-width: 14ch;
  margin: 0;
  font: italic 700 clamp(2.5rem, 8vw, 7rem)/0.92 var(--display);
  letter-spacing: -0.045em;
}
.dream-deck {
  max-width: 44rem;
  margin: 1.4rem 0 0;
  color: var(--muted);
  font-size: clamp(1.15rem, 2.4vw, 1.55rem);
}

.dream-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding: 1rem 0 1.5rem;
  border-block: 1px solid rgba(239, 230, 208, 0.28);
}
.dream-nav a {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 0.82rem;
  border: 1px solid rgba(239, 230, 208, 0.42);
  color: var(--limestone);
  text-decoration: none;
  font-weight: 700;
}
.dream-nav a[aria-current="page"] {
  background: var(--limestone);
  color: var(--archive-deep);
}

.dream-corridor {
  position: relative;
  display: grid;
  gap: clamp(4.5rem, 12vw, 10rem);
  padding: 6rem 0 10rem;
  isolation: isolate;
}
.dream-corridor::before {
  content: "";
  position: absolute;
  z-index: -2;
  top: 1rem;
  bottom: 1rem;
  left: 50%;
  width: 3px;
  background: linear-gradient(transparent, var(--copper) 7%, var(--lichen) 40%, var(--rain-glass) 73%, transparent);
  box-shadow: 0 0 30px rgba(201, 140, 90, 0.35);
  transform: rotate(1.8deg);
}
.threshold {
  --preview-a: var(--copper);
  --preview-b: var(--rain-glass);
  position: relative;
  width: min(82%, 62rem);
  min-height: 24rem;
  display: grid;
  grid-template-columns: minmax(15rem, 1.15fr) minmax(15rem, 0.85fr);
  gap: 2rem;
  align-items: center;
  padding: clamp(1.3rem, 3vw, 2.5rem);
  border: 1px solid rgba(239, 230, 208, 0.35);
  background:
    radial-gradient(circle at 20% 40%, color-mix(in srgb, var(--preview-a) 18%, transparent), transparent 55%),
    rgba(13, 10, 15, 0.9);
  color: var(--limestone);
  text-decoration: none;
  overflow: hidden;
}
.threshold:nth-child(even) {
  justify-self: end;
  grid-template-columns: minmax(15rem, 0.85fr) minmax(15rem, 1.15fr);
}
.threshold:nth-child(even) .threshold-preview { order: 2; }
.threshold:hover,
.threshold:focus-visible {
  border-color: var(--ember);
  background-color: #271b27;
}
.threshold h2 {
  margin: 0;
  font: italic 700 clamp(1.8rem, 4vw, 3.8rem)/1 var(--display);
  letter-spacing: -0.035em;
}
.threshold p {
  margin: 0.9rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}
.threshold-preview {
  min-height: 16rem;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.threshold-preview svg { width: 100%; min-height: 15rem; }
.preview-stroke { fill: none; stroke: var(--preview-b); stroke-width: 3; }
.preview-faint { fill: none; stroke: rgba(239, 230, 208, 0.35); stroke-width: 1.5; }
.preview-fill { fill: color-mix(in srgb, var(--preview-a) 24%, transparent); stroke: var(--limestone); stroke-width: 2; }
.preview-pulse { fill: var(--ember); transform-box: fill-box; transform-origin: center; }
.threshold[data-preview="grove"] { clip-path: polygon(8% 0, 92% 0, 100% 88%, 72% 100%, 24% 96%, 0 77%); }
.threshold[data-preview="choir"] { border-radius: 48% 7% 44% 11% / 20% 38% 14% 42%; --preview-a: #675776; }
.threshold[data-preview="citadel"] { clip-path: polygon(0 10%, 82% 0, 100% 31%, 94% 100%, 9% 94%); --preview-a: #6f8292; }
.threshold[data-preview="leviathan"] { border-radius: 70% 14% 68% 21% / 32% 53% 33% 52%; --preview-a: #326f6b; }
.threshold[data-preview="palace"] { clip-path: polygon(8% 0, 92% 0, 100% 100%, 0 100%); --preview-a: #8a735a; }
.threshold[data-preview="rain"] { border-radius: 50% 50% 9% 11% / 20% 20% 42% 43%; --preview-a: #477c91; }
.threshold[data-preview="mountain"] { clip-path: polygon(0 72%, 16% 47%, 29% 58%, 47% 12%, 64% 53%, 76% 40%, 100% 76%, 100% 100%, 0 100%); --preview-a: #655f50; }
.threshold[data-preview="library"] { clip-path: polygon(3% 0, 97% 4%, 91% 100%, 7% 94%); --preview-a: #956f48; }
.threshold[data-preview="migration"] { border-radius: 50% 50% 2% 2% / 80% 80% 4% 4%; --preview-a: #805b6b; }

.dream-main { padding: 2rem 0 6rem; }
.dream-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2rem;
  align-items: end;
  padding: 2rem 0;
}
.dream-heading h1 { font-size: clamp(2.4rem, 7vw, 6.4rem); }
.exact-block { text-align: right; }
.exact-label { display: block; color: var(--muted); }
.exact-time {
  display: block;
  margin-top: 0.3rem;
  color: var(--ember);
  font: 700 clamp(1.25rem, 3vw, 2rem) var(--utility);
  white-space: nowrap;
}
.exact-time-toggle { margin-top: 0.65rem; }
.exact-block.high-contrast {
  padding: 0.7rem 0.9rem;
  background: #fff;
  color: #000;
  outline: 4px solid #000;
}
.exact-block.high-contrast .exact-label,
.exact-block.high-contrast .exact-time { color: #000; }
.dream-instructions {
  max-width: 50rem;
  margin: 0 0 1.4rem;
  color: var(--muted);
  font-size: 1.1rem;
}
.dream-stage {
  position: relative;
  min-height: clamp(31rem, 70vh, 52rem);
  overflow: hidden;
  border: 1px solid rgba(239, 230, 208, 0.3);
  background: var(--archive-deep);
  isolation: isolate;
  touch-action: none;
}
.webgl-canvas,
.fallback-art,
.mechanism-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.webgl-canvas { z-index: 2; display: block; }
.fallback-art { z-index: 1; display: block; background: var(--archive-deep); }
.fallback-art svg { width: 100%; height: 100%; display: block; }
.fallback-active .webgl-canvas { visibility: hidden; }
.fallback-active .fallback-art { z-index: 3; }
.mechanism-overlay {
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease;
}
.mechanism-revealed .mechanism-overlay { opacity: 1; }
.mechanism-revealed .webgl-canvas { filter: saturate(0.55) contrast(1.08); }
.mechanism-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
  padding: 1rem 0;
}
.mechanism-panel {
  padding: 1.25rem 1.35rem;
  border-left: 5px solid var(--copper);
  background: var(--panel);
}
.mechanism-panel h2 { margin: 0 0 0.5rem; font: italic 700 1.45rem var(--display); }
.mechanism-panel p { margin: 0.4rem 0; color: var(--muted); }
.dream-explanation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  padding: 3rem 0;
}
.dream-explanation h2 { font: italic 700 1.55rem var(--display); }
.dream-explanation p { color: var(--muted); }
.dream-footer {
  padding: 2rem 0 4rem;
  border-top: 1px solid rgba(239, 230, 208, 0.28);
  color: var(--muted);
}

.fallback-sky { fill: #100d18; }
.fallback-dark { fill: #09090d; }
.fallback-stroke { fill: none; stroke: var(--rain-glass); stroke-width: 4; }
.fallback-faint { fill: none; stroke: rgba(239, 230, 208, 0.35); stroke-width: 2; }
.fallback-fill { fill: rgba(201, 140, 90, 0.22); stroke: var(--limestone); stroke-width: 2; }
.fallback-light { fill: var(--ember); }
.fallback-art [data-second-pulse] { opacity: calc(0.35 + var(--second-wave, 0.5) * 0.65); }
.fallback-art [data-minute-grow] { transform: scale(var(--minute-grow, 0.6)); transform-box: fill-box; transform-origin: center; }
.fallback-art [data-hour-turn] { transform: rotate(var(--hour-turn, 0deg)); transform-box: fill-box; transform-origin: center; }
.mechanism-overlay text { fill: var(--limestone); font: 700 20px var(--utility); }

@media (max-width: 760px) {
  html { font-size: 20px; }
  .dream-masthead { padding-top: 2.3rem; }
  .dream-masthead h1 { font-size: clamp(2.8rem, 14vw, 5rem); }
  .dream-nav { display: grid; grid-template-columns: 1fr 1fr; }
  .dream-nav a { justify-content: center; text-align: center; }
  .dream-corridor { gap: 4rem; padding-top: 4rem; }
  .dream-corridor::before { left: 1.1rem; }
  .threshold,
  .threshold:nth-child(even) {
    width: 100%;
    min-height: 30rem;
    grid-template-columns: 1fr;
    gap: 0.7rem;
    justify-self: stretch;
    border-radius: 0.5rem;
    clip-path: none;
  }
  .threshold:nth-child(even) .threshold-preview { order: 0; }
  .dream-heading { grid-template-columns: 1fr; }
  .exact-block { text-align: left; }
  .dream-stage { min-height: 34rem; }
  .dream-explanation { grid-template-columns: 1fr; gap: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
