/* PlantUML diagrams: each renders in a light and a dark variant, and the book shows the one that matches its theme */

.diagram {
    margin: 1.5em 0;
    text-align: center;
}

.diagram a {
    display: inline-block;
}

/* Without JavaScript, wide diagrams scale to the column and the link opens the full-size SVG */
.diagram img {
    max-width: 100%;
    height: auto;
}

.light .diagram .diagram-dark,
.rust .diagram .diagram-dark {
    display: none;
}

.coal .diagram .diagram-light,
.navy .diagram .diagram-light,
.ayu .diagram .diagram-light {
    display: none;
}

/* Viewer from diagrams.js: a framed viewport the diagram pans and zooms inside */
.diagram-viewer {
    display: block;
    text-align: start;
}

.diagram-viewport {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--table-border-color);
    border-radius: 4px;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.diagram-viewport:focus-visible {
    outline: 2px solid var(--links);
    outline-offset: 2px;
}

.diagram-viewport.diagram-dragging {
    cursor: grabbing;
}

.diagram .diagram-viewport img {
    position: absolute;
    top: 0;
    left: 0;
    max-width: none;
    transform-origin: 0 0;
    pointer-events: none;
}

.diagram-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4em;
    margin-top: 0.4em;
    font-size: 0.85em;
}

.diagram .diagram-button {
    display: inline-block;
    min-width: 2.2em;
    padding: 0.15em 0.6em;
    border: 1px solid var(--table-border-color);
    border-radius: 4px;
    background-color: var(--table-alternate-bg);
    color: var(--fg);
    font: inherit;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.diagram .diagram-button:hover {
    border-color: var(--links);
    color: var(--links);
}

.diagram-hint {
    color: var(--icons);
}
