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

:root {
  --bg: #f4f7fa;
  --surface: #ffffff;
  --surface-soft: #eef3f7;
  --border: #dbe3ea;

  --text: #17212b;
  --muted: #667582;
  --subtle: #8a98a5;

  --accent: #1976d2;
  --accent-dark: #125da5;

  --danger: #c62828;
  --warning: #a66a00;
  --success: #237a4b;

  --radius: 12px;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;

  background: var(--bg);
  color: var(--text);

  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  padding:
    max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));

  overflow-x: hidden;

  -webkit-tap-highlight-color: transparent;

  transition:
    background 1.2s ease,
    color 0.45s ease;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(25, 118, 210, 0.3);
  outline-offset: 2px;
}

.app {
  position: relative;
  z-index: 1;

  width: 100%;
  max-width: 760px;

  margin: 0 auto;

  padding-bottom:
    env(safe-area-inset-bottom);
}

/* =========================
   HEADER
========================= */

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;

  gap: 14px;

  margin-bottom: 18px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;

  flex-shrink: 0;
}

.eyebrow {
  color: var(--accent);

  font-size: 0.7rem;
  font-weight: 800;

  letter-spacing: 0.16em;

  margin-bottom: 5px;
}

.header h1 {
  font-size: 1.9rem;
  line-height: 1;

  font-weight: 750;

  letter-spacing: -0.03em;
}

/* =========================
   UNIT BUTTON
========================= */

.unit-button {
  min-height: 40px;

  border: 1px solid var(--border);

  background: var(--surface);
  color: var(--text);

  border-radius: 9px;

  padding: 8px 13px;

  font-weight: 700;

  touch-action: manipulation;

  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.45s ease,
    transform 0.15s ease;
}

.unit-button:hover {
  background: var(--surface-soft);
  border-color: #c7d2dc;
}

.unit-button:active {
  transform: scale(0.96);
}

/* =========================
   THEME BUTTON
========================= */

.theme-toggle {
  position: relative;

  width: 58px;
  height: 32px;

  padding: 0;

  border: 1px solid var(--border);
  border-radius: 999px;

  background: var(--surface-soft);

  overflow: hidden;

  touch-action: manipulation;

  transition:
    background 0.45s ease,
    border-color 0.45s ease;
}

.theme-toggle::before {
  content: "";

  position: absolute;

  top: 3px;
  left: 3px;

  width: 24px;
  height: 24px;

  border-radius: 50%;

  background: var(--accent);

  box-shadow:
    0 2px 5px rgba(0, 0, 0, 0.18);

  transition:
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.45s ease;
}

body.dark .theme-toggle::before {
  transform: translateX(26px);
}

.theme-toggle::after {
  content: "☀";

  position: absolute;

  left: 8px;
  top: 6px;

  font-size: 13px;
  line-height: 1;

  color: var(--text);

  transition:
    opacity 0.25s ease,
    transform 0.35s ease,
    color 0.45s ease;
}

body.dark .theme-toggle::after {
  content: "☾";

  left: auto;
  right: 8px;

  color: #dbeafe;
}

.theme-toggle:active::before {
  transform: scale(0.85);
}

body.dark .theme-toggle:active::before {
  transform: translateX(26px) scale(0.85);
}

/* =========================
   SEARCH
========================= */

.search-section {
  margin-bottom: 16px;
}

#searchForm {
  display: flex;
  gap: 8px;

  width: 100%;
}

#cityInput {
  flex: 1;
  min-width: 0;

  min-height: 46px;

  border: 1px solid var(--border);
  outline: none;

  background: var(--surface);
  color: var(--text);

  border-radius: 9px;

  padding: 12px 14px;

  appearance: none;
  -webkit-appearance: none;

  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.45s ease,
    color 0.45s ease;
}

#cityInput::placeholder {
  color: var(--subtle);
}

#cityInput:focus {
  border-color: var(--accent);

  box-shadow:
    0 0 0 3px rgba(25, 118, 210, 0.1);
}

#searchForm button {
  min-height: 46px;

  border: none;

  background: var(--accent);
  color: white;

  border-radius: 9px;

  padding: 0 18px;

  font-weight: 750;

  touch-action: manipulation;

  transition:
    background 0.15s ease,
    transform 0.15s ease;
}

#searchForm button:hover {
  background: var(--accent-dark);
}

