*,
*::before,
*::after { box-sizing: border-box; }

:root {
  --void: #0a0c10;
  --void-mid: #10141a;
  --accent: #e6d3b0;
  --accent-soft: rgba(230, 211, 176, 0.55);
  --accent-glow: rgba(230, 211, 176, 0.22);
  --line: rgba(230, 211, 176, 0.28);
}

html, body {
  margin: 0;
  min-height: 100%;
  height: 100%;
}

/* 全链路共用画布：颜色不断档 */
body.transit,
body.final,
body.gate {
  overflow: hidden;
  color: #f2ebe0;
  background:
    radial-gradient(ellipse 90% 55% at 50% 110%, var(--accent-glow), transparent 58%),
    radial-gradient(ellipse 60% 40% at 50% -10%, rgba(90, 110, 140, 0.12), transparent 50%),
    linear-gradient(180deg, var(--void-mid) 0%, var(--void) 100%);
  font-family: "Iowan Old Style", "Palatino Linotype", "Songti SC", serif;
}

/* 共用细网格 + 底部地平线，每页都在 */
body.transit::before,
body.final::before,
body.gate::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.012) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 75% 65% at 50% 45%, #000 15%, transparent 72%);
  opacity: 0.85;
}

.horizon {
  position: fixed;
  left: 50%;
  bottom: max(10vh, 40px);
  width: min(240px, 56vw);
  height: 1px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, var(--line), transparent);
  z-index: 2;
  pointer-events: none;
}

/* 进度：底部短线逐渐变长，建立“在前进”的感觉 */
.progress {
  position: fixed;
  left: 50%;
  bottom: max(calc(10vh - 14px), 26px);
  height: 2px;
  transform: translateX(-50%);
  background: var(--accent-soft);
  border-radius: 999px;
  z-index: 2;
  box-shadow: 0 0 12px var(--accent-glow);
}

body.theme-entry .progress { width: 18%; }
body.theme-s2 .progress    { width: 42%; }
body.theme-s3 .progress    { width: 68%; }
body.theme-s4 .progress    { width: 86%; }
body.final .progress       { width: 100%; max-width: min(240px, 56vw); opacity: 0.85; }

.stage {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100%;
  display: grid;
  place-items: center;
  opacity: 0;
  animation: arrive 0.28s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.stage.is-leaving {
  animation: depart 0.15s ease forwards;
}

@keyframes arrive {
  from { opacity: 0; filter: blur(3px); }
  to   { opacity: 1; filter: blur(0); }
}

@keyframes depart {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* —— 母题：光点 / 光核，各页形态是同一元素的演化 —— */
.motif {
  position: relative;
  width: min(200px, 48vw);
  height: min(200px, 48vw);
  display: grid;
  place-items: center;
}

.core {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #fff8ea, var(--accent) 42%, transparent 72%);
  box-shadow:
    0 0 28px var(--accent-glow),
    0 0 60px rgba(230, 211, 176, 0.12);
  z-index: 3;
}

.halo {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--line);
  z-index: 1;
}

.ray {
  position: absolute;
  background: linear-gradient(180deg, transparent, var(--accent-soft), transparent);
  z-index: 2;
}

/* ENTRY：光点凝聚（从门页光柱收束而来） */
body.theme-entry .core {
  width: 18%;
  height: 18%;
  animation: core-breathe 2s ease-in-out infinite alternate;
}

body.theme-entry .halo {
  inset: 22%;
  animation: halo-in 1.1s ease both, halo-pulse 2.6s ease-in-out 1.1s infinite;
}

body.theme-entry .halo.outer {
  inset: 0;
  opacity: 0.45;
  animation-delay: 0.15s, 1.25s;
}

body.theme-entry .ray {
  width: 2px;
  height: 42%;
  top: 0;
  left: 50%;
  margin-left: -1px;
  opacity: 0.55;
  animation: ray-settle 1s ease both;
}

@keyframes core-breathe {
  from { transform: scale(0.92); }
  to   { transform: scale(1.08); }
}

@keyframes halo-in {
  from { transform: scale(1.2); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

@keyframes halo-pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.03); opacity: 1; }
}

