/* ============================================================
   Attack Surface Map — shared styles (Nirvik / Trinetra brand)
   Dark, self-contained (renders the same in light or dark docs).
   ============================================================ */
:root {
  --bg: #14182b;
  --bg-2: #1b2138;
  --panel: #1b2138;
  --ink: #ece8df;
  --muted: #9aa3bf;
  --hair: #2b3250;
  --turmeric: #e8a53a;

  /* severity */
  --sev-critical: #f0556a;
  --sev-high: #ef8e3c;
  --sev-medium: #e8c14a;

  /* node groups */
  --g-client: #8ab4ff;
  --g-edge: #e8a53a;
  --g-backend: #7fd1c4;
  --g-data: #74d39a;
  --g-external: #f0556a;
  --g-physical: #c79bff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.am-wrap {
  max-width: 1320px;
  margin: 0 auto;
  padding: 18px 22px 26px;
}

/* Header */
.am-head h1 {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.am-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  max-width: 70ch;
}

/* Legend */
.am-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  align-items: center;
  margin: 14px 0 8px;
  font-size: 0.82rem;
  color: var(--muted);
}
.am-legend .li { display: inline-flex; align-items: center; gap: 7px; }
.am-legend .dot {
  width: 13px; height: 13px; border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}
.dot.critical { background: var(--sev-critical); }
.dot.high { background: var(--sev-high); }
.dot.medium { background: var(--sev-medium); }
.am-legend .hint { margin-left: auto; font-style: italic; opacity: 0.8; }

/* Body layout — map full width on top, list + explanations stacked below */
.am-body { display: flex; flex-direction: column; gap: 18px; margin-top: 8px; }
.am-stage { width: 100%; }
.am-panel { width: 100%; display: flex; flex-direction: column; gap: 16px; }

/* Detail card (explanations) */
.am-detail {
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: 14px;
  padding: 18px 20px;
  min-height: 96px;
}
.am-detail.flash { animation: am-flash 0.7s ease; }
@keyframes am-flash {
  0% { box-shadow: 0 0 0 2px var(--turmeric); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Issues / defenses side by side when there is room */
.am-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
@media (max-width: 620px) { .am-cols { grid-template-columns: 1fr; } }

/* SVG diagram */
.am-stage svg {
  width: 100%;
  height: auto;
  display: block;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(232, 165, 58, 0.06), transparent 60%),
    var(--bg-2);
  border: 1px solid var(--hair);
  border-radius: 14px;
}

/* Nodes (foreignObject divs) */
.node {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1.5px solid var(--g-backend);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
}
.node small { display: block; font-weight: 500; color: var(--muted); font-size: 10.5px; margin-top: 2px; }
.node.client { border-color: var(--g-client); }
.node.edge { border-color: var(--g-edge); }
.node.backend { border-color: var(--g-backend); }
.node.data { border-color: var(--g-data); }
.node.external { border-color: var(--g-external); border-style: dashed; }
.node.physical { border-color: var(--g-physical); }

/* Flows */
.flow { stroke: #4a5680; stroke-width: 2; fill: none; opacity: 0.7; }
.flow-label { fill: var(--muted); font-size: 10px; font-family: 'DM Mono', monospace; }

/* Pins */
.pin { cursor: pointer; }
.pin circle.bg {
  stroke: rgba(0, 0, 0, 0.35);
  stroke-width: 1.5;
  transition: transform 0.12s ease;
  transform-box: fill-box;
  transform-origin: center;
}
.pin:hover circle.bg { transform: scale(1.18); }
.pin text { fill: #14182b; font-weight: 800; font-size: 14px; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.pin circle.bg.critical { fill: var(--sev-critical); }
.pin circle.bg.high { fill: var(--sev-high); }
.pin circle.bg.medium { fill: var(--sev-medium); }
.pin circle.ring { fill: none; stroke: #fff; stroke-width: 2.5; opacity: 0; }
.pin.active circle.ring { opacity: 0.95; }
.pin:focus { outline: none; }
.pin:focus circle.ring { opacity: 0.7; stroke: var(--turmeric); }

/* Detail panel content */
.am-panel .empty { color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.am-panel .badge-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.sev-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; padding: 3px 9px; border-radius: 999px; color: #14182b;
}
.sev-badge.critical { background: var(--sev-critical); }
.sev-badge.high { background: var(--sev-high); }
.sev-badge.medium { background: var(--sev-medium); }
.sev-badge .num { background: rgba(0, 0, 0, 0.22); border-radius: 50%; width: 16px; height: 16px; display: inline-grid; place-items: center; }
.concept-pill {
  font-size: 0.72rem; color: var(--turmeric);
  border: 1px solid rgba(232, 165, 58, 0.45); border-radius: 999px; padding: 2px 9px;
}
.am-panel h3 { margin: 4px 0 12px; font-size: 1.08rem; font-weight: 800; line-height: 1.25; }
.am-panel .sub { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin: 14px 0 6px; }
.am-panel ul { margin: 0; padding-left: 0; list-style: none; }
.am-panel li { position: relative; padding: 5px 0 5px 20px; font-size: 0.9rem; line-height: 1.4; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.am-panel li:last-child { border-bottom: 0; }
.am-panel .issues li::before { content: '⚠'; position: absolute; left: 0; color: var(--sev-high); font-size: 0.8rem; top: 6px; }
.am-panel .defenses li::before { content: '✓'; position: absolute; left: 0; color: var(--g-data); font-weight: 800; top: 5px; }

/* All-risks quick list */
.am-list { margin-top: 0; }
.am-list .sub { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 8px; }
.am-list ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); }
.am-list button {
  width: 100%; text-align: left; cursor: pointer;
  background: var(--panel); border: 1px solid var(--hair); border-radius: 9px;
  color: var(--ink); font-family: inherit; font-size: 0.86rem; padding: 8px 10px;
  display: flex; align-items: center; gap: 9px;
}
.am-list button:hover { border-color: var(--turmeric); }
.am-list button.active { border-color: var(--turmeric); background: rgba(232, 165, 58, 0.08); }
.am-list .chip { flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 800; font-size: 0.72rem; color: #14182b; }
.chip.critical { background: var(--sev-critical); }
.chip.high { background: var(--sev-high); }
.chip.medium { background: var(--sev-medium); }
