/* ================================================================
   Elementor Puzzle Explosion Gallery — Stylesheet v1.0
   ================================================================ */

/* ── Container & Scene ─────────────────────────────────────────── */
.epe-container {
    position: relative;
    width: 100%;
    user-select: none;
    -webkit-user-select: none;
}

.epe-scene {
    position: relative;
    width: 100%;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    box-shadow:
        inset 0 0 60px rgba(0,0,0,0.4),
        0 8px 40px rgba(0,0,0,0.35);
}

/* ── Background Themes ─────────────────────────────────────────── */

.epe-bg-dark_felt {
    background-color: #1a1f28;
    background-image:
        radial-gradient(ellipse at center, rgba(30,36,50,0) 40%, rgba(0,0,0,0.5) 100%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Crect width='1' height='1' x='0' y='0' fill='rgba(255,255,255,0.018)'/%3E%3Crect width='1' height='1' x='2' y='2' fill='rgba(255,255,255,0.018)'/%3E%3C/svg%3E");
}

.epe-bg-cork {
    background-color: #c4935a;
    background-image:
        radial-gradient(ellipse at center, rgba(196,147,90,0) 40%, rgba(100,60,20,0.5) 100%),
        repeating-linear-gradient(
            42deg, transparent, transparent 3px,
            rgba(160,100,40,0.06) 3px, rgba(160,100,40,0.06) 4px
        ),
        repeating-linear-gradient(
            -42deg, transparent, transparent 3px,
            rgba(100,60,20,0.06) 3px, rgba(100,60,20,0.06) 4px
        );
}

.epe-bg-marble {
    background-color: #d8d4cc;
    background-image:
        radial-gradient(ellipse at 30% 40%, rgba(255,255,255,0.3) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 60%, rgba(200,195,188,0.4) 0%, transparent 55%),
        repeating-linear-gradient(
            120deg, transparent, transparent 40px,
            rgba(180,175,168,0.15) 40px, rgba(180,175,168,0.15) 41px
        );
}

.epe-bg-space {
    background-color: #030308;
    background-image:
        radial-gradient(ellipse at 25% 25%, rgba(30,20,80,0.4) 0%, transparent 50%),
        radial-gradient(ellipse at 75% 75%, rgba(10,40,60,0.35) 0%, transparent 50%);
}

.epe-bg-custom {
    background-color: #1a1a2e;
}

/* ── Layers ────────────────────────────────────────────────────── */
.epe-canvas,
.epe-pieces-layer,
.epe-balls-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.epe-canvas { z-index: 1; }         /* Matter.js debug (hidden) */
.epe-pieces-layer { z-index: 2; }   /* Puzzle piece DOM elements */
.epe-balls-layer { z-index: 3; }    /* Rolling ball DOM elements */
.epe-ui-layer { z-index: 10; }      /* Buttons */

/* ── Puzzle Pieces ─────────────────────────────────────────────── */
.epe-piece {
    position: absolute;
    top: 0; left: 0;
    overflow: hidden;
    cursor: pointer;
    border-radius: 2px;
    will-change: transform;
    transform-origin: center center;
    transition: filter 0.2s ease, box-shadow 0.2s ease;
    pointer-events: auto;
}

/* The inner div carries the background-image at full scene size */
.epe-piece-inner {
    position: absolute;
    background-size: cover;
    background-repeat: no-repeat;
    pointer-events: none;
}

/* Drop shadow (toggled via class) */
.epe-piece.epe-shadow {
    box-shadow:
        2px 4px 18px rgba(0,0,0,0.55),
        0 1px 3px rgba(0,0,0,0.35);
}

/* Hover glow – color set inline per piece via CSS variable */
.epe-piece:hover,
.epe-piece.epe-highlighted {
    filter: brightness(1.25) drop-shadow(0 0 10px var(--epe-glow, rgba(255,255,255,0.8)));
    z-index: 20;
}

/* Piece pop-in animation on init */
@keyframes epe-piece-pop {
    0%   { transform: scale(0) rotate(calc(var(--epe-rand, 0) * 30deg)); opacity: 0; }
    70%  { transform: scale(1.04); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* During reassembly the piece slides to its home */
.epe-piece.epe-assembling {
    transition: transform var(--epe-assemble-dur, 800ms) cubic-bezier(0.34, 1.3, 0.64, 1),
                opacity   var(--epe-assemble-dur, 800ms) ease;
    pointer-events: none;
}

/* Assembled glimmer sweep */
@keyframes epe-glimmer {
    0%   { background-position: -200% center; }
    100% { background-position: 300% center; }
}
.epe-scene.epe-assembled .epe-piece::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        105deg,
        transparent 30%,
        rgba(255,255,255,0.22) 48%,
        rgba(255,255,255,0.28) 50%,
        rgba(255,255,255,0.22) 52%,
        transparent 70%
    );
    background-size: 200% 100%;
    animation: epe-glimmer 1.2s ease forwards;
    pointer-events: none;
}

/* Gap line between pieces */
.epe-piece {
    outline: var(--epe-gap, 2px) solid rgba(0,0,0,0.0);
}
.epe-scene.epe-assembled .epe-piece {
    outline-color: rgba(0,0,0,0.18);
}

/* ── Rolling Balls ─────────────────────────────────────────────── */
.epe-ball {
    position: absolute;
    border-radius: 50%;
    will-change: transform;
    pointer-events: none;
    box-shadow:
        inset 0 -3px 8px rgba(0,0,0,0.35),
        0 4px 16px rgba(0,0,0,0.4);
}

/* 3D gloss on ball */
.epe-ball::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 14%;
    width: 38%;
    height: 32%;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    background: radial-gradient(
        ellipse at 40% 35%,
        rgba(255,255,255,0.7) 0%,
        rgba(255,255,255,0.15) 50%,
        transparent 70%
    );
}

