/* ═══════════════════════════════════════════════════════════════════════════
   DI VPN — globe + extension page
   Loaded by resources/views/frontend/extension.blade.php
   ═══════════════════════════════════════════════════════════════════════════ */

/* The stage owns the positioning context for the toolbar and the legend. */
.globe-stage {
  position: relative;
  width: 100%;
}

.di-globe {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  max-height: 640px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.di-globe svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  outline: none;
  opacity: 0;
  transition: opacity .6s ease;
}

.di-globe.is-ready svg { opacity: 1; }
.di-globe.is-dragging svg { cursor: grabbing; }
.di-globe.is-hot svg { cursor: pointer; }

.di-globe svg:focus-visible { filter: drop-shadow(0 0 12px rgba(34, 211, 238, .45)); }

/* ── countries ──────────────────────────────────────────────────────────── */

.dg-country {
  fill: #0f1c33;
  stroke: rgba(120, 160, 210, .30);
  stroke-width: .6;
  stroke-linejoin: round;
  transition: fill .45s ease, stroke .45s ease;
}

.dg-country.is-border {
  fill: #2c3f63;
  stroke: rgba(125, 211, 252, .5);
  stroke-width: .8;
}

.dg-country.is-home {
  fill: #2ea8e0;
  stroke: #bfe9ff;
  stroke-width: 1.2;
}

.dg-country.has-server {
  fill: #164e63;
  stroke: rgba(103, 232, 249, .9);
}

.dg-country.is-hover,
.dg-country:hover {
  fill: #1e3a5f;
  stroke: rgba(148, 197, 255, .9);
}

/* ── arcs ───────────────────────────────────────────────────────────────── */

.dg-arc {
  stroke: rgba(34, 211, 238, .34);
  stroke-width: .9;
  stroke-dasharray: 3 4;
  animation: dg-dash 2.4s linear infinite;
}

@keyframes dg-dash { to { stroke-dashoffset: -14; } }

/* ── pins ───────────────────────────────────────────────────────────────── */

.dg-pin { cursor: pointer; }

.dg-pin-halo {
  opacity: .28;
  animation: dg-pulse 2.2s ease-out infinite;
  transform-origin: center;
}

@keyframes dg-pulse {
  0%   { transform: scale(.35); opacity: .55; }
  70%  { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}

.dg-pin-core { stroke: rgba(255, 255, 255, .9); stroke-width: .7; }
.dg-pin-ring { opacity: .55; }

.dg-pin.is-hover .dg-pin-halo,
.dg-pin.is-active .dg-pin-halo { opacity: .5; }

.dg-pin.is-hover .dg-pin-core,
.dg-pin.is-active .dg-pin-core { r: 5.6; }

.dg-pin.is-active .dg-pin-ring {
  opacity: 1;
  stroke: #67e8f9;
  stroke-width: 1.8;
  animation: dg-ring 1.6s ease-in-out infinite;
}

@keyframes dg-ring {
  0%, 100% { r: 7; opacity: 1; }
  50%      { r: 13; opacity: .25; }
}

.dg-pin.is-active .dg-pin-halo { animation-duration: 1.4s; }

/* ── tooltip ────────────────────────────────────────────────────────────── */

.dg-tip-body {
  padding: 12px 14px;
  color: #e2e8f0;
  font-family: Inter, system-ui, sans-serif;
  font-size: 12px;
  line-height: 1.45;
}

.dg-tip-title {
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dg-tip-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #94a3b8;
}

.dg-tip-coords {
  margin-top: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  color: #64748b;
}

.dg-tip-hint {
  margin-top: 5px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #22d3ee;
}

/* ── legend ─────────────────────────────────────────────────────────────── */

.dg-legend {
  position: absolute;
  left: 0;
  bottom: 4px;
  /* stop short of the toolbar so the two never overlap */
  right: 250px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(8, 15, 30, .72);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(148, 163, 184, .16);
  font-size: 12px;
  color: #cbd5e1;
  max-width: 100%;
}

.dg-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 7px;
  vertical-align: -1px;
}

