/* ============ 基础 ============ */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: #fff;
  background: #070b16;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: rgba(120, 170, 255, .35); }

/* ============ 页面背景（随主题过渡） ============ */
.bg {
  position: fixed;
  inset: 0;
  z-index: -3;
  opacity: 0;
  transition: opacity 1.1s ease;
}
.bg.default { background: #070b16; opacity: 1; }
.bg.sunny {
  background:
    radial-gradient(900px 640px at 82% -12%, rgba(58, 120, 220, .38), transparent 68%),
    radial-gradient(760px 560px at 6% 112%, rgba(235, 150, 44, .20), transparent 70%),
    #0a1120;
}
.bg.wind {
  background:
    radial-gradient(900px 640px at 14% -12%, rgba(38, 160, 175, .32), transparent 68%),
    radial-gradient(760px 560px at 92% 112%, rgba(90, 200, 150, .14), transparent 70%),
    #08131a;
}
.bg.rain {
  background:
    radial-gradient(900px 640px at 50% -16%, rgba(88, 95, 205, .30), transparent 68%),
    radial-gradient(760px 560px at 10% 112%, rgba(40, 45, 110, .35), transparent 70%),
    #06080f;
}
.bg.snow {
  background:
    radial-gradient(900px 640px at 84% -12%, rgba(130, 165, 210, .28), transparent 68%),
    radial-gradient(760px 560px at 8% 112%, rgba(180, 200, 225, .16), transparent 70%),
    #0b1220;
}
body[data-theme="sunny"] .bg.sunny,
body[data-theme="wind"]  .bg.wind,
body[data-theme="rain"]  .bg.rain,
body[data-theme="snow"]  .bg.snow { opacity: 1; }

.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  z-index: -2;
  pointer-events: none;
}
.orb-1 {
  width: 44vw; height: 44vw;
  left: -12vw; top: -16vw;
  background: rgba(64, 110, 230, .22);
  animation: orbDrift 26s ease-in-out infinite alternate;
}
.orb-2 {
  width: 38vw; height: 38vw;
  right: -10vw; bottom: -14vw;
  background: rgba(45, 180, 175, .16);
  animation: orbDrift 32s ease-in-out infinite alternate-reverse;
}
@keyframes orbDrift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(6vw, 4vw) scale(1.12); }
}

/* ============ 布局 ============ */
.app {
  width: min(1280px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 26px clamp(18px, 3.4vw, 44px) 16px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
  animation: fadeDown .7s .08s cubic-bezier(.22, 1, .36, 1) backwards;
}
.topbar h1 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: .3px; }
.clock {
  margin: 5px 0 0;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, .55);
  letter-spacing: .3px;
}

.hint {
  text-align: center;
  margin: 16px 0 0;
  font-size: 12.5px;
  color: rgba(255, 255, 255, .38);
  letter-spacing: .4px;
  animation: fadeUp .7s .4s cubic-bezier(.22, 1, .36, 1) backwards;
}

