/*
 * Customer photos in the product gallery (ReviewPhotosGallery) and the
 * full-screen view caption.
 */

/* Customer photos come in any shape: each sits in a frame with the product
   image's aspect ratio (set inline), shown whole over a blurred copy of itself,
   so the gallery keeps one height. */
.asa-review-photo__frame {
    position: relative;
    display: block;
    width: 100%;
    overflow: hidden;
    aspect-ratio: var(--asa-photo-ratio, 1 / 1);
    background: #ece9e4;
}

.asa-review-photo__backdrop {
    position: absolute;
    inset: -24px;
    background-position: center;
    background-size: cover;
    filter: blur(20px) brightness(.92) saturate(1.1);
    transform: scale(1.08);
}

.woocommerce-product-gallery .asa-review-photo__frame img {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    max-width: none;
    height: 100%;
    object-fit: contain;
}

/* Caption bar along the bottom of a customer photo slide. The gallery's own
   buttons (full screen, video) sit at the inline-start corner: keep clear. */
.woocommerce-product-gallery figure:has(.asa-review-caption) {
    position: relative;
}

.asa-review-caption {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 36px 16px 14px;
    padding-inline-start: 84px;
    background: linear-gradient(to top, rgba(0, 0, 0, .78) 0, rgba(0, 0, 0, .5) 55%, rgba(0, 0, 0, 0) 100%);
    color: #fff;
    text-align: start;
    pointer-events: none;
    transition: opacity .2s;
}

.asa-review-caption__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    font-size: 13px;
    line-height: 1.6;
}

/* "Buyer" tag after the reviewer's name. */
.asa-review-tag {
    display: inline-flex;
    align-items: center;
    padding: 0 8px;
    border: 1px solid #3a8418;
    border-radius: 999px;
    background: #fff;
    color: #3a8418;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.8;
    white-space: nowrap;
}

.asa-review-caption__name {
    font-weight: 700;
}

.asa-review-caption__stars,
.asa-pswp-review__stars {
    color: #f5b301;
    font-size: 12px;
    letter-spacing: 1px;
    direction: ltr;
}

.asa-review-caption__text {
    display: -webkit-box;
    overflow: hidden;
    margin: 0;
    font-size: 13px;
    line-height: 1.8;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

/* Out of the way while the hover zoom is in use. */
@media (hover: hover) {
    .woocommerce-product-gallery figure:hover .asa-review-caption {
        opacity: 0;
    }
}

@media (max-width: 767px) {
    .asa-review-caption {
        padding: 28px 12px 10px;
        padding-inline-start: 60px;
    }

    .asa-review-caption__text {
        font-size: 12px;
        -webkit-line-clamp: 1;
    }
}

/* Marker on the thumbnails of customer photos (set by review-photos.js). */
.wd-gallery-thumb .asa-review-thumb {
    position: relative;
}

.wd-gallery-thumb .asa-review-thumb::after {
    content: "";
    position: absolute;
    bottom: 5px;
    inset-inline-start: 5px;
    width: 20px;
    height: 20px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #3a8418 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23fff'%3E%3Cpath d='M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10zm0 2c-4.4 0-8 2.2-8 5v3h16v-3c0-2.8-3.6-5-8-5z'/%3E%3C/svg%3E") center/11px no-repeat;
    box-sizing: border-box;
    pointer-events: none;
}

/* Full-screen view: a customer photo with its review in a panel beside it
   (below it on phones); review-photos.js builds the slide and sets --asa-r,
   the photo's width / height. The photo frame is sized from it, so photo and
   panel sit together in the middle with no gap between them. */
.asa-pswp-slide {
    --asa-panel-w: 340px;
    --asa-gap: 24px;
    --asa-avail-w: calc(100vw - 144px - var(--asa-panel-w) - var(--asa-gap));
    --asa-avail-h: calc(100dvh - 100px);
    --asa-media-w: min(var(--asa-avail-w), calc(var(--asa-avail-h) * var(--asa-r, 1)));
    --asa-media-h: calc(var(--asa-media-w) / var(--asa-r, 1));
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--asa-gap);
    /* PhotoSwipe's HTML holder has no size of its own. */
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    padding: 64px 72px 36px;
    direction: rtl;
}

