/* =============================================================================
 * Exposure Mapping — Hydro-terrain Metrics
 * Theme: clean cartographic tool UI. Blue accent carried over from the
 * prototype (#1b6cff); contour amber (#feb24c) reserved for map data only.
 * ========================================================================== */

:root {
  --accent:        #1b6cff;
  --accent-dark:   #0d47a1;
  --ink:           #202124;   /* primary text  */
  --ink-soft:      #5f6368;   /* secondary text */
  --line:          #dadce0;   /* hairline borders */
  --surface:       #ffffff;
  --danger:        #d93025;
  --radius:        10px;
  --radius-pill:   24px;
  --shadow-1:      0 1px 3px rgba(60, 64, 67, .25), 0 2px 8px rgba(60, 64, 67, .12);
  --shadow-2:      0 4px 16px rgba(60, 64, 67, .28);
  --font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

html, body, #map {
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  font-family: var(--font);
}

.is-hidden { display: none !important; }

.maplibregl-popup { z-index: 99999 !important; }

/* Hover popup content (built in JS) */
.hover-popup {
  max-width: 300px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--ink);
}
.hover-popup-item {
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.hover-popup-item:last-child { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }
.hover-popup-title { font-weight: 600; margin-bottom: 4px; }

/* =============================================================================
 * SEARCH BAR  — Google-Maps-style pill:  [ input  ✕ │ 🔍 ]
 * ========================================================================== */

#panel_search {
  position: absolute;
  top: 12px;
  left: 60px;
  z-index: 1001;
  width: min(504px, calc(100vw - 80px));
}

.searchbar {
  display: flex;
  align-items: center;
  height: 44px;
  background: var(--surface);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-1);
  padding: 0 4px 0 16px;
  transition: box-shadow .15s ease;
}
.searchbar:focus-within { box-shadow: var(--shadow-2); }

.searchbox {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font);
  font-size: 15px;
  color: var(--ink);
  text-overflow: ellipsis;
}
.searchbox::placeholder { color: var(--ink-soft); }

.searchbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  color: var(--ink-soft);
  flex-shrink: 0;
  transition: background .12s ease, color .12s ease;
}
.searchbar-btn:hover:not(:disabled) { background: rgba(60, 64, 67, .08); color: var(--ink); }
.searchbar-btn .material-icons { font-size: 22px; }

/* Clear ✕ — only visible while the field has text */
.searchbar-clear { visibility: hidden; opacity: 0; transition: opacity .12s ease; }
.searchbar-clear.is-visible { visibility: visible; opacity: 1; }

.searchbar-divider {
  width: 1px;
  height: 24px;
  background: var(--line);
  margin: 0 4px;
  flex-shrink: 0;
}

/* Geocode 🔍 — enabled only while the field has text */
.searchbar-go { color: var(--accent); }
.searchbar-go:disabled { color: #b9bdc4; cursor: default; }
.searchbar-go:hover:not(:disabled) { background: rgba(27, 108, 255, .10); color: var(--accent); }

/* Google Places autocomplete dropdown — align with the pill */
.pac-container {
  border-radius: 12px;
  margin-top: 6px;
  border: none;
  box-shadow: var(--shadow-2);
  font-family: var(--font);
}
.pac-item { padding: 8px 12px; font-size: 13px; cursor: pointer; }
.pac-item:hover { background: #f1f3f4; }
.pac-item-query { font-size: 14px; }

/* =============================================================================
 * MAIN PANEL
 * ========================================================================== */

#panel1a {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 255px;
  background: var(--surface);
  padding: 0 16px 10px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  z-index: 1001;
  color: var(--ink);
  overflow: hidden;               /* lets the title bar bleed to the rounded edges */
}

#toggle-panel {
  position: absolute;
  right: 6px;
  top: 8px;
  z-index: 1002;
  border: none;
  background: transparent;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;                    /* sits on the themed title bar */
}
#toggle-panel:hover { background: rgba(255, 255, 255, .22); }

/* Collapsed: a single themed round button (terrain icon) in the top-right corner */
#panel1a.collapsed {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: var(--shadow-1);
  overflow: visible;
}
#panel1a.collapsed #panel1a-content { display: none; }
#panel1a.collapsed #toggle-panel {
  position: static;
  width: 44px;
  height: 44px;
  color: #fff;
}
#panel1a.collapsed #toggle-panel .material-icons { font-size: 24px; }

/* Toggle button: arrow when expanded, brand mark when collapsed */
#toggle-panel .brand-mini { display: none; }
#panel1a.collapsed #toggle-panel #toggle-icon { display: none; }
#panel1a.collapsed #toggle-panel .brand-mini { display: block; }

.mapTitle-icon { flex-shrink: 0; }

/* Themed title bar: hydro-terrain icon + titles on an accent gradient */
#mapTitle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 -16px 12px;           /* bleed to panel edges */
  padding: 12px 40px 12px 14px;   /* right space for the collapse button */
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  text-align: left;
}

.mapTitle-main {
  display: block;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .2px;
  line-height: 1.2;
}
.mapTitle-sub {
  display: block;
  font-size: 11.5px;
  color: rgba(255, 255, 255, .85);
  margin-top: 1px;
}