/* ── UI Buttons ────────────────────────────────────────────────── */
.epe-ui-layer {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    align-items: center;
}

.epe-btn {
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 24px;
    padding: 8px 22px;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    letter-spacing: 0.04em;
    cursor: pointer;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    white-space: nowrap;
}

.epe-btn:hover {
    background: rgba(255,255,255,0.15);
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.epe-btn:active {
    transform: scale(0.97);
}

.epe-btn-explode {
    border-color: rgba(255,80,80,0.4);
}
.epe-btn-explode:hover {
    background: rgba(200,40,40,0.35);
    box-shadow: 0 0 16px rgba(255,80,80,0.3);
}

.epe-btn-assemble {
    border-color: rgba(80,200,120,0.4);
}
.epe-btn-assemble:hover {
    background: rgba(40,160,80,0.35);
    box-shadow: 0 0 16px rgba(80,200,120,0.3);
}

.epe-btn-next {
    border-color: rgba(80,140,255,0.4);
}
.epe-btn-next:hover {
    background: rgba(40,80,200,0.35);
    box-shadow: 0 0 16px rgba(80,140,255,0.3);
}

/* ── Hint text ─────────────────────────────────────────────────── */
.epe-hint {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.35);
    font-size: 12px;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    pointer-events: none;
    white-space: nowrap;
    transition: opacity 0.4s;
}

/* ── Explosion particle burst ──────────────────────────────────── */
@keyframes epe-spark {
    0%   { transform: translate(-50%,-50%) scale(1); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--sx,0px)), calc(-50% + var(--sy,0px))) scale(0); opacity: 0; }
}
.epe-spark {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    pointer-events: none;
    z-index: 50;
    animation: epe-spark 0.55s cubic-bezier(0.2, 0.8, 0.4, 1) forwards;
}

/* ── Assembled image flash ─────────────────────────────────────── */
@keyframes epe-assembled-flash {
    0%   { box-shadow: inset 0 0 0 0 rgba(255,255,255,0); }
    30%  { box-shadow: inset 0 0 60px 20px rgba(255,255,255,0.18); }
    100% { box-shadow: inset 0 0 0 0 rgba(255,255,255,0); }
}
.epe-scene.epe-assembled {
    animation: epe-assembled-flash 1s ease forwards;
}

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

.epe-lb-overlay {
    position: absolute;
    inset: 0;
    cursor: pointer;
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
}

.epe-lb-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90vw;
    max-height: 90vh;
    transform: scale(0.5);
    opacity: 0;
    transition: transform 0.38s cubic-bezier(0.34,1.4,0.64,1), opacity 0.28s ease;
}

.epe-lb-content.epe-lb-open {
    transform: scale(1);
    opacity: 1;
}

.epe-lb-img {
    max-width: 84vw;
    max-height: 74vh;
    object-fit: contain;
    border-radius: 6px;
    display: block;
    box-shadow: 0 24px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.08);
}

.epe-lb-caption {
    margin-top: 14px;
    color: rgba(255,255,255,0.9);
    font-size: 15px;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-align: center;
    max-width: 600px;
}

.epe-lb-desc {
    margin-top: 6px;
    color: rgba(255,255,255,0.55);
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    text-align: center;
    max-width: 600px;
    font-style: italic;
}

.epe-lb-close {
    position: absolute;
    top: -48px;
    right: -10px;
    width: 38px;
    height: 38px;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.25s;
    backdrop-filter: blur(4px);
}
.epe-lb-close:hover {
    background: rgba(255,255,255,0.18);
    transform: scale(1.12) rotate(90deg);
}

.epe-lb-prev,
.epe-lb-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 46px; height: 46px;
    background: rgba(0,0,0,0.45);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 50%;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    z-index: 3;
}
.epe-lb-prev { left: -68px; }
.epe-lb-next { right: -68px; }
.epe-lb-prev:hover,
.epe-lb-next:hover {
    background: rgba(255,255,255,0.18);
    transform: translateY(-50%) scale(1.1);
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .epe-lb-prev { left: -52px; }
    .epe-lb-next { right: -52px; }
    .epe-lb-img  { max-width: 92vw; max-height: 68vh; }
}
@media (max-width: 480px) {
    .epe-lb-prev, .epe-lb-next { display: none; }
}
