
/*
  Theme safety layer:
  - Makes the selected theme control the page, cards, header and navigation.
  - Keeps the weather hero readable over every daytime/nighttime condition sky.
  - Keeps dark modal surfaces readable even while Glass White is active.
*/

html[data-theme]:not([data-theme="midnight"]){
  color-scheme:dark;
  --wp-theme-surface:var(--glass-bg);
  --wp-theme-border:var(--glass-stroke);
  --wp-theme-text:var(--ink);
  --wp-theme-muted:var(--muted);
  --wp-theme-soft-dark:rgba(255,255,255,.055);
  --wp-theme-soft-light:rgba(255,255,255,.095);
  --wp-theme-shadow:0 18px 42px rgba(0,0,0,.28);
}
html[data-theme="glasswhite"]{
  color-scheme:light;
  --wp-theme-soft-dark:rgba(15,23,42,.045);
  --wp-theme-soft-light:rgba(255,255,255,.72);
  --wp-theme-shadow:0 16px 34px rgba(15,23,42,.13);
}

/* The old global body rule was covering --hp-bg, so themes only changed pieces. */
html[data-theme]:not([data-theme="midnight"]) body{
  color:var(--wp-theme-text)!important;
  background:var(--hp-bg)!important;
  background-attachment:fixed!important;
}

/* Main themed surfaces */
html[data-theme]:not([data-theme="midnight"]) .appbar,
html[data-theme]:not([data-theme="midnight"]) .card,
html[data-theme]:not([data-theme="midnight"]) .glass,
html[data-theme]:not([data-theme="midnight"]) .metric,
html[data-theme]:not([data-theme="midnight"]) .glance-card,
html[data-theme]:not([data-theme="midnight"]) .timeline-card,
html[data-theme]:not([data-theme="midnight"]) .spc-card,
html[data-theme]:not([data-theme="midnight"]) .season-card,
html[data-theme]:not([data-theme="midnight"]) #stormEtaCard,
html[data-theme]:not([data-theme="midnight"]) #aiCard,
html[data-theme]:not([data-theme="midnight"]) .wp-loader-card{
  color:var(--wp-theme-text)!important;
  border-color:var(--wp-theme-border)!important;
  background:
    linear-gradient(160deg,var(--wp-theme-soft-light),var(--wp-theme-soft-dark)),
    var(--wp-theme-surface)!important;
  box-shadow:0 1px 0 rgba(255,255,255,.08) inset,var(--wp-theme-shadow)!important;
}

html[data-theme]:not([data-theme="midnight"]) .appbar{
  backdrop-filter:blur(16px) saturate(165%);
  -webkit-backdrop-filter:blur(16px) saturate(165%);
}
html[data-theme]:not([data-theme="midnight"]) .appbar .brand,
html[data-theme]:not([data-theme="midnight"]) .appbar .row,
html[data-theme]:not([data-theme="midnight"]) .appbar button,
html[data-theme]:not([data-theme="midnight"]) .appbar .pill{
  color:var(--wp-theme-text)!important;
}
html[data-theme]:not([data-theme="midnight"]) .appbar .loc{color:var(--wp-theme-muted)!important;}
html[data-theme]:not([data-theme="midnight"]) .appbar .icon{color:currentColor!important;}
html[data-theme]:not([data-theme="midnight"]) .appbar .icon path,
html[data-theme]:not([data-theme="midnight"]) .appbar .icon circle,
html[data-theme]:not([data-theme="midnight"]) .appbar .icon line,
html[data-theme]:not([data-theme="midnight"]) .appbar .icon rect,
html[data-theme]:not([data-theme="midnight"]) .appbar .icon polygon{
  stroke:currentColor!important;
}

/* Header controls remain visible instead of using a fixed dark-only palette. */
html[data-theme]:not([data-theme="midnight"]) .pill,
html[data-theme]:not([data-theme="midnight"]) button.pill,
html[data-theme]:not([data-theme="midnight"]) a.pill{
  color:var(--wp-theme-text)!important;
  border-color:var(--wp-theme-border)!important;
  background:
    linear-gradient(160deg,var(--wp-theme-soft-light),var(--wp-theme-soft-dark)),
    var(--wp-theme-surface)!important;
  text-shadow:none!important;
}
html[data-theme]:not([data-theme="midnight"]) .pill:hover,
html[data-theme]:not([data-theme="midnight"]) button.pill:hover,
html[data-theme]:not([data-theme="midnight"]) a.pill:hover{
  border-color:var(--wp-theme-text)!important;
}

