/* ==========================================================
   MBE Blog Layout -- fully responsive
   All styles scoped inside .mbe-post-wrap only.
   ========================================================== */

/* ---- Base wrap ---- */
.mbe-post-wrap {
    width: 100%;
    box-sizing: border-box;
}

.mbe-post-wrap *,
.mbe-post-wrap *::before,
.mbe-post-wrap *::after {
    box-sizing: border-box;
}

/* ---- Post body typography ---- */
.mbe-post-body {
    font-size: 1rem;
    line-height: 1.8;
    color: #333;
    word-break: break-word;
    overflow-wrap: break-word;
}

.mbe-post-body h2 {
    font-size: clamp(1.1rem, 3vw, 1.3rem);
    font-weight: 700;
    margin: 2em 0 0.6em;
    line-height: 1.3;
}

.mbe-post-body h3 {
    font-size: clamp(1rem, 2.5vw, 1.1rem);
    font-weight: 700;
    margin: 1.6em 0 0.5em;
    line-height: 1.3;
}

.mbe-post-body p {
    margin-bottom: 1em;
}

.mbe-post-body ul,
.mbe-post-body ol {
    padding-left: 1.4em;
    margin-bottom: 1em;
}

.mbe-post-body li {
    margin-bottom: 0.4em;
}

.mbe-post-body blockquote {
    border-left: 4px solid #d4a855;
    margin: 1.5em 0;
    padding: 0.8em 1em;
    background: #fdf8ef;
    border-radius: 0 6px 6px 0;
    font-style: italic;
    color: #555;
}

.mbe-post-body blockquote p {
    margin: 0;
}

.mbe-post-body a {
    color: #c47d2c;
    text-decoration: underline;
    word-break: break-all;
}

.mbe-post-body a:hover {
    color: #a05f18;
}

/* ---- Tables: scrollable on small screens ---- */
.mbe-post-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2em 0;
    font-size: 0.9rem;
}

.mbe-table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1.2em 0;
}

.mbe-table-scroll table {
    min-width: 480px;
    margin: 0;
}

.mbe-post-body th {
    background: #f5f0e8;
    font-weight: 700;
    padding: 8px 12px;
    text-align: left;
    border: 1px solid #e0d8cc;
    white-space: nowrap;
}

.mbe-post-body td {
    padding: 8px 12px;
    border: 1px solid #e8e0d0;
    vertical-align: top;
}

.mbe-post-body tr:nth-child(even) td {
    background: #faf7f2;
}

/* ==========================================================
   Images -- 3 states managed by JS orientation detection
   
   DEFAULT (before JS runs or if JS fails):
     Portrait card: capped at 320px, centred
     This prevents any image from being huge on first paint.
   
   After JS loads and reads naturalWidth/naturalHeight it adds:
     .mbe-image-landscape  -- wide photo, 1 column full width
     .mbe-image-portrait   -- tall card, solo centred
     .mbe-image-pair wrap  -- two tall cards, side by side
   ========================================================== */

/* Default: treat all figures as portrait-sized until JS decides */
.mbe-post-body figure.wp-block-image {
    display: block;
    margin: 1.2em auto;
    max-width: 320px;       /* safe cap -- prevents huge images before JS */
    border-radius: 8px;
    overflow: hidden;
}

.mbe-post-body figure.wp-block-image img {
    width: 100%;
    height: auto;           /* always natural aspect ratio */
    display: block;
    border-radius: 8px;
}

/* ---- Landscape: full content width, 1 column ---- */
figure.mbe-image-landscape {
    max-width: 100% !important;
    margin: 1.2em 0 !important;
}

figure.mbe-image-landscape img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
}

/* ---- Solo portrait: centred, max 340px ---- */
figure.mbe-image-portrait {
    max-width: 340px !important;
    margin: 1.2em auto !important;
}

figure.mbe-image-portrait img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
}

/* ---- Portrait pair: 2-column grid, equal height ---- */
.mbe-image-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 1.2em 0;
    align-items: start;
}

/* Reset figure styles inside the pair wrapper */
.mbe-image-pair figure.wp-block-image {
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 8px;
    overflow: hidden;
}

/* Equal height via aspect-ratio -- portrait 3:4 */
.mbe-image-pair figure.wp-block-image img {
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    object-position: top center;
    display: block;
    border-radius: 8px;
}

/* ---- Category footer ---- */
.mbe-post-footer {
    margin-top: 2em;
    padding-top: 1em;
    border-top: 1px solid #eee;
    font-size: 0.85rem;
    color: #888;
}

.mbe-post-footer a {
    color: #c47d2c;
    text-decoration: none;
}

/* ==========================================================
   Responsive breakpoints
   ========================================================== */

/* Tablet / large mobile */
@media (max-width: 600px) {
    .mbe-post-body {
        font-size: 0.97rem;
    }

    .mbe-post-body blockquote {
        padding: 0.6em 0.8em;
        margin: 1em 0;
    }

    .mbe-post-body ul,
    .mbe-post-body ol {
        padding-left: 1.1em;
    }

    /* Slightly narrower portrait cap on tablet */
    figure.mbe-image-portrait {
        max-width: 280px !important;
    }

    /* Pair images a bit shorter on tablet */
    .mbe-image-pair figure.wp-block-image img {
        aspect-ratio: 2 / 3;
    }
}

/* Small mobile: stack everything */
@media (max-width: 480px) {
    /* Portrait pairs stack to 1 column */
    .mbe-image-pair {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Stacked pair images: natural portrait ratio, no forced height */
    .mbe-image-pair figure.wp-block-image img {
        aspect-ratio: 3 / 4;
        object-fit: cover;
    }

    /* Solo portrait and default figures: full width on tiny screens */
    figure.mbe-image-portrait,
    .mbe-post-body figure.wp-block-image {
        max-width: 100% !important;
    }

    /* Landscape stays full width (already 100%) */
    figure.mbe-image-landscape {
        max-width: 100% !important;
    }
}
