/* ═══════════════════════════════════════════════════════════════════
   responsive.css — Site-wide breakpoints
   Covers: page builder blocks, slider/banner, footer, layout, typography
   Breakpoints:
     ≥1200px  Desktop
     1024-1199px  Laptop
     768-1023px   Tablet
     480-767px    Mobile
     <480px       Small mobile
   ═══════════════════════════════════════════════════════════════════ */

/* ── Global safety ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: hidden; max-width: 100%; }
img, video, iframe, embed, object { max-width: 100%; height: auto; }

/* ── Full-width page builder pages must always be single-column ─────── */
/* frontend.css @media ≤1200px overrides .site-main--full with 1fr 270px;
   this restores the full-width layout at every breakpoint. */
.site-main--full { grid-template-columns: 1fr !important; }

/* ── Page builder pages: zero top/bottom padding on site-main ─────────── */
/* frontend.css base sets .site-main--pb { padding-top:0; padding-bottom:0 }
   but responsive breakpoints add padding back via .site-main { padding:Xpx }.
   This keeps PB pages flush-top (slider starts right below the header). */
.site-main--pb { padding-top: 0 !important; padding-bottom: 0 !important; }
.pb-page-output { margin-top: 0; }

/* ── Slider / Banner block (fd-slide inline height fix) ────────────── */
/* Reduce the fixed inline height of .fd-slide on smaller screens */
@media (max-width: 1023px) {
    .fd-slide { height: 380px !important; }
    .pb-banner-preview { height: 380px !important; }
}
@media (max-width: 767px) {
    .fd-slide { height: 280px !important; }
    .pb-banner-preview { height: 280px !important; }
}
@media (max-width: 479px) {
    .fd-slide { height: 220px !important; }
    .pb-banner-preview { height: 220px !important; }
    /* Banner text padding */
    .pb-banner-content { padding: 16px !important; }
    .pb-banner-title { font-size: 20px !important; }
    .pb-banner-subtitle { font-size: 13px !important; }
}

/* ── Page Builder — Preview grids (pb-blog-grid.cols-N) ─────────────── */
.pb-blog-grid { display: grid; gap: 20px; }
.pb-blog-grid.cols-1 { grid-template-columns: 1fr; }
.pb-blog-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.pb-blog-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.pb-blog-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1023px) {
    .pb-blog-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 767px) {
    .pb-blog-grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
    .pb-blog-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 479px) {
    .pb-blog-grid.cols-2,
    .pb-blog-grid.cols-3,
    .pb-blog-grid.cols-4 { grid-template-columns: 1fr; }
}

/* ── Page Builder — Saved HTML inline grids ─────────────────────────── */
/* These grids are saved with inline style="display:grid;grid-template-columns:repeat(N,1fr);gap:20px"
   They live inside .pb-page-output. We collapse them at mobile widths. */
