/* ========== Capability Risk Map – Dark Theme ========== */

body.map-page {
  background: #0a1628;
  color: #e0e6f0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ========== Map Container ========== */
.map-container {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  overflow: hidden;
}

.map-container svg {
  width: 100%;
  height: 100%;
  cursor: grab;
}

.map-container svg:active {
  cursor: grabbing;
}

/* ========== Country Geometry ========== */
.country {
  fill: #14253a;
  stroke: #1e3a5f;
  stroke-width: 0.5;
  stroke-opacity: 0.4;
  transition: fill 0.25s ease;
}

.country.has-deps {
  fill: #1a3050;
  cursor: pointer;
}

.country.has-deps:hover {
  fill: #254060;
}

.country.country-highlight {
  fill: #2a5070;
}

/* ========== Arcs ========== */
.arc-glow {
  fill: none;
  stroke-linecap: round;
  opacity: 0.3;
  filter: blur(4px);
  pointer-events: none;
}

.arc-line {
  fill: none;
  stroke-linecap: round;
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.arc-line.rag-R { stroke: var(--rag-red); }
.arc-line.rag-A { stroke: var(--rag-amber); }
.arc-line.rag-G, .arc-line.rag-D { stroke: var(--rag-green); }

.arc-glow.rag-R { stroke: var(--rag-red); }
.arc-glow.rag-A { stroke: var(--rag-amber); }
.arc-glow.rag-G, .arc-glow.rag-D { stroke: var(--rag-green); }

/* Dim state when hovering another arc */
.map-container.has-focus .arc-line:not(.focused) {
  opacity: 0.12;
}
.map-container.has-focus .arc-glow:not(.focused) {
  opacity: 0.05;
}
.map-container.has-focus .source-node:not(.focused) {
  opacity: 0.15;
}
.map-container.has-focus .flow-particle:not(.focused) {
  opacity: 0.08;
}

/* ========== Particles ========== */
.flow-particle {
  pointer-events: none;
  mix-blend-mode: screen;
}

/* ========== Nodes ========== */
.source-node {
  cursor: pointer;
  transition: opacity 0.3s ease;
}

/* Donut segments */
.donut-seg {
  transition: opacity 0.2s ease;
}
.source-node:hover .donut-seg {
  opacity: 0.85;
}

.uk-node-ring {
  fill: none;
  stroke: var(--ring);
  stroke-width: 2;
  opacity: 0;
}

@keyframes uk-pulse {
  0%   { r: 6;  opacity: 0.8; }
  100% { r: 20; opacity: 0; }
}

.uk-pulse-ring {
  fill: none;
  stroke: var(--ring);
  stroke-width: 1.5;
  animation: uk-pulse 2s ease-out infinite;
}

.uk-node-dot {
  fill: var(--ring);
}

/* ========== Tooltip (enhanced) ========== */
.map-tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(14, 31, 53, 0.96);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: #e0e6f0;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  z-index: 9000;
  opacity: 0;
  transition: opacity 0.15s ease;
  max-width: 320px;
  line-height: 1.5;
}
.map-tooltip.visible {
  opacity: 1;
}
.map-tooltip .tt-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.map-tooltip .tt-flag {
  font-size: 18px;
  line-height: 1;
}
.map-tooltip .tt-country {
  font-weight: 700;
  font-size: 15px;
}
.map-tooltip .tt-rag-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  margin-right: 6px;
  vertical-align: middle;
}
.map-tooltip .tt-rag-badge.rag-R { background: var(--rag-red); color: var(--rag-red-text); }
.map-tooltip .tt-rag-badge.rag-A { background: var(--rag-amber); color: var(--rag-amber-text); }
.map-tooltip .tt-rag-badge.rag-G { background: var(--rag-green); color: var(--rag-green-text); }
.map-tooltip .tt-rag-badge.rag-D { background: var(--rag-dk-green); color: var(--rag-dk-green-text); }
.map-tooltip .tt-count {
  color: #8899aa;
  font-size: 12px;
}
.map-tooltip .tt-sov {
  margin-top: 6px;
  font-size: 11px;
  color: #8899aa;
  border-top: 1px solid rgba(255,255,255,.06);
  padding-top: 5px;
}
.map-tooltip .tt-deps {
  margin-top: 4px;
  font-size: 11px;
  color: #6a7a8a;
  font-style: italic;
}