@keyframes ray-settle {
  from { height: 70%; opacity: 0.9; }
  to   { height: 42%; opacity: 0.55; }
}

/* S2：光点拉成路径（横向延展 = 行进） */
body.theme-s2 .core {
  width: 12%;
  height: 12%;
  animation: core-travel 1.8s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
}

body.theme-s2 .path {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 1px;
  margin-top: -0.5px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
  z-index: 1;
}

body.theme-s2 .halo {
  width: 22%;
  height: 22%;
  border-radius: 50%;
  opacity: 0.5;
}

body.theme-s2 .ray {
  display: none;
}

@keyframes core-travel {
  from { transform: translateX(-55px); }
  to   { transform: translateX(55px); }
}

/* S3：路径张开为门（菱形开口，仍是同一金色） */
body.theme-s3 .core {
  width: 10%;
  height: 10%;
  animation: core-breathe 1.8s ease-in-out infinite alternate;
}

body.theme-s3 .gate-shape {
  position: absolute;
  inset: 18%;
  border: 1px solid var(--line);
  transform: rotate(45deg);
  box-shadow: 0 0 40px rgba(230, 211, 176, 0.08);
  animation: aperture 2.4s ease-in-out infinite;
  z-index: 1;
}

body.theme-s3 .gate-shape.inner {
  inset: 30%;
  opacity: 0.55;
  animation-delay: 0.2s;
}

body.theme-s3 .path {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1px;
  height: 28%;
  margin-left: -0.5px;
  margin-top: -14%;
  background: linear-gradient(180deg, transparent, var(--accent-soft), transparent);
  z-index: 2;
}

@keyframes aperture {
  0%, 100% { transform: rotate(45deg) scale(0.96); opacity: 0.75; }
  50% { transform: rotate(45deg) scale(1.05); opacity: 1; }
}

/* S4：门已开，需亲手推动光核穿过门槛 */
body.theme-s4 {
  overflow: hidden;
}

body.theme-s4 .stage {
  opacity: 1;
  animation: arrive 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
  padding: 0 24px 88px;
}

body.theme-s4 .challenge {
  width: min(340px, 100%);
  text-align: center;
}

body.theme-s4 .challenge .eyebrow {
  margin-bottom: 10px;
}

body.theme-s4 .challenge h1 {
  margin: 0 0 10px;
  font-size: clamp(22px, 4.5vw, 28px);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #f2ebe0;
}

body.theme-s4 .challenge .lead {
  margin: 0 0 28px;
  font-size: 14px;
}

body.theme-s4 .motif-mini {
  position: relative;
  width: 56px;
  height: 56px;
  margin: 0 auto 22px;
  display: grid;
  place-items: center;
}

body.theme-s4 .motif-mini .gate-shape {
  position: absolute;
  inset: 8%;
  border: 1px solid var(--line);
  transform: rotate(45deg);
  box-shadow: 0 0 24px rgba(230, 211, 176, 0.08);
  animation: aperture 2.4s ease-in-out infinite;
}

body.theme-s4 .motif-mini .gate-shape.inner {
  inset: 24%;
  opacity: 0.5;
  animation-delay: 0.2s;
}

body.theme-s4 .motif-mini .core {
  width: 22%;
  height: 22%;
  animation: core-breathe 1.8s ease-in-out infinite alternate;
}

body.theme-s4 .slider {
  position: relative;
  height: 52px;
  border-radius: 2px;
  border: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(230, 211, 176, 0.04), transparent 40%),
    rgba(16, 20, 26, 0.75);
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

body.theme-s4 .slider-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: linear-gradient(90deg, transparent, rgba(230, 211, 176, 0.14));
  pointer-events: none;
}

body.theme-s4 .slider-rail {
  position: absolute;
  left: 18%;
  right: 18%;
  top: 50%;
  height: 1px;
  margin-top: -0.5px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
  pointer-events: none;
  opacity: 0.7;
}

