/* Current look of the map: deep navy, the map is the hero, chrome is small and solid.
   Logic and DOM ids stay in map-app.js — this file is paint and layout only.
   The basemap colours are painted into the tiles (map-geography.js): keep --tile-bg equal to
   MASK there. No backdrop-filter and no CSS filter on anything that moves with the map. */
:root[data-theme="dark"] {
  --bg: #0b0f14;
  --tile-bg: #0b0f14;
  --panel: rgba(17, 23, 31, .95);
  --panel-solid: #11171f;
  --surface: rgba(148, 178, 208, .08);
  --surface-hover: rgba(148, 178, 208, .14);
  --line: rgba(148, 178, 208, .13);
  --line-2: rgba(148, 178, 208, .24);
  --text: #eef3f8;
  --muted: #9aabbc;
  --dim: #6c7e90;
  --ink: #eef3f8;
  --ink-text: #0b0f14;
  --accent: #f5c518;
  --ok: #3dd68c;
  --warn: #f5c518;
  --err: #ff5c6a;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --r: 16px;
  --r-s: 11px;
}
:root[data-theme="light"] {
  --bg: #eaeef2;
  --tile-bg: #eaeef2;
  --panel: rgba(255, 255, 255, .97);
  --panel-solid: #ffffff;
  --accent: #c9a227;
  --shadow: 0 10px 26px rgba(18, 24, 32, .14);
}

html, body, .map-shell, .map-canvas, .leaflet-container.map-canvas { background: var(--tile-bg); }
.leaflet-container { background: var(--tile-bg) !important; }
.base-tiles, .leaflet-tile-pane { filter: none !important; }

.brand, .top-actions, .topbar-status, .map-dock, .activity-panel, .detail-panel,
.legend, .search-results, .map-message, .leaflet-control-zoom, .uav-tools,
.mh-ctl, .mh-bar, .rl-ctl, .rl-bar, .mx-ctl, .hm-ctl, .map-tooltip, .mc-ctl {
  background: var(--panel) !important;
  border: 1px solid var(--line) !important;
  box-shadow: var(--shadow) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* ---------- header ---------- */
.brand { height: 44px; padding: 0 12px 0 8px; border-radius: 13px; gap: 8px; }
.brand-logo { width: 28px; height: 28px; border-radius: 8px; }
.brand-copy strong { font-size: 13px; letter-spacing: .04em; font-weight: 700; }
.brand-copy small {
  margin-top: 1px;
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--ok) 16%, transparent);
  color: var(--ok);
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .04em;
}
.topbar { height: auto; }
.topbar-status {
  top: calc(var(--gap) + 54px);
  min-height: 36px;
  padding: 3px 4px 3px 10px;
  border-radius: 13px;
  gap: 0;
}
.connection { font-family: var(--sans); font-size: 11px; letter-spacing: 0; text-transform: none; }
.summary { min-height: 28px; padding: 4px 10px; font-size: 11px; }
.summary b { font-size: 13px; font-family: var(--sans); font-weight: 700; font-variant-numeric: tabular-nums; }
.summary-uav b { color: var(--accent); }

