/* ============================================================
   一窗两面 · base
   ============================================================ */

@property --fog {
  syntax: "<number>";
  inherits: true;
  initial-value: 0.85;
}
@property --open {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}
@property --hover-x {
  syntax: "<percentage>";
  inherits: true;
  initial-value: 50%;
}

:root {
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.4, 0.05, 0.15, 1);

  --yaqing: #1e293b;
  --yaqing-deep: #141e2b;
  --yeqing: #243044;
  --lvbi: #5b7f7a;
  --lvbi-deep: #3d5c63;
  --yuebai: #e2e8f0;
  --yuebai-soft: rgba(226, 232, 240, 0.68);
  --anjin: #c6a15b;
  --anjin-soft: rgba(198, 161, 91, 0.42);

  --xuanzhi: #f2e6d0;
  --xuanzhi-light: #f8efdd;
  --danjiang: #e8d0c4;
  --dailv: #4a6b4a;
  --zhusha: #b83b32;
  --yanzhi: #9e3b47;
  --ink: #23211f;
  --ink-soft: #4b4640;

  --axis-y: 50vh;
  --stone-y: 86vh;
  /* 12 扇窗的最小中心距由数据决定为 6vw。窗宽压到 5.8vw，
     使最窄一对在 1280 下仍留 +3.3px 净隙；高度严格保持 2:3。 */
  --win-w: 5.8vw;
  --win-h: 8.7vw;
  --foot-ratio: 0.9266667; /* figure foot line inside the 800x1200 mask */

  --hover-x: 50%;
  --fog: 0.85;
  --open: 0;
  --season-tint: #d8a7a0;
  --season-ink: #7d4b44;

  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--yaqing);
  background-color: var(--yaqing);
  color: var(--yuebai);
  font-family: "Noto Serif SC", "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

html {
  height: 100dvh;
}

body {
  height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 1px solid var(--anjin);
  outline-offset: 4px;
}

::selection {
  color: var(--yuebai);
  background: rgba(198, 161, 91, 0.45);
}

#app {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background: var(--yaqing);
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------
   Stage / intro switch
   ------------------------------------------------------------------ */

.stage {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  transform: scale(1.035);
  transition:
    opacity 800ms var(--ease),
    transform 800ms var(--ease);
  pointer-events: none;
}

#app[data-phase="main"] .stage,
#app[data-phase="hover"] .stage,
#app[data-phase="select"] .stage,
#app[data-phase="back"] .stage {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

#app[data-phase="select"] .stage {
  pointer-events: none;
}

.intro {
  position: absolute;
  inset: 0;
  z-index: 100;
  overflow: hidden;
  opacity: 1;
  visibility: visible;
  background-color: #101924;
  background-image:
    radial-gradient(120vw 80vh at 50% 58%, rgba(61, 92, 99, 0.26) 0%, rgba(30, 41, 59, 0) 62%),
    radial-gradient(70vw 60vh at 50% 30%, rgba(91, 127, 122, 0.10) 0%, rgba(30, 41, 59, 0) 70%),
    linear-gradient(180deg, #101924 0%, #1a2636 46%, #1e293b 78%, #141e2b 100%);
  transition:
    opacity 800ms var(--ease),
    visibility 0ms linear 800ms;
}

#app[data-phase="main"] .intro,
#app[data-phase="hover"] .intro,
#app[data-phase="select"] .intro,
#app[data-phase="back"] .intro {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--grain);
  opacity: 0.035;
  mix-blend-mode: screen;
  pointer-events: none;
}

.intro::after {
  display: none;
}

.intro__fog {
  position: absolute;
  left: -10%;
  right: -10%;
  pointer-events: none;
  filter: blur(20px);
  opacity: 0.55;
  background:
    radial-gradient(40vw 14vh at 20% 30%, rgba(226, 232, 240, 0.12), transparent 70%),
    radial-gradient(46vw 16vh at 70% 55%, rgba(91, 127, 122, 0.22), transparent 72%),
    radial-gradient(36vw 12vh at 48% 78%, rgba(226, 232, 240, 0.08), transparent 70%);
}

.intro__fog--a {
  top: 14vh;
  height: 40vh;
  animation: intro-fog-drift 26s ease-in-out infinite alternate;
}

.intro__fog--b {
  top: 44vh;
  height: 34vh;
  opacity: 0.35;
  animation: intro-fog-drift 34s ease-in-out infinite alternate-reverse;
}

@keyframes intro-fog-drift {
  from {
    transform: translate3d(-3vw, 0, 0) scale(1.04);
  }
  to {
    transform: translate3d(4vw, -1.2vh, 0) scale(1.1);
  }
}

