/* So Energy palette + glass control surfaces */
:root {
  --so-night: #252C29;
  --so-day: #E8E7E1;
  --so-dusk: #81877C;
  --so-midday: #FFFFFF;
  --so-morning: #F8FEB9;
  --so-electric: #CBFB00;
  --so-hydro: #019CA1;
  --so-dear: #FF646D;
  --so-mint: #40C9A2;

  --accent: var(--so-electric);          /* lng / story colour */
  --tanker: var(--so-hydro);             /* secondary tier */
  --other: var(--so-dusk);               /* tertiary tier */

  --panel-bg: rgba(31, 37, 34, 0.86);
  --panel-fg: var(--so-day);
  --panel-muted: #A7ACA2;
  --panel-border: rgba(232, 231, 225, 0.14);
  --panel-hover: rgba(232, 231, 225, 0.08);
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  font-family: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; background: var(--so-night); }
#map { position: absolute; inset: 0; z-index: 0; }

button { font-family: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---- panels ---- */
.panel {
  position: absolute;
  z-index: 1000;
  background: var(--panel-bg);
  color: var(--panel-fg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* ---- scrollbars (match dark UI) ---- */
.hl-list, .cx-list, #controls, .src-body, .kpidrop-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 231, 225, 0.22) transparent;
}
.hl-list::-webkit-scrollbar, .cx-list::-webkit-scrollbar,
#controls::-webkit-scrollbar, .src-body::-webkit-scrollbar,
.kpidrop-list::-webkit-scrollbar {
  width: 8px; height: 8px;
}
.hl-list::-webkit-scrollbar-track, .cx-list::-webkit-scrollbar-track,
#controls::-webkit-scrollbar-track, .src-body::-webkit-scrollbar-track,
.kpidrop-list::-webkit-scrollbar-track {
  background: transparent;
}
.hl-list::-webkit-scrollbar-thumb, .cx-list::-webkit-scrollbar-thumb,
#controls::-webkit-scrollbar-thumb, .src-body::-webkit-scrollbar-thumb,
.kpidrop-list::-webkit-scrollbar-thumb {
  background: rgba(232, 231, 225, 0.2);
  border: 2px solid transparent;
  border-radius: 6px;
  background-clip: padding-box;
}
.hl-list::-webkit-scrollbar-thumb:hover, .cx-list::-webkit-scrollbar-thumb:hover,
#controls::-webkit-scrollbar-thumb:hover, .src-body::-webkit-scrollbar-thumb:hover,
.kpidrop-list::-webkit-scrollbar-thumb:hover {
  background: rgba(232, 231, 225, 0.36);
  background-clip: padding-box;
}

/* ---- zoom controls (right, under vessels panel): Map + UI ---- */
.leaflet-top.leaflet-right { top: 486px; right: 18px; }
.leaflet-right .leaflet-control-zoom { margin: 0 0 26px 0; position: relative; }
.leaflet-right .leaflet-control-zoom.ui-zoom { margin-bottom: 0; }
/* label above each control */
.leaflet-right .leaflet-control-zoom::before {
  content: "Map";
  position: absolute;
  top: -16px; left: 0; right: 0;
  text-align: center;
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--panel-muted);
}
.leaflet-right .leaflet-control-zoom.ui-zoom::before { content: "UI"; }
.leaflet-control-zoom {
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.leaflet-control-zoom a {
  width: 34px; height: 34px; line-height: 34px;
  background: var(--panel-bg);
  color: var(--panel-fg);
  border: none;
  font-size: 18px; font-weight: 400;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.leaflet-control-zoom a:first-child {
  border-radius: 11px 11px 0 0;
  border-bottom: 1px solid var(--panel-border);
}
.leaflet-control-zoom a:last-child { border-radius: 0 0 11px 11px; }
.leaflet-control-zoom a:hover {
  background: rgba(232, 231, 225, 0.12);
  color: var(--accent);
}
.leaflet-control-zoom a.leaflet-disabled {
  color: var(--panel-muted);
  background: var(--panel-bg);
}

/* ---- header badge ---- */
#header {
  top: 18px;
  left: 18px;
  padding: 14px 18px;
  max-width: 340px;
}
#header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: lowercase;
}
#header .sub {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--panel-muted);
  font-variant-numeric: tabular-nums;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--so-mint);
  box-shadow: 0 0 0 0 rgba(64, 201, 162, 0.6);
  animation: ping 2s infinite;
}
.dot.travel { background: var(--so-morning); animation: none; }
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(64, 201, 162, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(64, 201, 162, 0); }
  100% { box-shadow: 0 0 0 0 rgba(64, 201, 162, 0); }
}

