/* ─────────────────────────────────────────────────────────────
   暮色林中小屋 — a cabin at dusk
   palette   ink / pine / fog / amber / ember / seal
   type      Noto Serif SC · display + prose
             Noto Sans SC  · interface
   ───────────────────────────────────────────────────────────── */

:root {
  --ink: #071011;
  --pine: #10211f;
  --fog: #9eada4;
  --amber: #e8b471;
  --amber-hot: #ffcf8e;
  --ember: #b96039;
  --seal: #a03b2b;
  --paper: #e9ede3;
  --bar: clamp(16px, 4.2vh, 44px);
  --edge: clamp(20px, 3.2vw, 54px);
  --serif: "Noto Serif SC", "STSong", "Songti SC", "SimSun", serif;
  --sans: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
  --ease-cine: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  background: #050a0a;
  color: var(--paper);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--sans);
  font-weight: 300;
  letter-spacing: 0.04em;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

button:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 6px;
}

#stage,
#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#stage {
  background:
    radial-gradient(120% 80% at 64% 52%, #1a2826 0%, #0b1515 44%, #050a0a 100%);
}

#scene {
  touch-action: none;
  cursor: none;
}

body.ui-idle #scene { cursor: none; }

/* film finish ------------------------------------------------ */

.vignette {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  background:
    radial-gradient(115% 90% at 50% 47%, transparent 42%, rgba(1, 5, 5, 0.28) 76%, rgba(1, 4, 4, 0.72) 100%),
    linear-gradient(90deg, rgba(1, 5, 5, 0.24), transparent 18%, transparent 82%, rgba(1, 5, 5, 0.2));
}

.grain {
  position: fixed;
  inset: -12%;
  z-index: 9;
  pointer-events: none;
  opacity: 0.075;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.86' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 0.7s steps(2) infinite;
}

@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-1.5%, 1%); }
  50% { transform: translate(1%, -1.5%); }
  75% { transform: translate(-0.5%, -0.5%); }
  100% { transform: translate(0.5%, 1%); }
}

.bar {
  position: fixed;
  left: 0;
  right: 0;
  height: var(--bar);
  z-index: 30;
  pointer-events: none;
  background: #030706;
}

.bar-top { top: 0; }
.bar-bottom { bottom: 0; }

/* cursor ----------------------------------------------------- */

.cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 1px solid rgba(232, 180, 113, 0.48);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(-50px, -50px, 0);
  transition: width 0.35s var(--ease-cine), height 0.35s var(--ease-cine),
              margin 0.35s var(--ease-cine), border-color 0.35s ease,
              background-color 0.35s ease, opacity 0.3s ease;
  mix-blend-mode: screen;
}

.cursor span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 3px;
  margin: -1.5px 0 0 -1.5px;
  border-radius: 50%;
  background: var(--amber-hot);
  box-shadow: 0 0 8px rgba(255, 207, 142, 0.9);
}

.cursor.is-active {
  width: 42px;
  height: 42px;
  margin: -21px 0 0 -21px;
  border-color: rgba(255, 207, 142, 0.75);
  background: rgba(232, 180, 113, 0.06);
}

body.cursor-on .cursor { opacity: 1; }
body.cursor-on #scene,
body.cursor-on .hud button,
body.cursor-on .intro button { cursor: none; }
body.is-interior.is-portrait #scene { cursor: grab; }
body.is-dragging #scene { cursor: grabbing; }

/* hud -------------------------------------------------------- */

.hud {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s var(--ease-cine);
}

body.is-entered .hud {
  opacity: 1;
}

.topline {
  position: absolute;
  top: calc(var(--bar) + clamp(16px, 2.4vh, 28px));
  left: var(--edge);
  right: var(--edge);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.wordmark {
  display: flex;
  align-items: baseline;
  gap: 14px;
  text-shadow: 0 1px 18px rgba(1, 6, 5, 0.85);
}

.wordmark-cn {
  font-family: var(--serif);
  font-size: clamp(13px, 1.15vw, 16px);
  font-weight: 500;
  letter-spacing: 0.34em;
  color: rgba(238, 241, 232, 0.9);
}

.wordmark-en {
  font-family: var(--serif);
  font-style: italic;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: rgba(158, 173, 164, 0.62);
}

.readout {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: rgba(213, 222, 214, 0.68);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 14px rgba(1, 6, 5, 0.9);
  white-space: nowrap;
}

.readout .tick {
  width: 1px;
  height: 9px;
  background: rgba(158, 173, 164, 0.32);
}

#clock {
  color: rgba(232, 180, 113, 0.82);
  letter-spacing: 0.14em;
}

