/* 场景：整页夜空与落雪、首屏小镇插画的动态层、炉子特效。
 * 插画是 AI 生成的静态图（Seedream 5.5），动起来的部分全部由这里的 CSS 叠加，只动 transform / opacity。
 * 叠加层用「百分比坐标 + padding-top 撑高」定位，不依赖新浏览器特性，微信老内核也能对齐。 */

/* ---------- 整页夜空 ---------- */
.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 120% 70% at 50% 42%, transparent 55%, rgba(2, 3, 14, 0.55) 100%),
    radial-gradient(ellipse 90% 45% at 50% 108%, rgba(130, 70, 170, 0.32), transparent 70%),
    linear-gradient(180deg, #0b1233 0%, var(--sky-1) 30%, var(--sky-2) 64%, var(--sky-3) 100%);
}
.sky__stars {
  position: absolute;
  inset: 30% 0 20% 0;
  background-image:
    radial-gradient(1.2px 1.2px at 6% 12%, #fff 50%, transparent 100%),
    radial-gradient(1px 1px at 14% 64%, #fff 50%, transparent 100%),
    radial-gradient(1.4px 1.4px at 22% 38%, #fff 50%, transparent 100%),
    radial-gradient(1px 1px at 38% 86%, #fff 50%, transparent 100%),
    radial-gradient(1.2px 1.2px at 63% 46%, #fff 50%, transparent 100%),
    radial-gradient(1px 1px at 82% 74%, #fff 50%, transparent 100%),
    radial-gradient(1.2px 1.2px at 94% 30%, #fff 50%, transparent 100%);
  opacity: 0.6;
}
.sky__stars--twinkle {
  background-image:
    radial-gradient(1.8px 1.8px at 27% 60%, #fff 50%, transparent 100%),
    radial-gradient(1.6px 1.6px at 76% 22%, #fff 50%, transparent 100%),
    radial-gradient(1.6px 1.6px at 48% 92%, #fff 50%, transparent 100%);
  animation: twinkle 3.6s var(--ease-soft) infinite alternate;
}
@keyframes twinkle { from { opacity: 0.2; } to { opacity: 1; } }

/* ---------- 落雪：每层是一块可无缝平铺的雪花图案，整块往下平移一个图块高度后循环 ---------- */
.snowfall { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.snowfall--front { z-index: 3; }
.snowfall__layer { position: absolute; left: 0; right: 0; will-change: transform; }
.snowfall__layer--far {
  --tile: 180px;
  top: calc(-1 * var(--tile));
  height: calc(100% + var(--tile));
  background-size: var(--tile) var(--tile);
  background-image:
    radial-gradient(circle at 20px 30px, rgba(255, 255, 255, 0.85) 0 1px, transparent 1.6px),
    radial-gradient(circle at 92px 12px, rgba(255, 255, 255, 0.7) 0 0.8px, transparent 1.4px),
    radial-gradient(circle at 150px 72px, rgba(255, 255, 255, 0.8) 0 1px, transparent 1.6px),
    radial-gradient(circle at 60px 112px, rgba(255, 255, 255, 0.7) 0 0.8px, transparent 1.4px),
    radial-gradient(circle at 132px 150px, rgba(255, 255, 255, 0.8) 0 1px, transparent 1.6px),
    radial-gradient(circle at 28px 164px, rgba(255, 255, 255, 0.6) 0 0.8px, transparent 1.4px);
  opacity: 0.55;
  animation: snow-fall-far 26s linear infinite;
}
.snowfall__layer--mid {
  --tile: 260px;
  top: calc(-1 * var(--tile));
  height: calc(100% + var(--tile));
  background-size: var(--tile) var(--tile);
  background-image:
    radial-gradient(circle at 40px 50px, rgba(255, 255, 255, 0.95) 0 1.6px, transparent 2.6px),
    radial-gradient(circle at 180px 24px, rgba(255, 255, 255, 0.85) 0 1.4px, transparent 2.4px),
    radial-gradient(circle at 228px 140px, rgba(255, 255, 255, 0.9) 0 1.8px, transparent 2.8px),
    radial-gradient(circle at 110px 196px, rgba(255, 255, 255, 0.85) 0 1.4px, transparent 2.4px),
    radial-gradient(circle at 18px 232px, rgba(255, 255, 255, 0.8) 0 1.2px, transparent 2.2px);
  opacity: 0.7;
  animation: snow-fall-mid 16s linear infinite;
}
.snowfall__layer--near {
  --tile: 360px;
  top: calc(-1 * var(--tile));
  height: calc(100% + var(--tile));
  background-size: var(--tile) var(--tile);
  background-image:
    radial-gradient(circle at 70px 80px, rgba(255, 255, 255, 0.9) 0 2.4px, transparent 4px),
    radial-gradient(circle at 290px 210px, rgba(255, 255, 255, 0.8) 0 2.8px, transparent 4.6px),
    radial-gradient(circle at 180px 330px, rgba(255, 255, 255, 0.7) 0 2px, transparent 3.6px);
  opacity: 0.45;
  animation: snow-fall-near 11s linear infinite;
}
@keyframes snow-fall-far  { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(0, 180px, 0); } }
@keyframes snow-fall-mid  { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(0, 260px, 0); } }
@keyframes snow-fall-near { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(0, 360px, 0); } }

/* ---------- 首屏小镇 ---------- */
.diorama {
  contain: layout paint;
  position: relative;
  margin: -46px calc(-1 * var(--gutter)) 0;  /* 往上伸到顶栏下面，天空和页面夜色连成一片 */
  padding-top: 92%;                           /* 手机上接近方形，比插画原本的 3:2 更高 */
}
/* 插画画布保持 3:2 原比例、高度撑满容器（宽 = 1.5 × 0.92 = 138%，左右各裁掉 19%）。
   动态光点放在画布里、用插画坐标定位，所以无论怎么裁都对得上。 */
.diorama__canvas { position: absolute; top: 0; bottom: 0; left: -19%; width: 138%; }
.diorama__world, .diorama__snow {
  position: absolute;
  inset: 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 16%, #000 80%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 16%, #000 80%, transparent 100%);
}
/* 镜头极慢地推近；炉子不在这一层里，所以看起来有前后景视差 */
.diorama__world { animation: camera-drift 30s var(--ease-soft) infinite alternate; transform-origin: 50% 62%; }
@keyframes camera-drift {
  from { transform: scale(1.02) translate3d(0, 0, 0); }
  to   { transform: scale(1.09) translate3d(-1.2%, 0.8%, 0); }
}
.diorama__scene { position: absolute; inset: 0; width: 100%; height: 100%; }

/* 通用：以 (--x, --y) 为中心、宽 --s 的圆形光斑 */
.fx-moon, .fx-lights i, .fx-stars i, .fx-chimneys i {
  position: absolute;
  left: var(--x);
  top: var(--y);
  display: block;
  pointer-events: none;
}
.fx-moon, .fx-lights i {
  width: var(--s);
  padding-top: var(--s);
  margin: calc(var(--s) * -0.5) 0 0 calc(var(--s) * -0.5);
  border-radius: 50%;
}
.fx-moon {
  background: radial-gradient(circle, rgba(255, 246, 205, 0.55) 0, rgba(255, 240, 190, 0.18) 38%, transparent 70%);
  animation: moon-breathe 7s var(--ease-soft) infinite;
}
@keyframes moon-breathe {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.12); }
}

/* 窗户灯：各自节奏地明暗，偶尔闪一下 */
.fx-lights i {
  background: radial-gradient(circle, rgba(255, 214, 140, 0.95) 0, rgba(255, 160, 70, 0.45) 32%, transparent 70%);
  opacity: 0.45;
  animation: window-glow var(--dur, 7s) ease-in-out var(--delay, 0s) infinite;
}
@keyframes window-glow {
  0%, 100% { opacity: 0.4; }
  40% { opacity: 0.85; }
  55% { opacity: 0.6; }
  58% { opacity: 0.9; }
  75% { opacity: 0.5; }
}
.fx-lights .is-lamp {
  background: radial-gradient(circle, rgba(255, 226, 160, 0.9) 0, rgba(255, 190, 100, 0.35) 30%, transparent 68%);
  animation-name: lamp-glow;
}
@keyframes lamp-glow {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 0.95; transform: scale(1.1); }
  52% { opacity: 0.7; }
  54% { opacity: 0.95; }
}

/* 星星 */
.fx-stars i {
  width: 3px; height: 3px;
  margin: -1.5px 0 0 -1.5px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px 1px rgba(220, 230, 255, 0.9);
  animation: star-twinkle var(--dur, 3s) ease-in-out var(--delay, 0s) infinite;
}
@keyframes star-twinkle {
  0%, 100% { opacity: 0.15; transform: scale(0.6); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* 流星：大约每 11 秒划过一次 */
.fx-shooting { position: absolute; left: 6%; top: 6%; width: 60%; height: 30%; rotate: 18deg; transform-origin: 0 0; }
.fx-shooting i {
  position: absolute;
  left: 0; top: 0;
  width: 26%; height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.95));
  opacity: 0;
  animation: shooting 11s linear 3s infinite;
}
@keyframes shooting {
  0% { opacity: 0; transform: translateX(0); }
  1% { opacity: 1; }
  7% { opacity: 0; transform: translateX(320%); }
  100% { opacity: 0; transform: translateX(320%); }
}

/* 房子烟囱冒烟 */
.fx-chimneys i {
  width: 2.6%;
  padding-top: 2.6%;
  margin: -1.3% 0 0 -1.3%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(220, 225, 245, 0.55), transparent 70%);
  opacity: 0;
  animation: chimney-smoke 6s ease-out var(--delay, 0s) infinite;
}
@keyframes chimney-smoke {
  0% { opacity: 0; transform: translate(0, 0) scale(0.6); }
  25% { opacity: 0.7; }
  100% { opacity: 0; transform: translate(12px, -34px) scale(2.4); }
}

/* 炉火映在雪地上的暖光，跟着火苗一起跳 */
.diorama__glow {
  position: absolute;
  left: 4%; right: 6%;
  top: 54%; height: 34%;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 55%, rgba(255, 160, 80, 0.5), rgba(255, 122, 47, 0.14) 45%, transparent 70%);
  animation: fire-breathe 2.6s ease-in-out infinite;
}
@keyframes fire-breathe {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  30% { opacity: 1; transform: scale(1.05); }
  45% { opacity: 0.8; }
  70% { opacity: 0.95; transform: scale(1.02); }
}

/* ---------- 炉子 ---------- */
.stove {
  position: absolute;
  left: 49%;
  bottom: 19%;
  width: 30%;
  margin-left: -15%;
  transform-origin: 50% 100%;
  animation: stove-idle 3.4s var(--ease-soft) infinite;
}
@keyframes stove-idle {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(1.012, 0.99); }
}
.stove__body { position: relative; display: block; }
.stove__img { display: block; width: 100%; height: auto; }
.stove__shadow {
  position: absolute;
  left: 6%; right: 6%; bottom: -5%;
  height: 12%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(24, 16, 40, 0.55), transparent 70%);
}
/* 炉门里的火光（炉门中心约在图片的 48%, 57%） */
.stove__fire, .stove__shade {
  position: absolute;
  left: 48%; top: 57%;
  width: 56%;
  padding-top: 56%;
  margin: -28% 0 0 -28%;
  border-radius: 50%;
  pointer-events: none;
}
.stove__fire {
  background: radial-gradient(circle, rgba(255, 214, 130, 0.75) 0, rgba(255, 140, 50, 0.3) 38%, transparent 66%);
  animation: fire-flicker 1.7s steps(1, end) infinite, fire-sway 2.3s ease-in-out infinite;
}
@keyframes fire-flicker {
  0% { opacity: 0.75; } 18% { opacity: 1; } 31% { opacity: 0.7; } 47% { opacity: 0.95; }
  63% { opacity: 0.8; } 79% { opacity: 1; } 90% { opacity: 0.72; }
}
@keyframes fire-sway {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08) translateY(-2%); }
}
.stove__shade { background: radial-gradient(circle, rgba(10, 6, 10, 0.85) 30%, transparent 60%); opacity: 0; }
.stove__plate {
  position: absolute;
  left: 47%; top: 80.5%;
  transform: translate(-50%, -50%);
  font-family: var(--font-letter);
  font-size: clamp(7px, 2.3vw, 10px);
  font-weight: 900;
  letter-spacing: 0.3em;
  padding-left: 0.3em;
  color: #f3d9a6;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  pointer-events: none;
}

