/* Weather Forecast · Professional UI layer
 * Loaded after the legacy inline stylesheet so the forecast/data logic stays
 * untouched while presentation follows the shared public design system.
 */

body.weather-page {
  --weather-edge: 20px;
  --weather-gutter: clamp(14px, 2.2vw, 28px);
  /* Matches the visible .nv3-desk panel: 1440px wrapper minus 20px each side. */
  --weather-shell: min(calc(100vw - (var(--weather-edge) * 2)), 1400px);
  --weather-radius: 18px;
  --weather-radius-sm: 12px;
  --f-sans: var(--aqm-font, 'IBM Plex Sans Thai', system-ui, sans-serif);
  --f-mono: var(--f-sans);
  font-family: var(--f-sans);
  font-size: 14px;
  font-weight: 350;
  background:
    radial-gradient(circle at 8% 12%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 30rem),
    radial-gradient(circle at 94% 32%, color-mix(in srgb, var(--teal) 5%, transparent), transparent 28rem),
    var(--sand);
}

body.weather-page :is(button, input, select, textarea) {
  font-family: var(--f-sans);
}

body.weather-page :is(.wh-temp, .wd-val, .wl-val, .wb-value, .sc-val, .hc-time, .hc-temp, .dc-hi, .dc-lo, .dc-uv, .dc-conf, .ctrl-info, .src-chip, .sci-table) {
  font-variant-numeric: tabular-nums;
}

body.weather-page .topbar {
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  box-shadow: 0 10px 28px rgba(2, 8, 23, .16);
}

body.weather-page .ctrl-bar {
  padding: 13px 0 11px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--sand) 82%, transparent);
  backdrop-filter: blur(18px) saturate(130%);
}

body.weather-page .ctrl-inner {
  width: var(--weather-shell);
  max-width: none;
  min-height: 58px;
  padding: 10px 13px;
  gap: 9px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  box-shadow: var(--sh-sm);
}

body.weather-page .ctrl-label {
  letter-spacing: .04em;
}

body.weather-page .ctrl-sel,
body.weather-page .ctrl-btn {
  min-height: 38px;
  border-radius: 9px;
}

body.weather-page .ctrl-sel {
  min-width: 220px;
  padding: 7px 34px 7px 12px;
}

body.weather-page .ctrl-btn {
  padding-inline: 17px;
  font-weight: 500;
}

body.weather-page .theme-toggle {
  min-height: 38px;
  padding: 3px !important;
  gap: 2px;
  border-radius: 10px !important;
  overflow: visible;
}

body.weather-page .theme-toggle button {
  width: 32px;
  min-height: 30px;
  padding: 4px !important;
  border: 0 !important;
  border-radius: 7px;
}

body.weather-page .theme-toggle button.active {
  box-shadow: 0 5px 14px color-mix(in srgb, var(--accent) 28%, transparent);
}

.weather-module-nav {
  position: relative;
  z-index: 25;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 5%, transparent);
  backdrop-filter: blur(16px) saturate(130%);
}

.weather-module-nav-inner {
  width: var(--weather-shell);
  min-height: 62px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  align-items: stretch;
  gap: 5px;
  padding: 8px 0;
}

.weather-module-nav a {
  min-width: 0;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  transition: color .18s ease, border-color .18s ease, background .18s ease, transform .18s ease;
}

.weather-module-nav a > span {
  color: color-mix(in srgb, var(--accent) 72%, var(--muted));
  font-size: 8px;
  font-weight: 600;
  letter-spacing: .08em;
}

.weather-module-nav a:hover,
.weather-module-nav a:focus-visible,
.weather-module-nav a.is-active {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
  background: color-mix(in srgb, var(--accent-bg) 58%, var(--panel));
  color: var(--ink);
  transform: translateY(-1px);
  outline: none;
}

.weather-module-nav a.is-active {
  box-shadow: inset 0 -2px 0 var(--accent);
}

body.weather-page .wrap {
  width: var(--weather-shell);
  max-width: none;
  padding: 26px 0 0 !important;
}

body.weather-page :is(#weatherNow, #weatherBrief, .sect[id]) {
  scroll-margin-top: 160px;
}

