/* WinLuisPlus WannaCry network simulator.
   A quiet, technical look: flat surfaces, hairlines, monospace labels, and colour used only for state.
   Nothing animates unless an attack is running. */

.ns {
  --ns-bg: #0b0e14;
  --ns-surface: #10141c;
  --ns-raised: #161b26;
  --ns-line: rgba(255,255,255,.08);
  --ns-line-strong: rgba(255,255,255,.16);
  --ns-wire: #2a3343;
  --ns-ink: #e7ebf3;
  --ns-dim: #8d97a8;
  --ns-faint: #5d6778;
  --ns-red: #ff5d52;
  --ns-amber: #f3b54a;
  --ns-green: #3fcf8e;
  --ns-blue: #4f8cff;
  --ns-mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  background: var(--ns-bg);
  color: var(--ns-ink);
  border: 1px solid var(--ns-line-strong);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 30px 60px -30px rgba(0,0,0,.8);
}
.ns button { font: inherit; color: inherit; }
.ns :focus-visible { outline: 2px solid var(--ns-blue); outline-offset: 2px; }

/* ---------- top bar ---------- */
.ns-bar { display: flex; align-items: center; gap: 16px 24px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--ns-line); background: var(--ns-surface); }
.ns-bar__name { display: grid; gap: 2px; min-width: 0; }
.ns-bar__name strong { font: 600 1rem/1.2 var(--font-display, inherit); letter-spacing: -.01em; }
.ns-bar__name span { font: .74rem/1.3 var(--ns-mono); color: var(--ns-dim); }
.ns-clock { margin: 0 0 0 auto; font: 500 .9rem/1 var(--ns-mono); color: var(--ns-dim); font-variant-numeric: tabular-nums; }
.ns-clock__time { color: var(--ns-ink); font-size: 1.15rem; margin: 0 2px; }
.ns.is-running .ns-clock__time { color: var(--ns-red); }
.ns-bar__btns { display: flex; gap: 8px; }

.ns-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--ns-line-strong); background: var(--ns-raised); font-size: .88rem; font-weight: 500; cursor: pointer; transition: background-color .15s, border-color .15s; }
.ns-btn:hover { background: #1d2331; border-color: rgba(255,255,255,.26); }
.ns-btn--ghost { background: transparent; font-family: var(--ns-mono); font-size: .82rem; }
.ns-btn--ghost[aria-pressed="true"] { color: var(--ns-blue); border-color: rgba(79,140,255,.5); }

/* ---------- body ---------- */
.ns-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; }
.ns-map { position: relative; padding: 14px 14px 10px; background:
  radial-gradient(circle at 1px 1px, rgba(255,255,255,.05) 1px, transparent 0) 0 0 / 22px 22px, var(--ns-bg); min-width: 0; }
