/* -- LOCATION SEARCH (inside panel loc-wrap) -- */
#search-wrap {
  position: relative;
  margin-top: 10px;
}
#search-row {
  display: flex; align-items: center; gap: 6px;
}
#search-row #loc-refresh {
  flex-shrink: 0;
  padding: 6px;
  border-radius: 8px;
}
#search-row #loc-refresh span { display: none; }
#search-box {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  background: var(--inset-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#search-box:focus-within {
  border-color: rgba(57,255,20,0.35);
  box-shadow: 0 0 8px rgba(57,255,20,0.08);
}
#search-box svg { flex-shrink: 0; color: var(--muted); }
#search-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text);
  font: 400 12px/1 'Rajdhani', sans-serif;
  letter-spacing: 0.5px;
  padding: 9px 0;
}
#search-input::placeholder { color: var(--muted); font-size: 11px; }
#search-clear {
  background: none; border: none; color: var(--muted);
  font-size: 16px; cursor: pointer; padding: 0 2px;
  line-height: 1;
}
#search-clear:hover { color: var(--text); }
#search-clear.hidden { display: none; }

#loc-wrap {
  position: relative;
  z-index: 50;
}
#search-wrap {
  position: relative;
  z-index: 50;
}
#search-results {
  position: absolute; left: 0; right: 0; top: 100%;
  margin-top: 4px;
  background: rgba(3, 14, 3, 0.97);
  border: 1px solid var(--border);
  border-radius: 8px;
  backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.7);
  overflow: hidden;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
}
#search-results.hidden { display: none; }
.search-item {
  display: block; width: 100%;
  background: none; border: none; border-bottom: 1px solid var(--border);
  color: var(--text);
  font: 400 12px/1.5 'Rajdhani', sans-serif;
  padding: 9px 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: rgba(57,255,20,0.06); }
.search-item .search-sub {
  display: block; font-size: 10px; color: var(--muted);
  margin-top: 2px; letter-spacing: 0.5px;
}

/* -- LIVE CAM MAP MARKER -- */
.livecam-marker {
  width: 36px; height: 36px;
  background: rgba(255, 40, 40, 0.85);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(255, 40, 40, 0.6), 0 2px 8px rgba(0,0,0,0.4);
  animation: livecam-pulse 2s ease infinite;
  transition: transform 0.2s;
}
.livecam-marker:hover {
  transform: scale(1.15);
  box-shadow: 0 0 20px rgba(255, 40, 40, 0.8), 0 2px 12px rgba(0,0,0,0.5);
}
@keyframes livecam-pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(255, 40, 40, 0.6), 0 2px 8px rgba(0,0,0,0.4); }
  50% { box-shadow: 0 0 22px rgba(255, 40, 40, 0.9), 0 2px 8px rgba(0,0,0,0.4); }
}

/* -- LIVE FEED POPUP — unified radar-telemetry card -- */
#livefeed {
  position: fixed; z-index: 300;
  bottom: 24px; right: 16px;
  width: 420px;
  animation: livefeed-in 0.3s ease;
}
#livefeed.hidden { display: none; }
@keyframes livefeed-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

#livefeed-card {
  position: relative;
  background: linear-gradient(to bottom,
    rgba(16, 32, 16, 0.95) 0%,
    rgba(6, 16, 6, 0.94) 100%);
  backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow:
    0 10px 32px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(57, 255, 20, 0.04) inset,
    0 1px 0 rgba(255, 255, 255, 0.05) inset;   /* top bevel highlight */
}

/* Resize grip — left-edge vertical bar, desktop only.
   Span is middle-40% of the card height, so it never overlaps the header
   (LIVE indicator) or the bottom nav (prev/next buttons). Hit area is a
   10-px-wide invisible strip; the visual handle is a thin green bar that
   brightens on hover. */
#livefeed-resize {
  position: absolute;
  left: 0; top: 30%; bottom: 30%;
  width: 10px;
  display: none;
  cursor: ew-resize;
  z-index: 5;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}
#livefeed-resize::before {
  content: '';
  position: absolute;
  left: 3px; top: 50%;
  transform: translate(0, -50%);
  width: 3px; height: 28px;
  background: rgba(57, 255, 20, 0.30);
  border-radius: 2px;
  transition: background 0.15s, box-shadow 0.15s, height 0.15s;
}
#livefeed-resize:hover::before {
  background: rgba(57, 255, 20, 0.85);
  box-shadow: 0 0 8px rgba(57, 255, 20, 0.45);
  height: 42px;
}
#livefeed.resizing { user-select: none; }
#livefeed.resizing #livefeed-resize::before {
  background: var(--green);
  box-shadow: 0 0 10px rgba(57, 255, 20, 0.6);
  height: 48px;
}
#livefeed-resize svg { display: none; } /* legacy SVG inside the grip, if any */

@media (hover: hover) and (pointer: fine) and (min-width: 721px) {
  #livefeed-resize { display: block; }
}
#livefeed.maximized #livefeed-resize { display: none; }

