/* Zoomable viewer for Mermaid diagrams. Behavior is in javascripts/mermaid-expand.js. */

div.mermaid {
  cursor: zoom-in;
}

/* Copy / SVG / PNG buttons over the corner of each diagram. */
.mermaid-frame {
  position: relative;
}

/* Zero-height and sticky, so the buttons stay in view while you scroll through a tall diagram. */
.mermaid-actions {
  position: sticky;
  top: 5.2rem;
  z-index: 2;
  height: 0;
  text-align: right;
  opacity: 0;
  transition: opacity 0.15s;
}

.mermaid-frame:hover .mermaid-actions,
.mermaid-frame:focus-within .mermaid-actions {
  opacity: 1;
}

/* No hover on touch screens, so keep the buttons visible there. */
@media (hover: none) {
  .mermaid-actions {
    opacity: 1;
  }
}

.mermaid-action {
  min-width: 2.6rem;
  margin: 0.2rem 0 0 0.2rem;
  height: 1.6rem;
  padding: 0 0.5rem;
  border: 1px solid var(--md-default-fg-color--lighter, rgba(128, 128, 128, 0.4));
  border-radius: 0.1rem;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  font-size: 0.65rem;
  line-height: 1;
  cursor: pointer;
}

.mermaid-action:hover,
.mermaid-action:focus-visible {
  border-color: var(--md-accent-fg-color);
  color: var(--md-accent-fg-color);
}

.mermaid-action--toolbar {
  height: 2rem;
  border-color: transparent;
}

div.mermaid:focus-visible {
  outline: 2px solid var(--md-accent-fg-color);
  outline-offset: 4px;
}

/* The open diagram is positioned and scaled from the top-left corner; the script sets its size and transform. */
div.mermaid.mermaid-expanded {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1001;
  box-sizing: border-box;
  padding: 16px;
  border-radius: 0.2rem;
  background: var(--md-default-bg-color);
  box-shadow: 0 0.4rem 2rem rgba(0, 0, 0, 0.4);
  cursor: grab;
  transform-origin: 0 0;
  touch-action: none;
  user-select: none;
}

div.mermaid.mermaid-expanded.mermaid-dragging {
  cursor: grabbing;
}

.mermaid-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  cursor: grab;
  touch-action: none;
}

.mermaid-toolbar {
  position: fixed;
  top: 0.8rem;
  right: 0.8rem;
  z-index: 1002;
  display: flex;
  gap: 0.2rem;
  padding: 0.2rem;
  border-radius: 0.2rem;
  background: var(--md-default-bg-color);
  box-shadow: 0 0.2rem 0.8rem rgba(0, 0, 0, 0.4);
}

.mermaid-tool {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 0.1rem;
  background: transparent;
  color: var(--md-default-fg-color);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.mermaid-tool:hover,
.mermaid-tool:focus-visible {
  background: var(--md-accent-fg-color--transparent, rgba(128, 128, 128, 0.2));
  color: var(--md-accent-fg-color);
}

html.mermaid-expand-open {
  overflow: hidden;
}
