/*
 * Casefront responsive safety layer.
 *
 * This stylesheet deliberately loads after theme and generated manager CSS.
 * It contains only layout safety rules, not brand styling. The goal is to
 * prevent desktop preset rules or custom section CSS from forcing horizontal
 * overflow or unusably narrow columns on tablets and phones.
 */

html,
body {
    max-width: 100%;
}

body {
    overflow-x: clip;
}

.cf-managed-homepage,
.cf-managed-product-page,
.cf-site-header,
.cf-site-main,
.cf-site-footer {
    max-width: 100%;
    overflow-x: clip;
}

.cf-managed-homepage *,
.cf-managed-product-page *,
.cf-site-header * {
    min-width: 0;
}

.cf-managed-homepage img,
.cf-managed-product-page img,
.cf-managed-homepage video,
.cf-managed-product-page video,
.cf-managed-homepage iframe,
.cf-managed-product-page iframe {
    max-width: 100%;
}

.cf-managed-homepage h1,
.cf-managed-homepage h2,
.cf-managed-homepage h3,
.cf-managed-homepage h4,
.cf-managed-product-page h1,
.cf-managed-product-page h2,
.cf-managed-product-page h3,
.cf-managed-product-page h4,
.cf-managed-homepage p,
.cf-managed-product-page p,
.cf-managed-homepage li,
.cf-managed-product-page li {
    overflow-wrap: break-word;
    word-break: normal;
}

