/* Mapa del sistema (mapa.js): nodos por tipo, niveles, escenarios animados, tarjeta y reproductor. */

.widget.map { display: grid; gap: 8px; outline: none; }
.widget.map:focus-visible { box-shadow: 0 0 0 2px var(--accent); border-radius: var(--radius); }

/* color de cada tipo de nodo */
.k-actor { --k: var(--s2); }
.k-system { --k: var(--s1); }
.k-container { --k: var(--s1); }
.k-component { --k: var(--s5); }
.k-database { --k: var(--s3); }
.k-queue { --k: var(--s4); }
.k-external { --k: var(--text-muted); }

/* barra: migas y ajustar */
.map-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 32px; }
.map-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.map-crumb { border: 0; background: none; padding: 4px 8px; border-radius: 7px; font: 550 0.84rem var(--font-sans); color: var(--text-muted); cursor: pointer; }
.map-crumb:hover { background: var(--surface-2); color: var(--text); }
.map-crumb.here { color: var(--text); font-weight: 650; }
.map-crumb + .map-crumb::before { content: "›"; margin-right: 8px; color: var(--border-strong); }
.map-spacer { flex: 1; }
.map-hint { font-size: 0.78rem; color: var(--text-muted); }
.map-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 32px; padding: 4px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: 550 0.82rem var(--font-sans); cursor: pointer;
}
.map-btn:hover { border-color: var(--border-strong); }
.map-btn.icon { min-width: 32px; padding: 4px; }
.map-btn.play { min-width: 44px; background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.map-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.map-btn[hidden] { display: none; }

/* lienzo */
.map-stage { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--plot-bg); }
.map-svg { display: block; width: 100%; min-width: min(calc(var(--sw, 600) * 0.62px), 1100px); height: auto; user-select: none; -webkit-user-select: none; touch-action: pan-x pan-y; -webkit-touch-callout: none; }
.map-stage.is-zoomed .map-svg { touch-action: none; cursor: grab; }

/* nodos */
.map-node { cursor: pointer; transition: opacity 0.2s; }
.map-shape { fill: color-mix(in srgb, var(--k) 11%, var(--plot-bg)); stroke: var(--k); stroke-width: 1.6; transition: stroke-width 0.15s, fill 0.15s; }
.map-line { fill: none; stroke: var(--k); stroke-width: 1.4; }
.map-hit { fill: transparent; }
.k-actor .map-shape { fill: color-mix(in srgb, var(--k) 18%, var(--plot-bg)); }
.k-external .map-shape { stroke-dasharray: 6 4; }
.k-system .map-shape { stroke-width: 2.2; }
.map-kind { font: 650 9.5px var(--font-sans); letter-spacing: 0.08em; fill: var(--k); text-anchor: middle; }
.map-title { font: 600 13.5px var(--font-sans); fill: var(--text); text-anchor: middle; }
.map-tech { font: 11.5px var(--font-sans); fill: var(--text-muted); text-anchor: middle; }
.map-badge circle { fill: var(--k); }
.map-badge path { stroke: var(--plot-bg); stroke-width: 2; stroke-linecap: round; }
.map-node.is-ctx { opacity: 0.6; }
.map-node.is-ctx .map-shape { stroke-dasharray: 3 3; }
.map-node:hover .map-shape { stroke-width: 2.4; }
.map-node.is-sel .map-shape { stroke-width: 3; }
.map-node.is-drag { opacity: 0.85; cursor: grabbing; }
.map-node.is-target .map-shape { stroke: var(--accent); stroke-width: 3.2; }
.map-node.is-src .map-shape { stroke: var(--accent); stroke-width: 2.6; }
.map-node.is-dst .map-shape { stroke: var(--accent); stroke-width: 3.4; fill: color-mix(in srgb, var(--accent) 16%, var(--plot-bg)); }
.map-node.is-pulse { animation: map-pulse 0.6s ease-in-out 2; transform-box: fill-box; transform-origin: center; }
@keyframes map-pulse { 50% { opacity: 0.55; } }

/* asa para conectar: solo en edición */
.map-handle { display: none; fill: var(--accent); stroke: var(--plot-bg); stroke-width: 2.5; cursor: crosshair; }
.is-editing .map-node:hover .map-handle, .is-editing .map-node.is-sel .map-handle { display: block; }
@media (pointer: coarse) { .map-handle { r: 11px; } }
.map-rubber { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4; }

/* marco del nivel abierto */
.map-frame rect { fill: color-mix(in srgb, var(--k) 4%, transparent); stroke: var(--k); stroke-width: 1.6; stroke-dasharray: 8 5; }
.map-frame-title { font: 650 14px var(--font-sans); fill: var(--text); }
.map-frame-kind { font: 11.5px var(--font-sans); fill: var(--text-muted); }

/* relaciones */
.map-edge line { stroke: var(--text-muted); stroke-width: 1.4; }
.map-edge.dashed line { stroke-dasharray: 6 4; }
.map-head.filled { fill: var(--text-muted); }
.map-head.open { fill: none; stroke: var(--text-muted); stroke-width: 1.4; stroke-linejoin: round; }
.map-edge-label { font: 11.5px var(--font-sans); fill: var(--text-muted); text-anchor: middle; paint-order: stroke; stroke: var(--plot-bg); stroke-width: 4px; stroke-linejoin: round; }

/* escenario: estela, mensaje en curso */
.map-trail line { stroke: var(--accent); stroke-width: 4; stroke-linecap: round; opacity: 0.28; }
.map-live-line { stroke: var(--accent); stroke-width: 2.6; stroke-linecap: round; }
.map-live-line.dashed { stroke-dasharray: 6 4; }
.map-token { fill: var(--accent); stroke: var(--plot-bg); stroke-width: 2.5; }
.map-token.back { fill: var(--plot-bg); stroke: var(--accent); stroke-width: 3; }
.map-token-label { font: 600 12px var(--font-sans); fill: var(--text); text-anchor: middle; paint-order: stroke; stroke: var(--plot-bg); stroke-width: 5px; stroke-linejoin: round; }

/* tarjeta del nodo */
.map-card { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.map-card[hidden] { display: none; }
.map-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.map-chip { padding: 2px 8px; border-radius: 99px; font: 650 0.7rem var(--font-sans); letter-spacing: 0.04em; text-transform: uppercase; color: var(--k); background: color-mix(in srgb, var(--k) 14%, transparent); }
.map-card-desc { margin: 0; }
.map-card-rels { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; font-size: 0.88rem; }
.map-card-arrow { display: inline-block; width: 1.4em; color: var(--text-muted); }
.map-card-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.map-card-actions:empty { display: none; }

/* reproductor */
.map-player { display: grid; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.map-player[hidden] { display: none; }
.map-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.map-controls select { width: auto; min-height: 32px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: 550 0.84rem var(--font-sans); }
.map-scen { max-width: 260px; }
.map-count { font-size: 0.82rem; color: var(--text-muted); padding: 0 4px; }
.map-narr { min-height: 44px; }
.map-narr p { margin: 4px 0 0; }
.map-narr-head { font-size: 0.92rem; }
.map-narr-arrow { color: var(--accent); font-weight: 700; }
.map-narr-msg { font: 600 0.92rem var(--font-mono); color: var(--accent); }
.map-narr-note { color: var(--text); }
.map-seq[hidden] { display: none; }

@media (pointer: coarse) {
  .map-btn, .map-controls select { min-height: 42px; }
  .map-btn.icon { min-width: 42px; }
  .map-crumb { padding: 9px 10px; }
}
@media (prefers-reduced-motion: reduce) { .map-node.is-pulse { animation: none; } }
