/* =========================================================================
   Sugar Skin Product Card
   Override any variable in Elementor → Site Settings → Custom CSS, e.g.
   .sspc-card { --sspc-title-font: "YourSerif"; --sspc-gallery-position: center 40%; }
   ========================================================================= */

/* Defaults at zero specificity so any .sspc-card { --sspc-… } override wins regardless of load order */
:where(.sspc-card) {
    --sspc-bg: #f5f5f5;
    --sspc-radius: 18px;
    --sspc-title-color: #6e6464;
    --sspc-btn-border: #6e6464;
    --sspc-btn-color: #414141;
    --sspc-btn-hover-bg: #6e6464;
    --sspc-btn-hover-color: #fff;
    --sspc-dot: rgba(110, 100, 100, .28);
    --sspc-dot-active: #6e6464;
    /* Image box: square by default (follows card width → equal heights in a row).
       For a fixed height instead: --sspc-media-h: 320px; --sspc-media-ratio: auto; */
    --sspc-media-h: auto;
    --sspc-media-ratio: 1 / 1;
    --sspc-main-position: center top;     /* main (square) image — keeps the in-image title */
    --sspc-gallery-position: center 38%;  /* other gallery images (portrait 2:3) — face/product area */
    --sspc-title-font: var(--e-global-typography-secondary-font-family, inherit);
    --sspc-btn-font: var(--e-global-typography-text-font-family, inherit);
    --sspc-private-lines: rgba(110, 100, 100, .22);  /* watermark on private products (admins only) */
    --sspc-private-gap: 9px;
}

.sspc-card {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    height: 100%;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    background: var(--sspc-bg);
    border-radius: var(--sspc-radius);
    overflow: hidden;
    text-align: left;
}
.sspc-card *, .sspc-card *::before, .sspc-card *::after { box-sizing: border-box; }

/* ---- Product grid (archives, related, upsells) ----
   The theme / Customizer controls columns in Archive Products, so the plugin sets its own grid
   on any ul.products that contains our cards. Change columns with:
   .sspc-grid-vars, ul.products { --sspc-cols-d: 4; --sspc-cols-t: 3; --sspc-cols-m: 2; }
   Disable entirely with: add_filter('sspc_force_grid', '__return_false'); */
ul.products:has(> li.sspc-li) {
    --sspc-cols: var(--sspc-cols-d, 4);
    --sspc-grid-gap: var(--sspc-gap-d, 24px);
    display: grid !important;
    grid-template-columns: repeat(var(--sspc-cols), minmax(0, 1fr)) !important;
    gap: var(--sspc-grid-gap) !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    float: none !important;
}
@media (max-width: 1024px) {
    ul.products:has(> li.sspc-li) { --sspc-cols: var(--sspc-cols-t, 3); --sspc-grid-gap: var(--sspc-gap-t, 20px); }
}
@media (max-width: 767px) {
    ul.products:has(> li.sspc-li) { --sspc-cols: var(--sspc-cols-m, 2); --sspc-grid-gap: var(--sspc-gap-m, 12px); }
}
/* theme clearfix pseudo-elements would otherwise become grid cells */
ul.products:has(> li.sspc-li)::before,
ul.products:has(> li.sspc-li)::after { display: none !important; content: none !important; }

/* Only direct children of a real grid. Inside a theme slider (slick/owl/swiper wrap the items),
   the slider owns width/float/transform — we leave the <li> alone. */
ul.products:has(> li.sspc-li) > li.product.sspc-li {
    display: flex !important;
    flex-direction: column;
    width: auto !important;
    max-width: none !important;
    min-width: 0;
    flex: none !important;
    float: none !important;
    clear: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0;
    background: none;
    box-shadow: none;
    text-align: left;
    transform: none;
}
ul.products li.product.sspc-li { padding-top: 0; padding-bottom: 0; border: 0; background: none; box-shadow: none; text-align: left; height: auto; }
ul.products li.product.sspc-li::before,
ul.products li.product.sspc-li::after { display: none; }

/* ---- Gallery ---- */
.sspc-card .sspc-gallery {
    position: relative;
    margin: 0;
    height: var(--sspc-media-h);
    aspect-ratio: var(--sspc-media-ratio, auto);
    min-height: 0;          /* stop tall images from stretching the ratio box */
    overflow: hidden;
    flex: 0 0 auto;
}
.sspc-card .sspc-gallery .sspc-gallery__track {
    position: absolute;
    inset: 0;
    display: flex;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;   /* swipes on photos stay in the gallery (it loops at the end) */
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.sspc-card .sspc-gallery .sspc-gallery__track::-webkit-scrollbar { display: none; }
.sspc-card .sspc-gallery a.sspc-gallery__slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: block;
    margin: 0;
    padding: 0;
    line-height: 0;
}
.sspc-card.sspc-card .sspc-gallery .sspc-gallery__slide img,
.sspc-card.sspc-card .sspc-gallery .sspc-gallery__slide video {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    object-fit: cover;
    object-position: var(--sspc-gallery-position);
    background: transparent;
}