/* Each section sits on its own soft shaded card */
.panel-section {
  margin-bottom: 12px;
  background: #f6f8fb;
  border-radius: 8px;
  padding: 10px;
}

.panel-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

/* Section headers: soft, no vertical bar */
.panel-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--ink-soft);
  padding: 0 2px;
  margin-bottom: 8px;
}
.panel-label .material-icons { font-size: 15px; color: var(--accent); }
.panel-section-head { margin-bottom: 8px; padding: 0 2px; }
.panel-section-head .panel-label { margin-bottom: 0; padding: 0; }

.basemap-dropdown {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}
.basemap-dropdown:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* Overlay checkboxes */
.overlay-map-options { display: flex; flex-direction: column; gap: 2px; }

.overlay-map-option {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  line-height: 1.35;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.overlay-map-option:hover { background: #e9eef7; }

.overlay-map-option input[type="checkbox"],
.overlay-map-option input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.opacity-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 6px 4px 30px;
  cursor: pointer;
}
.opacity-row .material-icons { font-size: 16px; color: var(--ink-soft); }
.opacity-row input[type="range"] {
  flex: 1;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
}

.info-icon {
  font-size: 20px;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
  transition: color .15s ease;
}
.info-icon:hover { color: var(--accent-dark); }

/* Coordinates form */
.form-search { display: flex; flex-direction: column; gap: 6px; }

.form-search input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.form-search input[type="text"]:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.button_style1 {
  align-self: flex-start;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  padding: 7px 22px;
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s ease;
}
.button_style1:hover { background: #155ee0; }
.button_style1:active { background: var(--accent-dark); }

#input_check { font-size: 12.5px; color: var(--danger); min-height: 1em; margin-top: 4px; }

/* Footer icon buttons */
.panel-footer {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  border-top: 1px solid var(--line);
  padding-top: 6px;
}
.icon-btn {
  border: none;
  background: transparent;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-soft);
}
.icon-btn:hover { background: rgba(60, 64, 67, .08); color: var(--ink); }
.icon-btn .material-icons { font-size: 21px; }

/* =============================================================================
 * DATA SOURCES TOOLTIP
 * ========================================================================== */

.tooltip {
  display: none;
  position: absolute;
  top: 86px;
  right: 312px;   /* panel box ends at 299px from the right → ~23px gap */
  background: var(--surface);
  border: none;
  box-shadow: var(--shadow-2);
  border-radius: 12px;
  padding: 14px 16px;
  width: min(390px, calc(100vw - 362px));
  z-index: 1003;
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink);
  max-height: calc(100vh - 150px);
  overflow-y: auto;
}
.tooltip.show { display: block; animation: fadeIn .18s ease-in-out; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .tooltip.show { animation: none; }
}

.tooltip h4 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  font-size: 15px;
}
.tooltip a { color: var(--accent); text-decoration: none; }
.tooltip a:hover { text-decoration: underline; }
.ext-link { font-size: 15px; vertical-align: middle; }

.tooltip ul { list-style: none; margin: 4px 0 0; padding-left: 0; }

.tooltip > ul > li {
  display: flex;
  flex-direction: column;
  margin-top: 10px;
  padding-left: 28px;
  position: relative;
}
.tooltip > ul > li > .material-icons {
  position: absolute;
  left: 0;
  top: 2px;
  font-size: 18px;
  color: var(--accent);
}
.tooltip ul ul { margin-left: 0; padding-left: 0; }
.tooltip ul ul li {
  margin: 4px 0;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.sub-icon { font-size: 16px; color: var(--ink-soft); flex-shrink: 0; }

/* Attribution & licence footer inside the info dialog */
.tooltip-attrib {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--ink-soft);
}
.tooltip-attrib b {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--ink);
  margin-bottom: 4px;
}
.tooltip-attrib p { margin: 0 0 6px; }
.tooltip-attrib p:last-child { margin-bottom: 0; }
.tooltip-attrib .ext-link { font-size: 13px; }
.tooltip-warn {
  background: #fff8e1;
  border-left: 3px solid #f0a500;
  border-radius: 0 4px 4px 0;
  padding: 6px 8px;
  color: #6b4e00;
}

/* =============================================================================
 * STATUS BAR — live cursor Lat / Lon / Zoom, bottom-centre
 * ========================================================================== */

#status-bar {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(3px);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-1);
  padding: 6px 16px;
  font-family: var(--font);
  font-size: 12.5px;
  color: var(--ink);
  white-space: nowrap;
  pointer-events: none;           /* never block map interaction */
}
#status-bar .sb-label { color: var(--ink-soft); margin-right: 4px; }
#status-bar .sb-value {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  display: inline-block;
  min-width: 78px;                /* stops jitter as digits change */
}
#status-bar .sb-zoom .sb-value { min-width: 20px; }

/* =============================================================================
 * SMALL SCREENS
 * ========================================================================== */

@media (max-width: 640px) {
  #panel_search { left: 56px; width: calc(100vw - 68px); }
  #panel1a { top: 68px; right: 8px; width: 230px; }
  .tooltip { right: 8px; left: 8px; width: auto; top: 130px; }
  #status-bar { font-size: 11.5px; gap: 10px; padding: 5px 12px; }
}
