/* ═══════════════════════════════════════
   VIMISS Frontend Content Styles
═══════════════════════════════════════ */

/* ── Fix horizontal scroll (dùng clip thay hidden để không break position:sticky) ── */
html {
    overflow-x: clip; /* clip: chặn scroll ngang, không tạo stacking context */
}
body {
    overflow-x: clip;
    max-width: 100%;
}
.wp-block-post-content {
    overflow-x: clip;
    max-width: 100%;
}

.wp-block-post-content img:not(.vm-post-card__img),
.wp-block-post-content figure {
    max-width: 100% !important;
    height: auto;
    box-sizing: border-box;
}

.wp-block-post-content .vm-post-card__img,
.wp-block-post-content .vm-post-card__thumb img {
    position: absolute !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 100% !important;
    min-height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
}

/* ── Blockquote ── */
.wp-block-post-content blockquote,
.entry-content blockquote,
body blockquote {
    display: block;
    margin: 1.4em 0 !important;
    padding: 8px 16px 8px 18px !important;
    border-left: 4px solid #ccc !important;
    border-top: none !important;
    border-right: none !important;
    border-bottom: none !important;
    background: #fbfbfb !important;
    border-radius: 0 4px 4px 0 !important;
    color: #555 !important;
    font-style: italic !important;
    line-height: 1.75;
}

.wp-block-post-content blockquote p,
.entry-content blockquote p,
body blockquote p {
    margin: 0 !important;
}

/* ── Figures / CKEditor image ── */
figure.image {
    margin: 1.2em auto;
    max-width: 100%;
    overflow: hidden;
}

figure.image img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    display: block;
    margin: 0 auto;
}

.image-style-align-center {
    text-align: center;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* ── Tables ── */
figure.table,
.wp-block-table {
    display: block !important;
    float: none !important;
    clear: both !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1.4em 0 !important;
    box-sizing: border-box !important;
}

.wp-block-post-content table,
figure.table table {
    width: 100% !important;
    max-width: 100% !important;
    border-collapse: collapse;
    margin: 0;
    font-size: 14px;
    table-layout: auto;
    word-break: normal;
    overflow-wrap: anywhere;
    float: none !important;
    clear: both !important;
}

.wp-block-post-content table th,
.wp-block-post-content table td,
figure.table table th,
figure.table table td {
    border: 1px solid #dcdcde;
    padding: 8px 12px;
    text-align: left;
}

.wp-block-post-content table th {
    background: #f6f7f7;
    font-weight: 600;
}

/* ── vimiss_option shortcode output ── */
body .vimiss-option-content,
body .vimiss-option-content * {
    font-size: var(--wp--preset--font-size--small) !important;
    line-height: 1.7 !important;
    color: #ffffff !important;
}

body .vimiss-option-content a {
    color: #ffffff !important;
}

body .vimiss-option-content h4 {
    margin: 0 0 8px 0 !important;
    font-weight: 700;
    color: #ffffff !important;
}

body .vimiss-option-content p {
    margin: 0 0 4px 0 !important;
    color: #ffffff !important;
}

/* Ẩn page-break block từ CKEditor cũ */
body .vimiss-option-content .page-break {
    display: none !important;
}

/* ── Mobile Layout & Content Padding Optimization (<= 991.98px) ── */
@media screen and (max-width: 991.98px) {
    /* 1. Header */
    header.wp-block-template-part > .wp-block-group,
    header > .wp-block-group {
        padding-left: 14px !important;
        padding-right: 14px !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }
    header.wp-block-template-part .wp-block-group.alignfull.is-content-justification-space-between,
    header.wp-block-template-part .wp-block-group.alignfull.is-layout-flex,
    header .wp-block-group.alignfull.is-layout-flex {
        padding: 8px 0 !important;
        gap: 8px !important;
        align-items: center !important;
    }
    header.wp-block-template-part .wp-block-group.has-global-padding {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    header.wp-block-template-part .wp-block-group.is-horizontal,
    header.wp-block-template-part .wp-block-group.is-content-justification-right {
        margin-left: auto !important;
        margin-right: 0 !important;
        gap: 8px !important;
        flex-shrink: 0 !important;
    }
    header.wp-block-template-part .wp-block-button__link,
    header .wp-block-button__link {
        padding: 6px 13px !important;
        font-size: 13px !important;
        line-height: 1.25 !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }

    /* 2. Global Content Containers */
    .has-global-padding,
    .entry-content,
    .wp-block-post-content,
    main#wp--skip-link--target,
    .wp-site-blocks > .wp-block-group:not(header *) {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* 3. Content Section Groups & Columns (Overriding inline 30px-50px padding with clean 14px) */
    .wp-block-group.alignfull:not(header *),
    .wp-block-columns.alignfull,
    .entry-content .wp-block-group.alignfull,
    .wp-block-post-content .wp-block-group.alignfull,
    main .wp-block-group.alignfull,
    main .wp-block-columns.alignfull {
        padding-left: 14px !important;
        padding-right: 14px !important;
    }

    .entry-content > :not(.alignfull),
    .wp-block-post-content > :not(.alignfull),
    main > :not(.alignfull) {
        padding-left: 14px !important;
        padding-right: 14px !important;
        box-sizing: border-box !important;
    }

    /* Spacing between header and first content section */
    main#wp--skip-link--target,
    .entry-content > :first-child,
    .wp-site-blocks > .wp-block-group:not(header):first-of-type {
        margin-top: 14px !important;
    }
}

/* Extra fine-tuning for compact mobile phones (<= 576px) */
@media screen and (max-width: 576px) {
    header.wp-block-template-part > .wp-block-group,
    header > .wp-block-group {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    header.wp-block-template-part .wp-block-group.alignfull.is-content-justification-space-between,
    header.wp-block-template-part .wp-block-group.alignfull.is-layout-flex,
    header .wp-block-group.alignfull.is-layout-flex {
        padding-top: 6px !important;
        padding-bottom: 6px !important;
    }

    /* Content sections on phones */
    .wp-block-group.alignfull:not(header *),
    .wp-block-columns.alignfull,
    .entry-content .wp-block-group.alignfull,
    .wp-block-post-content .wp-block-group.alignfull,
    main .wp-block-group.alignfull,
    main .wp-block-columns.alignfull {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .entry-content > :not(.alignfull),
    .wp-block-post-content > :not(.alignfull),
    main > :not(.alignfull) {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    main#wp--skip-link--target,
    .entry-content > :first-child,
    .wp-site-blocks > .wp-block-group:not(header):first-of-type {
        margin-top: 10px !important;
    }
}