/* ---- control panel ---- */
/* ---- strait status line ---- */
.strait-line { color: var(--panel-fg); font-weight: 600; }
.sdot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--so-dusk); display: inline-block; flex: none;
}
.sdot.ok { background: var(--so-mint); }
.sdot.warn { background: var(--so-morning); }
.sdot.bad { background: var(--so-dear); }
.sdetail { color: var(--panel-muted); font-weight: 400; }

#controls {
  top: 18px;
  right: 18px;
  width: 290px;
  padding: 4px 0 10px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
}
.section { padding: 14px 18px; border-top: 1px solid var(--panel-border); }
.section:first-child { border-top: none; }
.section h2 {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--panel-muted);
}

/* ---- filter rows ---- */
.filter {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  margin-bottom: 6px;
  background: var(--panel-hover);
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--panel-fg);
  text-align: left;
  transition: background 0.15s, opacity 0.15s, border-color 0.15s;
}
.filter:hover { background: rgba(232, 231, 225, 0.14); }
.filter[aria-pressed="false"] { opacity: 0.4; }
.filter[aria-pressed="true"] { border-color: var(--panel-border); }
.filter .glyph { flex: none; display: grid; place-items: center; }
.filter .label { flex: 1; }
.filter .name { font-size: 13px; font-weight: 600; display: block; }
.filter .desc { font-size: 11px; color: var(--panel-muted); }
.filter .count {
  font-size: 14px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* tier swatches sized by visual significance */
.swatch-lng {
  width: 26px; height: 26px;
  background: var(--accent);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  filter: drop-shadow(0 0 6px var(--accent));
}
.swatch-tanker {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--tanker);
  border: 1.5px solid rgba(255, 255, 255, 0.7);
}
.swatch-other {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--other);
}
.swatch-blockade {
  width: 22px; height: 0;
  border-top: 3px dashed var(--so-dear);
}
.swatch-trails {
  width: 22px; height: 0;
  border-top: 2px solid var(--so-hydro);
  border-radius: 2px;
}

/* ---- segmented + swatch controls ---- */
.segmented { display: flex; gap: 6px; }
.segmented button {
  flex: 1;
  padding: 8px 6px;
  font-size: 12px; font-weight: 600;
  color: var(--panel-fg);
  background: var(--panel-hover);
  border: 1px solid transparent;
  border-radius: 10px;
  text-transform: capitalize;
}
.segmented button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--so-night);
}

.swatches { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.swatches button {
  width: 26px; height: 26px; border-radius: 8px;
  border: 2px solid transparent;
}
.swatches button[aria-pressed="true"] { border-color: var(--so-midday); }
.swatches input[type="color"] {
  width: 30px; height: 30px; padding: 0;
  border: 1px solid var(--panel-border);
  border-radius: 8px; background: none; cursor: pointer;
}

.note { font-size: 11px; line-height: 1.5; color: var(--panel-muted); }
.note strong { color: var(--so-morning); font-weight: 600; }

/* ---- time-travel ---- */
#timebar {
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: min(720px, calc(100vw - 36px));
  padding: 14px 20px 16px;
}
#timebar .row { display: flex; align-items: center; gap: 14px; }
.tt-btn {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-size: 14px;
  color: var(--panel-fg);
  background: var(--panel-hover);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
}
.tt-btn:hover { background: rgba(232, 231, 225, 0.16); }
#liveBtn {
  flex: none;
  padding: 0 16px; height: 38px;
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--so-night);
  background: var(--so-mint);
  border: none; border-radius: 10px;
}
#liveBtn[data-live="false"] { background: var(--panel-hover); color: var(--panel-fg); }

#tt-stamp {
  flex: none;
  min-width: 168px;
  font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* range with boat thumb */
#tt-range {
  flex: 1;
  -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 6px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--so-hydro) 100%);
  opacity: 0.85;
}
#tt-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 34px; height: 34px;
  background: var(--so-night) center/20px no-repeat;
  background-image: var(--boat-thumb);
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
#tt-range::-moz-range-thumb {
  width: 34px; height: 34px;
  background: var(--so-night) center/20px no-repeat;
  background-image: var(--boat-thumb);
  border: 2px solid var(--accent);
  border-radius: 50%;
}
#tt-caption {
  margin-top: 8px;
  font-size: 11px; color: var(--panel-muted);
  text-align: center;
}

