:root {
  color-scheme: dark;
  --black: #030305;
  --obsidian: #08080d;
  --paper: #eee9e1;
  --muted: #a7a2af;
  --gold: #d1ad60;
  --violet: #9c7cff;
  --violet-deep: #4d3582;
  --line: rgba(209, 173, 96, 0.24);
  --serif: "Cinzel", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--black); }
body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--black);
  color: var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, a { font: inherit; }
a { color: inherit; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 1rem;
  left: 1rem;
  transform: translateY(-180%);
  padding: .8rem 1rem;
  background: var(--paper);
  color: var(--black);
}
.skip-link:focus { transform: translateY(0); }

.reading-progress {
  position: fixed;
  z-index: 60;
  inset: 0 0 auto;
  height: 2px;
  background: rgba(255,255,255,.05);
}
.reading-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--violet-deep), var(--violet), var(--gold));
  box-shadow: 0 0 16px rgba(156,124,255,.7);
}

.reader-bar {
  position: fixed;
  z-index: 50;
  inset: 2px 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: .8rem clamp(1rem,3vw,2.4rem);
  background: linear-gradient(180deg,rgba(3,3,5,.78),transparent);
  pointer-events: none;
}
.reader-bar > * { pointer-events: auto; }
.reader-brand {
  justify-self: start;
  color: rgba(238,233,225,.88);
  font-family: var(--serif);
  font-size: .78rem;
  letter-spacing: .13em;
  text-decoration: none;
}
.reader-brand span { color: var(--gold); }
.reader-bar p {
  margin: 0;
  color: rgba(238,233,225,.5);
  font-size: .68rem;
  letter-spacing: .13em;
}
.sound-toggle {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  min-height: 2.5rem;
  padding: .55rem .85rem;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  background: rgba(8,8,13,.55);
  color: rgba(238,233,225,.78);
  cursor: pointer;
  backdrop-filter: blur(12px);
}
.sound-icon {
  position: relative;
  width: 14px;
  height: 14px;
  border: 1px solid currentColor;
  border-radius: 50%;
}
.sound-icon::after {
  content: "";
  position: absolute;
  inset: 6px -3px auto;
  height: 1px;
  background: currentColor;
  transform: rotate(-45deg);
}
.sound-toggle[aria-pressed="true"] { border-color: var(--line); color: var(--gold); }
.sound-toggle[aria-pressed="true"] .sound-icon::after { display: none; }

.threshold {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
}
.threshold-image,
.threshold-veil { position: absolute; inset: 0; }
.threshold-image {
  z-index: -3;
  background: url("assets/E00-C03.webp") center/cover no-repeat;
  filter: saturate(.62) contrast(1.12) brightness(.52);
  transform: scale(1.08);
  animation: threshold-breathe 12s ease-in-out infinite alternate;
}
.threshold-veil {
  z-index: -2;
  background:
    radial-gradient(circle at 50% 45%, transparent 0 14rem, rgba(3,3,5,.22) 36rem),
    linear-gradient(180deg,rgba(3,3,5,.46),rgba(3,3,5,.16) 45%,#030305 100%);
}
.threshold-content {
  width: min(860px,calc(100% - 2rem));
  padding: 7rem 0 6rem;
  text-align: center;
}
.kicker {
  margin: 0 0 1.2rem;
  color: var(--gold);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
}
h1,h2 { font-family: var(--serif); font-weight: 600; }
h1 {
  margin: 0;
  font-size: clamp(3.2rem,9vw,8rem);
  line-height: .9;
  letter-spacing: -.045em;
  text-shadow: 0 6px 40px rgba(0,0,0,.75);
}
.threshold-line {
  margin: 2rem auto 2.3rem;
  color: rgba(238,233,225,.78);
  font-family: var(--serif);
  font-size: clamp(1rem,2vw,1.3rem);
  line-height: 1.7;
}
.entry-actions,.ending-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: .8rem;
}
.enter-button,.silent-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.15rem;
  padding: .85rem 1.35rem;
  border-radius: 2px;
  cursor: pointer;
  text-decoration: none;
}
.enter-button {
  border: 1px solid var(--gold);
  background: var(--gold);
  color: #15100a;
  font-weight: 600;
}
.silent-button {
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(5,5,8,.5);
  color: var(--paper);
}
.entry-note {
  margin: 1.4rem 0 0;
  color: rgba(238,233,225,.48);
  font-size: .72rem;
  letter-spacing: .08em;
}
.scroll-cue {
  position: absolute;
  bottom: 1.4rem;
  left: 50%;
  width: 1px;
  height: 3.6rem;
  background: rgba(255,255,255,.16);
}
.scroll-cue span {
  display: block;
  width: 1px;
  height: 1.25rem;
  background: var(--gold);
  animation: scroll-cue 2.3s ease-in-out infinite;
}