/* Core card typography */
html[data-theme]:not([data-theme="midnight"]) .sectionTitle,
html[data-theme]:not([data-theme="midnight"]) .metric .v,
html[data-theme]:not([data-theme="midnight"]) .glance-summary,
html[data-theme]:not([data-theme="midnight"]) .spc-title,
html[data-theme]:not([data-theme="midnight"]) .timechip .temp,
html[data-theme]:not([data-theme="midnight"]) .storm-meter-headline,
html[data-theme]:not([data-theme="midnight"]) .uv-value,
html[data-theme]:not([data-theme="midnight"]) .uv-risk,
html[data-theme]:not([data-theme="midnight"]) .fire-value,
html[data-theme]:not([data-theme="midnight"]) .fire-risk,
html[data-theme]:not([data-theme="midnight"]) .eta-header-title,
html[data-theme]:not([data-theme="midnight"]) .eta-row-kind,
html[data-theme]:not([data-theme="midnight"]) #aiText{
  color:var(--wp-theme-text)!important;
}
html[data-theme]:not([data-theme="midnight"]) .metric .k,
html[data-theme]:not([data-theme="midnight"]) .updated,
html[data-theme]:not([data-theme="midnight"]) .glance-meta,
html[data-theme]:not([data-theme="midnight"]) .timeline-meta,
html[data-theme]:not([data-theme="midnight"]) .spc-desc,
html[data-theme]:not([data-theme="midnight"]) .timechip .hour,
html[data-theme]:not([data-theme="midnight"]) .timechip .sub,
html[data-theme]:not([data-theme="midnight"]) .timechip .wxlabel,
html[data-theme]:not([data-theme="midnight"]) .storm-meter-scale-label,
html[data-theme]:not([data-theme="midnight"]) .storm-meter-scale,
html[data-theme]:not([data-theme="midnight"]) .uv-head .k,
html[data-theme]:not([data-theme="midnight"]) .uv-scale,
html[data-theme]:not([data-theme="midnight"]) .fire-head .k,
html[data-theme]:not([data-theme="midnight"]) .fire-scale,
html[data-theme]:not([data-theme="midnight"]) .confidence-label,
html[data-theme]:not([data-theme="midnight"]) .eta-header-sub,
html[data-theme]:not([data-theme="midnight"]) .eta-row-loc,
html[data-theme]:not([data-theme="midnight"]) .eta-row-motion,
html[data-theme]:not([data-theme="midnight"]) .eta-row-unit,
html[data-theme]:not([data-theme="midnight"]) .eta-clear,
html[data-theme]:not([data-theme="midnight"]) #nowcastCard .muted,
html[data-theme]:not([data-theme="midnight"]) #nowcastCard .legend{
  color:var(--wp-theme-muted)!important;
}

/* Card interiors and chips now follow each theme too. */
html[data-theme]:not([data-theme="midnight"]) .metric,
html[data-theme]:not([data-theme="midnight"]) .timechip,
html[data-theme]:not([data-theme="midnight"]) .timeline-frame,
html[data-theme]:not([data-theme="midnight"]) .glance-pills .pill,
html[data-theme]:not([data-theme="midnight"]) .fire-badges .pill{
  color:var(--wp-theme-text)!important;
  border-color:var(--wp-theme-border)!important;
  background:
    linear-gradient(160deg,var(--wp-theme-soft-light),var(--wp-theme-soft-dark)),
    var(--wp-theme-surface)!important;
}
html[data-theme]:not([data-theme="midnight"]) .timechip.now{
  border-color:#60a5fa!important;
  background:
    radial-gradient(170px 110px at 50% -10%,rgba(56,189,248,.24),transparent 60%),
    linear-gradient(160deg,var(--wp-theme-soft-light),var(--wp-theme-soft-dark)),
    var(--wp-theme-surface)!important;
}
html[data-theme]:not([data-theme="midnight"]) .timeline-frame::before{
  background:linear-gradient(90deg,var(--wp-theme-surface),transparent)!important;
}
html[data-theme]:not([data-theme="midnight"]) .timeline-frame::after{
  background:linear-gradient(270deg,var(--wp-theme-surface),transparent)!important;
}
html[data-theme]:not([data-theme="midnight"]) .confidence-bar,
html[data-theme]:not([data-theme="midnight"]) .timechip .rainbar,
html[data-theme]:not([data-theme="midnight"]) #aiCard .confidence-bar{
  background:rgba(127,127,127,.16)!important;
}

/* Links and neutral buttons */
html[data-theme]:not([data-theme="midnight"]) .linkbtn{
  color:var(--wp-theme-text)!important;
  border-color:var(--wp-theme-border)!important;
  background:var(--wp-theme-soft-dark)!important;
}
html[data-theme]:not([data-theme="midnight"]) .linkbtn:hover{
  background:var(--wp-theme-soft-light)!important;
  border-color:var(--wp-theme-text)!important;
}

/* The alert ticker follows the selected surface while alert badge colors stay intact. */
html[data-theme]:not([data-theme="midnight"]) #ticker{
  color:var(--wp-theme-text)!important;
  border-color:var(--wp-theme-border)!important;
}
html[data-theme]:not([data-theme="midnight"]) .tickerItem{border-right-color:var(--wp-theme-border)!important;}
html[data-theme]:not([data-theme="midnight"]) .tickerViewport::before{
  background:linear-gradient(90deg,var(--wp-theme-surface),transparent)!important;
}
html[data-theme]:not([data-theme="midnight"]) .tickerViewport::after{
  background:linear-gradient(270deg,var(--wp-theme-surface),transparent)!important;
}

