/* ===================================================================
   x-weather · 腾讯天气风格重构
   动态天空背景（晴/多云/阴/雨/雷/雪/雾/尘 × 昼/夜）
   玻璃拟态卡片 · 大字号温度 · 昼夜双主题
   =================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

:root {
  --accent: #FFC864;
  --text-dim: rgba(255, 255, 255, .82);
  --card-bg: rgba(255, 255, 255, .12);
  --card-bg-strong: rgba(255, 255, 255, .2);
  --card-border: rgba(255, 255, 255, .26);
  --radius: 24px;
  --bar-track: rgba(255, 255, 255, .22);
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Noto Sans SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  color: #fff;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background: #2E7BD0; /* 与白天主题顶色一致，防止过滚动露底 */
}
body.theme-night { background: #0B1B3A; }

/* ---------------- 动态天空 ---------------- */
#sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  transition: opacity .45s ease;
}
#sky.fading { opacity: 0; }
#sky > i, #sky > b, #sky > div { position: absolute; display: block; }

/* 白天各天气的天空 */
body.theme-day.sky-sunny    #sky { background: linear-gradient(180deg, #2E7BD0 0%, #63A7E4 52%, #A6D3F5 100%); }
body.theme-day.sky-cloudy   #sky { background: linear-gradient(180deg, #5D84B0 0%, #8FB4D4 55%, #C2D9EA 100%); }
body.theme-day.sky-overcast #sky { background: linear-gradient(180deg, #5B6B7C 0%, #8494A5 55%, #AEBBC7 100%); }
body.theme-day.sky-rain     #sky { background: linear-gradient(180deg, #3D5166 0%, #5E7590 55%, #8699AC 100%); }
body.theme-day.sky-thunder  #sky { background: linear-gradient(180deg, #2E3A52 0%, #46526E 55%, #5F6C8A 100%); }
body.theme-day.sky-snow     #sky { background: linear-gradient(180deg, #6E8CAD 0%, #A3BDD6 55%, #D6E5F0 100%); }
body.theme-day.sky-fog      #sky { background: linear-gradient(180deg, #7C8790 0%, #A5ADB3 55%, #C8CDD1 100%); }
body.theme-day.sky-dust     #sky { background: linear-gradient(180deg, #96805F 0%, #BEA987 55%, #DCCCA9 100%); }

/* 夜间各天气的天空 */
body.theme-night.sky-sunny    #sky { background: linear-gradient(180deg, #0B1B3A 0%, #14294E 55%, #1F3A66 100%); }
body.theme-night.sky-cloudy   #sky { background: linear-gradient(180deg, #0E1B2C 0%, #1B2C42 55%, #2A4058 100%); }
body.theme-night.sky-overcast #sky { background: linear-gradient(180deg, #10151C 0%, #1C2430 55%, #2A3442 100%); }
body.theme-night.sky-rain     #sky { background: linear-gradient(180deg, #0A1220 0%, #16233A 55%, #243650 100%); }
body.theme-night.sky-thunder  #sky { background: linear-gradient(180deg, #080D1A 0%, #131B30 55%, #202A44 100%); }
body.theme-night.sky-snow     #sky { background: linear-gradient(180deg, #101D30 0%, #1D3049 55%, #2C4663 100%); }
body.theme-night.sky-fog      #sky { background: linear-gradient(180deg, #12161B 0%, #20262D 55%, #30383F 100%); }
body.theme-night.sky-dust     #sky { background: linear-gradient(180deg, #241D12 0%, #3A3020 55%, #524530 100%); }

