/* theme.js applies the chosen palette before the page paints. */
.sr-only {
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip-path:inset(50%);
  white-space:nowrap;
  border:0;
}

#theme-icon {display:flex; align-items:center; pointer-events:none}
#theme-icon svg {width:16px; height:16px}
#theme-select option {color:var(--ink); background:var(--surface)}
.skip-link {background:var(--surface)}

:root:not([data-theme]),
:root[data-theme="green"] {
  --ink:#f3f1df;
  --muted:#b9c5b7;
  --green:#b7d7b8;
  --green-2:#cbe4c7;
  --paper:#172520;
  --surface:#1e3028;
  --pale:#23372e;
  --soft:#2d453a;
  --line:#435b4f;
  --rule:#789285;
  --signal:#f3a975;
  --signal-pale:#443025;
  --on-green:#17291e;
  --weather:#244638;
  --weather-ink:#fff7e6;
  --weather-muted:#dde7da;
  --weather-symbol:#f8c88b;
  --shadow:0 3px 14px #0006;
}

:root[data-theme="dark"] {
  --ink:#f1f3f6;
  --muted:#bcc4d0;
  --green:#c3d5e9;
  --green-2:#e0eaf5;
  --paper:#16181d;
  --surface:#20232a;
  --pale:#252933;
  --soft:#333a46;
  --line:#414957;
  --rule:#788497;
  --signal:#f3b58a;
  --signal-pale:#483226;
  --on-green:#17202b;
  --weather:#2b3545;
  --weather-ink:#f3f6fa;
  --weather-muted:#d6dfea;
  --weather-symbol:#f8c994;
  --shadow:0 3px 14px #0006;
  --map-terrain-filter:invert(.9) saturate(.15) contrast(1.05) brightness(.88);
}

:root[data-theme="light"] {
  --ink:#17212e;
  --muted:#505d6d;
  --green:#294d70;
  --green-2:#365e83;
  --paper:#f6f8fa;
  --surface:#ffffff;
  --pale:#edf0f4;
  --soft:#e0e6ed;
  --line:#cbd4de;
  --rule:#76818f;
  --signal:#925024;
  --signal-pale:#f4e6d6;
  --on-green:#ffffff;
  --weather:#203e5a;
  --weather-ink:#f2f7ff;
  --weather-muted:#dae6f5;
  --weather-symbol:#fbd59f;
  --shadow:0 3px 14px #17212e24;
  --map-terrain-filter:saturate(.25) contrast(1) brightness(1.07);
}

:root[data-theme="pink"] {
  --ink:#30272d;
  --muted:#675862;
  --green:#75445d;
  --green-2:#63374e;
  --paper:#faf7f7;
  --surface:#fffdfd;
  --pale:#f3ebee;
  --soft:#ece1e6;
  --line:#e2d5da;
  --rule:#927783;
  --signal:#9b4e69;
  --signal-pale:#f4e7ec;
  --on-green:#fffafd;
  --weather:#473640;
  --weather-ink:#fffafc;
  --weather-muted:#eee3e9;
  --weather-symbol:#f2cebf;
  --shadow:0 3px 14px #30272d18;
  --map-terrain-filter:saturate(.38) contrast(1) brightness(1.05);
}

html[data-theme="pink"] .topbar,
html[data-theme="pink"] .mobile-nav {border-color:var(--line)}
html[data-theme="pink"] dialog::backdrop {background:#32272d66}

html[data-theme-scheme="dark"] .detail-top:before {filter:brightness(2)}
html[data-theme-scheme="dark"] dialog::backdrop {background:#050b09a8}
html[data-theme="green"] .diff-dot.advanced {box-shadow:0 0 0 1px #b1c1ab}
html[data-theme="dark"] .diff-dot.advanced {box-shadow:0 0 0 1px var(--muted)}

/* Retain satellite and camera colors. The terrain raster alone is recolored. */
html[data-theme="green"] .map-section,
html[data-theme="green"] .leaflet-container {background:#15221c}
html[data-theme="green"] .alpine-topo-tiles {filter:invert(.92) hue-rotate(165deg) saturate(.3) brightness(.88) contrast(1.05)}
html[data-theme="green"] .leaflet-control-attribution {background:#14221dec!important; color:#a8baa1!important}
html[data-theme="green"] .leaflet-control-attribution a {color:#c4d7b8!important}
html[data-theme="green"] .alpine-cluster {background:#92b892; border-color:#243b2c; color:#13291b}
html[data-theme="green"] .marker-dot {background:#a2cba5; border-color:#24392d; box-shadow:0 2px 7px #00000070}
html[data-theme="green"] .selected .marker-dot {background:#e5a56d; box-shadow:0 0 0 5px #e9b98b22,0 2px 8px #00000070}
html[data-theme="green"] .marker-label {
  color:#e7efdf;
  text-shadow:0 1px 0 #12231a,0 -1px 0 #12231a,1px 0 #12231a,-1px 0 #12231a,0 0 5px #12231a,0 0 8px #12231a;
}
html[data-theme="green"] .alpine-trail-label {background:#192c22f0; color:#e0ead4}
html[data-theme="green"] .leaflet-container a.leaflet-popup-close-button {color:#b6c5ae}

html[data-theme]:not([data-theme="green"]) :is(.map-section,.leaflet-container) {background:var(--pale)}
html[data-theme]:not([data-theme="green"]) .alpine-topo-tiles {filter:var(--map-terrain-filter)}
html[data-theme]:not([data-theme="green"]) .leaflet-control-attribution {background:var(--surface)!important; color:var(--muted)!important}
html[data-theme]:not([data-theme="green"]) .leaflet-control-attribution a {color:var(--green)!important}
html[data-theme]:not([data-theme="green"]) .alpine-cluster {background:var(--green); border-color:var(--surface); color:var(--on-green)}
html[data-theme]:not([data-theme="green"]) .marker-dot {background:var(--green); border-color:var(--surface); box-shadow:var(--shadow)}
html[data-theme]:not([data-theme="green"]) .selected .marker-dot {background:var(--signal); box-shadow:0 0 0 5px var(--signal-pale),var(--shadow)}
html[data-theme]:not([data-theme="green"]) .marker-label {
  color:var(--ink);
  text-shadow:0 1px 0 var(--surface),0 -1px 0 var(--surface),1px 0 0 var(--surface),-1px 0 0 var(--surface),0 0 5px var(--surface),0 0 8px var(--surface);
}
html[data-theme]:not([data-theme="green"]) .alpine-trail-label {background:var(--surface); color:var(--ink)}
html[data-theme]:not([data-theme="green"]) .leaflet-container a.leaflet-popup-close-button {color:var(--muted)}

@media(max-width:370px) {
  .topbar {padding-left:12px; padding-right:12px; gap:8px}
  .brand {font-size:26px}
}
