/* ---------- Reset & base ---------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #eef2f7;
  --color-surface: #ffffff;
  --color-primary: #2f6fed;
  --color-primary-dark: #1f52b8;
  --color-text: #1c2331;
  --color-text-muted: #5a6472;
  --color-error: #d64545;
  --color-error-bg: #fdeaea;
  --radius: 12px;
  --shadow: 0 4px 16px rgba(20, 30, 60, 0.08);
}

body {
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* ---------- App shell ---------- */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 24px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.app-header {
  text-align: center;
  position: relative;
}

/* ---------- Language toggle ---------- */
.lang-toggle {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background: none;
  border: 1px solid #d3d9e2;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.lang-toggle:hover {
  border-color: var(--color-primary);
}

.lang-toggle:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.lang-toggle__divider {
  opacity: 0.4;
}

.lang-toggle__option {
  opacity: 0.5;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.lang-toggle__option.is-active {
  opacity: 1;
  color: var(--color-primary);
}

.app-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

.app-subtitle {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin-top: 4px;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

/* ---------- Search bar ---------- */
.search-bar {
  display: flex;
  gap: 8px;
}

.city-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid #d3d9e2;
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--color-surface);
  color: var(--color-text);
}

.city-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.15);
}

.city-input:disabled {
  background: #f2f4f8;
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.search-button {
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  background: var(--color-primary);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
  white-space: nowrap;
}

.search-button:hover {
  background: var(--color-primary-dark);
}

.search-button:active {
  transform: translateY(1px);
}

.search-button:disabled {
  background: #9db3d8;
  cursor: not-allowed;
  transform: none;
}

/* ---------- Recent searches ---------- */
.recent-searches {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.recent-searches__label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.recent-searches__item {
  padding: 6px 14px;
  border: 1px solid #d3d9e2;
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.recent-searches__item:hover {
  background: #eaf0fd;
  border-color: var(--color-primary);
}

.recent-searches__item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--color-surface);
  border-color: #d3d9e2;
}

/* ---------- Results area ---------- */
.results {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.state {
  display: none;
  width: 100%;
  text-align: center;
  padding: 32px 20px;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.state.is-active {
  display: block;
  animation: state-fade-in 0.25s ease;
}

@keyframes state-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .state.is-active {
    animation: none;
  }
}

.idle-icon {
  font-size: 1.75rem;
  margin-bottom: 8px;
  opacity: 0.6;
}

.state--idle p:last-child {
  color: var(--color-text-muted);
}

/* Loading state */
.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 16px;
  border: 4px solid #dfe6f0;
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.state--loading p {
  color: var(--color-text-muted);
}

/* Error state */
.state--error {
  background: var(--color-error-bg);
}

.error-icon {
  font-size: 1.75rem;
  margin-bottom: 8px;
}

.error-message {
  color: var(--color-error);
  font-weight: 600;
}

/* Result state */
.weather-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.weather-card__icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 4px;
}

.weather-card__top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.weather-card__city {
  font-size: 1.4rem;
  font-weight: 700;
}

.weather-card__condition {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.weather-card__temp {
  font-size: 3.25rem;
  font-weight: 700;
  color: var(--color-primary);
  margin: 8px 0 4px;
}

.weather-card__details {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #edf0f5;
}

.detail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.detail__label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail__value {
  font-weight: 600;
}

/* ---------- Responsive breakpoints ---------- */
@media (min-width: 600px) {
  .app {
    max-width: 560px;
    padding-top: 48px;
  }

  .app-header h1 {
    font-size: 2.1rem;
  }

  .weather-card__icon {
    font-size: 3.5rem;
  }

  .weather-card__temp {
    font-size: 3.5rem;
  }
}

@media (min-width: 900px) {
  .app {
    max-width: 640px;
  }

  .search-bar {
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
  }
}
