/* Mermaid diagram viewer: toolbar, pan/zoom area and full screen layout. */

.diagram-viewer {
  margin: 1em 0;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 6px;
  background: var(--md-default-bg-color);
  display: flex;
  flex-direction: column;
}

.diagram-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--md-default-fg-color--lightest);
  font-size: 0.8rem;
}

.diagram-toolbar button {
  font: inherit;
  min-width: 2.2rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--md-default-fg-color--light);
  border-radius: 4px;
  background: var(--md-code-bg-color);
  color: var(--md-default-fg-color);
  cursor: pointer;
}

.diagram-toolbar button:hover {
  border-color: var(--md-accent-fg-color);
}

.diagram-hint {
  margin-left: auto;
  color: var(--md-default-fg-color--light);
}

.diagram-view {
  position: relative;
  height: 460px;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
  background-image: radial-gradient(var(--md-default-fg-color--lightest) 1px, transparent 1px);
  background-size: 16px 16px;
}

.diagram-viewer.is-tall .diagram-view {
  height: 780px;
}

.diagram-view.is-dragging {
  cursor: grabbing;
}

.diagram-stage {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}

.diagram-stage svg {
  display: block;
}

/* Full screen: the viewer fills the screen and the diagram area takes the rest. */
.diagram-viewer:fullscreen {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--md-default-bg-color);
}

.diagram-viewer:fullscreen .diagram-view,
.diagram-viewer.is-tall:fullscreen .diagram-view {
  flex: 1 1 auto;
  height: auto;
}

@media (max-width: 600px) {
  .diagram-view {
    height: 340px;
  }
  .diagram-hint {
    display: none;
  }
}
