/* ==========================================================================
   Homepage — Product Carousel (ARKAN-442), a "+ Add Section" template

   Markup: template-parts/home/added-section-product-carousel.php
   Script: js/homepage-product-carousel.js

   As the ticket's reference ("Trending Now"):
   - the title on the left (as staging, ARKAN-462), the previous (‹) and next
     (›) arrows at the end of its row: small round white buttons with a light
     grey ring and a thin grey chevron, side by side;
   - every product of the collection in ONE row, on desktop and phones: four
     cards across on desktop, or five, as the admin picks per section
     (ARKAN-462), two on phones, the rest reached with the arrows, a swipe or
     a mouse drag.

   The cards are the homepage's shop cards (homepage-shop-cards.css, ARKAN-438)
   with the same spacing: 24px between cards, 14px under 1024px.

   Arrow sizes, from the reference pictures (circle diameter against the card
   width: 1/8 on desktop, about 1/6.5 on the phone picture): 34px on desktop,
   28px on phones; 6px apart. The row snaps to a card's start edge.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Heading: the title at the start of its row, where the other homepage
   sections' titles start (desktop: the shared heading row's padding, 15px in
   from the first card; phones: the card's edge), the arrows at the end. As
   staging's default title position (ARKAN-448), here the only one
   (ARKAN-462). "Start" is the left on English pages and the right on Arabic
   ones; the arrows stay at the other end.
   -------------------------------------------------------------------------- */
.page-homepage .qs-product-carousel .showcase-section-heading-row.qs-pc-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 16px;
    width: 100%;
    /* the row's own padding inside its width: the arrows end where the
       other sections' VIEW MORE ends */
    box-sizing: border-box;
}

@media (min-width: 1024px) {
    /* As tall as the other sections' heading rows (their 48px VIEW MORE and
       the row's padding), so the title and the cards sit on their lines */
    .page-homepage .qs-product-carousel .showcase-section-heading-row.qs-pc-head {
        min-height: 58px;
    }
}

/* The title at the start (it outranks the phones' centred section titles,
   homepage-sections.css) */
.page-homepage .qs-product-carousel .qs-pc-head .showcase-section-heading {
    grid-column: 1;
    text-align: start;
    width: auto;
}

.page-homepage .qs-product-carousel .qs-pc-arrows {
    grid-column: 2;
    justify-self: end;
    display: flex;
    gap: 6px;
}

.page-homepage .qs-product-carousel .qs-pc-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    margin: 0;
    border: 1px solid #e5e5e5;
    border-radius: 50%;
    background: #fff;
    color: #999999;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.page-homepage .qs-product-carousel .qs-pc-arrow:disabled {
    cursor: default;
}

.page-homepage .qs-product-carousel .qs-pc-arrow svg {
    display: block;
    width: 7px;
    height: 12px;
}

/* One chevron drawing, pointing left (‹); the next arrow points right (›) */
.page-homepage .qs-product-carousel .qs-pc-arrow--next svg {
    transform: scaleX(-1);
}

/* Arabic pages run right to left: the first products are on the right, the
   arrows sit on the left end and point the other way: ‹ previous points
   right, › next points left. Same selectors as the rules above plus
   [dir="rtl"], so they outrank them (tests/test-product-carousel-arrows.js) */
[dir="rtl"] .page-homepage .qs-product-carousel .qs-pc-arrow--prev svg {
    transform: scaleX(-1);
}

[dir="rtl"] .page-homepage .qs-product-carousel .qs-pc-arrow--next svg {
    transform: none;
}

/* --------------------------------------------------------------------------
   The row
   -------------------------------------------------------------------------- */
.page-homepage .qs-product-carousel .qs-pc-viewport {
    width: 100%;
    min-width: 0;
}

.page-homepage .qs-product-carousel .products-container.qs-pc-track {
    display: flex !important;
    flex-wrap: nowrap;
    grid-template-columns: none !important;
    grid-template-rows: none !important;
    grid-template-areas: none !important;
    column-gap: 24px !important;
    row-gap: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.page-homepage .qs-product-carousel .products-container.qs-pc-track::-webkit-scrollbar {
    display: none;
}

/* Every card shows (the 2 × 2 phone grid hides the fifth on). Four across:
   the default, and qs-pc--per-row-4 (ARKAN-462); five below */
.page-homepage .qs-product-carousel .products-container.qs-pc-track > * {
    display: flex !important;
    flex: 0 0 calc((100% - 3 * 24px) / 4);
    min-width: 0;
    grid-area: auto !important;
    scroll-snap-align: start;
}

/* Five across, for a section set to 5 (ARKAN-462). Desktop only: under
   1024px every carousel keeps two across (below) */
@media (min-width: 1024px) {
    .page-homepage .qs-product-carousel.qs-pc--per-row-5 .products-container.qs-pc-track > * {
        flex-basis: calc((100% - 4 * 24px) / 5);
    }
}

/* A mouse drag (js/homepage-product-carousel.js): the row follows the
   pointer freely, then settles on a card */
.page-homepage .qs-product-carousel .products-container.qs-pc-track.is-dragging {
    scroll-snap-type: none;
    cursor: grabbing;
    -webkit-user-select: none;
    user-select: none;
}

.page-homepage .qs-product-carousel .products-container.qs-pc-track.is-dragging * {
    cursor: grabbing !important;
}

/* A swipe on a card's photo scrolls the row here (the colour swipe holds
   sideways moves elsewhere; collection-colour-swiper.css) */
.page-homepage .qs-product-carousel .qs-pc-track .product-card-image.qs-cs,
.page-homepage .qs-product-carousel .qs-pc-track .product-card-image {
    touch-action: pan-x pan-y;
}

/* --------------------------------------------------------------------------
   Phones and tablets (under 1024px): two cards across, 14px apart; the title
   keeps the other sections' 32px below it
   -------------------------------------------------------------------------- */
@media (max-width: 1023px) {
    .page-homepage .qs-product-carousel .showcase-section-heading-row.qs-pc-head {
        margin-bottom: 32px;
        column-gap: 8px;
    }

    .page-homepage .qs-product-carousel .qs-pc-head .showcase-section-heading {
        margin-bottom: 0;
    }

    .page-homepage .qs-product-carousel .qs-pc-arrow {
        width: 28px;
        height: 28px;
    }

    .page-homepage .qs-product-carousel .qs-pc-arrow svg {
        width: 6px;
        height: 10px;
    }

    .page-homepage .qs-product-carousel .products-container.qs-pc-track {
        column-gap: 14px !important;
        border-radius: 0 !important;
        background: transparent !important;
    }

    .page-homepage .qs-product-carousel .products-container.qs-pc-track > * {
        flex-basis: calc((100% - 14px) / 2);
    }
}