#searchForm button:active {
  transform: scale(0.97);
}

.status {
  color: var(--muted);

  font-size: 0.82rem;

  margin-top: 8px;

  min-height: 19px;
}

/* =========================
   SKYORA ALERT
========================= */

.alert-box {
  margin: 16px 0;
  padding: 16px;

  border: 1px solid #e0b44c;
  border-left: 5px solid var(--warning);

  border-radius: 9px;

  background: #fff9e8;

  animation: alertAppear 0.25s ease-out;

  box-shadow: none;

  overflow: hidden;
}

.alert-box[hidden] {
  display: none;
}

.alert-header {
  display: flex;
  align-items: center;

  gap: 11px;
}

.alert-icon {
  width: 42px;
  height: 42px;

  display: grid;
  place-items: center;

  flex-shrink: 0;

  border-radius: 8px;

  background: #fff0c2;

  font-size: 1.3rem;
}

.alert-heading {
  min-width: 0;
}

.alert-label {
  color: var(--warning);

  font-size: 0.67rem;
  font-weight: 850;

  letter-spacing: 0.1em;

  margin-bottom: 3px;
}

.alert-heading h2 {
  font-size: 1.08rem;
  line-height: 1.25;

  overflow-wrap: anywhere;
}

.alert-content {
  margin-top: 13px;
}

#alertDescription {
  color: #4c4534;

  font-size: 0.9rem;
  line-height: 1.55;

  white-space: pre-line;

  overflow-wrap: anywhere;
}

.alert-details {
  display: grid;
  gap: 6px;

  margin-top: 12px;

  color: #756c59;

  font-size: 0.78rem;
}

.alert-details p {
  overflow-wrap: anywhere;
}

.alert-details strong {
  color: #4e4635;
}

.dismiss-alert {
  width: 100%;

  min-height: 42px;

  margin-top: 14px;

  border: 1px solid #dfd4b7;

  background: #fffdf6;
  color: #514a3b;

  border-radius: 7px;

  padding: 10px;

  font-weight: 700;

  touch-action: manipulation;

  transition:
    background 0.15s ease,
    transform 0.15s ease;
}

.dismiss-alert:hover {
  background: #fff8e6;
}

.dismiss-alert:active {
  transform: scale(0.98);
}

@keyframes alertAppear {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.current-card {
  border: 1px solid var(--border);

  border-radius: var(--radius);

  background: var(--surface);

  padding: 20px;

  box-shadow:
    0 2px 8px rgba(25, 40, 55, 0.05);

  transition:
    background 0.45s ease,
    border-color 0.45s ease,
    box-shadow 0.45s ease,
    color 0.45s ease;
}

.location h2 {
  font-size: 1.4rem;
  line-height: 1.2;

  letter-spacing: -0.02em;

  overflow-wrap: anywhere;
}

.location p {
  color: var(--muted);

  margin-top: 3px;

  font-size: 0.82rem;
}

.current-weather {
  text-align: center;

  padding: 25px 0;
}

.weather-icon {
  font-size: 3.6rem;

  line-height: 1;

  margin-bottom: 10px;
}

.temperature {
  font-size: 4.5rem;

  line-height: 0.95;

  font-weight: 750;

  letter-spacing: -0.07em;
}

.condition {
  color: var(--muted);

  font-size: 0.95rem;

  margin-top: 8px;
}

.weather-details {
  display: grid;

  grid-template-columns: repeat(2, 1fr);

  gap: 1px;

  background: var(--border);

  border: 1px solid var(--border);

  border-radius: 9px;

  overflow: hidden;
}

.detail {
  min-width: 0;

  padding: 12px;

  background: var(--surface);
}

.detail span {
  display: block;

  color: var(--muted);

  font-size: 0.7rem;

  margin-bottom: 4px;
}

.detail strong {
  font-size: 0.93rem;

  overflow-wrap: anywhere;
}

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

.forecast-section {
  margin-top: 24px;
}

.section-heading {
  margin-bottom: 9px;
}

.section-heading h2 {
  font-size: 1.05rem;
  font-weight: 750;
}

/* =========================
   HOURLY
========================= */

.hourly-list {
  display: flex;

  gap: 1px;

  overflow-x: auto;
  overflow-y: hidden;

  padding-bottom: 5px;

  background: var(--border);

  border: 1px solid var(--border);

  border-radius: 9px;

  -webkit-overflow-scrolling: touch;

  scrollbar-width: thin;
}

.hourly-list::-webkit-scrollbar {
  height: 5px;
}

.hourly-list::-webkit-scrollbar-track {
  background: transparent;
}

.hourly-list::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 999px;
}