/* ========== Summary Panel ========== */
.summary-panel {
  position: absolute;
  top: 20px;
  left: 20px;
  background: rgba(14, 31, 53, 0.92);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 30px 36px;
  min-width: 420px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  z-index: 5000;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.summary-panel.visible {
  opacity: 1;
}
.summary-panel h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
  color: #fff;
  text-align: left;
}

/* Capability name */
.summary-cap-name {
  font-size: 28px;
  font-weight: 800;
  color: #ff3b55;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

/* Overall RAG badge */
.summary-overall-rag {
  margin-bottom: 12px;
}
.overall-badge {
  display: inline-block;
  padding: 6px 20px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.overall-badge.rag-R {
  background: #ff3b55;
  color: #fff;
  animation: ragPulse 2s ease-in-out infinite;
}
.overall-badge.rag-A {
  background: #ffcf33;
  color: #1a1a2e;
}
.overall-badge.rag-G {
  background: #5fd99a;
  color: #1a1a2e;
}
@keyframes ragPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(255,59,85,.4); }
  50% { box-shadow: 0 0 24px rgba(255,59,85,.7); }
}

/* Report link in summary */
.summary-report-link {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.summary-report-link a {
  color: #0f9bff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s;
}
.summary-report-link a:hover {
  color: #00e5a0;
}

/* Report button in detail panel */
.panel-report-btn {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 12px 20px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0f9bff, #00e5a0);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
  transition: opacity 0.2s;
}
.panel-report-btn:hover {
  opacity: 0.85;
}
.panel-report-btn i {
  margin-right: 6px;
}
.summary-stats {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 13px;
  color: #8899aa;
}
.rag-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.rag-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.15);
  background: transparent;
  color: #ccc;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.rag-toggle .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.rag-toggle.active {
  border-color: rgba(255,255,255,.3);
  color: #fff;
}
.rag-toggle:not(.active) {
  opacity: 0.4;
}
.dot.red { background: var(--rag-red); }
.dot.amber { background: var(--rag-amber); }
.dot.green { background: var(--rag-green); }

/* ========== Detail Panel (slide-in from right) ========== */
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  background: #0e1f35;
  border-left: 1px solid rgba(255,255,255,.08);
  box-shadow: -8px 0 30px rgba(0,0,0,.5);
  z-index: 8000;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  padding: 24px;
}
.detail-panel.open {
  transform: translateX(0);
}

.detail-panel .panel-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.12);
  background: transparent;
  color: #8899aa;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 1;
}
.detail-panel .panel-close:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.detail-panel .panel-country {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  color: #fff;
}
.detail-panel .panel-rag-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 16px;
}
.panel-rag-badge.rag-R { background: var(--rag-red); color: var(--rag-red-text); }
.panel-rag-badge.rag-A { background: var(--rag-amber); color: var(--rag-amber-text); }
.panel-rag-badge.rag-G { background: var(--rag-green); color: var(--rag-green-text); }
.panel-rag-badge.rag-D { background: var(--rag-dk-green); color: var(--rag-dk-green-text); }

.detail-panel h4 {
  font-size: 13px;
  font-weight: 600;
  color: #8899aa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 20px 0 10px;
}

/* ========== Sovereignty Bar Chart ========== */
.sov-bars {
  margin-bottom: 8px;
}
.sov-bars h4 {
  margin-top: 12px;
}
.sov-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.sov-bar-label {
  font-size: 12px;
  font-weight: 600;
  color: #8899aa;
  width: 60px;
  flex-shrink: 0;
  text-align: right;
}
.sov-bar-track {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,.06);
  border-radius: 4px;
  overflow: hidden;
}
.sov-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.sov-bar-value {
  font-size: 13px;
  font-weight: 700;
  width: 32px;
  flex-shrink: 0;
  text-align: left;
}