#sceneName { color: rgba(238, 241, 232, 0.82); }

/* whisper ---------------------------------------------------- */

.whisper {
  position: absolute;
  left: 50%;
  bottom: calc(var(--bar) + clamp(104px, 13.5vh, 150px));
  transform: translateX(-50%);
  width: min(560px, 64vw);
  text-align: center;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(13px, 1.05vw, 16px);
  line-height: 1.9;
  letter-spacing: 0.14em;
  color: rgba(235, 238, 228, 0.78);
  text-shadow: 0 2px 22px rgba(1, 6, 5, 0.95), 0 0 3px rgba(1, 6, 5, 0.6);
  pointer-events: none;
  opacity: 0.95;
  transition: opacity 0.45s ease, transform 0.65s var(--ease-cine);
}

.whisper.is-changing {
  opacity: 0;
  transform: translateX(-50%) translateY(5px);
}

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

.controls {
  position: absolute;
  left: var(--edge);
  right: var(--edge);
  bottom: calc(var(--bar) + clamp(16px, 2.4vh, 26px));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(24px, 5vw, 90px);
  pointer-events: auto;
}

.time-rail {
  width: clamp(270px, 30vw, 430px);
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.rail-kicker {
  flex: none;
  padding-top: 1px;
  font-family: var(--serif);
  font-size: 10px;
  letter-spacing: 0.34em;
  color: rgba(158, 173, 164, 0.58);
  writing-mode: vertical-rl;
  line-height: 1;
}

.rail-track { position: relative; flex: 1; padding-top: 9px; }

.rail-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: rgba(158, 173, 164, 0.22);
}

.rail-line i {
  position: absolute;
  top: -2px;
  left: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--amber-hot);
  box-shadow: 0 0 10px rgba(255, 196, 118, 0.85);
  transform: translateX(-2px);
  transition: left 1.25s var(--ease-cine);
}

.rail-stops { display: flex; justify-content: space-between; }

.time-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  text-align: left;
  color: rgba(195, 205, 197, 0.46);
  transition: color 0.4s ease;
}

.time-btn span {
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.2em;
  transition: color 0.4s ease, letter-spacing 0.5s var(--ease-cine);
}

.time-btn small {
  font-family: var(--serif);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  color: rgba(158, 173, 164, 0.3);
  transition: color 0.4s ease;
}

.time-btn:hover { color: rgba(235, 238, 228, 0.8); }
.time-btn.is-on { color: var(--amber); }
.time-btn.is-on span { letter-spacing: 0.28em; }
.time-btn.is-on small { color: rgba(232, 180, 113, 0.56); }

.actions {
  display: flex;
  align-items: center;
  gap: clamp(18px, 2.6vw, 34px);
}

.quiet-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  color: rgba(197, 207, 199, 0.52);
  font-size: 11px;
  letter-spacing: 0.16em;
  transition: color 0.35s ease;
}

.quiet-btn:hover { color: rgba(238, 241, 232, 0.92); }

.btn-glyph {
  display: inline-flex;
  transform: rotate(0.001deg);
  transition: transform 0.9s var(--ease-cine);
}

#weatherToggle[aria-pressed="true"] .btn-glyph { transform: rotate(90deg); }
#weatherToggle[aria-pressed="true"] { color: rgba(232, 180, 113, 0.86); }

.sound-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 11px;
}

.sound-bars i {
  display: block;
  width: 1px;
  height: 4px;
  background: currentColor;
  transition: height 0.4s ease;
}

.sound-bars i:nth-child(2) { height: 8px; }
.sound-bars i:nth-child(3) { height: 5px; }
.sound-bars i:nth-child(4) { height: 10px; }

