/**
 * Brand Carousel — frontend styles.
 *
 * Sizing is driven by CSS custom properties so the logo box can be tuned from
 * one place (or overridden per instance with an Additional CSS class).
 */

.wp-block-sophia-blocks-brand-carousel {
    --brand-item-width: 200px;
    --brand-logo-height: 90px;
    --brand-gap: 32px;
}

/* Doubled class on purpose: the theme's own `.wp-block-section` rule sets
   padding-top: 0, so a single-class selector here would win or lose purely on
   stylesheet order. Matching its specificity makes this section deterministic. */
.wp-block-sophia-blocks-brand-carousel.wp-block-section {
    padding-top: var(--wp--preset--spacing--42, 60px);
    padding-bottom: var(--wp--preset--spacing--42, 60px);
    background-color: #ffffff;
    /* The track scrolls its own overflow; this stops any overshoot from
       extending the page and creating a horizontal scrollbar. `clip` is
       preferred because, unlike `hidden`, it does not make this element a
       scroll container. */
    overflow-x: hidden;
    overflow-x: clip;
}

.wp-block-sophia-blocks-brand-carousel .brand-carousel-inner {
    max-width: var(--wp--style--global--wide-size, 1320px);
    margin-inline: auto;
    padding-inline: var(--wp--preset--spacing--42, 24px);
}

/* Heading ------------------------------------------------------------------ */

.wp-block-sophia-blocks-brand-carousel .brand-carousel-heading {
    margin-bottom: var(--wp--preset--spacing--40, 32px);
    text-align: center;
}

/* Matches the "Featured Cigars" treatment used by the product carousel. */
.wp-block-sophia-blocks-brand-carousel .brand-carousel-heading h2 {
    margin: 0;
    font-size: var(--wp--preset--font-size--extra-large, clamp(24px, 2.6vw, 42px));
    font-weight: 700;
    line-height: 1.25;
}

.wp-block-sophia-blocks-brand-carousel .brand-carousel-subheading {
    margin: 12px 0 0;
}

/* Track ------------------------------------------------------------------- */

.wp-block-sophia-blocks-brand-carousel .brand-carousel-container {
    position: relative;
    display: flex;
    align-items: center;
}

.wp-block-sophia-blocks-brand-carousel .brand-track {
    display: flex;
    gap: var(--brand-gap);
    flex: 1;
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    /* Stops a swipe that reaches the end of the track from chaining into the
       page scroll or the browser's back gesture. */
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-block: 8px;
}

.wp-block-sophia-blocks-brand-carousel .brand-track::-webkit-scrollbar {
    display: none;
}

.wp-block-sophia-blocks-brand-carousel .brand-item {
    flex: 0 0 var(--brand-item-width);
    scroll-snap-align: start;
}

.wp-block-sophia-blocks-brand-carousel .brand-link {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--brand-logo-height);
    padding: 10px;
    text-decoration: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.wp-block-sophia-blocks-brand-carousel .brand-link:hover,
.wp-block-sophia-blocks-brand-carousel .brand-link:focus-visible {
    transform: translateY(-3px);
}

.wp-block-sophia-blocks-brand-carousel .brand-logo {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    /* Logos arrive in mixed colours; unify them, then reveal colour on hover. */
    filter: grayscale(100%);
    opacity: 0.75;
    transition: filter 0.3s ease, opacity 0.3s ease;
}

.wp-block-sophia-blocks-brand-carousel .brand-link:hover .brand-logo,
.wp-block-sophia-blocks-brand-carousel .brand-link:focus-visible .brand-logo {
    filter: grayscale(0);
    opacity: 1;
}

/* Brands with no image assigned still get a usable label. */
.wp-block-sophia-blocks-brand-carousel .brand-logo-fallback {
    font-size: var(--wp--preset--font-size--normal, 16px);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: center;
    color: inherit;
}

/* Grid mode — every brand visible at once, for an "all brands" listing page. */

.wp-block-sophia-blocks-brand-carousel.is-display-grid .brand-carousel-container {
    display: block;
}

.wp-block-sophia-blocks-brand-carousel.is-display-grid .brand-track {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--brand-item-width), 1fr));
    row-gap: calc(var(--brand-gap) * 1.5);
    overflow: visible;
    scroll-snap-type: none;
}

.wp-block-sophia-blocks-brand-carousel.is-display-grid .brand-item {
    flex: initial;
}

/* Navigation -------------------------------------------------------------- */

.wp-block-sophia-blocks-brand-carousel .brand-nav-button {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: opacity 0.3s ease, background-color 0.3s ease;
}

.wp-block-sophia-blocks-brand-carousel .brand-nav-button:hover:not(:disabled) {
    background-color: rgba(0, 0, 0, 0.06);
}

.wp-block-sophia-blocks-brand-carousel .brand-nav-button:disabled {
    opacity: 0.25;
    cursor: default;
}

.wp-block-sophia-blocks-brand-carousel .brand-nav-button[hidden] {
    display: none;
}

.wp-block-sophia-blocks-brand-carousel .brand-nav-icon {
    width: 22px;
    height: 22px;
}

/* View all button --------------------------------------------------------- */

.wp-block-sophia-blocks-brand-carousel .brand-carousel-footer {
    margin-top: var(--wp--preset--spacing--40, 32px);
    text-align: center;
}

.wp-block-sophia-blocks-brand-carousel .brand-view-all {
    display: inline-block;
    padding: 14px 34px;
    border: 1px solid currentColor;
    border-radius: 4px;
    font-size: var(--wp--preset--font-size--body-default, 16px);
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.wp-block-sophia-blocks-brand-carousel .brand-view-all:hover,
.wp-block-sophia-blocks-brand-carousel .brand-view-all:focus-visible {
    background-color: var(--wp--preset--color--tan-brown, #954e26);
    border-color: var(--wp--preset--color--tan-brown, #954e26);
    color: var(--wp--preset--color--background, #fff);
}

/* Empty state ------------------------------------------------------------- */

.wp-block-sophia-blocks-brand-carousel.brand-carousel-empty p {
    margin: 0;
    padding: 24px;
    text-align: center;
    opacity: 0.7;
}

/* Responsive -------------------------------------------------------------- */

@media (max-width: 1024px) {
    .wp-block-sophia-blocks-brand-carousel {
        --brand-item-width: 170px;
        --brand-logo-height: 80px;
        --brand-gap: 24px;
    }
}

@media (max-width: 768px) {
    .wp-block-sophia-blocks-brand-carousel {
        --brand-item-width: 140px;
        --brand-logo-height: 70px;
        --brand-gap: 16px;
    }

    .wp-block-sophia-blocks-brand-carousel .brand-nav-button {
        display: none;
    }

    /* Without arrows, make it obvious the row can be swiped. */
    .wp-block-sophia-blocks-brand-carousel .brand-track {
        scroll-snap-type: x proximity;
    }
}
