/* ============================================================
   EcoWeather — style.css
   Pure CSS3, aucun préprocesseur, aucun framework
   ============================================================ */

/* ---------- Reset & base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100dvh;
  font-family: 'DM Sans', sans-serif;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  position: relative;
  transition:
    background-color 1.2s ease,
    color 0.6s ease;
}

a {
  color: inherit;
  opacity: 0.65;
  text-decoration: none;
  transition: opacity 0.2s;
}
a:hover { opacity: 1; }

/* ============================================================
   THÈMES DYNAMIQUES
   Chaque thème redéfinit les variables + les orbes de fond
   ============================================================ */

/* --- Défaut (chargement) --- */
.theme-default {
  --bg-from: #1a1c2e;
  --bg-to:   #2d2f4a;
  --orb-1:   rgba(80, 90, 180, 0.35);
  --orb-2:   rgba(50, 60, 140, 0.25);
  --orb-3:   rgba(100, 80, 160, 0.20);
  --card-bg: rgba(255,255,255,0.07);
  --card-border: rgba(255,255,255,0.10);
  --text-primary:   #f0f2ff;
  --text-secondary: rgba(240,242,255,0.55);
  --accent:         #7b8fff;
  --stat-bg:  rgba(255,255,255,0.06);
  --input-bg: rgba(255,255,255,0.08);
  --input-border: rgba(255,255,255,0.14);
  --loader-ring: rgba(255,255,255,0.25);
  --loader-spin: #7b8fff;
  --bar-track: rgba(255,255,255,0.12);
  --bar-fill:  #7b8fff;
}

/* --- Soleil (Clear) --- */
.theme-sunny {
  --bg-from: #f97316;
  --bg-to:   #3b82f6;
  --orb-1:   rgba(251, 191, 36, 0.55);
  --orb-2:   rgba(249, 115, 22, 0.40);
  --orb-3:   rgba(59, 130, 246, 0.30);
  --card-bg: rgba(255,255,255,0.15);
  --card-border: rgba(255,255,255,0.25);
  --text-primary:   #fff8f0;
  --text-secondary: rgba(255,248,240,0.65);
  --accent:         #fbbf24;
  --stat-bg:  rgba(255,255,255,0.12);
  --input-bg: rgba(255,255,255,0.18);
  --input-border: rgba(255,255,255,0.30);
  --loader-ring: rgba(255,255,255,0.30);
  --loader-spin: #fbbf24;
  --bar-track: rgba(255,255,255,0.20);
  --bar-fill:  #fbbf24;
}

/* --- Pluie (Rain / Drizzle / Thunderstorm) --- */
.theme-rainy {
  --bg-from: #1e2d3d;
  --bg-to:   #2c3e55;
  --orb-1:   rgba(56,  89, 130, 0.40);
  --orb-2:   rgba(30,  60,  95, 0.35);
  --orb-3:   rgba(70, 100, 140, 0.25);
  --card-bg: rgba(255,255,255,0.06);
  --card-border: rgba(255,255,255,0.08);
  --text-primary:   #dce8f5;
  --text-secondary: rgba(220,232,245,0.55);
  --accent:         #60a5fa;
  --stat-bg:  rgba(255,255,255,0.05);
  --input-bg: rgba(255,255,255,0.07);
  --input-border: rgba(255,255,255,0.12);
  --loader-ring: rgba(255,255,255,0.20);
  --loader-spin: #60a5fa;
  --bar-track: rgba(255,255,255,0.10);
  --bar-fill:  #60a5fa;
}

/* --- Nuages / Brouillard --- */
.theme-cloudy {
  --bg-from: #e8eaf0;
  --bg-to:   #cfd3de;
  --orb-1:   rgba(190, 195, 215, 0.70);
  --orb-2:   rgba(170, 178, 200, 0.50);
  --orb-3:   rgba(200, 205, 220, 0.60);
  --card-bg: rgba(255,255,255,0.50);
  --card-border: rgba(255,255,255,0.70);
  --text-primary:   #2d3250;
  --text-secondary: rgba(45,50,80,0.55);
  --accent:         #6b7db3;
  --stat-bg:  rgba(255,255,255,0.40);
  --input-bg: rgba(255,255,255,0.55);
  --input-border: rgba(100,110,150,0.20);
  --loader-ring: rgba(45,50,80,0.15);
  --loader-spin: #6b7db3;
  --bar-track: rgba(45,50,80,0.10);
  --bar-fill:  #6b7db3;
}

