@import url("https://fonts.googleapis.com/css2?family=Fraunces:wght@300;500;700&family=Space+Grotesk:wght@400;500;600&display=swap");

:root {
  --frame: #1e2026;
  --glass: rgba(255, 255, 255, 0.14);
  --glass-border: rgba(255, 255, 255, 0.35);
  --glow: rgba(255, 255, 255, 0.45);
  --text: #e9edf6;
  --muted: rgba(255, 255, 255, 0.7);
  --accent: #ffcf6d;
  --shadow: rgba(7, 12, 24, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top, #2a3148 0%, #121520 60%, #0b0d14 100%),
    linear-gradient(120deg, rgba(255, 255, 255, 0.08), transparent 40%);
  color: var(--text);
  font-family: "Space Grotesk", system-ui, sans-serif;
}

.stage {
  width: min(92vw, 820px);
}

.window {
  position: relative;
  padding: 28px;
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(0, 0, 0, 0.2));
  box-shadow: 0 30px 80px var(--shadow);
}

.frame {
  border-radius: 24px;
  background: var(--frame);
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.scene {
  position: relative;
  height: 360px;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(180deg, #6db4ff 0%, #b7ddff 70%, #fef4d9 100%);
  transition: background 0.6s ease;
  background-position: calc(50% + var(--px, 0px)) calc(50% + var(--py, 0px));
  background-size: 120% 120%;
  --mist-opacity: 0;
  --mist-blur: 0px;
  --streak-opacity: 0;
  --px: 0px;
  --py: 0px;
  --flag-tilt: -12;
  --flag-sway: 4;
  --flag-stretch: 0.75;
  --flag-speed: 4.2s;
}

.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.1), transparent 40%);
  pointer-events: none;
}

.sky {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.55), transparent 45%);
  opacity: 0.7;
  transform: translate(calc(var(--px) * 0.35), calc(var(--py) * 0.35));
  transition: transform 0.2s ease;
}

.sun,
.moon {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  top: 40px;
  right: 80px;
  transition: opacity 0.4s ease, transform 0.2s ease;
  transform: translate(calc(var(--px) * 0.5), calc(var(--py) * 0.4));
}

.sun {
  background: radial-gradient(circle at 30% 30%, #fff6c6, #ffb347 70%);
  box-shadow: 0 0 50px rgba(255, 200, 120, 0.65);
  z-index: 2;
}

.moon {
  position: absolute;
  background: radial-gradient(circle at 30% 30%, #f5f7ff, #b3c3ff 70%);
  box-shadow: 0 0 36px rgba(163, 185, 255, 0.7);
  opacity: 0;
  overflow: hidden;
  z-index: 2;
}

.moon::after {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(20, 26, 44, 0.95), rgba(20, 26, 44, 1));
  transform: translateX(40%);
}

.cloud {
  position: absolute;
  width: 220px;
  height: 80px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50px;
  top: 90px;
  left: -40px;
  filter: blur(0.3px);
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.2s ease;
  transform: translate(calc(var(--px) * 0.85), calc(var(--py) * 0.55));
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  top: -35px;
  left: 25px;
}

.cloud::after {
  width: 120px;
  height: 120px;
  top: -60px;
  left: 90px;
}

.cloud-b {
  width: 260px;
  top: 160px;
  left: -80px;
  opacity: 0;
  transform: translate(calc(var(--px) * 1.05), calc(var(--py) * 0.7));
}

.rain,
.snow,
.fog {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.rain::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
      120deg,
      rgba(255, 255, 255, 0.6) 0px,
      rgba(255, 255, 255, 0.6) 2px,
      transparent 2px,
      transparent 14px
    );
  background-size: 40px 60px;
  animation: rain 0.8s linear infinite;
}

.snow::before {
  content: "";
  position: absolute;
  inset: -20px;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0 2px, transparent 3px);
  background-size: 30px 30px;
  animation: snow 6s linear infinite;
}

.fog::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.5));
  opacity: 0.7;
  filter: blur(12px);
  animation: fog 10s ease-in-out infinite;
}

.bolt {
  position: absolute;
  width: 120px;
  height: 220px;
  background: linear-gradient(135deg, transparent 40%, rgba(255, 255, 255, 0.9) 42%, transparent 60%);
  top: 60px;
  right: 120px;
  opacity: 0;
  filter: drop-shadow(0 0 18px rgba(255, 255, 255, 0.8));
}

.flag {
  position: absolute;
  right: 36px;
  bottom: 26px;
  width: 90px;
  height: 100px;
  z-index: 8;
}

.flag .pole {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 2px;
  height: 82px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.35), 0 2px 6px rgba(0, 0, 0, 0.15);
}

.flag .cloth {
  position: absolute;
  right: 2px;
  bottom: 58px;
  width: 56px;
  height: 26px;
  background: rgba(138, 187, 255, 0.85);
  clip-path: polygon(0 50%, 100% 0, 100% 100%);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.18);
  transform-origin: 100% 50%;
  transform: rotate(calc(var(--flag-tilt) * 1deg)) scaleX(var(--flag-stretch));
  animation: flag-sway var(--flag-speed) ease-in-out infinite;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15));
}

.humidity,
.streaks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.humidity {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.05));
  opacity: var(--mist-opacity);
  filter: blur(var(--mist-blur));
  transition: opacity 0.6s ease, filter 0.6s ease;
  mix-blend-mode: screen;
  z-index: 6;
}