.ns-svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--ns-mono); }
.ns-hint { position: absolute; left: 18px; top: 18px; max-width: 32%; margin: 0; padding: 8px 12px; border-radius: 10px; background: rgba(16,20,28,.92); border: 1px solid var(--ns-line-strong); font-size: .8rem; line-height: 1.4; color: var(--ns-dim); pointer-events: none; }
.ns-hint[hidden] { display: none; }
.ns-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 8px 4px 0; padding: 0; font-size: .76rem; color: var(--ns-dim); }
.ns-legend li { display: inline-flex; align-items: center; gap: 6px; }
.ns-key { width: 10px; height: 10px; border-radius: 2px; border: 1.5px solid var(--ns-faint); }
.ns-key--infected { border-color: var(--ns-red); background: linear-gradient(0deg, var(--ns-red) 45%, transparent 45%); }
.ns-key--encrypted { border-color: var(--ns-red); background: var(--ns-red); }
.ns-key--crashed { border-color: var(--ns-blue); background: var(--ns-blue); }
.ns-key--safe { border-color: var(--ns-green); }
.ns-key--exited { border-color: var(--ns-faint); background: #3a4252; }

/* ---------- side panel ---------- */
.ns-side { border-left: 1px solid var(--ns-line); background: var(--ns-surface); }
.ns-panel { padding: 16px 18px; }
.ns-panel + .ns-panel { border-top: 1px solid var(--ns-line); }
.ns-h { margin: 0 0 12px; font: 600 .7rem/1 var(--ns-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ns-dim); }

.ns-starts { display: grid; gap: 8px; }
.ns-btn--start { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px; padding: 10px 12px; text-align: left; border-radius: 10px; }
.ns-btn--start b { font-weight: 600; font-size: .9rem; }
.ns-btn--start b::before { content: "▸ "; color: var(--ns-red); }
.ns-btn--start span { font-size: .78rem; color: var(--ns-dim); font-weight: 400; }
.ns.is-running .ns-btn--start { opacity: .5; }

.ns-presets { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- the editor ---------- */
.ns-custom__lead { margin: 0 0 12px; font-size: .8rem; line-height: 1.45; color: var(--ns-dim); }
.ns-btn--wide { width: 100%; }
.ns-btn--wide[aria-pressed="true"] { background: var(--ns-blue); border-color: var(--ns-blue); color: #fff; }
.ns-btn--danger:not(:disabled):hover { background: rgba(255,93,82,.16); border-color: var(--ns-red); color: #ffb4ae; }
.ns-btn:disabled { opacity: .45; cursor: not-allowed; }
.ns-editor { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--ns-raised); border: 1px solid var(--ns-line-strong); display: grid; gap: 10px; }
.ns-editor[hidden] { display: none; }
.ns-editor p { margin: 0; }
.ns-editor__where { font: 600 .7rem/1 var(--ns-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ns-dim); }
.ns-editor__note, .ns-editor__msg { font-size: .78rem; line-height: 1.45; color: var(--ns-dim); }
.ns-editor__note:empty, .ns-editor__msg:empty { display: none; }
.ns-editor__msg { color: var(--ns-green); }
.ns-editor__field, .ns-editor__add label { display: grid; gap: 5px; font-size: .78rem; color: var(--ns-dim); }
.ns-editor input[type="text"], .ns-editor select {
  font: 500 .88rem/1.2 var(--ns-mono); color: var(--ns-ink); background: var(--ns-bg); border: 1px solid var(--ns-line-strong);
  border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0;
}
.ns-editor select { font-family: inherit; }
.ns-editor input[type="text"]:focus, .ns-editor select:focus { outline: 2px solid var(--ns-blue); outline-offset: 1px; }
.ns-editor__check { display: flex; align-items: center; gap: 9px; font-size: .84rem; cursor: pointer; }
.ns-editor__check input { width: 16px; height: 16px; accent-color: var(--ns-green); margin: 0; flex: none; }
.ns-editor__check:has(input:disabled) { opacity: .45; cursor: not-allowed; }
.ns-editor__add { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
.ns-editor__add .ns-btn { grid-column: 1 / -1; }
.ns-editor__row { display: flex; flex-wrap: wrap; gap: 8px; }
.ns-editor__row .ns-btn { flex: 1 1 auto; }
/* while editing, the map is for picking, not attacking */
.ns.is-editing .ns-node { cursor: pointer; }
.ns.is-editing .ns-btn--start { opacity: .5; }
.ns-node.is-picked .ns-hit { fill: rgba(79,140,255,.12); stroke: var(--ns-blue); stroke-width: 1.5; stroke-dasharray: 4 3; }
.ns-chip { padding: 6px 10px; border-radius: 999px; border: 1px solid var(--ns-line-strong); background: transparent; font-size: .78rem; cursor: pointer; color: var(--ns-dim) !important; }
.ns-chip:hover { color: var(--ns-ink) !important; border-color: rgba(255,255,255,.3); }
.ns-chip[aria-pressed="true"] { background: var(--ns-ink); border-color: var(--ns-ink); color: var(--ns-bg) !important; }

.ns-defs { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ns-def { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; padding: 8px 8px; margin: 0 -8px; border-radius: 8px; cursor: pointer; }
.ns-def:hover { background: rgba(255,255,255,.03); }
.ns-def input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ns-switch { position: relative; width: 32px; height: 18px; margin-top: 1px; border-radius: 999px; background: #2a3140; border: 1px solid var(--ns-line-strong); transition: background-color .18s; }
.ns-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #aab3c3; transition: transform .18s, background-color .18s; }
.ns-def input:checked + .ns-switch { background: var(--ns-green); border-color: var(--ns-green); }
.ns-def input:checked + .ns-switch::after { transform: translateX(14px); background: #06140d; }
.ns-def input:focus-visible + .ns-switch { outline: 2px solid var(--ns-blue); outline-offset: 2px; }
.ns-def__txt { display: grid; gap: 2px; }
.ns-def__txt b { font-size: .88rem; font-weight: 600; }
.ns-def__txt span { font-size: .77rem; line-height: 1.4; color: var(--ns-dim); }

.ns-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 0; background: var(--ns-line); border: 1px solid var(--ns-line); border-radius: 10px; overflow: hidden; }
.ns-stats div { background: var(--ns-surface); padding: 10px 12px; }
.ns-stats dt { font-size: .72rem; color: var(--ns-dim); }
.ns-stats dd { margin: 4px 0 0; font: 600 1.35rem/1 var(--ns-mono); font-variant-numeric: tabular-nums; }
.ns-stats [data-stat="encrypted"], .ns-stats [data-stat="ransom"] { color: var(--ns-red); }
.ns-stats [data-stat="crashed"] { color: #8fb4ff; }
.ns-stats [data-stat="safe"] { color: var(--ns-green); }
.ns-stats dd.is-zero { color: var(--ns-faint); }

/* ---------- log and outcome ---------- */
.ns-main { display: flex; flex-direction: column; min-width: 0; }
.ns-log-wrap { flex: 1; display: flex; flex-direction: column; padding: 16px 18px; min-width: 0; border-top: 1px solid var(--ns-line); }
.ns-log { list-style: none; margin: 0; padding: 0; flex: 1 1 0; min-height: 170px; contain: size; overflow-y: auto; font: .8rem/1.5 var(--ns-mono); scrollbar-width: thin; }
.ns-log .ns-log__empty { display: block; border-left-color: transparent; padding-left: 0; color: var(--ns-faint); font-family: var(--font, sans-serif); font-size: .85rem; }
.ns-log li { display: grid; grid-template-columns: 3.6em 1fr; gap: 10px; padding: 4px 0 4px 10px; border-left: 2px solid var(--ns-line-strong); color: var(--ns-dim); }
.ns-log li + li { margin-top: 2px; }
.ns-log time { color: var(--ns-faint); font-variant-numeric: tabular-nums; }
.ns-log b { color: var(--ns-ink); font-weight: 600; }
.ns-log .ns-log__bad { border-left-color: var(--ns-red); }
.ns-log .ns-log__warn { border-left-color: var(--ns-amber); }
.ns-log .ns-log__good { border-left-color: var(--ns-green); }
.ns-log li:first-child { animation: ns-in .25s ease-out; }
@keyframes ns-in { from { opacity: 0; transform: translateY(-4px); } }

.ns-outcome { padding: 16px 18px 18px; border-top: 1px solid var(--ns-line); background: var(--ns-surface); display: grid; align-content: start; gap: 8px; }
.ns-outcome[hidden] { display: none; }
.ns-outcome p { margin: 0; font-size: .88rem; line-height: 1.5; color: var(--ns-dim); }
.ns-outcome__head { font: 600 1.05rem/1.3 var(--font-display, inherit) !important; color: var(--ns-ink) !important; }
.ns-outcome.is-bad .ns-outcome__head::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ns-red); margin-right: 8px; vertical-align: .12em; }
.ns-outcome.is-warn .ns-outcome__head::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ns-amber); margin-right: 8px; vertical-align: .12em; }
.ns-outcome.is-good .ns-outcome__head::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ns-green); margin-right: 8px; vertical-align: .12em; }
.ns-outcome__tip { padding: 10px 12px; border-radius: 8px; background: rgba(79,140,255,.08); border: 1px solid rgba(79,140,255,.25); color: #c9d8ff !important; }
.ns-outcome .ns-btn { justify-self: start; margin-top: 4px; }

/* ---------- the map (SVG) ---------- */
.ns-zone { fill: rgba(255,255,255,.018); stroke: var(--ns-line-strong); stroke-width: 1; }
.ns-zone__name { fill: var(--ns-ink); font-size: 11px; font-weight: 600; letter-spacing: .1em; }
.ns-zone__net { fill: var(--ns-faint); font-size: 10.5px; }
.ns-wires path { fill: none; stroke: var(--ns-wire); stroke-width: 1.5; stroke-linejoin: round; }
.ns-wires path.is-unplugged { stroke-dasharray: 3 5; stroke: #3a2f2f; }
.ns-infra { fill: var(--ns-raised); stroke: #6b7689; stroke-width: 1.3; }
.ns-infra ellipse, .ns-infra path { fill: none; }
.ns-infra circle { fill: var(--ns-raised); }
.ns-infra .ns-port { fill: #3d475a; stroke: none; }
.ns-infra__label { fill: var(--ns-dim); stroke: none; font-size: 11px; }

.ns-node { cursor: pointer; outline: none; }
.ns-hit { fill: transparent; stroke: none; }
.ns-node:hover .ns-hit, .ns-node:focus-visible .ns-hit { fill: rgba(255,255,255,.04); stroke: var(--ns-line-strong); }
.ns-node:focus-visible .ns-hit { stroke: var(--ns-blue); stroke-width: 1.5; }
.ns-face { fill: #1a202c; stroke: #7a8599; stroke-width: 1.5; transition: stroke .2s; }
.ns-stand { fill: #3a4354; }
.ns-rack { stroke: #4c5669; stroke-width: 1.5; fill: none; }
.ns-fill { fill: var(--ns-red); transition: y .5s ease-out, height .5s ease-out; }
.ns-host { fill: var(--ns-ink); font-size: 10.5px; font-weight: 600; text-anchor: middle; letter-spacing: .02em; }
.ns-sub { fill: var(--ns-faint); font-size: 9px; text-anchor: middle; letter-spacing: .03em; }
.ns-glyph { display: none; }
.ns-glyph--lock path { stroke: #fff; stroke-width: 1.8; }
.ns-glyph--lock rect { fill: #fff; }
.ns-glyph--sad { fill: #fff; font: 700 11px var(--font, sans-serif); }
.ns-badge { display: none; }
.ns-badge circle { fill: var(--ns-green); }
.ns-badge path { stroke: #06140d; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.ns-node.is-infected .ns-face { stroke: var(--ns-red); }
.ns-node.is-infected .ns-sub, .ns-node.is-encrypted .ns-sub { fill: var(--ns-red); }
.ns-node.is-infected .ns-face { animation: ns-alarm 1.1s ease-in-out infinite; }
@keyframes ns-alarm { 50% { stroke: #ff9a92; stroke-width: 2.4; } }
.ns-node.is-encrypted .ns-face { stroke: var(--ns-red); }
.ns-node.is-encrypted .ns-glyph--lock { display: block; }
.ns-node.is-crashed .ns-fill { fill: #1f5fd6; }
.ns-node.is-crashed .ns-face { stroke: #6f9cff; }
.ns-node.is-crashed .ns-glyph--sad { display: block; }
.ns-node.is-crashed .ns-sub { fill: #8fb4ff; }
.ns-node.is-exited .ns-fill { fill: #333b4a; }
.ns-node.is-exited .ns-face { stroke: var(--ns-faint); stroke-dasharray: 3 3; }
.ns-node.is-exited .ns-sub { fill: var(--ns-dim); }
.ns-node.is-safe .ns-face { stroke: var(--ns-green); }
.ns-node.is-safe .ns-badge { display: block; }
.ns-node.is-safe .ns-sub { fill: var(--ns-green); }
.ns-node.is-offline { opacity: .55; }
.ns-node.is-offline .ns-face { stroke-dasharray: 3 3; }
.ns-node.is-offline .ns-sub { fill: var(--ns-dim); }

.ns-packet { fill: var(--ns-red); stroke: var(--ns-bg); stroke-width: 2; }
.ns-packet.is-outside { fill: var(--ns-amber); }
.ns-mark circle { stroke-width: 1.5; }
.ns-mark path { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ns-mark.is-block circle { fill: #2a1416; stroke: var(--ns-red); }
.ns-mark.is-block path { stroke: var(--ns-red); }
.ns-mark.is-ok circle { fill: #0f2a1d; stroke: var(--ns-green); }
.ns-mark.is-ok path { stroke: var(--ns-green); }
.ns-mark { animation: ns-mark 1.4s ease-out forwards; }
@keyframes ns-mark { 0% { opacity: 0; } 12% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- smaller screens: controls first, then the map ---------- */
@media (max-width: 980px) {
  .ns-body { grid-template-columns: 1fr; }
  .ns-main, .ns-side { display: contents; }
  .ns-side > .ns-panel { order: 1; border-top: 1px solid var(--ns-line); background: var(--ns-surface); }
  .ns-side > .ns-panel:first-child { border-top: 0; }
  .ns-map { order: 2; border-top: 1px solid var(--ns-line); }
  .ns-side > .ns-panel:nth-child(4) { order: 3; }
  .ns-outcome { order: 4; }
  .ns-log-wrap { order: 5; }
  .ns-log { flex: none; height: 220px; }
  .ns-defs { grid-template-columns: 1fr 1fr; column-gap: 20px; }
}
@media (max-width: 640px) {
  .ns { border-radius: 12px; margin-inline: -4px; }
  .ns-defs { grid-template-columns: 1fr; }
  .ns-map { padding: 10px 6px; }
  .ns-hint { position: static; transform: none; margin: 0 0 8px; white-space: normal; text-align: center; border-radius: 8px; }
  .ns-host { font-size: 11.5px; }
  .ns-sub { font-size: 9.5px; }
  .ns-clock { margin-left: 0; }
  .ns-bar__btns { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .ns-node.is-infected .ns-face, .ns-mark, .ns-log li:first-child { animation: none; }
  .ns-fill, .ns-switch, .ns-switch::after { transition: none; }
}
