/* ═══════════════════════════════════════════════════════════
   PROJETO CLIMA · style.css
   Arquitetura CSS:
   1. Variáveis globais (temas)
   2. Reset & base
   3. Layout principal
   4. Header & busca
   5. Telas de estado (welcome / loading / error)
   6. Resultado (hero card)
   8. Temas dinâmicos (body classes)
   9. Responsivo
   10. Animações
═══════════════════════════════════════════════════════════ */

/* ─── 1. VARIÁVEIS GLOBAIS ──────────────────────────────── */
:root {
  /* Tipografia */
  --font-display : 'Playfair', sans-serif;
  --font-body    : 'Poppins', sans-serif;

  /* Espaçamentos */
  --space-xs  : 0.4rem;
  --space-sm  : 0.75rem;
  --space-md  : 1.25rem;
  --space-lg  : 2rem;
  --space-xl  : 3rem;

  /* Bordas */
  --radius-sm : 12px;
  --radius-md : 20px;
  --radius-lg : 32px;

  /* Transição de tema */
  --theme-transition : background 0.8s ease, color 0.8s ease;

  /* ── Padrão: Dia Ensolarado ── */
  --bg-primary    : #f0e8d8;
  --bg-secondary  : #e8dcc8;
  --bg-card       : rgba(255, 255, 255, 0.55);
  --card-border   : rgba(255, 255, 255, 0.8);
  --card-shadow   : 0 8px 32px rgba(180, 120, 40, 0.15);
  --text-primary  : #2d2013;
  --text-secondary: #6b5030;
  --text-muted    : #9c7a50;
  --accent        : #e07c2a;
  --accent-soft   : rgba(224, 124, 42, 0.18);
  --bar-fill      : #e07c2a;
  --gradient-body : linear-gradient(145deg, #fcefd8 0%, #f5d99b 40%, #e8b95a 100%);
  --logo-color    : #c05a10;
}

/* ─── 2. RESET & BASE ───────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--gradient-body);
  min-height: 100dvh;
  transition: var(--theme-transition);
  overflow-x: hidden;
  position: relative;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

button {
  cursor: pointer;
  font-family: var(--font-body);
  border: none;
  outline: none;
}

input {
  font-family: var(--font-body);
  outline: none;
}

/* ─── 3. LAYOUT PRINCIPAL ───────────────────────────────── */

.app-wrapper {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-md);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ─── 4. HEADER & BUSCA ─────────────────────────────────── */
.app-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg) 0 var(--space-md);
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  text-decoration: none;
  color: var(--logo-color);
}

.logo-icon {
  font-size: 4rem;
  line-height: 1;
  animation: logoSpin 8s linear infinite;
}

.logo-text {
  font-family: var(--font-body);
  font-size: 3rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text-secondary);
  transition: color 0.6s;
}

.logo-text strong {
  font-family: var(--font-display);
  font-size: 4rem;
  color: var(--logo-color);
  font-weight: 800;
  font-style: italic;
}

/* Caixa de busca */
.search-container {
  width: 100%;
  max-width: 520px;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xs) var(--space-xs) var(--space-xs) var(--space-md);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--card-shadow);
  transition: border-color 0.3s, box-shadow 0.3s, background 0.6s;
  gap: var(--space-xs);
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--card-shadow);
}

.city-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-primary);
  padding: var(--space-xs) 0;
  transition: color 0.6s;
}

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

/* Botão de busca */
.search-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  padding: 0.55rem 1.1rem;
  border-radius: calc(var(--radius-lg) - 6px);
  transition: background 0.2s, transform 0.15s, opacity 0.3s;
  white-space: nowrap;
  flex-shrink: 0;
}

.search-btn:hover:not(:disabled) {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

.search-btn:active:not(:disabled) {
  transform: translateY(0);
}

.search-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.search-btn .btn-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ─── 5. TELAS DE ESTADO ────────────────────────────────── */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-md) 0;
}

/* ── Welcome ── */
.welcome-screen {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  animation: fadeInUp 0.6s ease both;
}

.welcome-subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  font-weight: 300;
  line-height: 1.6;
  max-width: 340px;
  margin: 0 auto var(--space-lg);
}

.welcome-hints {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  justify-content: center;
}

.welcome-hints span {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.3rem 0.8rem;
  border-radius: 100px;
  cursor: default;
  border: 1px solid rgba(224, 124, 42, 0.2);
}

