/* mermaidJS markdown is converted to svg, this rule affects them */
svg {
  /* https://stackoverflow.com/questions/8639383/how-do-i-center-an-svg-in-a-div */
  display: block;
  margin: auto;
}

/* Keep menu-bar actions on one row (translate dropdown used float:right and broke flex) */
#mdbook-menu-bar .right-buttons {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  position: relative;
}

/* Align Font Awesome 4 (globe) with embedded SVG icons in the menu bar */
#mdbook-menu-bar .left-buttons .icon-button,
#mdbook-menu-bar .right-buttons .icon-button,
#mdbook-menu-bar .right-buttons > a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#mdbook-menu-bar .left-buttons .fa-svg,
#mdbook-menu-bar .right-buttons .fa-svg {
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
}
#mdbook-menu-bar .left-buttons .fa,
#mdbook-menu-bar .right-buttons .fa {
  font-size: 1em;
  line-height: 1;
  vertical-align: middle;
}

/* In-page TOC from mdbook-toc (`<!-- toc -->` → first list in main): sidebar-style box */
#mdbook-content main > ul:first-of-type {
  float: right;
  clear: right;
  max-width: min(280px, 38vw);
  margin: 0 0 1rem 1.25rem;
  padding: 0.5rem 0.75rem 0.5rem 1.25rem;
  font-size: 0.9em;
  line-height: 1.35;
  border: 1px solid var(--table-border-color);
  border-radius: 4px;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-fg);
}
@media (max-width: 720px) {
  #mdbook-content main > ul:first-of-type {
    float: none;
    clear: both;
    max-width: none;
    margin: 0 0 1rem 0;
  }
}

#mdbook-content main::after {
  content: "";
  display: table;
  clear: both;
}

/* ==========================================================================
   Minimal Mermaid Fullscreen Lightbox & Zoom Styles
   ========================================================================== */

.mermaid-interactive-container {
  position: relative;
  cursor: zoom-in;
  border-radius: 8px;
  padding: 8px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid transparent;
}

.mermaid-interactive-container:hover {
  border-color: var(--table-border-color, rgba(255, 180, 84, 0.3));
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.2);
}

/* Minimal Expand Icon */
.mermaid-expand-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--sidebar-bg, rgba(30, 30, 40, 0.9));
  border: 1px solid var(--table-border-color, rgba(255, 255, 255, 0.2));
  color: var(--fg, #e5e7eb);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: scale(0.9);
  z-index: 5;
  padding: 0;
}

.mermaid-interactive-container:hover .mermaid-expand-badge {
  opacity: 0.85;
  transform: scale(1);
}

.mermaid-expand-badge:hover {
  opacity: 1 !important;
  border-color: var(--theme-hover, #ffb454);
  color: var(--theme-hover, #ffb454);
}

/* Fullscreen Modal */
.mermaid-lightbox-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999999;
  display: none;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
}

.mermaid-lightbox-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1;
}

.mermaid-lightbox-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 2;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.mermaid-lightbox-canvas {
  transform-origin: center center;
  transition: transform 0.05s ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform;
}

/* Theme-Aware Lightbox Card */
.mermaid-lightbox-card {
  background: var(--bg, #1e1e2e);
  color: var(--fg, #ffffff);
  padding: 28px 36px;
  border-radius: 10px;
  border: 1px solid var(--table-border-color, rgba(255, 255, 255, 0.15));
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 90vw;
  max-height: 85vh;
}

.mermaid-lightbox-card svg {
  max-width: none !important;
  max-height: none !important;
}

/* Minimal Controls Pill */
.mermaid-lightbox-controls {
  position: absolute;
  top: 20px;
  right: 24px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--sidebar-bg, rgba(24, 24, 32, 0.95));
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--table-border-color, rgba(255, 255, 255, 0.15));
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.mermaid-btn {
  background: transparent;
  border: none;
  color: var(--fg, #d1d5db);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.mermaid-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--theme-hover, #ffb454);
}

.mermaid-btn-close:hover {
  background-color: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.mermaid-zoom-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg, #9ca3af);
  padding: 0 6px;
  min-width: 38px;
  text-align: center;
  font-family: monospace;
}
