/*
 * WGE Painted by the Community.
 *
 * Colours come from the theme's --gbl-primary-color custom property, with the
 * brand red as a fallback, so this follows a customizer change instead of
 * hard-coding a second near-identical red — a mistake this store has made
 * before with #af111c.
 */

/* --- The gallery on the product page ------------------------------------ */
.wge-pbc {
    margin: 40px 0;
    clear: both;
}

.wge-pbc__title {
    margin: 0 0 6px;
    font-size: 20px;
    line-height: 1.2;
}

.wge-pbc__lead {
    margin: 0 0 18px;
    color: #5a5a5a;
    font-size: 15px;
    line-height: 1.5;
}

.wge-pbc__lead--empty {
    max-width: 60ch;
}

.wge-pbc__grid,
.wge-pbc-review-photos {
    margin: 0;
    padding: 0;
    list-style: none;
    max-width: 100%;
}

.wge-pbc__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    min-width: 0;
}

/*
 * Inside a review the photos are supporting evidence, not the subject, so they
 * are small and left-aligned rather than stretched across the column.
 *
 * FLEX, NOT GRID, and that is not a style preference. The first version used
 * `grid-template-columns: repeat(auto-fill, minmax(88px, 1fr))` with a
 * `max-width: 460px`, and it gave the whole product page 131px of horizontal
 * scroll at 390px wide. The theme's `.comment_container` does not give its
 * children a definite width, and an `auto-fill` track list in an indefinite
 * container is resolved against the container's *max-content* size — so the
 * grid asked for as many 88px columns as its own max-width allowed (four, 404px)
 * and dragged `.comment-text` out to 438px inside a 390px viewport.
 *
 * A wrapping flex row cannot do that: its min-content contribution is one item,
 * 88px, whatever the container is doing. Measure the document's scrollWidth
 * against clientWidth on a 390px viewport before changing this back.
 */
.wge-pbc-review-photos {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 0;
}

.wge-pbc-review-photos .wge-pbc-photo {
    flex: 0 0 auto;
    width: 88px;
}

/* WooCommerce and this theme both put bullets and counters on li elements deep
   in the product page; these lists are grids and want neither. */
.wge-pbc__grid > li::before,
.wge-pbc-review-photos > li::before {
    content: none;
}

.wge-pbc-photo {
    margin: 0;
    padding: 0;
}

.wge-pbc-photo__btn {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: #f3f3f3;
    cursor: zoom-in;
    overflow: hidden;
    line-height: 0;
}

.wge-pbc-photo__btn:focus-visible {
    outline: 2px solid var(--gbl-primary-color, #a12324);
    outline-offset: 2px;
}

/* aspect-ratio on the image itself, not a height on the box.
   The box has no height of its own, so a percentage height would compute to
   auto and object-fit would have nothing to work against — the same trap
   documented for the product card thumbnails. */
.wge-pbc-photo__btn img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
    transition: transform .25s ease-in-out;
}

@media (hover: hover) {
    .wge-pbc-photo__btn:hover img {
        transform: scale(1.04);
    }
}

.wge-pbc-photo__by {
    display: block;
    margin: 5px 0 0;
    color: #767676;
    font-size: 12px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wge-pbc-review-photos .wge-pbc-photo__by {
    display: none;
}

/* --- The upload control in the review form ------------------------------ */
.wge-pbc-field {
    margin: 0 0 20px;
    padding: 16px;
    border: 1px dashed #d0d0d0;
    border-radius: 6px;
    background: #fafafa;
}

.wge-pbc-field__label {
    display: block;
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 700;
}

.wge-pbc-field__hint {
    margin: 0 0 12px;
    color: #5a5a5a;
    font-size: 13px;
    line-height: 1.45;
}

.wge-pbc-add {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border: 1px solid var(--gbl-primary-color, #a12324);
    border-radius: 4px;
    background: #fff;
    color: var(--gbl-primary-color, #a12324);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.wge-pbc-add:hover {
    background: var(--gbl-primary-color, #a12324);
    color: #fff;
}

/* The real input is driven by the label wrapping it. Kept in the layout and
   merely invisible rather than display:none, so it stays focusable and the
   keyboard path works. */
.wge-pbc-add input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.wge-pbc-add:focus-within {
    outline: 2px solid var(--gbl-primary-color, #a12324);
    outline-offset: 2px;
}

.wge-pbc-queue {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
}

.wge-pbc-queue:empty {
    margin: 0;
}

.wge-pbc-queue > li::before {
    content: none;
}

.wge-pbc-item {
    position: relative;
    width: 84px;
    height: 84px;
    margin: 0;
    padding: 0;
    border-radius: 4px;
    background: #eee;
    overflow: hidden;
}

.wge-pbc-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.wge-pbc-item.is-uploading img {
    opacity: .45;
}

.wge-pbc-item__status {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    color: #333;
    font-size: 11px;
    text-align: center;
}

.wge-pbc-item__remove {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .65);
    color: #fff;
    font-size: 16px;
    line-height: 22px;
    cursor: pointer;
}

.wge-pbc-item__remove:hover {
    background: var(--gbl-primary-color, #a12324);
}

.wge-pbc-error {
    margin: 12px 0 0;
    color: #a12324;
    font-size: 13px;
    line-height: 1.45;
}

/* --- Lightbox ------------------------------------------------------------ */
.wge-pbc-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, .88);
}

.wge-pbc-lightbox[hidden] {
    display: none;
}

.wge-pbc-lightbox__figure {
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    text-align: center;
}

.wge-pbc-lightbox img {
    max-width: 100%;
    max-height: 82vh;
    display: block;
    margin: 0 auto;
    border-radius: 4px;
}

.wge-pbc-lightbox__by {
    margin: 12px 0 0;
    color: #e6e6e6;
    font-size: 14px;
}

.wge-pbc-lightbox__close {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: none;
    color: #fff;
    font-size: 34px;
    line-height: 1;
    cursor: pointer;
}

.wge-pbc-locked {
    overflow: hidden;
}

@media (max-width: 600px) {
    .wge-pbc__grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }
}