/* 太阳 / 月亮 / 星星 */
.sun-core {
  top: 7%; right: 9%; width: 116px; height: 116px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #FFF7DA 0%, #FFD666 62%, #FFC94D 100%);
  box-shadow: 0 0 64px 20px rgba(255, 214, 102, .5);
  animation: breathe 6s ease-in-out infinite;
}
.sun-halo {
  top: calc(7% - 44px); right: calc(9% - 44px); width: 204px; height: 204px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 220, 120, .32) 0%, rgba(255, 220, 120, 0) 68%);
  animation: breathe 6s ease-in-out infinite reverse;
}
.moon {
  top: 8%; right: 11%; width: 86px; height: 86px; border-radius: 50%;
  background: radial-gradient(circle at 38% 38%, #FDFBE8 0%, #ECE8CC 62%, #D9D5B6 100%);
  box-shadow: 0 0 46px 14px rgba(253, 251, 232, .28), inset -14px -10px 0 rgba(90, 84, 40, .08);
}
.star {
  width: 2px; height: 2px; border-radius: 50%; background: #fff;
  animation: twinkle ease-in-out infinite;
}

/* 云 / 雨 / 雪 / 雾 / 尘 */
.cloud {
  --c: rgba(255, 255, 255, .92);
  border-radius: 100px;
  background: var(--c);
  filter: blur(2px);
  animation: drift linear infinite;
}
.theme-night .cloud { --c: rgba(255, 255, 255, .1); }
.sky-overcast .cloud { --c: rgba(228, 234, 240, .78); }
.theme-night.sky-overcast .cloud,
.theme-night.sky-rain .cloud,
.theme-night.sky-thunder .cloud { --c: rgba(255, 255, 255, .07); }
.cloud::before, .cloud::after { content: ''; position: absolute; background: var(--c); border-radius: 50%; }
.cloud::before { width: 55%; height: 170%; top: -75%; left: 16%; }
.cloud::after  { width: 42%; height: 130%; top: -45%; right: 10%; }

.drop {
  top: -26px; width: 2px; border-radius: 2px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, .6));
  animation: fall linear infinite;
}
.flake {
  top: -12px; border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  filter: blur(.6px);
  animation: snowfall linear infinite;
}
.fog {
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  filter: blur(30px);
  animation: sway ease-in-out infinite alternate;
}
.theme-night .fog { background: rgba(255, 255, 255, .07); }
.dust-tint { inset: 0; background: rgba(214, 178, 116, .16); }
.lightning {
  inset: 0;
  background: rgba(255, 255, 255, .85);
  opacity: 0;
  animation: flash 8s infinite;
}

@keyframes drift    { from { transform: translateX(-32vw); } to { transform: translateX(112vw); } }
@keyframes fall     { to { transform: translateY(112vh); } }
@keyframes snowfall { to { transform: translate(7vw, 112vh); } }
@keyframes twinkle  { 0%, 100% { opacity: .15; } 50% { opacity: .95; } }
@keyframes breathe  { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes flash    { 0%, 86%, 91%, 100% { opacity: 0; } 88% { opacity: .55; } 89.5% { opacity: .12; } }
@keyframes sway     { from { transform: translateX(-5vw); } to { transform: translateX(5vw); } }
@keyframes float    { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes rise     { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes spin     { to { transform: rotate(360deg); } }

/* ---------------- 页面骨架 ---------------- */
.page {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 2px 10px;
}
.brand-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
  color: inherit;
  background: none;
  border: none;
  padding: 6px 10px;
  margin-left: -10px;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .2);
  transition: background .3s ease;
}
.brand-btn:hover { background: rgba(255, 255, 255, .12); }
.brand-btn > svg { width: 22px; height: 22px; }
.brand-btn .chev { width: 14px; height: 14px; opacity: .8; transition: transform .3s ease; }
.brand-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }

.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform .2s ease, background .3s ease;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--card-bg-strong); }
.icon-btn:active { transform: scale(.9); }

:focus-visible { outline: 2px solid #fff; outline-offset: 3px; border-radius: 8px; }

.glass {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .14);
}

/* ---------------- 实况主区 ---------------- */
.hero {
  text-align: center;
  padding: 20px 12px 30px;
  animation: rise .6s ease both;
}
.hero-icon {
  width: 112px; height: 112px;
  object-fit: contain;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, .28));
  animation: float 5s ease-in-out infinite;
}
.hero-temp {
  font-size: clamp(84px, 17vw, 128px);
  font-weight: 200;
  line-height: 1.05;
  letter-spacing: -3px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 4px 28px rgba(0, 0, 0, .18);
}
.hero-temp .deg {
  font-size: .48em;
  font-weight: 300;
  vertical-align: .58em;
  margin-left: 3px;
  letter-spacing: 0;
}
.hero-desc { font-size: 20px; font-weight: 500; margin-top: 2px; }
.hero-range { font-size: 14px; color: var(--text-dim); margin-top: 6px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .22);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.chip svg { width: 14px; height: 14px; opacity: .9; }

