:root {
  --bg-start: #0f1c2e;
  --bg-end: #1a3a5c;
  --card-bg: rgba(255, 255, 255, 0.07);
  --card-border: rgba(255, 255, 255, 0.12);
  --accent: #4fc3f7;
  --accent-glow: rgba(79, 195, 247, 0.3);
  --text-primary: #f0f4f8;
  --text-secondary: rgba(240, 244, 248, 0.6);
  --input-bg: rgba(255, 255, 255, 0.08);
  --error: #ff6b6b;
  --success: #69db7c;
  --radius: 18px;
  --transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 24px;
  font-family: 'Outfit', sans-serif;
  background: linear-gradient(160deg, var(--bg-start) 0%, var(--bg-end) 100%);
  color: var(--text-primary);
  overflow-x: hidden;
  position: relative;
}

/* ── Animated background orbs ── */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  pointer-events: none;
  animation: float 20s ease-in-out infinite;
}

.bg-orb:nth-child(1) {
  width: 500px;
  height: 500px;
  background: #4fc3f7;
  top: -10%;
  left: -10%;
  animation-duration: 25s;
}

.bg-orb:nth-child(2) {
  width: 400px;
  height: 400px;
  background: #7c4dff;
  bottom: -15%;
  right: -10%;
  animation-duration: 30s;
  animation-delay: -5s;
}

.bg-orb:nth-child(3) {
  width: 300px;
  height: 300px;
  background: #00e5ff;
  top: 50%;
  left: 60%;
  animation-duration: 22s;
  animation-delay: -10s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25%      { transform: translate(40px, -30px) scale(1.05); }
  50%      { transform: translate(-20px, 20px) scale(0.95); }
  75%      { transform: translate(30px, 40px) scale(1.02); }
}

/* ── Main Card ── */
.container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-radius: var(--radius);
  padding: 40px 32px 32px;
  text-align: center;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset;
  animation: cardEnter 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.96);
  }
}

/* ── Header ── */
.header {
  margin-bottom: 28px;
}

.header-icon {
  font-size: 28px;
  display: inline-block;
  margin-bottom: 8px;
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.1); }
}

h1 {
  font-family: 'Playfair Display', serif;
  font-size: 1.9em;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.subtitle {
  font-size: 0.85em;
  color: var(--text-secondary);
  margin-top: 6px;
  font-weight: 300;
}

/* ── Search Form ── */
.search-form {
  display: flex;
  gap: 0;
  margin-bottom: 10px;
  position: relative;
}

.search-input {
  flex: 1;
  padding: 14px 18px 14px 44px;
  border: 1px solid var(--card-border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 1em;
  outline: none;
  transition: var(--transition);
}

.search-input::placeholder {
  color: var(--text-secondary);
}

.search-input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--text-secondary);
  pointer-events: none;
  z-index: 2;
}

.search-btn {
  padding: 14px 22px;
  border: 1px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: linear-gradient(135deg, var(--accent), #039be5);
  color: var(--bg-start);
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.95em;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.search-btn:hover {
  filter: brightness(1.15);
  transform: scaleX(1.03);
}

.search-btn:active {
  transform: scale(0.97);
}

.search-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Autocomplete suggestions ── */
.suggestions-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #162b44;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  overflow: hidden;
  z-index: 100;
  list-style: none;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  animation: fadeIn 0.15s ease;
}

.suggestions-list[hidden] {
  display: none;
}

.suggestion-item {
  padding: 11px 16px;
  font-size: 0.88em;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover {
  background: rgba(79, 195, 247, 0.1);
  color: var(--accent);
}

/* ── Geolocation button ── */
.geo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-bottom: 18px;
  padding: 9px 18px;
  background: transparent;
  border: 1px solid var(--card-border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.82em;
  font-weight: 400;
  cursor: pointer;
  transition: var(--transition);
}

.geo-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.geo-btn:active {
  transform: scale(0.98);
}

.geo-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Weather Result ── */
.weather-result {
  min-height: 60px;
  transition: var(--transition);
}

.weather-result:empty {
  display: none;
}

.weather-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 24px 20px;
  animation: resultEnter 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes resultEnter {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
}

.city-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.5em;
  font-weight: 700;
  margin-bottom: 4px;
}

.country-tag {
  display: inline-block;
  font-size: 0.7em;
  background: rgba(79, 195, 247, 0.15);
  color: var(--accent);
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 600;
  letter-spacing: 0.05em;
  vertical-align: middle;
  margin-left: 4px;
}

.weather-emoji {
  font-size: 72px;
  line-height: 1;
  margin: 16px 0 8px;
  display: block;
  animation: emojiPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: 0.15s;
}

@keyframes emojiPop {
  from {
    opacity: 0;
    transform: scale(0.4) rotate(-10deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

.weather-desc {
  font-size: 1em;
  color: var(--accent);
  text-transform: capitalize;
  font-weight: 600;
  margin-bottom: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 14px 10px;
  animation: statSlide 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.stat-item:nth-child(1) { animation-delay: 0.2s; }
.stat-item:nth-child(2) { animation-delay: 0.28s; }
.stat-item:nth-child(3) { animation-delay: 0.36s; }
.stat-item:nth-child(4) { animation-delay: 0.44s; }

@keyframes statSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

.stat-icon {
  font-size: 20px;
  margin-bottom: 4px;
  display: block;
}

.stat-value {
  font-size: 1.25em;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
}

.stat-label {
  font-size: 0.72em;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 400;
  margin-top: 2px;
}

/* ── Loader ── */
.loader-wrap {
  padding: 30px 0;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
}

.loader {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader-text {
  font-size: 0.85em;
  color: var(--text-secondary);
  font-weight: 300;
}

/* ── Error ── */
.error-card {
  background: rgba(255, 107, 107, 0.08);
  border: 1px solid rgba(255, 107, 107, 0.2);
  border-radius: 14px;
  padding: 20px;
  animation: shake 0.5s ease;
}

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

.error-icon {
  font-size: 32px;
  margin-bottom: 8px;
  display: block;
}

.error-msg {
  color: var(--error);
  font-weight: 600;
  font-size: 0.95em;
}

.error-hint {
  color: var(--text-secondary);
  font-size: 0.8em;
  margin-top: 6px;
}

/* ── Forecast ── */
#forecastResult:empty {
  display: none;
}

.forecast-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 20px 16px;
  margin-top: 12px;
  animation: resultEnter 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 0.1s;
}

.forecast-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.72em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.forecast-day {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: statSlide 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.forecast-date {
  font-size: 0.72em;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.forecast-date small {
  font-weight: 400;
  font-size: 0.88em;
}

.forecast-emoji {
  font-size: 26px;
  line-height: 1;
}

.forecast-temps {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.forecast-max {
  font-size: 0.92em;
  font-weight: 700;
  color: var(--text-primary);
}

.forecast-min {
  font-size: 0.75em;
  color: var(--text-secondary);
}

/* ── Footer ── */
.footer {
  margin-top: 20px;
  font-size: 0.72em;
  color: var(--text-secondary);
  font-weight: 300;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .container {
    padding: 28px 16px 24px;
  }

  h1 {
    font-size: 1.5em;
  }

  .search-input {
    min-width: 0;
    padding: 12px 14px 12px 40px;
  }

  .search-btn {
    padding: 12px 16px;
    font-size: 0.85em;
    flex-shrink: 0;
  }

  .weather-emoji {
    font-size: 56px;
  }

  .stats-grid {
    gap: 8px;
  }

  .stat-item {
    padding: 10px 8px;
  }

  .stat-value {
    font-size: 1.1em;
  }
}