/* 烟囱口（约在图片的 90%, 4%）的烟和火星 */
.stove__smoke i, .stove__sparks i, .stove__burst i, .stove__soot i {
  position: absolute;
  display: block;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}
.stove__smoke i {
  left: 84%; top: -6%;
  width: 26px; height: 26px;
  background: radial-gradient(circle, rgba(215, 220, 245, 0.42) 0, rgba(215, 220, 245, 0.16) 45%, transparent 70%);
  animation: smoke-rise 5s ease-out infinite;
}
.stove__smoke i:nth-child(2) { animation-delay: -1.7s; }
.stove__smoke i:nth-child(3) { animation-delay: -3.4s; }
@keyframes smoke-rise {
  0% { opacity: 0; transform: translate(0, 0) scale(0.5); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(18px, -72px) scale(2.2); }
}
.stove__sparks i {
  left: 89%; top: 0;
  width: 4px; height: 4px;
  background: #ffd98a;
  box-shadow: 0 0 6px 2px rgba(255, 140, 60, 0.85);
  animation: spark-rise var(--dur, 3s) ease-out var(--delay, 0s) infinite;
}
@keyframes spark-rise {
  0% { opacity: 0; transform: translate(0, 0) scale(1); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--x, 10px), -110px) scale(0.3); }
}