.dg-legend .lg-home i   { background: #0e7490; box-shadow: 0 0 0 1.5px #22d3ee; }
.dg-legend .lg-border i { background: #13305c; box-shadow: 0 0 0 1.5px #60a5fa; }
.dg-legend .lg-server i { background: #22d3ee; border-radius: 50%; }
.dg-legend .lg-other i  { background: #0f1c33; box-shadow: 0 0 0 1px rgba(120, 160, 210, .45); }

.dg-legend strong { color: #fff; font-weight: 600; }

/* ── loading ────────────────────────────────────────────────────────────── */

.di-globe.is-loading::after,
.di-globe.is-ready.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(34, 211, 238, .2);
  border-top-color: #22d3ee;
  animation: dg-spin .8s linear infinite;
}

@keyframes dg-spin { to { transform: rotate(360deg); } }

/* ── toolbar over the globe ─────────────────────────────────────────────── */

.globe-toolbar {
  position: absolute;
  bottom: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
  z-index: 4;
}

.globe-toolbar button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
  background: rgba(8, 15, 30, .72);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(148, 163, 184, .18);
  cursor: pointer;
  transition: all .2s ease;
  white-space: nowrap;
}

.globe-toolbar button:hover {
  color: #fff;
  border-color: rgba(34, 211, 238, .55);
  background: rgba(14, 116, 144, .35);
}

.globe-toolbar button.is-on {
  color: #041016;
  background: linear-gradient(135deg, #22d3ee, #2563eb);
  border-color: transparent;
}

@media (max-width: 900px) {
  .dg-legend { right: 0; bottom: 52px; }
  .globe-toolbar { bottom: 10px; right: 10px; }
}

@media (max-width: 640px) {
  .dg-legend { font-size: 10.5px; padding: 9px 11px; gap: 6px 10px; }
  .globe-toolbar button span { display: none; }
  .globe-toolbar button { padding: 7px 9px; }
}

/* ── the visitor's own marker ───────────────────────────────────────────── */

.dg-home-pin { pointer-events: none; }
.dg-home-halo { fill: #22d3ee; opacity: .3; animation: dg-home-pulse 2.4s ease-out infinite; transform-origin: center; }
@keyframes dg-home-pulse {
  0%   { transform: scale(.4); opacity: .55; }
  70%  { transform: scale(1.7); opacity: 0; }
  100% { transform: scale(1.7); opacity: 0; }
}
.dg-home-ring { fill: none; stroke: #22d3ee; stroke-width: 1.4; opacity: .9; }
.dg-home-dot { fill: #fff; stroke: #22d3ee; stroke-width: 1.4; }
.dg-home-text {
  fill: #a5f3fc; font: 700 10px Inter, system-ui, sans-serif; letter-spacing: .06em;
  text-transform: uppercase; paint-order: stroke; stroke: rgba(4, 8, 17, .85); stroke-width: 2.6px;
}

/* ── full screen modal ──────────────────────────────────────────────────── */

.globe-modal-stage {
  position: relative; flex: 1 1 auto; min-height: 0; padding: 12px 26px;
  display: flex; align-items: center; justify-content: center;
}
.globe-modal-stage .di-globe {
  width: 100%; max-width: 1500px; height: auto; aspect-ratio: 2 / 1; max-height: none;
}

/* ── fullscreen node details ────────────────────────────────────────────────
   Rendered inside the modal stage: the hero inspector is covered by the
   overlay, so node clicks need their own panel in the fullscreen view. */
.globe-modal-detail {
  position: absolute; z-index: 7; top: 88px; right: 22px; width: 306px;
  max-height: calc(100% - 36px); overflow-y: auto;
  padding: 18px 18px 16px; border-radius: 16px;
  background: rgba(9, 13, 26, .9);
  border: 1px solid rgba(120, 160, 255, .28);
  box-shadow: 0 26px 60px rgba(0, 0, 0, .55);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  animation: gdFade .18s ease both;
}
.globe-modal-detail-x {
  position: absolute; top: 10px; right: 10px; width: 28px; height: 28px;
  display: grid; place-items: center; border-radius: 8px; font-size: 13px;
  color: #93a4c8; background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .1); transition: .18s;
}
.globe-modal-detail-x:hover { color: #fff; background: rgba(255, 255, 255, .14); }
@keyframes gdFade { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@media (max-width: 860px) {
  .globe-modal-detail { position: static; width: auto; margin: 0 0 12px; max-height: 40%; }
}

/* ── node count badge (several nodes in one city = one pin) ──────────────── */

.dg-pin-count {
    fill: #7dd3fc;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 9px; font-weight: 700;
    paint-order: stroke; stroke: rgba(4, 8, 17, .9); stroke-width: 2.4px;
    pointer-events: none;
}

/* ── home-only view ──────────────────────────────────────────────────────────
   The visitor's country and the closest neighbours are the point of the map.
   Everything else drops back so the red wash on the two stays readable. */

/* The red wash is a separate layer at 15% — see .dg-wash. */
.dg-country.is-offmap {
    fill: #0e1728;
    stroke: rgba(125, 190, 250, .16);
    opacity: .75;
}

/* A single 15% red layer over the visitor's country and its neighbours. */
.dg-wash {
    fill: rgba(255, 42, 67, .15);
    stroke: none;
    pointer-events: none;
}
.dg-wash.is-border { fill: rgba(255, 42, 67, .15); }

/* flat map: marker sizes are in map units, so the text has to be small too */
.di-globe.is-flat .dg-home-text {
    font-size: 7px;
    font-weight: 800;
    fill: #fff;
    paint-order: stroke; stroke: rgba(4, 8, 17, .9); stroke-width: 2px;
}
.di-globe.is-flat .dg-pin-count { font-size: 5.5px; }

/* ── hover card on the flat map ──────────────────────────────────────────── */

.dg-tip-card {
    position: absolute; z-index: 6; display: none;
    min-width: 158px; max-width: 230px; padding: 11px 13px;
    border-radius: 13px; pointer-events: none;
    background: rgba(8, 13, 24, .95);
    border: 1px solid rgba(120, 170, 255, .28);
    box-shadow: 0 18px 40px rgba(0, 0, 0, .55);
    font-size: 12px; color: #e2e8f0;
}
.dg-tip-card.is-on { display: block; }
.dg-tip-card .dg-tip-title { font-size: 12.5px; font-weight: 800; color: #fff; }
.dg-tip-card .dg-tip-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-top: 5px; color: #93a4c8;
}
.dg-tip-card .dg-tip-coords {
    margin-top: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10.5px; color: #64748b;
}
.dg-tip-card .dg-tip-hint { margin-top: 6px; font-size: 10px; color: #475569; }


@media (max-width: 640px) {
    .dg-legend {
        display:flex; flex-wrap:nowrap; align-items:center;
        gap:7px 12px; max-width:calc(100% - 12px);
        overflow-x:auto; overflow-y:hidden; white-space:nowrap;
        scrollbar-width:none; -webkit-overflow-scrolling:touch;
    }
    .dg-legend::-webkit-scrollbar { display:none; }
    .dg-legend > span { flex:0 0 auto; }
}


@media (max-width:640px) {
    .di-globe.is-flat .dg-home-text,
    .di-globe.is-flat .dg-home-pin text,
    .dg-home-text { font-size:3.5px !important; stroke-width:1px !important; }
    .di-globe.is-flat .dg-pin-count { font-size:2.75px !important; }
    .di-globe .dg-country { stroke-width:.3px !important; }
    .di-globe .dg-country.is-border { stroke-width:.4px !important; }
    .di-globe .dg-country.is-home { stroke-width:.6px !important; }
    .di-globe .dg-home-halo { r:5px !important; }
    .di-globe .dg-home-ring { r:4px !important; stroke-width:.7px !important; }
    .di-globe .dg-home-dot { r:2px !important; stroke-width:.7px !important; }
    .di-globe .dg-pin-halo { r:8px !important; }
    .di-globe .dg-pin-core { r:2.1px !important; }
    .di-globe .dg-pin-ring { r:4px !important; stroke-width:.6px !important; }
    .di-globe .dg-pin-count { font-size:2.75px !important; }
}
