/* Shared foundations for both forecast surfaces. Page files own only their layout. */

:root {
  color-scheme: light;
  --ink-950: #172b3a;
  --ink-900: #203747;
  --ink-800: #344b5b;
  --ink-700: #506574;
  --ink-500: #657785;
  --snow-50: #fafbfd;
  --snow-100: #f6f8fa;
  --snow-200: #e8edf2;
  --glacier-300: #b8dcf6;
  --glacier-500: #1675c5;
  --glacier-600: #1064ab;
  --surface: #fff;
  --surface-soft: #f6f8fa;
  --border: #dfe6ec;
  --border-subtle: #eef2f5;
  --border-hover: #abbfce;
  --focus-ring: #86bdec;
  --on-accent: #fff;
  --accent-soft: #edf6fe;
  --accent-border: #bfdcf4;
  --forecast-heading: #f0f6fc;
  --today-heading: #e8f2ff;
  --today-border: #c4daf3;
  --placeholder: #84939e;
  --favorite: #d75270;
  --favorite-muted: #8ea1af;
  --favorite-surface: #fff0f3;
  --rain-icon: #548576;
  --scrollbar: #b4c6d3;
  --row-hover: #b6d5ed;
  --error-text: #943d31;
  --error-surface: #fff6f4;
  --error-border: #efc9c4;
  --warning-text: #9f4b28;
  --warning-surface: #fff8f3;
  --warning-border: #f0d5c7;
  --modal-overlay: rgb(23 43 58 / 35%);
  --heat-surface: var(--surface);
  --heat-ink-muted: #435c6c;
  --heat-snow: #cfe8ff;
  --heat-snow-heavy: #b8daf6;
  --heat-rain: #cfefd8;
  --heat-cold: #dceff8;
  --heat-freezing: #f8fbfc;
  --heat-warm: #fff8f0;
  --heat-hot: #fff2e8;
  --chart-snow: #2563eb;
  --chart-rain: #298453;
  --chart-probability: #7c3aed;
  --chart-depth: #0f766e;
  --chart-wind: #b45309;
  --chart-direction: #be185d;
  --chart-visibility: #334155;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-soft: 0 2px 8px rgb(23 43 58 / 4%);
  --shadow-card: 0 1px 3px rgb(23 43 58 / 3%);
  --shadow-modal: 0 16px 60px rgb(23 43 58 / 18%);
  --shadow-control: 0 1px 4px rgb(23 43 58 / 10%);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink-950: #e6edf3;
  --ink-900: #dbe6ef;
  --ink-800: #c9d8e5;
  --ink-700: #b5c6d4;
  --ink-500: #98afc0;
  --snow-50: #1d3040;
  --snow-100: #0d1721;
  --snow-200: #2b3e4d;
  --glacier-300: #365d7b;
  --glacier-500: #82c6ff;
  --glacier-600: #a4d7ff;
  --surface: #142331;
  --surface-soft: #192b3a;
  --border: #2d4354;
  --border-subtle: #223746;
  --border-hover: #5c7e98;
  --focus-ring: #82c6ff;
  --on-accent: #102b40;
  --accent-soft: #1b3549;
  --accent-border: #365e7f;
  --forecast-heading: #182e42;
  --today-heading: #203f5c;
  --today-border: #426b8b;
  --placeholder: #91a7b8;
  --favorite: #ff9cb4;
  --favorite-muted: #92a9bb;
  --favorite-surface: #3b2b3b;
  --rain-icon: #94ccb5;
  --scrollbar: #4b677d;
  --row-hover: #547fa0;
  --error-text: #ffc1b2;
  --error-surface: #3b292b;
  --error-border: #79504a;
  --warning-text: #f2c6a4;
  --warning-surface: #352e28;
  --warning-border: #74604b;
  --modal-overlay: rgb(3 10 17 / 70%);
  --heat-snow: #23425b;
  --heat-ink-muted: var(--ink-500);
  --heat-snow-heavy: #0e4266;
  --heat-rain: #234333;
  --heat-cold: #254456;
  --heat-freezing: #182c39;
  --heat-warm: #302d2c;
  --heat-hot: #49362d;
  --chart-snow: #82b5ff;
  --chart-rain: #94ccb5;
  --chart-probability: #c1a0ff;
  --chart-depth: #6fd5bf;
  --chart-wind: #efb273;
  --chart-direction: #f696c1;
  --chart-visibility: #becddd;
  --shadow-soft: 0 2px 8px rgb(0 0 0 / 12%);
  --shadow-card: 0 1px 3px rgb(0 0 0 / 10%);
  --shadow-modal: 0 16px 60px rgb(0 0 0 / 35%);
  --shadow-control: 0 1px 4px rgb(0 0 0 / 22%);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--snow-100);
}

body {
  margin: 0;
  color: var(--ink-950);
  background: var(--snow-100);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select {
  font: inherit;
}

button, select {
  cursor: pointer;
}

button, a, input, select {
  -webkit-tap-highlight-color: transparent;
}

button, input, select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink-800);
  background: var(--surface);
}

button {
  padding: 9px 14px;
  font-weight: 600;
}