.asa-pswp-slide__media {
    flex: 0 0 auto;
    width: var(--asa-media-w);
    height: var(--asa-media-h);
}

/* Beats PhotoSwipe's ".pswp img { max-width: none }", which loads later. */
.pswp .asa-pswp-slide .asa-pswp-slide__media img {
    display: block;
    width: 100%;
    max-width: none;
    height: 100%;
    border-radius: 8px;
    object-fit: contain;
}

.asa-pswp-slide__panel {
    box-sizing: border-box;
    flex: 0 0 var(--asa-panel-w);
    height: max(var(--asa-media-h), 260px);
    max-height: var(--asa-avail-h);
    padding-inline-end: 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    scrollbar-color: rgba(255, 255, 255, .45) transparent;
    scrollbar-width: thin;
}

.asa-pswp-review {
    direction: rtl;
    color: #fff;
    font-size: 14px;
    line-height: 2;
    text-align: right;
}

.asa-pswp-review__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, .15);
}

.asa-pswp-review__name {
    font-size: 15px;
    font-weight: 700;
}

.asa-pswp-review__stars {
    font-size: 16px;
}

.asa-pswp-review__date {
    flex-basis: 100%;
    opacity: .65;
    font-size: 12px;
}

.asa-pswp-review__text {
    margin: 0;
    white-space: pre-line;
}

/* Beats the theme's button styles. */
.pswp .asa-pswp-review .asa-pswp-review__more {
    display: none;
}

@media (max-width: 767px) {
    .asa-pswp-slide {
        --asa-avail-w: calc(100vw - 24px);
        --asa-avail-h: calc(100dvh - 300px);
        flex-direction: column;
        justify-content: center;
        gap: 14px;
        padding: 50px 12px 16px;
    }

    .asa-pswp-slide__panel {
        flex: 0 0 auto;
        align-self: stretch;
        height: auto;
        max-height: 34dvh;
        padding: 0 0 0 4px;
        overflow-y: hidden;
    }

    .asa-pswp-slide__panel.is-expanded {
        overflow-y: auto;
    }

    .asa-pswp-review {
        font-size: 13px;
        line-height: 1.9;
    }

    .asa-pswp-review__head {
        margin-bottom: 6px;
        padding-bottom: 0;
        border-bottom: 0;
    }

    .asa-pswp-review__date {
        display: none;
    }

    .asa-pswp-slide__panel:not(.is-expanded) .asa-pswp-review__text {
        display: -webkit-box;
        overflow: hidden;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
    }

    .pswp .asa-pswp-review .asa-pswp-review__more:not([hidden]) {
        display: inline-flex;
        min-height: 0;
        box-shadow: none;
        text-transform: none;
        align-items: center;
        gap: 4px;
        margin-top: 6px;
        padding: 0;
        border: 0;
        background: none;
        color: rgba(255, 255, 255, .7);
        font: inherit;
        font-size: 13px;
        cursor: pointer;
    }

    .asa-pswp-review__more::after {
        content: "";
        width: 10px;
        height: 10px;
        background: currentColor;
        -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15.4 4.6 8 12l7.4 7.4 1.4-1.4-6-6 6-6z'/%3E%3C/svg%3E") center/contain no-repeat;
        mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15.4 4.6 8 12l7.4 7.4 1.4-1.4-6-6 6-6z'/%3E%3C/svg%3E") center/contain no-repeat;
    }

    .asa-pswp-slide__panel.is-expanded .asa-pswp-review__more::after {
        transform: rotate(90deg);
    }
}
