/* ==========================================================================
   Rich content blocks produced by MarkdownRenderer (Components/Cms/MarkdownRenderer.cs).

   Loaded on every page, so the public site (.site-prose) and the admin editor's preview render the
   same blocks the same way. Colours use currentColor / translucent tints, which keeps the blocks
   readable in the light and dark themes of both areas without separate overrides.

   Conventions:
   - media-left / media-right are PHYSICAL: the image sits on the left / right of the screen in both
     LTR and RTL pages, matching the toolbar button an author clicks. Text wraps around it.
   - Below 768px every block stacks to one column, image first, full width.
   ========================================================================== */

.md-media-left,
.md-media-right,
.md-columns-2,
.md-columns-3,
.md-callout-info,
.md-callout-warning,
.md-callout-tip {
    margin-block: 1.25rem;
}

/* ---- Images ---------------------------------------------------------------- */

.site-prose img,
.md-preview img,
.md-figure img {
    border-radius: 0.75rem;
    height: auto;
    max-width: 100%;
}

.md-figure {
    margin: 1.25rem 0;
    text-align: center;
}

.md-figure > p {
    margin: 0;
}

.md-figure figcaption {
    font-size: 0.85rem;
    margin-top: 0.5rem;
    opacity: 0.7;
}

/* ---- Image + text ------------------------------------------------------------- */

.md-media-left,
.md-media-right {
    display: flow-root; /* contains the floated image so following blocks never wrap around it */
}

.md-media-left > p:first-child,
.md-media-right > p:first-child {
    margin: 0;
    width: 40%;
}

.md-media-left.md-w-30 > p:first-child,
.md-media-right.md-w-30 > p:first-child { width: 30%; }
.md-media-left.md-w-40 > p:first-child,
.md-media-right.md-w-40 > p:first-child { width: 40%; }
.md-media-left.md-w-50 > p:first-child,
.md-media-right.md-w-50 > p:first-child { width: 50%; }

.md-media-left > p:first-child {
    float: left;
    margin-right: 1.5rem;
    margin-bottom: 0.75rem;
}

.md-media-right > p:first-child {
    float: right;
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.md-media-left > p:first-child img,
.md-media-right > p:first-child img {
    display: block;
    width: 100%;
}

/* ---- Columns --------------------------------------------------------------------- */

.md-columns-2,
.md-columns-3 {
    display: grid;
    gap: 1.5rem;
}

.md-columns-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.md-columns-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.md-col > :first-child { margin-top: 0; }
.md-col > :last-child { margin-bottom: 0; }

/* ---- Callouts ------------------------------------------------------------------------- */

.md-callout-info,
.md-callout-warning,
.md-callout-tip {
    border-inline-start: 4px solid var(--md-callout, #17a2b8);
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--md-callout, #17a2b8) 12%, transparent);
    padding: 0.9rem 1.1rem;
}

.md-callout-info { --md-callout: #17a2b8; }
.md-callout-warning { --md-callout: #f1a005; }
.md-callout-tip { --md-callout: #28a745; }

.md-callout-info > :first-child,
.md-callout-warning > :first-child,
.md-callout-tip > :first-child { margin-top: 0; }

.md-callout-info > :last-child,
.md-callout-warning > :last-child,
.md-callout-tip > :last-child { margin-bottom: 0; }

/* ---- Tables --------------------------------------------------------------------------- */

.site-prose table,
.md-preview table {
    border-collapse: collapse;
    display: block;
    margin-bottom: 1rem;
    max-width: 100%;
    overflow-x: auto;
}

.site-prose th,
.site-prose td,
.md-preview th,
.md-preview td {
    border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
    padding: 0.4rem 0.75rem;
}

.site-prose th,
.md-preview th {
    background: color-mix(in srgb, currentColor 7%, transparent);
}

/* ---- Responsive --------------------------------------------------------------------------- */

@media (max-width: 767.98px) {
    .md-columns-2,
    .md-columns-3 {
        grid-template-columns: 1fr;
    }

    .md-media-left > p:first-child,
    .md-media-right > p:first-child,
    .md-media-left.md-w-30 > p:first-child,
    .md-media-right.md-w-30 > p:first-child,
    .md-media-left.md-w-40 > p:first-child,
    .md-media-right.md-w-40 > p:first-child,
    .md-media-left.md-w-50 > p:first-child,
    .md-media-right.md-w-50 > p:first-child {
        float: none;
        margin-inline: 0;
        width: 100%;
    }
}
