/* ============================================================
   OPS COMMAND CENTER — live field-unit radar markers
   These elements are created by s5-map.js (MapLibre HTML markers),
   so they live OUTSIDE Blazor scoped CSS and must be styled globally.
   ============================================================ */

.u-marker {
    /* Phase palette — one variable drives every layer of the signature. */
    --u: #22c55e;               /* ONLINE / idle (green) */
    --u-glow: 34, 197, 94;
    position: relative;
    width: 0;                    /* anchor is the geometric center */
    height: 0;
    pointer-events: none;        /* only the core opts back in */
    z-index: 1;
}

.u-marker[data-phase="EN_ROUTE"] { --u: #4085f5; --u-glow: 64, 133, 245; }
.u-marker[data-phase="ON_JOB"]   { --u: #f3c40f; --u-glow: 243, 196, 15; }
.u-marker[data-phase="ONLINE"]   { --u: #22c55e; --u-glow: 34, 197, 94; }

/* ── Sonar rings: three expanding shells, staggered ── */
.u-rings,
.u-sweep,
.u-core,
.u-tag {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -50%);
}

.u-ring {
    position: absolute;
    left: 0;
    top: 0;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    border-radius: 50%;
    border: 1.5px solid rgba(var(--u-glow), 0.7);
    box-shadow: 0 0 8px rgba(var(--u-glow), 0.35), inset 0 0 6px rgba(var(--u-glow), 0.25);
    opacity: 0;
    animation: u-sonar 2.8s cubic-bezier(0.2, 0.6, 0.3, 1) infinite;
}

.u-ring:nth-child(2) { animation-delay: 0.9s; }
.u-ring:nth-child(3) { animation-delay: 1.8s; }

@keyframes u-sonar {
    0%   { opacity: 0.9; transform: scale(0.35); }
    70%  { opacity: 0.12; }
    100% { opacity: 0; transform: scale(3.6); }
}

/* ── Rotating radar sweep — only for units reporting LIVE GPS ── */
.u-sweep {
    width: 76px;
    height: 76px;
    margin: 0;
    border-radius: 50%;
    background: conic-gradient(from 0deg,
        rgba(var(--u-glow), 0) 0deg,
        rgba(var(--u-glow), 0) 300deg,
        rgba(var(--u-glow), 0.28) 352deg,
        rgba(var(--u-glow), 0.55) 360deg);
    -webkit-mask: radial-gradient(circle, transparent 5px, #000 6px, #000 100%);
    mask: radial-gradient(circle, transparent 5px, #000 6px, #000 100%);
    opacity: 0;
    animation: u-sweep 3.6s linear infinite;
}

.u-marker[data-live="1"] .u-sweep { opacity: 1; }

@keyframes u-sweep {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ── Core: the unit dot itself (the clickable hit) ── */
.u-core {
    width: 26px;
    height: 26px;
    margin: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--u) 88%, #fff), var(--u) 62%, color-mix(in srgb, var(--u) 70%, #000));
    border: 1.5px solid color-mix(in srgb, var(--u) 55%, #fff 45%);
    box-shadow:
        0 0 0 2px rgba(8, 9, 14, 0.55),
        0 0 14px 2px rgba(var(--u-glow), 0.65),
        0 2px 6px rgba(0, 0, 0, 0.6);
    pointer-events: auto;
    animation: u-breathe 2.8s ease-in-out infinite;
    transition: transform 0.12s ease;
}

.u-marker[data-live="1"] .u-core { animation: u-breathe-live 1.5s ease-in-out infinite; }
.u-core:hover { transform: translate(-50%, -50%) scale(1.12); }

.u-core-glyph {
    font: 800 10px/1 ui-monospace, "SFMono-Regular", Menlo, monospace;
    letter-spacing: 0.02em;
    color: #05070c;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
    user-select: none;
}

@keyframes u-breathe {
    0%, 100% { box-shadow: 0 0 0 2px rgba(8,9,14,0.55), 0 0 10px 1px rgba(var(--u-glow), 0.45), 0 2px 6px rgba(0,0,0,0.6); }
    50%      { box-shadow: 0 0 0 2px rgba(8,9,14,0.55), 0 0 18px 3px rgba(var(--u-glow), 0.8),  0 2px 6px rgba(0,0,0,0.6); }
}
@keyframes u-breathe-live {
    0%, 100% { box-shadow: 0 0 0 2px rgba(8,9,14,0.55), 0 0 12px 2px rgba(var(--u-glow), 0.6), 0 2px 6px rgba(0,0,0,0.6); }
    50%      { box-shadow: 0 0 0 2px rgba(8,9,14,0.55), 0 0 26px 5px rgba(var(--u-glow), 0.95), 0 2px 6px rgba(0,0,0,0.6); }
}

/* ── Callsign tag under the unit ── */
.u-tag {
    top: 20px;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 2px 7px;
    white-space: nowrap;
    border-radius: 999px;
    background: rgba(8, 10, 16, 0.82);
    border: 1px solid rgba(var(--u-glow), 0.5);
    backdrop-filter: blur(3px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.u-tag-name {
    font: 800 10px/1.3 ui-monospace, "SFMono-Regular", Menlo, monospace;
    letter-spacing: 0.03em;
    color: #eaf2ff;
    text-transform: uppercase;
}

.u-tag-wo {
    font: 700 9.5px/1.3 ui-monospace, "SFMono-Regular", Menlo, monospace;
    color: var(--u);
    padding-left: 5px;
    border-left: 1px solid rgba(var(--u-glow), 0.4);
}

/* ── Roster "focus" ping ── */
.u-marker.u-ping .u-core { animation: u-ping 0.9s ease-out 2; }
@keyframes u-ping {
    0%   { transform: translate(-50%, -50%) scale(1); }
    30%  { transform: translate(-50%, -50%) scale(1.6); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .u-ring, .u-sweep, .u-core, .u-marker.u-ping .u-core { animation: none !important; }
    .u-marker[data-live="1"] .u-sweep { opacity: 0.5; }
    .u-ring { opacity: 0.35; }
}
