/* ============================================
   DESIGN SYSTEM
   ============================================ */

:root {
  /* Glass effect */
  --glass-bg: rgba(15, 20, 40, 0.45);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-hover: rgba(255, 255, 255, 0.04);
  --glass-blur: 24px;

  /* Colors */
  --accent: #60a5fa;
  --accent-warm: #fbbf24;
  --accent-rose: #f472b6;
  --text-primary: rgba(255, 255, 255, 0.95);
  --text-secondary: rgba(255, 255, 255, 0.55);
  --text-tertiary: rgba(255, 255, 255, 0.35);

  /* Mountain palette */
  --mountain-far: #2d3561;
  --mountain-mid: #1e2749;
  --mountain-near: #141b33;
  --snow: rgba(230, 240, 255, 0.85);
  --tree-color: #0a1220;
  --ground-color: #080e1a;
  --fog-color: rgba(180, 200, 230, 0.12);
  --cloud-color: rgba(255, 255, 255, 0.25);

  /* Spacing */
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============================================
   RESET & BASE
   ============================================ */

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

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-primary);
  background: #0b0d2e;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   SKY & SCENE (background)
   ============================================ */

#sky-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

/* Celestial */
#celestial-body {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 30%;
  z-index: 2;
}

#sun {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff8dc 10%, #ffe58f 40%, #ffb347 70%, rgba(255,160,50,0) 100%);
  box-shadow: 0 0 40px 15px rgba(255,200,100,0.4), 0 0 100px 40px rgba(255,160,50,0.15);
  position: absolute;
  transform: translate(-50%, 50%);
  opacity: 1;
}

#moon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f0f4ff 0%, #d4dff7 60%, #b0bed8 100%);
  box-shadow: 0 0 30px 10px rgba(200,215,255,0.25), 0 0 80px 30px rgba(180,200,255,0.1);
  position: absolute;
  transform: translate(-50%, 50%);
  opacity: 0;
}

#moon::before {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: rgba(160,175,210,0.3);
  top: 15px; left: 18px;
}

#moon::after {
  content: '';
  position: absolute;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(160,175,210,0.25);
  top: 32px; left: 34px;
}

/* Clouds */
#clouds {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.cloud {
  position: absolute;
  background: var(--cloud-color);
  border-radius: 60px;
  filter: blur(20px);
  animation: cloud-drift linear infinite;
  will-change: transform;
}

.cloud-1 { width: 280px; height: 50px; top: 12%; left: -300px; animation-duration: 80s; }
.cloud-2 { width: 360px; height: 60px; top: 18%; left: -400px; animation-duration: 110s; animation-delay: -30s; opacity: 0.6; }
.cloud-3 { width: 220px; height: 40px; top: 8%;  left: -250px; animation-duration: 95s;  animation-delay: -50s; }
.cloud-4 { width: 320px; height: 55px; top: 25%; left: -350px; animation-duration: 120s; animation-delay: -70s; opacity: 0.5; }
.cloud-5 { width: 200px; height: 35px; top: 15%; left: -220px; animation-duration: 90s;  animation-delay: -15s; opacity: 0.7; }

@keyframes cloud-drift {
  from { transform: translateX(0); }
  to   { transform: translateX(calc(100vw + 600px)); }
}

/* Mountains */
.mountain-layer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
}

#mountain-far  { height: 55%; fill: var(--mountain-far);  z-index: 5; }
#mountain-mid  { height: 50%; fill: var(--mountain-mid);  z-index: 6; }
#mountain-near { height: 48%; fill: var(--mountain-near); z-index: 7; }

.snow-cap { fill: var(--snow); }

/* Forest */
#forest {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 22%;
  z-index: 8;
}
#treeline { width: 100%; height: 100%; fill: var(--tree-color); }

/* Fog */
.fog {
  position: absolute;
  left: -10%; width: 120%; height: 120px;
  z-index: 9;
  background: linear-gradient(to top, var(--fog-color), transparent);
  pointer-events: none;
}
.fog-1 { bottom: 18%; opacity: 0.6; animation: fog-drift 30s ease-in-out infinite alternate; }
.fog-2 { bottom: 12%; opacity: 0.4; animation: fog-drift 40s ease-in-out infinite alternate-reverse; }

@keyframes fog-drift {
  from { transform: translateX(-3%); }
  to   { transform: translateX(3%); }
}

/* Ground */
#ground {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 10%;
  background: var(--ground-color);
  z-index: 10;
}

/* Particles */
#particle-canvas {
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
  z-index: 11;
  pointer-events: none;
}