.sspc-card.sspc-card .sspc-gallery .sspc-gallery__slide.is-main img { object-position: var(--sspc-main-position); }

.sspc-card .sspc-gallery__dots {
    position: absolute;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    width: max-content;
    max-width: var(--sspc-dots-max, 70%);   /* wraps to a new row past this width */
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    pointer-events: none;
}
.sspc-card .sspc-gallery__dots span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--sspc-dot);
    transition: background .2s, transform .2s;
}
.sspc-card .sspc-gallery__dots span.is-active { background: var(--sspc-dot-active); transform: scale(1.15); }

.sspc-card button.sspc-gallery__arrow {
    position: absolute;
    top: 50%;
    z-index: 2;
    width: 32px; height: 32px;
    margin: -16px 0 0;
    padding: 0;
    display: none;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .85);
    color: var(--sspc-title-color);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
    cursor: pointer;
    opacity: 0;
    transition: opacity .2s;
    line-height: 0;
    min-height: 0;
}
.sspc-card .sspc-gallery__arrow--prev { left: 10px; }
.sspc-card .sspc-gallery__arrow--next { right: 10px; }
.sspc-card button.sspc-gallery__arrow[disabled] { opacity: 0 !important; pointer-events: none; }
@media (hover: hover) and (pointer: fine) {
    .sspc-card button.sspc-gallery__arrow { display: flex; }
    .sspc-card:hover button.sspc-gallery__arrow,
    .sspc-card button.sspc-gallery__arrow:focus-visible { opacity: 1; }
}

/* ---- Private product watermark (diagonal lines over the whole card) ---- */
.sspc-card.sspc-card--private::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 5;
    border-radius: inherit;
    pointer-events: none;   /* card stays fully clickable */
    background: repeating-linear-gradient(
        -55deg,
        var(--sspc-private-lines) 0 1px,
        transparent 1px var(--sspc-private-gap)
    );
}

