/* ============================================================
   WaterMaps — starter styles
   Palette: deep-water navy UI chrome over a light basemap,
   grade scale runs blue (clean) -> warm red (trouble).
   ============================================================ */

:root {
  --ink:        #0b2239;   /* deep water navy — chrome background */
  --ink-soft:   #16344f;
  --paper:      #f7fafc;
  --text:       #eaf2f8;
  --text-dim:   #9db4c6;
  --accent:     #38b6d8;   /* clean-water cyan */

  /* Grade scale */
  --grade-a: #2e86c1;
  --grade-b: #58b09c;
  --grade-c: #e3b23c;
  --grade-d: #e07b39;
  --grade-f: #c0392b;
  --grade-u: #aab4bd;

  --radius: 10px;
  --shadow: 0 4px 18px rgba(11, 34, 57, 0.25);
  --font-ui:   "Space Grotesk", system-ui, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font-ui);
  background: var(--paper);
}

/* ===== Top bar ===== */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--text);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.brand-mark {
  width: 18px;
  height: 18px;
  color: var(--accent);
  align-self: center;
}

.brand-name {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.02em;
}

.brand-tag {
  font-size: 12px;
  color: var(--text-dim);
}

.search {
  flex: 1;
  max-width: 520px;
  display: flex;
  background: var(--ink-soft);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  overflow: hidden;
}

.search input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 9px 12px;
  font: 14px var(--font-ui);
  outline: none;
}

.search input::placeholder { color: var(--text-dim); }

.search button,
.locate {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 0 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.search button:hover,
.locate:hover { color: var(--accent); }

.locate {
  background: var(--ink-soft);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  height: 38px;
  width: 42px;
  justify-content: center;
}

/* Visible keyboard focus */
.search input:focus-visible,
.search button:focus-visible,
.locate:focus-visible,
.disclaimer-accept:focus-visible,
.detail-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== Map ===== */
#map {
  position: fixed;
  inset: 58px 0 0 0;
}

/* ===== Legend ===== */
.legend {
  position: fixed;
  left: 16px;
  bottom: 24px;
  z-index: 15;
  background: rgba(11, 34, 57, 0.92);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  font-size: 12.5px;
  backdrop-filter: blur(4px);
}

.legend-title {
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}

.swatch {
  width: 16px;
  height: 12px;
  border-radius: 3px;
  flex: none;
}

.g-a { background: var(--grade-a); }
.g-b { background: var(--grade-b); }
.g-c { background: var(--grade-c); }
.g-d { background: var(--grade-d); }
.g-f { background: var(--grade-f); }
.g-u { background: var(--grade-u); }

.legend-note {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-dim);
  font-family: var(--font-data);
  font-size: 10.5px;
}

/* ===== Detail panel ===== */
.detail-panel {
  position: fixed;
  top: 74px;
  right: 16px;
  z-index: 15;
  width: 340px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  color: #16344f;
}

.detail-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: 0;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: #7d93a6;
  cursor: pointer;
}

.detail-panel h3 {
  margin: 0 32px 2px 0;
  font-size: 17px;
  line-height: 1.25;
}

.detail-panel .pwsid {
  font-family: var(--font-data);
  font-size: 11.5px;
  color: #7d93a6;
  margin-bottom: 12px;
}

.detail-grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: #fff;
  font-weight: 700;
  font-size: 22px;
  margin-right: 10px;
}

.detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  margin: 14px 0;
  font-size: 13px;
}

.detail-stats .stat-label {
  color: #7d93a6;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-stats .stat-value {
  font-family: var(--font-data);
  font-size: 14px;
}

/* ===== Disclaimer overlay ===== */
.disclaimer-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(11, 34, 57, 0.66);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}

.disclaimer-overlay[hidden] { display: none; }

.disclaimer-card {
  background: #fff;
  border-radius: 14px;
  max-width: 560px;
  padding: 28px 30px;
  color: #16344f;
  box-shadow: var(--shadow);
}

.disclaimer-card h2 {
  margin: 0 0 12px;
  font-size: 21px;
}

.disclaimer-card p {
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 12px;
}

.disclaimer-card a { color: #2e86c1; }

.disclaimer-accept {
  margin-top: 6px;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font: 600 15px var(--font-ui);
  padding: 12px;
  cursor: pointer;
}

.disclaimer-accept:hover { background: var(--ink-soft); }

/* ===== Popups (hover tooltip) ===== */
.maplibregl-popup.wm-hover .maplibregl-popup-content {
  font: 12.5px var(--font-ui);
  padding: 8px 10px;
  border-radius: 8px;
}

/* ===== Mobile ===== */
@media (max-width: 720px) {
  .brand-tag { display: none; }
  .topbar { flex-wrap: nowrap; gap: 10px; }
  .detail-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 55vh;
    border-radius: 14px 14px 0 0;
  }
  .legend { bottom: auto; top: 74px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
