/* ═══════════════════════════════════════════════════════════════
   Cyber view of the global assets map (pairs with cyber-view.js).
   Arcs, live pulses, target nodes, country dots, popups and the operations
   panel. Colors and timings come from config.js through custom properties
   that cyber-view.js sets on :root (--cyber-color-<level>, --cyber-attacker,
   --cyber-target, and --cyber-glow-seconds for the chosen marker style) and on
   each target node
   (--cyber-node-color); nothing here sets a palette.
   ═══════════════════════════════════════════════════════════════ */

/* ── Cyber mode layout ────────────────────────────────── */
/* The panel sits beside the map, not over it, on wide screens: the map's
   US end stays visible. On narrow screens the sidebar overlays as before. */
@media (min-width: 1025px) {
  body.cyber-mode.cyber-panel-open #map { left: var(--sidebar-width); }
}

/* Phone width: the "SYSTEM ONLINE" badge overlaps the ONGOING count in the top bar, so
   cyber mode drops it there. On wide screens it crowds nothing and stays. */
@media (max-width: 480px) {
  body.cyber-mode .hud-stat--status { display: none; }
}

/* Phone width: the map fills the screen, but its panes (and the vector basemap canvas) are wider than it.
   That overflow stretched the page past the screen width, so the top bar ran off the right edge. Paint
   containment clips them to the map box, which is the whole screen here; wider screens keep the overflow. */
@media (max-width: 600px) {
  body.cyber-mode #map {
    contain: paint;
  }
}

/* Cyber mode: the tiled brand watermark competes with the arcs, so it is lighter */
body.cyber-mode #map-watermark-center .wm-tile { color: rgba(255, 255, 255, 0.012); }

/* ── Arcs ─────────────────────────────────────────────── */
/* Ongoing operations are bright and thick, concluded ones static and dim (weights
   and opacities are set from config.js; these rules only add the interaction).
   Arcs carry no transition or animation: only ongoing operations move. */
.cyber-arc-hit {
  cursor: pointer;
}

/* Hovering a list row (or an arc) lifts that arc and sinks the rest */
.cyber-focus .cyber-arc {
  stroke-opacity: 0.12;
}

.cyber-focus .cyber-arc.cyber-arc--hot {
  stroke-opacity: 1;
  stroke-width: 5;
}

/* Page-wide hover brightening is for markers; it washes out thin dotted arcs */
.cyber-arc-hit:hover,
.cyber-arc:hover {
  filter: none;
}

/* ── Arrowhead at the target end of an arc ────────────── */
/* The box is a Leaflet icon (class cyber-arrow, plain background and border in styles.css);
   the chevron inside takes its level color from --arrow-color, set by index.php. */
.cyber-arrow__glyph {
  color: var(--arrow-color);
  font-size: 10px;
  filter: drop-shadow(0 0 3px var(--arrow-color));
}

/* ── Target nodes on ongoing operations ───────────────── */
/* A small marker at the target in the operation's level color, in the style the
   viewer picks in the operations panel (config.js markerStyles; one modifier
   class per style below). Every style keeps its size: only opacity changes in
   its animation, so it reads as a live node, not a blast. The pulse along the
   arc is moved by cyber-view.js. The icon box carries Leaflet's positioning
   transform and the style's size, so the look lives on its two inner parts:
   __halo (glow or center point) and __core (the mark itself). A style that does
   not use a part hides it. --cyber-glow-seconds is the chosen style's timing. */
.cyber-target-node {
  pointer-events: none;
}

.cyber-target-node__halo,
.cyber-target-node__core {
  position: absolute;
  inset: 0;
}

/* Signal point: a bright round core with a soft halo that slowly brightens and dims */
.cyber-target-node--signal .cyber-target-node__core {
  border-radius: 50%;
  background: var(--cyber-node-color);
  box-shadow: 0 0 0 1px var(--theme-bg), 0 0 2px 1px var(--cyber-node-color);
}

.cyber-target-node--signal .cyber-target-node__halo {
  border-radius: 50%;
  box-shadow: 0 0 6px 3px var(--cyber-node-color);
  opacity: 0.2;
  animation: cyber-node-glow var(--cyber-glow-seconds, 3.2s) ease-in-out infinite alternate;
}

/* Hexagon node: a thin hexagon outline with a bright center point and a slow soft
   flicker. The outline is a ring cut by clip-path (outer and inner hexagon, even-odd);
   its glow is a drop shadow on the icon box, because clip-path would cut a shadow
   drawn on the ring itself. */
.cyber-target-node--hex {
  filter: drop-shadow(0 0 2px var(--cyber-node-color));
}

.cyber-target-node--hex .cyber-target-node__core {
  background: var(--cyber-node-color);
  clip-path: polygon(evenodd,
    50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%, 50% 0,
    50% 15%, 13% 34%, 13% 66%, 50% 85%, 87% 66%, 87% 34%, 50% 15%);
  animation: cyber-node-flicker var(--cyber-glow-seconds, 2.4s) ease-in-out infinite;
}

.cyber-target-node--hex .cyber-target-node__halo {
  inset: 3px;
  background: var(--cyber-node-color);
  box-shadow: 0 0 2px var(--cyber-node-color);
}

/* Terminal pixel: a square pixel that blinks softly like a terminal cursor */
.cyber-target-node--pixel .cyber-target-node__core {
  background: var(--cyber-node-color);
  box-shadow: 0 0 3px var(--cyber-node-color);
  animation: cyber-node-blink var(--cyber-glow-seconds, 1.1s) ease-in-out infinite;
}

.cyber-target-node--pixel .cyber-target-node__halo {
  display: none;
}

