/* ============================================================
   ACF ACF Product Display — Frontend Styles
   ============================================================ */

/* ── Gallery wrapper ─────────────────────────────────────── */
.aapd-gallery {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
    max-width: 100%;
}

/* ── Main image ──────────────────────────────────────────── */
.aapd-gallery__main {
    position: relative;
    display: inline-block;
    line-height: 0;
    overflow: hidden;
    border-radius: 6px;
    background: #f5f5f5;
    cursor: zoom-in;
}

.aapd-gallery__main-img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 520px;
    object-fit: contain;
    transition: opacity .25s ease, transform .25s ease;
    border-radius: 6px;
}

.aapd-gallery__main-img.aapd-gallery--loading {
    opacity: .4;
    transform: scale(.99);
}

.aapd-gallery__main:focus-within .aapd-gallery__zoom-hint,
.aapd-gallery__main:hover .aapd-gallery__zoom-hint {
    opacity: 1;
}

.aapd-gallery__zoom-hint {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,.55);
    color: #fff;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
}

/* ── Thumbnails ──────────────────────────────────────────── */
.aapd-gallery__thumbs {
    display: flex;
    flex-direction: row;
    gap: 10px;
    flex-wrap: wrap;
}

.aapd-gallery__thumb {
    padding: 0;
    border: 2px solid #ddd;
    border-radius: 4px;
    background: #fafafa;
    cursor: pointer;
    overflow: hidden;
    transition: border-color .2s, transform .15s, box-shadow .15s;
    flex-shrink: 0;
    line-height: 0;
    outline: none;
}

.aapd-gallery__thumb img {
    display: block;
    width: 90px;
    height: 90px;
    object-fit: cover;
    transition: opacity .15s;
}

.aapd-gallery__thumb:hover {
    border-color: #888;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
}

.aapd-gallery__thumb:focus-visible {
    border-color: #2271b1;
    box-shadow: 0 0 0 3px rgba(34,113,177,.3);
}

.aapd-gallery__thumb--active {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

.aapd-gallery__thumb--active img { opacity: 1; }

/* ── Lightbox ────────────────────────────────────────────── */
.aapd-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.aapd-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .88);
    cursor: zoom-out;
    animation: apd-fade-in .2s ease;
}

.aapd-lightbox__frame {
    position: relative;
    z-index: 1;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    animation: apd-zoom-in .2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aapd-lightbox__img {
    display: block;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0,0,0,.6);
    user-select: none;
}

.aapd-lightbox__close {
    position: absolute;
    top: -42px;
    right: -2px;
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 50%;
    color: #fff;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s;
    padding: 0;
}
.aapd-lightbox__close:hover { background: rgba(255,255,255,.28); }
.aapd-lightbox__close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ── Misc ────────────────────────────────────────────────── */
.aapd-error {
    background: #fff0f0;
    border: 1px solid #fca5a5;
    color: #991b1b;
    padding: 10px 14px;
    border-radius: 4px;
    font-size: .9rem;
}

.aapd-edit-link {
    display: inline-block;
    font-size: .75rem;
    padding: 3px 9px;
    background: #f0f0f1;
    border: 1px solid #c3c4c7;
    border-radius: 3px;
    color: #646970;
    text-decoration: none;
    margin-top: 8px;
    transition: background .15s;
}
.aapd-edit-link:hover { background: #e0e0e0; color: #1d2327; }

.aapd-gallery-empty { color: #888; font-style: italic; }

/* ── Animations ──────────────────────────────────────────── */
@keyframes apd-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes apd-zoom-in {
    from { opacity: 0; transform: scale(.93); }
    to   { opacity: 1; transform: scale(1); }
}