.hero-time { margin-top: 16px; font-size: 12px; color: var(--text-dim); }

/* ---------------- 卡片通用 ---------------- */
.card {
  margin-top: 16px;
  padding: 20px 22px;
  animation: rise .6s ease both;
  animation-delay: .08s;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
}
.card-head svg { width: 17px; height: 17px; opacity: .85; }

/* ---------------- 四天预报 ---------------- */
.fc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.fc-col {
  text-align: center;
  padding: 14px 4px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid transparent;
  transition: background .3s ease;
}
.fc-col.today {
  background: rgba(255, 255, 255, .15);
  border-color: rgba(255, 255, 255, .3);
}
.fc-week { font-size: 13px; font-weight: 700; }
.fc-col.today .fc-week { color: var(--accent); }
.fc-date { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.fc-icon { width: 52px; height: 52px; margin: 8px auto 0; display: block; object-fit: contain; }
.fc-w { font-size: 13px; margin-top: 2px; white-space: nowrap; }
.fc-hi { font-size: 20px; font-weight: 700; margin-top: 10px; font-variant-numeric: tabular-nums; }
.fc-bar {
  position: relative;
  height: 6px;
  border-radius: 4px;
  background: var(--bar-track);
  margin: 8px 8px 6px;
}
.fc-bar i {
  position: absolute;
  top: 0; bottom: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, #6EC6FF, #FFB74D);
}
.fc-lo { font-size: 14px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.fc-night {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 7px;
  font-size: 11px;
  color: var(--text-dim);
}
.fc-night img { width: 17px; height: 17px; object-fit: contain; opacity: .85; }
.fc-wind { font-size: 11px; color: var(--text-dim); margin-top: 6px; white-space: nowrap; }

/* ---------------- 实况详情 + 今日提示 ---------------- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.two-col .card { margin-top: 0; animation-delay: .16s; }

.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.tile {
  text-align: center;
  padding: 14px 6px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .07);
}
.tile svg { width: 20px; height: 20px; opacity: .8; }
.tile-value { font-size: 16px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tile-label { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.tips { display: flex; flex-direction: column; gap: 10px; }
.tip {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .07);
}
.tip > svg { width: 19px; height: 19px; flex: none; margin-top: 2px; color: var(--accent); }
.tip-title { font-size: 13px; font-weight: 700; }
.tip-text { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; line-height: 1.55; text-align: left; }

/* ---------------- 加载 / 错误状态 ---------------- */
.state-card {
  margin-top: 60px;
  padding: 44px 20px;
  text-align: center;
  animation: rise .5s ease both;
}
.state-card svg { width: 38px; height: 38px; opacity: .9; }
.state-card p { margin-top: 12px; font-size: 14px; color: var(--text-dim); }
.spinner {
  width: 34px; height: 34px; margin: 0 auto;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .25);
  border-top-color: #fff;
  animation: spin 1s linear infinite;
}
.retry-btn {
  margin-top: 16px;
  padding: 9px 24px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .4);
  background: rgba(255, 255, 255, .15);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: background .3s ease;
}
.retry-btn:hover { background: rgba(255, 255, 255, .26); }

/* ---------------- 页脚 ---------------- */
.footer {
  text-align: center;
  font-size: 11px;
  color: rgba(255, 255, 255, .55);
  margin-top: 30px;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 640px) {
  .fc-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .hero-icon { width: 92px; height: 92px; }
  .card { padding: 16px; }
}

