:root {
  --bg: linear-gradient(160deg, #a8edea 0%, #74b9ff 40%, #0984e3 100%);
  --glass: rgba(255, 255, 255, 0.25);
  --glass-border: rgba(255, 255, 255, 0.45);
  --text: #0d1b2a;
  --text-muted: rgba(13, 27, 42, 0.6);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  --radius: 20px;
}

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

body {
  min-height: 100vh;
  background: var(--bg);
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  transition: background 1.5s ease, color 0.4s;
}

.glass {
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ── Loading overlay ── */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(3px);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-overlay.visible {
  display: flex;
}

.spinner {
  width: 52px;
  height: 52px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Error toast ── */
.error-toast {
  display: none;
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(220, 53, 69, 0.92);
  color: #fff;
  padding: 0.7rem 1.5rem;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 1001;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(220, 53, 69, 0.4);
  white-space: nowrap;
}

.error-toast.visible {
  display: block;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { transform: translateX(-50%) translateY(-16px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

/* ── App shell ── */
.app {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 1rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Search ── */
.search-card {
  padding: 1.25rem 1.5rem;
}

.search-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid var(--glass-border);
  border-radius: 50px;
  padding: 0.5rem 1rem;
  margin-bottom: 0.75rem;
  transition: box-shadow 0.2s;
}

.search-wrapper:focus-within {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.4);
}

.search-wrapper input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
}

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

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem 0.5rem;
  transition: opacity 0.2s;
  line-height: 1;
}

.btn-icon:hover {
  opacity: 0.6;
}

.header-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.city {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  min-height: 1.8rem;
}

.date-time {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Main grid ── */
.main-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  flex: 1;
}

/* ── Weather card ── */
.weather-card {
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.weather-icon {
  width: 140px;
  height: 140px;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.18));
  animation: float 4s ease-in-out infinite;
}

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

.temp-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.degrees {
  font-size: 5rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -3px;
}

.unit-toggle {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
}

.unit-btn {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.1rem 0;
  transition: color 0.2s, font-size 0.15s;
  line-height: 1.3;
}

.unit-btn.active {
  color: var(--text);
  font-size: 1.35rem;
}

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

.description {
  font-size: 1.1rem;
  font-weight: 500;
  text-transform: capitalize;
  min-height: 1.4rem;
}

.min-max {
  display: flex;
  gap: 1.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ── Side panel ── */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Details: 2-column grid ── */
.details-card {
  padding: 1.25rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.detail-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.detail-item i {
  font-size: 1.15rem;
  width: 1.25rem;
  text-align: center;
  opacity: 0.7;
  flex-shrink: 0;
}

.detail-value {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
}

.detail-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

/* ── Forecast ── */
.forecast-card {
  padding: 1.25rem;
  flex: 1;
}

.forecast-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}

.card-weather {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  text-align: center;
}

.card-weather .today {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.forecast-icon {
  width: 36px;
  height: 36px;
}

.temperatures {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Footer ── */
footer {
  text-align: center;
  padding: 0.25rem;
}

.coder {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.coder a {
  color: var(--text);
  text-decoration: none;
  margin-left: 0.4rem;
  opacity: 0.75;
  transition: opacity 0.2s;
}

.coder a:hover {
  opacity: 1;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .app {
    padding: 1rem;
  }

  .main-content {
    grid-template-columns: 1fr;
  }

  .weather-card {
    padding: 1.5rem 1rem;
  }

  .degrees {
    font-size: 4rem;
  }

  .weather-icon {
    width: 110px;
    height: 110px;
  }

  .details-card {
    grid-template-columns: 1fr 1fr;
    padding: 1rem;
    gap: 0.75rem;
  }

  .forecast-icon {
    width: 28px;
    height: 28px;
  }

  .card-weather .today,
  .temperatures {
    font-size: 0.62rem;
  }
}
