/* ————— Bandwidth: field-instrument HUD over a full-bleed map ————— */
:root {
  --ink: #14201b;          /* spruce ink: HUD chrome */
  --ink-2: #1d2c25;
  --bone: #e8e4d8;         /* readout text */
  --dim: #93a096;          /* secondary labels */
  --paper: #f1ede0;        /* USGS quad paper (minimal basemap bg) */
  --band: #e5342b;         /* highlighter red */
  --hair: rgba(232, 228, 216, 0.14);
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
#map { position: absolute; inset: 0; }

/* ————— HUD ————— */
#hud {
  position: absolute; top: 12px; right: 12px; z-index: 10;
  width: 262px;
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  backdrop-filter: blur(6px);
  border: 1px solid var(--hair);
  border-radius: 10px;
  color: var(--bone);
  font-family: var(--sans);
  font-size: 12.5px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

#hud-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--hair);
}
#hud-head h1 {
  margin: 0; font-family: var(--mono); font-size: 14px;
  font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
}
#hud-head .sub { color: var(--dim); font-size: 10.5px; flex: 1; }
#hud-collapse {
  background: none; border: 1px solid var(--hair); border-radius: 5px;
  color: var(--dim); width: 20px; height: 20px; line-height: 1;
  cursor: pointer; font-family: var(--mono);
}
#hud-collapse:hover { color: var(--bone); }
#hud.collapsed #hud-body { display: none; }

.hud-section { padding: 10px 12px; border-bottom: 1px solid var(--hair); }
.hud-section:last-child { border-bottom: none; }
.section-label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--dim); margin-bottom: 8px;
}

/* ————— Bands: stacked cards, each slider track is a live legend ————— */
.band-add {
  background: none; border: 1px solid var(--hair); border-radius: 5px;
  color: var(--dim); font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 2px 8px; cursor: pointer;
}
.band-add:hover { color: var(--bone); border-color: var(--band); }

.band-card { padding-top: 8px; border-top: 1px dashed var(--hair); margin-top: 8px; }
.band-card:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.band-card-head {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--dim); font-size: 10.5px;
}
.b-remove {
  background: none; border: none; color: var(--dim);
  cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 5px;
}
.b-remove:hover { color: var(--band); }

/* ————— Signature: band slider whose track is a live legend ————— */
.band-slider { position: relative; height: 26px; margin: 2px 0 6px; }
.band-slider .track {
  position: absolute; left: 0; right: 0; top: 11px; height: 4px;
  background: var(--paper); border-radius: 2px; overflow: hidden;
}
.band-slider .fill {
  position: absolute; top: 0; bottom: 0;
  background: var(--band); opacity: 0.75;
}
.band-slider input[type="range"] {
  position: absolute; left: 0; right: 0; top: 0; width: 100%; height: 26px;
  margin: 0; background: none; -webkit-appearance: none; appearance: none;
  pointer-events: none; /* thumbs re-enable */
}
.band-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; pointer-events: auto;
  width: 14px; height: 14px; margin-top: 6px; border-radius: 50%;
  background: var(--bone); border: 2px solid var(--ink);
  box-shadow: 0 0 0 1px var(--bone); cursor: ew-resize;
}
.band-slider input[type="range"]::-moz-range-thumb {
  pointer-events: auto; width: 12px; height: 12px; border-radius: 50%;
  background: var(--bone); border: 2px solid var(--ink);
  box-shadow: 0 0 0 1px var(--bone); cursor: ew-resize;
}
.band-slider input[type="range"]::-moz-range-track { background: none; }
.band-slider input[type="range"]:focus-visible { outline: 2px solid var(--band); outline-offset: 2px; }

.band-numbers {
  display: flex; gap: 10px; font-family: var(--mono); color: var(--dim);
}
.band-numbers label { display: flex; align-items: center; gap: 5px; font-size: 10.5px; }
.band-numbers input {
  width: 64px; background: var(--ink-2); color: var(--bone);
  border: 1px solid var(--hair); border-radius: 5px;
  font-family: var(--mono); font-size: 12px; padding: 3px 5px;
}

.band-style {
  display: flex; gap: 14px; align-items: center; margin-top: 8px;
  color: var(--dim); font-size: 10.5px;
}
.band-style label { display: flex; align-items: center; gap: 6px; }
.band-style input[type="color"] {
  width: 24px; height: 18px; padding: 0; border: 1px solid var(--hair);
  border-radius: 4px; background: none; cursor: pointer;
}
.band-style input[type="range"] { width: 90px; accent-color: var(--band); }

/* toggles */
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.switch-row { display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--bone); }
.switch-row input, .switch input { accent-color: var(--band); }
.switch { display: inline-flex; }

.meta { font-family: var(--mono); font-size: 10.5px; color: var(--dim); }

/* ————— Cursor readout ————— */
#readout {
  position: absolute; left: 12px; bottom: 34px; z-index: 10;
  background: color-mix(in srgb, var(--ink) 90%, transparent);
  border: 1px solid var(--hair); border-radius: 8px;
  color: var(--bone); font-family: var(--mono);
  padding: 6px 10px; font-size: 12px;
  display: flex; gap: 10px; align-items: baseline;
  pointer-events: none;
}
#readout-ele { font-size: 15px; font-weight: 600; }
#readout-ll { color: var(--dim); font-size: 10px; }

/* ————— Mobile: actual touch devices at phone widths, not narrow desktop windows ————— */
@media (pointer: coarse) and (max-width: 820px) {
  #hud {
    left: 10px; right: 10px; width: auto; top: auto;
    bottom: calc(10px + env(safe-area-inset-bottom));
    max-height: 60dvh;
    display: flex; flex-direction: column;
  }
  #hud-body { overflow-y: auto; overscroll-behavior: contain; }
  /* keep the readout clear of the top-left zoom controls */
  #readout {
    bottom: auto; top: calc(10px + env(safe-area-inset-top));
    left: auto; right: 10px;
  }
}

/* ————— Touch ergonomics ————— */
@media (pointer: coarse) {
  #hud { font-size: 14px; }
  .band-slider { height: 34px; }
  .band-slider .track { top: 15px; }
  .band-slider input[type="range"] { height: 34px; }
  .band-slider input[type="range"]::-webkit-slider-thumb {
    width: 22px; height: 22px; margin-top: 6px;
  }
  .band-slider input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; }
  .band-numbers input { font-size: 16px; width: 76px; padding: 6px; } /* ≥16px stops iOS zoom-on-focus */
  .band-numbers label, .band-style, .band-style label { font-size: 12px; }
  .band-style input[type="range"] { width: 120px; height: 28px; }
  .band-style input[type="color"] { width: 32px; height: 26px; }
  .switch-row { padding: 4px 0; }
  .switch-row input, .switch input { width: 18px; height: 18px; }
  #hud-collapse { width: 28px; height: 28px; }
  .band-add { padding: 6px 12px; font-size: 11px; }
  .b-remove { font-size: 18px; padding: 4px 8px; }
}

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