/* ── Loading ── */
.loading-screen {
  text-align: center;
  padding: var(--space-xl);
  animation: fadeIn 0.3s ease both;
}

.loader-ring {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-md);
  position: relative;
}

.ring-segment {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
}

.ring-segment:nth-child(1) {
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

.ring-segment:nth-child(2) {
  border-right-color: var(--accent);
  opacity: 0.5;
  animation: spin 1s linear infinite 0.2s;
}

.ring-segment:nth-child(3) {
  border-bottom-color: var(--accent);
  opacity: 0.25;
  animation: spin 1s linear infinite 0.4s;
}

.loading-text {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 300;
}

/* ── Error ── */
.error-screen {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  animation: shake 0.4s ease both;
}

.error-icon {
  font-size: 3.5rem;
  margin-bottom: var(--space-sm);
  display: block;
  opacity: 0.8;
}

.error-message {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: var(--space-lg);
}

.error-retry {
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.65rem 1.5rem;
  border-radius: 100px;
  transition: filter 0.2s, transform 0.15s;
}

.error-retry:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

/* ─── 6. RESULTADO ──────────────────────────────────────── */
.weather-result {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  animation: fadeInUp 0.55s ease both;
}

/* Card base */
.card {
  background: var(--bg-card);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--card-shadow);
  transition: background 0.6s, border-color 0.6s, box-shadow 0.6s;
}

/* ── Hero Card ── */
.hero-card {
  padding: var(--space-lg) var(--space-lg) var(--space-md);
}

.hero-location {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

.pin-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--accent);
}

.city-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.country-name {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 300;
}

/* Temperatura principal */
.hero-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

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

.current-temp {
  font-family: var(--font-display);
  font-size: clamp(4.5rem, 14vw, 7rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--text-primary);
  line-height: 1;
  transition: color 0.6s;
}

.temp-unit {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 0.6rem;
}

/* Ícone animado */
.weather-icon-wrap {
  flex-shrink: 0;
}

.weather-icon-main {
  font-size: clamp(4rem, 12vw, 6rem);
  display: block;
  line-height: 1;
  animation: float 3.5s ease-in-out infinite;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.15));
  transition: filter 0.6s;
}

/* Descrição e range */
.hero-meta {
  margin-top: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.weather-desc {
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color 0.6s;
}

.temp-range {
  display: flex;
  gap: var(--space-md);
}

.temp-max, .temp-min {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
}

.temp-max svg, .temp-min svg {
  width: 14px;
  height: 14px;
}

.temp-max { color: #e05050; }
.temp-min { color: #5090e0; }

 
/* ── Grid de Métricas ── */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}
 
.metric-card {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s;
}
 
.metric-card:hover {
  transform: translateY(-2px);
}
 
.metric-icon {
  font-size: 1.6rem;
  line-height: 1;
  margin-bottom: 2px;
}
 
.metric-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
 
.metric-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 500;
  transition: color 0.6s;
}
 
.metric-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  transition: color 0.6s;
}
 
/* Barra de precipitação */
.metric-bar-track {
  width: 100%;
  height: 4px;
  background: rgba(0,0,0,0.08);
  border-radius: 100px;
  margin-top: var(--space-xs);
  overflow: hidden;
}
 
.metric-bar-fill {
  height: 100%;
  background: var(--bar-fill);
  border-radius: 100px;
  transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}
 
/* Rótulo UV */
.uv-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 100px;
  align-self: flex-start;
  margin-top: var(--space-xs);
  transition: background 0.6s, color 0.6s;
}

/* ─── 7. FOOTER ─────────────────────────────────────────── */
.app-footer {
  text-align: center;
  padding: var(--space-md) 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  transition: color 0.6s;
  flex-shrink: 0;
}

/* ─── 8. TEMAS DINÂMICOS ────────────────────────────────── */

