/* css/gamePuzzle.css */
/*
 * Stylesheet khusus untuk game "Slide Puzzle".
 * Didesain secara premium, konsisten dengan Whack-a-Mole, dan responsif.
 */

.game-puzzle-page {
    display: none;
    position: absolute;
    top: 90px;
    left: 0;
    width: 100%;
    height: calc(100% - 90px);
    background-color: #f7fafc;
    box-sizing: border-box;
    padding: 20px 40px;
    overflow: hidden;
}

/* 1. Tampilan Pemilihan Gambar */
.puzzle-select-view {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    box-sizing: border-box;
}

.puzzle-select-title {
    font-size: 36px;
    font-weight: 800;
    color: #2d3748;
    margin-bottom: 30px;
    text-align: center;
}

.puzzle-image-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    width: 100%;
    margin-bottom: 40px;
}

.puzzle-image-card {
    border-radius: 16px;
    overflow: hidden;
    border: 3px solid transparent;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    aspect-ratio: 1.25;
    background-color: #ffffff;
}

.puzzle-image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.puzzle-image-card.focused,
.puzzle-image-card:hover {
    transform: translateY(-8px);
    border-color: var(--ariston-red);
    box-shadow: 0 15px 30px rgba(227, 28, 45, 0.15);
}

.puzzle-select-actions {
    width: 100%;
    display: flex;
    justify-content: center;
}

.game-puzzle-page.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.puzzle-game-container {
    max-width: 1200px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: space-between;
}

/* Header Bar (Sama persis dengan Whack-a-Mole) */
.puzzle-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 10px 0;
    border-bottom: 2px solid rgba(0, 0, 0, 0.05);
}

.puzzle-stat-box {
    background-color: #ffffff;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.06);
    padding: 12px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.02);
    min-width: 120px;
}

.puzzle-stat-lbl {
    font-size: 12px;
    font-weight: 700;
    color: #a0aec0;
    letter-spacing: 1.5px;
    margin-bottom: 4px;
}

.puzzle-stat-val {
    font-size: 28px;
    font-weight: 800;
    color: var(--ariston-red);
}

.puzzle-title-wrapper {
    height: 70px;
    display: flex;
    align-items: center;
}

.puzzle-game-title-img {
    height: 100%;
    object-fit: contain;
}

/* Board Grid Puzzle */
.puzzle-grid-board {
    display: grid;
    grid-template-columns: repeat(3, 150px);
    grid-template-rows: repeat(3, 150px);
    gap: 6px;
    background: #e2e8f0;
    padding: 15px;
    border-radius: 20px;
    box-shadow: inset 0 4px 12px rgba(0,0,0,0.08), 0 10px 25px rgba(0,0,0,0.05);
    margin: 20px 0;
}

/* Sel Potongan Gambar */
.puzzle-cell {
    width: 150px;
    height: 150px;
    border-radius: 8px;
    cursor: pointer;
    background-size: 450px 450px; /* Gambar asli 450x450 (3 kali ukuran sel) */
    background-repeat: no-repeat;
    transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.2s ease, border-color 0.2s ease;
    box-sizing: border-box;
    border: 2px solid transparent;
    position: relative; /* Wajib ada agar absolute badge terkunci di setiap sel */
}

.puzzle-cell.piece {
    background-color: #ffffff;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.puzzle-cell.piece:active {
    transform: scale(0.96); /* Efek membal saat kepingan diklik/disentuh */
}

/* Animasi Pengacakan Puzzle (Shuffle Effect) */
.puzzle-grid-board.shuffling {
    animation: boardPulse 0.5s ease-in-out infinite alternate;
}

.puzzle-cell.shuffle-anim {
    animation: puzzleShake 0.4s ease-in-out;
}

@keyframes boardPulse {
    0% { transform: scale(1); box-shadow: 0 10px 25px rgba(0,0,0,0.05); }
    100% { transform: scale(0.99); box-shadow: 0 5px 15px rgba(0,0,0,0.02); }
}

@keyframes puzzleShake {
    0% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(-3px, 2px) rotate(-1deg); }
    50% { transform: translate(3px, -2px) rotate(1deg); }
    75% { transform: translate(-2px, -2px) rotate(-0.5deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

/* Slot kosong */
.puzzle-cell.empty {
    background: #cbd5e0;
    box-shadow: inset 0 4px 8px rgba(0,0,0,0.1);
}

/* Kursor Fokus Remote TV Spasial */
.puzzle-cell.focused {
    border-color: var(--ariston-red);
    box-shadow: 0 0 15px rgba(227, 28, 45, 0.7);
    transform: scale(1.02);
    z-index: 10;
}

/* Badge Nomor Urutan Puzzle */
.puzzle-number-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background-color: rgba(227, 28, 45, 0.85); /* Merah khas Ariston dengan opacity */
    color: #ffffff;
    font-size: 14px;
    font-weight: 800;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
    z-index: 15;
    pointer-events: none;
    border: 1.5px solid #ffffff;
}

/* Footer & Aksi */
.puzzle-footer-actions {
    width: 100%;
    display: flex;
    justify-content: center;
    padding-bottom: 15px;
}

/* Modal Pop-up (Konsisten dengan Whack-a-Mole) */
.puzzle-overlay-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    z-index: 999;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.puzzle-overlay-modal.active {
    display: flex;
}

.puzzle-modal-content {
    background-color: #ffffff;
    border-radius: 24px;
    padding: 50px 60px;
    max-width: 650px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    transform: scale(0.9);
    animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes modalPop {
    to { transform: scale(1); }
}

.puzzle-modal-title {
    font-size: 38px;
    font-weight: 800;
    color: #1a202c;
    margin-bottom: 16px;
}

.puzzle-modal-desc {
    font-size: 18px;
    color: #4a5568;
    line-height: 1.6;
    margin-bottom: 30px;
}

.puzzle-score-summary {
    background-color: #fff5f5;
    border: 2px dashed rgba(227, 28, 45, 0.3);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 35px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.puzzle-summary-lbl {
    font-size: 14px;
    font-weight: 700;
    color: #718096;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.puzzle-summary-val {
    font-size: 48px;
    font-weight: 900;
    color: var(--ariston-red);
}

.puzzle-modal-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.puzzle-modal-buttons button {
    min-width: 180px;
}