#soundToggle[aria-pressed="true"] { color: rgba(232, 180, 113, 0.86); }
#soundToggle[aria-pressed="true"] .sound-bars i { animation: eq 1.4s ease-in-out infinite; }
#soundToggle[aria-pressed="true"] .sound-bars i:nth-child(2) { animation-delay: -0.25s; }
#soundToggle[aria-pressed="true"] .sound-bars i:nth-child(3) { animation-delay: -0.6s; }
#soundToggle[aria-pressed="true"] .sound-bars i:nth-child(4) { animation-delay: -0.9s; }

@keyframes eq {
  0%, 100% { transform: scaleY(0.45); }
  50% { transform: scaleY(1); }
}

.door-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 8px 0 8px 2px;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.32em;
  color: rgba(238, 241, 232, 0.92);
  transition: color 0.35s ease;
}

.door-line {
  width: 28px;
  height: 1px;
  background: linear-gradient(90deg, rgba(232, 180, 113, 0.1), var(--amber));
  transform-origin: right center;
  transition: width 0.55s var(--ease-cine), background 0.4s ease;
}

.door-btn::after {
  content: "";
  position: absolute;
  left: 41px;
  right: 0;
  bottom: 3px;
  height: 1px;
  background: rgba(232, 180, 113, 0.42);
  transform: scaleX(0.25);
  transform-origin: left center;
  transition: transform 0.65s var(--ease-cine);
}

.door-btn:hover { color: var(--amber-hot); }
.door-btn:hover .door-line { width: 42px; }
.door-btn:hover::after { transform: scaleX(1); }

/* intro ------------------------------------------------------ */

.intro {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(var(--bar) + 5vh) var(--edge) calc(var(--bar) + 8vh);
  opacity: 1;
  visibility: visible;
  transition: opacity 1.15s var(--ease-cine), visibility 0s linear 1.15s;
}

.scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(3, 9, 8, 0.82) 0%, rgba(3, 9, 8, 0.5) 26%, rgba(3, 9, 8, 0.08) 54%, transparent 74%),
    linear-gradient(0deg, rgba(3, 8, 8, 0.64) 0%, transparent 34%),
    linear-gradient(180deg, rgba(3, 8, 8, 0.52), transparent 26%);
}

.intro-main {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: clamp(38px, 5.2vw, 82px);
  padding-left: clamp(0px, 1vw, 18px);
  max-width: 1100px;
}

.title-lockup {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex: none;
}

.vertical-title {
  margin: 0;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.08em;
  writing-mode: vertical-rl;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(42px, 4.7vw, 72px);
  line-height: 1.01;
  letter-spacing: 0.14em;
  color: #eef1e7;
  text-shadow: 0 0 42px rgba(0, 8, 7, 0.55), 0 2px 18px rgba(0, 6, 5, 0.7);
}

.vertical-title span { display: block; }

.vertical-title span:last-child {
  color: rgba(238, 241, 231, 0.8);
  font-size: 0.78em;
  letter-spacing: 0.28em;
}

.seal {
  width: clamp(28px, 2.6vw, 38px);
  height: clamp(28px, 2.6vw, 38px);
  display: grid;
  place-items: center;
  margin-bottom: 4px;
  background: var(--seal);
  color: #f1d9c8;
  font-family: "STKaiti", "KaiTi", var(--serif);
  font-size: clamp(16px, 1.55vw, 21px);
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 225, 201, 0.22), 0 6px 24px rgba(0, 0, 0, 0.28);
  transform: rotate(-2deg);
  opacity: 0.92;
}

.intro-copy {
  position: relative;
  padding-bottom: 7px;
  max-width: 400px;
}

.tagline {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-size: clamp(15px, 1.25vw, 19px);
  font-weight: 300;
  line-height: 1.95;
  letter-spacing: 0.1em;
  color: rgba(237, 240, 230, 0.9);
  text-shadow: 0 2px 22px rgba(0, 6, 5, 0.85);
}