/* 投料成功 / 刚开炉：火光一窜，火星从炉门迸出来 */
.stove__burst i {
  left: 48%; top: 57%;
  width: 6px; height: 6px;
  margin: -3px 0 0 -3px;
  background: #ffe7a8;
  box-shadow: 0 0 8px 3px rgba(255, 150, 60, 0.9);
}
.stove.is-fed .stove__burst i,
.stove.is-lit .stove__burst i { animation: burst 1s var(--ease-out) forwards; }
.stove.is-fed .stove__fire,
.stove.is-lit .stove__fire { animation: fire-flare 1.1s var(--ease-pop); }
@keyframes burst {
  0% { opacity: 1; transform: translate(0, 0) scale(0.4); }
  100% { opacity: 0; transform: translate(var(--bx), var(--by)) scale(1); }
}
@keyframes fire-flare {
  0% { opacity: 0.8; transform: scale(1); }
  30% { opacity: 1; transform: scale(1.9); }
  100% { opacity: 0.8; transform: scale(1); }
}

/* 炸炉：抖动、炉门一黑、冒黑烟 */
.stove.is-exploding { animation: shake 0.6s ease-in-out; }
.stove.is-exploding .stove__shade { animation: dim 1.4s ease-out; }
.stove__soot i {
  top: 18%;
  width: 46px; height: 46px;
  background: radial-gradient(circle at 40% 40%, #3a3238, #120d10 70%);
}
.stove__soot i:nth-child(1) { left: 6%; }
.stove__soot i:nth-child(2) { left: 30%; top: 8%; width: 58px; height: 58px; }
.stove__soot i:nth-child(3) { left: 56%; top: 16%; }
.stove__soot i:nth-child(4) { left: 20%; top: 26%; width: 34px; height: 34px; }
.stove.is-exploding .stove__soot i { animation: soot-burst 1.5s var(--ease-out); }
.stove.is-exploding .stove__soot i:nth-child(2) { animation-delay: 0.08s; }
.stove.is-exploding .stove__soot i:nth-child(3) { animation-delay: 0.16s; }
@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  15% { transform: translateX(-7px) rotate(-3deg); }
  30% { transform: translateX(6px) rotate(2deg); }
  45% { transform: translateX(-5px) rotate(-2deg); }
  60% { transform: translateX(4px) rotate(1deg); }
  75% { transform: translateX(-2px); }
}
@keyframes dim { 0% { opacity: 0; } 20% { opacity: 0.9; } 100% { opacity: 0; } }
@keyframes soot-burst {
  0% { opacity: 0; transform: translateY(12px) scale(0.4); }
  25% { opacity: 0.92; }
  100% { opacity: 0; transform: translateY(-64px) scale(1.6); }
}

