/* ═══════════════════════════════════════════════════════════
   Product Gallery — Premium Component
   Namespace: .pg   (zero conflict with existing styles)
   ═══════════════════════════════════════════════════════════ */

/* ── Design tokens ───────────────────────────────────────── */
.pg {
    --pg-accent: #461959;
    --pg-accent-soft: rgba(70, 25, 89, 0.12);
    --pg-accent-ring: rgba(70, 25, 89, 0.25);
    --pg-surface: #ffffff;
    --pg-surface-alt: #f6f6f8;
    --pg-border: rgba(0, 0, 0, 0.08);
    --pg-border-strong: rgba(0, 0, 0, 0.14);
    --pg-text: #1d1d1f;
    --pg-text-secondary: rgba(255, 255, 255, 0.92);
    --pg-radius: 16px;
    --pg-radius-sm: 10px;
    --pg-ease: cubic-bezier(0.25, 0.1, 0.25, 1);
    --pg-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --pg-thumb-size: 64px;
    --pg-zoom-scale: 2.4;
    position: relative;
    width: 100%;
}

/* ── Dark mode ───────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    .pg {
        --pg-surface: #1c1c1e;
        --pg-surface-alt: #2c2c2e;
        --pg-border: rgba(255, 255, 255, 0.08);
        --pg-border-strong: rgba(255, 255, 255, 0.14);
        --pg-text: #f5f5f7;
    }
}

/* ═══════════════════════════════════════════════════════════
   SKELETON
   ═══════════════════════════════════════════════════════════ */

@keyframes pg-shimmer {
    0%   { background-position: -468px 0; }
    100% { background-position: 468px 0; }
}