/* Diamond: a turned square with a framed outer glow that brightens and dims */
.cyber-target-node--diamond .cyber-target-node__core {
  inset: 2px;
  transform: rotate(45deg);
  background: var(--cyber-node-color);
  box-shadow: 0 0 0 1px var(--theme-bg), 0 0 4px var(--cyber-node-color);
}

.cyber-target-node--diamond .cyber-target-node__core::before {
  content: "";
  position: absolute;
  inset: -3px;
  border: 1px solid var(--cyber-node-color);
  box-shadow: 0 0 8px var(--cyber-node-color), inset 0 0 4px var(--cyber-node-color);
  opacity: 0.25;
  animation: cyber-node-glow var(--cyber-glow-seconds, 2.8s) ease-in-out infinite alternate;
}

.cyber-target-node--diamond .cyber-target-node__halo {
  display: none;
}

@keyframes cyber-node-glow {
  from { opacity: 0.25; }
  to   { opacity: 0.9; }
}

@keyframes cyber-node-flicker {
  0%, 100% { opacity: 1; }
  40%      { opacity: 0.85; }
  50%      { opacity: 0.45; }
  60%      { opacity: 0.9; }
  70%      { opacity: 0.6; }
}

@keyframes cyber-node-blink {
  0%, 45%   { opacity: 1; }
  55%, 100% { opacity: 0.2; }
}

/* Reduced motion: no animation in any style; a still medium glow marks the node */
@media (prefers-reduced-motion: reduce) {
  .cyber-target-node--signal .cyber-target-node__halo,
  .cyber-target-node--diamond .cyber-target-node__core::before {
    animation: none;
    opacity: 0.55;
  }

  .cyber-target-node--hex .cyber-target-node__core,
  .cyber-target-node--pixel .cyber-target-node__core {
    animation: none;
  }
}

/* ── Country dots ─────────────────────────────────────── */
.cyber-node {
  cursor: pointer;
  transition: fill-opacity 0.15s ease;
}

.cyber-node--target:hover {
  fill-opacity: 1;
}

.cyber-node--attacker:hover {
  fill-opacity: 0.3;
}

.leaflet-tooltip.cyber-tip {
  background: var(--theme-surface-solid);
  color: var(--theme-text);
  border: 1px solid var(--theme-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.leaflet-tooltip-top.cyber-tip::before {
  border-top-color: var(--theme-border);
}

/* ── Popups ───────────────────────────────────────────── */
/* The popup never grows taller than the visible map, so Leaflet does not have to
   drag the map to fit it (the shared 350px cap was taller than a small embed). */
.cyber-popup .leaflet-popup-content {
  max-height: min(350px, max(140px, calc(100vh - 190px)));
}

.cyber-level {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--theme-text);
}

.cyber-level__line {
  flex-shrink: 0;
}

.cyber-popup__by {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--theme-border-subtle);
  font-size: 11px;
  line-height: 1.4;
  color: var(--theme-text);
}

.cyber-popup__body .popup-cyber-type-badge {
  --badge-color: var(--theme-cyan);
}

.cyber-popup__link {
  color: var(--theme-cyan);
}

.cyber-popup__focus {
  margin-top: 4px;
  padding: 2px 8px;
  background: none;
  border: 1px solid var(--theme-border);
  border-radius: var(--radius-sm);
  color: var(--theme-accent);
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
}

.cyber-popup__focus:hover {
  background: var(--theme-hover);
}

/* ── Operations panel (inside the sidebar) ────────────── */
.cyber-panel__summary {
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--theme-meta);
}

.cyber-panel__heading {
  margin: 14px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--theme-border-faint);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--theme-meta);
}

.cyber-panel__group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cyber-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: none;
  border: 1px solid var(--theme-border-faint);
  border-radius: var(--radius-sm);
  color: var(--theme-label);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  opacity: 0.6;
}

.cyber-filter--on {
  border-color: var(--theme-border);
  color: var(--theme-text);
  opacity: 1;
}

.cyber-filter:hover {
  background: var(--theme-hover);
}

.cyber-filter__icon {
  width: 14px;
  text-align: center;
}

.cyber-filter__count {
  color: var(--theme-meta);
}

.cyber-filter__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--state-inactive);
}

.cyber-filter__dot--ongoing {
  background: var(--theme-accent);
}

/* Phone width: the filter and marker style buttons are touch targets, 40px tall at least */
@media (max-width: 600px) {
  .cyber-filter {
    min-height: 40px;
  }
}

/* Up to 480px styles.css moves #sidebar-toggle to the bottom centre (10px up, 28px tall),
   so the time filter bar sits above it instead of under it */
@media (max-width: 480px) {
  body.cyber-mode #filter-bar {
    bottom: 48px;
  }
}

.cyber-list {
  list-style: none;
}

.cyber-list__item[hidden] {
  display: none;
}

.cyber-list__row {
  display: grid;
  grid-template-columns: 22px 1fr;
  column-gap: 8px;
  align-items: baseline;
  width: 100%;
  padding: 6px 4px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--theme-border-faint);
  color: var(--theme-text);
  font-family: var(--font-mono);
  text-align: left;
  cursor: pointer;
}

.cyber-list__row:hover,
.cyber-list__row:focus-visible {
  background: var(--theme-hover);
}

.cyber-list__line {
  align-self: center;
}

.cyber-list__title {
  font-size: 11px;
  line-height: 1.35;
}

.cyber-list__meta {
  grid-column: 2;
  font-size: 10px;
  color: var(--theme-meta);
}

/* Cyber mode tabs: the operations panel replaces the generic layers, events and legend tabs */
body.cyber-mode .sidebar-tabs button[data-tab="events"],
body.cyber-mode .sidebar-tabs button[data-tab="legend"] {
  display: none;
}