/* --- Neige --- */
.theme-snowy {
  --bg-from: #dbeafe;
  --bg-to:   #eff6ff;
  --orb-1:   rgba(219,234,254,0.90);
  --orb-2:   rgba(191,219,254,0.70);
  --orb-3:   rgba(255,255,255,0.80);
  --card-bg: rgba(255,255,255,0.60);
  --card-border: rgba(255,255,255,0.80);
  --text-primary:   #1e3a5f;
  --text-secondary: rgba(30,58,95,0.55);
  --accent:         #3b82f6;
  --stat-bg:  rgba(255,255,255,0.45);
  --input-bg: rgba(255,255,255,0.65);
  --input-border: rgba(59,130,246,0.20);
  --loader-ring: rgba(30,58,95,0.15);
  --loader-spin: #3b82f6;
  --bar-track: rgba(30,58,95,0.10);
  --bar-fill:  #3b82f6;
}

/* ============================================================
   FOND ANIMÉ
   ============================================================ */
.bg-layer {
  position: fixed;
  inset: 0;
  background: linear-gradient(145deg, var(--bg-from), var(--bg-to));
  transition: background 1.4s ease;
  z-index: 0;
  overflow: hidden;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  transition: background-color 1.4s ease, opacity 1.4s ease;
  will-change: transform;
}

.orb-1 {
  width: 520px; height: 520px;
  background: var(--orb-1);
  top: -140px; left: -120px;
  animation: drift1 18s ease-in-out infinite alternate;
}

.orb-2 {
  width: 380px; height: 380px;
  background: var(--orb-2);
  bottom: -100px; right: -80px;
  animation: drift2 22s ease-in-out infinite alternate;
}

.orb-3 {
  width: 260px; height: 260px;
  background: var(--orb-3);
  top: 50%; left: 55%;
  transform: translate(-50%, -50%);
  animation: drift3 15s ease-in-out infinite alternate;
}

@keyframes drift1 {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(60px, 40px) scale(1.08); }
}
@keyframes drift2 {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-50px, -30px) scale(1.06); }
}
@keyframes drift3 {
  from { transform: translate(-50%, -50%) scale(1); }
  to   { transform: translate(-42%, -58%) scale(1.12); }
}

/* ============================================================
   ANIMATION PLUIE
   ============================================================ */
.rain-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
  opacity: 0;
  transition: opacity 1s ease;
}

.rain-container.active {
  opacity: 1;
}

.raindrop {
  position: absolute;
  top: -20px;
  width: 1.5px;
  border-radius: 2px;
  background: linear-gradient(to bottom, transparent, rgba(147, 197, 253, 0.55));
  animation: fall linear infinite;
}

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

/* ============================================================
   SHELL PRINCIPAL
   ============================================================ */
.app-shell {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  padding: 20px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100dvh;
}

/* ============================================================
   EN-TÊTE
   ============================================================ */
.app-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 12px;
}

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

.brand-leaf {
  font-size: 1.3rem;
  line-height: 1;
  animation: sway 4s ease-in-out infinite;
  display: inline-block;
  transform-origin: bottom center;
}

@keyframes sway {
  0%, 100% { transform: rotate(-5deg); }
  50%       { transform: rotate(5deg); }
}

.brand-name {
  font-family: 'DM Serif Display', serif;
  font-size: 1.4rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  transition: color 0.6s ease;
}

.search-wrapper {
  display: flex;
  gap: 8px;
}

.search-input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 14px;
  padding: 11px 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  color: var(--text-primary);
  outline: none;
  transition:
    background 0.4s ease,
    border-color 0.4s ease,
    color 0.4s ease,
    box-shadow 0.2s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

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

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.search-btn {
  background: var(--accent);
  border: none;
  border-radius: 14px;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background 0.4s ease,
    transform 0.15s ease,
    box-shadow 0.2s ease;
}