button:hover {
  border-color: var(--border-hover);
  background: var(--snow-50);
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

a {
  color: var(--glacier-600);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--glacier-500);
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

input[type="checkbox"] {
  accent-color: var(--glacier-500);
}

[hidden] {
  display: none !important;
}

h1, h2, h3, p {
  margin-top: 0;
}

h1, h2, h3 {
  line-height: 1.25;
}

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

.skip-link {
  position: absolute;
  left: 20px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: 10px;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  max-width: 1440px;
  min-height: 64px;
  padding: 0 32px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-950);
  text-decoration: none;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--on-accent);
  background: var(--glacier-500);
}

.brand-mark svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.brand-mark svg path + path {
  fill: none;
  stroke: var(--glacier-500);
  stroke-width: 2.5;
}

.brand-copy strong {
  font-size: 19px;
  letter-spacing: -0.6px;
}

.brand-copy span {
  display: none;
}

.site-header-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.theme-toggle {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  width: 64px;
  height: 36px;
  padding: 3px;
  border-radius: 18px;
  background: var(--surface-soft);
  font-size: 12px;
  line-height: 1;
}

.theme-toggle:hover {
  background: var(--surface-soft);
}

.theme-toggle-thumb {
  position: absolute;
  inset: 3px auto 3px 3px;
  width: calc((100% - 6px) / 2);
  border-radius: 50%;
  background: var(--glacier-500);
  box-shadow: var(--shadow-control);
  transition: transform 180ms ease-out;
}

.theme-toggle-options {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  pointer-events: none;
}

.theme-toggle-option {
  display: grid;
  place-items: center;
  color: var(--ink-700);
}

.theme-toggle-day {
  color: var(--on-accent);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:root[data-theme="dark"] .theme-toggle-thumb {
  transform: translateX(100%);
}

:root[data-theme="dark"] .theme-toggle-day {
  color: var(--ink-700);
}

:root[data-theme="dark"] .theme-toggle-night {
  color: var(--on-accent);
}

.unit-toggle {
  position: relative;
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  flex: 0 0 auto;
  min-height: 32px;
  padding: 3px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
}

.unit-toggle:hover {
  background: var(--surface-soft);
}

.unit-toggle::before {
  content: "";
  position: absolute;
  inset: 3px auto 3px 3px;
  width: calc((100% - 6px) / 2);
  border-radius: 4px;
  background: var(--glacier-500);
  box-shadow: var(--shadow-control);
  pointer-events: none;
  transition: transform 180ms ease-out;
}

.unit-toggle[data-mode="imperial"]::before {
  transform: translateX(100%);
}

.unit-toggle-option,
.unit-btn {
  position: relative;
  min-width: 42px;
  border: 0;
  border-radius: 4px;
  padding: 4px 8px;
  background: transparent;
  color: var(--ink-700);
  font-size: 11px;
  line-height: 16px;
}

.unit-toggle-option {
  pointer-events: none;
}

.unit-btn:hover {
  background: transparent;
}

.unit-toggle-option.is-active,
.unit-btn.is-active {
  color: var(--on-accent);
}

.unit-btn:focus-visible {
  outline-offset: 0;
}

main {
  width: 100%;
  max-width: 1440px;
  margin: auto;
  padding: 28px 32px;
  min-width: 0;
}

.page-footer {
  max-width: 1440px;
  margin: auto;
  padding: 20px 32px 28px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  color: var(--ink-500);
  font-size: 11px;
}

.page-footer strong {
  color: var(--ink-700);
}

.page-footer a {
  color: inherit;
}

@media (max-width: 700px) {
  main {
    padding: 20px 16px;
  }

  .site-header-inner {
    min-height: 58px;
    padding: 0 16px;
  }

  .page-footer {
    padding: 12px 16px 24px;
    flex-direction: column;
  }

}

/* Only the outgoing page is captured. The incoming page remains live, so
   controls keep their actual hit targets, hover cursor, and keyboard focus. */
:root {
  view-transition-name: none;
}

:root[data-theme-snapshot="old"] {
  view-transition-name: theme-page;
}

/* Extract the whole switch from the old page image, then omit that image.
   Its real DOM paints through this opening while the page fades around it. */
:root[data-theme-snapshot="old"] .theme-toggle {
  view-transition-name: theme-switch;
}

:root[data-theme-transitioning]::view-transition {
  pointer-events: none;
}

:root[data-theme-transitioning]::view-transition-group(theme-page) {
  animation: none;
}

:root[data-theme-transitioning]::view-transition-old(theme-page) {
  animation: theme-conceal 180ms ease-out both;
  mix-blend-mode: normal;
}

:root[data-theme-transitioning]::view-transition-group(theme-switch) {
  display: none;
}

@keyframes theme-conceal {
  from { opacity: 1; }
  to { opacity: 0; }
}

@media (max-width: 380px) {
  .site-header-inner {
    gap: 10px;
  }

  .brand {
    gap: 8px;
  }

  .brand-copy strong {
    font-size: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle-thumb,
  .unit-toggle::before {
    transition: none !important;
  }

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

}
