/**
 * PILMMA Mobile Responsive Overrides
 * Scoped strictly to viewports below 768px to ensure tablet and desktop layouts are preserved.
 */

@media (max-width: 767px) {
    /* ==========================================
     * 1. Header & Top Utility Bar
     * ========================================== */
    #topbar {
        position: relative !important;
        display: block !important;
        z-index: 1001 !important;
        padding: 8px 10px !important;
        text-align: center !important;
        background: #111111 !important;
    }

    #topbar .topbar-right {
        float: none !important;
        justify-content: center !important;
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px 12px !important;
    }

    #topbar .topbar-widget {
        padding: 6px 0 !important;
        font-size: 11px !important;
        height: auto !important;
        display: inline-block !important;
        float: none !important;
    }

    header.header-mobile {
        position: sticky !important;
        top: 0 !important;
        z-index: 999 !important;
    }

    header.header-mobile div#logo {
        padding-left: 15px !important;
    }

    header.header-mobile #menu-btn {
        margin-left: 15px !important;
        margin-right: 5px !important;
    }

    /* Target action icons in the mobile header */
    header.header-mobile .h-phone,
    header.header-mobile .h-search,
    header.header-mobile .h-cart,
    header.header-mobile .menu-item-search,
    header.header-mobile .menu-item-cart {
        margin-left: 10px !important;
        margin-right: 10px !important;
        padding-top: 15px !important;
    }

    /* ==========================================
     * 2. Home Hero Section
     * ========================================== */
    #de-carousel,
    #de-carousel .carousel-inner,
    #de-carousel .carousel-item,
    #de-carousel .carousel-item.active {
        height: auto !important;
        min-height: 520px !important;
    }

    #de-carousel .carousel-item {
        padding-top: 120px !important;
        padding-bottom: 70px !important;
    }

    #de-carousel h1 {
        font-size: 26px !important;
        line-height: 1.25 !important;
        margin-bottom: 15px !important;
    }

    #de-carousel h4 {
        font-size: 14px !important;
        margin-bottom: 10px !important;
        letter-spacing: 1px !important;
    }

    #de-carousel p.lead {
        font-size: 14px !important;
        line-height: 1.5 !important;
        margin-bottom: 20px !important;
    }

    #de-carousel .carousel-indicators {
        bottom: 25px !important;
    }

    /* ==========================================
     * 3. Proximity Spacing & General Layout
     * ========================================== */
    /* Add vertical margins to adjacent headings and subheadings */
    h2 + h3, 
    h2 + h4, 
    h2 + p, 
    h3 + p, 
    .section-title-content h2 + p,
    .container h2 + p {
        margin-top: 15px !important;
    }

    /* Space out stacked column layouts globally on mobile */
    .row > [class*="col-"] {
        margin-bottom: 25px;
    }
    
    .row > [class*="col-"]:last-child {
        margin-bottom: 0;
    }

    /* Soften harsh white drop-shadows on dark sections */
    .shadow-1-strong, 
    .shadow-2-strong, 
    .shadow-3-strong, 
    .shadow-4-strong, 
    .shadow-5-strong, 
    .shadow-sm, 
    .shadow,
    .video-card,
    .btn-custom {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25) !important;
    }

    /* Spacing between adjacent buttons */
    .btn-custom {
        margin-bottom: 15px !important;
        width: 100% !important;
        text-align: center !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .btn-custom:last-child {
        margin-bottom: 0 !important;
    }

    /* ==========================================
     * 4. Services Grid Cards
     * ========================================== */
    .services-card-mask {
        margin-bottom: 25px !important;
        height: 280px !important;
        position: relative !important;
        overflow: hidden !important;
    }

    .services-card-mask img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }

    /* Force the cover overlay to be visible by default on mobile, using original desktop styles */
    .services-card-mask .cover {
        height: 100% !important;
        top: 0 !important;
        margin-top: 0 !important;
        background: rgba(0, 0, 0, 0.8) !important;
    }

    .services-card-mask .cover p {
        opacity: 1 !important;
    }

    /* ==========================================
     * 5. Video aspect ratios & testmonials
     * ========================================== */
    .video-shell iframe,
    .video-embed iframe,
    .embed-container iframe,
    iframe[src*="vimeo"],
    iframe[src*="youtube"] {
        width: 100% !important;
        aspect-ratio: 16/9 !important;
        height: auto !important;
    }

    .video-shell,
    .video-embed {
        margin-bottom: 20px !important;
    }

    /* ==========================================
     * 6. Gold Crest Banner (Guarantee Section)
     * ========================================== */
    .justica-guarantee-banner {
        padding: 40px 15px !important;
    }

    .justica-guarantee-banner img {
        max-width: 90px !important;
        margin-bottom: 20px !important;
    }

    .justica-guarantee-banner .guarantee-title {
        font-size: 20px !important;
        line-height: 1.3 !important;
    }

    .justica-guarantee-banner .guarantee-text {
        font-size: 14px !important;
        line-height: 1.45 !important;
        margin-top: 10px !important;
    }

    /* ==========================================
     * 7. Mockup Images (Books, Magazines, Journals)
     * ========================================== */
    /* Stop single mockup images from expanding to full screen width */
    .journal-mockup, 
    .book-cover,
    .wp-block-image img,
    .wp-block-columns img {
        max-width: 240px !important;
        margin-left: auto !important;
        margin-right: auto !important;
        margin-bottom: 20px !important;
        display: block !important;
        height: auto !important;
    }

    /* ==========================================
     * 8. Roadmap & General Forms
     * ========================================== */
    .field-set, 
    .form-group, 
    .wpcf7-form-control-wrap,
    input.form-control,
    textarea.form-control {
        margin-bottom: 12px !important;
    }

    form input[type="submit"],
    form button,
    .wpcf7-submit {
        width: 100% !important;
        margin-top: 10px !important;
        padding: 12px 20px !important;
    }

    /* ==========================================
     * 9. Latest Blog Posts
     * ========================================== */
    .bloglist.item {
        margin-bottom: 30px !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding-bottom: 25px;
    }

    .bloglist.item:last-child {
        border-bottom: none !important;
        padding-bottom: 0 !important;
    }

    .bloglist.item .post-image img {
        width: 100% !important;
        height: 200px !important;
        object-fit: cover !important;
        border-radius: 4px;
    }

    /* Decrease blog post title size on mobile while keeping original styling */
    .bloglist.item .post-text h4 a {
        font-size: 18px !important;
    }

    /* Elevate blog Read More links (if any) into touch-friendly button layouts */
    .bloglist.item .post-text a.more-link {
        padding: 8px 16px !important;
        background: rgba(207, 159, 76, 0.1) !important;
        color: #cf9f4c !important;
        border: 1px solid #cf9f4c !important;
        border-radius: 4px !important;
        text-decoration: none !important;
        margin-top: 10px !important;
        font-size: 12px !important;
        text-transform: uppercase !important;
        font-weight: bold !important;
        display: inline-block !important;
    }

    /* ==========================================
     * 10. Footer Alignment
     * ========================================== */
    /* Ensure newsletter widget fields and buttons match width */
    .frm_forms input,
    .frm_forms select,
    .frm_forms textarea,
    .frm_forms input[type="email"],
    .frm_forms input[type="text"],
    .frm_forms .frm_primary_label,
    .frm_form_fields,
    .frm_submit,
    .frm_submit input[type="submit"],
    .frm_submit button {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Improve social media icons layout and touch targets (44x44px target) */
    .subfooter .social-icons {
        display: flex !important;
        justify-content: center !important;
        gap: 15px !important;
        margin-top: 15px !important;
    }

    .subfooter .social-icons a {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 44px !important;
        height: 44px !important;
        background: rgba(255, 255, 255, 0.05) !important;
        border-radius: 50% !important;
        font-size: 16px !important;
        margin: 0 !important;
    }

    .subfooter .social-icons a:hover {
        background: #cf9f4c !important;
        color: #111 !important;
    }
}
