/**
 * pb-designer-front.css
 * Applied on the frontend when a pb_designer page is served.
 * Ensures the design wrapper can be full-width even inside a constrained theme.
 */

/* Full-bleed escape for designs that need it */
#pb-designer-output {
    position: relative;
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    overflow-x: hidden;
}

/* Reset so theme's Bootstrap grid/font-size doesn't bleed into GrapesJS blocks */
.pb-design {
    all: initial;
    display: block;
    font-family: inherit;
    --pb-fluid-base-min: 16px;
    --pb-fluid-base-max: 18px;
    --pb-min-body-text: 16px;
    --pb-min-small-text: 14px;
    --pb-min-h1: 30px;
    --pb-min-h2: 26px;
    --pb-min-h3: 22px;
    --pb-min-h4: 20px;
    --pb-min-h5: 18px;
    --pb-min-h6: 16px;
    font-size: clamp(var(--pb-fluid-base-min), 0.95rem + 0.35vw, var(--pb-fluid-base-max));
    line-height: 1.5;
    color: #212529;
    box-sizing: border-box;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
.pb-design * {
    box-sizing: border-box;
}

/* Fluid typography defaults — use 1em so GrapesJS user CSS can always override */
.pb-design :where(p, li, a, label, input, textarea, button, select, td, th, blockquote, figcaption) {
    font-size: 1em;
}

.pb-design :where(small) {
    font-size: 0.875em;
}

.pb-design :where(h1) { font-size: 2em; }
.pb-design :where(h2) { font-size: 1.5em; }
.pb-design :where(h3) { font-size: 1.17em; }
.pb-design :where(h4) { font-size: 1em; }
.pb-design :where(h5) { font-size: 0.83em; }
.pb-design :where(h6) { font-size: 0.67em; }

/* Laptop / tablet landscape */
@media (max-width: 1200px) {
    .pb-design {
        --pb-fluid-base-min: 15px;
        --pb-fluid-base-max: 17px;
        --pb-min-body-text: 15px;
        --pb-min-small-text: 13px;
        --pb-min-h1: 28px;
        --pb-min-h2: 24px;
        --pb-min-h3: 21px;
        --pb-min-h4: 19px;
        --pb-min-h5: 17px;
        --pb-min-h6: 15px;
    }
}

/* Tablet / large mobile */
@media (max-width: 992px) {
    .pb-design {
        --pb-fluid-base-min: 15px;
        --pb-fluid-base-max: 16px;
        --pb-min-body-text: 15px;
        --pb-min-small-text: 13px;
        --pb-min-h1: 26px;
        --pb-min-h2: 23px;
        --pb-min-h3: 20px;
        --pb-min-h4: 18px;
        --pb-min-h5: 16px;
        --pb-min-h6: 15px;
    }
}

/* Mobile */
@media (max-width: 576px) {
    .pb-design {
        --pb-fluid-base-min: 14px;
        --pb-fluid-base-max: 15px;
        --pb-min-body-text: 14px;
        --pb-min-small-text: 12px;
        --pb-min-h1: 24px;
        --pb-min-h2: 21px;
        --pb-min-h3: 18px;
        --pb-min-h4: 17px;
        --pb-min-h5: 15px;
        --pb-min-h6: 14px;
    }
}

/* Ensure images inside designs are responsive by default */
.pb-design img {
    max-width: 100%;
    height: auto;
}

/* ── Video responsive wrapper ─────────────────────────────────── */
.pb-video-wrap { width: 100%; box-sizing: border-box; }
.pb-video-wrap > div { position: relative; overflow: hidden; }
.pb-video-wrap video,
.pb-video-wrap iframe {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%; border: none;
}

/* ── Global overflow guard ────────────────────────────────────── */
.pb-design { overflow-x: hidden; }
.pb-design * { max-width: 100%; box-sizing: border-box; }
.pb-design img, .pb-design video, .pb-design iframe { max-width: 100%; height: auto; }

/* ── Mobile column stacking ───────────────────────────────────── */
@media (max-width: 768px) {
    .pb-design [data-pb-type="pb-row"] {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: unset !important;
    }
    .pb-design [data-pb-type="pb-col"] {
        width: 100% !important;
        min-width: 0 !important;
    }
    .pb-design section {
        padding-left: 14px !important;
        padding-right: 14px !important;
    }
}