/* ============================================
   APP CONTAINER
   ============================================ */

#app {
  position: relative;
  z-index: 20;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================
   TOP BAR
   ============================================ */

#top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(8, 12, 30, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
}

#brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  flex-shrink: 0;
}

#brand-icon {
  width: 26px;
  height: 26px;
  color: var(--accent);
}

/* Search */
#search-container {
  position: relative;
  flex: 1;
  max-width: 420px;
}

#search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 8px 14px;
  transition: all 0.25s var(--ease-out);
}

#search-box:focus-within {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.18);
  box-shadow: 0 0 0 3px rgba(96,165,250,0.15);
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

#search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 400;
}

#search-input::placeholder {
  color: var(--text-tertiary);
}

#location-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  color: var(--text-secondary);
  transition: all 0.2s;
  display: flex;
  align-items: center;
}

#location-btn svg {
  width: 18px;
  height: 18px;
}

#location-btn:hover {
  color: var(--accent);
  background: rgba(96,165,250,0.12);
}

/* Search results dropdown */
#search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  list-style: none;
  background: rgba(12, 16, 36, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: none;
  max-height: 280px;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,0.4);
}

#search-results.visible {
  display: block;
  animation: dropdown-in 0.2s var(--ease-out);
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

#search-results li {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: all 0.15s;
}

#search-results li:last-child {
  border-bottom: none;
}

#search-results li:hover,
#search-results li.active {
  background: rgba(96,165,250,0.1);
  color: var(--text-primary);
}

#search-results li .result-country {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-left: 6px;
}

/* Unit toggle */
#unit-toggle {
  display: flex;
  gap: 2px;
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 3px;
  flex-shrink: 0;
}

.unit-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.unit-btn.active {
  background: rgba(96,165,250,0.2);
  color: var(--accent);
}

.unit-btn:hover:not(.active) {
  color: var(--text-secondary);
}

/* ============================================
   LOADING & ERROR
   ============================================ */

#loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 20px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 300;
}

.loader-ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.08);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

#error-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 12px;
  text-align: center;
  padding: 0 24px;
}

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

#error-screen h2 {
  font-size: 1.4rem;
  font-weight: 600;
}

#error-screen p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 380px;
}

#retry-btn {
  margin-top: 8px;
  background: rgba(96,165,250,0.18);
  color: var(--accent);
  border: 1px solid rgba(96,165,250,0.25);
  padding: 10px 28px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

#retry-btn:hover {
  background: rgba(96,165,250,0.28);
}

.hidden { display: none !important; }

/* ============================================
   MAIN CONTENT
   ============================================ */

#weather-content {
  flex: 1;
  padding: 28px 28px 20px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: content-in 0.6s var(--ease-out);
}

@keyframes content-in {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================
   CURRENT WEATHER HERO
   ============================================ */

#current-weather {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  position: relative;
  overflow: hidden;
}

#current-weather::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(96,165,250,0.06) 0%, transparent 50%);
  pointer-events: none;
}

#current-left {
  position: relative;
  z-index: 1;
}

#current-location {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

#city-name {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

#current-date {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 300;
}

#current-temp-block {
  display: flex;
  align-items: flex-start;
  margin-top: 16px;
}

#current-temp {
  font-size: 5.5rem;
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.04em;
}

#current-unit {
  font-size: 1.8rem;
  font-weight: 300;
  color: var(--text-secondary);
  margin-top: 8px;
  margin-left: 2px;
}

#current-description {
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: 8px;
  text-transform: capitalize;
}

#current-hi-lo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 300;
}

.sep {
  color: var(--text-tertiary);
}

#current-right {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

#weather-icon-large {
  width: 140px;
  height: 140px;
  font-size: 7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 4px 20px rgba(0,0,0,0.3));
  animation: icon-float 4s ease-in-out infinite;
}

@keyframes icon-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}

/* ============================================
   DETAIL CARDS GRID
   ============================================ */

#detail-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.detail-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: all 0.25s var(--ease-out);
  position: relative;
  overflow: hidden;
}

.detail-card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

#card-feels::before  { background: linear-gradient(135deg, rgba(251,191,36,0.08), transparent); }
#card-humidity::before { background: linear-gradient(135deg, rgba(96,165,250,0.08), transparent); }
#card-wind::before   { background: linear-gradient(135deg, rgba(52,211,153,0.08), transparent); }
#card-uv::before     { background: linear-gradient(135deg, rgba(244,114,182,0.08), transparent); }
#card-visibility::before { background: linear-gradient(135deg, rgba(167,139,250,0.08), transparent); }
#card-pressure::before { background: linear-gradient(135deg, rgba(251,146,60,0.08), transparent); }

