/* 小津助手 v2.1 — dynamic weather scene (js/scene.js, docs/DESIGN-v21.md §2).
   All scene colours are computed in JS per phase × weather × theme and arrive as --sc-* custom properties
   (illustration exception to the "colours come from tokens" rule). Fades use explicit rgba stops of the
   same rgb (no transparent-black grey halos on old engines).
   Compatibility: no color-mix(), :has(), nesting, @container, @layer, backdrop-filter. */

/* Optional host helper: the caller's container. Content placed over the scene should be
   position:relative; z-index:1. */
.scene-host { position: relative; isolation: isolate; }
.scene-host > :not(.scene) { position: relative; z-index: 1; }

.scene {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
  -webkit-user-select: none;
  user-select: none;
  contain: layout paint;
  animation: sc-in 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.scene > * { position: absolute; }
.scene.is-swap { animation: sc-swap 700ms ease-out; }
@keyframes sc-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sc-swap { 0% { opacity: 0.45; } 100% { opacity: 1; } }

/* ---------- sky ---------- */
.sc-sky {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(180deg, var(--sc-sky1) 0%, var(--sc-sky2) 46%, var(--sc-sky3) 74%, var(--sc-sky3) 100%);
}
.sc-stars {
  top: 0;
  left: 0;
  width: 100%;
  height: 70%;
  fill: #FFF8E6;
  opacity: var(--sc-stars-o);
}
.sc-stars .tw { animation: sc-twinkle 3.6s ease-in-out infinite alternate; }
.sc-stars .tw:nth-child(2n) { animation-duration: 4.8s; animation-delay: -1.2s; }
.sc-stars .tw2 { animation: sc-twinkle 5.4s ease-in-out infinite alternate; animation-delay: -2s; }
@keyframes sc-twinkle { from { opacity: 1; } to { opacity: 0.25; } }

/* ---------- sun, moon, glow ---------- */
.sc-glow {
  left: var(--sc-sun-x);
  top: var(--sc-sun-y);
  width: var(--sc-glow-size);
  height: var(--sc-glow-size);
  border-radius: 50%;
  background: radial-gradient(circle closest-side, var(--sc-glow-0) 0%, var(--sc-glow-1) 42%, var(--sc-glow-2) 100%);
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  animation: sc-breathe 7s ease-in-out infinite alternate;
}
@keyframes sc-breathe {
  from { -webkit-transform: translate(-50%, -50%) scale(0.96); transform: translate(-50%, -50%) scale(0.96); }
  to { -webkit-transform: translate(-50%, -50%) scale(1.06); transform: translate(-50%, -50%) scale(1.06); }
}
.sc-sun {
  left: var(--sc-sun-x);
  top: var(--sc-sun-y);
  width: var(--sc-sun-size);
  height: var(--sc-sun-size);
  border-radius: 50%;
  background: radial-gradient(circle at 46% 42%, #FFFFFF 0%, var(--sc-sun) 58%, var(--sc-sun) 100%);
  box-shadow: 0 0 0 calc(var(--sc-sun-size) * 0.14) var(--sc-ring-1), 0 0 0 calc(var(--sc-sun-size) * 0.32) var(--sc-ring-2);
  opacity: var(--sc-sun-o);
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}
.sc-moon {
  left: var(--sc-sun-x);
  top: var(--sc-sun-y);
  width: var(--sc-sun-size);
  height: var(--sc-sun-size);
  opacity: var(--sc-moon-o);
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}
.sc-moon-art { width: 100%; height: 100%; overflow: visible; }
.sc-moon-art path { fill: #FFF3D2; }
.sc-moon-art .mc { fill: #EAD9AE; opacity: 0.55; }
[data-theme="dark"] .sc-moon-art path { fill: #EFE2C2; }

/* ---------- clouds ---------- */
.sc-clouds { top: 0; right: 0; bottom: 0; left: 0; }
.sc-cloud { position: absolute; }
.sc-cloud svg { display: block; width: 100%; height: auto; overflow: visible; }
.sc-cloud .b { fill: var(--sc-cloud); }
.sc-cloud .s { fill: var(--sc-shade); }
.sc-bank { position: absolute; left: -20%; width: 140%; }
.sc-bank path { fill: var(--sc-cloud); }
.sc-bank-s path { fill: var(--sc-shade); }
.sc-d-a { animation: sc-drift-a 46s ease-in-out infinite alternate; }
.sc-d-b { animation: sc-drift-b 58s ease-in-out infinite alternate; animation-delay: -12s; }
.sc-d-c { animation: sc-drift-c 70s ease-in-out infinite alternate; animation-delay: -30s; }
.sc-d-ba { animation: sc-drift-bank 90s ease-in-out infinite alternate; }
.sc-d-bb { animation: sc-drift-bank 74s ease-in-out infinite alternate-reverse; }
@keyframes sc-drift-a { from { -webkit-transform: translateX(-18px); transform: translateX(-18px); } to { -webkit-transform: translateX(26px); transform: translateX(26px); } }
@keyframes sc-drift-b { from { -webkit-transform: translateX(16px); transform: translateX(16px); } to { -webkit-transform: translateX(-24px); transform: translateX(-24px); } }
@keyframes sc-drift-c { from { -webkit-transform: translateX(-30px); transform: translateX(-30px); } to { -webkit-transform: translateX(30px); transform: translateX(30px); } }
@keyframes sc-drift-bank { from { -webkit-transform: translateX(-3%); transform: translateX(-3%); } to { -webkit-transform: translateX(3%); transform: translateX(3%); } }

/* ---------- land ---------- */
.sc-land {
  left: 0;
  bottom: 0;
  width: 100%;
  height: 56%;
  overflow: hidden;
}
.scene--login .sc-land { height: 62%; }
.scene--hero .sc-land { height: 58%; }
.scene--header .sc-land { height: 62%; }
.scene--lobby .sc-land { height: 56%; }
.sc-far { fill: var(--sc-far); }
.sc-mid { fill: var(--sc-mid); }
.sc-near { fill: var(--sc-near); }
.sc-town { fill: var(--sc-town); }
.sc-win { fill: #FFD27A; opacity: var(--sc-lights); }
.sc-leaf { fill: var(--sc-tree); }
.sc-leaf2 { fill: var(--sc-tree2); }
.sc-trunk { fill: var(--sc-tree); }
.sc-road { fill: var(--sc-road); opacity: 0.9; }
.sc-snowcap { fill: var(--sc-cap); opacity: var(--sc-caps); }

/* ---------- weather veils ---------- */
.sc-fog { left: 0; right: 0; bottom: 0; height: 64%; display: none; }
.scene[data-weather="fog"] .sc-fog { display: block; }
.sc-fog i {
  position: absolute;
  left: -30%;
  width: 160%;
  height: 34%;
  background: linear-gradient(180deg, var(--sc-fog-0) 0%, var(--sc-fog-1) 50%, var(--sc-fog-0) 100%);
  animation: sc-fog 38s ease-in-out infinite alternate;
}
.sc-fog i:nth-child(1) { top: 6%; opacity: 0.85; }
.sc-fog i:nth-child(2) { top: 34%; opacity: 0.95; animation-duration: 52s; animation-direction: alternate-reverse; }
.sc-fog i:nth-child(3) { top: 62%; animation-duration: 44s; }
@keyframes sc-fog { from { -webkit-transform: translateX(-5%); transform: translateX(-5%); } to { -webkit-transform: translateX(5%); transform: translateX(5%); } }

.sc-veil {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: none;
  background: linear-gradient(180deg, var(--sc-veil-0) 0%, var(--sc-veil-1) 45%, var(--sc-veil-2) 100%);
}
.scene[data-weather="haze"] .sc-veil, .scene[data-weather="dust"] .sc-veil { display: block; }

.sc-pattern {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  opacity: 0.5;
  background-image:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.07) 0, rgba(255, 255, 255, 0.07) 1px, rgba(255, 255, 255, 0) 1px, rgba(255, 255, 255, 0) 16px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.07) 0, rgba(255, 255, 255, 0.07) 1px, rgba(255, 255, 255, 0) 1px, rgba(255, 255, 255, 0) 16px);
}

.sc-fx { top: 0; left: 0; width: 100%; height: 100%; }
.sc-flash {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: #F4F7FF;
  opacity: 0;
}
.sc-flash.is-on { animation: sc-flash 900ms ease-out; }
@keyframes sc-flash { 0% { opacity: 0; } 8% { opacity: 0.42; } 22% { opacity: 0.06; } 32% { opacity: 0.28; } 100% { opacity: 0; } }

/* ---------- bottom fade into the page ---------- */
.sc-fade {
  left: 0;
  right: 0;
  bottom: 0;
  height: 22%;
  background: linear-gradient(180deg, var(--sc-fade-0) 0%, var(--sc-fade-1) 62%, var(--sc-fade-2) 100%);
}
.scene--header .sc-fade { height: 30%; }
.scene--lobby .sc-fade { height: 26%; }

/* ---------- motion states ---------- */
.scene.is-paused, .scene.is-paused * { animation-play-state: paused !important; }
.scene.is-static, .scene.is-static * { animation: none !important; }
.scene.is-lowfx .sc-stars .tw, .scene.is-lowfx .sc-stars .tw2 { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .scene, .scene * { animation: none !important; }
}

/* ---------- weather pill 「天津 · 霾 12°」 ---------- */
.weather-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  max-width: 100%;
  padding: 0 11px 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 1px 2px rgba(84, 48, 24, 0.08);
  color: #2B1E17;
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.weather-pill[hidden] { display: none; }
.weather-pill > span { overflow: hidden; text-overflow: ellipsis; line-height: 18px; }
.weather-pill .weather-glyph { flex: none; width: 16px; height: 16px; }
[data-theme="dark"] .weather-pill {
  background: rgba(28, 21, 17, 0.58);
  box-shadow: 0 0 0 1px rgba(255, 230, 210, 0.1);
  color: #F5ECE3;
}
.scene > .weather-pill {
  top: calc(var(--safe-top, 0px) + 12px);
  right: 16px;
  z-index: 3;
}
.scene--hero > .weather-pill, .scene--lobby > .weather-pill { top: 12px; right: 12px; }
