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

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f0f4f8;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.15);
  --warm: #fb923c;
  --cold: #7dd3fc;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

body {
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(56, 189, 248, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(99, 102, 241, 0.08), transparent);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.header {
  margin-bottom: 2rem;
}

.favorites {
  margin-bottom: 1.5rem;
}

.favorites.hidden {
  display: none;
}

.favorites__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.favorites__item {
  display: flex;
  align-items: stretch;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
}

.favorites__item--active {
  border-color: rgba(56, 189, 248, 0.45);
  background: var(--accent-soft);
}

.favorites__select {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  padding: 0.45rem 0.85rem;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  min-width: 0;
}

.favorites__select:hover,
.favorites__select:focus-visible {
  background: var(--surface-hover);
  outline: none;
}

.favorites__name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 12rem;
}

.favorites__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 12rem;
}

.favorites__remove {
  flex-shrink: 0;
  width: 2rem;
  border: none;
  border-left: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}

.favorites__remove:hover,
.favorites__remove:focus-visible {
  color: #f87171;
  background: rgba(248, 113, 113, 0.12);
  outline: none;
}

.header__favorite {
  flex-shrink: 0;
  margin-left: auto;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

.header__favorite[aria-pressed="true"] {
  border-color: rgba(56, 189, 248, 0.45);
  background: var(--accent-soft);
}

.header__favorite:hover,
.header__favorite:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.header__location {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.storm-alerts {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.storm-alerts.hidden {
  display: none;
}

.storm-alert {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  border: 1px solid rgba(251, 146, 60, 0.35);
  background: rgba(251, 146, 60, 0.12);
}

.storm-alert--official {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.12);
}

.storm-alert__icon {
  font-size: 1.75rem;
  line-height: 1;
}

.storm-alert__title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.storm-alert__message {
  color: var(--text);
  font-size: 0.95rem;
}

.storm-alert__meta {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.35rem;
}

.storm-alert__notify-btn {
  align-self: flex-start;
  background: transparent;
  border: 1px solid rgba(251, 146, 60, 0.45);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.storm-alert__notify-btn:hover {
  background: rgba(251, 146, 60, 0.12);
}

.storm-alert__notify-status {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.search {
  margin-bottom: 1.5rem;
}

.search__label {
  display: block;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.search__field {
  position: relative;
}

.search__input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

.search__input:focus {
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.search__results {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  z-index: 20;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 280px;
  overflow-y: auto;
}

.search__result {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.search__result:hover,
.search__result:focus-visible {
  background: var(--surface-hover);
  outline: none;
}

.search__result-name {
  font-weight: 600;
}

.search__result-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.search__empty {
  padding: 0.85rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.header__pin {
  font-size: 1.75rem;
}

.header__city {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header__updated {
  margin-top: 0.75rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.today {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.today-card {
  width: 100%;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.today-card--loading {
  position: relative;
  display: block;
}

.today-card--loading .today__content {
  opacity: 0.45;
}

.today-card:has(.today__content) {
  min-height: auto;
}

.radar {
  margin-bottom: 2rem;
  width: 100%;
}

.radar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.radar__title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.radar__toggle,
.forecast__toggle {
  flex-shrink: 0;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-elevated, var(--surface));
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

.radar__toggle:hover,
.forecast__toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}

.radar__toggle:focus-visible,
.forecast__toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.radar--collapsed .radar__header {
  margin-bottom: 0;
}

.radar--collapsed .radar__content {
  display: none;
}

.radar__credit {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.radar__credit a {
  color: var(--accent);
  text-decoration: none;
}

.radar__credit a:hover {
  text-decoration: underline;
}

.radar .precipitation-map-container {
  border-radius: calc(var(--radius) - 4px);
  overflow: hidden;
  border: 1px solid var(--border);
}

.radar .precipitation-map-container #map {
  height: 846px;
}

.radar .precipitation-map-container .time-controls {
  border-radius: 0;
}

@media (max-width: 520px) {
  .radar .precipitation-map-container #map {
    height: 320px;
  }
}

.today__content {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.today__main {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.today__icon,
.forecast-day__icon,
.hourly-row__icon {
  flex-shrink: 0;
}

.weather-icon {
  display: block;
  object-fit: contain;
}

.weather-icon--lg {
  width: 4rem;
  height: 4rem;
}

.weather-icon--md {
  width: 3.75rem;
  height: 3.75rem;
}

.weather-icon--sm {
  width: 3.75rem;
  height: 3.75rem;
}

.weather-icon--fallback {
  line-height: 1;
  text-align: center;
}

.weather-icon--fallback.weather-icon--lg {
  font-size: 4rem;
}

.weather-icon--fallback.weather-icon--md {
  font-size: 1.75rem;
}

.weather-icon--fallback.weather-icon--sm {
  font-size: 1.25rem;
}

.today__temp {
  font-size: 3.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.today__label {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.today__description {
  font-size: 1.25rem;
  font-weight: 500;
  margin-top: 0.25rem;
}

.today__details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem 1.5rem;
}

.today__detail {
  display: flex;
  flex-direction: column;
}

.today__detail-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.today__detail-value {
  font-weight: 600;
  font-size: 1rem;
}

.forecast__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.forecast__title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-muted);
}

.forecast--collapsed .forecast__heading {
  margin-bottom: 0;
}

.forecast--collapsed .forecast__content {
  display: none;
}

.forecast__hint {
  font-weight: 400;
  font-size: 0.85rem;
  opacity: 0.75;
}

.forecast__header {
  display: grid;
  grid-template-columns: 241px 241px 241px 241px 241px;
  padding: 0 0.5rem 0.5rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.forecast__header span:nth-child(n + 2):not(:last-child) {
  text-align: center;
}

.forecast__header span:last-child {
  text-align: right;
}

.forecast__grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.forecast__grid--loading {
  position: relative;
}

.forecast__grid--loading .forecast-day-group {
  opacity: 0.45;
}

.forecast-day--loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 8rem;
  cursor: default;
  pointer-events: none;
}

.forecast-day--loading:hover {
  background: var(--surface);
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 20, 25, 0.55);
  backdrop-filter: blur(2px);
  border-radius: 12px;
}

.forecast-day-group {
  border-radius: 12px;
  overflow: hidden;
}

.forecast-day-group--today .forecast-day {
  border-color: rgba(56, 189, 248, 0.35);
  background: var(--accent-soft);
}

.forecast-day-group--expanded .forecast-day {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: var(--surface-hover);
}

.forecast-day {
  display: grid;
  align-items: center;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  transition: background 0.15s ease;
  color: inherit;
  font: inherit;
  text-align: inherit;
  cursor: pointer;
}

.forecast-day:not(.forecast-day--loading) {
  grid-template-columns: 241px 241px 241px 241px 241px;
}

.forecast-day:hover {
  background: var(--surface-hover);
}

.forecast-day--today {
  border-color: rgba(56, 189, 248, 0.35);
  background: var(--accent-soft);
}

.forecast-day__hours-wrap {
  background: rgba(15, 20, 25, 0.55);
  border: 1px solid var(--border);
  border-top: none;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

.forecast-day__hours {
  padding: 0 1.25rem 1rem;
}

.hourly__header {
  display: grid;
  grid-template-columns: 241px 241px 241px 241px 241px;
  padding: 0.75rem 1.25rem 0.5rem;
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hourly__header span:nth-child(n + 2):not(:last-child) {
  text-align: center;
}

.hourly__header span:last-child {
  text-align: right;
}

.hourly__list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.hourly-row {
  display: grid;
  grid-template-columns: 241px 241px 241px 241px 241px;
  align-items: center;
  padding: 0.55rem 0;
  border-radius: 8px;
  font-size: 0.85rem;
}

.hourly-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.hourly-row--current {
  background: var(--accent-soft);
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  margin: 0 -0.75rem;
}

.hourly-row--current .hourly-row__time {
  color: var(--text);
  font-weight: 600;
}

.hourly-row__time {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.hourly-row__temp {
  font-weight: 600;
  text-align: center;
}

.hourly-row__precip {
  color: var(--accent);
  text-align: right;
  font-size: 0.85rem;
  font-weight: 600;
}

.hourly-row__wind {
  color: var(--text);
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
}

.hourly-row__humidity {
  color: var(--text-muted);
  text-align: center;
  font-size: 0.8rem;
}

.hourly__empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.5rem;
}

.forecast-day__date {
  display: flex;
  flex-direction: column;
}

.forecast-day__weekday {
  font-weight: 600;
  font-size: 0.95rem;
}

.forecast-day__date-num {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.forecast-day__icon,
.hourly-row__icon {
  justify-self: center;
}

.forecast-day__temps {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
}

.forecast-day__high {
  font-weight: 600;
}

.forecast-day__low {
  color: var(--text-muted);
}

.forecast-day__wind {
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
}

.forecast-day__precip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.forecast-day__precip-amount {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
}

.forecast-day__precip-prob {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  width: 100%;
  text-align: center;
  color: var(--text-muted);
}

.today-card > .loading {
  min-height: 120px;
}

.forecast-day--loading .loading,
.loading-overlay .loading {
  width: auto;
}

.loading__spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  margin-top: 1rem;
}

.error.hidden {
  display: none;
}

.error__message {
  margin-bottom: 1rem;
  color: #fca5a5;
}

.error__retry {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.25rem;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.error__retry:hover {
  opacity: 0.85;
}

.footer {
  margin-top: 2.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

@media (max-width: 520px) {
  .today__content {
    flex-direction: column;
    align-items: flex-start;
  }

  .forecast__header {
    display: none;
  }

  .forecast-day:not(.forecast-day--loading) {
    grid-template-columns: 1fr auto auto auto 20px;
    grid-template-rows: auto auto auto;
  }

  .forecast-day__wind,
  .forecast-day__precip {
    grid-column: 1 / -2;
  }

  .forecast-day__wind {
    text-align: left;
    min-width: unset;
  }

  .forecast-day__precip {
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-start;
    min-width: unset;
  }

  .forecast-day__chevron {
    grid-row: 1;
    grid-column: -1;
    align-self: center;
  }

  .hourly__header {
    display: none;
  }

  .hourly-row {
    grid-template-columns: 241px 241px 241px 241px 241px ;
    grid-template-rows: auto auto;
  }

  .hourly-row__precip,
  .hourly-row__wind,
  .hourly-row__humidity {
    grid-column: 1 / -1;
    text-align: left;
    font-size: 0.75rem;
  }

  .hourly-row__precip::before { content: "Précip. : "; color: var(--text-muted); }
  .hourly-row__wind::before { content: "Vent : "; color: var(--text-muted); }
  .hourly-row__humidity::before { content: "Humidité : "; color: var(--text-muted); }
}
