/*
 * Shock Mode — Premium Map (LIGHT). Scoped to .zspm; touches nothing else.
 * Typography: Tajawal only, no synthesis, no tracking, tabular numerals.
 */

.zspm {
  --zspm-font: 'Tajawal', sans-serif;
  --zspm-ink: #141518;
  --zspm-ink-2: #4b5059;
  --zspm-ink-3: #7b818b;
  --zspm-card: #ffffff;
  --zspm-card-line: rgba(20, 21, 24, 0.07);
  --zspm-warm: #f2a23a;
  --zspm-warm-deep: #d9861c;
  --zspm-stable: #15803d;
  --zspm-watch: #f59e0b;
  --zspm-shock: #e5484d;
  --zspm-closed: #7c8591;
  --zspm-partial: #c5cad3;
  --zspm-unmeasured: #8a9099;
  --zspm-ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  container-type: inline-size;
  position: relative;
  margin: 0;
  width: 100%;
  font-family: var(--zspm-font);
  font-synthesis: none;
  letter-spacing: 0;
  color: var(--zspm-ink);
  -webkit-font-smoothing: antialiased;
}

.zspm *,
.zspm *::before,
.zspm *::after {
  box-sizing: border-box;
  letter-spacing: 0;
}

.zspm__stage {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 22px;
  background: #f3f2ef;
  box-shadow:
    inset 0 0 0 1px rgba(20, 21, 24, 0.05),
    0 1px 2px rgba(20, 21, 24, 0.04),
    0 24px 60px -36px rgba(20, 21, 24, 0.28);
  isolation: isolate;
}

.zspm__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ── background ─────────────────────────────────────────── */

