/* Mermaid diagrams are clickable */

.mermaid {
  cursor: zoom-in;
}


/* Stop the page behind the viewer scrolling */

body.mermaid-zoom-open {
  overflow: hidden;
}


/* Full-screen viewer */

.mermaid-zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;

  display: flex;
  flex-direction: column;

  background: var(--md-default-bg-color);
}


/* Toolbar */

.mermaid-zoom-toolbar {
  flex: 0 0 auto;

  display: flex;
  align-items: center;
  gap: 1rem;

  min-height: 3.5rem;
  padding: 0.5rem 1rem;

  color: var(--md-default-fg-color);
  background: var(--md-default-bg-color);

  border-bottom: 1px solid var(--md-default-fg-color--lightest);
}

.mermaid-zoom-toolbar span {
  flex: 1;

  font-size: 0.8rem;
  opacity: 0.7;

  user-select: none;
}

.mermaid-zoom-toolbar button {
  padding: 0.4rem 0.8rem;

  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 0.25rem;

  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);

  font: inherit;

  cursor: pointer;
}

.mermaid-zoom-toolbar button:hover {
  background: var(--md-default-fg-color--lightest);
}

.mermaid-zoom-toolbar .mermaid-zoom-close {
  width: 2.5rem;
  height: 2.5rem;

  padding: 0;
  border: 0;

  background: transparent;

  font-size: 2rem;
  line-height: 1;
}


/* Pan/zoom viewport */

.mermaid-zoom-viewport {
  flex: 1 1 auto;

  display: flex;
  align-items: center;
  justify-content: center;

  min-width: 0;
  min-height: 0;

  overflow: hidden;

  background: var(--md-default-bg-color);

  cursor: grab;

  touch-action: none;
  user-select: none;
}

.mermaid-zoom-viewport.is-dragging {
  cursor: grabbing;
}


/* This whole stage is scaled and moved */

.mermaid-zoom-stage {
  display: flex;
  align-items: center;
  justify-content: center;

  padding: 2rem;

  background: var(--md-default-bg-color);

  transform-origin: center center;
  will-change: transform;
}


/*
 * This is the ORIGINAL Mermaid host element, moved from the document
 * into the viewer.
 */

.mermaid-zoom-stage > .mermaid {
  width: 90vw;
  max-width: 1600px;

  cursor: grab;
}


/* Mobile */

@media (max-width: 700px) {
  .mermaid-zoom-toolbar span {
    display: none;
  }

  .mermaid-zoom-toolbar {
    justify-content: flex-end;
  }

  .mermaid-zoom-stage {
    padding: 1rem;
  }

  .mermaid-zoom-stage > .mermaid {
    width: 95vw;
  }
}
