/**
 * PlayLabs Lucky Draw Game Styles
 * File: assets/css/luckydraw-game.css
 */

/* ============================================
   MAIN CONTAINER
   ============================================ */

.playlabs-luckydraw-container {
    width: 100%;
    margin: 0;
    padding: 0;
    text-align: center;
}

/* ============================================
   HEADER SECTION
   ============================================ */

.luckydraw-header {
    margin-bottom: 30px;
}

.luckydraw-header h2 {
    color: #333;
    margin-bottom: 10px;
}

.luckydraw-player {
    color: #666;
    font-size: 14px;
}

/* ============================================
   GAME AREA
   ============================================ */

.luckydraw-game-area {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 0;
    padding: 0;
    min-height: 200px;
    flex-wrap: wrap;
    flex-direction: row;
}

/* ============================================
   CARD STRUCTURE
   ============================================ */

.luckydraw-card {
    width: 215px;
    height: 356px;
    perspective: 1000px;
    cursor: pointer;
    position: relative;
    transition: transform 0.3s ease;
}

.luckydraw-card:hover:not(.disabled):not(.spinning):not(.revealed) {
    transform: scale(1.05);
}

.luckydraw-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.luckydraw-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* ============================================
   CARD FACES
   ============================================ */

.luckydraw-card-back,
.luckydraw-card-front {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    overflow: hidden;
    padding: 0;
}

/* Card Back Styling */
.luckydraw-card-back {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.luckydraw-card-back img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    display: block;
}

/* Card Front Styling */
.luckydraw-card-front {
    background: white;
    transform: rotateY(180deg);
}

.luckydraw-card-front img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    display: block;
    z-index: 0;
}

.luckydraw-card-front img.normal {
    position: relative;
    object-fit: contain;
    height: auto;
    width: auto;
    padding: 15px;
}

/* Default Back Content (when no image) */
.luckydraw-card-default-back {
    font-size: 48px;
    font-weight: bold;
    color: white;
}

/* ============================================
   PRIZE CONTENT
   ============================================ */

.luckydraw-prize-content {
    position: relative;
    padding: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.luckydraw-result-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    text-align: center;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

/* Default result state with image */
.luckydraw-result-text.defalt {
    z-index: 1;
}

.luckydraw-result-text.defalt img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    display: block;
}

/* Winner/Loser text states */
.luckydraw-result-text.winner,
.luckydraw-result-text.loser {
    z-index: 2;
    background: #000;
}

.luckydraw-result-text span {
    display: block;
    line-height: 1;
}

.luckydraw-result-text span:first-child {
    font-size: 24px;
}

.luckydraw-result-text span:last-child {
    font-size: 36px;
}

.luckydraw-result-text.winner {
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.luckydraw-result-text.loser {
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

/* ============================================
   OVERLAY
   ============================================ */

.luckydraw-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.luckydraw-overlay.active {
    display: block;
    opacity: 1;
}

/* ============================================
   CARD STATES
   ============================================ */

/* Flipped State */
.luckydraw-card.flipped .luckydraw-card-inner {
    transform: rotateY(180deg);
}

/* Enlarged State */
.luckydraw-card.enlarged {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1.5);
    z-index: 1001; /* Above overlay */
}

/* Winner State */
.luckydraw-card.winner .luckydraw-card-front {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    animation: winner-pulse 7s ease-in-out infinite;
}

/* Loser State */
.luckydraw-card.loser .luckydraw-card-front {
    background: #f0f0f0;
}

/* Placeholder */
.luckydraw-card-placeholder {
    width: 215px;
    height: 356px;
    visibility: hidden;
}

/* ============================================
   ANIMATIONS
   ============================================ */

.luckydraw-card-inner.spinning-animation {
    animation: spin 0.3s linear infinite;
}

.luckydraw-card-inner.stopping-animation {
    animation: spinSlow var(--stop-duration, 2s) ease-out forwards;
}

@keyframes spin {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(360deg); }
}

@keyframes spinSlow {
    0% {
        transform: rotateY(0deg);
        animation-timing-function: linear;
    }
    70% {
        transform: rotateY(1080deg);
        animation-timing-function: ease-out;
    }
    100% {
        transform: rotateY(1260deg);
    }
}

@keyframes winner-pulse {
    0%, 100% { transform: rotateY(180deg) scale(1); }
    50% { transform: rotateY(180deg) scale(1.05); }
}

/* ============================================
   CONTROLS SECTION
   ============================================ */

.luckydraw-controls {
    margin-top: 30px;
}

.luckydraw-status {
    font-size: 18px;
    margin-bottom: 20px;
    color: #333;
    min-height: 30px;
}

.luckydraw-play-again {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 30px;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.luckydraw-play-again:hover {
    background: #764ba2;
}

/* ============================================
   MESSAGE SECTION
   ============================================ */

.luckydraw-message {
    border-radius: 5px;
    padding: 30px;
    text-align: center;
    font-family: 'Montserrat';
}

.luckydraw-message p {
    margin-bottom: 20px;
    color: #fff;
}

.luckydraw-btn, .luckydraw-restart {
    background: #fff;
    padding: 10px 20px 9px;
    border-radius: 10px;
    color: #1a3965 !important;
    text-transform: uppercase;
    font-weight: 800;
    font-family: 'Montserrat';
    text-decoration: none;
}

/* ============================================
   STATS INTEGRATION
   ============================================ */

.playlabs-game-stats-wrapper {
    margin-top: 30px;
    padding: 0;
    background: #f8f9fa;
    border-radius: 5px;
}

.stat-value {
    font-weight: bold;
    color: #667eea;
}

/* ============================================
   THEME VARIATIONS
   ============================================ */

/* Dark Theme */
.playlabs-luckydraw-container.dark-theme {
    background: #2c3e50;
    color: white;
}

.playlabs-luckydraw-container.dark-theme .luckydraw-status,
.playlabs-luckydraw-container.dark-theme .luckydraw-header h2 {
    color: white;
}

/* Light Theme */
.playlabs-luckydraw-container.light-theme {
    background: white;
}

/* ============================================
   TABLET RESPONSIVE (768px - 1024px)
   ============================================ */

@media (min-width: 768px) and (max-width: 1024px) {
    .luckydraw-card {
        width: 150px;
        height: 247px;
    }

    .luckydraw-card-placeholder {
        width: 150px;
        height: 247px;
    }

    .luckydraw-game-area {
        gap: 15px;
    }

    .luckydraw-restart.active {
        bottom: 15%;
    }
}

/* ============================================
   MOBILE RESPONSIVE (max 767px)
   ============================================ */

@media (max-width: 767px) {
    .luckydraw-game-area {
        flex-direction: row;
        justify-content: center;
        gap: 10px;
    }

    .luckydraw-card {
        width: 100px;
        height: 166px;
    }

    .luckydraw-card-placeholder {
        width: 100px;
        height: 166px;
    }

    .luckydraw-card-back, .luckydraw-card-front{
        border-radius: 5px;
    }

    .luckydraw-card.enlarged {
        transform: translate(-50%, -50%) scale(2);
    }

    .luckydraw-result-text span:first-child {
        font-size: 18px;
    }

    .luckydraw-result-text span:last-child {
        font-size: 24px;
    }

    .luckydraw-restart.active {
        bottom: 20%;
        padding: 10px 25px;
        font-size: 16px;
        line-height: 1;
        height: 14px;
    }
}