.detail-card:hover::before {
  opacity: 1;
}

.detail-card:hover {
  border-color: rgba(255,255,255,0.14);
  transform: translateY(-2px);
}

.detail-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.detail-value {
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.detail-sub {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 300;
}

.detail-bar {
  margin-top: 10px;
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  overflow: hidden;
}

.detail-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), #818cf8);
  width: 0%;
  transition: width 0.8s var(--ease-out);
}

/* ============================================
   FORECAST SECTIONS
   ============================================ */

.forecast-section {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  overflow: hidden;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 18px;
}

.section-title svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
}

/* Hourly */
#hourly-scroll {
  overflow-x: auto;
  margin: 0 -24px;
  padding: 0 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

#hourly-scroll::-webkit-scrollbar {
  height: 4px;
}

#hourly-scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}

#hourly-cards {
  display: flex;
  gap: 6px;
  padding-bottom: 8px;
}

.hourly-card {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  min-width: 72px;
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
  transition: all 0.2s;
}

.hourly-card:hover {
  background: rgba(255,255,255,0.06);
  border-color: var(--glass-border);
}

.hourly-card.now {
  background: rgba(96,165,250,0.1);
  border-color: rgba(96,165,250,0.2);
}

.hourly-time {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
}

.hourly-icon {
  font-size: 1.5rem;
}

.hourly-temp {
  font-size: 0.95rem;
  font-weight: 600;
}

.hourly-precip {
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 400;
}

/* Daily */
#daily-cards {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.daily-card {
  display: grid;
  grid-template-columns: 110px 40px 1fr 80px;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.daily-card:hover {
  background: rgba(255,255,255,0.04);
}

.daily-card.today {
  background: rgba(96,165,250,0.06);
}

.daily-day {
  font-size: 0.9rem;
  font-weight: 500;
}

.daily-icon {
  font-size: 1.35rem;
  text-align: center;
}

.daily-temp-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.daily-lo {
  color: var(--text-tertiary);
  font-weight: 400;
  min-width: 32px;
  text-align: right;
}

.daily-bar-track {
  flex: 1;
  height: 5px;
  background: rgba(255,255,255,0.06);
  border-radius: 5px;
  position: relative;
  overflow: hidden;
}

.daily-bar-fill {
  position: absolute;
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--accent), #818cf8, var(--accent-rose));
  transition: all 0.8s var(--ease-out);
}

.daily-hi {
  font-weight: 600;
  min-width: 32px;
}

.daily-precip {
  font-size: 0.78rem;
  color: var(--accent);
  text-align: right;
  font-weight: 400;
}

/* Sun / Sunset cards */
#sun-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.sun-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 16px;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.sun-card:hover {
  background: rgba(255,255,255,0.06);
}

.sun-card-icon {
  font-size: 1.8rem;
}

.sun-card-label {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.sun-card-time {
  font-size: 1.2rem;
  font-weight: 600;
}

/* ============================================
   FOOTER
   ============================================ */

#footer {
  position: relative;
  z-index: 20;
  text-align: center;
  padding: 20px;
  font-size: 0.78rem;
  color: var(--text-tertiary);
  font-weight: 300;
}

#footer a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

#footer a:hover {
  color: #93c5fd;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  #top-bar {
    padding: 10px 16px;
    gap: 10px;
  }

  #brand span {
    display: none;
  }

  #search-container {
    max-width: none;
  }

  #weather-content {
    padding: 16px 14px 16px;
    gap: 16px;
  }

  #current-weather {
    flex-direction: column;
    text-align: center;
    padding: 28px 24px;
  }

  #current-location {
    justify-content: center;
  }

  #current-temp-block {
    justify-content: center;
  }

  #current-temp {
    font-size: 4rem;
  }

  #weather-icon-large {
    width: 100px;
    height: 100px;
    font-size: 5rem;
  }

  #detail-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .daily-card {
    grid-template-columns: 80px 32px 1fr 60px;
    gap: 8px;
    padding: 10px 8px;
  }

  #sun {
    width: 60px; height: 60px;
  }

  #moon {
    width: 45px; height: 45px;
  }
}

@media (max-width: 480px) {
  #detail-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .detail-card {
    padding: 16px;
  }

  .detail-value {
    font-size: 1.3rem;
  }

  #current-temp {
    font-size: 3.5rem;
  }

  #sun-cards {
    grid-template-columns: 1fr;
  }
}
