/* Diagram presentation.
 *
 * In the page a diagram FITS the content column — Pele lays it out for the column's width, and
 * anything still wider is scaled down proportionally, never clipped and never scrolling. The
 * escape hatch for a diagram worth studying closely is `diagram-open.js`, which opens it full
 * size in its own tab where the browser's zoom and scroll apply. Colours: `pele-theme.css`.
 */

.diagram {
    padding: 0.5rem 0;
    margin: 1.5rem 0;

    /* Narrow diagrams sit centred in the column rather than hugging the left margin. */
    text-align: center;
}

.diagram-error {
    color: var(--warning-border, #c0392b);
    font-size: 0.85em;
    margin-bottom: 0.25rem;
}

.diagram svg {
    /* Fit the column, keep the aspect ratio. No horizontal scrollbar, nothing cut off. */
    max-width: 100%;
    height: auto;
}

/* ---- click to open the diagram in its own tab (diagram-open.js) ---------------------- */

div.diagram {
    cursor: zoom-in;
    position: relative;
}

div.diagram:focus-visible {
    outline: 2px solid var(--links, #4a90d9);
    outline-offset: 4px;
    border-radius: 4px;
}

/* A quiet affordance: the hint appears only on hover/focus, so it never competes with the
 * diagram itself. Hidden on touch, where there is no hover and the label would be a lie. */
div.diagram::after {
    content: "open in a new tab \2197";
    position: absolute;
    top: 0.25rem;
    right: 0.5rem;
    font-size: 0.72rem;
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
    pointer-events: none;
    color: var(--fg, #333);
    background: var(--bg, #fff);
    border: 1px solid var(--table-border-color, rgba(128, 128, 128, 0.35));
    border-radius: 3px;
    padding: 0.05rem 0.35rem;
}

div.diagram:hover::after,
div.diagram:focus-visible::after {
    opacity: 0.8;
}

@media (hover: none) {
    div.diagram::after { content: none; }
}