.streaks {
  opacity: var(--streak-opacity);
  z-index: 7;
}

.streaks::before,
.streaks::after {
  content: "";
  position: absolute;
  inset: -20% 0;
  background-image: repeating-linear-gradient(95deg, rgba(255, 255, 255, 0.35) 0 2px, transparent 2px 18px);
  background-size: 60px 140px;
  animation: streaks 16s linear infinite;
  opacity: 0.55;
}

.streaks::after {
  background-size: 90px 180px;
  animation-duration: 22s;
  background-position-x: 30px;
  opacity: 0.35;
}

.glass {
  margin-top: 20px;
  padding: 20px 22px;
  border-radius: 20px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  backdrop-filter: blur(16px);
}

.readout {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.temp {
  font-family: "Fraunces", serif;
  font-size: clamp(36px, 4vw, 52px);
  letter-spacing: 1px;
}

.city {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.meta {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.68);
  letter-spacing: 0.08em;
}

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

.search-input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  outline: none;
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

.search-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.search-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.8);
}

.sound-toggle {
  height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.sound-toggle::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  right: 10px;
  top: 9px;
  opacity: 0.6;
  transition: opacity 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.sound-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.8);
}

.window.sound-on .sound-toggle {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.9);
}

.window.sound-on .sound-toggle::after {
  opacity: 1;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(255, 209, 125, 0.8);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(255, 209, 125, 0.7);
}

.window.loading .dot {
  animation: pulse 1s ease-in-out infinite;
}

.window.error .glass {
  border-color: rgba(255, 120, 120, 0.6);
}

.scene[data-condition="clear"][data-day="true"] {
  background: linear-gradient(180deg, #63b4ff 0%, #bfe3ff 70%, #fdf2d8 100%);
}

.scene[data-condition="clear"][data-day="false"] {
  background: linear-gradient(180deg, #1b2440 0%, #3a4968 70%, #6a6f85 100%);
}

.scene[data-condition="clouds"] {
  background: linear-gradient(180deg, #8aa4c0 0%, #cdd8e9 70%, #f3f4f6 100%);
}

.scene[data-condition="rain"] {
  background: linear-gradient(180deg, #61738c 0%, #9bb3c8 70%, #cfd6dd 100%);
}

.scene[data-condition="rain"],
.scene[data-condition="thunder"] {
  --streak-opacity: 0.55;
}

.scene[data-condition="snow"] {
  background: linear-gradient(180deg, #c7d8ef 0%, #e8eef7 70%, #f8fbff 100%);
}

.scene[data-condition="fog"] {
  background: linear-gradient(180deg, #9aa6b2 0%, #cbd3da 70%, #e6e8eb 100%);
}

.scene[data-condition="thunder"] {
  background: linear-gradient(180deg, #4c556b 0%, #7a859a 70%, #b4b8c4 100%);
}

.scene[data-condition="clear"] .cloud,
.scene[data-condition="clear"] .cloud-b {
  opacity: 0.15;
}

.scene[data-condition="clouds"] .cloud,
.scene[data-condition="clouds"] .cloud-b {
  opacity: 0.75;
}

.scene[data-condition="rain"] .cloud,
.scene[data-condition="rain"] .cloud-b,
.scene[data-condition="thunder"] .cloud,
.scene[data-condition="thunder"] .cloud-b {
  opacity: 0.9;
}

.scene[data-condition="rain"] .rain,
.scene[data-condition="thunder"] .rain {
  opacity: 0.7;
}

.scene[data-condition="snow"] .snow {
  opacity: 0.8;
}

.scene[data-condition="fog"] .fog {
  opacity: 0.8;
}

.scene[data-condition="thunder"] .bolt {
  opacity: 1;
  animation: lightning 2.8s infinite;
}

.scene[data-day="false"] .sun {
  opacity: 0;
}

.scene[data-day="false"] .moon {
  opacity: 1;
}

.scene.night .sun {
  opacity: 0;
  visibility: hidden;
}

.scene.night .moon {
  opacity: 1;
}

.scene.night .sky {
  opacity: 0.2;
}

@keyframes rain {
  from {
    transform: translateY(-30px);
  }
  to {
    transform: translateY(30px);
  }
}

@keyframes snow {
  from {
    transform: translateY(-20px);
  }
  to {
    transform: translateY(40px);
  }
}

@keyframes fog {
  0%,
  100% {
    transform: translateX(-10%);
  }
  50% {
    transform: translateX(10%);
  }
}

@keyframes lightning {
  0%,
  90%,
  100% {
    opacity: 0;
  }
  92% {
    opacity: 1;
  }
  95% {
    opacity: 0;
  }
}

@keyframes streaks {
  from {
    background-position-y: -120px;
  }
  to {
    background-position-y: 120px;
  }
}

@keyframes flag-sway {
  0%,
  100% {
    transform: rotate(calc((var(--flag-tilt) - var(--flag-sway)) * 1deg)) scaleX(var(--flag-stretch));
  }
  50% {
    transform: rotate(calc((var(--flag-tilt) + var(--flag-sway)) * 1deg)) scaleX(var(--flag-stretch));
  }
}

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

@media (max-width: 720px) {
  .scene {
    height: 280px;
  }

  .glass {
    flex-direction: column;
    align-items: flex-start;
  }

  .search {
    width: 100%;
  }

  .sound-toggle {
    align-self: flex-start;
  }
}