/* ---- kpi strip ---- */
#kpibar {
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 10px 8px;
}
.kpi {
  display: flex; flex-direction: column; align-items: center;
  padding: 2px 16px; min-width: 74px;
  border-right: 1px solid var(--panel-border);
}
.kpi:last-child { border-right: none; }
.kpi .kv {
  font-size: 20px; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi .kv.accent { color: var(--accent); }
.kpi .kl {
  margin-top: 4px; font-size: 10px; color: var(--panel-muted);
  text-transform: lowercase; letter-spacing: 0.02em;
}
.kpi-btn {
  cursor: pointer; font: inherit; color: var(--panel-fg); border: none;
  background: none; border-radius: 10px; transition: background 0.15s;
}
.kpi-btn:hover, .kpi-btn[aria-expanded="true"] { background: var(--panel-hover); }
.kpi-btn .kl::after { content: " ▾"; opacity: 0.55; }

/* ---- kpi drilldown dropdown ---- */
#kpiDrop {
  top: 86px;
  transform: translateX(-50%);
  width: 300px; padding: 0; overflow: hidden; z-index: 1100;
}
.kpidrop-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--panel-border);
}
#kpiDropTitle {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--panel-muted);
}
#kpiDropClose {
  width: 22px; height: 22px; line-height: 1;
  color: var(--panel-fg); background: var(--panel-hover);
  border: 1px solid var(--panel-border); border-radius: 7px; font-size: 14px;
}
.kpidrop-list { max-height: 320px; overflow-y: auto; padding: 6px 8px 10px; }
.kpidrop-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px; border-radius: 10px;
  background: none; border: none; color: var(--panel-fg); text-align: left;
}
.kpidrop-row:hover { background: var(--panel-hover); }
.kpidrop-row + .kpidrop-row { border-top: 1px solid var(--panel-border); }
.kpidrop-dir {
  flex: none; width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.kpidrop-dir.inbound { background: rgba(64, 201, 162, 0.2); color: var(--so-mint); }
.kpidrop-dir.outbound { background: rgba(248, 254, 185, 0.18); color: var(--so-morning); }
.kpidrop-main { flex: 1; min-width: 0; }
.kpidrop-name {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpidrop-meta {
  font-size: 11px; color: var(--panel-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpidrop-time { flex: none; font-size: 11px; color: var(--panel-muted); }
.kpidrop-empty { padding: 12px; font-size: 12px; color: var(--panel-muted); }

/* ---- latest headlines ---- */
#headlines {
  top: 128px;
  bottom: 468px;          /* stretch down, gap matches header→headlines */
  left: 18px;
  width: 290px;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.hl-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 8px;
}
.hl-head h2 {
  margin: 0; font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--panel-muted);
}
.hl-live {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--so-dear); animation: ping 2s infinite;
}
.hl-list { flex: 1 1 auto; overflow-y: auto; padding: 0 8px 10px; }
.hl-item {
  display: block; padding: 8px; border-radius: 10px;
  text-decoration: none; color: var(--panel-fg);
}
.hl-item:hover { background: var(--panel-hover); }
.hl-item + .hl-item { border-top: 1px solid var(--panel-border); }
.hl-src {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--panel-muted);
}
.hl-item.primary .hl-src { color: var(--so-morning); }
.hl-title { font-size: 12px; line-height: 1.35; margin-top: 2px; }
.hl-time {
  font-size: 10px; color: var(--panel-muted); margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.hl-empty { padding: 8px; font-size: 12px; color: var(--panel-muted); }

/* ---- recent crossings feed ---- */
#crossings {
  bottom: 110px;
  left: 18px;
  width: 290px;
  padding: 0;
  overflow: hidden;
}
.cx-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
}
.cx-head h2 {
  margin: 0; font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--panel-muted);
}
#cxToggle {
  width: 24px; height: 24px; line-height: 1;
  color: var(--panel-fg); background: var(--panel-hover);
  border: 1px solid var(--panel-border); border-radius: 7px; font-size: 16px;
}
.cx-list { max-height: 230px; overflow-y: auto; padding: 0 8px 8px; }
#crossings.collapsed .cx-list { display: none; }
.cx-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 8px; border-radius: 10px;
  background: none; border: none; color: var(--panel-fg); text-align: left;
}
.cx-row:hover { background: var(--panel-hover); }
.cx-dir {
  flex: none; width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.cx-dir.inbound { background: rgba(64, 201, 162, 0.2); color: var(--so-mint); }
.cx-dir.outbound { background: rgba(248, 254, 185, 0.18); color: var(--so-morning); }
.cx-dir.in_strait { background: rgba(1, 156, 161, 0.2); color: var(--so-hydro); }
.cx-main { flex: 1; min-width: 0; }
.cx-name {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cx-meta {
  font-size: 11px; color: var(--panel-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cx-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.cx-time { flex: none; font-size: 11px; color: var(--panel-muted); font-variant-numeric: tabular-nums; }

/* ---- blockade sources footer ---- */
.cx-sources {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--panel-border);
}
.cx-src-label {
  width: 100%;
  font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--panel-muted);
}
.cx-sources a {
  font-size: 11px; color: var(--so-hydro); text-decoration: none;
  border-bottom: 1px solid transparent;
}
.cx-sources a:hover { border-bottom-color: var(--so-hydro); }

/* ---- trend mini chart ---- */
#trend { width: 100%; height: 56px; }
#trend svg { width: 100%; height: 100%; display: block; overflow: visible; }
#trend rect { transition: opacity 0.15s; }
#trend rect:hover { opacity: 0.7; }

/* ---- ship search ---- */
.cx-search { padding: 0 16px 10px; }
#shipSearch {
  width: 100%; padding: 8px 10px;
  font-size: 12px; font-family: inherit;
  color: var(--panel-fg); background: var(--panel-hover);
  border: 1px solid var(--panel-border); border-radius: 10px;
}
#shipSearch::placeholder { color: var(--panel-muted); }
.cx-search-hint {
  display: block; margin-top: 5px; min-height: 12px;
  font-size: 10px; color: var(--panel-muted);
}

/* ---- search highlight marker ---- */
.search-marker svg { filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6)); }