/* ============ iOS 分段控件 ============ */
.segmented {
  position: relative;
  display: flex;
  padding: 3px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .10);
  border: 1px solid rgba(255, 255, 255, .14);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.glider {
  position: absolute;
  top: 3px; left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  border-radius: 9px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .28);
  transition: transform .38s cubic-bezier(.22, 1, .36, 1);
}
.segmented.is-f .glider { transform: translateX(100%); }
.segment {
  flex: 1;
  position: relative;
  z-index: 1;
  border: 0;
  background: none;
  padding: 7px 22px;
  border-radius: 9px;
  font: 600 13px/1 inherit;
  color: rgba(255, 255, 255, .75);
  cursor: pointer;
  transition: color .3s ease;
}
.segment.active { color: #0b1426; }

/* ============ 卡片通用 ============ */
.cards {
  display: flex;
  gap: 20px;
  flex: 1;
  min-height: 380px;
  perspective: 1400px;
}

.card {
  position: relative;
  flex: 1 1 0;
  min-width: 220px;
  border-radius: 32px;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  border: 1px solid rgba(255, 255, 255, .30);
  box-shadow:
    0 24px 50px -14px rgba(2, 7, 22, .55),
    0 6px 18px rgba(2, 7, 22, .30),
    inset 0 1px 0 rgba(255, 255, 255, .25);
  transition:
    transform .55s cubic-bezier(.22, 1, .36, 1),
    flex .65s cubic-bezier(.22, 1, .36, 1),
    box-shadow .5s ease,
    filter .5s ease,
    border-color .5s ease;
  animation: cardIn .85s cubic-bezier(.22, 1, .36, 1) backwards;
  will-change: transform;
}
.card:nth-child(1) { animation-delay: .04s; }
.card:nth-child(2) { animation-delay: .12s; }
.card:nth-child(3) { animation-delay: .20s; }
.card:nth-child(4) { animation-delay: .28s; }

.card:hover {
  box-shadow:
    0 36px 70px -16px rgba(2, 7, 22, .62),
    0 8px 22px rgba(2, 7, 22, .34),
    inset 0 1px 0 rgba(255, 255, 255, .30);
}
.card:focus-visible { outline: 2px solid rgba(255, 255, 255, .75); outline-offset: 3px; }
.card.active {
  flex-grow: 1.85;
  border-color: rgba(255, 255, 255, .55);
  box-shadow:
    0 40px 80px -18px rgba(2, 7, 22, .70),
    0 10px 26px rgba(2, 7, 22, .36),
    inset 0 1px 0 rgba(255, 255, 255, .35);
}
.cards.has-active .card:not(.active) { filter: saturate(.78) brightness(.82); }

/* ============ 场景（天空） ============ */
.scene {
  position: absolute;
  inset: -9%;                       /* 出血，供视差位移 */
  container-type: size;             /* 粒子用 cqh/cqw 计算位移 */
  transform: translate3d(calc(var(--px, 0) * -14px), calc(var(--py, 0) * -10px), 0);
  transition: transform .4s ease-out;
}
.scene-sunny {
  background:
    radial-gradient(150px 150px at 50% 21%, rgba(255, 213, 102, .50), transparent 70%),
    linear-gradient(180deg, #1e6fd0 0%, #4e9de8 46%, #a6d4f4 100%);
}
.scene-wind { background: linear-gradient(180deg, #0e5266 0%, #2e8fa8 52%, #a3dbe7 100%); }
.scene-rain { background: linear-gradient(180deg, #10162e 0%, #222b4d 55%, #3a4260 100%); }
.scene-snow { background: linear-gradient(180deg, #3d5b84 0%, #7b9cbe 55%, #deeaf4 100%); }

.fx { position: absolute; inset: 0; }

.scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg,
    rgba(5, 10, 24, .20), rgba(5, 10, 24, 0) 26%,
    rgba(5, 10, 24, 0) 55%, rgba(5, 10, 24, .40));
}

.sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(112deg, transparent 40%, rgba(255, 255, 255, .13) 50%, transparent 60%);
  transform: translateX(calc(var(--px, 0) * -110px));
  transition: transform .3s ease;
}

/* ---- 太阳 ---- */
.sun {
  position: absolute;
  left: calc(50% - 42px);
  top: 9%;
  width: 84px; height: 84px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 32%, #fff6d8, #ffd75e 42%, #ffaa33 78%, #ff9822);
  box-shadow:
    0 0 34px 8px rgba(255, 203, 92, .65),
    0 0 110px 36px rgba(255, 166, 44, .28);
  animation: sunPulse 4.6s ease-in-out infinite alternate;
}
@keyframes sunPulse { from { transform: scale(1); } to { transform: scale(1.06); } }

.sun-rays {
  position: absolute;
  left: calc(50% - 118px);
  top: calc(9% - 76px);
  width: 236px; height: 236px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 3deg,
    rgba(255, 228, 140, .40) 0 5deg, transparent 5deg 22.5deg);
  -webkit-mask: radial-gradient(circle, #000 30%, transparent 66%);
  mask: radial-gradient(circle, #000 30%, transparent 66%);
  animation: spin 32s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 云朵 ---- */
.cloud {
  position: absolute;
  width: 110px; height: 32px;
  border-radius: 18px;
  background: #fff;
  opacity: .92;
  transform: scale(var(--s, 1));
}
.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}
.cloud::before { width: 54px; height: 54px; top: -28px; left: 16px; }
.cloud::after  { width: 38px; height: 38px; top: -18px; right: 18px; }

@keyframes bob {
  from { transform: translateX(-14px) scale(var(--s, 1)); }
  to   { transform: translateX(14px)  scale(var(--s, 1)); }
}
@keyframes rush {
  0%   { transform: translateX(-180px) scale(var(--s, 1)); opacity: 0; }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { transform: translateX(115cqw) scale(var(--s, 1)); opacity: 0; }
}

.s-c1 { left: 5%; bottom: 16%; width: 92px; height: 26px; opacity: .85; filter: blur(.4px); animation: bob 9s ease-in-out infinite alternate; }
.w-c1 { top: 15%; left: 0; animation: rush 13s linear infinite; }
.w-c2 { top: 33%; left: 0; --s: .7; opacity: .8; animation: rush 9s linear infinite 2s; }
.w-c3 { top: 7%; right: 9%; --s: .6; opacity: .85; animation: bob 5s ease-in-out infinite alternate; }
.r-c1 { background: #454e79; top: -14px; left: 4%;  --s: 1.15; animation: bob 7s ease-in-out infinite alternate; }
.r-c2 { background: #3a4370; top: -6px;  right: -8%; --s: .9;  animation: bob 9s ease-in-out infinite alternate 1.2s; }
.sn-c1 { background: #dfe9f4; top: 9%; right: 6%; --s: .65; opacity: .75; animation: bob 11s ease-in-out infinite alternate; }

/* ---- 大风：风线 ---- */
.wind-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.streak {
  fill: none;
  stroke: rgba(255, 255, 255, .66);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 64 268;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, .35));
  animation: streak var(--dur, 2.6s) linear infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes streak { from { stroke-dashoffset: 332; } to { stroke-dashoffset: -332; } }

.leaf {
  position: absolute;
  width: 13px; height: 8px;
  border-radius: 0 100% 0 100%;
  background: linear-gradient(100deg, #8fd460, #3e9330);
  opacity: .9;
  animation: leafFly var(--dur, 4s) linear infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes leafFly {
  0%   { transform: translate(-40px, 0) rotate(0deg); }
  30%  { transform: translate(30cqw, -26px) rotate(220deg); }
  60%  { transform: translate(62cqw, 8px) rotate(400deg); }
  100% { transform: translate(118cqw, -14px) rotate(660deg); }
}

/* ---- 暴雨：雨滴 / 涟漪 / 闪电 ---- */
.drop {
  position: absolute;
  top: 0;
  width: 2px; height: 20px;
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(158, 196, 255, 0), rgba(158, 196, 255, .9));
  animation: fall var(--dur, .8s) linear infinite;
}
.drop.back { width: 1.5px; height: 13px; opacity: .45; }
@keyframes fall {
  from { transform: translateY(-30cqh) rotate(10deg); }
  to   { transform: translateY(118cqh) rotate(10deg); }
}

.ripple {
  position: absolute;
  bottom: var(--b, 14px);
  left: var(--x, 50%);
  width: 9px; height: 3.5px;
  border: 1.4px solid rgba(190, 220, 255, .75);
  border-radius: 50%;
  opacity: 0;
  animation: ripple var(--dur, 1.3s) ease-out infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes ripple {
  0%   { transform: scale(.3); opacity: .85; }
  70%  { opacity: 0; }
  100% { transform: scale(3.6); opacity: 0; }
}

.bolt-svg {
  position: absolute;
  top: 20%; left: 56%;
  width: 64px; height: 64px;
  color: #ffe45e;
  filter: drop-shadow(0 0 16px rgba(255, 224, 90, .95));
  opacity: 0;
  transform: scale(.5) rotate(-6deg);
}
.flash {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(60% 55% at 58% 16%, rgba(255, 255, 255, .95), rgba(255, 255, 255, 0) 70%);
}
.scene.strike .flash    { animation: flashAnim .55s ease-out; }
.scene.strike .bolt-svg { animation: boltPop  .55s ease-out; }
@keyframes flashAnim {
  0% { opacity: 0; } 6% { opacity: 1; } 14% { opacity: .15; }
  22% { opacity: .85; } 34% { opacity: .1; } 100% { opacity: 0; }
}
@keyframes boltPop {
  0%   { opacity: 0; transform: scale(.4) rotate(-8deg); }
  10%  { opacity: 1; transform: scale(1.15) rotate(2deg); }
  30%  { opacity: 1; transform: scale(1) rotate(0deg); }
  60%  { opacity: 0; transform: scale(1.05) translateY(6px); }
  100% { opacity: 0; transform: scale(1.05) translateY(6px); }
}

/* ---- 暴雪：雪花 / 地面积雪 ---- */
.flake {
  position: absolute;
  top: -6%;
  border-radius: 50%;
  background: #fff;
  animation: snowA var(--dur, 7s) linear infinite;
  animation-delay: var(--delay, 0s);
}
.flake.swB { animation-name: snowB; }
.flake.gust { animation: snowGust var(--dur, 1.5s) linear infinite; animation-delay: var(--delay, 0s); }
@keyframes snowA {
  0%   { transform: translate(0, -8cqh); }
  45%  { transform: translate(2.5cqw, 52cqh); }
  100% { transform: translate(-1.5cqw, 112cqh); }
}
@keyframes snowB {
  0%   { transform: translate(0, -8cqh); }
  45%  { transform: translate(-2.5cqw, 52cqh); }
  100% { transform: translate(1.5cqw, 112cqh); }
}
@keyframes snowGust {
  from { transform: translate(-6cqw, -10cqh); }
  to   { transform: translate(30cqw, 115cqh); }
}

.ground {
  position: absolute;
  left: -20%; bottom: -30px;
  width: 140%; height: 120px;
  background: radial-gradient(60% 100% at 50% 100%, rgba(255, 255, 255, .85), rgba(255, 255, 255, 0) 70%);
  filter: blur(6px);
}

/* ---- 晴：光斑 ---- */
.spark {
  position: absolute;
  bottom: 6%;
  border-radius: 50%;
  background: radial-gradient(circle, #fff3c4, rgba(255, 220, 120, 0) 70%);
  animation: rise var(--dur, 7s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes rise {
  0%   { transform: translateY(0) scale(.6); opacity: 0; }
  18%  { opacity: .9; }
  80%  { opacity: .35; }
  100% { transform: translateY(-88cqh) scale(1.15); opacity: 0; }
}

/* ============ 卡片内容 ============ */
.card-content {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px 20px 18px;
  text-shadow: 0 1px 10px rgba(0, 0, 0, .22);
}
.spacer { flex: 1; }

.card-head { display: flex; justify-content: space-between; align-items: flex-start; }
.city { margin: 0; font-size: 21px; font-weight: 600; }
.cond { margin: 3px 0 0; font-size: 14px; color: rgba(255, 255, 255, .88); }
.head-ic {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .25);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.head-ic .ic { width: 21px; height: 21px; }

.temp {
  margin-top: 14px;
  font-size: clamp(54px, 5.4vw, 78px);
  font-weight: 200;
  line-height: .95;
  letter-spacing: -2px;
  transform-origin: left bottom;
}
.temp.bump { animation: popTemp .45s cubic-bezier(.22, 1, .36, 1); }
@keyframes popTemp { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }
.hl { margin-top: 10px; font-size: 13px; color: rgba(255, 255, 255, .92); }
.hl b { font-weight: 600; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  color: rgba(255, 255, 255, .9);
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .22);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.chip b { font-weight: 600; color: #fff; }
.chip .ic { width: 13px; height: 13px; opacity: .9; }

/* ---- 逐时预报（点按展开） ---- */
.hourly-wrap {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px);
  transition:
    max-height .6s cubic-bezier(.22, 1, .36, 1),
    opacity .4s ease .12s,
    transform .6s cubic-bezier(.22, 1, .36, 1);
}
.card.active .hourly-wrap { max-height: 150px; opacity: 1; transform: none; }
.hourly {
  display: flex;
  justify-content: space-between;
  padding-top: 12px;
  margin-top: 13px;
  border-top: 1px solid rgba(255, 255, 255, .25);
}
.h-item { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.h-time { font-size: 11px; color: rgba(255, 255, 255, .70); letter-spacing: .3px; }
.h-ic   { width: 18px; height: 18px; opacity: .95; }
.h-temp { font-size: 13.5px; font-weight: 600; }

.ic { width: 1em; height: 1em; display: inline-block; fill: currentColor; }

/* ============ 入场动画 ============ */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(36px) scale(.95); }
  to   { opacity: 1; transform: none; }
}
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ============ 响应式 ============ */
@media (max-width: 1020px) {
  .cards { flex-wrap: wrap; min-height: 0; }
  .card { flex: 1 1 calc(50% - 11px); min-height: 340px; }
}
@media (max-width: 640px) {
  .card { flex-basis: 100%; }
  .temp { font-size: 64px; }
}

/* ============ 减弱动态效果 ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