.hourly-card {
  min-width: 92px;

  padding: 13px 10px;

  background: var(--surface);

  text-align: center;

  flex-shrink: 0;
}

.hourly-card:first-child {
  border-radius: 8px 0 0 8px;
}

.hourly-card:last-child {
  border-radius: 0 8px 8px 0;
}

.hourly-time {
  color: var(--muted);

  font-size: 0.7rem;

  margin-bottom: 9px;
}

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

  margin-bottom: 8px;
}

.hourly-temp {
  font-size: 0.98rem;

  font-weight: 750;
}

/* =========================
   7-DAY FORECAST
========================= */

.forecast-list {
  display: grid;

  gap: 1px;

  background: var(--border);

  border: 1px solid var(--border);

  border-radius: 9px;

  overflow: hidden;
}

.forecast-day {
  display: grid;

  grid-template-columns: 1.1fr 0.9fr 0.8fr;

  align-items: center;

  gap: 10px;

  padding: 14px;

  background: var(--surface);
}

.forecast-date {
  font-weight: 700;
}

.forecast-condition {
  display: flex;

  align-items: center;

  gap: 7px;

  min-width: 0;

  color: var(--muted);

  font-size: 0.8rem;
}

.forecast-condition span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.forecast-temps {
  text-align: right;

  font-weight: 750;

  white-space: nowrap;
}

.forecast-low {
  color: var(--muted);

  font-weight: 500;
}

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

footer {
  text-align: center;

  color: var(--subtle);

  font-size: 0.73rem;

  padding:
    28px 0
    calc(8px + env(safe-area-inset-bottom));
}

footer p {
  line-height: 1.5;
}

footer a {
  color: var(--accent);

  text-decoration: none;
}

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

.footer-brand {
  margin-top: 6px;

  font-weight: 700;

  color: var(--muted);
}

/* =========================
   WEATHER BACKGROUNDS
========================= */

body.weather-clear {
  background:
    linear-gradient(
      180deg,
      #4fa3e3 0%,
      #b9e4f7 100%
    );

  background-attachment: fixed;
}

body.weather-partly-cloudy {
  background:
    linear-gradient(
      180deg,
      #6fa9d3 0%,
      #d5e5ee 100%
    );

  background-attachment: fixed;
}

body.weather-cloudy {
  background:
    linear-gradient(
      180deg,
      #657786 0%,
      #b6c3cc 100%
    );

  background-attachment: fixed;
}

body.weather-fog {
  background:
    linear-gradient(
      180deg,
      #aeb9bf 0%,
      #dce3e6 100%
    );

  background-attachment: fixed;
}

body.weather-rain {
  background:
    linear-gradient(
      180deg,
      #243b55 0%,
      #506a80 100%
    );

  background-attachment: fixed;
}

body.weather-snow {
  background:
    linear-gradient(
      180deg,
      #8fa9bd 0%,
      #e3edf2 100%
    );

  background-attachment: fixed;
}

body.weather-storm {
  background:
    linear-gradient(
      180deg,
      #17202a 0%,
      #34495e 100%
    );

  background-attachment: fixed;
}

/* =========================
   WEATHER EFFECT LAYER
========================= */

.weather-effects {
  position: fixed;

  inset: 0;

  pointer-events: none;

  overflow: hidden;

  z-index: 0;
}

/* =========================
   DARK MODE
========================= */

body.dark {
  --bg: #101820;
  --surface: #17222c;
  --surface-soft: #1d2a35;
  --border: #2a3945;

  --text: #f1f5f8;
  --muted: #9eacb8;
  --subtle: #748390;

  --accent: #55a6e8;
  --accent-dark: #418fcf;
}

body.dark .current-card {
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.25);
}

body.dark .alert-box {
  background: #2a2518;
  border-color: #705d2e;
}

body.dark .alert-icon {
  background: #3b321c;
}

body.dark #alertDescription {
  color: #ddd5c0;
}

body.dark .alert-details {
  color: #aaa184;
}

body.dark .alert-details strong {
  color: #d2c8aa;
}

body.dark .dismiss-alert {
  background: #302b1d;

  border-color: #554b32;

  color: #ddd5c0;
}