.meta {
  margin: 0 0 34px;
  font-size: 10px;
  font-weight: 300;
  line-height: 1.8;
  letter-spacing: 0.15em;
  color: rgba(184, 197, 187, 0.72);
  text-shadow: 0 1px 12px rgba(0, 5, 4, 0.9), 0 0 26px rgba(0, 5, 4, 0.6);
}

.entry { display: flex; flex-direction: column; align-items: flex-start; gap: 13px; }

.enter-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-width: 186px;
  padding: 13px 42px 13px 0;
  border-top: 1px solid rgba(232, 180, 113, 0.28);
  border-bottom: 1px solid rgba(232, 180, 113, 0.28);
  color: rgba(245, 240, 227, 0.95);
  position: relative;
  overflow: hidden;
}

.enter-btn::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: 1px;
  background: var(--amber);
  transform: scaleX(0.18);
  transform-origin: left center;
  transition: transform 0.85s var(--ease-cine);
}

.enter-label {
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0.34em;
  transition: letter-spacing 0.7s var(--ease-cine), color 0.4s ease;
}

.enter-sub {
  font-size: 9px;
  letter-spacing: 0.28em;
  color: rgba(232, 180, 113, 0.55);
  transition: color 0.4s ease;
}

.enter-btn:hover .enter-label { letter-spacing: 0.46em; color: var(--amber-hot); }
.enter-btn:hover::before { transform: scaleX(1); }
.enter-btn:hover .enter-sub { color: rgba(255, 207, 142, 0.82); }

.silent-btn {
  padding: 2px 0;
  border-bottom: 1px solid rgba(184, 197, 187, 0.3);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: rgba(190, 202, 192, 0.78);
  text-shadow: 0 1px 10px rgba(0, 5, 4, 0.9);
  transition: color 0.35s ease, border-color 0.35s ease;
}

.silent-btn:hover { color: rgba(238, 241, 232, 0.9); border-color: rgba(238, 241, 232, 0.5); }

.intro-credit {
  position: absolute;
  left: var(--edge);
  right: var(--edge);
  bottom: calc(var(--bar) + clamp(18px, 2.6vh, 28px));
  display: flex;
  justify-content: space-between;
  gap: 20px;
  font-size: 9px;
  letter-spacing: 0.2em;
  color: rgba(174, 188, 178, 0.62);
  text-shadow: 0 1px 12px rgba(0, 5, 4, 0.9);
}

