/* ========================================
   Atmos Weather · 沉浸式天气体验 v2
   设计语言：多层叠加粒子 + 大气光 + 噪点质感
   参考：Awwwards 2025 Dark Glassmorphism 趋势
   参考：markparayno.com/portfolio/weather 粒子系统
   参考：studiolimb.com 三层景深雪效果
   ======================================== */

:root {
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.16);
  --text: #f0f4ff;
  --text-muted: rgba(240, 244, 255, 0.65);
  --accent: #ffd54a;
  --accent-glow: rgba(255, 213, 74, 0.35);
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow-lg: 0 24px 80px rgba(0, 0, 0, 0.45);
}

/* === 天气主题变量（动态切换） === */
body[data-weather="clear-day"] {
  --sky-top: #1a365d;
  --sky-mid: #2d5a87;
  --sky-bot: #4a90d9;
  --horizon: #87ceeb;
  --glow: rgba(255, 200, 80, 0.5);
  --accent: #ffd54a;
  --accent-glow: rgba(255, 213, 74, 0.5);
}
body[data-weather="clear-night"] {
  --sky-top: #050814;
  --sky-mid: #0a1025;
  --sky-bot: #151c3a;
  --horizon: #1a2350;
  --glow: rgba(180, 200, 255, 0.3);
  --accent: #a0c4ff;
  --accent-glow: rgba(160, 196, 255, 0.4);
}
body[data-weather="cloudy"] {
  --sky-top: #3d4f5f;
  --sky-mid: #5a6a7a;
  --sky-bot: #7b8a9a;
  --horizon: #94a3b3;
  --glow: rgba(180, 190, 200, 0.3);
  --accent: #b0b8c4;
  --accent-glow: rgba(176, 184, 196, 0.4);
}
body[data-weather="rain"] {
  --sky-top: #1a2332;
  --sky-mid: #2c3e50;
  --sky-bot: #3d4f5f;
  --horizon: #5a6a7a;
  --glow: rgba(150, 170, 200, 0.25);
  --accent: #7ab8ff;
  --accent-glow: rgba(122, 184, 255, 0.45);
}
body[data-weather="snow"] {
  --sky-top: #4a5568;
  --sky-mid: #5c6e80;
  --sky-bot: #7b8a9a;
  --horizon: #a0b4c8;
  --glow: rgba(200, 210, 220, 0.35);
  --accent: #e8f0ff;
  --accent-glow: rgba(232, 240, 255, 0.5);
}
body[data-weather="fog"] {
  --sky-top: #565e68;
  --sky-mid: #6b7280;
  --sky-bot: #8a94a0;
  --horizon: #a0aab4;
  --glow: rgba(200, 205, 210, 0.3);
  --accent: #c8cfd6;
  --accent-glow: rgba(200, 207, 214, 0.4);
}

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

body {
  font-family: 'Noto Sans SC', 'PingFang SC', sans-serif;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  background: var(--sky-top);
}

.hidden { display: none !important; }

/* ========================================
   1. 大气背景层（3D 深度感的核心）
   ======================================== */
.atmosphere-layer {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  transition: background 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 多层天空渐变（模拟大气散射） */
.sky-gradient {
  position: absolute;
  inset: 0;
  background:
    /* 底部地平线暖色 */
    linear-gradient(to top,
      var(--horizon) 0%,
      var(--sky-bot) 25%,
      var(--sky-mid) 55%,
      var(--sky-top) 90%
    );
  transition: all 1.2s ease;
}

/* 太阳/月亮光晕（右上偏置） */
.sun-moon-glow {
  position: absolute;
  top: -15%;
  right: -10%;
  width: 70%;
  height: 70%;
  background: radial-gradient(
    circle at 70% 30%,
    var(--glow) 0%,
    transparent 50%
  );
  animation: breathe 8s ease-in-out infinite;
  mix-blend-mode: screen;
}

@keyframes breathe {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.08); }
}