.intro__arch {
  position: absolute;
  left: 50%;
  bottom: 4vh;
  width: min(60vw, 780px);
  height: min(70vh, 680px);
  transform: translateX(-50%);
  z-index: 3;
  filter: drop-shadow(0 3vh 4vh rgba(0, 0, 0, 0.45));
}

.intro__pillar {
  position: absolute;
  top: 7%;
  bottom: 0;
  width: 11.5%;
  background:
    repeating-linear-gradient(180deg, transparent 0 8.4vh, rgba(8, 13, 20, 0.28) 8.4vh 8.7vh),
    linear-gradient(90deg, #2d3847 0%, #4c5762 22%, #69737a 47%, #3c4653 72%, #222c3a 100%);
  box-shadow:
    inset 0 0 0 1px rgba(226, 232, 240, 0.08),
    inset 0 0 3vh rgba(0, 0, 0, 0.35);
  clip-path: polygon(8% 0, 100% 2.2%, 96% 100%, 0 100%);
}

.intro__pillar--left {
  left: 4%;
  clip-path: polygon(0 2.2%, 92% 0, 100% 100%, 4% 100%);
}

.intro__pillar--right {
  right: 4%;
}

.intro__pillar::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--grain);
  opacity: 0.09;
  mix-blend-mode: multiply;
}

.intro__lintel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 10%;
  background:
    repeating-linear-gradient(90deg, transparent 0 9vw, rgba(8, 13, 20, 0.2) 9vw 9.2vw),
    linear-gradient(180deg, #5a636b 0%, #3e4a56 42%, #2a3542 100%);
  box-shadow:
    inset 0 0 0 1px rgba(226, 232, 240, 0.1),
    inset 0 -1.2vh 2vh rgba(0, 0, 0, 0.3);
  clip-path: polygon(2.5% 0, 97.5% 0, 100% 100%, 0 100%);
}

.intro__eave {
  position: absolute;
  top: -3.2%;
  left: -4%;
  right: -4%;
  height: 6%;
  background: linear-gradient(180deg, #202a37 0%, #3a4653 68%, #222c39 100%);
  clip-path: polygon(2% 62%, 9% 18%, 91% 18%, 98% 62%, 100% 100%, 0 100%);
  opacity: 0.92;
}

.intro__plaque {
  position: absolute;
  top: 2.3%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 10.5vw;
  padding: 1.1vh 1.6vw 1.3vh;
  text-align: center;
  background:
    linear-gradient(180deg, #1c2530 0%, #25313f 55%, #1a232e 100%);
  border: 1px solid rgba(198, 161, 91, 0.55);
  box-shadow:
    inset 0 0 0 3px rgba(198, 161, 91, 0.08),
    0 0.8vh 2vh rgba(0, 0, 0, 0.35);
  color: var(--anjin);
}

.intro__plaque strong {
  display: block;
  font-size: clamp(18px, 2.3vh, 26px);
  font-weight: 700;
  letter-spacing: 0.38em;
  text-indent: 0.38em;
  text-shadow: 0 0 1.4vh rgba(198, 161, 91, 0.38);
}

.intro__plaque small {
  display: block;
  margin-top: 0.7vh;
  font-size: clamp(8px, 0.95vh, 11px);
  letter-spacing: 0.45em;
  text-indent: 0.45em;
  color: rgba(226, 232, 240, 0.58);
}

.intro__couplet {
  position: absolute;
  top: 17%;
  bottom: 12%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.8vh 0.9vw;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: clamp(12px, 1.55vh, 18px);
  letter-spacing: 0.3em;
  line-height: 1.9;
  color: rgba(226, 232, 240, 0.78);
  text-shadow: 0 0 1.8vh rgba(0, 0, 0, 0.45);
}

.intro__couplet--right {
  right: 6.2%;
}

.intro__couplet--left {
  left: 6.2%;
}

.intro__couplet::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(198, 161, 91, 0.28), transparent);
}

.intro__couplet--right::before {
  right: -0.2vw;
}

.intro__couplet--left::before {
  left: -0.2vw;
}

.intro__prologue {
  position: absolute;
  right: 18vw;
  top: 18vh;
  z-index: 4;
  writing-mode: vertical-rl;
  font-size: clamp(10px, 1.15vh, 13px);
  letter-spacing: 0.32em;
  line-height: 1.8;
  color: rgba(226, 232, 240, 0.5);
}

.intro__prologue::before {
  content: "";
  display: block;
  width: 1px;
  height: 3.6vh;
  margin: 0 auto 1.2vh;
  background: linear-gradient(180deg, transparent, rgba(198, 161, 91, 0.45));
}

