/* ============================================================
   ALL FIXES — Barbus WP Theme
   СИСТЕМА: каждый блок строго в своём @media.
   Правила десктопа и мобила НИКОГДА не пересекаются.
   Desktop: min-width: 769px
   Mobile:  max-width: 768px
   ============================================================ */


/* ============================================================
   DESKTOP ONLY (769px+)
   ============================================================ */
@media (min-width: 769px) {

    /* --- Section 01: Hero vertical centering --- */
    .section-01 {
        min-height: 100vh !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin-top: 0 !important;
        margin-bottom: 5vw !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    .section-01 h1,
    .section-01 h1.hero-title-part1 {
        font-size: 3.3vw !important;
        line-height: 1.2 !important;
        margin-bottom: 1.5vw !important;
        display: inline !important;
    }

    .section-01 .hero-title-part2 {
        display: inline !important;
        font-size: 1.27vw !important;
        color: inherit !important;
        font-weight: 400 !important;
        line-height: 1.6 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .section-01 .section-01-text {
        font-size: 1.27vw !important;
        line-height: 1.6 !important;
        margin-bottom: 2vw !important;
    }

    .section-01 .column:last-child {
        margin-left: -3vw !important;
    }

    .section-01 .column:first-child {
        padding-top: 0 !important;
        padding-right: 2vw !important;
    }

    .section-01 .btn {
        font-size: 1.1vw !important;
        padding: 0.9vw 2vw !important;
    }

    .section-01 .btn::after {
        font-size: 1.3vw !important;
    }

    /* --- Section 04 desktop: HIDE mobile-only title, columns side-by-side --- */
    .section-04 .mobile-only-title {
        display: none !important;  /* Mobile duplicate — invisible on desktop */
    }

    /* column-text and column-image: standard flex children (theme handles the rest) */
    .section-04 .column-text,
    .section-04 .column-image {
        /* Let theme CSS control the flex layout on desktop */
    }
    /* --- Footer: remove all stray border lines ---
       Sources found in style.css / barbus.css:
       - .widget_custom_html ul li { border-left: 1px solid #fff }
       - WordPress default widget may add border on section
       - .row may have border-bottom from barbus.css            */
    .site-footer .widget_custom_html ul li {
        border: none !important;
        padding-left: 0 !important;
    }
    .site-footer section.widget {
        border: none !important;
        box-shadow: none !important;
        outline: none !important;
    }
    .site-footer .row {
        border: none !important;
    }
    .site-footer .widget_custom_html {
        border: none !important;
    }

    /* --- Pro Nas: Redesign layout --- */
    .section-about-01 {
        padding-top: 1vw !important; 
        margin-top: -5vw !important; /* Значно менше повітря над блоком */
    }
    .section-about-01 .image-01 {
        transform: translate(5vw, 6vw) !important; /* Чуть вище ніж 10vw, але нижче ніж 4vw */
    }
    .section-about-01 .directions-block {
        margin-top: 2vw !important; /* Reduced to bring it closer to text above */
        width: 100%;
    }
    .section-about-01 .directions-title {
        font-size: 1.8vw !important;
        color: #001e4b !important;
        margin-bottom: 2vw !important;
        display: flex !important;
        font-weight: 700 !important;
        align-items: center !important;
    }
    .section-about-01 .directions-accordion {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 1.5vw 2vw !important; /* Збільшений відступ між колонками */
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .section-about-01 .static-item {
        display: contents !important; 
        border: none !important;
    }
    .section-about-01 .static-title {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        text-align: center !important;
        padding: 0 !important;
        border: none !important;
        outline: none !important;
        background: transparent !important;
        box-shadow: none !important;
        font-size: 0.85vw !important; 
        font-weight: 700 !important;
        line-height: 1.3 !important;
        color: #001e4b !important;
        cursor: default !important; /* Disabled pointer */
        position: relative !important;
    }
    .section-about-01 .static-title figure {
        position: relative !important; 
        display: block !important;
        width: 4.8vw !important; 
        height: 4.8vw !important;
        background-position: center bottom !important;
        background-repeat: no-repeat !important;
        background-size: contain !important;
        margin: 0 auto 1vw auto !important;
        border-radius: 0 !important; 
        box-shadow: none !important;
        border: none !important;
        outline: none !important;
        float: none !important;
    }

    /* --- Pro Nas: Expanded Section (Desktop default - Checkerboard UI) --- */
    .directions-expanded-section {
        margin-top: 6vw; /* Clear sticky header */
        padding: 4vw 0 6vw 0;
    }
    .directions-expanded-list {
        max-width: 1200px; /* Align precisely with Legacy column widths */
        margin: 0 auto;
        padding: 0 4vw; /* Inner breathing room */
        display: flex;
        flex-direction: column;
        gap: 6vw; /* Air between sections */
    }
    .directions-expanded-item {
        background: transparent;
        border-bottom: 1px solid #eaeaea;
        padding-bottom: 6vw;
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 4vw;
    }
    .directions-expanded-item:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }
    /* Checkerboard Pattern: Reverse layout for even items */
    .directions-expanded-item:nth-child(even) {
        flex-direction: row-reverse;
    }

    .expanded-column-text {
        width: 50%;
        flex-shrink: 0;
    }
    .expanded-column-visual {
        width: 45%;
        flex-shrink: 0;
    }

    .expanded-header {
        display: flex;
        align-items: center;
        gap: 1.5vw;
        margin-bottom: 2.5vw;
    }
    .expanded-header figure {
        width: 3vw;
        height: 3vw;
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
        opacity: 0.8; /* Subtle icon */
        margin: 0;
    }
    .expanded-header h3 {
        font-size: 2.2vw;
        font-weight: 700;
        color: #001e4b;
        margin: 0;
        text-transform: none;
        line-height: 1.3;
    }
    .expanded-text {
        font-size: 1vw;
        line-height: 1.8;
        color: #4a4a4a;
    }
    .expanded-text p {
        margin-bottom: 1.2em;
    }
    
    /* Collapsible Logic for SEO */
    .expanded-text-collapse {
        max-height: 250px; /* ~20% of content / roughly 7-8 lines */
        overflow: hidden;
        position: relative;
        transition: max-height 0.5s ease;
        margin-bottom: 2vw;
    }
    .expanded-text-collapse::after {
        display: none; /* Removed blur effect entirely per request */
    }
    .expanded-text-collapse.is-open {
        max-height: 3000px; /* Big enough to fit all content securely */
    }
    .expanded-text-collapse.is-open::after {
        display: none;
    }
    .read-more-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 1vw;
        font-size: 1vw;
        font-weight: 700;
        color: #ffffff !important;
        background: #04b4cb !important;
        padding: 1.2vw 2.5vw;
        border-radius: 4vw;
        border: none;
        cursor: pointer;
        margin-bottom: 2vw;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        transition: all 0.3s ease;
        box-shadow: 0 4px 15px rgba(4, 180, 203, 0.25) !important;
    }
    .read-more-btn:hover {
        background: #0394a5 !important;
        box-shadow: 0 6px 20px rgba(4, 180, 203, 0.4) !important;
    }
    .read-more-btn::after {
        content: '';
        display: inline-block;
        width: 1.5vw;
        height: 1.5vw;
        background-image: url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M19 9L12 16L5 9" stroke="%23ffffff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></svg>') !important;
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
        transition: transform 0.4s ease;
    }
    .expanded-text-collapse.is-open + .read-more-btn::after {
        transform: rotate(180deg) !important;
    }
    .read-more-btn:hover::after {
        background-image: url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M19 9L12 16L5 9" stroke="%230394a5" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></svg>');
    }
    .expanded-text-collapse.is-open + .read-more-btn::after {
        transform: rotate(180deg);
    }
    .expanded-images {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 16vw; /* Exact row height so grid defines the picture size */
        gap: 1.5vw;
    }
    /* If exactly 3 images: leave only 1 and make it full width */
    .expanded-images figure:first-child:nth-last-child(3) {
        grid-column: 1 / -1;
    }
    .expanded-images figure:first-child:nth-last-child(3) ~ figure {
        display: none !important;
    }
    /* If exactly 1 image anywhere: make it full width */
    .expanded-images figure:first-child:last-child,
    .expanded-images-two figure:first-child:last-child {
        grid-column: 1 / -1;
    }
    .expanded-images-two {
        grid-template-columns: repeat(2, 1fr);
    }
    .expanded-images figure {
        width: 100%;
        height: 16vw; /* Bulletproof explicit height */
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        border-radius: 1vw;
        margin: 0;
        box-shadow: 0 1vw 3vw rgba(0,0,0,0.06);
    }
    .expanded-brands {
        display: flex;
        flex-wrap: wrap;
        gap: 1.5vw;
        padding: 0;
        margin: 0;
        list-style: none;
    }
    .expanded-brands li {
        width: calc(33.333% - 1vw); /* 3 items per row in 50% col */
        background: #fdfdfd;
        padding: 1.5vw;
        border-radius: 0.5vw;
        border: 1px solid #f0f0f0;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.3s ease;
    }
    .expanded-brands li:hover {
        transform: translateY(-0.2vw);
        box-shadow: 0 0.5vw 1vw rgba(0,0,0,0.05);
    }
    .expanded-brands li img {
        max-width: 100%;
        max-height: 3vw;
        object-fit: contain;
    }
}


/* ============================================================
   MOBILE ONLY (768px-)
   ============================================================ */
@media (max-width: 768px) {

    /* --- Brands carousel: full-width infinite auto-scroll --- */
    .brands-carousel-wrapper {
        margin: 8vw -5.3vw 6vw -5.3vw !important;
        padding: 5vw 0 !important;
        border-radius: 0 !important;
        overflow: hidden !important;
    }

    .brands-carousel-wrapper::before,
    .brands-carousel-wrapper::after {
        display: none !important;
    }

    .brands-track {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 4vw !important;
        width: max-content !important;
        padding: 0 !important;
        animation: infiniteScrollMobile 30s linear infinite !important;
        will-change: transform !important;
    }

    .brand-item {
        width: 40vw !important;
        min-width: 40vw !important;
        height: 26vw !important;
        padding: 3vw !important;
        border-radius: 3vw !important;
        box-shadow: 0 1.5vw 3vw rgba(0, 0, 0, 0.08) !important;
        flex-shrink: 0 !important;
    }

    /* --- General mobile page spacing --- */
    body:not(.home) .site-content {
        padding-top: 25vw !important;
    }

    body.home .site-content {
        padding-top: 8.33333vw !important;
    }

    /* --- Breadcrumbs --- */
    .barbus-top .barbus-breadcrumb {
        font-size: 4.5vw !important;
        line-height: 1.6 !important;
    }

    /* --- Section 04: Mobile order — Заголовок → Картинка → Текст → Кнопка ---

       HTML structure (from page-home.php):
         .wrapper
           .mobile-only-title   ← h2 duplicate (hidden on desktop)
           .column.column-text  ← full $text (h2+p) + button
           .column.column-image ← figure

       On mobile:
         mobile-only-title → order 1 (SHOWN, replaces h2 in column-text)
         column-image      → order 2
         column-text       → order 3 (h2 inside it is hidden to avoid duplicate)
    */
    .section-04 .wrapper {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        text-align: center !important;
    }

    /* Mobile title: shown first */
    .section-04 .mobile-only-title {
        display: block !important;
        order: 1 !important;
        width: 100% !important;
        text-align: center !important;
        margin-bottom: 4vw !important;
    }

    /* Image column: shown second */
    .section-04 .column-image {
        order: 2 !important;
        width: 100% !important;
        margin-bottom: 5vw !important;
    }

    /* Text column: shown third. h2 inside it is HIDDEN (mobile-only-title shows instead) */
    .section-04 .column-text {
        order: 3 !important;
        width: 100% !important;
        margin-bottom: 5vw !important;
        text-align: center !important;
    }

    .section-04 .column-text h2 {
        display: none !important;  /* Hide original h2 — mobile-only-title shows instead */
    }

    /* Image figure sizing on mobile */
    .section-04 .image-02 {
        position: relative !important;
        top: 0 !important;
        right: 0 !important;
        margin: 0 auto !important;
        width: 100% !important;
        height: 60vw !important;
        background-size: contain !important;
        background-repeat: no-repeat !important;
        background-position: center !important;
    }

    /* --- Section 04 column fallback (in case old .column class is used elsewhere) --- */
    .section-04 .column {
        width: 100% !important;
    }

    /* --- Pro Nas: Redesign layout (Mobile fallback & Flex Ordering) --- */
    .section-about-01 .wrapper {
        display: flex !important;
        flex-direction: column !important;
    }
    .section-about-01 .column {
        display: contents !important; /* Strips columns so children can be ordered freely */
    }
    .section-about-01 h2 {
        order: 1 !important;
        margin-bottom: 5vw !important;
    }
    .section-about-01 .image-01 {
        order: 2 !important;
        position: static !important;
        transform: none !important; /* Reset desktop translate offset */
        margin: 5vw auto 8vw auto !important;
        width: 100% !important;
        display: flex !important;
        justify-content: center !important;
    }
    .section-about-01 .image-01 img {
        width: 75% !important; /* Nice balanced size on mobile */
    }
    .section-about-01 p {
        order: 3 !important;
        margin-bottom: 6vw !important;
    }
    .section-about-01 .directions-block {
        order: 4 !important;
        margin-top: 8vw !important;
        width: 100% !important;
    }
    .section-about-01 .directions-title {
        font-size: 6vw !important;
        margin-bottom: 5vw !important;
        font-weight: 700 !important;
        color: #001e4b !important;
    }
    .section-about-01 .directions-accordion {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important; /* 2x2 Clean Mobile Grid */
        gap: 6vw 3vw !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .section-about-01 .static-item {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }
    .section-about-01 .static-title {
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        align-items: center !important;
        text-align: center !important;
        font-size: 3.5vw !important;
        font-weight: 700 !important;
        color: #001e4b !important;
        cursor: default !important;
        line-height: 1.2 !important;
    }
    .section-about-01 .static-title figure {
        width: 14vw !important;
        height: 14vw !important;
        background-position: center !important;
        background-repeat: no-repeat !important;
        background-size: contain !important;
        margin: 0 auto 2vw auto !important;
    }

    /* --- Pro Nas: Expanded Section (Mobile Overrides) --- */
    .directions-expanded-section {
        padding: 10vw 0;
    }
    .directions-expanded-list {
        gap: 12vw;
    }
    .directions-expanded-item {
        display: flex !important;
        flex-direction: column !important; /* Force stacking on mobile */
        height: auto !important;
        position: relative !important;
        padding-bottom: 12vw !important;
        border-bottom: 1px solid #eaeaea !important;
        gap: 6vw !important;
        float: none !important;
    }
    .directions-expanded-item:nth-child(even) {
        flex-direction: column !important; /* Strictly enforce override of checkerboard row-reverse */
    }
    .expanded-column-text, 
    .expanded-column-visual {
        display: contents !important; /* Strip wrapper for accurate flex ordering */
    }
    .expanded-header {
        order: 1 !important;
        gap: 3vw;
        margin-bottom: 4vw;
        width: 100% !important;
    }
    .expanded-images {
        order: 2 !important;
        width: 100% !important;
        margin-bottom: 6vw !important;
    }
    .expanded-text-collapse {
        order: 3 !important;
        margin-bottom: 3vw !important;
        max-height: 200px !important; 
        overflow: hidden !important; 
        position: relative !important;
        display: block !important;
        width: 100% !important;
    }
    .expanded-text-collapse.is-open {
        max-height: 4000px !important;
    }
    .read-more-btn {
        order: 4 !important;
        font-size: 4vw !important;
        padding: 3.5vw 0 !important;
        margin-top: 2vw !important;
        margin-bottom: 6vw !important;
        gap: 2.5vw !important; /* Space for icon */
        width: 100% !important;
        display: flex !important;
        justify-content: center !important;
        background: #04b4cb !important;
        border: none !important;
        border-radius: 8vw !important;
        color: #ffffff !important;
    }
    .read-more-btn::after {
        width: 4vw !important;
        height: 4vw !important;
    }
    .expanded-brands {
        order: 5 !important;
        width: 100% !important;
    }
    .expanded-images {
        grid-template-columns: repeat(2, 1fr) !important; /* 2 columns on mobile */
        grid-auto-rows: 35vw !important; /* Controlled height for mobile so collages work */
        gap: 3vw !important;
    }
    /* Mobile: Ensure the forced single-image spans correctly */
    .expanded-images figure:first-child:nth-last-child(3),
    .expanded-images figure:first-child:last-child,
    .expanded-images-two figure:first-child:last-child {
        grid-column: 1 / -1 !important;
    }
    .expanded-images figure {
        height: 35vw !important; /* Explicit absolute height matching grid rows */
        border-radius: 2vw !important;
    }
    .expanded-brands {
        gap: 2vw;
    }
    .expanded-brands li {
        width: calc(33.333% - 1.35vw); /* 3 items per row on mobile too */
        padding: 2vw;
        border-radius: 1vw;
    }
    .expanded-brands li img {
        max-height: 8vw;
    }

    /* --- Footer cleanup --- */
    .site-footer::before,
    .site-footer::after,
    .site-footer .wrapper::before,
    .site-footer .wrapper::after,
    .site-footer .row::before,
    .site-footer .row::after {
        display: none !important;
    }

    .site-footer,
    .site-footer .wrapper,
    .site-footer .row,
    .site-footer .widget {
        border: none !important;
        box-shadow: none !important;
    }
}


/* ============================================================
   GLOBAL (all screen sizes)
   ============================================================ */

/* Footer cleanup (applies everywhere) */
.site-footer::before,
.site-footer::after,
.site-footer .wrapper::before,
.site-footer .wrapper::after,
.site-footer .row::before,
.site-footer .row::after {
    display: none !important;
}

.site-footer,
.site-footer .wrapper,
.site-footer .row,
.site-footer .widget {
    border: none !important;
    box-shadow: none !important;
}

/* --- Homepage specific fixes --- */
.section-02 h2 {
    text-align: center !important;
    margin-bottom: 40px !important; /* Fixed padding relative to text */
    font-size: 35.5px !important;  /* Exactly matches "Наші бренди" */
    font-weight: 700 !important;
    color: #012351 !important;     /* Exact theme color */
    font-family: Roboto, sans-serif !important;
}

@media (max-width: 768px) {
    .section-02 h2 {
        font-size: 5.333vw !important; /* Exact mobile theme scale */
        margin-bottom: 8vw !important;
    }
}
