/* ============================================================
   Atmosphera Weather App — style.css
   Design: Refined glassmorphism · Syne + DM Sans typography
   ============================================================ */

/* ── CSS Variables ── */
:root {
  /* Dark theme (default) */
  --bg-start: #090e1a;
  --bg-end: #0f1e35;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
  --text-primary: #f0f4ff;
  --text-secondary: rgba(200, 215, 245, 0.65);
  --text-muted: rgba(160, 185, 225, 0.45);
  --accent: #5b9cf6;
  --accent-glow: rgba(91, 156, 246, 0.35);
  --accent-2: #a78bfa;
  --badge-bg: rgba(91, 156, 246, 0.15);
  --card-hover: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(255, 255, 255, 0.06);
  --input-border: rgba(255, 255, 255, 0.12);
  --error-bg: rgba(239, 68, 68, 0.12);
  --error-border: rgba(239, 68, 68, 0.30);
  --error-text: #fca5a5;
  --suggestion-hover: rgba(91, 156, 246, 0.12);
  --scrollbar-track: rgba(255,255,255,0.03);
  --scrollbar-thumb: rgba(255,255,255,0.12);

  /* Typography */
  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;

  /* Spacing */
  --max-width: 860px;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --radius-xl: 36px;
}

[data-theme="light"] {
  --bg-start: #dce8f8;
  --bg-end: #eef2fc;
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-border: rgba(255, 255, 255, 0.80);
  --glass-shadow: 0 8px 40px rgba(80, 120, 200, 0.14);
  --text-primary: #0d1b3e;
  --text-secondary: rgba(20, 50, 110, 0.65);
  --text-muted: rgba(30, 60, 130, 0.40);
  --accent: #2563eb;
  --accent-glow: rgba(37, 99, 235, 0.20);
  --accent-2: #7c3aed;
  --badge-bg: rgba(37, 99, 235, 0.10);
  --card-hover: rgba(37, 99, 235, 0.06);
  --input-bg: rgba(255, 255, 255, 0.70);
  --input-border: rgba(37, 99, 235, 0.18);
  --error-bg: rgba(239, 68, 68, 0.08);
  --error-border: rgba(239, 68, 68, 0.25);
  --error-text: #dc2626;
  --suggestion-hover: rgba(37, 99, 235, 0.08);
  --scrollbar-track: rgba(0,0,0,0.03);
  --scrollbar-thumb: rgba(0,0,0,0.12);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-primary);
  background: linear-gradient(145deg, var(--bg-start), var(--bg-end));
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.6s ease, color 0.4s ease;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 99px; }

/* ── Particle Canvas ── */
#particleCanvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

/* ── Background layer (weather-based gradient) ── */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0;
  transition: opacity 1.2s ease, background 1.2s ease;
  pointer-events: none;
}
.bg-layer.active { opacity: 1; }

/* Weather-specific gradients */
.bg-sunny     { background: radial-gradient(ellipse at 20% 10%, rgba(251, 191, 36, 0.18) 0%, transparent 60%),
                             radial-gradient(ellipse at 80% 80%, rgba(251, 146, 60, 0.12) 0%, transparent 55%); }
.bg-cloudy    { background: radial-gradient(ellipse at 50% 0%, rgba(148, 163, 184, 0.18) 0%, transparent 70%); }
.bg-rainy     { background: radial-gradient(ellipse at 30% 20%, rgba(59, 130, 246, 0.20) 0%, transparent 60%),
                             radial-gradient(ellipse at 70% 90%, rgba(99, 102, 241, 0.14) 0%, transparent 55%); }
.bg-snowy     { background: radial-gradient(ellipse at 50% 10%, rgba(186, 230, 253, 0.22) 0%, transparent 70%); }
.bg-thunder   { background: radial-gradient(ellipse at 50% 20%, rgba(167, 139, 250, 0.25) 0%, transparent 65%); }
.bg-night     { background: radial-gradient(ellipse at 70% 10%, rgba(99, 102, 241, 0.18) 0%, transparent 60%),
                             radial-gradient(ellipse at 20% 80%, rgba(30, 27, 75, 0.30) 0%, transparent 55%); }
.bg-foggy     { background: radial-gradient(ellipse at 50% 40%, rgba(200, 200, 200, 0.15) 0%, transparent 70%); }

/* ── App Wrapper ── */
.app-wrapper {
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 28px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ── Glass Card ── */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: var(--glass-shadow);
  transition: background 0.4s, border-color 0.4s, box-shadow 0.4s;
}
.glass-card:hover {
  background: var(--card-hover);
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  animation: fadeDown 0.6s ease both;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  font-size: 22px;
  color: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent-glow));
  animation: pulse 3s ease infinite;
}
.logo-text {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, var(--text-primary) 40%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.unit-toggle,
.theme-toggle {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 50px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s, transform 0.2s, box-shadow 0.25s;
  backdrop-filter: blur(10px);
  letter-spacing: 0.3px;
}
.unit-toggle:hover,
.theme-toggle:hover {
  background: var(--badge-bg);
  border-color: var(--accent);
  box-shadow: 0 0 14px var(--accent-glow);
  transform: translateY(-1px);
}
.unit-toggle:active,
.theme-toggle:active {
  transform: scale(0.96);
}
.theme-toggle { padding: 7px 12px; font-size: 15px; }

/* ── Search Section ── */
.search-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fadeUp 0.65s 0.1s ease both;
}

.search-wrapper {
  position: relative;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-xl);
  padding: 12px 16px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: border-color 0.25s, box-shadow 0.25s;
}
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), 0 8px 30px rgba(0,0,0,0.2);
}