.movement-card {
  position: relative;
  min-height: 92svh;
  display: grid;
  place-items: center;
  padding: 7rem 1.2rem;
  overflow: hidden;
  text-align: center;
  background:
    radial-gradient(circle at 50% 50%,rgba(72,48,119,.22),transparent 28rem),
    var(--black);
}
.movement-card::before {
  content: "";
  position: absolute;
  width: min(70vw,700px);
  height: 1px;
  background: linear-gradient(90deg,transparent,var(--violet),transparent);
  box-shadow: 0 0 32px rgba(156,124,255,.5);
  transform: rotate(-4deg) scaleX(.35);
  opacity: 0;
  transition: 1.2s ease;
}
.movement-card.is-active::before { opacity: 1; transform: rotate(-4deg) scaleX(1); }
.movement-label {
  margin: 0 0 1rem;
  color: var(--gold);
  font-size: .72rem;
  letter-spacing: .24em;
  text-transform: uppercase;
}
.movement-card h2 {
  position: relative;
  margin: 0;
  max-width: 18ch;
  font-size: clamp(2.5rem,7vw,6.5rem);
  line-height: 1;
  text-wrap: balance;
}
.movement-subtitle {
  position: relative;
  margin: 1.4rem 0 0;
  color: var(--muted);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.scene {
  --hold-height: 112svh;
  position: relative;
  min-height: var(--hold-height);
  background: var(--black);
}
.scene[data-hold="short"] { --hold-height: 92svh; }
.scene[data-hold="long"] { --hold-height: 132svh; }
.scene-stage {
  position: sticky;
  top: 0;
  height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
}
.scene-backdrop {
  position: absolute;
  z-index: -3;
  inset: -4rem;
  background-image: var(--scene-image);
  background-position: center;
  background-size: cover;
  filter: blur(36px) saturate(.72) brightness(.31);
  opacity: .8;
  transform: scale(1.14);
}
.scene-stage::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg,rgba(3,3,5,.58),transparent 18%,transparent 68%,rgba(3,3,5,.92)),
    linear-gradient(90deg,rgba(3,3,5,.22),transparent 24%,transparent 76%,rgba(3,3,5,.22));
}
.scene-image {
  position: absolute;
  z-index: -1;
  inset: clamp(3.7rem,7vh,5.5rem) clamp(.6rem,3vw,3rem) clamp(2rem,5vh,4rem);
  width: calc(100% - clamp(1.2rem,6vw,6rem));
  height: calc(100% - clamp(5.7rem,12vh,9.5rem));
  object-fit: contain;
  filter: saturate(.84) contrast(1.05) brightness(.76);
  opacity: .3;
  transform: scale(1.065) translate3d(0,2%,0);
  transition: opacity 1.1s ease, filter 1.5s ease;
  will-change: transform,opacity;
}
.scene.is-active .scene-image { opacity: 1; filter: saturate(.98) contrast(1.04) brightness(.94); }
.scene-copy {
  position: relative;
  z-index: 4;
  width: min(930px,calc(100% - 2rem));
  margin-top: auto;
  padding: 0 0 clamp(4.5rem,9vh,7rem);
  text-align: center;
  opacity: 0;
  transform: translateY(1.5rem);
  transition: opacity .85s ease .18s, transform .9s ease .18s;
}
.scene.is-active .scene-copy { opacity: 1; transform: translateY(0); }
.scene-copy p {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.35rem,3.2vw,3rem);
  line-height: 1.35;
  text-wrap: balance;
  text-shadow: 0 3px 24px #000,0 3px 50px #000;
}
.scene-id {
  position: absolute;
  z-index: 4;
  right: clamp(1rem,3vw,2.4rem);
  bottom: 1rem;
  color: rgba(238,233,225,.3);
  font-size: .62rem;
  letter-spacing: .14em;
}
.scene[data-effect="fracture"] .scene-stage::before,
.scene[data-effect="mark"] .scene-stage::before,
.scene[data-effect="thread"] .scene-stage::before {
  content: "";
  position: absolute;
  z-index: 3;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: linear-gradient(180deg,transparent,var(--violet),var(--gold),transparent);
  box-shadow: 0 0 28px var(--violet);
  opacity: 0;
  transform: rotate(7deg) scaleY(.2);
  transition: opacity .8s ease, transform 1.6s cubic-bezier(.2,.7,.2,1);
}
.scene[data-effect="fracture"].is-active .scene-stage::before,
.scene[data-effect="mark"].is-active .scene-stage::before,
.scene[data-effect="thread"].is-active .scene-stage::before { opacity: .65; transform: rotate(7deg) scaleY(1); }
.scene[data-effect="heartbeat"].is-active .scene-image { animation: heartbeat 2.8s ease-in-out infinite; }
.scene[data-effect="ghost"].is-active .scene-image { animation: ghost 5s ease-in-out infinite alternate; }
.scene[data-effect="sigil"].is-active .scene-image { filter: saturate(1.18) brightness(1); }

