/* public/css/puzzle.css */

.puzzle-body {
    background: linear-gradient(135deg, #f0f4f8 0%, #e1e8f0 100%);
    min-height: 100vh;
}

body.dark-theme .puzzle-body {
    background: linear-gradient(135deg, #1a1c2c 0%, #0d0e14 100%);
}

.puzzle-wrapper {
    margin-top: 2rem;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 2rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

body.dark-theme .glass-panel {
    background: rgba(30, 32, 45, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.fw-800 { font-weight: 800; }

/* Upload Area */
.upload-box {
    border: 2px dashed rgba(var(--bs-primary-rgb), 0.3);
    background: rgba(var(--bs-primary-rgb), 0.03);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.upload-box:hover {
    border-color: var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), 0.08);
    transform: translateY(-2px);
}

.upload-box strong {
    color: var(--bs-primary);
}

/* Puzzle Board (Workspace) */
.puzzle-board {
    width: min(100%, 600px);
    height: auto;
    min-height: 200px;
    background: rgba(0,0,0,0.05);
    border-radius: 12px;
    position: relative;
    user-select: none;
    touch-action: none;
    margin: 1rem auto 3rem auto;
    overflow: visible;
    transform-origin: center top; /* Good for mobile scaling */
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

body.dark-theme .puzzle-board {
    background: rgba(255,255,255,0.05);
}

.ghost-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%; /* Target size of finished puzzle */
    height: 80%;
    opacity: 0.15;
    background-size: cover;
    pointer-events: none;
    z-index: 0;
    filter: grayscale(100%);
}

body.dark-theme .ghost-guide {
    opacity: 0.1;
}

.puzzle-piece {
    position: absolute;
    cursor: grab;
    background-size: 500px 500px; /* Base size, updated in JS */
    transition: transform 0.1s ease;
    z-index: 10;
    will-change: left, top;
}

.puzzle-piece:active {
    cursor: grabbing;
    z-index: 100;
}



.puzzle-piece.locked {
    filter: brightness(1.05);
    box-shadow: none !important;
    pointer-events: none;
}

/* Performance and Polish */
.puzzle-piece.active {
    filter: brightness(1.1) drop-shadow(0 10px 15px rgba(0,0,0,0.5));
    transition: none; /* No transition while dragging for performance */
}

.puzzle-piece.snapped {
    cursor: default;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1 !important;
    filter: brightness(1.05);
}

.snap-mark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #27ae60;
    font-size: 1.5rem;
    pointer-events: none;
    animation: snapPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 200;
    text-shadow: 0 0 10px rgba(255,255,255,0.8);
}

@keyframes snapPop {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    70% { transform: translate(-50%, -50%) scale(1.4); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
}

.pulse-animation {
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(39, 174, 96, 0); }
    100% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0); }
}

.zoom-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: -1rem;
    margin-bottom: 1.5rem;
    display: none;
}

@media (max-width: 768px) {
    .zoom-hint { display: block; }
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .puzzle-wrapper {
        margin-top: 1rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    .glass-panel {
        padding: 1rem !important;
        border-radius: 1rem;
    }
    
    .display-4 {
        font-size: 1.75rem;
    }

    .upload-box {
        padding: 2rem 1rem !important;
    }

    .puzzle-board {
        margin-top: 1rem;
    }
}

@media (max-width: 360px) {
    .display-4 {
        font-size: 1.5rem;
    }
    .game-controls {
        flex-direction: column;
        gap: 1rem;
    }
}

/* Confetti overlay fix */
canvas#confetti {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 9999;
    pointer-events: none;
}
