/* Baccarat Game - Premium UI
 *
 * Extends platform.css design system for baccarat-specific components.
 * Card styles (.bj-card) come from blackjack.css (shared).
 */

/* ========== Scroll Lock During Gameplay ========== */
@media (max-width: 768px) {
    body.baccarat-playing {
        overscroll-behavior: none;
    }
}

/* ========== Baccarat Table Container ========== */
.baccarat-container {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1rem;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    position: relative;
    box-sizing: border-box;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 0 1 auto;
}

.baccarat-container.animate-in {
    animation: baccarat-fade-in 0.4s ease forwards;
}
@keyframes baccarat-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.baccarat-table {
    background: linear-gradient(180deg, #1a472a 0%, #0f2d1a 100%);
    border-radius: 16px;
    padding: 1rem;
    position: relative;
    overflow: hidden;
    border: 3px solid var(--primary);
    box-sizing: border-box;
    box-shadow:
        inset 0 4px 20px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(247, 147, 26, 0.2);
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.75rem;
}

/* Green felt texture overlay */
.baccarat-table::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(34, 197, 94, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(34, 197, 94, 0.1) 0%, transparent 40%);
    border-radius: 16px;
    pointer-events: none;
}

.baccarat-table.dimmed {
    opacity: 0.5;
    transition: opacity 0.4s ease;
}

/* ========== Hand Areas ========== */
.banker-area,
.player-area {
    text-align: center;
    padding: 0.5rem;
    flex: 0 0 auto;
}

.banker-area {
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.15);
}

.player-area {
    padding-top: 0.5rem;
    /* No border-top — banker-area border-bottom serves as the separator.
       Avoids double-border overlap between the two areas. */
}

/* Hand containers — reuse card layout from blackjack */
.banker-hand,
.player-hand {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(clamp(70px, 11.2vmin, 112px) + 0.5rem);
    padding: 0.25rem;
}

/* Card overlap in baccarat hands */
.banker-hand .bj-card,
.player-hand .bj-card {
    margin-left: -20px;
}
.banker-hand .bj-card:first-child,
.player-hand .bj-card:first-child {
    margin-left: 0;
}

/* Hover reveal for overlapped cards */
.banker-hand .bj-card:not(.dealing):hover,
.player-hand .bj-card:not(.dealing):hover {
    transform: translateY(-5px);
    z-index: 10;
}

/* Hand value badge */
.hand-value-badge {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 0.25rem;
    height: 2rem;
    line-height: 2rem;
    text-align: center;
    overflow: hidden;
}

.hand-value-badge.natural {
    color: var(--primary);
    text-shadow: 0 0 15px rgba(247, 147, 26, 0.5);
}

/* ========== Controls Stack Override ========== */
/* Blackjack uses CSS grid stacking for hit/stand ↔ bet-controls swap.
   Baccarat has position-selector + bet-controls that must flow vertically,
   not overlap in the same grid cell. */
.baccarat-container .controls-stack {
    display: flex;
    flex-direction: column;
}

.baccarat-container .controls-stack > * {
    grid-row: unset;
    grid-column: unset;
}

/* ========== Position Selector ========== */
.position-selector {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    padding: 0.75rem 0 0.25rem;
}

.position-btn {
    flex: 1;
    max-width: 140px;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    font-family: inherit;
}

.position-btn:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
}

.position-btn.selected {
    border-color: #f7931a;
    background: rgba(247, 147, 26, 0.15);
    box-shadow: 0 0 12px rgba(247, 147, 26, 0.2);
}

.position-btn.tie.selected {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.2);
}

.position-label {
    display: block;
    font-weight: 600;
    font-size: 1rem;
}

.position-payout {
    display: block;
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 2px;
}

/* Disabled during dealing */
.position-selector.disabled .position-btn {
    opacity: 0.4;
    pointer-events: none;
}

/* Win highlight on position button */
.position-btn.winner {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.2);
    box-shadow: 0 0 16px rgba(34, 197, 94, 0.3);
}

/* Loss dim on position button */
.position-btn.loser {
    opacity: 0.5;
}

/* ========== Result Display ========== */
/* Inherits .result-display, .result-label, .result-amount from platform.css/blackjack.css */
/* Baccarat-specific: natural celebration */
.baccarat-table .result-display.natural-celebration {
    animation: naturalPulse 0.5s ease;
}

@keyframes naturalPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* ========== Confetti ========== */
.baccarat-table .confetti {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    top: -10px;
    z-index: 100;
    animation: confettiFall 2s ease-in forwards;
    pointer-events: none;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(300px) rotate(720deg);
        opacity: 0;
    }
}

/* ========== Responsive ========== */

/* Hide promo banner on baccarat — it eats vertical space needed for the table */
.baccarat-page .pm-promo-banner {
    display: none;
}

@media (max-width: 768px) {
    .position-selector {
        gap: 0.35rem;
    }

    .position-btn {
        padding: 0.6rem 0.5rem;
        max-width: 120px;
    }

    .position-label {
        font-size: 0.9rem;
    }

    .position-payout {
        font-size: 0.7rem;
    }

    .hand-value-badge {
        font-size: 1.25rem;
        height: 1.75rem;
        line-height: 1.75rem;
    }

    .baccarat-table {
        padding: 0.5rem;
        gap: 0.375rem;
    }

    .banker-area,
    .player-area {
        padding: 0.25rem;
    }
}

/* Extra compact for very small phones */
@media (max-width: 360px) {
    .baccarat-table {
        padding: 0.375rem;
        gap: 0.25rem;
        border-width: 2px;
        border-radius: 10px;
    }

    .baccarat-container {
        padding: 0.5rem;
        border-radius: 10px;
    }

    .banker-hand,
    .player-hand {
        min-height: calc(clamp(60px, 10vmin, 80px) + 0.25rem);
    }

    .position-btn {
        padding: 0.5rem 0.35rem;
        max-width: 100px;
    }

    .position-label {
        font-size: 0.8rem;
    }

    .position-payout {
        font-size: 0.65rem;
    }
}