body.is-entering .intro {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body.is-entering .intro-main { transform: translateY(-8px); }
.intro-main { transition: transform 1.1s var(--ease-cine); }

/* transition veil ------------------------------------------- */

.veil {
  position: fixed;
  inset: 0;
  z-index: 35;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(55% 65% at 66% 56%, rgba(255, 204, 138, 0.34) 0%, rgba(255, 178, 92, 0.12) 28%, transparent 70%),
    rgba(4, 9, 8, 0.92);
  transition: opacity 0.55s ease;
}

.veil.is-on { opacity: 1; }
.veil.is-cold {
  background:
    radial-gradient(60% 70% at 50% 50%, rgba(138, 176, 175, 0.12) 0%, transparent 68%),
    rgba(3, 8, 8, 0.92);
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: #071011;
  color: var(--paper);
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.12em;
}

/* responsive ------------------------------------------------ */

@media (max-width: 820px) {
  :root { --edge: clamp(16px, 5vw, 28px); }

  .topline { align-items: flex-start; }
  .wordmark { flex-direction: column; gap: 4px; }
  .wordmark-en { display: none; }
  .readout { font-size: 9px; gap: 8px; letter-spacing: 0.12em; }

  .scrim {
    background:
      linear-gradient(90deg, rgba(3, 9, 8, 0.9) 0%, rgba(3, 9, 8, 0.7) 52%, rgba(3, 9, 8, 0.24) 82%, transparent 100%),
      linear-gradient(0deg, rgba(3, 8, 8, 0.58) 0%, transparent 42%),
      linear-gradient(180deg, rgba(3, 8, 8, 0.4), transparent 26%);
  }
  .intro { justify-content: flex-start; padding-top: calc(var(--bar) + 9vh); }
  .intro-main {
    flex-direction: column;
    align-items: flex-start;
    gap: 34px;
    padding-left: 0;
  }
  .title-lockup { gap: 12px; }
  .vertical-title { font-size: clamp(38px, 11vw, 58px); letter-spacing: 0.1em; }
  .vertical-title span:last-child { font-size: 0.72em; }
  .seal { margin-bottom: 2px; }
  .intro-copy { padding-bottom: 0; max-width: 330px; }
  .tagline { margin-bottom: 12px; font-size: 14px; }
  .meta { margin-bottom: 26px; font-size: 9px; }
  .intro-credit { font-size: 8px; }
  .intro-credit span:last-child { display: none; }

  .whisper {
    bottom: calc(var(--bar) + 112px);
    width: 84vw;
    font-size: 12px;
    line-height: 1.8;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  .time-rail { width: 100%; gap: 12px; }
  .rail-kicker { writing-mode: horizontal-tb; padding-top: 12px; }
  .rail-track { padding-top: 8px; }
  .time-btn { gap: 3px; }
  .time-btn span { font-size: 11px; letter-spacing: 0.14em; }
  .time-btn.is-on span { letter-spacing: 0.18em; }
  .time-btn small { font-size: 8px; }
  .actions {
    justify-content: flex-start;
    gap: 20px;
    border-top: 1px solid rgba(158, 173, 164, 0.13);
    padding-top: 12px;
  }
  .door-btn { margin-left: auto; font-size: 12px; }
  .door-line { width: 20px; }
  .quiet-btn { font-size: 10px; }
}

@media (max-width: 520px) {
  .readout { font-size: 9.5px; gap: 0.55em; letter-spacing: 0.16em; }
  .readout .tick,
  .readout #weatherState { display: none; }

  .intro { padding-top: calc(var(--bar) + 7vh); }
  .intro-main { gap: 26px; }
  .vertical-title { font-size: clamp(34px, 11.6vw, 48px); letter-spacing: 0.08em; }
  .vertical-title span:last-child { font-size: 0.8em; letter-spacing: 0.18em; }
  .seal { width: 26px; height: 26px; font-size: 15px; }
  .intro-copy { max-width: 300px; }
  .tagline { font-size: 13px; line-height: 1.85; }
  .meta { margin-bottom: 22px; font-size: 8.5px; letter-spacing: 0.1em; }
  .enter-btn { min-width: 160px; padding: 11px 28px 11px 0; }
  .enter-label { font-size: 15px; }
  .intro-credit { font-size: 7.5px; letter-spacing: 0.14em; }

  .whisper {
    bottom: calc(var(--bar) + 116px);
    width: 88vw;
    font-size: 11px;
    letter-spacing: 0.1em;
    line-height: 1.8;
  }
  .controls { gap: 13px; }
  .time-rail { gap: 0; }
  .rail-kicker,
  .time-btn small { display: none; }
  .time-btn span { font-size: 11px; letter-spacing: 0.12em; }
  .time-btn.is-on span { letter-spacing: 0.16em; }
  .actions { gap: 12px; justify-content: space-between; }
  .quiet-btn { font-size: 9.5px; letter-spacing: 0.1em; }
  .door-btn { font-size: 11px; margin-left: 0; letter-spacing: 0.2em; }
  .door-line { width: 16px; }
  .door-btn::after { left: 28px; }
}

@media (max-width: 420px) {
  .readout #weatherState, .readout .tick:nth-of-type(2) { display: none; }
  .actions { gap: 14px; }
  .sound-bars { display: none; }
  .whisper { bottom: calc(var(--bar) + 112px); }
}

@media (max-height: 620px) and (orientation: landscape) {
  .intro-main { align-items: center; }
  .intro { padding-top: calc(var(--bar) + 4vh); padding-bottom: calc(var(--bar) + 6vh); }
  .vertical-title { font-size: clamp(34px, 5.2vw, 54px); }
  .whisper { bottom: calc(var(--bar) + 84px); }
}

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .vertical-title,
  .intro-main,
  .hud,
  .whisper { transition-duration: 0.01ms !important; }
}
