:root {
  --bg-gradient-start: #4facfe;
  --bg-gradient-end: #00f2fe;
  --card-bg: rgba(255, 255, 255, 0.85);
  --text-dark: #1a2b3c;
  --text-muted: #5a6b7c;
  --accent: #2b6cb0;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: var(--text-dark);
  position: relative;
  overflow-x: hidden;
}

/* ---------- Fond animé selon la météo ---------- */

.weather-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
  transition: background 1.5s ease;
}

.weather-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.05));
  pointer-events: none;
}

.weather-bg.sunny { background: linear-gradient(180deg, #4facfe 0%, #78d6ff 60%, #c2f0ff 100%); }
.weather-bg.partlyCloudy { background: linear-gradient(180deg, #5b9fd4 0%, #8fc4e6 60%, #d3ecf5 100%); }
.weather-bg.cloudy { background: linear-gradient(180deg, #7f8c9a 0%, #a9b4bd 60%, #c9d2d8 100%); }
.weather-bg.rainy { background: linear-gradient(180deg, #3a4a5c 0%, #5a6b7d 60%, #7c8a99 100%); }
.weather-bg.stormy { background: linear-gradient(180deg, #232526 0%, #3c4245 60%, #52585b 100%); }
.weather-bg.snowy { background: linear-gradient(180deg, #8fa3b3 0%, #b9c7d1 60%, #e7edf0 100%); }

/* Soleil */
.sun {
  position: absolute;
  top: 8%;
  right: 10%;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff9c4 0%, #ffd54f 60%, transparent 72%);
  box-shadow: 0 0 70px 25px rgba(255, 213, 79, 0.45);
  opacity: 0;
  transition: opacity 1.2s ease;
  animation: pulse 4s ease-in-out infinite;
}

.weather-bg.sunny .sun,
.weather-bg.partlyCloudy .sun {
  opacity: 1;
}

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

/* Nuages */
.clouds {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.weather-bg.partlyCloudy .clouds,
.weather-bg.cloudy .clouds,
.weather-bg.rainy .clouds,
.weather-bg.stormy .clouds,
.weather-bg.snowy .clouds {
  opacity: 1;
}

.cloud {
  position: absolute;
  filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.12));
}

.cloud svg {
  width: 100%;
  height: 100%;
  display: block;
}

.cloud1 { top: 15%; left: -25%; width: 220px; opacity: 0.95; animation: drift 42s linear infinite; }
.cloud2 { top: 32%; left: -35%; width: 160px; opacity: 0.75; animation: drift 58s linear infinite; animation-delay: -12s; }
.cloud3 { top: 6%; left: -30%; width: 190px; opacity: 0.6; animation: drift 70s linear infinite; animation-delay: -25s; }

@keyframes drift {
  from { transform: translateX(-10vw); }
  to { transform: translateX(120vw); }
}

/* Pluie */
.rain {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.9s ease;
  pointer-events: none;
}

.weather-bg.rainy .rain,
.weather-bg.stormy .rain {
  opacity: 1;
}

.drop {
  position: absolute;
  top: -10%;
  width: 2px;
  height: 60px;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.65));
  animation-name: fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

@keyframes fall {
  to { transform: translateY(110vh); }
}

/* Neige */
.snow {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.9s ease;
  pointer-events: none;
}

.weather-bg.snowy .snow {
  opacity: 1;
}

.flake {
  position: absolute;
  top: -5%;
  border-radius: 50%;
  background: white;
  animation-name: fall-slow;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

@keyframes fall-slow {
  to { transform: translate(20px, 110vh); }
}

/* Éclairs (orage) */
.lightning {
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
}

.lightning.flash {
  animation: flash 0.5s ease-out;
}

@keyframes flash {
  0% { opacity: 0; }
  8% { opacity: 0.85; }
  18% { opacity: 0; }
  28% { opacity: 0.5; }
  100% { opacity: 0; }
}

.app {
  width: 100%;
  max-width: 480px;
}

.app-header {
  text-align: center;
  margin-bottom: 20px;
  color: white;
}

.app-title {
  font-size: 1.8rem;
  margin-bottom: 16px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  user-select: none;
  display: inline-block;
  transition: transform 0.15s ease;
}

.app-title:hover,
.app-title:focus-visible {
  transform: scale(1.05);
}

.search-form {
  position: relative;
  display: flex;
  gap: 8px;
}

#city-input {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  box-shadow: var(--shadow);
  outline: none;
}

.search-form button {
  border: none;
  border-radius: var(--radius);
  background: var(--card-bg);
  font-size: 1.1rem;
  padding: 12px 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}

.search-form button:hover {
  transform: translateY(-2px);
}

.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 60px;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow);
  list-style: none;
  overflow: hidden;
  z-index: 10;
}

.suggestions li {
  padding: 10px 14px;
  cursor: pointer;
  color: var(--text-dark);
  font-size: 0.9rem;
  text-align: left;
}

.suggestions li:hover {
  background: #f0f4f8;
}

.hidden {
  display: none !important;
}

.status {
  text-align: center;
  color: white;
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.current-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  backdrop-filter: blur(10px);
  margin-bottom: 20px;
}

.current-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.city-name {
  font-size: 1.4rem;
  font-weight: 600;
}

.date {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 2px;
  text-transform: capitalize;
}

.unit-toggle {
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 600;
  cursor: pointer;
}

.current-temp-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.weather-icon {
  font-size: 3.5rem;
  line-height: 1;
}

.current-temp {
  font-size: 3rem;
  font-weight: 700;
}

.description {
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: capitalize;
}

.details-grid {
  display: grid;
  /* Passe de 3 a 4 cases (ajout de l'indice UV) -- en 2x2 plutot que sur
     une seule ligne, pour laisser assez de place a un texte comme
     "6 · Élevé" sans que ce soit trop serre. */
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.detail-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-value {
  font-weight: 600;
}

.forecast {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  backdrop-filter: blur(10px);
}

.forecast h2 {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.forecast h2 .hint {
  font-size: 0.75rem;
  font-weight: 400;
  opacity: 0.7;
}

.forecast-list {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.forecast-day {
  flex: 1;
  text-align: center;
  padding: 10px 4px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.forecast-day:hover,
.forecast-day:focus-visible {
  background: rgba(0, 0, 0, 0.05);
}

.forecast-day.selected {
  background: rgba(43, 108, 176, 0.12);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.forecast-day .day-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

.forecast-day .day-icon {
  font-size: 1.6rem;
  margin: 6px 0;
}

.forecast-day .day-temps {
  font-size: 0.8rem;
}

.forecast-day .day-max {
  font-weight: 700;
}

.forecast-day .day-min {
  color: var(--text-muted);
}

.hourly-forecast {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.hourly-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.hourly-header span {
  font-weight: 600;
  text-transform: capitalize;
  font-size: 0.9rem;
}

.hourly-header button {
  border: none;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.hourly-header button:hover {
  background: rgba(0, 0, 0, 0.12);
}

.hourly-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x proximity;
}

.hour-card {
  flex: 0 0 auto;
  scroll-snap-align: start;
  text-align: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.03);
  min-width: 54px;
}

.hour-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.hour-icon {
  font-size: 1.2rem;
  margin: 4px 0;
}

.hour-temp {
  font-size: 0.8rem;
  font-weight: 600;
}

.app-footer {
  text-align: center;
  margin-top: 16px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.8rem;
}

.app-footer a {
  color: white;
}

.preview-btn {
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(6px);
  color: white;
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.preview-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

@media (max-width: 400px) {
  .current-temp {
    font-size: 2.4rem;
  }
  .weather-icon {
    font-size: 2.8rem;
  }
}