@keyframes breathe-soft { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; } }

/* ---------- 炉子的状态：闷烧（封炉、满了）/ 熄火（炉子没了） ---------- */
.diorama--smolder .stove__fire { opacity: 0.45; animation-duration: 3.4s, 4.6s; }
.diorama--smolder .stove__shade { opacity: 0.35; }
.diorama--smolder .stove__sparks i { animation-duration: 6s; }
.diorama--smolder .stove__sparks i:nth-child(n+3) { display: none; }
.diorama--smolder .diorama__glow { opacity: 0.45; animation-duration: 5s; }

.diorama--cold .stove__fire,
.diorama--cold .stove__sparks { display: none; }
/* 插画里雪地上的暖光是画死的：熄火时用一层冷色把它压下去 */
.diorama--cold .diorama__glow {
  animation: none;
  background: radial-gradient(ellipse at 50% 55%, rgba(14, 22, 62, 0.62), rgba(14, 22, 62, 0.25) 50%, transparent 74%);
}
.diorama--cold .stove__shade { opacity: 0.8; }
.diorama--cold .stove__smoke i { background: radial-gradient(circle, rgba(150, 155, 175, 0.5) 0, rgba(150, 155, 175, 0.18) 45%, transparent 70%); }

/* 场景滚出屏幕时暂停（common.js 根据可见性切换这个类）；页面上的落雪照常 */
.scene-paused .diorama,
.scene-paused .diorama * { animation-play-state: paused !important; }

@media (prefers-reduced-motion: reduce) {
  .snowfall, .diorama__snow, .stove__sparks, .stove__smoke, .fx-shooting, .fx-chimneys { display: none; }
}