@media (max-width: 767px) {
    .pb-page-output [style*="grid-template-columns:repeat(2"],
    .pb-page-output [style*="grid-template-columns: repeat(2"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .pb-page-output [style*="grid-template-columns:repeat(3"],
    .pb-page-output [style*="grid-template-columns: repeat(3"],
    .pb-page-output [style*="grid-template-columns:3fr 2fr"],
    .pb-page-output [style*="grid-template-columns: 3fr 2fr"] {
        grid-template-columns: 1fr !important;
    }
    .pb-page-output [style*="grid-template-columns:repeat(4"],
    .pb-page-output [style*="grid-template-columns: repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    /* Masonry (column-count) collapse */
    .pb-page-output [style*="column-count:3"],
    .pb-page-output [style*="column-count: 3"],
    .pb-page-output [style*="column-count:4"],
    .pb-page-output [style*="column-count: 4"] {
        column-count: 2 !important;
    }
}
@media (max-width: 479px) {
    .pb-page-output [style*="grid-template-columns:repeat(2"],
    .pb-page-output [style*="grid-template-columns: repeat(2"],
    .pb-page-output [style*="grid-template-columns:repeat(3"],
    .pb-page-output [style*="grid-template-columns: repeat(3"],
    .pb-page-output [style*="grid-template-columns:repeat(4"],
    .pb-page-output [style*="grid-template-columns: repeat(4"],
    .pb-page-output [style*="grid-template-columns:3fr 2fr"],
    .pb-page-output [style*="grid-template-columns: 3fr 2fr"] {
        grid-template-columns: 1fr !important;
    }
    .pb-page-output [style*="column-count:2"],
    .pb-page-output [style*="column-count: 2"],
    .pb-page-output [style*="column-count:3"],
    .pb-page-output [style*="column-count: 3"],
    .pb-page-output [style*="column-count:4"],
    .pb-page-output [style*="column-count: 4"] {
        column-count: 1 !important;
    }
}

/* ── Page Builder — Magazine layout (preview) ───────────────────────── */
.pb-blog-magazine {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 24px;
    align-items: start;
}
.pb-blog-mag-left { min-width: 0; }
.pb-blog-mag-right { min-width: 0; }
.pb-blog-mag-img { width: 100%; height: 240px; object-fit: cover; display: block; }

@media (max-width: 767px) {
    .pb-blog-magazine { grid-template-columns: 1fr; }
    .pb-blog-mag-img { height: 180px; }
}

/* ── Page Builder — Compact layout (preview) ────────────────────────── */
.pb-blog-compact { display: flex; flex-direction: column; gap: 0; }
.pb-blog-compact-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
}
.pb-blog-compact-img {
    width: 72px;
    height: 54px;
    object-fit: cover;
    border-radius: 5px;
    flex-shrink: 0;
}
.pb-blog-compact-body { flex: 1; min-width: 0; }
.pb-blog-compact-nimg {
    width: 72px;
    height: 54px;
    flex-shrink: 0;
    background: #f1f5f9;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 600;
    text-transform: uppercase;
    color: #94a3b8;
    text-align: center;
}

/* ── Page Builder — List layout (preview) ───────────────────────────── */
.pb-blog-list { display: flex; flex-direction: column; gap: 0; }
.pb-blog-list-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
}
.pb-blog-list-body { flex: 1; min-width: 0; }
.pb-blog-list-title { font-size: 14px; font-weight: 600; color: #1e293b; }
.pb-blog-card-title { font-size: 18px; font-weight: 700; color: #1e293b; margin: 8px 0; }

/* ── Page Builder — fd-blog-post (list rows: image too small on mobile) */
@media (max-width: 479px) {
    .fd-blog-post[style*="display:flex"] img,
    .fd-blog-post[style*="display: flex"] img {
        width: 70px !important;
        height: 52px !important;
    }
}

/* ── Page Builder — Top bar (heading + View All link) ───────────────── */
@media (max-width: 479px) {
    /* Top bar: heading + view all side by side, allow wrapping */
    .pb-page-output [style*="display:flex"][style*="justify-content:space-between"][style*="border-bottom"] {
        flex-wrap: wrap;
        gap: 8px !important;
    }
    .pb-page-output [style*="display:flex"][style*="justify-content:space-between"][style*="border-bottom"] h2 {
        font-size: 18px !important;
    }
}

/* ── Page Builder — Filter bar buttons ──────────────────────────────── */
.fd-blog-fb { touch-action: manipulation; }

/* ── Hero block ─────────────────────────────────────────────────────── */
@media (max-width: 767px) {
    .pb-page-output [style*="min-height:360px"],
    .pb-page-output [style*="min-height: 360px"] {
        min-height: 260px !important;
        padding: 32px 16px !important;
    }
    .pb-page-output [style*="font-size:36px"][style*="font-weight:700"] {
        font-size: 26px !important;
    }
}
@media (max-width: 479px) {
    .pb-page-output [style*="min-height:360px"],
    .pb-page-output [style*="min-height: 360px"] {
        min-height: 200px !important;
        padding: 24px 14px !important;
    }
}

/* ── Masonry preview class ──────────────────────────────────────────── */
.pb-blog-masonry { columns: var(--masonry-cols, 3); column-gap: 20px; }
.pb-blog-masonry.cols-2 { --masonry-cols: 2; }
.pb-blog-masonry.cols-3 { --masonry-cols: 3; }
.pb-blog-masonry.cols-4 { --masonry-cols: 4; }
.pb-blog-masonry-item { break-inside: avoid; margin-bottom: 20px; }
@media (max-width: 767px) {
    .pb-blog-masonry { --masonry-cols: 2 !important; }
}
@media (max-width: 479px) {
    .pb-blog-masonry { --masonry-cols: 1 !important; }
}

/* ── Page Builder carousel: touch scroll ───────────────────────────── */
[id$="_track"] { -webkit-overflow-scrolling: touch; }
[id$="_wrap"]  { -webkit-overflow-scrolling: touch; }

/* ══════════════════════════════════════════════════════════════════════
   LAPTOP  (1100px – 1199px)
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 1199px) {
    .pb-blog-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
    /* Slider height: slightly reduce */
    .fd-slide { height: 420px !important; }
    .pb-banner-preview { height: 420px !important; }
}

/* ══════════════════════════════════════════════════════════════════════
   TABLET  (768px – 1099px)  ← raised from 1023px to cover 1060px etc.
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 1099px) {
    /* ── Nav: collapse to hamburger (override frontend.css 900px rule) ── */
    .site-header__inner { position: relative; }
    .nav-toggle { display: flex !important; }
    .site-nav:not(.site-nav--open) { display: none !important; }
    .site-nav {
        position: absolute !important;
        top: 72px !important;
        left: 0 !important;
        right: 0 !important;
        background: #fff !important;
        border-bottom: 1px solid #e5e7eb !important;
        padding: 12px 20px 20px !important;
        box-shadow: 0 8px 24px rgba(0,0,0,.10) !important;
        z-index: 999 !important;
        max-height: calc(100vh - 72px) !important;
        overflow-y: auto !important;
    }
    .site-nav--open { display: block !important; }
    .nav-menu { flex-direction: column !important; align-items: flex-start !important; gap: 0 !important; height: auto !important; }
    .nav-menu > li { height: auto !important; width: 100% !important; }
    .nav-menu > li > a { padding: 11px 6px !important; height: auto !important; font-size: 15px !important; }
    .nav-menu > li > a::after { display: none !important; }
    .sub-menu {
        position: static !important; opacity: 1 !important; pointer-events: auto !important;
        transform: none !important; box-shadow: none !important; border: none !important;
        padding: 0 0 4px 20px !important;
    }
    .mega-menu-item { position: static !important; }
    .mega-dropdown { position: static !important; border: none !important; box-shadow: none !important; animation: none !important; }
    .mega-dropdown-inner { flex-direction: column !important; gap: 0 !important; padding: 0 0 8px 20px !important; max-width: none !important; }
    .mega-column { border-right: none !important; padding: 0 0 10px 0 !important; flex: none !important; }

    /* ── Layout: sidebar collapses ────────────────────────────────── */
    .site-main { grid-template-columns: 1fr !important; gap: 28px; padding: 28px 0 48px; }
    .sidebar { position: static !important; }

    /* ── Slider / Banner ─────────────────────────────────────────── */
    .fd-slide { height: 360px !important; }
    .pb-banner-preview { height: 360px !important; }

    /* ── Page builder grids ──────────────────────────────────────── */
    .pb-blog-grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
    .pb-blog-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }

    /* Inline saved-HTML grids: 3-col → 2-col */
    .pb-page-output [style*="grid-template-columns:repeat(3"],
    .pb-page-output [style*="grid-template-columns: repeat(3"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .pb-page-output [style*="grid-template-columns:repeat(4"],
    .pb-page-output [style*="grid-template-columns: repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* ── Footer: brand full-width row, 3 widget cols below ───────── */
    .site-footer__grid { grid-template-columns: repeat(3, 1fr) !important; gap: 28px !important; }
    .site-footer__brand { grid-column: 1 / -1 !important; }

    /* ── Related posts ────────────────────────────────────────────── */
    .related-posts__grid { grid-template-columns: repeat(2, 1fr); }

    /* ── View-all page ────────────────────────────────────────────── */
    .posts-grid { gap: 20px; }
}

/* ══════════════════════════════════════════════════════════════════════
   MOBILE  (480px – 767px)
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
    /* Typography */
    h1 { font-size: clamp(22px, 6vw, 32px) !important; }
    h2 { font-size: clamp(18px, 5vw, 26px) !important; }
    h3 { font-size: clamp(16px, 4.5vw, 22px) !important; }

    /* Site header */
    .site-header__inner { height: 60px !important; }
    .site-nav { top: 60px !important; }
    .site-logo img { max-height: 36px; }

    /* Page builder grids */
    .pb-blog-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
    .pb-blog-grid.cols-3 { grid-template-columns: 1fr; }
    .pb-blog-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }

    /* Inline grids: magazine (3fr 2fr) collapses */
    .pb-page-output [style*="grid-template-columns:3fr 2fr"],
    .pb-page-output [style*="grid-template-columns: 3fr 2fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Footer */
    .site-footer__grid { grid-template-columns: 1fr !important; gap: 24px !important; }
    .site-footer__brand { grid-column: auto !important; }
    .site-footer__bottom { flex-direction: column; align-items: center; gap: 10px; text-align: center; }
    .footer-back-top { align-self: center; }

    /* Page padding */
    .site-container { padding: 0 16px; }
    .site-main { padding: 20px 0 40px; }

    /* Related posts */
    .related-posts__grid { grid-template-columns: 1fr !important; }

    /* Post single */
    .post-card__image { height: 200px; }

    /* Sidebar widgets */
    .widget { margin-bottom: 20px; }

    /* View-all grid */
    .posts-grid { grid-template-columns: 1fr !important; }

    /* Category filter pill scroll */
    #cat-filter { flex-wrap: nowrap !important; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
    #cat-filter::-webkit-scrollbar { display: none; }

    /* fd-blog-post card: reduce image height */
    .fd-blog-post img[style*="height:180px"],
    .fd-blog-post img[style*="height: 180px"] { height: 140px !important; }

    /* CTA block */
    .fd-cta { padding: 32px 20px !important; }
    .fd-cta__title { font-size: 22px !important; }
    .fd-cta__text  { font-size: 15px !important; }

    /* Features block */
    .fd-features--cols-2,
    .fd-features--cols-3 { grid-template-columns: 1fr !important; }

    /* Counter */
    .fd-counter--cols-3,
    .fd-counter--cols-4 { grid-template-columns: repeat(2, 1fr) !important; }

    /* Pricing */
    .fd-pricing--2,
    .fd-pricing--3 { grid-template-columns: 1fr !important; }

    /* Gallery */
    .fd-gallery--cols-3,
    .fd-gallery--cols-4 { grid-template-columns: repeat(2, 1fr) !important; }

    /* Team */
    .fd-team--cols-3,
    .fd-team--cols-4 { grid-template-columns: repeat(2, 1fr) !important; }

    /* Tabs: scroll */
    .fd-tabs__nav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 0; }
    .fd-tabs__tab { white-space: nowrap; }

    /* Share buttons */
    .share-buttons { flex-wrap: wrap; gap: 6px; }
    .share-btn { font-size: 12px; padding: 7px 12px; }
}