/* ---- Badges ("-20%", "Sold out") — style matches the Elementor template ---- */
.sspc-card .sspc-badge {
    position: absolute;
    top: 12px; right: 12px;
    z-index: 2;
    padding: 4px 9px;
    border-radius: 8px;
    background: var(--sspc-badge-bg, #cecece);
    color: var(--sspc-badge-color, #fff);
    font-family: var(--sspc-btn-font);
    font-size: 15px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    line-height: 1.4;
    pointer-events: none;
}
@media (max-width: 767px) {
    .sspc-card .sspc-badge { font-size: 13px; padding: 3px 7px; top: 8px; right: 8px; }
}

/* ---- Title (hardened: themes often hide/reposition loop titles) ---- */
.sspc-card a.sspc-card__title-link {
    display: block !important;
    position: static !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    text-decoration: none;
    color: inherit;
    padding: 22px 20px 0;
}
.sspc-card .sspc-card__title-link h2.sspc-card__title {
    display: block !important;
    position: static !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
    clip: auto !important;
    clip-path: none !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 0;
    padding: 0;
    color: var(--sspc-title-color);
    font-family: var(--sspc-title-font);
    font-size: 15px;
    line-height: 1.35;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    text-align: center;
}

/* ---- Button (pushed to the bottom → buttons line up across the row) ---- */
.sspc-card .sspc-card__actions {
    margin-top: auto;
    padding: 18px 10px 10px;
}
.sspc-card .sspc-card__actions a.sspc-btn.button {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 9px 16px;
    border: 2px solid var(--sspc-btn-border);
    border-radius: 999px;
    background: transparent;
    color: var(--sspc-btn-color);
    box-shadow: none;
    font-family: var(--sspc-btn-font);
    font-size: 15px;
    line-height: 1.2;
    font-weight: 400;
    letter-spacing: .02em;
    text-transform: uppercase;
    text-align: center;
    text-decoration: none;
    white-space: normal;
    transition: background .2s, color .2s, opacity .2s;
}
.sspc-card .sspc-card__actions a.sspc-btn.button:hover,
.sspc-card .sspc-card__actions a.sspc-btn.button:focus-visible {
    background: var(--sspc-btn-hover-bg);
    color: var(--sspc-btn-hover-color);
    border-color: var(--sspc-btn-hover-bg);
}
.sspc-card .sspc-btn__text { font-weight: 700; }
.sspc-card .sspc-btn__sep { white-space: pre; }
.sspc-card .sspc-btn__price,
.sspc-card .sspc-btn__price .amount,
.sspc-card .sspc-btn__price bdi { color: inherit; font-weight: 400; font-size: inherit; }
.sspc-card .sspc-btn__price del { opacity: .55; margin-right: 4px; }
.sspc-card .sspc-btn__price ins { text-decoration: none; background: none; }
.sspc-card .sspc-btn__price .screen-reader-text { position: absolute; clip: rect(1px, 1px, 1px, 1px); width: 1px; height: 1px; overflow: hidden; }
.sspc-card .sspc-card__actions a.sspc-btn.button.loading { opacity: .6; pointer-events: none; }
.sspc-card .sspc-card__actions a.sspc-btn.button.loading::after,
.sspc-card .sspc-card__actions a.sspc-btn.button.added::after { display: none; }
.sspc-card .sspc-card__actions a.sspc-btn--soldout { opacity: .6; }
/* Woo appends a "View cart" link after AJAX add — not wanted inside the card */
.sspc-card .sspc-card__actions .added_to_cart { display: none !important; }

/* ---- Small screens (2-column archive) ---- */
@media (max-width: 767px) {
    :where(.sspc-card) { --sspc-radius: 14px; }
    .sspc-card a.sspc-card__title-link { padding: 16px 12px 0; }
    .sspc-card .sspc-card__title-link h2.sspc-card__title { font-size: 13px; letter-spacing: .06em; }
    .sspc-card .sspc-card__actions { padding: 14px 8px 8px; }
    .sspc-card .sspc-card__actions a.sspc-btn.button { min-height: 38px; padding: 6px 6px; font-size: 12px; letter-spacing: .04em; }
}

/* =========================================================================
   Carousel  [sspc_products_carousel]
   ========================================================================= */
.sspc-carousel {
    --sspc-pv: var(--sspc-pv-d, 4);
    --sspc-g: var(--sspc-gap, 20px);
    position: relative;
    width: 100%;
}
@media (max-width: 1024px) { .sspc-carousel { --sspc-pv: var(--sspc-pv-t, 2.5); } }
@media (max-width: 767px)  { .sspc-carousel { --sspc-pv: var(--sspc-pv-m, 1.15); --sspc-g: var(--sspc-gap-m, 12px); } }

.sspc-carousel__viewport { position: relative; }
ul.sspc-carousel__track {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: calc((100% - (var(--sspc-pv) - 1) * var(--sspc-g)) / var(--sspc-pv));
    gap: var(--sspc-g);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
ul.sspc-carousel__track::-webkit-scrollbar { display: none; }
ul.sspc-carousel__track > li.sspc-carousel__slide {
    display: flex;
    margin: 0;
    padding: 0;
    min-width: 0;
    scroll-snap-align: start;
    list-style: none;
}
ul.sspc-carousel__track > li.sspc-carousel__slide::before { display: none; }
.sspc-carousel.is-dragging ul.sspc-carousel__track { scroll-snap-type: none; cursor: grabbing; user-select: none; }
.sspc-carousel.is-dragging a { pointer-events: none; }

.sspc-carousel__dots {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 80%;
    margin-left: auto;
    margin-right: auto;
    gap: 10px;
    margin-top: 16px;
}
.sspc-carousel__dots button {
    width: 9px; height: 9px;
    min-height: 0;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 50%;
    background: #dcdcdc;
    cursor: pointer;
    transition: background .2s;
}
.sspc-carousel__dots button.is-active { background: #6e6464; }
.sspc-carousel__dots[hidden] { display: none; }

button.sspc-carousel__arrow {
    position: absolute;
    top: 50%;
    z-index: 3;
    width: 42px; height: 42px;
    margin: -21px 0 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #6e6464;
    border-radius: 50%;
    background: #fff;
    color: #6e6464;
    cursor: pointer;
    line-height: 0;
    min-height: 0;
    transition: opacity .2s;
}
.sspc-carousel__arrow--prev { left: -12px; }
.sspc-carousel__arrow--next { right: -12px; }
button.sspc-carousel__arrow[disabled] { opacity: 0; pointer-events: none; }
@media (max-width: 767px) { button.sspc-carousel__arrow { display: none; } }
.sspc-card .sspc-btn__price { white-space: nowrap; }
.sspc-card--carousel .sspc-card__actions a.sspc-btn.button { white-space: nowrap; }

/* =========================================================================
   Load More (archives)
   ========================================================================= */
.sspc-loadmore {
    display: flex;
    justify-content: center;
    margin: 36px 0 8px;
}
.sspc-loadmore button.sspc-loadmore__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    min-width: 120px;
    margin: 0;
    padding: 9px 24px;
    border: 0;
    border-radius: 999px;
    background: var(--sspc-loadmore-bg, #414141);
    color: var(--sspc-loadmore-color, #fff);
    box-shadow: none;
    font-family: var(--e-global-typography-text-font-family, inherit);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: 0;
    text-transform: none;
    cursor: pointer;
    transition: opacity .2s, background .2s;
}
.sspc-loadmore button.sspc-loadmore__btn:hover { opacity: .85; }
.sspc-loadmore button.sspc-loadmore__btn:disabled { opacity: .6; cursor: progress; }

/* Cards inside a theme slider (related products, upsells…): the slider sets slide widths
   but leaves no gutter, so add one. Change with: .sspc-card { --sspc-slider-gap: 24px; } */
ul.products:not(:has(> li.sspc-li)) li.sspc-li > .sspc-card {
    width: auto;
    margin-left: calc(var(--sspc-slider-gap, 20px) / 2);
    margin-right: calc(var(--sspc-slider-gap, 20px) / 2);
}
