/* System status map. See system-map.js.
   Calm and flat: thin borders, no shadows, no gradients.
   Colours come from the variables at the top of styles.css. */

.sysmap { font-size: 13px; line-height: 1.3; }
.sysmap-empty { color: var(--faint); font-size: 13px; }

/* ---------- The two-option switch ---------- */

.sysmap-switch {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.sysmap-option {
  border: 0;
  border-radius: 6px;
  padding: 4px 12px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}

.sysmap-option:hover { color: var(--text); }
.sysmap-option-on { background: var(--raised); color: var(--text); }

/* ---------- Layout ---------- */

.sysmap-map { position: relative; display: grid; }

/* Tech: four equal columns. The wide gaps leave room for the lines. */
.sysmap-tech { grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 9%; }
.sysmap-column { display: flex; flex-direction: column; gap: 22px; min-width: 0; }

/* Business: service groups on the left, a wide gap for the lines, systems on the right. */
.sysmap-business { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); column-gap: 20%; }
.sysmap-groups { display: flex; flex-direction: column; gap: 26px; min-width: 0; }
.sysmap-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 14px; row-gap: 10px; }
.sysmap-group .sysmap-title { grid-column: 1 / -1; }
.sysmap-stack { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.sysmap-systems { display: flex; flex-direction: column; justify-content: space-around; gap: 10px; min-width: 0; }

.sysmap-title {
  margin: 0;
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ---------- Boxes ---------- */

.sysmap-box {
  --sysmap-tone: var(--unknown);

  position: relative; /* above the lines, and the anchor for the pulsing dot */
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--sysmap-tone) 45%, var(--line-strong));
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  text-align: left;
  transition: opacity 120ms, background 120ms;
}

.sysmap-box:hover { background: var(--raised); }

.sysmap-tone-crit { --sysmap-tone: var(--crit); }
.sysmap-tone-warn { --sysmap-tone: var(--warn); }
.sysmap-tone-ok { --sysmap-tone: var(--ok); }
.sysmap-tone-unknown { --sysmap-tone: var(--unknown); }
/* "No sign": a quiet grey-green, calmer than the green of "Contained". */
.sysmap-tone-clear { --sysmap-tone: color-mix(in srgb, var(--ok) 40%, var(--unknown)); }

.sysmap-tone-unknown, .sysmap-tone-clear { border-color: var(--line-strong); }

/* A long name wraps to a second line. Only a third line would be cut. */
.sysmap-name {
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.25;
  font-weight: 500;
}

.sysmap-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.sysmap-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sysmap-tone); }

/* The attacker is marked active here now. */
.sysmap-active {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--crit);
  animation: sysmap-pulse 1.4s ease-in-out infinite;
}

@keyframes sysmap-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(1.5); }
}

@media (prefers-reduced-motion: reduce) {
  .sysmap-active { animation: none; }
  .sysmap-box { transition: none; }
}

/* ---------- Lines ---------- */

.sysmap-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none; /* only the paths take clicks */
}

.sysmap-line {
  fill: none;
  stroke: color-mix(in srgb, var(--muted) 45%, transparent);
  stroke-width: 1;
  marker-end: url(#sysmap-arrow);
  transition: opacity 120ms;
}

.sysmap-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }

.sysmap-lines marker path { fill: none; stroke: var(--muted); stroke-width: 1.2; }
#sysmap-arrow-lit path { stroke: var(--text); }

/* ---------- Hover or focus: the box, its lines and its neighbours stay bright ---------- */

.sysmap-focus .sysmap-box:not(.sysmap-lit) { opacity: 0.3; }
.sysmap-focus .sysmap-line:not(.sysmap-lit) { opacity: 0.2; }
.sysmap-line.sysmap-lit { stroke: var(--text); marker-end: url(#sysmap-arrow-lit); }

/* ---------- Popover for one line ---------- */

.sysmap-popover {
  position: fixed;
  z-index: 50;
  display: grid;
  gap: 6px;
  width: 300px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--raised);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
}

.sysmap-popover-label { font-weight: 500; }
.sysmap-popover-quote { color: var(--muted); }
.sysmap-popover-link { color: var(--text); text-decoration: underline; text-underline-offset: 3px; justify-self: start; }

/* ---------- Narrow windows ---------- */

@media (max-width: 1100px) {
  .sysmap-tech { column-gap: 6%; }
  .sysmap-business { column-gap: 12%; }
  .sysmap-box { padding: 0 10px; gap: 8px; }
}

/* Under 800px everything stacks in one column and the lines are not drawn. */
@media (max-width: 799px) {
  .sysmap-tech, .sysmap-business { grid-template-columns: 1fr; row-gap: 26px; }
  .sysmap-column, .sysmap-systems { gap: 10px; }
  .sysmap-lines { display: none; }
}
