/* ── @property: animatable custom properties ── */
@property --accent {
  syntax: "<color>";
  inherits: true;
  initial-value: #60a5fa;
}

@property --bg-tint {
  syntax: "<color>";
  inherits: true;
  initial-value: #0f172a;
}

@property --glass-tint {
  syntax: "<color>";
  inherits: true;
  initial-value: rgba(255, 255, 255, 0.06);
}

/* ── google font ── */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

/* ── theme tokens ── */
:root {
  --bg-primary: #0a0a0f;
  --text-primary: #f0f0f0;
  --text-secondary: #a0a0b0;
  --text-muted: #6b6b7b;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --transition: 0.3s ease;
  --max-width: 420px;
}

/* ── weather-dependent tokens (animated via @property) ── */
[data-weather="Clear"] {
  --accent: #fbbf24;
  --bg-tint: #1a1508;
  --glass-tint: rgba(251, 191, 36, 0.06);
}

[data-weather="Clouds"] {
  --accent: #94a3b8;
  --bg-tint: #0f1219;
  --glass-tint: rgba(148, 163, 184, 0.06);
}

[data-weather="Rain"] {
  --accent: #60a5fa;
  --bg-tint: #0a1628;
  --glass-tint: rgba(96, 165, 250, 0.06);
}

[data-weather="Snow"] {
  --accent: #e2e8f0;
  --bg-tint: #0f1520;
  --glass-tint: rgba(226, 232, 240, 0.08);
}

[data-weather="Mist"] {
  --accent: #a78bfa;
  --bg-tint: #110f1a;
  --glass-tint: rgba(167, 139, 250, 0.06);
}

/* ── view transitions ── */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.5s;
}

/* ── reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg-tint);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  transition: background var(--transition), --accent 0.8s ease, --bg-tint 0.8s ease,
    --glass-tint 0.8s ease;
}

a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent);
}

/* ── app shell ── */
.app {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── search ── */
.search {
  display: flex;
  gap: 8px;
}

.search input {
  flex: 1;
  padding: 14px 16px;
  font-size: 15px;
  font-family: var(--font);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

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

.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

.search-btn {
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.search-btn:hover {
  filter: brightness(1.15);
}

.search-btn:active {
  transform: scale(0.95);
}

/* ── error ── */
.error {
  font-size: 13px;
  color: #f87171;
  text-align: center;
  min-height: 18px;
}

/* ── glass card ── */
.card {
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.5s ease;
}

.card-glass {
  background: var(--glass-tint);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  position: relative;
  overflow: hidden;
}

/* ── animation stage ── */
.animation-stage {
  position: relative;
  height: 120px;
  margin-bottom: 16px;
  overflow: hidden;
  border-radius: var(--radius-sm);
}

/* ── city & tagline ── */
.city {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.1;
  view-transition-name: city;
}

.tagline {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
  margin-bottom: 20px;
  line-height: 1.4;
}

/* ── temperature ── */
.temp-group {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 4px;
}

.temp {
  font-size: 64px;
  font-weight: 700;
  letter-spacing: -2px;
  line-height: 1;
  color: var(--accent);
  transition: color 0.8s ease;
  view-transition-name: temp;
}

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

.description {
  font-size: 15px;
  color: var(--text-secondary);
  text-transform: capitalize;
  margin-bottom: 20px;
}

/* ── meta row ── */
.meta-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
}

.meta-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.meta-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── forecast ── */
.forecast {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.forecast-day {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--glass-tint);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.forecast-day:hover {
  background: rgba(255, 255, 255, 0.08);
}

.forecast-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  width: 48px;
}

.forecast-icon {
  font-size: 20px;
  flex: 1;
  text-align: center;
}

.forecast-temp {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
  width: 48px;
}

/* ── footer ── */
.footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 16px 0;
  margin-top: auto;
}

/* ═══════════════════════════════════════════
   WEATHER ANIMATIONS
   ═══════════════════════════════════════════ */

/* ── sun ── */
.sun-anim {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sun-core {
  width: 48px;
  height: 48px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  position: relative;
  z-index: 2;
  animation: sunPulse 3s ease-in-out infinite;
}

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

.beam {
  position: absolute;
  width: 3px;
  height: 16px;
  background: var(--accent);
  top: 50%;
  left: 50%;
  transform-origin: 50% 0%;
  border-radius: 2px;
  animation: beamPulse 2s ease-in-out infinite alternate;
}

@keyframes beamPulse {
  0%, 100% { height: 16px; opacity: 0.6; }
  50% { height: 24px; opacity: 1; }
}

.beam-1 { transform: rotate(0deg) translateY(-44px); animation-delay: 0s; }
.beam-2 { transform: rotate(45deg) translateY(-44px); animation-delay: 0.25s; }
.beam-3 { transform: rotate(90deg) translateY(-44px); animation-delay: 0.5s; }
.beam-4 { transform: rotate(135deg) translateY(-44px); animation-delay: 0.75s; }
.beam-5 { transform: rotate(180deg) translateY(-44px); animation-delay: 1s; }
.beam-6 { transform: rotate(225deg) translateY(-44px); animation-delay: 1.25s; }
.beam-7 { transform: rotate(270deg) translateY(-44px); animation-delay: 1.5s; }
.beam-8 { transform: rotate(315deg) translateY(-44px); animation-delay: 1.75s; }

/* ── clouds ── */
.clouds-anim {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.cloud {
  position: absolute;
  opacity: 0.4;
  animation: cloudFloat linear infinite;
  filter: brightness(2);
}

.cloud-1 { width: 80px; top: 20px; animation-duration: 18s; }
.cloud-2 { width: 100px; top: 40px; animation-duration: 24s; animation-delay: -8s; }
.cloud-3 { width: 60px; top: 10px; animation-duration: 30s; animation-delay: -15s; }
.cloud-4 { width: 90px; top: 55px; animation-duration: 20s; animation-delay: -5s; }
.cloud-5 { width: 70px; top: 30px; animation-duration: 26s; animation-delay: -12s; }

@keyframes cloudFloat {
  from { transform: translateX(-120px); }
  to { transform: translateX(calc(100% + 120px)); }
}

/* ── rain ── */
.rain-anim {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.umbrella-icon {
  width: 56px;
  height: 56px;
  opacity: 0.5;
  filter: brightness(2);
  position: relative;
  z-index: 2;
}

.drop {
  position: absolute;
  width: 2px;
  height: 12px;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0.5;
  animation: rainFall 1s linear infinite;
}

.drop-1 { left: 8%; animation-delay: 0.1s; }
.drop-2 { left: 18%; animation-delay: 0.4s; }
.drop-3 { left: 32%; animation-delay: 0.7s; }
.drop-4 { left: 45%; animation-delay: 0.2s; }
.drop-5 { left: 58%; animation-delay: 0.5s; }
.drop-6 { left: 70%; animation-delay: 0.8s; }
.drop-7 { left: 82%; animation-delay: 0.3s; }
.drop-8 { left: 92%; animation-delay: 0.6s; }

@keyframes rainFall {
  0% { top: -12px; opacity: 0; }
  20% { opacity: 0.6; }
  100% { top: 100%; opacity: 0; }
}

/* ── snow ── */
.snow-anim {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.flake {
  position: absolute;
  font-size: 14px;
  opacity: 0;
  animation: snowFall linear infinite;
}

.flake-1 { left: 5%; animation-duration: 4s; animation-delay: 0s; }
.flake-2 { left: 15%; animation-duration: 5s; animation-delay: 1s; }
.flake-3 { left: 25%; animation-duration: 3.5s; animation-delay: 0.5s; }
.flake-4 { left: 35%; animation-duration: 4.5s; animation-delay: 2s; }
.flake-5 { left: 45%; animation-duration: 3s; animation-delay: 0.8s; }
.flake-6 { left: 55%; animation-duration: 5.5s; animation-delay: 1.5s; }
.flake-7 { left: 65%; animation-duration: 4s; animation-delay: 0.3s; }
.flake-8 { left: 75%; animation-duration: 3.8s; animation-delay: 1.8s; }
.flake-9 { left: 85%; animation-duration: 4.2s; animation-delay: 0.7s; }
.flake-10 { left: 92%; animation-duration: 5s; animation-delay: 2.5s; }
.flake-11 { left: 40%; animation-duration: 3.2s; animation-delay: 3s; }
.flake-12 { left: 60%; animation-duration: 4.8s; animation-delay: 1.2s; }

@keyframes snowFall {
  0% { top: -10%; opacity: 0; transform: translateX(0); }
  10% { opacity: 0.8; }
  100% { top: 100%; opacity: 0; transform: translateX(20px); }
}

/* ── mist ── */
.mist-anim {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.mist-layer {
  position: absolute;
  width: 200%;
  height: 40px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--accent) 30%,
    transparent 60%
  );
  opacity: 0.08;
  border-radius: 50%;
  animation: mistDrift linear infinite;
}

.mist-1 { top: 20%; animation-duration: 12s; }
.mist-2 { top: 45%; animation-duration: 16s; animation-delay: -5s; opacity: 0.06; }
.mist-3 { top: 70%; animation-duration: 20s; animation-delay: -10s; opacity: 0.04; }

@keyframes mistDrift {
  from { transform: translateX(-50%); }
  to { transform: translateX(0); }
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

@media (max-width: 400px) {
  .temp {
    font-size: 52px;
  }

  .meta-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .city {
    font-size: 26px;
  }
}

/* ── light theme ── */
@media (prefers-color-scheme: light) {
  :root {
    --bg-primary: #f5f5f5;
    --text-primary: #1a1a2e;
    --text-secondary: #555566;
    --text-muted: #888899;
    --border: rgba(0, 0, 0, 0.08);
  }

  [data-weather="Clear"] {
    --bg-tint: #fffbeb;
    --glass-tint: rgba(251, 191, 36, 0.08);
    --accent: #d97706;
  }

  [data-weather="Clouds"] {
    --bg-tint: #f1f5f9;
    --glass-tint: rgba(100, 116, 139, 0.06);
    --accent: #64748b;
  }

  [data-weather="Rain"] {
    --bg-tint: #eff6ff;
    --glass-tint: rgba(59, 130, 246, 0.06);
    --accent: #2563eb;
  }

  [data-weather="Snow"] {
    --bg-tint: #f0f4f8;
    --glass-tint: rgba(71, 85, 105, 0.06);
    --accent: #475569;
  }

  [data-weather="Mist"] {
    --bg-tint: #f5f3ff;
    --glass-tint: rgba(124, 58, 237, 0.06);
    --accent: #7c3aed;
  }

  .card-glass {
    background: var(--glass-tint);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  .search input {
    background: rgba(0, 0, 0, 0.03);
  }

  .cloud {
    opacity: 0.3;
    filter: none;
  }

  .umbrella-icon {
    filter: none;
    opacity: 0.4;
  }

  .search-btn {
    color: white;
  }
}
