/* ==========================================================================
   Mermaid Zoom Lightbox — Windows 11 Fluent styles
   Pairs with docs/javascripts/mermaid-lightbox.js
   Light scheme first; [data-md-color-scheme="slate"] dark variants below.
   ========================================================================== */

/* ---------------------------------------------------------------- host --- */
.mermaid.mlbx-host {
  position: relative;
  cursor: zoom-in;
}

/* floating "⤢ expand" affordance — white pill, hairline border, soft shadow */
.mlbx-expand-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  padding: 3px 10px;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 11.5px;
  line-height: 1.6;
  color: #1b1b1b;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #e5e5e5;
  border-radius: 999px;
  box-shadow: 0 1.6px 3.6px rgba(0, 0, 0, 0.07), 0 0.3px 0.9px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 140ms ease, transform 140ms ease, background-color 120ms ease;
  pointer-events: none;
}

.mermaid.mlbx-host:hover .mlbx-expand-btn,
.mermaid.mlbx-host:focus-within .mlbx-expand-btn {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.mlbx-expand-btn:hover {
  background: #f3f3f3;
}

.mlbx-expand-btn:active {
  background: #ebebeb;
}

/* ------------------------------------------------------------- overlay --- */
.mlbx-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.65);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  backdrop-filter: blur(20px) saturate(1.2);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
}

.mlbx-overlay.mlbx-open {
  display: flex;
}

/* -------------------------------------------------------------- canvas --- */
.mlbx-canvas {
  position: relative;
  width: 92vw;
  height: 86vh;
  max-width: 92vw;
  max-height: 86vh;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  box-shadow:
    0 32px 64px rgba(0, 0, 0, 0.14),
    0 8.9px 14.2px rgba(0, 0, 0, 0.07),
    0 1.6px 3.6px rgba(0, 0, 0, 0.05);
  cursor: grab;
  touch-action: none;
}

.mlbx-canvas.mlbx-grabbing {
  cursor: grabbing;
}

.mlbx-viewport {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.mlbx-viewport svg {
  display: block;
  max-width: none !important;
  max-height: none !important;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none; /* drag/dblclick land on the canvas, not svg internals */
}

/* ------------------------------------------------------------- toolbar --- */
.mlbx-toolbar {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e5e5e5;
  border-radius: 999px;
  box-shadow: 0 1.6px 3.6px rgba(0, 0, 0, 0.07), 0 0.3px 0.9px rgba(0, 0, 0, 0.05);
}

.mlbx-tbtn {
  appearance: none;
  border: none;
  background: transparent;
  color: #1b1b1b;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  line-height: 1;
  padding: 7px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 120ms ease;
  white-space: nowrap;
}

.mlbx-tbtn:hover {
  background: #f3f3f3;
}

.mlbx-tbtn:active {
  background: #ebebeb;
}

.mlbx-pct {
  min-width: 48px;
  text-align: center;
  font-size: 12.5px;
  color: #5d5d5d;
  font-variant-numeric: tabular-nums;
  user-select: none;
  -webkit-user-select: none;
}

/* ------------------------------------------------------- dark scheme ----- */
[data-md-color-scheme="slate"] .mlbx-overlay {
  background: rgba(32, 32, 32, 0.7);
}

[data-md-color-scheme="slate"] .mlbx-canvas {
  background: #2d2d2d;
  border-color: #444444;
  box-shadow:
    0 32px 64px rgba(0, 0, 0, 0.5),
    0 8.9px 14.2px rgba(0, 0, 0, 0.3),
    0 1.6px 3.6px rgba(0, 0, 0, 0.25);
}

[data-md-color-scheme="slate"] .mlbx-toolbar {
  background: rgba(45, 45, 45, 0.95);
  border-color: #444444;
}

[data-md-color-scheme="slate"] .mlbx-tbtn {
  color: #f3f3f3;
}

[data-md-color-scheme="slate"] .mlbx-tbtn:hover {
  background: #3d3d3d;
}

[data-md-color-scheme="slate"] .mlbx-tbtn:active {
  background: #474747;
}

[data-md-color-scheme="slate"] .mlbx-pct {
  color: #b9b9b9;
}

[data-md-color-scheme="slate"] .mlbx-expand-btn {
  color: #f3f3f3;
  background: rgba(45, 45, 45, 0.92);
  border-color: #444444;
}

[data-md-color-scheme="slate"] .mlbx-expand-btn:hover {
  background: #3d3d3d;
}

[data-md-color-scheme="slate"] .mlbx-expand-btn:active {
  background: #474747;
}

/* mermaid svg on the dark canvas card: keep node text readable */
[data-md-color-scheme="slate"] .mlbx-canvas svg {
  filter: none;
}