body.weather-page .weather-hero {
  min-height: 330px;
  margin-bottom: 18px;
  padding: clamp(24px, 3vw, 38px);
  grid-template-columns: minmax(210px, .78fr) minmax(330px, 1.12fr) minmax(300px, 1fr);
  gap: clamp(20px, 3vw, 44px);
  border: 1px solid rgba(147, 197, 253, .16);
  border-radius: 26px;
  background:
    linear-gradient(115deg, rgba(59, 130, 246, .11), transparent 45%),
    radial-gradient(circle at 88% 14%, rgba(56, 189, 248, .16), transparent 28rem),
    linear-gradient(135deg, var(--hero-from) 0%, var(--hero-mid) 54%, var(--hero-to) 100%);
  box-shadow: 0 28px 64px rgba(2, 8, 23, .22), inset 0 1px 0 rgba(255, 255, 255, .04);
}

body.weather-page .weather-hero::before {
  width: 440px;
  height: 440px;
  top: -210px;
  right: -100px;
  border: 1px solid rgba(147, 197, 253, .1);
  border-radius: 50%;
  background:
    radial-gradient(circle, transparent 46%, rgba(147, 197, 253, .08) 47%, transparent 48%),
    radial-gradient(circle, color-mix(in srgb, var(--accent) 18%, transparent), transparent 66%);
}

body.weather-page .weather-hero::after {
  content: '';
  position: absolute;
  right: 18%;
  bottom: -80px;
  width: 250px;
  height: 120px;
  border-radius: 50%;
  background: rgba(96, 165, 250, .09);
  filter: blur(42px);
  pointer-events: none;
  animation: weatherDrift 8s ease-in-out infinite alternate;
}

body.weather-page .wh-main,
body.weather-page .wh-details,
body.weather-page .wh-local {
  position: relative;
  z-index: 1;
}

body.weather-page .wh-main {
  padding: 12px;
}

body.weather-page .wh-icon {
  font-size: clamp(64px, 6vw, 82px);
  animation: weatherFloat 4.8s ease-in-out infinite;
}

body.weather-page .wh-temp {
  font-size: clamp(50px, 5vw, 66px);
  font-weight: 500;
  letter-spacing: -.04em;
}

body.weather-page .wh-desc {
  margin-top: 9px;
  font-size: 15px;
  font-weight: 400;
}

body.weather-page .wh-feels {
  margin-top: 5px;
  font-size: 11px;
  opacity: .68;
}

body.weather-page .wh-details {
  gap: 9px;
}

body.weather-page .wd-item,
body.weather-page .wl-row {
  border-color: rgba(255, 255, 255, .1);
  background: rgba(255, 255, 255, .055);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025);
  backdrop-filter: blur(8px);
}

body.weather-page .wd-item {
  min-height: 80px;
  padding: 13px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-radius: 11px;
}

body.weather-page .wd-label {
  letter-spacing: .04em;
  opacity: .62;
}

body.weather-page .wd-val {
  font-size: 18px;
  font-weight: 500;
}

body.weather-page .wh-local {
  padding: 16px;
  border: 1px solid rgba(147, 197, 253, .12);
  border-radius: 15px;
  background: rgba(4, 13, 28, .2);
}

body.weather-page .wl-title {
  color: #a9d0ff;
  letter-spacing: .04em;
}

body.weather-page .wl-title::before {
  background: #7ab7ff;
}

body.weather-page .wl-row {
  min-height: 38px;
  padding: 7px 10px;
  border-radius: 8px;
}

body.weather-page .wl-val {
  color: #a9d0ff;
}

body.weather-page .weather-brief {
  margin-bottom: 42px;
  padding: clamp(20px, 2.5vw, 30px);
  gap: 24px;
  border-radius: var(--weather-radius);
  background:
    linear-gradient(115deg, color-mix(in srgb, var(--accent-bg) 66%, var(--panel)), transparent 55%),
    var(--panel);
  box-shadow: 0 14px 34px color-mix(in srgb, var(--ink) 6%, transparent);
}

body.weather-page .weather-brief-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

body.weather-page .wb-eyebrow {
  letter-spacing: .1em !important;
  font-size: 9px;
}

body.weather-page .weather-brief h1 {
  max-width: 540px;
  font-size: clamp(27px, 3vw, 38px);
  font-weight: 500;
  letter-spacing: -.025em;
}

