/* MinecraftDocs — site overrides on top of mdBook's theme (book.toml: additional-css).
 *
 * Two problems this fixes, both found in pass 2's read of the live site:
 *  - mdBook's reading column is 750px, so any table with three or four
 *    columns of identifiers scrolled sideways even on a wide screen. Prose
 *    keeps a readable measure; tables, diagrams and figures may use the
 *    whole (wider) column.
 *  - Identifiers in table cells never wrapped, which is what pushed the
 *    tables over the edge in the first place.
 */

:root {
    /* The main column. Prose is capped separately below. */
    --content-max-width: 1100px;
    --prose-max-width: 800px;
}

/* Prose keeps a readable measure; everything is left-aligned inside the
 * (centred) main column so wide blocks extend to the right, not both ways. */
.content main > :not(.table-wrapper):not(pre):not(figure):not(.wide) {
    max-width: var(--prose-max-width);
}

/* Tables: use the room, wrap the cells, and stop padding each cell 20px a side. */
.content .table-wrapper {
    max-width: 100%;
}
.content table {
    margin: 0;
    max-width: 100%;
}
.content table td,
.content table th {
    padding: 3px 10px;
    vertical-align: top;
    white-space: normal;
}
.content table code {
    white-space: normal;
    overflow-wrap: anywhere;
}
/* Numeric columns stay right-aligned as the generators emit them. */
.content table td[align="right"],
.content table th[align="right"] {
    white-space: nowrap;
}

/* Diagrams: mermaid scales an SVG to its container, so a nine-lane sequence
 * diagram in a 750px column was unreadable. Let it have the full column. */
.content pre.mermaid {
    max-width: 100%;
    background: transparent;
    overflow-x: auto;
}

/* Click to enlarge (diagram-zoom.js): the overlay sits on the page's own
 * background so mermaid's light/dark palette still reads. */
.content pre.mermaid svg,
.content figure.map svg {
    cursor: zoom-in;
}
.content pre.mermaid::after {
    content: "click to enlarge";
    display: block;
    text-align: right;
    font-size: 0.75em;
    color: var(--icons);
    font-family: inherit;
}
.diagram-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
.diagram-lightbox-panel {
    box-sizing: border-box;
    width: 96vw;
    max-height: 96vh;
    overflow: auto;
    padding: 1em;
    border-radius: 6px;
    background: var(--bg);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}
.diagram-lightbox-panel svg {
    display: block;
    width: 100%;
    height: auto;
    max-width: none !important;
    max-height: 90vh;
}

/* Generated figures (inline SVG from tools/, see pass 3): full column,
 * text in the theme's foreground colour. */
.content figure.map,
.content .wide {
    max-width: 100%;
    margin: 1em 0;
}
.content figure.map svg {
    max-width: 100%;
    height: auto;
    color: var(--fg);
}

/* The atlas's generated figures (tools/map_source.py → src/generated/*.svg,
 * pass-3 session B). The SVG carries classes only; every colour lives here so
 * the five themes and the zoom overlay all read. Text is currentColor. */
:root {
    --map-shared: #3b7dd8;
    --map-client: #e0862e;
    --map-lib: #8f8f8f;
}
.coal, .navy, .ayu {
    --map-shared: #6aa6ee;
    --map-client: #f0a24a;
    --map-lib: #a0a0a0;
}
svg.mapfig {
    font-family: inherit;
    color: var(--fg);
    display: block;
}
svg.mapfig text {
    fill: currentColor;
}
svg.mapfig .muted {
    opacity: 0.65;
}
svg.mapfig .fold {
    opacity: 0.65;
    font-style: italic;
}
svg.mapfig rect.shared { fill: var(--map-shared); fill-opacity: 0.55; }
svg.mapfig rect.client { fill: var(--map-client); fill-opacity: 0.55; }
svg.mapfig rect.lib    { fill: var(--map-lib);    fill-opacity: 0.55; }
svg.mapfig rect.skip   { fill: url(#mapfig-hatch); }
svg.mapfig .hatch      { stroke: currentColor; stroke-width: 1; opacity: 0.35; }
svg.mapfig g.cell rect.shared,
svg.mapfig g.cell rect.client {
    stroke: var(--bg);
    stroke-width: 1;
}
svg.mapfig rect.group {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
}
svg.mapfig .edge {
    fill: none;
    stroke: currentColor;
    stroke-width: 1;
    opacity: 0.45;
}
.content figure.map {
    max-width: 100%;
    margin: 1.5em 0;
}
.content figure.map figcaption {
    font-size: 0.85em;
    color: var(--icons);
    margin-top: 0.4em;
}

/* The licence and disclaimer footer (site-footer.js): quiet, and out of the
   way of the prose it follows. */
.content footer.site-footer {
    max-width: 800px;
    margin: 3.5em auto 0;
    padding-top: 1.2em;
    border-top: 1px solid var(--table-border-color, currentColor);
    font-size: 0.8em;
    color: var(--icons);
}
.content footer.site-footer p {
    margin: 0.4em 0;
}
