/* ============================================================
   ARCHITECTURE DIAGRAM — arch-diagram.css
   Loaded via {% block head_extra %} on case pages only.
   Uses only tokens defined in tokens.css / themes.css.
   ============================================================ */

/* ── Container ─────────────────────────────────────────────── */
.arch-container {
  position: relative;
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: 180px;
}

.arch-container--loading,
.arch-container--error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}

.arch-loading,
.arch-error {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  color: var(--text-subtle);
  margin: 0;
  padding: var(--space-8) 0;
}

/* ── SVG canvas ─────────────────────────────────────────────── */
.arch-svg {
  width: 100%;
  height: auto;
  display: block;
  /* Fixed viewBox 1280×500 drives aspect ratio — no overflow artifacts */
  overflow: visible;
}

/* ── Nodes — base ───────────────────────────────────────────── */
.arch-node {
  cursor: pointer;
  transition: transform 200ms ease;
}

.arch-node rect {
  fill: var(--bg-elevated);
  stroke: var(--border);
  stroke-width: 1;
  transition: fill 250ms ease, stroke 250ms ease, stroke-width 250ms ease;
}

.arch-node text {
  fill: var(--text-subtle);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  pointer-events: none;
  transition: fill 250ms ease;
}

/* ── Node type variants (B&W system — no color rainbow) ─────── */

/* Trigger — outlined, entry points */
.arch-node--trigger rect {
  fill: transparent;
  stroke: var(--border-strong);
  stroke-width: 1;
}
.arch-node--trigger text {
  fill: var(--text);
}

/* System — filled, pass-through processors */
.arch-node--system rect {
  fill: var(--bg-subtle);
  stroke: var(--border);
  stroke-width: 1;
}
.arch-node--system text {
  fill: var(--text-muted);
}

/* Action — outlined + dot indicator (see .arch-node-dot) */
.arch-node--action rect {
  fill: transparent;
  stroke: var(--border-strong);
  stroke-width: 1;
}
.arch-node--action text {
  fill: var(--text);
}

/* Dot for action nodes */
.arch-node-dot {
  fill: var(--text-subtle);
  pointer-events: none;
  transition: fill 250ms ease;
}

/* Output — filled, prominent terminal point */
.arch-node--output rect {
  fill: var(--bg-elevated);
  stroke: var(--text);
  stroke-width: 1;
}
.arch-node--output text {
  fill: var(--text-muted);
}

/* ── Hover: highlighted node ────────────────────────────────── */
.arch-node--highlighted {
  transform: translateY(-1px);
}

.arch-node--highlighted rect {
  stroke: var(--text);
  stroke-width: 1.5;
  fill: var(--bg-subtle);
}

.arch-node--highlighted text {
  fill: var(--text);
}

.arch-node--highlighted .arch-node-dot {
  fill: var(--text);
}

/* ── Hover: dimmed nodes ────────────────────────────────────── */
.arch-node--dimmed {
  opacity: 0.25;
  transition: opacity 250ms ease;
}

/* ── Keyboard focus ring ────────────────────────────────────── */
.arch-node:focus {
  outline: none;
}
.arch-node:focus-visible rect {
  stroke: var(--text);
  stroke-width: 1.5;
}

/* ── Edges ──────────────────────────────────────────────────── */
.arch-edge {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 1.5;
  stroke-linecap: square;
  stroke-linejoin: miter;
  transition: stroke 250ms ease, stroke-width 250ms ease, opacity 250ms ease;
}

.arch-edge--active {
  stroke: var(--text);
  stroke-width: 1.5;
}

.arch-edge--dimmed {
  opacity: 0.3;
}

/* Arrow markers — CSS fill on path elements in <defs> */
.arch-arrow-path {
  fill: var(--border-strong);
}
.arch-arrow-path--active {
  fill: var(--text);
}

/* ── Tooltip ────────────────────────────────────────────────── */
.arch-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--text-muted);
  pointer-events: none;
  white-space: normal;
  max-width: 240px;
  text-align: center;
  line-height: 1.4;
  z-index: 20;
}

/* Tooltip placed dynamically via JS — override static defaults */
.arch-tooltip[style] {
  bottom: auto;
  left: auto;
  transform: none;
}

/* ── Tabs (ROIway multi-diagram switcher) ───────────────────── */
.arch-tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.arch-tab {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  color: var(--text-subtle);
  cursor: pointer;
  transition: border-color 200ms ease, color 200ms ease;
  line-height: 1;
}

.arch-tab:hover {
  border-color: var(--text);
  color: var(--text-muted);
}

.arch-tab--active {
  border-color: var(--text);
  color: var(--text);
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .arch-node,
  .arch-node rect,
  .arch-node text,
  .arch-node-dot,
  .arch-edge,
  .arch-node--dimmed {
    transition: none;
  }
}