.search-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 18px color-mix(in srgb, var(--accent) 45%, transparent);
}

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

/* ============================================================
   CARTE MÉTÉO
   ============================================================ */
.weather-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 28px;
  padding: 28px 24px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 380px;
  transition:
    background 1s ease,
    border-color 1s ease;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
}

/* --- Loader --- */
.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.loader-ring {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 3px solid var(--loader-ring);
  border-top-color: var(--loader-spin);
  animation: spin 0.9s linear infinite;
  transition: border-color 0.6s ease;
}

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

.loader-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  transition: color 0.6s ease;
}

/* --- État d'erreur --- */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.error-icon { font-size: 2.2rem; }

.error-msg {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 260px;
  transition: color 0.6s ease;
}

.retry-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 9px 22px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 0.4s ease,
    transform 0.15s ease;
}

.retry-btn:hover  { transform: scale(1.04); }
.retry-btn:active { transform: scale(0.97); }

/* --- Données météo --- */
.weather-data {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: fadeSlideUp 0.55s cubic-bezier(0.22, 0.82, 0.42, 1) both;
}

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

/* Localisation */
.location-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.pin-icon {
  fill: var(--accent);
  flex-shrink: 0;
  transition: fill 0.6s ease;
}

.city-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: color 0.6s ease;
}

.country-code {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 400;
  transition: color 0.6s ease;
}

/* Hero */
.weather-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.weather-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.weather-icon {
  font-size: 5rem;
  line-height: 1;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.20));
  animation: iconFloat 3.5s ease-in-out infinite;
  display: inline-block;
  transition: all 0.5s ease;
}

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

.temp-block {
  display: flex;
  align-items: flex-start;
  line-height: 1;
}

.temp-value {
  font-family: 'DM Serif Display', serif;
  font-size: 4.8rem;
  color: var(--text-primary);
  letter-spacing: -0.04em;
  transition: color 0.6s ease;
}

.temp-unit {
  font-size: 1.8rem;
  color: var(--text-secondary);
  margin-top: 10px;
  font-weight: 300;
  transition: color 0.6s ease;
}

/* Description */
.weather-desc {
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--text-primary);
  text-transform: capitalize;
  letter-spacing: 0.01em;
  transition: color 0.6s ease;
}

.feels-like {
  font-size: 0.80rem;
  color: var(--text-secondary);
  transition: color 0.6s ease;
}

/* Stats secondaires */
.stats-row {
  display: flex;
  align-items: center;
  background: var(--stat-bg);
  border-radius: 18px;
  padding: 14px 4px;
  transition: background 0.8s ease;
}

.stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-icon { font-size: 1.1rem; line-height: 1; }

.stat-label {
  font-size: 0.70rem;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
  transition: color 0.6s ease;
}

.stat-value {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: color 0.6s ease;
}

.stat-divider {
  width: 1px;
  height: 36px;
  background: var(--card-border);
  transition: background 0.8s ease;
}

/* Barre min/max */
.minmax-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.minmax-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.minmax-label {
  font-size: 0.68rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  transition: color 0.6s ease;
}

.minmax-val {
  font-size: 0.90rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: color 0.6s ease;
}

.temp-bar-track {
  flex: 1;
  height: 4px;
  background: var(--bar-track);
  border-radius: 4px;
  overflow: hidden;
  transition: background 0.8s ease;
}

.temp-bar-fill {
  height: 100%;
  background: var(--bar-fill);
  border-radius: 4px;
  transition:
    width 1s cubic-bezier(0.22, 0.82, 0.42, 1),
    background 0.8s ease;
}

/* ============================================================
   PIED DE PAGE
   ============================================================ */
.app-footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-secondary);
  padding-bottom: 4px;
  transition: color 0.6s ease;
}

/* ============================================================
   UTILITAIRES
   ============================================================ */
[hidden] { display: none !important; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (min-width: 480px) {
  .app-shell {
    min-height: auto;
    padding: 32px 20px;
  }

  .weather-card {
    min-height: 420px;
  }
}