/* ---------------- 城市切换 ---------------- */
.city-menu {
  position: absolute;
  top: 64px;
  left: 20px;
  right: 20px;
  max-width: 420px;
  z-index: 30;
  padding: 16px;
  animation: rise .3s ease both;
}
.city-search { display: flex; gap: 8px; margin-bottom: 12px; }
.city-search input {
  flex: 1;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font: inherit;
  font-size: 14px;
  outline: none;
  min-width: 0;
}
.city-search input::placeholder { color: rgba(255, 255, 255, .55); }
.city-search input:focus { border-color: rgba(255, 255, 255, .5); }
.city-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.city-chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background .3s ease;
}
.city-chip:hover { background: rgba(255, 255, 255, .22); }
.city-chip.active { background: rgba(255, 255, 255, .28); border-color: rgba(255, 255, 255, .45); }
.city-results { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; margin-top: 10px; }
.city-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .08);
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
}
.city-result:hover { background: rgba(255, 255, 255, .18); }
.city-result small { color: var(--text-dim); font-size: 11px; flex: none; }
.city-empty { font-size: 12.5px; color: var(--text-dim); text-align: center; padding: 10px 0 4px; }

/* ---------------- 24 小时预报（桌面两行铺满 / 移动端单行滑动） ---------------- */
.hourly-wrap { position: relative; }
.hourly-strip {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px 3px;
}
.hour {
  min-width: 0;
  overflow: hidden;
  text-align: center;
  padding: 8px 0 7px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .06);
}
.hour.now { background: rgba(255, 255, 255, .18); }
.hour-time { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.hour.now .hour-time { color: var(--accent); font-weight: 700; }
.hour-icon { width: 32px; height: 32px; object-fit: contain; margin: 4px auto 0; display: block; }
.hour-temp { font-size: 14px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.hour-precip {
  font-size: 10.5px;
  color: #9FD8FF;
  margin-top: 2px;
  min-height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hour-precip svg { width: 9px; height: 9px; flex: none; }

.strip-arrow {
  display: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: rgba(18, 28, 46, .55);
  color: #fff;
  cursor: pointer;
  padding: 0;
  place-items: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
  z-index: 2;
  transition: opacity .25s ease, background .3s ease;
}
.strip-arrow svg { width: 16px; height: 16px; }
.strip-arrow.left { left: -8px; }
.strip-arrow.right { right: -8px; }
.strip-arrow:disabled { opacity: 0; pointer-events: none; }
.strip-arrow:not(:disabled):hover { background: rgba(30, 45, 72, .78); }
.strip-arrow:active { transform: translateY(-50%) scale(.92); }

@media (max-width: 640px) {
  .hourly-strip {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    padding: 2px 2px 8px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .hourly-strip::-webkit-scrollbar { display: none; }
  .hour {
    flex: 0 0 54px;
    scroll-snap-align: start;
  }
  .strip-arrow { display: grid; }
}

/* ---------------- 温度趋势曲线 ---------------- */
.trend { margin: 2px 0 14px; }
.trend svg { display: block; width: 100%; height: auto; }
.trend-line { fill: none; stroke-width: 2; stroke-linecap: round; }
.trend-line.hi { stroke: #FFC864; }
.trend-line.lo { stroke: #7CC4FF; stroke-dasharray: 5 5; }
.trend-dot.hi { fill: #FFC864; }
.trend-dot.lo { fill: #7CC4FF; }
.trend-label { font-size: 11.5px; font-weight: 700; fill: rgba(255, 255, 255, .95); }
.trend-label.lo { fill: var(--text-dim); font-weight: 400; }

.card-note { margin-top: 12px; font-size: 10.5px; color: rgba(255, 255, 255, .5); line-height: 1.6; }

@media (max-width: 640px) {
  .city-menu { left: 12px; right: 12px; }
}

/* ---------------- 动效减免 ---------------- */
@media (prefers-reduced-motion: reduce) {
  .cloud, .drop, .flake, .star, .sun-core, .sun-halo, .lightning, .fog,
  .hero-icon, .hero, .card, .state-card, .city-menu { animation: none !important; }
  #sky, .icon-btn, .retry-btn, .brand-btn, .brand-btn .chev, .city-chip { transition: none !important; }
}