.search-icon {
  color: var(--text-muted);
  display: flex;
  flex-shrink: 0;
}

#searchInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 400;
  caret-color: var(--accent);
}
#searchInput::placeholder { color: var(--text-muted); }

.locate-btn {
  background: var(--badge-bg);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--accent);
  flex-shrink: 0;
  transition: background 0.25s, transform 0.2s, box-shadow 0.25s;
}
.locate-btn:hover {
  background: var(--accent);
  color: #fff;
  transform: rotate(15deg) scale(1.1);
  box-shadow: 0 0 14px var(--accent-glow);
}

/* ── Suggestions List ── */
.suggestions-list {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--glass-shadow);
  list-style: none;
  overflow: hidden;
  z-index: 100;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}
.suggestions-list.open {
  max-height: 240px;
  opacity: 1;
}
.suggestions-list li {
  padding: 11px 18px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--glass-border);
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.suggestions-list li:last-child { border-bottom: none; }
.suggestions-list li:hover {
  background: var(--suggestion-hover);
  color: var(--text-primary);
}
.suggestions-list li .sug-pin { color: var(--accent); font-size: 12px; }

/* ── Recent Searches ── */
.recent-searches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
}
.recent-chip {
  background: var(--badge-bg);
  border: 1px solid var(--glass-border);
  border-radius: 99px;
  padding: 5px 13px;
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.recent-chip:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-1px);
}
.recent-label {
  font-size: 11px;
  color: var(--text-muted);
  align-self: center;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-weight: 500;
}

/* ── Loader ── */
.loader-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 60px 0;
  animation: fadeUp 0.4s ease both;
}
.loader-ring {
  width: 48px;
  height: 48px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.loader-text {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.4px;
}

/* ── Error Banner ── */
.error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  color: var(--error-text);
  font-size: 14px;
  animation: shake 0.4s ease, fadeUp 0.4s ease;
}
.error-icon { font-size: 16px; }

/* ── Weather Content ── */
.weather-content {
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: fadeUp 0.55s ease both;
}

/* ── Current Card ── */
.current-card {
  padding: 30px 30px 24px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: relative;
  overflow: hidden;
}

/* Decorative orb */
.current-card::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
  border-radius: 50%;
  animation: float 6s ease-in-out infinite;
}

.current-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.city-name {
  font-family: var(--font-display);
  font-size: clamp(26px, 5vw, 38px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.country-date {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 5px;
  letter-spacing: 0.2px;
}

.weather-icon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.weather-icon-large {
  font-size: 58px;
  line-height: 1;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.20));
  animation: float 4s ease-in-out infinite;
}

.condition-text {
  font-size: 12.5px;
  color: var(--text-secondary);
  text-align: center;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: capitalize;
}

.temp-display {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.temp-main {
  font-family: var(--font-display);
  font-size: clamp(54px, 12vw, 82px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -2px;
  background: linear-gradient(135deg, var(--text-primary) 50%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.temp-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.feels-like {
  font-size: 13px;
  color: var(--text-secondary);
}
.temp-range {
  font-size: 12px;
  color: var(--text-muted);
}

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  text-align: center;
  transition: background 0.25s, transform 0.2s;
}
.stat-item:hover {
  background: var(--card-hover);
  transform: translateY(-2px);
}
.stat-icon { font-size: 18px; line-height: 1; }
.stat-label { font-size: 11px; color: var(--text-muted); letter-spacing: 0.3px; font-weight: 500; text-transform: uppercase; }
.stat-value { font-size: 14px; font-weight: 600; color: var(--text-primary); font-family: var(--font-display); }

/* ── Sun Row ── */
.sun-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.sun-card {
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  transition: transform 0.2s;
}
.sun-card:hover { transform: translateY(-3px); }

.sun-emoji { font-size: 24px; line-height: 1; }
.sun-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 500; }
.sun-time { font-size: 15px; font-weight: 600; color: var(--text-primary); font-family: var(--font-display); }

/* ── Forecast Section ── */
.forecast-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-heading {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.forecast-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.forecast-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 18px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  transition: background 0.25s, transform 0.2s, box-shadow 0.25s;
  cursor: default;
}
.forecast-card:hover {
  background: var(--card-hover);
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.25), 0 0 0 1px var(--accent);
}
.forecast-day {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.forecast-icon { font-size: 28px; line-height: 1; }
.forecast-desc { font-size: 11px; color: var(--text-secondary); text-transform: capitalize; line-height: 1.3; }
.forecast-temps {
  display: flex;
  gap: 5px;
  align-items: baseline;
}
.f-high {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}
.f-low {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Footer ── */
.footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 10px;
}
.footer a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}
.footer a:hover { color: var(--accent-2); }

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-8px); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; filter: drop-shadow(0 0 6px var(--accent-glow)); }
  50%       { opacity: 0.7; filter: drop-shadow(0 0 14px var(--accent-glow)); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-6px); }
  75%       { transform: translateX(6px); }
}

/* ── Responsive ── */
@media (max-width: 700px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .sun-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .forecast-row {
    grid-template-columns: repeat(3, 1fr);
  }
  .forecast-row .forecast-card:nth-child(4),
  .forecast-row .forecast-card:nth-child(5) {
    display: none;
  }
  .current-card { padding: 22px 18px 18px; }
}

@media (max-width: 480px) {
  .app-wrapper { padding: 18px 14px 48px; gap: 18px; }
  .current-top { flex-direction: column-reverse; align-items: flex-start; }
  .weather-icon-wrap { flex-direction: row; align-items: center; }
  .weather-icon-large { font-size: 42px; }
  .forecast-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .forecast-row .forecast-card:nth-child(5) {
    display: none;
  }
}

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