.zspm__orbits ellipse,
.zspm__orbits path {
  fill: none;
  stroke: rgba(105, 110, 118, 0.26);
  stroke-width: 1;
  stroke-dasharray: 1 7;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.zspm__orbits path {
  stroke: rgba(105, 110, 118, 0.18);
}

.zspm__star {
  opacity: 0.9;
}

/* ── land ───────────────────────────────────────────────── */

.zspm__land path {
  stroke: none;
}

.zspm__region {
  fill: transparent;
  cursor: pointer;
  transition: fill 260ms var(--zspm-ease), opacity 260ms var(--zspm-ease);
}
.zspm__region.is-hovered {
  fill: rgba(255, 255, 255, 0.05);
}
.zspm__region.is-dimmed {
  fill: rgba(243, 242, 239, 0.17);
}
.zspm__region.is-selected {
  /* fill + localized pearl haze via attributes (gradient / filter ids are per-instance) */
  opacity: 1;
  stroke: rgba(255, 252, 248, 0.55);
  stroke-width: 1px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.zspm__borders {
  fill: none;
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 0.55;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
/* ~20% brighter country borders, clipped to selected region only */
.zspm__borders--selected {
  stroke: rgba(255, 255, 255, 0.4);
  stroke-width: 0.68;
}

.zspm__coast path {
  fill: none;
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 0.6;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
.zspm__coast path.is-selected {
  stroke: rgba(255, 252, 248, 0.58);
  stroke-width: 0.95;
}

/* ── routes — dual contrast: dark under-stroke + pearl/amber core ── */

.zspm__routes {
  pointer-events: none;
}

.zspm__route {
  opacity: 1;
  transition: opacity 320ms var(--zspm-ease);
}

.zspm__route path,
.zspm__route line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* LAYER A — dark under-stroke (readable on pearl ocean) */
.zspm__route-under {
  stroke: rgba(24, 27, 32, 0.18);
  stroke-width: 1.75px;
  opacity: 1;
  vector-effect: non-scaling-stroke;
}
.zspm__route--elevated .zspm__route-under {
  stroke: rgba(24, 27, 32, 0.2);
}

/* LAYER B — pearl core (readable on charcoal land; visible in static frames) */
.zspm__route-core {
  stroke: rgba(252, 250, 246, 0.82);
  stroke-width: 1.05px;
  opacity: 1;
  vector-effect: non-scaling-stroke;
}
.zspm__route--elevated .zspm__route-core {
  stroke: #d99a3d;
  opacity: 0.96;
  stroke-width: 1.08px;
}

/* Selected / connected — slightly brighter pearl, still crisp */
.zspm--has-selection .zspm__route.is-focused.zspm__route--cool .zspm__route-core {
  stroke: rgba(255, 253, 248, 0.94);
  stroke-width: 1.12px;
}
.zspm--has-selection .zspm__route.is-focused.zspm__route--elevated .zspm__route-core {
  stroke-width: 1.15px;
  opacity: 1;
}

/* Unrelated — remain clearly visible in static screenshots */
.zspm--has-selection .zspm__route.is-muted .zspm__route-core {
  opacity: 0.82;
}
.zspm--has-selection .zspm__route.is-muted .zspm__route-under {
  opacity: 0.95;
}

/* Glow removed — contrast comes from under-stroke + pearl core */
.zspm__route-glow,
.zspm__route-base {
  display: none !important;
}

.zspm__route-motion {
  fill: none;
  stroke: none;
  pointer-events: none;
}

/* Travel signal — short pearl segment + tip (SMIL animateMotion) */
.zspm__route-signal {
  opacity: 0;
}
.zspm__route-segment {
  stroke: rgba(255, 253, 248, 0.92);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}
.zspm__route--elevated .zspm__route-segment {
  stroke: rgba(232, 196, 120, 0.9);
  stroke-width: 1.05px;
}
.zspm__route-signal-halo {
  fill: rgba(255, 253, 248, 0.18);
  stroke: none;
}
.zspm__route-signal-core {
  fill: #fffdf8;
  stroke: rgba(20, 21, 24, 0.16);
  stroke-width: 0.45;
}
.zspm__route--elevated .zspm__route-signal-halo {
  fill: rgba(217, 154, 61, 0.18);
}
.zspm__route--elevated .zspm__route-signal-core {
  fill: #fff1d6;
  stroke: rgba(100, 60, 15, 0.2);
}

.zspm__route-arrive {
  fill: none;
  stroke: rgba(255, 253, 248, 0.5);
  stroke-width: 1;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}
.zspm__route--elevated .zspm__route-arrive {
  stroke: rgba(217, 154, 61, 0.5);
}

/* ── nodes — graphite ring + pearl core ─────────────────── */

.zspm__nodes {
  pointer-events: none;
}
.zspm__node {
  transition: opacity 300ms var(--zspm-ease);
}
.zspm--has-selection .zspm__node.is-muted {
  opacity: 0.86;
}
.zspm__node-halo {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0.45;
}
.zspm__node-bloom {
  display: none;
}
.zspm__node-ring {
  fill: rgba(32, 34, 38, 0.55);
  stroke: rgba(48, 52, 58, 0.9);
  stroke-width: 1.15;
  vector-effect: non-scaling-stroke;
  transform-box: fill-box;
  transform-origin: center;
}
.zspm__node-core {
  fill: #fffdf8;
  stroke: rgba(20, 21, 24, 0.2);
  stroke-width: 0.7;
  vector-effect: non-scaling-stroke;
}
.zspm__node.is-selected .zspm__node-ring {
  stroke: rgba(52, 56, 62, 0.95);
  stroke-width: 1.3;
  fill: rgba(28, 30, 34, 0.55);
}
.zspm__node.is-selected .zspm__node-core {
  fill: #fffef9;
  stroke: rgba(20, 21, 24, 0.22);
}
.zspm__node.is-selected .zspm__node-halo {
  opacity: 0.5;
}
.zspm__node.is-unmeasured .zspm__node-core {
  fill: #e4e2dc;
}
.zspm__node.is-unmeasured .zspm__node-ring {
  stroke: rgba(80, 84, 90, 0.55);
  stroke-dasharray: 2 2.5;
}

.zspm__leaders line {
  stroke: rgba(20, 21, 24, 0.22);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.zspm__leaders circle {
  fill: rgba(20, 21, 24, 0.35);
}
.zspm__leaders .is-selected line {
  stroke: rgba(90, 96, 106, 0.55);
}
.zspm__leaders .is-selected circle {
  fill: rgba(90, 96, 106, 0.7);
}

/* ── callouts ───────────────────────────────────────────── */

.zspm__callouts {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.zspm-callout {
  --zspm-dot: var(--zspm-stable);
  position: absolute;
  z-index: 1;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(2px, 0.35cqw, 6px);
  min-width: clamp(104px, 11.4cqw, 186px);
  padding: clamp(7px, 0.85cqw, 14px) clamp(10px, 1.15cqw, 18px) clamp(7px, 0.8cqw, 13px);
  margin: 0;
  border: 1px solid var(--zspm-card-line);
  border-radius: clamp(10px, 0.95cqw, 15px);
  background: #ffffff;
  box-shadow:
    0 1px 2px rgba(20, 21, 24, 0.05),
    0 12px 30px -12px rgba(20, 21, 24, 0.3);
  color: var(--zspm-ink);
  font: inherit;
  text-align: start;
  cursor: pointer;
  transition:
    box-shadow 240ms var(--zspm-ease),
    border-color 240ms var(--zspm-ease),
    opacity 240ms var(--zspm-ease),
    translate 240ms var(--zspm-ease);
}
.zspm-callout:hover {
  box-shadow:
    0 1px 1px rgba(20, 21, 24, 0.05),
    0 16px 34px -14px rgba(20, 21, 24, 0.38);
}
.zspm-callout:focus {
  outline: none;
}
.zspm-callout:focus-visible {
  outline: 2px solid rgba(90, 96, 106, 0.45);
  outline-offset: 2px;
}
.zspm-callout.is-selected {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(80, 86, 96, 0.38);
  box-shadow:
    0 8px 24px rgba(20, 24, 30, 0.09),
    inset 0 0 0 1px rgba(255, 255, 255, 0.65);
  outline: none;
}
.zspm-callout.is-selected:focus,
.zspm-callout.is-selected:focus-visible {
  outline: none;
  box-shadow:
    0 8px 24px rgba(20, 24, 30, 0.09),
    inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}
/* Tiny pearl/graphite active indicator — not a browser focus ring */
.zspm-callout.is-selected .zspm-callout__name::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-inline-end: 6px;
  vertical-align: 0.15em;
  border-radius: 999px;
  background: #fffdf8;
  box-shadow:
    0 0 0 1px rgba(48, 52, 58, 0.7),
    0 0 0 2.5px rgba(255, 253, 248, 0.35);
}
.zspm-callout.is-muted {
  box-shadow:
    0 1px 2px rgba(20, 21, 24, 0.04),
    0 8px 22px -14px rgba(20, 21, 24, 0.22);
}
.zspm-callout.is-muted .zspm-callout__name,
.zspm-callout.is-muted .zspm-callout__score {
  color: var(--zspm-ink-2);
}

.zspm-callout--stable { --zspm-dot: var(--zspm-stable); }
.zspm-callout--watch { --zspm-dot: var(--zspm-watch); }
.zspm-callout--shock { --zspm-dot: var(--zspm-shock); }
.zspm-callout--closed { --zspm-dot: var(--zspm-closed); }
.zspm-callout--partial { --zspm-dot: var(--zspm-partial); }
.zspm-callout--unmeasured { --zspm-dot: var(--zspm-unmeasured); }

.zspm-callout__head {
  display: flex;
  align-items: center;
  gap: clamp(5px, 0.5cqw, 8px);
  white-space: nowrap;
}
.zspm-callout__dot {
  flex: none;
  width: clamp(6px, 0.55cqw, 8px);
  height: clamp(6px, 0.55cqw, 8px);
  border-radius: 999px;
  background: var(--zspm-dot);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--zspm-dot) 16%, transparent);
}
/* PARTIAL — solid pearl/silver; never hollow / disabled */
.zspm-callout.is-partial .zspm-callout__dot {
  background: linear-gradient(145deg, #f7f8fa 0%, #c5cad3 72%, #aeb4be 100%);
  box-shadow:
    0 0 0 1px rgba(72, 78, 88, 0.38),
    0 0 0 3px rgba(197, 202, 211, 0.28);
}
/* UNAVAILABLE — solid slate, intentional */
.zspm-callout.is-unavailable .zspm-callout__dot {
  background: var(--zspm-unmeasured);
  box-shadow: 0 0 0 3px rgba(138, 144, 153, 0.16);
}
.zspm-callout__name {
  font-weight: 600;
  font-size: clamp(12px, 1.02cqw, 12.5px);
  line-height: 1.25;
  color: var(--zspm-ink);
}

.zspm-callout__body {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: clamp(8px, 1cqw, 16px);
  white-space: nowrap;
}
.zspm-callout__status {
  font-weight: 500;
  font-size: clamp(10.5px, 0.9cqw, 11px);
  line-height: 1.3;
  color: var(--zspm-ink-3);
}
.zspm-callout__score {
  font-weight: 600;
  font-size: clamp(17px, 1.55cqw, 19px);
  line-height: 1;
  color: var(--zspm-ink);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: 'tnum' 1, 'lnum' 1;
}
.zspm-callout__score small {
  margin-inline-start: 2px;
  font-size: 0.42em;
  font-weight: 600;
  color: var(--zspm-ink-3);
}
.zspm-callout.is-partial .zspm-callout__name,
.zspm-callout.is-unavailable .zspm-callout__name {
  color: var(--zspm-ink);
  font-weight: 600;
}
.zspm-callout.is-partial .zspm-callout__score {
  color: #5c636e;
  font-weight: 600;
  font-size: clamp(16px, 1.45cqw, 18px);
}
.zspm-callout.is-partial .zspm-callout__status {
  color: #7b818b;
  font-weight: 500;
}
.zspm-callout.is-unavailable .zspm-callout__status {
  color: #6b717a;
}
.zspm-callout.is-unavailable .zspm-callout__score {
  color: #7a8088;
  font-weight: 600;
  font-size: clamp(16px, 1.45cqw, 18px);
}
/* Coverage states stay full-opacity — never look disabled */
.zspm-callout.is-partial,
.zspm-callout.is-unavailable {
  opacity: 1;
}

/* ── legend ─────────────────────────────────────────────── */

.zspm-legend {
  position: absolute;
  left: 50%;
  bottom: clamp(10px, 3cqw, 38px);
  transform: translateX(-50%);
  z-index: 1;
  display: flex;
  align-items: center;
  gap: clamp(8px, 1cqw, 16px);
  padding: clamp(6px, 0.6cqw, 10px) clamp(12px, 1.4cqw, 22px);
  border: 1px solid var(--zspm-card-line);
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 10px 26px -16px rgba(20, 21, 24, 0.32);
  white-space: nowrap;
}
.zspm-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: clamp(10px, 0.85cqw, 13.5px);
  font-weight: 500;
  color: var(--zspm-ink-2);
}
.zspm-legend__dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}
.zspm-legend__item--high .zspm-legend__dot {
  background: var(--zspm-warm);
  box-shadow: 0 0 0 3px rgba(242, 162, 58, 0.18);
}
.zspm-legend__item--low .zspm-legend__dot {
  background: #8a9099;
}
.zspm-legend__bar {
  width: clamp(70px, 13cqw, 220px);
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, #c6cbd2 0%, #d9d3c9 45%, #f2a23a 100%);
}
.zspm[dir='rtl'] .zspm-legend__bar {
  background: linear-gradient(to left, #f2a23a 0%, #d9d3c9 55%, #c6cbd2 100%);
}

/* ── motion (CSS + SMIL; never under reduced motion) ─────── */

@media (prefers-reduced-motion: no-preference) {
  /* Travel packet fade — synced to animateMotion via same --zspm-dur / --zspm-delay */
  .zspm--animated .zspm__route-signal {
    animation: zspm-signal-fade var(--zspm-dur, 11s) linear var(--zspm-delay, 0s) infinite;
  }
  .zspm--has-selection .zspm--animated .zspm__route.is-focused .zspm__route-signal {
    /* slightly clearer packet when connected to selection */
    filter: brightness(1.08);
  }

  /* Arrival micro-pulse once per cycle near end of travel */
  .zspm--animated .zspm__route-arrive {
    animation: zspm-arrive var(--zspm-dur, 11s) ease-out var(--zspm-delay, 0s) infinite;
  }

  /* Node breathing — slow, desynced, max ~1.06 */
  .zspm--animated .zspm__node-halo {
    animation: zspm-breathe var(--zspm-node-dur, 4.8s) ease-in-out var(--zspm-node-delay, 0s) infinite;
  }
  .zspm--animated .zspm__node-ring {
    animation: zspm-ring-breathe var(--zspm-node-dur, 4.8s) ease-in-out var(--zspm-node-delay, 0s) infinite;
  }
  .zspm--animated .zspm__node.is-selected .zspm__node-halo {
    animation-duration: calc(var(--zspm-node-dur, 4.8s) * 0.92);
  }
  .zspm--animated .zspm__node.is-selected .zspm__node-ring {
    animation-name: zspm-ring-breathe-selected;
  }

  .zspm--animated .zspm__star {
    animation: zspm-twinkle 6.5s ease-in-out var(--zspm-delay, 0s) infinite;
  }
}

@keyframes zspm-signal-fade {
  0% {
    opacity: 0;
  }
  6% {
    opacity: var(--zspm-packet-peak, 0.74);
  }
  90% {
    opacity: calc(var(--zspm-packet-peak, 0.74) * 0.9);
  }
  100% {
    opacity: 0;
  }
}

@keyframes zspm-arrive {
  0%,
  86% {
    opacity: 0;
    transform: scale(0.55);
  }
  90% {
    opacity: 0.42;
  }
  96% {
    opacity: 0;
    transform: scale(1.45);
  }
  100% {
    opacity: 0;
    transform: scale(1.45);
  }
}

@keyframes zspm-breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.72;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.95;
  }
}

@keyframes zspm-ring-breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.04);
    opacity: 1;
  }
}

