/* ── Mermaid Diagram Zoom & Pan Styles ── */

/* The outer wrapper — contains the diagram and zoom controls */
.mermaid-zoom-wrapper {
  position: relative;
  overflow: hidden;          /* Hide parts of diagram that are panned outside */
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 8px;
  background: var(--md-code-bg-color);
  min-height: 200px;
  max-height: 80vh;          /* Don't let diagrams take up more than 80% of screen */
  margin: 1rem 0;
}

/* The inner viewport — this is what gets zoomed and panned via CSS transform */
.mermaid-zoom-viewport {
  transform-origin: 0 0;     /* Zoom from top-left (our JS handles centering) */
  transition: none;           /* No animation during drag (would feel laggy) */
  padding: 1rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* Make the mermaid container fill properly when zoom is enabled */
.mermaid-zoom-enabled {
  overflow: visible !important;
  background: transparent !important;
}

/* ── Zoom Controls Bar ── */
.mermaid-zoom-controls {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--md-default-bg-color);
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 6px;
  padding: 4px 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 10;               /* Stay above the diagram */
  user-select: none;          /* Prevent accidental text selection */
  font-size: 0.75rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

/* Show controls more prominently on hover */
.mermaid-zoom-wrapper:hover .mermaid-zoom-controls {
  opacity: 1;
}

/* Individual zoom buttons */
.mermaid-zoom-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--md-default-fg-color--light);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mermaid-zoom-btn:hover {
  background: var(--md-accent-fg-color--transparent);
  color: var(--md-accent-fg-color);
}

/* Zoom percentage display */
.mermaid-zoom-level {
  min-width: 40px;
  text-align: center;
  color: var(--md-default-fg-color--light);
  font-weight: 500;
  font-variant-numeric: tabular-nums;   /* Keep numbers from jumping around */
}

/* "Scroll to zoom · Drag to pan" hint text */
.mermaid-zoom-hint {
  color: var(--md-default-fg-color--lighter);
  font-size: 0.65rem;
  margin-left: 4px;
  white-space: nowrap;
}

/* Hide hint on small screens */
@media (max-width: 768px) {
  .mermaid-zoom-hint {
    display: none;
  }
}

/* ── Divider between zoom buttons and fullscreen button ── */
.mermaid-zoom-divider {
  width: 1px;
  height: 16px;
  background: var(--md-default-fg-color--lightest);
  margin: 0 4px;
}

/* ── Fullscreen mode ── */
.mermaid-zoom-wrapper.mermaid-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  max-height: none;           /* Override the 80vh limit */
  z-index: 9999;              /* Above everything */
  border-radius: 0;
  border: none;
  margin: 0;
  background: var(--md-default-bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Keep controls visible and in a good spot in fullscreen */
.mermaid-zoom-wrapper.mermaid-fullscreen .mermaid-zoom-controls {
  bottom: 24px;
  right: 24px;
  opacity: 1;
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.mermaid-zoom-wrapper.mermaid-fullscreen .mermaid-zoom-btn {
  width: 32px;
  height: 32px;
}

/* Center the diagram viewport in fullscreen */
.mermaid-zoom-wrapper.mermaid-fullscreen .mermaid-zoom-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ── Ensure SVGs inside zoom containers behave well ── */
.mermaid-zoom-viewport svg {
  max-width: none !important;
  height: auto !important;
}

/* ── Dark mode adjustments ── */
[data-md-color-scheme="slate"] .mermaid-zoom-wrapper {
  border-color: rgba(255, 255, 255, 0.1);
}

[data-md-color-scheme="slate"] .mermaid-zoom-controls {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