/* Header — lightest band (primary info / title) — also the drag handle on desktop */
#livefeed-header {
  padding: 7px 10px 9px 12px;
  background: rgba(255, 255, 255, 0.028);
  border-bottom: 1px solid rgba(57, 255, 20, 0.12);
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}
@media (min-width: 721px) {
  #livefeed-header { cursor: grab; }
  #livefeed.dragging #livefeed-header { cursor: grabbing; }
  #livefeed.dragging { opacity: 0.96; transition: none; }
  /* Buttons + grip keep their own cursors, not grab */
  #livefeed-header button,
  #livefeed-resize { cursor: inherit; }
  #livefeed-close { cursor: pointer; }
  #livefeed-resize { cursor: nwse-resize; }
}
#livefeed-header-meta {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 5px;
}
.livefeed-meta-spacer { flex: 1; }
.livefeed-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #ff3333;
  box-shadow: 0 0 8px rgba(255, 50, 50, 0.9);
  animation: livefeed-pulse 1.5s ease infinite;
  flex-shrink: 0;
}
@keyframes livefeed-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(255, 50, 50, 0.9); }
  50%      { opacity: 0.35; box-shadow: 0 0 2px rgba(255, 50, 50, 0.3); }
}
.livefeed-live-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px; font-weight: 700;
  letter-spacing: 1.8px;
  color: #ff4d4d;
  flex-shrink: 0;
}
#livefeed-location {
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px; font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1.25;
  color: var(--text);
  /* Up to 2 lines, ellipsize the rest — handles 60+ char aggregator titles */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
}
#livefeed-close {
  background: none; border: none;
  color: var(--muted);
  width: 24px; height: 24px;
  border-radius: 5px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}
#livefeed-close:hover { color: #ff4444; background: rgba(255,68,68,0.08); }

/* Maximize button — desktop only. Default state is hidden; the button is
   ONLY revealed on true desktop (hover-capable pointer AND viewport ≥ 721px).
   Defensive: if the media query below fails to load, the button stays hidden
   rather than appearing on a phone. */
#livefeed-maximize {
  display: none;
  background: none; border: none;
  color: var(--muted);
  width: 24px; height: 24px;
  border-radius: 5px;
  cursor: pointer;
  align-items: center; justify-content: center;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}
#livefeed-maximize:hover {
  color: var(--green);
  background: rgba(57,255,20,0.08);
}
/* Icon swaps based on state (restore hidden by default) */
#livefeed-maximize .icon-restore { display: none; }
#livefeed.maximized #livefeed-maximize .icon-max     { display: none; }
#livefeed.maximized #livefeed-maximize .icon-restore { display: inline; }

@media (hover: hover) and (pointer: fine) and (min-width: 721px) {
  #livefeed-maximize { display: flex; }
}

/* ── MAXIMIZED STATE — fills the viewport (desktop only) ────────────────── */
@media (min-width: 721px) {
  #livefeed.maximized {
    left:   24px !important;
    right:  24px !important;
    top:    24px !important;
    bottom: 24px !important;
    width:  auto !important;
  }
  #livefeed.maximized #livefeed-card {
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  #livefeed.maximized #livefeed-video-wrap { flex: 1; min-height: 0; }
  #livefeed.maximized #livefeed-embed     { padding-bottom: 0; height: 100%; }
  #livefeed.maximized #livefeed-header    { cursor: default; }
}

/* Telemetry strip — mid-tone band (data/secondary info) */
#livefeed-telemetry {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 6px 12px;
  background: linear-gradient(to right,
    rgba(57, 255, 20, 0.035) 0%,
    rgba(0, 0, 0, 0.18) 100%);
  border-top: 1px solid rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid rgba(57, 255, 20, 0.08);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset;
}
#livefeed-region {
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px; font-weight: 600;
  letter-spacing: 1.2px; text-transform: uppercase;
  line-height: 1.35;
  color: var(--muted);
  flex: 1; min-width: 0;
  /* Up to 2 lines, ellipsize — mirrors the header title behavior */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Clock module — promoted from a small badge to a proper readout */
.livefeed-clock {
  display: inline-grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  flex-shrink: 0;
  padding: 3px 10px 3px 14px;
  border-left: 1px solid rgba(57, 255, 20, 0.22);
  box-shadow: -1px 0 0 rgba(0, 0, 0, 0.25);  /* subtle shadow pair → "etched" groove */
}
.livefeed-clock-label {
  grid-column: 1; grid-row: 1;
  font-family: 'Rajdhani', sans-serif;
  font-size: 8px; font-weight: 700;
  letter-spacing: 1.8px; text-transform: uppercase;
  color: var(--muted);
  line-height: 1;
  align-self: end;
}
.livefeed-clock-time {
  grid-column: 2; grid-row: 1 / span 2;
  font-family: 'Bebas Neue', monospace;
  font-size: 22px;
  letter-spacing: 1.5px;
  color: var(--green);
  text-shadow: 0 0 8px rgba(57,255,20,0.45);
  line-height: 1;
  display: inline-flex; align-items: baseline;
}
.livefeed-colon {
  animation: livefeed-colon-blink 1s step-end infinite;
  padding: 0 1px;
}
@keyframes livefeed-colon-blink {
  0%, 50%  { opacity: 1; }
  51%, 100% { opacity: 0.25; }
}
.livefeed-clock-tz {
  grid-column: 1; grid-row: 2;
  font-family: 'Rajdhani', sans-serif;
  font-size: 9px; font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--green);
  opacity: 0.6;
  line-height: 1;
  align-self: start;
  text-align: right;
}