/* Always-readable current conditions over all condition artwork and every theme. */
html[data-theme]:not([data-theme="midnight"]) .sky .tempRow{
  color:#f8fbff!important;
  padding:10px 16px 10px 8px;
  border-radius:18px;
  background:linear-gradient(90deg,rgba(2,6,23,.58),rgba(2,6,23,.20) 72%,transparent);
  box-shadow:inset 1px 0 0 rgba(255,255,255,.10);
  backdrop-filter:blur(2px);
  -webkit-backdrop-filter:blur(2px);
}
html[data-theme]:not([data-theme="midnight"]) .sky .temp,
html[data-theme]:not([data-theme="midnight"]) .sky .cond{
  color:#f8fbff!important;
  text-shadow:0 3px 4px rgba(0,0,0,.72),0 10px 34px rgba(0,0,0,.58)!important;
}
html[data-theme]:not([data-theme="midnight"]) .sky .feels,
html[data-theme]:not([data-theme="midnight"]) .sky .updated,
html[data-theme]:not([data-theme="midnight"]) .sky #sunArc{
  color:#dbeafe!important;
  text-shadow:0 2px 4px rgba(0,0,0,.90)!important;
}

/* Bottom navigation follows the active theme and fixes hardcoded white SVG strokes. */
html[data-theme]:not([data-theme="midnight"]) .wpnav{
  --wpnav-bg1:var(--wp-theme-surface);
  --wpnav-bg2:var(--wp-theme-surface);
  --wpnav-ink:var(--wp-theme-text);
  --wpnav-muted:var(--wp-theme-muted);
  color:var(--wp-theme-text)!important;
  border-color:var(--wp-theme-border)!important;
  background:
    linear-gradient(180deg,var(--wp-theme-soft-light),var(--wp-theme-soft-dark)),
    var(--wp-theme-surface)!important;
  box-shadow:0 -14px 38px rgba(0,0,0,.24),inset 0 1px 0 rgba(255,255,255,.08)!important;
}
html[data-theme]:not([data-theme="midnight"]) .wpnav a{color:var(--wp-theme-muted)!important;}
html[data-theme]:not([data-theme="midnight"]) .wpnav a.active{
  color:var(--wp-theme-text)!important;
  border:1px solid var(--wp-theme-border)!important;
  background:var(--wp-theme-soft-light)!important;
  text-shadow:none!important;
}
html[data-theme]:not([data-theme="midnight"]) .wpnav svg path,
html[data-theme]:not([data-theme="midnight"]) .wpnav svg circle,
html[data-theme]:not([data-theme="midnight"]) .wpnav svg line,
html[data-theme]:not([data-theme="midnight"]) .wpnav svg rect,
html[data-theme]:not([data-theme="midnight"]) .wpnav svg polygon{
  stroke:currentColor!important;
}
html[data-theme]:not([data-theme="midnight"]) .wpnav svg [fill="white"]{fill:currentColor!important;}

/* Glass White-specific tuning: strong dark text on light surfaces. */
html[data-theme="glasswhite"] .home-card-kicker{color:#1d4ed8!important;}
html[data-theme="glasswhite"] .glance-status{
  color:#1e40af!important;
  background:rgba(37,99,235,.10)!important;
  border-color:rgba(37,99,235,.25)!important;
}
html[data-theme="glasswhite"] .confidence-value{color:#15803d!important;}
html[data-theme="glasswhite"] .wpnav-day-icon{
  color:#0f172a!important;
  box-shadow:0 0 0 1px rgba(15,23,42,.12),0 6px 18px rgba(15,23,42,.14)!important;
}

/* These overlays intentionally stay dark. Give them their own text tokens so
   activating Glass White cannot turn their text dark-on-dark. */
.wp-theme-panel,
.wp-layout-panel,
.wp-search-panel,
.wp-tools-dropdown,
#nowcastCard .nowcast-probe{
  --ink:#eef6ff;
  --muted:#b9c6ea;
  color:#eef6ff!important;
}
.wp-theme-panel .wp-theme-sub,
.wp-theme-panel .wp-theme-card-tag,
.wp-layout-panel .wp-layout-sub,
.wp-layout-panel .wp-layout-tag,
.wp-layout-panel .wp-layout-toggle,
.wp-search-panel .wp-srch-sub,
.wp-search-panel .wp-srch-label,
.wp-search-panel .wp-srch-empty{
  color:#b9c6ea!important;
}
.wp-theme-panel .wp-theme-close,
.wp-layout-panel .wp-layout-close,
.wp-layout-panel .wp-layout-card,
.wp-search-panel .wp-search-input,
.wp-search-panel .wp-srch-result{
  color:#eef6ff!important;
}
.wp-search-panel .wp-search-input::placeholder{color:#8392bd!important;}

/* Form controls should not vanish on light mode. */
html[data-theme="glasswhite"] input,
html[data-theme="glasswhite"] select,
html[data-theme="glasswhite"] textarea{
  color:#0f172a;
}

@media (max-width:640px){
  html[data-theme]:not([data-theme="midnight"]) .sky .tempRow{
    padding:9px 12px 9px 6px;
    background:linear-gradient(90deg,rgba(2,6,23,.62),rgba(2,6,23,.24) 80%,transparent);
  }
}