/* 光束漏射（丁达尔效应） */
.light-leaks {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 120px 400px at 20% 0%, rgba(255, 220, 150, 0.12), transparent),
    radial-gradient(ellipse 80px 300px at 60% 0%, rgba(255, 220, 150, 0.08), transparent),
    radial-gradient(ellipse 150px 500px at 85% 0%, rgba(255, 220, 150, 0.1), transparent);
  animation: lightShift 12s ease-in-out infinite alternate;
  mix-blend-mode: screen;
}

@keyframes lightShift {
  0%   { transform: translateX(-5%); opacity: 0.8; }
  100% { transform: translateX(3%);  opacity: 1; }
}

/* 暗角（vignette） */
.vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 120% 80% at 50% 50%,
      transparent 50%,
      rgba(0, 0, 0, 0.45) 100%
    );
  pointer-events: none;
}

/* ========================================
   2. 云层系统（SVG 形状 + 视差漂移）
   ======================================== */
.cloud-system {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s ease;
  overflow: hidden;
}

body[data-weather="cloudy"] .cloud-system,
body[data-weather="rain"] .cloud-system,
body[data-weather="snow"] .cloud-system,
body[data-weather="fog"] .cloud-system {
  opacity: 1;
}

/* 太阳天也有少量薄云 */
body[data-weather="clear-day"] .cloud-system {
  opacity: 0.25;
}

.cloud-svg {
  position: absolute;
  pointer-events: none;
  will-change: transform;
}

.cloud-svg svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.25));
}

/* 不同层级不同速度 */
.cloud-svg.layer-far {
  opacity: 0.35;
  animation: cloudDrift 60s linear infinite;
}

.cloud-svg.layer-mid {
  opacity: 0.55;
  animation: cloudDrift 40s linear infinite;
}

.cloud-svg.layer-near {
  opacity: 0.75;
  animation: cloudDrift 28s linear infinite;
}

@keyframes cloudDrift {
  0%   { transform: translateX(-20vw); }
  100% { transform: translateX(120vw); }
}

/* 雷暴云：更暗更低 */
body[data-weather="rain"] .cloud-svg,
body[data-weather="storm"] .cloud-svg {
  filter: brightness(0.7) saturate(0.6);
}

/* ========================================
   3. Canvas 粒子引擎层（js/effects.js）
   ======================================== */
.weather-canvas {
  position: fixed;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

/* ========================================
   4. 噪点纹理层
   ======================================== */
.grain-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0.06;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grainShift 8s steps(10) infinite;
}

@keyframes grainShift {
  0%, 100% { transform: translate(0, 0); }
  10%      { transform: translate(-5%, -5%); }
  20%      { transform: translate(-10%, 5%); }
  30%      { transform: translate(5%, -10%); }
  40%      { transform: translate(-5%, 15%); }
  50%      { transform: translate(-10%, 5%); }
  60%      { transform: translate(15%, 0); }
  70%      { transform: translate(0, 10%); }
  80%      { transform: translate(-15%, 0); }
  90%      { transform: translate(10%, 5%); }
}

/* ========================================
   主容器 & UI 样式
   ======================================== */