@keyframes zspm-ring-breathe-selected {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.95;
  }
  50% {
    transform: scale(1.06);
    opacity: 1;
  }
}

@keyframes zspm-twinkle {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 0.95;
  }
}

@media (prefers-reduced-motion: reduce) {
  .zspm *,
  .zspm *::before,
  .zspm *::after {
    animation: none !important;
  }
  .zspm__route-signal,
  .zspm__route-arrive {
    display: none !important;
  }
  .zspm__route-core {
    opacity: 0.85;
  }
}

/* ── narrow containers ──────────────────────────────────── */

@container (max-width: 760px) {
  .zspm__stage { border-radius: 16px; }
  .zspm-callout {
    min-width: 0;
    gap: 1px;
    padding: 4px 7px 5px;
    border-radius: 9px;
  }
  .zspm-callout__status { display: none; }
  .zspm-callout__name { font-size: 12px; font-weight: 600; }
  .zspm-callout__score { font-size: 16px; font-weight: 600; }
  .zspm-callout.is-partial .zspm-callout__score,
  .zspm-callout.is-unavailable .zspm-callout__score { font-size: 16px; }
  .zspm-callout__body { justify-content: flex-start; }
  .zspm-legend { bottom: 8px; padding: 4px 10px; gap: 6px; }
  .zspm-legend__item { font-size: 10.5px; }
  .zspm-legend__bar { width: 54px; height: 4px; }
}

/* list is only used on narrow containers */
.zspm__list {
  display: none;
}

@container (max-width: 560px) {
  .zspm__callouts,
  .zspm__leaders {
    display: none;
  }
  .zspm__stage {
    border-radius: 14px;
  }
  .zspm-legend {
    position: static;
    transform: none;
    width: fit-content;
    margin: 10px auto 0;
    padding: 5px 12px;
    gap: 8px;
  }
  .zspm-legend__item { font-size: 11px; }
  .zspm-legend__bar { width: 72px; height: 4px; }
  .zspm__list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
  }
  .zspm__list .zspm-callout {
    position: relative;
    min-width: 0;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 12px;
  }
  .zspm__list .zspm-callout__status { display: inline; font-size: 12px; }
  .zspm__list .zspm-callout__name { font-size: 13.5px; }
  .zspm__list .zspm-callout__score { font-size: 22px; }
  .zspm__list .zspm-callout__body { justify-content: space-between; }
}