/* ---- sources tray ---- */
#sources { bottom: 22px; right: 18px; width: 262px; padding: 0; overflow: hidden; }
.src-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 12px 16px; background: none; border: none;
  color: var(--panel-fg); font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.src-chev { color: var(--panel-muted); transition: transform 0.2s; }
#sources.collapsed .src-chev { transform: rotate(180deg); }
#sources.collapsed .src-body { display: none; }
.src-body { padding: 0 16px 14px; }
.src-group { padding: 8px 0; border-top: 1px solid var(--panel-border); }
.src-label {
  display: block; margin-bottom: 4px;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--panel-muted);
}
.src-group a {
  font-size: 12px; color: var(--so-hydro); text-decoration: none;
  margin-right: 10px; border-bottom: 1px solid transparent;
}
.src-group a:hover { border-bottom-color: var(--so-hydro); }
.src-note {
  display: block; margin-top: 4px;
  font-size: 10px; line-height: 1.4; color: var(--panel-muted);
}

/* ---- lng vessel marker ---- */
.lng-marker { position: relative; width: 34px; height: 34px; }
.lng-marker .pulse {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: lngpulse 2.4s ease-out infinite;
}
@keyframes lngpulse {
  0% { transform: scale(0.4); opacity: 0.9; }
  100% { transform: scale(1.3); opacity: 0; }
}
.lng-marker .hull {
  position: absolute; top: 7px; left: 7px;
  width: 20px; height: 20px;
  background: var(--accent);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  filter: drop-shadow(0 0 6px var(--accent));
}

/* ---- leaflet popup theming ---- */
.leaflet-popup-content-wrapper {
  background: var(--panel-bg);
  color: var(--panel-fg);
  border-radius: 12px;
  backdrop-filter: blur(12px);
}
.leaflet-popup-tip { background: var(--panel-bg); }
.vpop .vname { font-size: 14px; font-weight: 700; margin-bottom: 1px; }
.vpop .vflag { font-size: 12px; color: var(--panel-muted); margin-bottom: 7px; }
.vpop .vtier {
  display: inline-block; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 2px 7px; border-radius: 999px; margin-bottom: 8px;
  background: var(--accent); color: var(--so-night);
}
.vpop table { font-size: 12px; border-collapse: collapse; }
.vpop td { padding: 2px 0; }
.vpop td.k { color: var(--panel-muted); padding-right: 12px; }
.vpop td.v { font-variant-numeric: tabular-nums; }

/* blockade marker labels */
.bk-marker { display: flex; align-items: center; gap: 7px; }
.bk-square {
  flex: none; width: 14px; height: 14px;
  background: none; border: 2px solid #FF646D; border-radius: 2px;
}
.bk-label {
  background: rgba(31, 37, 34, 0.82);
  color: var(--so-day);
  font-size: 12px; font-weight: 400;
  padding: 2px 8px; border-radius: 6px; white-space: nowrap;
  backdrop-filter: blur(6px);
}
.dest-square {
  flex: none; width: 11px; height: 11px;
  background: none; border: 2px solid #FF646D; border-radius: 2px;
}
.dest-label {
  background: rgba(31, 37, 34, 0.7);
  color: var(--so-day);
  font-size: 11px; font-weight: 400;
  padding: 1px 6px; border-radius: 5px; white-space: nowrap;
}

@media (max-width: 720px) {
  #controls { width: 250px; }
  #header { max-width: 220px; }
}
