/* Mermaid diagram container — themed via design tokens (follows light/dark toggle).
   Node/edge colors are intentionally NOT hardcoded here: Mermaid's built-in
   light/dark theme (set in scripts.html from data-theme) owns them, so diagrams
   recolor correctly when the theme flips. */
.mermaid {
  text-align: center;
  margin: 1.5em 0;
  background-color: var(--surface, #ffffff);
  border: 1px solid var(--border, #e1e4e8);
  border-radius: 12px;
  padding: 16px;
  overflow-x: auto;
  position: relative;
  cursor: zoom-in; /* diagrams open in a zoomable lightbox on click */
}

.mermaid svg {
  max-width: 100%;
  height: auto;
}

/* Hover hint that the diagram is expandable (GitHub-style). */
.mermaid::after {
  content: "\2922"; /* ⤢ expand glyph */
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 15px;
  line-height: 1;
  color: var(--text-muted, #8c8d92);
  opacity: 0;
  transition: opacity 0.15s ease-out;
  pointer-events: none;
}
.mermaid:hover::after { opacity: 0.85; }

/* Responsive */
@media (max-width: 768px) {
  .mermaid {
    font-size: 0.8em;
    padding: 12px;
  }
}

/* ---- Click-to-zoom lightbox (built in scripts.html) ---- */
.mmd-lightbox {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  flex-direction: column;
}
.mmd-lightbox[hidden] { display: none; }

.mmd-lb-toolbar {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 16px;
  flex: 0 0 auto;
}
.mmd-lb-toolbar button {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease-out;
}
.mmd-lb-toolbar button:hover { background: rgba(255, 255, 255, 0.22); }

.mmd-lb-stage {
  flex: 1 1 auto;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
}
.mmd-lb-stage:active { cursor: grabbing; }

.mmd-lb-canvas {
  transform-origin: center center;
  will-change: transform;
}
.mmd-lb-canvas svg {
  /* Size is set explicitly in JS (fit-to-viewport from viewBox aspect),
     so do NOT cap with max-width here or it would shrink back to a thumbnail. */
  display: block;
  background: #ffffff;
  border-radius: 8px;
}