body.weather-page .weather-brief p {
  font-size: 13px;
  line-height: 1.85;
}

body.weather-page .wb-card {
  min-height: 142px;
  padding: 16px;
  border-radius: 13px;
  background: color-mix(in srgb, var(--panel) 94%, var(--accent-bg));
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 8%, transparent);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

body.weather-page .wb-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 26%, var(--border));
  box-shadow: var(--sh-md);
}

body.weather-page .wb-value {
  font-size: 21px;
  font-weight: 500;
}

body.weather-page .sect {
  margin-bottom: 46px;
}

body.weather-page .sect:last-child {
  margin-bottom: 0;
}

body.weather-page .sect-hd {
  min-height: 74px;
  margin-bottom: 15px;
  padding: 13px 15px;
  gap: 11px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: 14px;
  background:
    linear-gradient(110deg, color-mix(in srgb, var(--accent-bg) 40%, transparent), transparent 46%),
    var(--panel);
  box-shadow: var(--sh-sm);
}

body.weather-page .sect-hd::before {
  content: attr(data-weather-no);
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent-bg) 62%, var(--panel));
  color: var(--accent);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .05em;
}

body.weather-page .sect-hd h2 {
  font-size: clamp(17px, 1.8vw, 22px);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -.01em;
}

body.weather-page .sect-hd .badge {
  min-height: 25px;
  padding: 4px 9px;
  display: inline-flex;
  align-items: center;
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  border-radius: 999px;
  letter-spacing: .04em;
}

body.weather-page .sect-hd .meta {
  max-width: 440px;
  line-height: 1.45;
  text-align: right;
}

body.weather-page .panel,
body.weather-page .stat-card,
body.weather-page .hc,
body.weather-page .dc {
  border-color: color-mix(in srgb, var(--border) 90%, var(--accent) 10%);
  box-shadow: 0 10px 28px color-mix(in srgb, var(--ink) 4.5%, transparent);
}

body.weather-page .panel {
  padding: 20px;
  border-radius: 16px;
}

body.weather-page :is(.panel-2, .panel-3) {
  align-items: stretch;
}

body.weather-page :is(.panel-2, .panel-3) > .panel {
  height: 100%;
}

/* Pressure comparison: both columns inherit the tallest content automatically. */
body.weather-page .pressure-compare-grid {
  align-items: stretch;
}

body.weather-page .pressure-compare-column {
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

body.weather-page .pressure-chart-column .chart-wrap {
  height: auto;
  min-height: 310px;
  flex: 1 1 auto;
}

body.weather-page .pressure-insight-body {
  min-height: 0;
  padding: 0;
  display: flex;
  flex: 1 1 auto;
}

body.weather-page .pressure-insight-body > div {
  width: 100%;
  min-height: 100%;
}

body.weather-page .stat-card {
  min-height: 108px;
  padding: 16px;
  border-radius: 13px;
}

body.weather-page .stat-card::before {
  height: 2px;
}

body.weather-page .chart-wrap {
  border-radius: 13px;
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 4%, transparent);
}

body.weather-page .hourly-scroll {
  gap: 8px;
  padding: 2px 2px 13px;
}

body.weather-page .hc {
  min-width: 76px;
  padding: 12px 8px;
}

body.weather-page .dc {
  min-height: 216px;
  padding: 17px 12px;
}

body.weather-page .aqm-public-footer {
  margin-top: 24px;
}

body.weather-page .aqm-footer-inner {
  width: var(--weather-shell);
  max-width: none !important;
  padding-right: 0;
  padding-left: 0;
}

/* Safe fallback for a temporarily cached legacy footer template. */
body.weather-page .aqm-footer-inner > .aqm-footer-links {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: stretch;
  gap: 8px;
  margin-top: 28px;
  padding: 20px 0;
  border-top: 1px solid var(--aqm-footer-line, rgba(140, 180, 230, .14));
  border-bottom: 1px solid var(--aqm-footer-line, rgba(140, 180, 230, .14));
}