.ending {
  min-height: 100svh;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 7rem 1.2rem;
  text-align: center;
  background:
    radial-gradient(circle at 50% 42%,rgba(87,56,146,.25),transparent 26rem),
    var(--black);
}
.ending-sigil {
  margin-bottom: 1.4rem;
  color: var(--violet);
  font-size: clamp(4rem,10vw,8rem);
  text-shadow: 0 0 40px rgba(156,124,255,.6);
}
.ending h2 {
  margin: 0;
  font-size: clamp(2.5rem,7vw,6rem);
  line-height: 1;
}
.ending > p:not(.kicker) {
  margin: 1.5rem 0 2.2rem;
  color: var(--muted);
  font-family: var(--serif);
  font-size: clamp(1rem,2vw,1.3rem);
}
.noscript { padding: 2rem; text-align: center; }

@keyframes threshold-breathe { to { transform: scale(1.14); filter: saturate(.72) contrast(1.1) brightness(.61); } }
@keyframes scroll-cue { 0% { transform: translateY(0); opacity: 0; } 25% { opacity: 1; } 80% { opacity: 1; } 100% { transform: translateY(2.3rem); opacity: 0; } }
@keyframes heartbeat { 0%,100% { transform: scale(1.02); } 10% { transform: scale(1.055); } 20% { transform: scale(1.02); } 30% { transform: scale(1.045); } }
@keyframes ghost { from { opacity: .76; } to { opacity: 1; } }

@media (max-width: 680px) {
  .reader-bar { grid-template-columns: 1fr auto; }
  .reader-bar p { display: none; }
  .reader-brand { font-size: .68rem; }
  .sound-toggle { min-height: 2.35rem; padding: .48rem .7rem; font-size: .76rem; }
  .threshold-image { background-position: 58% center; }
  .threshold-line br { display: none; }
  .entry-actions { align-items: stretch; flex-direction: column; width: min(19rem,100%); margin-inline: auto; }
  .scene-copy p { font-size: clamp(1.25rem,7vw,2rem); }
  .scene-image { inset-inline: .45rem; width: calc(100% - .9rem); }
  .movement-subtitle { font-size: .76rem; line-height: 1.7; }
  .ending-actions { align-items: stretch; flex-direction: column; width: min(19rem,100%); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,*::before,*::after { animation: none !important; transition-duration: .01ms !important; }
  .scene-image { transform: none !important; }
}