.top-actions { min-height: 44px; padding: 4px; border-radius: 13px; gap: 4px; }
.theme-switch { border-radius: 10px; padding: 2px; }
.theme-switch button { min-height: 28px; padding: 0 10px; border-radius: 8px; font-size: 11px; }
.theme-switch button[aria-pressed="true"] { background: var(--text); color: var(--ink-text); box-shadow: none; }
.icon-button { width: 36px; height: 36px; border-radius: 10px; }
.game-button { min-height: 36px; border-radius: 10px; background: var(--accent); color: #16140c; font-weight: 600; }
.game-button:hover { background: #ffd54a; color: #16140c; }
.text-link { min-height: 32px; font-size: 12px; }

/* ---------- search and chips ---------- */
.map-dock { padding: 6px; border-radius: 16px; gap: 6px; }
.place-search input { height: 42px; border-radius: 12px; font-size: 14px; background: var(--surface); }
.mobile-map-actions button { min-height: 42px; border-radius: 12px; font-size: 12px; }
.mobile-map-actions button[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }

.legend { border-radius: 14px; bottom: calc(var(--gap) + 26px); }
.legend[open] { background: var(--panel-solid) !important; }
.legend summary { min-height: 40px; font-family: var(--sans); font-size: 11px; letter-spacing: .04em; }

/* ---------- feed ---------- */
.activity-panel { border-radius: 18px; background: var(--panel-solid) !important; }
.activity-head { padding: 16px 16px 0; }
.activity-head h1 { font-size: 21px; font-weight: 700; letter-spacing: -.03em; }
.eyebrow { font-family: var(--sans); letter-spacing: .08em; }
.activity-sub { margin: 6px 16px 10px; }
.feed-item {
  margin-bottom: 8px;
  padding: 12px 12px 12px 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}
.feed-item::before { left: 8px; top: 12px; bottom: 12px; width: 3px; }
.feed-item strong { font-size: 14px; font-weight: 650; }
.feed-item time, .feed-time-row em { font-family: var(--sans); font-size: 10px; color: var(--dim); }
.activity-foot { font-family: var(--sans); font-size: 11px; letter-spacing: 0; }

.detail-panel { border-radius: 18px; background: var(--panel-solid) !important; }
.detail-panel h2 { font-size: 18px; font-weight: 700; }

/* ---------- tool rail ---------- */
.leaflet-control-zoom, .uav-tools, .mh-ctl, .rl-ctl, .mx-ctl, .hm-ctl, .mc-ctl { border-radius: 13px !important; }
.leaflet-control-zoom a, .uav-tools .uav-tool, .mh-tool, .mx-ctl a, .mx-ctl button,
.hm-ctl a, .hm-ctl button, .rl-ctl a, .rl-ctl button, .mc-more {
  width: 38px !important;
  height: 38px !important;
  line-height: 38px !important;
}
.leaflet-control-attribution { background: transparent !important; color: var(--dim) !important; }

/* ---------- things on the map ---------- */
/* The icon box is 40px and anchored at its middle; at 34px the rotation centre was off the real
   point. The white body with its dark outline reads without a shadow, and a filter here would be
   recomputed on each propeller repaint. */
.uav-icon-body { width: 40px; height: 40px; filter: none; }
.uav-icon-fly { transform-origin: 50% 50%; }
.quiet-label span { font-family: var(--sans); letter-spacing: .08em; }
.map-tooltip { border-radius: 11px; }

.leave-cover { background: var(--tile-bg); }

/* ---------- phone: search on top, chips and sheet below, the district in the middle ---------- */
@media (max-width: 760px) {
  :root { --header: 44px; --gap: 8px; --feed-height: 220px; --dock-h: 58px; --search-top: 56px; }
  body.embed { --search-top: 8px; }
  body.feed-collapsed { --feed-height: 56px; }

  .brand { height: 40px; padding: 0 10px 0 6px; }
  .brand-logo { width: 26px; height: 26px; }
  .brand-copy strong { font-size: 12px; }
  .top-actions { min-height: 40px; padding: 3px; }
  .theme-switch button { min-height: 28px; padding: 0 8px; }
  .icon-button { width: 32px; height: 32px; }

  .topbar-status {
    top: calc(var(--search-top) + 50px);
    left: 8px;
    right: auto;
    min-height: 32px;
    padding: 2px 4px 2px 8px;
  }
  body .topbar-status .summary span { display: inline; font-size: 9px; }
  .summary { padding: 4px 7px; gap: 4px; }
  .summary b { font-size: 12px; }

  .map-canvas { bottom: 0; }
  /* the dock is only a wrapper here: its two parts sit at opposite ends of the screen */
  .map-dock, body.embed .map-dock { display: contents; }
  .place-search {
    position: absolute;
    z-index: 760;
    top: var(--search-top);
    left: 8px;
    right: 56px;
    width: auto;
    border-radius: 14px;
    background: var(--panel-solid);
    box-shadow: var(--shadow);
  }
  .place-search::before { top: 15px; }
  .place-search input { height: 44px; border: 1px solid var(--line); border-radius: 14px; font-size: 16px; background: var(--surface); }
  .search-results { top: calc(100% + 6px); bottom: auto; max-height: 45vh; }

  .mobile-map-actions {
    position: absolute;
    z-index: 760;
    left: 56px;
    right: 8px;
    bottom: calc(var(--feed-height) + 8px);
    margin: 0;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  body.mc-phone .mobile-map-actions { right: 8px; }
  .mobile-map-actions::-webkit-scrollbar { display: none; }
  .mobile-map-actions button {
    flex: 1 0 auto;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--panel-solid);
    color: var(--text);
    font-size: 12.5px;
    font-weight: 500;
  }

  /* the legend folds into a round button at the start of the chip row */
  .legend { left: 8px; bottom: calc(var(--feed-height) + 8px); max-width: calc(100% - 16px); z-index: 770; border-radius: 13px; }
  .legend summary { justify-content: center; width: 40px; min-height: 38px; padding: 0; font-size: 0; gap: 0; }
  .legend summary::before { content: "?"; color: var(--text); font-size: 16px; font-weight: 600; }
  .legend summary::after { display: none; }
  .legend[open] { width: calc(100% - 16px); }

  .leaflet-top { top: calc(var(--search-top) - 2px); }
  body.embed .leaflet-top { top: 2px; }
  .leaflet-right { right: 0; }
  body .leaflet-top.leaflet-right > .leaflet-control { margin-right: 8px !important; }
  /* zoomed out, the caption under a quiet region's name only covers the drones */
  .uav-far .quiet-label small { display: none; }
  .uav-far .quiet-label span { font-size: 9px; letter-spacing: .04em; }
  .leaflet-control-attribution { display: none !important; }

  .activity-panel { height: var(--feed-height); border-radius: 20px 20px 0 0; }
  .activity-head { padding: 16px 14px 8px; min-height: 52px; }
  .activity-head h1 { font-size: 16px; }
  .detail-panel { bottom: calc(var(--feed-height) + var(--dock-h)); }
  .map-message { bottom: calc(var(--feed-height) + var(--dock-h)); max-width: calc(100% - 16px); }
  body.mh-on .detail-panel, body.mh-on .map-message { bottom: calc(var(--feed-height) + var(--dock-h) + 84px); }
  .rl-bar, .mh-bar {
    --rl-bottom: calc(var(--feed-height) + var(--dock-h));
    --mh-bottom: calc(var(--feed-height) + var(--dock-h));
  }
}

@media (max-width: 480px) {
  .brand-copy small { display: none; }
  .topbar-status .connection .status-label { display: none; }
}

@media (max-height: 500px) and (max-width: 760px) {
  .topbar-status { display: none; }
}