body.weather-page .aqm-footer-inner > .aqm-footer-links > a {
  min-height: 42px;
  padding: 9px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(140, 180, 230, .12);
  border-radius: 9px;
  background: rgba(10, 24, 48, .46);
  color: var(--aqm-footer-muted, #8fa6c4);
  text-decoration: none;
}

body.weather-page .aqm-footer-inner > .aqm-footer-links > a::after {
  content: '\2197';
  color: rgba(143, 166, 196, .5);
}

body.weather-page .aqm-footer-inner > .aqm-footer-links > a[href$="weather_forecast.php"] {
  border-color: rgba(122, 183, 255, .24);
  background: rgba(122, 183, 255, .09);
  color: #dceeff;
}

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

@keyframes weatherDrift {
  from { transform: translateX(-18px) scale(.96); }
  to { transform: translateX(20px) scale(1.05); }
}

@media (max-width: 1100px) {
  .weather-module-nav-inner {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    min-height: 0;
    overflow: visible;
  }

  body.weather-page .weather-hero {
    grid-template-columns: minmax(200px, .7fr) minmax(300px, 1fr);
  }

  body.weather-page .wh-local {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  body.weather-page .wl-title {
    grid-column: 1 / -1;
  }

  body.weather-page .weather-brief-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  body.weather-page .ctrl-inner {
    align-items: stretch;
  }

  body.weather-page .ctrl-info {
    width: 100%;
  }

  body.weather-page .ctrl-inner > div[style*="margin-left:auto"] {
    width: 100%;
    margin-left: 0 !important;
  }

  body.weather-page .weather-hero {
    grid-template-columns: 1fr;
  }

  body.weather-page .wh-local {
    grid-column: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.weather-page .weather-brief-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.weather-page .pressure-compare-column {
    height: auto;
  }

  body.weather-page .pressure-chart-column .chart-wrap {
    min-height: 270px;
  }

  body.weather-page .sect-hd .meta {
    width: 100%;
    max-width: none;
    margin-left: 49px;
    text-align: left;
  }

  body.weather-page .aqm-footer-inner > .aqm-footer-links {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  body.weather-page {
    --weather-edge: 14px;
    --weather-gutter: 14px;
  }

  body.weather-page .ctrl-bar {
    padding-block: 10px;
  }

  body.weather-page .ctrl-inner {
    padding: 11px;
  }

  body.weather-page .ctrl-label,
  body.weather-page .ctrl-divider {
    display: none;
  }

  body.weather-page .ctrl-sel,
  body.weather-page .ctrl-btn.pri {
    width: 100%;
    min-width: 0;
  }

  body.weather-page .theme-toggle {
    margin-right: auto;
  }

  .weather-module-nav-inner {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 0;
    padding-block: 7px;
  }

  .weather-module-nav a {
    min-height: 36px;
    padding: 6px 7px;
  }

  body.weather-page .wrap {
    padding-top: 18px;
  }

  body.weather-page .weather-hero {
    min-height: 0;
    padding: 20px 16px;
    border-radius: 19px;
  }

  body.weather-page .wh-details,
  body.weather-page .wh-local {
    grid-template-columns: 1fr 1fr;
  }

  body.weather-page .wl-title {
    grid-column: 1 / -1;
  }

  body.weather-page .weather-brief {
    margin-bottom: 34px;
    padding: 18px;
  }

  body.weather-page .weather-brief-grid {
    grid-template-columns: 1fr;
  }

  body.weather-page .wb-card {
    min-height: 112px;
  }

  body.weather-page .sect {
    margin-bottom: 36px;
  }

  body.weather-page .sect:last-child {
    margin-bottom: 0;
  }

  body.weather-page .sect-hd {
    align-items: flex-start;
    min-height: 0;
    padding: 13px;
  }

  body.weather-page .sect-hd h2 {
    width: calc(100% - 50px);
  }

  body.weather-page .sect-hd .badge {
    margin-left: 49px;
  }

  body.weather-page .sect-hd .meta {
    margin-left: 49px;
  }

  body.weather-page .panel {
    padding: 15px;
  }

  body.weather-page .aqm-public-footer {
    margin-top: 18px;
  }

  body.weather-page .aqm-footer-inner > .aqm-footer-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 20px;
    padding: 16px 0;
  }
}

@media print {
  .weather-module-nav,
  body.weather-page .ctrl-bar {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.weather-page .wh-icon,
  body.weather-page .weather-hero::after {
    animation: none !important;
  }
}
