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

:root {
  --font-display: 'DM Serif Display', serif;
  --font-body: 'DM Sans', sans-serif;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  overflow: hidden;
}

body {
  color: #fff;
  position: relative;
}

/* ── Backgrounds ── */
#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  transition: background 1.4s ease;
}

#bg.clear-day {
  background: linear-gradient(150deg, #1565c0 0%, #1e88e5 35%, #64b5f6 70%, #e3f2fd 100%);
}
#bg.clear-night {
  background: linear-gradient(150deg, #020818 0%, #0a1628 40%, #0d2148 70%, #162d6b 100%);
}
#bg.clouds {
  background: linear-gradient(150deg, #37474f 0%, #546e7a 40%, #78909c 70%, #b0bec5 100%);
}
#bg.rain {
  background: linear-gradient(150deg, #1a202c 0%, #243447 40%, #2d4059 70%, #3d5a73 100%);
}
#bg.snow {
  background: linear-gradient(150deg, #90a4ae 0%, #b0bec5 40%, #cfd8dc 70%, #eceff1 100%);
}
#bg.thunderstorm {
  background: linear-gradient(150deg, #12002f 0%, #1e0040 40%, #2d1060 70%, #3d1f7a 100%);
}
#bg.mist {
  background: linear-gradient(150deg, #607d8b 0%, #78909c 40%, #9eaeb8 70%, #cdd8de 100%);
}
#bg.default {
  background: linear-gradient(150deg, #0f1b35 0%, #162340 40%, #1a2d50 70%, #1e3566 100%);
}

/* ── Canvas ── */
#canvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* ── App layout ── */
#app {
  position: relative;
  z-index: 2;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

/* ── Search ── */
#search-wrap {
  display: flex;
  gap: 0;
  background: rgba(255,255,255,0.13);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 50px;
  padding: 6px 6px 6px 20px;
  width: min(460px, 90vw);
  animation: slideDown 0.6s var(--spring) both;
}

#city-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 400;
}

#city-input::placeholder {
  color: rgba(255,255,255,0.45);
}

#search-btn {
  background: rgba(255,255,255,0.22);
  border: none;
  border-radius: 40px;
  padding: 9px 22px;
  color: #fff;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  white-space: nowrap;
}

#search-btn:hover {
  background: rgba(255,255,255,0.38);
  transform: scale(1.04);
}

#search-btn:active {
  transform: scale(0.96);
}

/* ── Card ── */
#card {
  margin-top: 1.6rem;
  width: min(460px, 90vw);
  background: rgba(255,255,255,0.11);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 28px;
  padding: 1.8rem 1.8rem 1.4rem;
  animation: fadeUp 0.7s var(--spring) 0.1s both;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#card:hover {
  transform: translateY(-5px);
  box-shadow: 0 30px 60px rgba(0,0,0,0.25);
}

#card.hidden { display: none; }

/* Card content */
#location {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  margin-bottom: 3px;
}

#city-name {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 5vw, 2.7rem);
  line-height: 1.1;
  margin-bottom: 4px;
}

#date-line {
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  margin-bottom: 1.4rem;
}

/* Temp + icon */
#main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

#temperature {
  font-family: var(--font-display);
  font-size: clamp(4rem, 10vw, 5.5rem);
  line-height: 1;
  font-style: italic;
}

#weather-icon-wrap {
  animation: floatIcon 4s ease-in-out infinite;
}

#weather-emoji {
  font-size: 72px;
  line-height: 1;
  filter: drop-shadow(0 6px 20px rgba(0,0,0,0.3));
}

#description {
  font-size: 16px;
  font-weight: 300;
  text-transform: capitalize;
  color: rgba(255,255,255,0.78);
  margin-bottom: 1.4rem;
}

/* Stats */
#stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat {
  background: rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 12px 8px;
  text-align: center;
  transition: background 0.2s, transform 0.2s;
}

.stat:hover {
  background: rgba(255,255,255,0.18);
  transform: scale(1.03);
}

.stat-val {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 3px;
}

.stat-lbl {
  font-size: 10px;
  letter-spacing: 0.09em;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
}

/* Divider */
#divider {
  height: 1px;
  background: rgba(255,255,255,0.12);
  margin: 1.3rem 0 1rem;
}

/* Bottom row */
#bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: rgba(255,255,255,0.55);
}

/* ── Loader ── */
#loader {
  margin-top: 1.8rem;
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255,255,255,0.18);
  border-top-color: rgba(255,255,255,0.9);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

#loader.hidden { display: none; }

/* ── Error ── */
#error {
  margin-top: 1rem;
  font-size: 14px;
  color: rgba(255,190,190,0.9);
  text-align: center;
  animation: fadeUp 0.4s ease both;
}

#error.hidden { display: none; }

/* ── Hint ── */
#hint {
  margin-top: 1.4rem;
  font-size: 13px;
  color: rgba(255,255,255,0.3);
  text-align: center;
  animation: slideDown 0.8s var(--spring) 0.3s both;
}

/* ── Keyframes ── */
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes floatIcon {
  0%,100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-12px) rotate(3deg); }
}

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