.container {
  position: relative;
  z-index: 20;
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* --- 搜索区 --- */
.search-section {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.brand-icon svg {
  width: 24px;
  height: 24px;
  color: var(--accent);
  filter: drop-shadow(0 0 10px var(--accent-glow));
}

.brand:hover .brand-icon {
  transform: scale(1.08);
}

.brand-text h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.brand-text span {
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.search-form {
  flex: 1;
  min-width: 200px;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 4px 4px 4px 44px;
  transition: all 0.3s ease;
}

.search-input-wrap:focus-within {
  background: rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 213, 74, 0.5);
  box-shadow: 0 0 0 4px rgba(255, 213, 74, 0.1);
}

.search-icon {
  position: absolute;
  left: 16px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.search-input-wrap input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  padding: 8px 12px 8px 4px;
}

.search-input-wrap input::placeholder {
  color: var(--text-muted);
}

.search-btn {
  padding: 9px 20px;
  border-radius: 999px;
  background: var(--accent);
  color: #1a1a2e;
  font-weight: 600;
  font-size: 13px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.search-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.location-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.location-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  border-color: var(--accent);
}

.location-btn svg {
  width: 16px;
  height: 16px;
}

/* --- 欢迎/加载/错误屏 --- */
.welcome, .loading, .error {
  text-align: center;
  padding: 80px 20px;
  animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.welcome-icon, .error-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  color: var(--accent);
  filter: drop-shadow(0 0 20px var(--accent-glow));
}

.welcome-icon svg, .error-icon svg {
  width: 100%;
  height: 100%;
}

.welcome h2, .error h3 {
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  font-weight: 600;
  margin-bottom: 10px;
}

.welcome p, .error p {
  color: var(--text-muted);
  font-size: 14px;
}

.loader {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border: 2.5px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading p {
  color: var(--text-muted);
  font-size: 13px;
}

/* --- 内容屏 --- */
.content {
  animation: fadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.location-bar {
  text-align: center;
  margin-bottom: 24px;
}

.location-bar h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.8rem, 4.5vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.location-bar .country {
  font-size: 12px;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* 毛玻璃卡片 */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg),
              inset 0 1px 0 rgba(255, 255, 255, 0.08),
              inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  transition: background 0.3s ease, transform 0.3s ease;
}

.glass-card:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* 主天气卡片 */
.main-weather {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 32px 28px;
  margin-bottom: 20px;
}

.weather-icon-big {
  flex-shrink: 0;
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.weather-icon-big svg {
  width: 100%;
  height: 100%;
  color: var(--accent);
  filter: drop-shadow(0 4px 28px var(--accent-glow));
}

.weather-info {
  flex: 1;
  min-width: 0;
}

.temperature {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(3rem, 7vw, 4.5rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  display: flex;
  align-items: baseline;
}

.temperature .unit {
  font-size: 0.35em;
  font-weight: 400;
  margin-left: 6px;
  color: var(--text-muted);
}

.weather-desc {
  font-size: 1.1rem;
  font-weight: 500;
  margin: 6px 0 4px;
}

.feels-like {
  font-size: 13px;
  color: var(--text-muted);
}

.feels-like span {
  color: var(--text);
  font-weight: 600;
}

/* 详细数据网格 */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.detail-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-icon {
  width: 32px;
  height: 32px;
  color: var(--accent);
  display: flex;
}

.card-icon svg {
  width: 100%;
  height: 100%;
}

.card-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.card-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* 小时/日预报 */
.hourly-card, .daily-card {
  padding: 22px;
  margin-bottom: 20px;
}

.card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.hourly-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

.hourly-scroll::-webkit-scrollbar { height: 3px; }
.hourly-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.hourly-item {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  min-width: 56px;
  transition: background 0.3s ease;
}

.hourly-item:hover {
  background: rgba(255, 255, 255, 0.12);
}

.hourly-item .time {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.hourly-item .icon {
  width: 26px;
  height: 26px;
  color: var(--accent);
}

.hourly-item .temp {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 600;
}

/* 日预报 */
.daily-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.daily-item {
  display: grid;
  grid-template-columns: 80px 32px 1fr 90px;
  align-items: center;
  gap: 14px;
  padding: 12px 6px;
  border-radius: var(--radius-sm);
  transition: background 0.3s ease;
}

.daily-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.daily-item .day {
  font-size: 13px;
  font-weight: 500;
}

.daily-item .icon {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.daily-item .desc {
  font-size: 12px;
  color: var(--text-muted);
}

.daily-item .temps {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.daily-item .temp-min {
  color: var(--text-muted);
  font-weight: 500;
}

/* ========================================
   响应式
   ======================================== */
@media (max-width: 640px) {
  .container { padding: 18px 14px 40px; }

  .brand-text h1 { font-size: 1.2rem; }
  .brand-text span { display: none; }

  .main-weather {
    flex-direction: column;
    text-align: center;
    padding: 24px 20px;
    gap: 18px;
  }

  .weather-icon-big { width: 72px; height: 72px; }
  .temperature { justify-content: center; }

  .detail-grid { gap: 10px; }
  .detail-card { padding: 14px; }
  .card-value { font-size: 1.2rem; }

  .daily-item {
    grid-template-columns: 60px 28px 1fr 75px;
    gap: 8px;
  }
  .daily-item .desc { display: none; }

  .hourly-card, .daily-card { padding: 18px 16px; }
}

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