.intro__knob {
  position: absolute;
  left: 50%;
  top: 52%;
  width: clamp(74px, 11.5vh, 120px);
  height: clamp(74px, 11.5vh, 120px);
  transform: translate(-50%, -50%);
  z-index: 5;
  border-radius: 50%;
  background: radial-gradient(circle at 46% 38%, #3c5f58 0%, #1d3533 42%, #0e1c1d 76%);
  border: 1px solid rgba(198, 161, 91, 0.62);
  box-shadow:
    0 0 0 0.5vh rgba(198, 161, 91, 0.05),
    0 0 4vh rgba(198, 161, 91, 0.14),
    inset 0 0 2.5vh rgba(0, 0, 0, 0.55);
  color: var(--anjin);
  transition:
    box-shadow 500ms var(--ease),
    transform 500ms var(--ease);
}

.intro__knob:hover,
.intro__knob:focus-visible {
  box-shadow:
    0 0 0 0.9vh rgba(198, 161, 91, 0.06),
    0 0 6vh rgba(198, 161, 91, 0.26),
    inset 0 0 2.5vh rgba(0, 0, 0, 0.45);
}

.intro__knob::before,
.intro__knob::after {
  content: "";
  position: absolute;
  inset: -0.9vh;
  border-radius: 50%;
  border: 1px solid rgba(198, 161, 91, 0.18);
  pointer-events: none;
}

.intro__knob::after {
  inset: -2.2vh;
  border-color: rgba(198, 161, 91, 0.08);
}

.knob__water {
  position: absolute;
  inset: 13%;
  border-radius: 50%;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(226, 232, 240, 0.2) 0%, rgba(226, 232, 240, 0.03) 32%, transparent 60%),
    radial-gradient(ellipse at 50% 55%, #294d48 0%, #173330 55%, #0a1718 100%);
}

.knob__water::after {
  content: "";
  position: absolute;
  left: 22%;
  top: 28%;
  width: 34%;
  height: 18%;
  border-radius: 50%;
  border: 1px solid rgba(226, 232, 240, 0.28);
  opacity: 0.55;
  animation: knob-ripple 4.8s ease-out infinite;
}

@keyframes knob-ripple {
  0% {
    transform: scale(0.55);
    opacity: 0.55;
  }
  75% {
    transform: scale(2.2);
    opacity: 0;
  }
  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}

.knob__label {
  position: relative;
  z-index: 2;
  font-size: clamp(11px, 1.35vh, 15px);
  letter-spacing: 0.36em;
  text-indent: 0.36em;
  text-shadow: 0 0 1.4vh rgba(198, 161, 91, 0.5);
}

.intro__hint {
  position: absolute;
  left: 50%;
  top: calc(52% + clamp(62px, 9.5vh, 100px));
  transform: translateX(-50%);
  z-index: 5;
  font-size: clamp(9px, 1.05vh, 11px);
  letter-spacing: 0.32em;
  color: rgba(226, 232, 240, 0.4);
  white-space: nowrap;
}

.intro__footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1.6vh;
  z-index: 4;
  text-align: center;
  font-size: clamp(8px, 0.9vh, 10px);
  letter-spacing: 0.42em;
  color: rgba(226, 232, 240, 0.24);
}

/* ------------------------------------------------------------------
   Shared controls
   ------------------------------------------------------------------ */

.controls {
  position: absolute;
  top: 2.6vh;
  right: 2.6vw;
  z-index: 32;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1.35vh;
}

.ctl {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.55vw;
  padding: 0.35vh 0;
  color: rgba(226, 232, 240, 0.6);
  font-size: clamp(9px, 1.05vh, 12px);
  letter-spacing: 0.18em;
  transition: color 280ms ease;
  white-space: nowrap;
}

.ctl::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(198, 161, 91, 0.45), transparent);
  opacity: 0;
  transition: opacity 280ms ease;
}

.ctl:hover,
.ctl:focus-visible,
.ctl[aria-pressed="true"] {
  color: var(--anjin);
}

.ctl:hover::after,
.ctl:focus-visible::after,
.ctl[aria-pressed="true"]::after {
  opacity: 1;
}

.ctl__dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0.7vh currentColor;
  opacity: 0.65;
}

.ctl__key {
  font-size: 0.8em;
  opacity: 0.45;
  letter-spacing: 0.05em;
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 8.2vh;
  z-index: 34;
  transform: translate(-50%, 1vh);
  padding: 0.7vh 1.2vw;
  color: rgba(35, 33, 31, 0.62);
  font-size: clamp(10px, 1.2vh, 13px);
  letter-spacing: 0.28em;
  white-space: nowrap;
  opacity: 0;
  transition:
    opacity 600ms var(--ease),
    transform 600ms var(--ease);
  pointer-events: none;
}