body.theme-s4 .slider-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 40px;
  color: rgba(242, 235, 224, 0.38);
  font-size: 13px;
  letter-spacing: 0.12em;
  font-family: "Segoe UI", "PingFang SC", sans-serif;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

body.theme-s4 .slider.is-dragging .slider-hint,
body.theme-s4 .slider.is-done .slider-hint {
  opacity: 0;
}

body.theme-s4 .slider-thumb {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 48px;
  height: 48px;
  border-radius: 2px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 38% 32%, #fff8ea, var(--accent) 46%, rgba(230, 211, 176, 0.35) 72%),
    rgba(230, 211, 176, 0.12);
  box-shadow: 0 0 18px var(--accent-glow);
  display: grid;
  place-items: center;
  cursor: grab;
  z-index: 2;
  will-change: transform;
}

body.theme-s4 .slider-thumb:active {
  cursor: grabbing;
}

body.theme-s4 .slider-thumb svg {
  width: 18px;
  height: 18px;
  fill: var(--void);
  opacity: 0.7;
}

body.theme-s4 .slider.is-done .slider-thumb {
  background:
    radial-gradient(circle at 38% 32%, #fff, #e8f5e0 42%, rgba(120, 190, 130, 0.4) 72%),
    rgba(120, 190, 130, 0.16);
  border-color: rgba(160, 210, 160, 0.45);
  box-shadow: 0 0 22px rgba(140, 200, 150, 0.28);
}

body.theme-s4 .slider.is-done .slider-thumb svg {
  fill: #1a2a1c;
  opacity: 0.85;
}

body.theme-s4 .status {
  margin-top: 18px;
  min-height: 1.4em;
  color: rgba(242, 235, 224, 0.42);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-family: "Segoe UI", "PingFang SC", sans-serif;
  transition: color 0.25s ease;
}

body.theme-s4 .status.is-ok {
  color: rgba(180, 210, 170, 0.85);
}

body.theme-s4 .stage.is-leaving {
  animation: depart 0.18s ease forwards;
}

/* FINAL：门打开，内容落在同一画布上 */
body.final {
  display: grid;
  place-items: center;
  overflow: auto;
}

body.final main {
  position: relative;
  z-index: 1;
  width: min(520px, calc(100% - 48px));
  padding: 36px 8px 80px;
  animation: arrive 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-soft);
  font-size: 11px;
  letter-spacing: 0.22em;
  font-weight: 600;
  font-family: "Segoe UI", "PingFang SC", sans-serif;
  text-transform: uppercase;
}

body.final h1 {
  margin: 0 0 12px;
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.lead {
  margin: 0 0 22px;
  color: rgba(242, 235, 224, 0.72);
  line-height: 1.75;
  font-size: 15px;
  font-family: "Segoe UI", "PingFang SC", sans-serif;
}

.meta {
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
  color: rgba(242, 235, 224, 0.45);
  font-size: 13px;
  line-height: 1.9;
  font-family: "Segoe UI", "PingFang SC", sans-serif;
}

.btn {
  display: inline-block;
  padding: 12px 22px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.08em;
  font-family: "Segoe UI", "PingFang SC", sans-serif;
}

.btn:hover {
  background: rgba(230, 211, 176, 0.08);
}

@media (prefers-reduced-motion: reduce) {
  .stage, body.final main,
  .core, .halo, .ray, .gate-shape {
    animation: none !important;
  }
  .stage { opacity: 1; }
}


body.theme-gate .progress.gate { width: 8%; }
body.theme-gate .ray {
  width: 2px; height: 58%; top: 4%; left: 50%; margin-left: -1px; opacity: 0.7;
  animation: ray-settle 1s ease both;
}
body.theme-gate .core.gate-core {
  width: 10px; height: 10px; position: absolute; left: 50%; bottom: 22%; margin-left: -5px;
  animation: core-breathe 1.6s ease-in-out infinite alternate;
}
