/*
 * MatrixPets Core V3 — Shared Site Layout
 *
 * This file is intentionally loaded AFTER each selectable theme stylesheet.
 * It controls only shared page sizing / responsive structure, allowing every
 * theme to keep its own colours, typography and visual identity.
 */

:root {
    --mp-site-max-width: 1240px;
    --mp-site-gutter: 16px;
    --mp-sidebar-width: 230px;
    --mp-layout-gap: 16px;
}

/* Keep the logo/header, page body and footer on the same wide site grid. */
.mp-header-inner,
.mp-layout,
.mp-footer-inner {
    width: min(
        calc(100% - (var(--mp-site-gutter) * 2)),
        var(--mp-site-max-width)
    ) !important;
    max-width: var(--mp-site-max-width) !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Shared desktop sidebar + content structure. */
.mp-layout {
    display: flex !important;
    align-items: flex-start;
    gap: var(--mp-layout-gap) !important;
}

.mp-sidebar {
    flex: 0 0 var(--mp-sidebar-width);
    width: var(--mp-sidebar-width);
    max-width: var(--mp-sidebar-width);
}

.mp-main {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: none;
}

/*
 * Older pages often contain tables/images with hard-coded widths.
 * Prevent those from forcing the whole site wider than the viewport.
 */
.mp-main img {
    max-width: 100%;
}

.mp-main table {
    max-width: 100%;
}

/* Tablets and phones: stack the sidebar above the page content. */
@media (max-width: 760px) {
    :root {
        --mp-site-gutter: 10px;
    }

    .mp-layout {
        flex-direction: column !important;
    }

    .mp-sidebar,
    .mp-main {
        flex: 0 0 auto;
        width: 100% !important;
        max-width: none !important;
    }

    .mp-header-inner {
        width: min(
            calc(100% - (var(--mp-site-gutter) * 2)),
            var(--mp-site-max-width)
        ) !important;
    }
}

/* Very small phones get a little extra breathing room. */
@media (max-width: 420px) {
    :root {
        --mp-site-gutter: 6px;
    }
}