/* ============================================================
   SYSTEM STACK (L0-L5) — the Cyber-Iceberg schematic page.

   V23: ported out of the Astro simulator page when the runtime
   simulator moved to /vm/simulator. Console tokens are scoped to
   .stack-viewport, NEVER :root — base.css already defines
   --text-dim etc. and the two layers must not collide (same rule
   the Astro app follows with .system-viewport).
   ============================================================ */

.stack-viewport {
  /* console tokens (light "blueprint console" remap) */
  --bg: #ffffff;
  --panel: var(--bg-light, #fdfdfc);
  --border: var(--border-color, rgba(53, 134, 145, 0.2));
  --border-dim: rgba(37, 74, 75, 0.12);
  --text: var(--text-main, #1a1a1a);
  --text-dim: #666666;
  /* interactive accent: brand-blue family, darkened a step so
     small text passes WCAG AA (#358691 is only ~4.2:1 on white) */
  --accent: #2F7A86;
  --accent-strong: var(--dark-teal, #254a4b);
  --accent-warm: var(--brand-orange, #a26538);
  --accent-dim: rgba(53, 134, 145, 0.35);
  --accent-glow: rgba(53, 134, 145, 0.12);
  --error: #C2410C;
  --error-glow: rgba(194, 65, 12, 0.08);
  --font-mono: 'Source Code Pro', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-sans: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 4px;

  /* base.css centers .container text — the schematic reads left-aligned */
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
}

.stack-viewport *,
.stack-viewport *::before,
.stack-viewport *::after {
  box-sizing: border-box;
}

/* Static docs -> runtime instance: a primary terminal command. */
.sys-boot-link {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #ffffff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 11px 18px;
  margin: 0 0 26px;
  text-decoration: none;
  transition: background 120ms linear, transform 120ms linear, box-shadow 120ms linear;
}

.sys-boot-link:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(37, 74, 75, 0.18);
  text-decoration: none;
}

.stack-intro {
  margin: 6px 0 24px;
}

/* 2-col text measure: theory left, protocol right. Row-gap 0 — the
   .lede bottom margins carry the vertical rhythm in both the grid
   and the stacked mobile mode. */
.noc-text-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 2rem;
}

@media (max-width: 767.98px) {
  .noc-text-grid {
    grid-template-columns: 1fr;
  }
}

.stack-intro h3 {
  font-family: var(--font-mono);
  font-size: 17px;
  letter-spacing: 0.04em;
  color: var(--accent-strong);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin: 0 0 14px;
}

.stack-intro .lede { margin-bottom: 14px; }

.exec-protocol {
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--accent-warm);
}

.system-alert a {
  color: var(--error);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- Desktop SVG blueprint ---------- */

.schematic-desktop {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  padding: 10px;
}

.schematic-svg {
  display: block;
  width: 100%;
  height: auto;
}

.bus {
  stroke: var(--accent-dim);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.band {
  fill: #ffffff;
  stroke: var(--border-dim);
  stroke-width: 1;
}

.band-label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  fill: var(--text-dim);
}

.band-id {
  fill: var(--accent-warm);
  font-weight: 700;
}

.node { cursor: pointer; outline: none; }

.node-box {
  fill: var(--panel);
  stroke: var(--accent-dim);
  stroke-width: 1;
  transition: stroke 120ms linear, fill 120ms linear;
}

.node-led {
  fill: rgba(162, 101, 56, 0.35);
  transition: fill 120ms linear;
}

.node-name {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  fill: var(--accent);
  pointer-events: none;
}

/* Soft "active server rack" glow on hover/focus — brand-blue, not neon. */
.node:hover .node-box,
.node:focus-visible .node-box {
  stroke: var(--accent);
  stroke-width: 1.5;
  fill: #ffffff;
  filter: drop-shadow(0 3px 8px rgba(53, 134, 145, 0.35));
}

.node:hover .node-led,
.node:focus-visible .node-led {
  fill: var(--accent-warm);
}

.node:hover .node-name,
.node:focus-visible .node-name {
  fill: var(--accent-strong);
}

/* ---------- Cyber-Iceberg: depth gradient + zones ---------- */
.abyss {
  stroke: var(--border-dim);
  stroke-width: 1;
}

.depth-line {
  stroke: rgba(190, 215, 220, 0.1);
  stroke-width: 1;
}

.bus-deep { stroke: rgba(160, 200, 205, 0.35); }

.waterline {
  stroke: rgba(72, 180, 200, 0.85);
  stroke-width: 1.5;
  stroke-dasharray: 6 6;
}

.waterline-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  fill: var(--accent);
}

.zone-hint {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  fill: rgba(37, 74, 75, 0.55);
}

/* L5 floats above the berg: airy, permeable dashed border */
.band-l5 .band {
  stroke-dasharray: 5 6;
  fill: rgba(255, 255, 255, 0.55);
}

/* Submerged zone: light-on-dark wireframe with glowing cyan borders.
   The surface rules above stay untouched for L5/L4. */
.zone-deep .band {
  fill: rgba(255, 255, 255, 0.04);
  stroke: rgba(160, 200, 205, 0.22);
}

.zone-deep .band-label { fill: rgba(210, 228, 230, 0.75); }
.zone-deep .band-id { fill: #c8845a; }

.zone-deep .node-box {
  fill: rgba(13, 25, 29, 0.55);
  stroke: rgba(72, 180, 200, 0.55);
  filter: drop-shadow(0 0 5px rgba(72, 180, 200, 0.25));
}

.zone-deep .node-name { fill: #cfe6e9; }
.zone-deep .node-led { fill: rgba(72, 180, 200, 0.4); }

.zone-deep .node:hover .node-box,
.zone-deep .node:focus-visible .node-box {
  fill: rgba(13, 25, 29, 0.85);
  stroke: rgba(72, 180, 200, 0.95);
  stroke-width: 1.5;
  filter: drop-shadow(0 0 9px rgba(72, 180, 200, 0.5));
}

.zone-deep .node:hover .node-name,
.zone-deep .node:focus-visible .node-name { fill: #ffffff; }

.zone-deep .node:hover .node-led,
.zone-deep .node:focus-visible .node-led { fill: rgba(72, 180, 200, 0.95); }

.svg-tooltip {
  position: absolute;
  z-index: 40;
  max-width: 300px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  box-shadow: 0 10px 26px rgba(37, 74, 75, 0.18);
  padding: 10px 12px;
  pointer-events: none;
}

.tooltip-name {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 4px;
}

.tooltip-body {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text);
  margin: 0;
}

/* ---------- Shared: glossary deep-links (modal + accordion) ---------- */
.gl-link {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.gl-link:hover { color: var(--accent-strong); }

.modal-gl-row { margin: 14px 0 16px; }

.gl-ref { margin: 12px 0 0; }

/* ---------- Shared: spec list + system alert ---------- */

.spec-list {
  margin: 0;
}

.spec-list dt {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-top: 14px;
}

.spec-list dd {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text);
  margin: 4px 0 0;
}

.system-alert {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.55;
  color: var(--error);
  border: 1px solid var(--error);
  border-radius: var(--radius);
  background: var(--error-glow);
  padding: 12px 14px;
  margin: 18px 0 0;
}

/* ---------- Modal ---------- */

/* `display: flex` would override the [hidden] UA style and leave the modal
   permanently painted over the schematic — hide it explicitly. */
.modal-overlay[hidden] { display: none; }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(23, 47, 48, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-panel {
  position: relative;
  width: min(560px, 100%);
  max-height: 85vh;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(23, 47, 48, 0.35);
  padding: 26px 28px 28px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  background: #ffffff;
  border: 1px solid var(--border);
  padding: 5px 9px;
  transition: color 120ms linear, border-color 120ms linear;
}

.modal-close:hover {
  color: var(--error);
  border-color: var(--error);
}

.lock-icon {
  color: var(--error);
  margin-bottom: 8px;
}

.modal-status {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--error);
  margin: 0 0 6px;
}

.modal-title {
  font-size: 19px;
  margin: 0 0 4px;
}

/* ---------- Mobile accordion ---------- */

.schematic-mobile { display: none; }

.acc-layer { margin-bottom: 26px; }

/* mobile waterline divider — mirrors the SVG's SOMATIC THRESHOLD */
.acc-waterline {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  border-top: 2px dashed rgba(72, 180, 200, 0.6);
  padding-top: 8px;
  margin: 22px 0 14px;
}

.acc-layer-head {
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin: 0 0 10px;
}

.acc-layer-head .layer-id { color: var(--accent-warm); }

.acc-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.acc-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  padding: 12px 14px;
}

.acc-item summary::-webkit-details-marker { display: none; }

.acc-item summary::after {
  content: '+';
  font-family: var(--font-mono);
  color: var(--accent-warm);
  flex-shrink: 0;
}

.acc-item[open] summary::after { content: '\2212'; }

.acc-item[open] {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(37, 74, 75, 0.1);
}

.acc-item[open] summary { color: var(--accent-strong); }

.acc-body {
  border-top: 1px solid var(--border-dim);
  padding: 4px 14px 16px;
}

.acc-tip {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-dim);
  margin: 12px 0 0;
}

/* ---------- The 768px unmount threshold ---------- */

@media (max-width: 767.98px) {
  .schematic-desktop { display: none; }
  .schematic-mobile { display: block; }
}
