/* =========================================================
   CyberShield · mapa.css — interfaz del mapa en vivo
   ========================================================= */
:root {
  color-scheme: dark;
  --bg: #03040a;
  --panel: rgba(9, 12, 24, .86);
  --line: rgba(140, 170, 255, .16);
  --text: #e9edff;
  --muted: #8b93ba;
  --a: #00e5ff;
  --ok: #b6ff3b;
  --warn: #ffb020;
  --bad: #ff3d6e;
  --display: "Chakra Petch", Bahnschrift, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", Consolas, ui-monospace, monospace;
  --ticker-h: 34px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--text); font: 13px/1.5 "Sora", "Segoe UI", system-ui, sans-serif; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: var(--a); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--a); outline-offset: 2px; }
h2, h3 { font-family: var(--display); letter-spacing: .04em; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.hint { color: var(--muted); font-size: 11px; }

#stars {
  position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(1px 1px at 20px 30px, #fff, transparent 60%),
    radial-gradient(1px 1px at 140px 120px, #9fb4ff, transparent 60%),
    radial-gradient(1.5px 1.5px at 210px 60px, #cdf6ff, transparent 60%),
    radial-gradient(1px 1px at 90px 190px, #fff, transparent 60%),
    radial-gradient(1px 1px at 260px 230px, #8b93ba, transparent 60%),
    radial-gradient(ellipse at 50% 50%, rgba(0, 120, 200, .13), transparent 55%);
  background-size: 290px 260px, 330px 310px, 270px 280px, 250px 230px, 310px 290px, 100% 100%;
  opacity: .65;
}
/* El lienzo del mapa es transparente fuera del globo: las estrellas se ven detrás. */
#map { position: fixed !important; inset: 0 0 var(--ticker-h) 0; }
.measuring .maplibregl-canvas { cursor: crosshair !important; }

/* ---------- Cabecera y estado ---------- */
.brand { position: fixed; top: 14px; left: 18px; z-index: 3; pointer-events: none; }
.brand a { pointer-events: auto; display: inline-flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand svg { width: 38px; height: 38px; filter: drop-shadow(0 0 10px rgba(0, 229, 255, .55)); }
.brand b { display: block; font: 700 19px/1.1 var(--display); letter-spacing: .34em; }
.brand small { font: 500 10px var(--mono); letter-spacing: .3em; color: var(--a); }
.brand p { margin-top: 6px; font: 9.5px var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); opacity: .6; text-shadow: 0 0 6px #000; }

.status { position: fixed; top: 16px; right: 18px; z-index: 3; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 16px; max-width: 62vw; font: 11px var(--mono); text-shadow: 0 0 8px #000, 0 0 3px #000; }
.status div { display: flex; gap: 6px; }
.status dt { color: var(--muted); text-transform: uppercase; }
.status dd { font-weight: 700; color: var(--a); }
.status .clock dt { color: var(--a); }
.status dd[data-state="ok"] { color: var(--ok); }
.status dd[data-state="warn"] { color: var(--warn); }

/* ---------- Barras laterales ---------- */
.rail { position: fixed; z-index: 4; display: flex; flex-direction: column; gap: 6px; padding: 7px; background: var(--panel); border: 1px solid var(--line); border-radius: 26px; backdrop-filter: blur(10px); top: 50%; transform: translateY(-50%); }
.rail-left { left: 12px; }
.rail-right { right: 12px; }
.rail button { position: relative; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); border: 1px solid transparent; transition: .2s; }
.rail svg { width: 19px; height: 19px; }
.rail button:hover, .rail button[aria-expanded="true"], .rail button[aria-pressed="true"] { color: var(--a); border-color: rgba(0, 229, 255, .45); background: rgba(0, 229, 255, .1); box-shadow: 0 0 18px rgba(0, 229, 255, .25); }
.rail-left button::after { content: attr(data-badge); position: absolute; top: -2px; right: -2px; min-width: 15px; height: 15px; border-radius: 8px; background: var(--a); color: #001318; font: 700 9px/15px var(--mono); text-align: center; }
.rail-left button[data-badge=""]::after { display: none; }
.rail-left span { position: absolute; left: 48px; white-space: nowrap; padding: 4px 9px; border-radius: 6px; background: #0b0f1e; border: 1px solid var(--line); color: var(--text); font: 11px var(--mono); opacity: 0; pointer-events: none; transition: opacity .15s; }
.rail-left button:hover span { opacity: 1; }
.rail-left button[aria-expanded="true"] span { opacity: 0; }

/* ---------- Paneles ---------- */
.flyout, .panel, .detail, .rainbar, .seg, #toast, dialog { background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(14px); box-shadow: 0 18px 50px rgba(0, 0, 0, .55); }
.flyout { position: fixed; z-index: 5; left: 76px; top: 50%; transform: translateY(-50%); width: 272px; max-height: calc(100vh - 170px); overflow: auto; padding: 12px; border-radius: 14px; animation: in .22s ease; }
.flyout header, .panel header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.flyout h2, .panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .16em; color: var(--a); }
.flyout header button, .panel header button { color: var(--muted); padding: 4px 7px; }
.flyout label { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 9px 2px; border-top: 1px solid var(--line); cursor: pointer; }
.flyout label span small { display: block; color: var(--muted); font-size: 10.5px; line-height: 1.35; }
.flyout label b { font: 500 11px var(--mono); color: var(--muted); }
.flyout input { appearance: none; width: 32px; height: 17px; border-radius: 10px; background: #232944; position: relative; cursor: pointer; transition: .2s; }
.flyout input::before { content: ""; position: absolute; width: 11px; height: 11px; top: 3px; left: 3px; border-radius: 50%; background: var(--muted); transition: .2s; }
.flyout input:checked { background: color-mix(in srgb, var(--c) 40%, #10142a); box-shadow: 0 0 12px color-mix(in srgb, var(--c) 45%, transparent); }
.flyout input:checked::before { left: 18px; background: var(--c); }

.panel { position: fixed; z-index: 5; right: 76px; top: 70px; bottom: calc(var(--ticker-h) + 150px); width: 330px; display: flex; flex-direction: column; border-radius: 14px; animation: in .22s ease; }
.panel > header { padding: 12px 14px 8px; border-bottom: 1px solid var(--line); }
#panel-body { overflow: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; }
#panel-body > * { flex-shrink: 0; }
.panel ul { list-style: none; }
.tabs { display: flex; flex-wrap: wrap; gap: 5px; }
.tabs button { padding: 4px 9px; border: 1px solid var(--line); border-radius: 20px; font: 10.5px var(--mono); color: var(--muted); }
.tabs button[aria-pressed="true"] { color: var(--a); border-color: var(--a); background: rgba(0, 229, 255, .1); }
.alerts li { border-left: 3px solid #3a4470; background: rgba(255, 255, 255, .03); border-radius: 0 8px 8px 0; margin-bottom: 6px; }
.alerts li.sev1 { border-color: var(--warn); }
.alerts li.sev2 { border-color: var(--bad); }
.alerts li > * { display: block; width: 100%; text-align: left; padding: 7px 10px; color: var(--text); text-decoration: none; }
.alerts li > *:hover { background: rgba(0, 229, 255, .08); }
.alerts small { display: block; font: 10px var(--mono); color: var(--muted); text-transform: uppercase; }
.alerts .empty { padding: 10px; color: var(--muted); }
.panel input[type="search"] { width: 100%; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line); background: #070914; }
.results button { display: block; width: 100%; text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.results button:hover { background: rgba(0, 229, 255, .08); }
.results small { display: block; color: var(--muted); font-size: 10.5px; }
.big { font: 700 40px/1 var(--display); color: var(--a); text-shadow: 0 0 24px rgba(0, 229, 255, .45); }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 90px; border-bottom: 1px solid var(--line); }
.bars i { flex: 1; background: var(--ok); opacity: .75; border-radius: 2px 2px 0 0; }
.bars i.mid { background: var(--warn); }
.bars i.hi { background: var(--bad); }
.stats li { display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; margin-bottom: 9px; }
.stats b { font: 700 12px var(--mono); }
.stats i { grid-column: 1 / -1; height: 4px; border-radius: 3px; }
.sources li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.sources small { display: block; color: var(--muted); font-size: 10.5px; }

/* ---------- Ficha ---------- */
.detail { position: fixed; z-index: 6; left: 76px; bottom: calc(var(--ticker-h) + 80px); width: 300px; max-height: calc(100vh - 220px); overflow: auto; padding: 14px; border-radius: 14px; animation: in .22s ease; }
.detail .close { position: absolute; top: 8px; right: 8px; color: var(--muted); padding: 4px 7px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 20px; font: 700 9.5px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--c); border: 1px solid var(--c); }
.detail h3 { font-size: 18px; margin: 8px 0; padding-right: 18px; overflow-wrap: anywhere; }
.detail dl > div { display: flex; justify-content: space-between; gap: 14px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.detail dt { color: var(--muted); }
.detail dd { font-family: var(--mono); text-align: right; overflow-wrap: anywhere; }
.detail .hint { margin-top: 8px; }
.detail .cam { display: block; width: 100%; aspect-ratio: 352 / 288; object-fit: cover; border-radius: 8px; background: #000; margin-bottom: 6px; }
.actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.actions button { padding: 5px 14px; border-radius: 20px; border: 1px solid var(--a); color: var(--a); }
.actions button[aria-pressed="true"] { background: var(--a); color: #001318; }

/* ---------- Controles inferiores ---------- */
.views { position: fixed; z-index: 3; left: 76px; bottom: calc(var(--ticker-h) + 36px); display: flex; gap: 8px; }
.seg { display: flex; gap: 3px; padding: 4px; border-radius: 11px; }
.seg button { padding: 5px 12px; border-radius: 8px; font: 700 10.5px var(--mono); letter-spacing: .08em; color: var(--muted); border: 1px solid transparent; }
.seg button[aria-pressed="true"] { color: var(--a); border-color: rgba(0, 229, 255, .45); background: rgba(0, 229, 255, .1); }
.readout { position: fixed; z-index: 2; left: 200px; bottom: calc(var(--ticker-h) + 6px); display: flex; gap: 18px; font: 10px var(--mono); color: var(--muted); text-transform: uppercase; pointer-events: none; text-shadow: 0 0 6px #000, 0 0 3px #000; }
.readout b { color: var(--a); }
#ro-hint { color: var(--warn); }
.rainbar { position: fixed; z-index: 3; left: 50%; transform: translateX(-50%); bottom: calc(var(--ticker-h) + 36px); display: flex; align-items: center; gap: 10px; padding: 6px 14px; border-radius: 30px; }
.rainbar input { width: min(240px, 36vw); accent-color: var(--a); }
.rainbar output { font: 700 11px var(--mono); }

.ticker { position: fixed; z-index: 4; left: 0; right: 0; bottom: 0; height: var(--ticker-h); display: flex; align-items: center; background: #070914; border-top: 1px solid var(--line); font: 11px var(--mono); }
.ticker > button { flex: none; height: 100%; padding: 0 14px; border-right: 1px solid var(--line); color: var(--a); }
.ticker-view { flex: 1; overflow: hidden; }
.ticker-track { display: inline-flex; gap: 38px; white-space: nowrap; padding-left: 16px; }
.ticker-track.run { animation: marquee 90s linear infinite; }
.ticker-view:hover .ticker-track { animation-play-state: paused; }
.ticker .up { color: var(--ok); }
.ticker .down, .ticker .quake { color: #ff7c9c; }
.ticker .cve { color: var(--warn); }

#toast { position: fixed; z-index: 9; left: 50%; top: 74px; transform: translateX(-50%); padding: 9px 18px; border-radius: 30px; border-color: var(--a); width: max-content; max-width: 90vw; text-align: center; }
dialog { margin: auto; color: var(--text); padding: 22px 26px; border-radius: 16px; max-width: min(380px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog ul { list-style: none; margin: 12px 0; }
dialog li { display: flex; gap: 12px; padding: 4px 0; }
kbd { min-width: 96px; font: 700 11px var(--mono); color: var(--a); }
dialog form button { padding: 6px 18px; border-radius: 20px; border: 1px solid var(--a); color: var(--a); }
.noscript { position: fixed; inset: 40% 10% auto; text-align: center; z-index: 10; }

/* Controles propios de MapLibre */
.maplibregl-ctrl-group { background: var(--panel) !important; border: 1px solid var(--line); }
.maplibregl-ctrl-group button + button { border-top-color: var(--line) !important; }
.maplibregl-ctrl-icon { filter: invert(.85); }
.maplibregl-ctrl-attrib { background: rgba(7, 9, 20, .85) !important; color: var(--muted); font-size: 10px; }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
.maplibregl-ctrl-attrib.maplibregl-compact-show { color: var(--text); }
.maplibregl-ctrl-scale { background: none; border-color: var(--muted); color: var(--muted); font: 10px var(--mono); }
.maplibregl-ctrl-bottom-left { left: 76px; bottom: 74px; }

@keyframes in { from { opacity: 0; filter: blur(6px); } }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Pantallas bajas ---------- */
@media (max-height: 620px) and (min-width: 801px) {
  .rail { gap: 2px; padding: 4px; }
  .rail button { width: 32px; height: 32px; }
  .brand p { display: none; }
}

/* ---------- Móvil ---------- */
@media (max-width: 800px) {
  .brand { top: 10px; left: 12px; }
  .brand svg { width: 30px; height: 30px; }
  .brand b { font-size: 14px; letter-spacing: .24em; }
  .brand p { display: none; }
  .status { top: 52px; left: 12px; right: 12px; max-width: none; justify-content: flex-start; font-size: 10px; gap: 2px 12px; }
  .rail { top: auto; transform: none; flex-direction: row; gap: 2px; padding: 4px; left: 8px; right: 8px; justify-content: space-between; }
  .rail button { width: 36px; height: 36px; }
  .rail-left { bottom: calc(var(--ticker-h) + 6px); }
  .rail-right { bottom: calc(var(--ticker-h) + 58px); }
  .rail-left span { display: none; }
  .views { left: 8px; bottom: calc(var(--ticker-h) + 110px); }
  .seg button { padding: 5px 9px; }
  .readout { left: 10px; right: 10px; bottom: auto; top: 92px; flex-wrap: wrap; gap: 4px 12px; }
  .readout span:nth-child(-n+2) { display: none; }
  .flyout, .panel, .detail { left: 8px; right: 8px; width: auto; top: auto; transform: none; bottom: calc(var(--ticker-h) + 110px); max-height: 52vh; }
  .panel { height: 52vh; }
  .detail { z-index: 7; }
  .rainbar { bottom: calc(var(--ticker-h) + 154px); }
  .rainbar input { width: 44vw; }
  #toast { top: 110px; }
  .maplibregl-ctrl-bottom-left { display: none; }
  .maplibregl-ctrl-bottom-right { bottom: 112px; }
  .maplibregl-ctrl-bottom-right .maplibregl-ctrl-group { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .ticker-view { overflow-x: auto; }
}

/* ---------- Avisos sobre el mapa y capas bloqueadas ---------- */
.map-note { position: fixed; z-index: 2; left: 50%; top: 66px; transform: translateX(-50%); width: max-content; max-width: 92vw; padding: 6px 16px; border-radius: 30px; border: 1px solid var(--line); background: var(--panel); font: 10.5px var(--mono); color: var(--muted); text-align: center; pointer-events: none; }
.map-note.sim { border-color: #ffe66d; color: #ffe66d; font-weight: 700; }
.flyout label.locked { cursor: default; }
.flyout label.locked input { cursor: not-allowed; opacity: .35; }
.flyout label.locked span { color: var(--muted); }
.flyout label.locked small { color: var(--warn); }
#panel-body h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--a); margin-top: 6px; }
@media (max-width: 800px) { .map-note { top: 108px; font-size: 9.5px; } }