.pg__skel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pg__skel-stage {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: var(--pg-radius);
    background: linear-gradient(90deg, #f2f2f4 28%, #e8e8ec 50%, #f2f2f4 72%);
    background-size: 936px 100%;
    animation: pg-shimmer 1.6s linear infinite;
}

.pg__skel-strip {
    display: flex;
    gap: 8px;
}

.pg__skel-dot {
    width: var(--pg-thumb-size);
    height: var(--pg-thumb-size);
    border-radius: var(--pg-radius-sm);
    flex-shrink: 0;
    background: linear-gradient(90deg, #f2f2f4 28%, #e8e8ec 50%, #f2f2f4 72%);
    background-size: 936px 100%;
    animation: pg-shimmer 1.6s linear infinite;
    animation-delay: calc(var(--i, 0) * 0.08s);
}

.pg__skel-dot:nth-child(1) { --i: 1; }
.pg__skel-dot:nth-child(2) { --i: 2; }
.pg__skel-dot:nth-child(3) { --i: 3; }
.pg__skel-dot:nth-child(4) { --i: 4; }
.pg__skel-dot:nth-child(5) { --i: 5; }
.pg__skel-dot:nth-child(6) { --i: 6; }

/* Hide body until loaded */
.pg__body { display: none; }

.pg--loaded .pg__skel  { display: none; }
.pg--loaded .pg__body  {
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: pg-reveal 0.5s var(--pg-ease) both;
}

@keyframes pg-reveal {
    from { opacity: 0; transform: translateY(8px) scale(0.985); }
    to   { opacity: 1; transform: none; }
}

/* ═══════════════════════════════════════════════════════════
   MAIN IMAGE STAGE
   ═══════════════════════════════════════════════════════════ */

.pg__stage {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: var(--pg-radius);
    background: var(--pg-surface-alt);
    border: 1px solid var(--pg-border);
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
}

/* Zoom cursor only on hover-capable devices */
@media (hover: hover) {
    .pg__stage { cursor: zoom-in; }
}

/* ── Hero image ──────────────────────────────────────────── */

.pg__hero {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 16px;
    transition: transform 0.4s var(--pg-ease), opacity 0.22s ease;
    will-change: transform;
    -webkit-user-drag: none;
}

/* Zoom state — applied on hover via JS */
.pg__hero--zoomed {
    transform: scale(var(--pg-zoom-scale));
    transition: transform 0.1s linear;
}

/* Fade-out during image switch */
.pg__hero--switching {
    opacity: 0;
    transition: opacity 0.18s ease;
}

/* ── Counter badge ───────────────────────────────────────── */

.pg__badge {
    position: absolute;
    bottom: 12px;
    left: 12px;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.4px;
    color: var(--pg-text-secondary);
    background: rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(12px) saturate(1.4);
    -webkit-backdrop-filter: blur(12px) saturate(1.4);
    border-radius: 100px;
    z-index: 4;
    pointer-events: none;
    font-variant-numeric: tabular-nums;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
}

.pg__badge-sep {
    opacity: 0.5;
    margin: 0 1px;
}

/* ── Fullscreen button ───────────────────────────────────── */

.pg__fs {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(12px) saturate(1.4);
    -webkit-backdrop-filter: blur(12px) saturate(1.4);
    color: var(--pg-text);
    cursor: pointer;
    z-index: 4;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: background 0.25s var(--pg-ease),
                color 0.25s var(--pg-ease),
                transform 0.25s var(--pg-ease-spring),
                box-shadow 0.25s var(--pg-ease);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.pg__fs:hover {
    background: var(--pg-accent);
    color: #fff;
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(70, 25, 89, 0.28);
}

.pg__fs:focus-visible {
    box-shadow: 0 0 0 3px var(--pg-accent-ring);
}

.pg__fs:active {
    transform: scale(0.95);
}

/* ═══════════════════════════════════════════════════════════
   THUMBNAIL STRIP (HORIZONTAL — DESKTOP & MOBILE)
   ═══════════════════════════════════════════════════════════ */

.pg__strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    padding: 2px;

    /* Hide scrollbar */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.pg__strip::-webkit-scrollbar {
    display: none;
}

/* ── Individual thumbnail ────────────────────────────────── */

.pg__thumb {
    flex-shrink: 0;
    width: var(--pg-thumb-size);
    height: var(--pg-thumb-size);
    padding: 0;
    border: 2px solid transparent;
    border-radius: var(--pg-radius-sm);
    background: var(--pg-surface);
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    overflow: hidden;
    scroll-snap-align: start;
    transition: border-color 0.25s var(--pg-ease),
                box-shadow 0.3s var(--pg-ease),
                transform 0.3s var(--pg-ease-spring);
    position: relative;
}

.pg__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: calc(var(--pg-radius-sm) - 2px);
    pointer-events: none;
    transition: transform 0.3s var(--pg-ease);
}

/* Hover */
.pg__thumb:hover {
    border-color: var(--pg-border-strong);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.pg__thumb:hover img {
    transform: scale(1.06);
}

/* Focus */
.pg__thumb:focus-visible {
    box-shadow: 0 0 0 3px var(--pg-accent-ring);
    border-color: var(--pg-accent);
}

/* Active state */
.pg__thumb--on {
    border-color: var(--pg-accent);
    box-shadow: 0 0 0 1px var(--pg-accent), 0 2px 8px var(--pg-accent-soft);
    transform: none;
}

.pg__thumb--on:hover {
    transform: none;
}

.pg__thumb--on img {
    transform: none;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */

/* ── Tablet (< 992px) ────────────────────────────────────── */
@media (max-width: 991.98px) {
    .pg {
        --pg-thumb-size: 58px;
        --pg-radius: 14px;
    }

    .pg__hero {
        padding: 12px;
    }
}

/* ── Phone (< 576px) ─────────────────────────────────────── */
@media (max-width: 575.98px) {
    .pg {
        --pg-thumb-size: 50px;
        --pg-radius: 12px;
        --pg-radius-sm: 8px;
    }

    .pg__stage {
        aspect-ratio: 4 / 5;
    }

    .pg__hero {
        padding: 8px;
    }

    .pg__badge {
        font-size: 10px;
        padding: 3px 10px;
        bottom: 8px;
        left: 8px;
    }

    .pg__fs {
        width: 34px;
        height: 34px;
        top: 8px;
        right: 8px;
    }

    .pg__fs svg {
        width: 16px;
        height: 16px;
    }

    .pg__strip {
        gap: 6px;
    }
}

/* ── Disable zoom on touch devices ───────────────────────── */
@media (hover: none) {
    .pg__hero--zoomed {
        transform: none !important;
    }

    .pg__stage {
        cursor: pointer;
    }
}