/* ── Dia Ensolarado (padrão) ── */
body.day-clear {
  --bg-primary    : #f0e8d8;
  --bg-secondary  : #e8dcc8;
  --bg-card       : rgba(255, 255, 255, 0.55);
  --card-border   : rgba(255, 255, 255, 0.8);
  --card-shadow   : 0 8px 32px rgba(180, 120, 40, 0.15);
  --text-primary  : #2d2013;
  --text-secondary: #6b5030;
  --text-muted    : #9c7a50;
  --accent        : #e07c2a;
  --accent-soft   : rgba(224, 124, 42, 0.15);
  --bar-fill      : #e07c2a;
  --gradient-body : linear-gradient(145deg, #fcefd8 0%, #f5d99b 40%, #e8b95a 100%);
  --logo-color    : #c05a10;
}

/* ── Noite Limpa ── */
body.night-clear {
  --bg-card       : rgba(20, 30, 60, 0.55);
  --card-border   : rgba(80, 100, 160, 0.4);
  --card-shadow   : 0 8px 40px rgba(0, 0, 40, 0.4);
  --text-primary  : #e8eeff;
  --text-secondary: #8898cc;
  --text-muted    : #5060a0;
  --accent        : #6688ee;
  --accent-soft   : rgba(102, 136, 238, 0.2);
  --bar-fill      : #6688ee;
  --gradient-body : linear-gradient(145deg, #050a1a 0%, #0d1538 50%, #162050 100%);
  --logo-color    : #8aabff;
}

/* ── Chuva ── */
body.rain {
  --bg-card       : rgba(30, 45, 65, 0.55);
  --card-border   : rgba(90, 120, 160, 0.35);
  --card-shadow   : 0 8px 40px rgba(0, 20, 50, 0.35);
  --text-primary  : #d8e5f0;
  --text-secondary: #7a9ab8;
  --text-muted    : #4a6888;
  --accent        : #4a9fd4;
  --accent-soft   : rgba(74, 159, 212, 0.2);
  --bar-fill      : #4a9fd4;
  --gradient-body : linear-gradient(145deg, #1a2535 0%, #1e3248 50%, #253c58 100%);
  --logo-color    : #6bc0e8;
}

/* ── Nublado ── */
body.cloudy {
  --bg-card       : rgba(50, 55, 65, 0.5);
  --card-border   : rgba(120, 130, 150, 0.4);
  --card-shadow   : 0 8px 32px rgba(0, 0, 0, 0.2);
  --text-primary  : #d8d8e0;
  --text-secondary: #8898a8;
  --text-muted    : #5a6878;
  --accent        : #7890a8;
  --accent-soft   : rgba(120, 144, 168, 0.2);
  --bar-fill      : #7890a8;
  --gradient-body : linear-gradient(145deg, #2a2e34 0%, #32363e 50%, #3a3f48 100%);
  --logo-color    : #a0b8cc;
}

/* ── Tempestade ── */
body.storm {
  --bg-card       : rgba(15, 12, 30, 0.65);
  --card-border   : rgba(90, 70, 150, 0.4);
  --card-shadow   : 0 8px 48px rgba(80, 50, 180, 0.2);
  --text-primary  : #d0cce8;
  --text-secondary: #7068a0;
  --text-muted    : #4a4278;
  --accent        : #9060e0;
  --accent-soft   : rgba(144, 96, 224, 0.2);
  --bar-fill      : #9060e0;
  --gradient-body : linear-gradient(145deg, #08060f 0%, #100d22 50%, #180f30 100%);
  --logo-color    : #b090ff;
}

/* ─── 9. RESPONSIVO ─────────────────────────────────────── */
@media (max-width: 520px) {
  .app-header {
    padding: var(--space-md) 0 var(--space-sm);
  }

  .logo-icon {
    font-size: 2rem;
  }

  .logo-text {
    font-size: 1.5rem;
  }

  .logo-text strong {
    font-size: 2rem;
  }

  .card {
    padding: var(--space-md);
  }

  .hero-card {
    padding: var(--space-md);
  }

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

  .metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xs);
  }
 
  .metric-card {
    padding: var(--space-sm) var(--space-md);
  }

  .search-btn .btn-text {
    display: none;
  }

  .search-btn {
    padding: 0.55rem 0.75rem;
  }

  .search-btn .btn-icon {
    width: 18px;
    height: 18px;
  }

}

@media (min-width: 600px) {
    .metrics-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ─── 10. ANIMAÇÕES ─────────────────────────────────────── */

/* Flutuação do ícone */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

/* Spin do loader */
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Spin logo */
@keyframes logoSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Fade + subida */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade simples */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Shake para erro */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-5px); }
  80%       { transform: translateX(5px); }
}

/* Utility: esconder */
[hidden] { display: none !important; }