/* ====================================================================
   map.css — geographic detection map (dark theme, reuses style.css vars)
   ==================================================================== */

html, body { height: 100%; }

.map-body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---------- slim header ---------- */
.map-header {
  flex: none;
  padding: 12px 0;
}
.map-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.map-header h1 { font-size: 17px; }
.map-header .sub { font-size: 12.5px; }
.site-nav { display: flex; gap: 18px; font-size: 13.5px; white-space: nowrap; }
.site-nav a { text-decoration: none; }
.site-nav a:hover { text-decoration: underline; }

/* ---------- map area ---------- */
.map-main {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}
.map-canvas {
  position: absolute;
  inset: 0;
  background: #060a0e;
  z-index: 1;
}

/* Leaflet on dark theme */
.leaflet-container { background: #060a0e; font-family: inherit; }
.leaflet-control-layers,
.leaflet-bar {
  background: var(--panel) !important;
  color: var(--text);
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5) !important;
}
.leaflet-control-layers-expanded { padding: 8px 10px; }
.leaflet-control-layers label { color: var(--text); }
.leaflet-bar a {
  background: var(--panel) !important;
  color: var(--text) !important;
  border-bottom: 1px solid var(--border) !important;
}
.leaflet-bar a:hover { background: var(--panel-2) !important; }
.leaflet-control-attribution {
  background: rgba(11,16,22,0.78) !important;
  color: var(--muted) !important;
}
.leaflet-control-attribution a { color: var(--accent) !important; }