/* ========== Risk Groups ========== */
.risk-group {
  margin-bottom: 16px;
}
.risk-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #b0bec5;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.risk-group-header .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.risk-group-deps {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ========== Dependency Accordion ========== */
.dep-accordion {
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.08);
  overflow: hidden;
  transition: border-color 0.2s ease;
}
.dep-accordion:hover {
  border-color: rgba(255,255,255,.15);
}
.dep-accordion.open {
  border-color: rgba(255,255,255,.18);
}

.dep-acc-header {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.2s ease;
  gap: 8px;
}
.dep-acc-header:hover {
  background: rgba(255,255,255,.04);
}
.dep-acc-header.rag-R { background: rgba(255,59,85,.1); }
.dep-acc-header.rag-A { background: rgba(255,207,51,.08); }
.dep-acc-header.rag-G, .dep-acc-header.rag-D { background: rgba(95,217,154,.08); }
.dep-acc-header.rag-N { background: rgba(255,255,255,.04); }

.dep-acc-label {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: #e0e6f0;
}
.dep-acc-icon {
  font-size: 10px;
  color: #5a6a7a;
  transition: transform 0.25s ease;
}
.dep-accordion.open .dep-acc-icon {
  transform: rotate(180deg);
}

.dep-acc-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.25, 0.8, 0.25, 1),
              padding 0.3s ease;
  padding: 0 12px;
}
.dep-accordion.open .dep-acc-body {
  max-height: 500px;
  padding: 8px 12px 12px;
}

/* Sovereignty detail within accordion */
.dep-acc-body .sov-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  font-size: 12px;
  margin: 0;
}
.dep-acc-body .sov-grid dt {
  color: #8899aa;
  font-weight: 600;
}
.dep-acc-body .sov-grid dd {
  margin: 0;
  font-weight: 700;
}
.dep-acc-body .sov-notes {
  margin-top: 6px;
  font-size: 11px;
  color: #7a8a9a;
  line-height: 1.4;
  padding: 4px 8px;
  background: rgba(255,255,255,.03);
  border-radius: 4px;
  border-left: 2px solid rgba(255,255,255,.1);
}

/* Activity count badge on accordion header */
.dep-act-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: rgba(255,255,255,.1);
  font-size: 10px;
  font-weight: 700;
  color: #8899aa;
  padding: 0 5px;
}

/* Affected activities list in accordion body */
.dep-activities {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.dep-acts-title {
  font-size: 10px;
  font-weight: 700;
  color: #5a6a7a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.dep-act-row {
  font-size: 11px;
  color: #8899aa;
  line-height: 1.5;
  padding: 2px 0;
  padding-left: 8px;
  border-left: 2px solid rgba(15,155,255,.2);
  margin-bottom: 2px;
}

/* ========== Zoom Controls ========== */
.zoom-controls {
  position: absolute;
  bottom: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 5000;
}
.zoom-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(14, 31, 53, 0.9);
  color: #8899aa;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.zoom-btn:hover {
  background: rgba(15,155,255,.15);
  color: var(--ring);
  border-color: var(--ring);
}

/* Replay button — inherits .zoom-btn styles, just adds top separator */
.replay-btn {
  margin-top: 4px;
}

/* ========== Legend ========== */
.map-legend {
  position: absolute;
  bottom: 24px;
  right: 24px;
  background: rgba(14, 31, 53, 0.9);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  padding: 12px 16px;
  z-index: 5000;
  font-size: 12px;
}
.map-legend h4 {
  font-size: 11px;
  font-weight: 700;
  color: #8899aa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 8px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  color: #b0bec5;
}
.legend-line {
  width: 24px;
  height: 3px;
  border-radius: 2px;
}
.legend-line.red { background: var(--rag-red); }
.legend-line.amber { background: var(--rag-amber); }
.legend-line.green { background: var(--rag-green); }

/* ========== Arc Draw Animation ========== */
@keyframes arc-draw {
  to { stroke-dashoffset: 0; }
}

/* ========== Page Transitions ========== */
body.map-page.page-fade-in {
  animation: mapFadeIn 0.4s ease forwards;
}
@keyframes mapFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