.hint.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast {
  position: absolute;
  left: 50%;
  top: 7.5vh;
  z-index: 60;
  transform: translate(-50%, -1vh);
  max-width: min(72vw, 520px);
  padding: 0.8vh 1.4vw;
  border: 1px solid rgba(198, 161, 91, 0.22);
  background: rgba(20, 30, 43, 0.72);
  color: rgba(226, 232, 240, 0.82);
  font-size: clamp(10px, 1.2vh, 13px);
  letter-spacing: 0.16em;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 320ms ease,
    transform 320ms var(--ease),
    visibility 0ms linear 320ms;
  backdrop-filter: blur(4px);
}

.toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition:
    opacity 320ms ease,
    transform 320ms var(--ease),
    visibility 0ms;
}

/* ------------------------------------------------------------------
   Season gauge
   ------------------------------------------------------------------ */

.gauge {
  position: absolute;
  left: 50%;
  bottom: 2.1vh;
  z-index: 33;
  width: min(46vw, 680px);
  transform: translateX(-50%);
  color: var(--ink-soft);
  user-select: none;
}

.gauge__readout {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1.1vw;
  margin-bottom: 1.15vh;
  white-space: nowrap;
}

.gauge__label {
  font-size: clamp(10px, 1.2vh, 13px);
  letter-spacing: 0.24em;
  color: rgba(35, 33, 31, 0.75);
}

.gauge__chapter {
  font-size: clamp(8px, 0.95vh, 10px);
  letter-spacing: 0.14em;
  color: rgba(35, 33, 31, 0.42);
}

.gauge__track {
  position: relative;
  height: 2.6vh;
  border-top: 1px solid rgba(35, 33, 31, 0.22);
}

.gauge__track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(198, 161, 91, 0.5) 8%, rgba(35, 33, 31, 0.26) 50%, rgba(198, 161, 91, 0.5) 92%, transparent);
}

.gauge__bead {
  position: absolute;
  top: -0.55vh;
  left: var(--bead-x, 0%);
  width: 1.1vh;
  height: 1.1vh;
  margin-left: -0.55vh;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #f6e3b2 0%, #c6a15b 42%, #7a5a28 100%);
  box-shadow:
    0 0 0 0.45vh rgba(198, 161, 91, 0.08),
    0 0 1.6vh rgba(198, 161, 91, 0.35);
  transition: left 800ms var(--ease);
}

.gauge__marks {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
}

.gauge__mark {
  position: relative;
  width: 18%;
  padding-top: 1.1vh;
  color: rgba(35, 33, 31, 0.42);
  font-size: clamp(8px, 0.95vh, 10px);
  letter-spacing: 0.18em;
  text-align: center;
  transition: color 320ms ease;
}

.gauge__mark::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: 0.7vh;
  background: currentColor;
  opacity: 0.55;
}

.gauge__mark:hover,
.gauge__mark[aria-pressed="true"] {
  color: var(--season-ink);
}

.gauge__mark[aria-pressed="true"]::before {
  height: 1.2vh;
  opacity: 1;
  background: var(--season-ink);
}

.gauge__mark small {
  display: block;
  margin-top: 0.25vh;
  font-size: 0.82em;
  letter-spacing: 0.06em;
  opacity: 0.55;
}

/* ------------------------------------------------------------------
   Accessibility
   ------------------------------------------------------------------ */

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


.audit-layout .stage {
  opacity: 1;
  transform: none;
}

.audit-layout *,
.audit-layout *::before,
.audit-layout *::after {
  animation: none !important;
  transition: none !important;
}


/* PDF snapshots must keep the painted backgrounds */
html,
body,
#app,
#app *,
#app *::before,
#app *::after {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* Intro sound: the same gate as the top-right 听梦, available before 入梦. */
.intro__sound {
  position: absolute;
  right: 2.4vw;
  top: 2.2vh;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 0.55vw;
  padding: 0.55vh 0.8vw;
  border: 1px solid rgba(198, 161, 91, 0.18);
  background: rgba(20, 30, 43, 0.24);
  color: rgba(226, 232, 240, 0.54);
  font-size: clamp(9px, 1vh, 11px);
  letter-spacing: 0.16em;
  transition:
    color 240ms ease,
    border-color 240ms ease,
    background 240ms ease;
}

.intro__sound small {
  color: rgba(226, 232, 240, 0.3);
  font-size: 0.86em;
  letter-spacing: 0.06em;
}

.intro__sound-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 1vh currentColor;
  opacity: 0.7;
}

.intro__sound:hover,
.intro__sound:focus-visible,
.intro__sound[aria-pressed="true"] {
  color: #f3d693;
  border-color: rgba(198, 161, 91, 0.48);
  background: rgba(20, 30, 43, 0.4);
}

.intro__sound[aria-pressed="true"] .intro__sound-dot {
  opacity: 1;
}

@media (max-width: 767px) {
  .intro__sound {
    right: 3vw;
    top: 1.8vh;
    gap: 1.4vw;
  }
}
