/* ═══════════════════════════════════════════════════
   SOTW Answer Visualization
   Animated map overlays for agent answers
   ═══════════════════════════════════════════════════ */

/* ── Overlay controls ──────────────────────────── */
.viz-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.viz-overlay-visible {
  opacity: 1;
  transform: translateY(0);
}

.viz-overlay-dismissing {
  opacity: 0;
  transform: translateY(-8px);
}

.viz-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-data);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent);
  background: rgba(6, 182, 212, 0.06);
  border: 1px solid rgba(6, 182, 212, 0.2);
  padding: 5px 12px;
  border-radius: 4px;
  backdrop-filter: blur(6px);
}

.viz-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: vizBadgeDotPulse 2s ease-in-out infinite;
}

@keyframes vizBadgeDotPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px var(--accent); }
  50% { opacity: 0.3; box-shadow: 0 0 0 var(--accent); }
}

.viz-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(6, 10, 16, 0.88);
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
  transition: all 0.2s ease;
  backdrop-filter: blur(6px);
}

.viz-close:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(6, 182, 212, 0.12);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.15);
  transform: scale(1.05);
}

.viz-close:active {
  transform: scale(0.95);
}

/* ── Highlight markers ─────────────────────────── */
.viz-highlight {
  position: relative;
  width: 48px;
  height: 48px;
  animation: vizHighlightIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  opacity: 0;
  will-change: transform, opacity;
}

@keyframes vizHighlightIn {
  from { opacity: 0; transform: scale(0.2); }
  to { opacity: 1; transform: scale(1); }
}

.viz-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px solid;
  transform: translate(-50%, -50%);
  opacity: 0;
  will-change: width, height, opacity;
}

.viz-ring-1 {
  animation: vizRingExpand 3s ease-out infinite;
}

.viz-ring-2 {
  animation: vizRingExpand 3s ease-out 1s infinite;
}

.viz-ring-3 {
  animation: vizRingExpand 3s ease-out 2s infinite;
}

@keyframes vizRingExpand {
  0% { width: 14px; height: 14px; opacity: 0.7; border-width: 2px; }
  70% { opacity: 0.15; }
  100% { width: 70px; height: 70px; opacity: 0; border-width: 0.5px; }
}

.viz-core {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 14px currentColor, 0 0 28px currentColor;
  border: 2px solid rgba(255,255,255,0.7);
  animation: vizCorePulse 2s ease-in-out infinite;
}

@keyframes vizCorePulse {
  0%, 100% { box-shadow: 0 0 14px currentColor, 0 0 28px currentColor; }
  50% { box-shadow: 0 0 8px currentColor, 0 0 16px currentColor; }
}

.viz-label {
  position: absolute;
  top: calc(50% + 22px);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  color: #eae8e3;
  white-space: nowrap;
  text-shadow: 0 1px 6px rgba(0,0,0,0.95), 0 0 12px rgba(0,0,0,0.8);
  letter-spacing: 0.06em;
  pointer-events: none;
  text-transform: uppercase;
}

/* ── Insight cards (via popup) ─────────────────── */
.viz-popup .maplibregl-popup-content {
  background: transparent !important;
  padding: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}

.viz-popup .maplibregl-popup-tip {
  display: none !important;
}

.viz-card {
  position: relative;
  width: 220px;
  background: rgba(6, 10, 16, 0.93);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 6px;
  padding: 10px 14px 10px 16px;
  backdrop-filter: blur(12px);
  animation: vizCardIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  opacity: 0;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.viz-card:hover {
  border-color: rgba(255,255,255,0.12);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

@keyframes vizCardIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.viz-card-accent {
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  border-radius: 6px 0 0 6px;
  box-shadow: 2px 0 8px rgba(var(--accent-rgb, 6,182,212), 0.15);
}

.viz-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.viz-card-sev {
  font-family: var(--font-data);
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  padding: 1px 5px;
  border: 1px solid;
  border-radius: 2px;
  opacity: 0.9;
}

.viz-card-name {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  color: #eae8e3;
  text-transform: capitalize;
}

.viz-card-detail {
  font-size: 0.65rem;
  color: #9299a5;
  line-height: 1.55;
  max-height: 4.7em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* ── Mobile responsive ─────────────────────────── */
@media (max-width: 900px) {
  .viz-card {
    width: 170px;
    padding: 8px 10px 8px 14px;
  }
  .viz-card-detail { font-size: 0.55rem; }
  .viz-card-name { font-size: 0.6rem; }
  .viz-label { font-size: 0.55rem; }
  .viz-highlight { width: 40px; height: 40px; }

  @keyframes vizRingExpand {
    0% { width: 12px; height: 12px; opacity: 0.7; border-width: 2px; }
    70% { opacity: 0.15; }
    100% { width: 55px; height: 55px; opacity: 0; border-width: 0.5px; }
  }
}

@media (max-width: 480px) {
  .viz-card { width: 150px; }
  .viz-badge { font-size: 0.5rem; padding: 4px 8px; }
}

/* ── Mobile Insight Sheet ─────────────────── */
.viz-mobile-sheet {
  position: relative;
  background: linear-gradient(180deg, rgba(6,10,16,0.98) 0%, rgba(6,10,16,0.95) 100%);
  border-top: 1px solid rgba(6,182,212,0.2);
  border-bottom: 1px solid rgba(6,182,212,0.1);
  padding: 10px 12px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease;
  z-index: 10;
}
.viz-mobile-sheet-visible {
  max-height: 300px;
  overflow-y: auto;
  opacity: 1;
  padding: 10px 12px;
}

.viz-mobile-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.viz-mobile-sheet-title {
  font-family: 'Space Mono', monospace;
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-transform: uppercase;
}

.viz-mobile-sheet-count {
  font-family: 'Space Mono', monospace;
  font-size: 0.55rem;
  color: var(--muted);
  background: rgba(6,182,212,0.1);
  padding: 2px 6px;
  border-radius: 3px;
}

.viz-mobile-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  opacity: 0;
  transform: translateX(-10px);
  animation: mobileItemIn 0.3s ease forwards;
}
.viz-mobile-item:last-child { border-bottom: none; }
.viz-mobile-item:active { background: rgba(6,182,212,0.05); }

@keyframes mobileItemIn {
  to { opacity: 1; transform: translateX(0); }
}

.viz-mobile-item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}

.viz-mobile-item-body {
  flex: 1;
  min-width: 0;
}

.viz-mobile-item-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.viz-mobile-item-name {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  color: #e0e6ef;
  text-transform: capitalize;
}

.viz-mobile-item-sev {
  font-family: 'Space Mono', monospace;
  font-size: 0.45rem;
  letter-spacing: 0.08em;
  padding: 1px 5px;
  border: 1px solid;
  border-radius: 3px;
}

.viz-mobile-item-detail {
  font-size: 0.65rem;
  line-height: 1.5;
  color: #8a919c;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Tap hint */
.viz-mobile-item::after {
  content: '↗';
  font-size: 0.6rem;
  color: var(--muted);
  margin-top: 4px;
  opacity: 0.4;
}
