/*
 * WBMerit 2.3.46 — professional compatibility layer.
 * Kept separate from the legacy visual layer so future maintenance can be done
 * without changing the established WBMerit design.
 */

/* Never impose a border color on every element. Plugin controls and block UI
 * should retain their own border tokens. */

/* Core content safety without changing plugin layouts. */
.wbmerit-theme .entry-content,
.wbmerit-theme .entry-content > * { min-width: 0; }
.wbmerit-theme .entry-content img,
.wbmerit-theme .entry-content video,
.wbmerit-theme .entry-content iframe,
.wbmerit-theme .entry-content embed,
.wbmerit-theme .entry-content object { max-width: 100%; }
.wbmerit-theme .entry-content table { max-width: 100%; }

/* Gutenberg: do not force columns to one width or rewrite block display rules. */
.wbmerit-theme .wp-block-columns,
.wbmerit-theme .wp-block-column,
.wbmerit-theme .wp-block-group,
.wbmerit-theme .wp-block-cover,
.wbmerit-theme .wp-block-media-text { min-width: 0; }
.wbmerit-theme .wp-block-image img,
.wbmerit-theme .wp-block-gallery img { max-width: 100%; height: auto; }
.wbmerit-theme .wp-block-embed__wrapper { max-width: 100%; }

/* Keyboard focus: visible, theme-consistent and low-specificity. */
.wbmerit-theme a:focus-visible,
.wbmerit-theme button:focus-visible,
.wbmerit-theme input:focus-visible,
.wbmerit-theme textarea:focus-visible,
.wbmerit-theme select:focus-visible,
.wbmerit-theme summary:focus-visible {
    outline: 3px solid rgba(245,183,25,.72);
    outline-offset: 2px;
}

/* Mobile drawer accessibility states. */
#wbm-mobile-drawer[aria-hidden="true"] { visibility: hidden; }
#wbm-mobile-drawer[aria-hidden="false"] { visibility: visible; }
.wbm-submenu-toggle { flex: 0 0 42px; min-width: 42px; }
.wbm-submenu-toggle:focus-visible { outline-offset: -2px; }

/* Forms: only the theme's own content areas are scoped. */
.wbmerit-theme .site-main .button,
.wbmerit-theme .site-main input[type="submit"],
.wbmerit-theme .site-main input[type="button"] { max-width: 100%; }

/* Reduced-motion support for the compatibility layer. */
@media (prefers-reduced-motion: reduce) {
    .wbmerit-theme *,
    .wbmerit-theme *::before,
    .wbmerit-theme *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* WBMerit v2.3.48 — definitive full-image thumbnail fix
 * Loaded after style.css and legacy.css. Thumbnail containers may keep their
 * layout dimensions, but the actual image is constrained by BOTH dimensions.
 * This prevents text/edges from ever being cropped or stretched.
 */
.post-thumb,
.post-list-thumb,
.wbm-horizontal-post-card > .post-thumb,
.wbm-horizontal-post-card > .wbm-card-thumb,
.wbm-related-thumb {
    display:flex !important;
    align-items:center !important;
    justify-content:center !important;
    overflow:hidden !important;
}

.post-thumb img,
.post-list-thumb img,
.wbm-horizontal-post-card > .post-thumb img,
.wbm-horizontal-post-card > .wbm-card-thumb img,
.wbm-related-thumb img {
    display:block !important;
    width:auto !important;
    height:auto !important;
    max-width:100% !important;
    max-height:100% !important;
    min-width:0 !important;
    min-height:0 !important;
    object-fit:contain !important;
    object-position:center center !important;
    flex:0 1 auto !important;
    margin:0 auto !important;
}

/* Keep the placeholder centered without affecting real thumbnails. */
.post-thumb > span,
.post-list-thumb > span,
.wbm-related-thumb-placeholder {
    display:grid !important;
    place-items:center !important;
    width:100% !important;
    height:100% !important;
}

/* WBMerit v2.3.50 — Related Study Materials: single authoritative layout.
 * The card owns the outer gutter. The thumbnail owns only its inner image gutter.
 * This avoids conflicting margin/padding rules and keeps the complete image visible.
 */
.wbm-related-card{
    display:flex !important;
    align-items:stretch !important;
    min-width:0 !important;
    min-height:118px !important;
    box-sizing:border-box !important;
    padding:8px !important;
    gap:12px !important;
    overflow:hidden !important;
    border:1px solid var(--line) !important;
    border-radius:13px !important;
    background:#fff !important;
}
.wbm-related-card > .wbm-related-thumb{
    display:flex !important;
    align-items:center !important;
    justify-content:center !important;
    flex:0 0 132px !important;
    width:132px !important;
    min-width:132px !important;
    min-height:100px !important;
    height:auto !important;
    margin:0 !important;
    padding:6px !important;
    box-sizing:border-box !important;
    overflow:hidden !important;
    border-radius:9px !important;
    background:#eef4f8 !important;
}
.wbm-related-card > .wbm-related-thumb img{
    display:block !important;
    width:auto !important;
    height:auto !important;
    max-width:100% !important;
    max-height:100% !important;
    min-width:0 !important;
    min-height:0 !important;
    margin:0 !important;
    object-fit:contain !important;
    object-position:center center !important;
}
.wbm-related-card > .wbm-related-body{
    display:flex !important;
    flex:1 1 auto !important;
    min-width:0 !important;
    padding:4px 5px !important;
    box-sizing:border-box !important;
}
@media(max-width:620px){
    .wbm-related-card{
        min-height:100px !important;
        padding:6px !important;
        gap:9px !important;
        border-radius:11px !important;
    }
    .wbm-related-card > .wbm-related-thumb{
        flex:0 0 104px !important;
        width:104px !important;
        min-width:104px !important;
        min-height:88px !important;
        padding:5px !important;
    }
    .wbm-related-card > .wbm-related-body{
        padding:3px 2px !important;
    }
}