body.dark .dismiss-alert:hover {
  background: #3a3322;
}

/* Dark weather backgrounds */

body.dark.weather-clear {
  background:
    linear-gradient(
      180deg,
      #183b58 0%,
      #102534 100%
    );
}

body.dark.weather-partly-cloudy {
  background:
    linear-gradient(
      180deg,
      #29485d 0%,
      #182d3b 100%
    );
}

body.dark.weather-cloudy {
  background:
    linear-gradient(
      180deg,
      #273640 0%,
      #111c24 100%
    );
}

body.dark.weather-fog {
  background:
    linear-gradient(
      180deg,
      #39454b 0%,
      #1b252a 100%
    );
}

body.dark.weather-rain {
  background:
    linear-gradient(
      180deg,
      #101c2b 0%,
      #172d3d 100%
    );
}

body.dark.weather-snow {
  background:
    linear-gradient(
      180deg,
      #344957 0%,
      #17242c 100%
    );
}

body.dark.weather-storm {
  background:
    linear-gradient(
      180deg,
      #090d12 0%,
      #18242e 100%
    );
}

/* =========================
   THEME TRANSITION
========================= */

body,
.current-card,
.hourly-card,
.forecast-day,
.detail,
.unit-button,
#cityInput,
.hourly-list,
.forecast-list,
.weather-details,
.theme-toggle {
  transition:
    background-color 0.45s ease,
    background 1.2s ease,
    color 0.45s ease,
    border-color 0.45s ease,
    box-shadow 0.45s ease;
}

/* Page fade */

body.theme-changing::after {
  content: "";

  position: fixed;

  inset: 0;

  background: rgba(255, 255, 255, 0.35);

  pointer-events: none;

  z-index: 9999;

  animation: themeFade 0.5s ease;
}

body.dark.theme-changing::after {
  background: rgba(0, 0, 0, 0.35);
}

@keyframes themeFade {
  0% {
    opacity: 0;
  }

  45% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

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

@media (min-width: 600px) {
  body {
    padding:
      max(30px, env(safe-area-inset-top))
      max(20px, env(safe-area-inset-right))
      max(30px, env(safe-area-inset-bottom))
      max(20px, env(safe-area-inset-left));
  }

  .weather-details {
    grid-template-columns: repeat(4, 1fr);
  }

  .alert-details {
    grid-template-columns: 1fr 1fr;
  }

  .current-card {
    padding: 26px;
  }
}

@media (max-width: 430px) {
  .header {
    align-items: flex-start;
  }

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

  .header-actions {
    gap: 6px;
  }

  .unit-button {
    padding-left: 11px;
    padding-right: 11px;
  }

  .theme-toggle {
    width: 54px;
  }

  body.dark .theme-toggle::before {
    transform: translateX(22px);
  }

  body.dark .theme-toggle:active::before {
    transform: translateX(22px) scale(0.85);
  }

  #searchForm {
    flex-direction: column;
  }

  #searchForm button {
    padding: 12px;
  }

  .current-card {
    padding: 17px;
  }

  .temperature {
    font-size: 4rem;
  }

  .forecast-day {
    grid-template-columns: 1fr auto;
  }

  .forecast-condition {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .forecast-temps {
    grid-column: 2;
    grid-row: 1;
  }

  .alert-box {
    padding: 14px;
  }
}

@media (max-width: 350px) {
  body {
    padding-left: 12px;
    padding-right: 12px;
  }

  .header h1 {
    font-size: 1.55rem;
  }

  .eyebrow {
    font-size: 0.62rem;
  }

  .header-actions {
    gap: 4px;
  }

  .unit-button {
    padding-left: 9px;
    padding-right: 9px;
  }

  .theme-toggle {
    width: 50px;
  }

  body.dark .theme-toggle::before {
    transform: translateX(18px);
  }

  body.dark .theme-toggle:active::before {
    transform: translateX(18px) scale(0.85);
  }

  .temperature {
    font-size: 3.5rem;
  }

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

/* =========================
   REDUCED MOTION
========================= */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =========================
   PWA / MOBILE SAFETY
========================= */

@supports (-webkit-touch-callout: none) {
  body {
    min-height: -webkit-fill-available;
  }
}

input,
button {
  touch-action: manipulation;
}

img,
svg {
  max-width: 100%;
  height: auto;
}