@media (max-width: 1100px) {
    .cf-pack-card-grid,
    .cf-pack-steps,
    .cf-ebook-card-grid,
    .cf-ebook-steps,
    .cf-managed-card-grid,
    .cf-managed-steps,
    .cf-product-content-grid,
    .cf-product-steps,
    .cf-product-audience-grid,
    .cf-product-review-grid,
    .cf-product-service-grid,
    .cf-shop-product-grid,
    .cf-shop-category-grid,
    .cf-patriotic-trust {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 1024px) {
    /* Header: logo + hamburger + cart. Desktop CTA moves out of the way. */
    .cf-site-header__inner {
        position: relative;
        grid-template-columns: minmax(0, 1fr) auto auto !important;
        gap: .55rem !important;
    }

    .cf-site-branding {
        width: auto;
        max-width: 100%;
        overflow: hidden;
        transform: none !important;
    }

    .cf-brand,
    .cf-brand-image,
    .custom-logo-link {
        max-width: 100%;
    }

    .cf-brand img,
    .cf-brand-image img,
    .custom-logo-link img {
        width: auto !important;
        max-width: min(var(--cf-logo-max-width), 52vw) !important;
        max-height: min(var(--cf-logo-max-height), 58px) !important;
    }

    .cf-nav-toggle {
        display: inline-flex !important;
        grid-column: 2;
        justify-self: end;
        flex: 0 0 44px;
    }

    .cf-nav {
        position: absolute !important;
        z-index: 120;
        top: 100% !important;
        right: calc(var(--cf-side-padding) * -1) !important;
        left: calc(var(--cf-side-padding) * -1) !important;
        display: none !important;
        width: auto !important;
        max-height: min(70vh, 560px);
        overflow-y: auto;
        padding: .75rem var(--cf-side-padding) 1rem !important;
        border-bottom: 1px solid var(--cf-border);
        background: rgba(var(--cf-header-rgb), .985) !important;
        box-shadow: var(--cf-shadow-md);
        backdrop-filter: blur(16px);
    }

    .cf-nav.is-open {
        display: block !important;
    }

    .cf-nav ul,
    .cf-nav .menu {
        display: flex !important;
        width: 100% !important;
        max-width: var(--cf-container);
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0 !important;
        margin-inline: auto !important;
    }

    .cf-nav li {
        width: 100%;
    }

    .cf-nav a {
        display: block !important;
        width: 100%;
        padding: .72rem .15rem !important;
    }

    .cf-header-actions {
        grid-column: 3;
        justify-self: end;
        gap: .35rem !important;
    }

    .cf-site-header .cf-header-cta {
        display: none !important;
    }

    .cf-cart-link {
        min-width: 44px;
        min-height: 44px;
        justify-content: center;
    }

    .cf-cart-link__label {
        display: none !important;
    }
}

@media (max-width: 900px) {
    /* Every built-in two-column Casefront composition becomes a real stack. */
    .cf-managed-hero,
    .cf-managed-media-copy,
    .cf-managed-purchase,
    .cf-ebook-hero,
    .cf-ebook-split,
    .cf-ebook-author,
    .cf-ebook-results,
    .cf-ebook-final,
    .cf-pack-hero,
    .cf-pack-inside,
    .cf-pack-authority,
    .cf-pack-results,
    .cf-pack-final,
    .cf-product-hero,
    .cf-product-story,
    .cf-product-final-cta,
    .cf-ebook-product-hero,
    .cf-media-layout,
    .cf-media-layout--left,
    .cf-media-layout--right,
    .cf-patriotic-hero,
    .cf-patriotic-story,
    .cf-shop-rotator__slide {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .cf-pack-hero,
    .cf-managed-hero,
    .cf-ebook-hero {
        min-height: 0 !important;
    }

    .cf-pack-hero__media,
    .cf-pack-inside figure,
    .cf-pack-authority figure,
    .cf-product-hero__media,
    .cf-managed-hero__media,
    .cf-ebook-hero__media {
        order: -1;
    }

    .cf-media-layout .cf-media-layout__media,
    .cf-media-layout .cf-media-layout__content {
        float: none !important;
        width: auto !important;
        max-width: 100% !important;
        margin: 0 !important;
    }

    .cf-media-layout--mobile-image-first .cf-media-layout__media {
        order: 1 !important;
    }

    .cf-media-layout--mobile-image-first .cf-media-layout__content {
        order: 2 !important;
    }

    .cf-media-layout--mobile-text-first .cf-media-layout__media {
        order: 2 !important;
    }

    .cf-media-layout--mobile-text-first .cf-media-layout__content {
        order: 1 !important;
    }

    .cf-managed-homepage table,
    .cf-managed-product-page table {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 760px) {
    .cf-pack-card-grid,
    .cf-pack-card-grid--three,
    .cf-pack-steps,
    .cf-pack-reviews,
    .cf-pack-stat-grid,
    .cf-pack-trust,
    .cf-ebook-trust,
    .cf-ebook-card-grid,
    .cf-ebook-card-grid--three,
    .cf-ebook-steps,
    .cf-ebook-stat-grid,
    .cf-managed-card-grid,
    .cf-managed-steps,
    .cf-managed-reviews,
    .cf-managed-review-grid,
    .cf-managed-trust,
    .cf-product-content-grid,
    .cf-product-trust,
    .cf-product-steps,
    .cf-product-audience-grid,
    .cf-product-review-grid,
    .cf-product-service-grid,
    .cf-product-gallery,
    .cf-shop-product-grid,
    .cf-shop-category-grid,
    .cf-patriotic-trust {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .cf-pack-trust,
    .cf-ebook-trust,
    .cf-managed-trust,
    .cf-product-trust {
        overflow: visible !important;
    }

    .cf-pack-trust > div,
    .cf-ebook-trust > div,
    .cf-managed-trust > div,
    .cf-product-trust > div {
        border-right: 0 !important;
        border-bottom: 1px solid var(--cf-border);
    }

    .cf-pack-trust > div:last-child,
    .cf-ebook-trust > div:last-child,
    .cf-managed-trust > div:last-child,
    .cf-product-trust > div:last-child {
        border-bottom: 0;
    }

    .cf-managed-section,
    .cf-product-section {
        padding-top: var(--cf-section-space-mobile) !important;
        padding-bottom: var(--cf-section-space-mobile) !important;
    }

    .cf-managed-section--template-banner,
    .cf-product-section--template-banner {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    .cf-pack-results,
    .cf-pack-final,
    .cf-ebook-results,
    .cf-ebook-final,
    .cf-product-final-cta {
        padding: clamp(1.25rem, 5vw, 2rem) !important;
    }

    .cf-pack-card,
    .cf-pack-steps article,
    .cf-pack-reviews blockquote,
    .cf-managed-card,
    .cf-product-content-card {
        padding: clamp(1.2rem, 5vw, 1.65rem) !important;
    }

    .cf-managed-homepage h1,
    .cf-managed-product-page h1 {
        font-size: clamp(2.15rem, 10vw, 3.15rem) !important;
        line-height: 1.02 !important;
    }

    .cf-managed-homepage h2,
    .cf-managed-product-page h2 {
        font-size: clamp(1.8rem, 8vw, 2.55rem) !important;
        line-height: 1.08 !important;
    }

    .cf-managed-homepage h3,
    .cf-managed-product-page h3 {
        font-size: clamp(1.3rem, 6vw, 1.75rem) !important;
        line-height: 1.16 !important;
    }

    .cf-section__header {
        max-width: 100% !important;
        margin-bottom: clamp(1.5rem, 6vw, 2.2rem) !important;
    }

    .cf-managed-actions,
    .cf-hero__actions {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .cf-managed-actions .cf-button,
    .cf-hero__actions .cf-button,
    .cf-product-final-cta__action .cf-button,
    .cf-pack-final__action .cf-button {
        width: 100%;
    }

    .cf-pack-chapters li,
    .cf-ebook-chapters li {
        grid-template-columns: 2.25rem minmax(0, 1fr) !important;
        gap: .65rem !important;
    }

    .cf-product-section .cart,
    .cf-product-section form.cart {
        max-width: 100%;
    }
}

@media (max-width: 560px) {
    .cf-site-header__inner {
        min-height: clamp(68px, var(--cf-header-height), 88px) !important;
        gap: .4rem !important;
    }

    .cf-brand img,
    .cf-brand-image img,
    .custom-logo-link img {
        max-width: min(var(--cf-logo-max-width), 50vw) !important;
        max-height: min(var(--cf-logo-max-height), 50px) !important;
    }

    .cf-nav-toggle,
    .cf-cart-link {
        width: 42px;
        min-width: 42px;
        height: 42px;
        min-height: 42px;
    }

    .cf-managed-homepage .cf-container,
    .cf-managed-product-page .cf-container,
    .cf-media-layout {
        width: min(calc(100% - 32px), var(--cf-container)) !important;
    }

    .cf-pack-hero,
    .cf-pack-inside,
    .cf-pack-authority,
    .cf-pack-results,
    .cf-pack-final,
    .cf-ebook-hero,
    .cf-ebook-split,
    .cf-ebook-author,
    .cf-ebook-results,
    .cf-ebook-final,
    .cf-product-hero,
    .cf-product-story,
    .cf-product-final-cta {
        gap: clamp(1.4rem, 6vw, 2.25rem) !important;
    }

    .cf-managed-homepage .cf-lead,
    .cf-managed-product-page .cf-lead {
        font-size: clamp(1.02rem, 4.7vw, 1.18rem) !important;
        line-height: 1.52 !important;
    }

    .cf-product-mobile-buy-bar {
        grid-template-columns: minmax(0, 1fr) auto !important;
        gap: .55rem !important;
    }

    .cf-product-mobile-buy-bar .cf-button {
        min-height: 46px;
        padding-inline: .9rem;
        font-size: .92rem;
    }

    .cf-product-section .cart,
    .cf-product-section form.cart {
        grid-template-columns: minmax(4.5rem, 5rem) minmax(0, 1fr) !important;
    }

    .cf-product-section .cart .button,
    .cf-product-section form.cart .button {
        max-width: 100%;
        white-space: normal;
    }
}