/* Video with scan-line overlay (the "C" bit) */
#livefeed-video-wrap {
  position: relative;
  background: #000;
}
#livefeed-embed {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  background: #000;
  overflow: hidden;
}
#livefeed-embed iframe {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  border: none;
}
.livefeed-img {
  width: 100%;
  display: block;
  background: #000;
}

/* Nav — darkest band (utility chrome) */
#livefeed-nav {
  display: flex; align-items: center;
  background: linear-gradient(to bottom,
    rgba(0, 0, 0, 0.35) 0%,
    rgba(0, 0, 0, 0.45) 100%);
  border-top: 1px solid rgba(0, 0, 0, 0.4);
  box-shadow: 0 1px 0 rgba(57, 255, 20, 0.06) inset;   /* thin green inset separator */
}
#livefeed-prev, #livefeed-next {
  background: rgba(57,255,20,0.05);
  border: none;
  color: var(--green);
  width: 52px; height: 38px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  opacity: 0.85;
}
#livefeed-prev svg, #livefeed-next svg {
  width: 18px; height: 18px;
  stroke-width: 3;
  filter: drop-shadow(0 0 4px rgba(57,255,20,0.35));
}
#livefeed-prev:hover, #livefeed-next:hover {
  color: var(--green);
  background: rgba(57,255,20,0.18);
  opacity: 1;
  box-shadow: inset 0 0 12px rgba(57,255,20,0.25);
}
#livefeed-prev:active, #livefeed-next:active {
  background: rgba(57,255,20,0.28);
}
#livefeed-counter {
  flex: 1;
  text-align: center;
  font-family: 'Bebas Neue', monospace;
  font-size: 13px; letter-spacing: 2.5px;
  color: var(--green); opacity: 0.8;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  line-height: 38px;
}

/* Offline state — shown when a YouTube feed errors */
.livefeed-offline {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
  background: radial-gradient(ellipse at center, rgba(20,20,20,0.95), #000 80%);
  color: var(--text);
  padding: 16px;
  text-align: center;
}
.livefeed-offline-icon {
  font-size: 28px;
  color: #ffaa33;
  text-shadow: 0 0 10px rgba(255,170,51,0.5);
  line-height: 1;
}
.livefeed-offline-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 13px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  color: #ff6b6b;
}
.livefeed-offline-sub {
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px; font-weight: 500;
  color: var(--muted);
  max-width: 280px; line-height: 1.4;
}
.livefeed-offline-hint {
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px; font-weight: 600;
  letter-spacing: 1px;
  color: var(--green);
  opacity: 0.7;
  margin-top: 4px;
}

/* Light theme: swap the dark-shade ladder for a warm cream equivalent */
[data-theme="light"] #livefeed-card {
  background: linear-gradient(to bottom,
    rgba(255, 253, 250, 0.82) 0%,
    rgba(245, 243, 238, 0.78) 100%);
  box-shadow:
    0 8px 24px rgba(120, 113, 108, 0.18),
    0 1px 0 rgba(255, 255, 255, 0.6) inset;
}
[data-theme="light"] #livefeed-header       { background: rgba(255, 255, 255, 0.5); }
[data-theme="light"] #livefeed-telemetry    { background: linear-gradient(to right, rgba(71, 85, 105, 0.05) 0%, rgba(120, 113, 108, 0.08) 100%); }
[data-theme="light"] #livefeed-nav          { background: linear-gradient(to bottom, rgba(120, 113, 108, 0.08) 0%, rgba(120, 113, 108, 0.14) 100%); }
[data-theme="light"] .livefeed-clock-time   { text-shadow: none; }
[data-theme="light"] .livefeed-clock        { border-left-color: rgba(71, 85, 105, 0.22); box-shadow: none; }

/* -- TOP-RIGHT CONTROLS PANEL -- */
#map-controls {
  position: fixed; top: 16px; right: 16px; z-index: 200;
  display: flex; align-items: center; gap: 0;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 12px;
  backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  overflow: hidden;
}

.ctrl-btn {
  background: none; border: none;
  color: var(--muted);
  padding: 10px 14px;
  cursor: pointer;
  font-family: 'Rajdhani', sans-serif; font-size: 11px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.ctrl-btn:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.ctrl-btn svg { width: 16px; height: 16px; display: block; }

/* Language buttons */
.lang-btn.active { color: var(--green); background: rgba(57,255,20,0.08); }

/* Theme toggle */
#theme-toggle { color: var(--muted); }
#theme-toggle:hover { color: var(--text); }

/* Cloud toggle */
#cloud-toggle.active { color: var(--green); background: rgba(57,255,20,0.08); }
#cloud-toggle.active svg { color: var(--green); }

/* Divider between groups */
.ctrl-sep {
  width: 1px; height: 20px;
  background: var(--border);
  flex-shrink: 0;
}