/* ══════════════════════════════════════════════════════════════════════
   SMALL MOBILE  (< 480px)
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 479px) {
    /* Container */
    .site-container { padding: 0 12px; }

    /* Header */
    .site-header__inner { height: 56px; }
    .site-nav { top: 56px !important; }
    .site-logo img { max-height: 32px; }

    /* Post grids */
    .pb-blog-grid.cols-2,
    .pb-blog-grid.cols-3,
    .pb-blog-grid.cols-4 { grid-template-columns: 1fr; }

    /* Footer social */
    .footer-social { gap: 8px; }
    .footer-social__btn { width: 34px; height: 34px; border-radius: 8px; }

    /* Related posts */
    .related-posts__grid { grid-template-columns: 1fr; }

    /* Widgets */
    .widget { padding: 14px; }
    .widget-title { margin: -14px -14px 12px; padding: 9px 14px; }

    /* Comment nesting */
    .comment-children { margin-left: 14px; padding-left: 10px; }

    /* Post card image */
    .post-card__image { height: 180px; }

    /* Counter */
    .fd-counter--cols-2 { grid-template-columns: 1fr !important; }
    .fd-counter--cols-3,
    .fd-counter--cols-4 { grid-template-columns: 1fr !important; }

    /* Gallery */
    .fd-gallery--cols-2,
    .fd-gallery--cols-3,
    .fd-gallery--cols-4 { grid-template-columns: 1fr !important; }

    /* Team */
    .fd-team--cols-2,
    .fd-team--cols-3,
    .fd-team--cols-4 { grid-template-columns: 1fr !important; }

    /* Features */
    .fd-features--grid { grid-template-columns: 1fr !important; }

    /* Search bar */
    .search-form { flex-direction: column; gap: 8px; }
    .search-form input,
    .search-form button { width: 100%; border-radius: 6px !important; }

    /* Post meta */
    .post-meta { flex-wrap: wrap; gap: 6px; }

    /* View-all pagination */
    .pagination { flex-wrap: wrap; justify-content: center; }

    /* Author box */
    .author-box { flex-direction: column; align-items: center; text-align: center; }
    .author-box__avatar { width: 64px !important; height: 64px !important; }
}

/* ══════════════════════════════════════════════════════════════════════
   VIEW-ALL PAGE  — always usable on all screens
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
    /* view-all page: 2-col → 1-col below mobile */
    .posts-grid[style*="grid-template-columns: repeat(2"] { grid-template-columns: 1fr !important; }
    .posts-grid[style*="grid-template-columns:repeat(2"] { grid-template-columns: 1fr !important; }
}

/* ══════════════════════════════════════════════════════════════════════
   PRINT  — clean minimal output
   ══════════════════════════════════════════════════════════════════════ */
@media print {
    .site-header, .site-footer, .sidebar, .nav-toggle, .share-buttons,
    .footer-back-top, .site-footer__bottom .nav-menu { display: none !important; }
    .site-main { grid-template-columns: 1fr !important; }
    body { font-size: 12pt; color: #000; }
    a { color: #000; text-decoration: underline; }
}