/* ---------- popups ---------- */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 4px 18px rgba(0,0,0,0.55);
}
.leaflet-popup-content { margin: 10px 12px; font-size: 12.5px; }
.leaflet-popup-close-button { color: var(--muted) !important; }
.det-popup .det-chip {
  width: 140px;
  height: 140px;
  object-fit: contain;
  image-rendering: pixelated;
  background: #060a0e;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: block;
  margin: 0 0 8px;
}
.det-popup .det-tag {
  display: inline-block;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; padding: 2px 7px; border-radius: 999px;
  color: #06110a; margin-bottom: 6px;
}
.det-kind {
  margin: 0 0 7px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
}
.det-kind-moving { color: var(--vessel, #35c759); }
.det-kind-static { color: #b9c4cf; }

/* static (island/rig) diamond marker — a rotated square via divIcon */
.static-diamond-wrap { background: transparent; border: 0; }
.static-diamond {
  display: block;
  width: 9px;
  height: 9px;
  margin: 1.5px;
  transform: rotate(45deg);
  border: 1px solid rgba(255,255,255,0.55);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}

.det-popup dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.det-popup dt { color: var(--muted); }
.det-popup dd { margin: 0; font-variant-numeric: tabular-nums; }

/* ---------- legend overlay ---------- */
.map-legend {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1000;
  width: 248px;
  max-width: calc(100% - 24px);
  background: rgba(21,30,39,0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.5);
  font-size: 12.5px;
}
.ml-region { margin: 0 0 8px; font-weight: 600; line-height: 1.35; }
.ml-summary {
  margin: 0 0 8px;
  font-size: 11.5px;
  color: var(--accent, #4ea8de);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ml-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 6px; }
.ml-item { color: var(--muted); font-variant-numeric: tabular-nums; }
.ml-count { margin: 0 0 10px; font-size: 12px; }
.map-legend .status-badge { margin-left: 0; }

/* ---------- date stepper ---------- */
.date-stepper {
  margin: 0 0 10px;
  padding: 8px 10px;
  background: rgba(6,10,14,0.55);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.ds-row { display: flex; align-items: center; gap: 6px; margin-bottom: 7px; }
.ds-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
}
.ds-btn:hover:not(:disabled) { background: var(--border); }
.ds-btn:disabled { opacity: 0.4; cursor: default; }
.ds-select {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.ds-slider { width: 100%; accent-color: var(--accent, #4ea8de); cursor: pointer; }

/* ---------- hide-static toggle ---------- */
.ds-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.ds-toggle input { accent-color: var(--accent, #4ea8de); cursor: pointer; }

/* ---------- crude oil price panel ---------- */
.ml-oil {
  margin-bottom: 10px;
  padding: 8px 10px;
  background: rgba(6,10,14,0.55);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.oil-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.oil-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent, #4ea8de);
}
.oil-date {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.oil-rows { display: grid; gap: 3px; }
.oil-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.oil-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.oil-brent { color: #ffb454; }
.oil-wti { color: #5bc8ff; }
.oil-price {
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.oil-na { margin: 0; font-size: 11.5px; color: var(--muted); }
.oil-src { margin: 6px 0 0; font-size: 10px; color: var(--muted); line-height: 1.35; }

.btn-zoom {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
}
.btn-zoom:hover { background: var(--border); }

.ml-key { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.ml-key li { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.key-swatch {
  width: 12px; height: 12px; border-radius: 3px; flex: none;
  border: 1px solid rgba(255,255,255,0.25);
}
.key-swatch[data-label="unverified"] { background: var(--unverified); }
.key-swatch[data-label="vessel"]     { background: var(--vessel); }
.key-swatch[data-label="island"]     { background: var(--island); }
.key-swatch[data-label="rig"]        { background: var(--rig); }
.key-swatch[data-label="noise"]      { background: #2a3744; }
.key-swatch.key-moving { background: var(--vessel, #35c759); }
.key-swatch.key-static {
  background: rgba(138,151,163,0.4);
  border: 1px dashed #8a97a3;
}
.key-swatch.key-aoi { background: transparent; border: 1px dashed var(--accent); }

.ml-note { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.4; }

/* ---------- news / signals panel (right side) ---------- */
/* Starts below the Leaflet layer/zoom controls in the top-right so it never
   overlaps them; scrolls vertically; capped width consistent with legend. */
.news-panel {
  position: absolute;
  top: 92px;
  right: 12px;
  z-index: 1000;
  width: 320px;
  max-width: calc(100% - 24px);
  /* Cap so the SAR scene panel (stacked below) stays visible without either
     covering the whole map. */
  max-height: calc(55% - 60px);
  overflow-y: auto;
  background: rgba(21,30,39,0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.5);
  font-size: 12.5px;
}
.news-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.news-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent, #4ea8de);
}
.news-date {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.news-list { display: grid; gap: 10px; }
.news-item {
  padding: 8px 10px;
  background: rgba(6,10,14,0.55);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.news-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 7px;
  margin-bottom: 5px;
}
.news-badge {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
  flex: none;
}
.news-badge-news { background: var(--accent, #4ea8de); color: #06110a; }
.news-badge-social { background: #b07cf0; color: #100617; }
.news-itemdate {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.news-asof {
  font-size: 10px;
  font-style: italic;
  color: var(--rig, #ff9f0a);
}
.news-source { font-size: 10.5px; color: var(--muted); }
.news-headline { line-height: 1.35; margin-bottom: 4px; }
.news-link { font-weight: 600; color: var(--text); text-decoration: none; }
.news-link[href]:hover { text-decoration: underline; color: var(--accent, #4ea8de); }
.news-link-plain { cursor: default; }
.news-summary { margin: 0; font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.news-empty { margin: 0; font-size: 11.5px; color: var(--muted); }

/* ---------- SAR scene panel (right side, stacked below news) ---------- */
/* Pinned to the bottom-right so it sits below the news panel; same dark card
   style. Capped so it never covers the whole map or the top-right controls. */
.scene-panel {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 1000;
  width: 320px;
  max-width: calc(100% - 24px);
  max-height: calc(45% - 24px);
  overflow-y: auto;
  background: rgba(21,30,39,0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.5);
  font-size: 12.5px;
}
.scene-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.scene-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent, #4ea8de);
}
.scene-date {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.scene-link { display: block; }
.scene-img {
  display: block;
  width: 300px;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #060a0e;
}
.scene-caption {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}
.scene-empty { margin: 0; font-size: 11.5px; color: var(--muted); }

/* ---------- hard error overlay ---------- */
.map-error {
  position: absolute;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.map-error-inner {
  text-align: center;
  max-width: 420px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.map-error-inner h2 { margin: 0 0 8px; font-size: 18px; }
.map-error-inner p { margin: 0; color: var(--muted); }

@media (max-width: 640px) {
  .map-legend { width: 210px; }
  .map-header .sub { display: none; }
  /* On narrow screens, shrink the right-side panels and stack them at the
     bottom-right so they never cover the whole map. */
  .news-panel {
    width: 200px;
    top: auto;
    bottom: 12px;
    right: 12px;
    max-height: 32%;
  }
  /* Scene panel sits above the news panel on mobile (news pinned to bottom). */
  .scene-panel {
    width: 200px;
    bottom: auto;
    top: 12px;
    right: 12px;
    max-height: 32%;
  }
}
