/**
 * Video Poker Game Styles
 * Extracted from templates/videopoker.html
 */

/* Loading Spinner Animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Card Preloader (Hidden) */
#card-preloader {
    position: absolute;
    left: -9999px;
    top: -9999px;
}

#card-preloader img {
    width: 1px;
    height: 1px;
    opacity: 0;
}

/* Main Container */
.video-poker-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 1vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: linear-gradient(to bottom, #1101f2, #1101f2);
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.2);
    color: #c79d05;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
    font-family: 'Press Start 2P', monospace;
}

/* Current Game Title */
.current-game {
    text-align: center;
    color: rgb(255, 255, 255);
    margin-bottom: 1vh;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.7);
    font-size: clamp(0.8em, 2vh, 1em);
    flex: 0 0 4vh;
}

/* Pay Table */
.pay-table {
    background: rgba(14, 0, 121, 0.8);
    border: 2px solid #c79d05;
    margin: 1vh auto;
    box-shadow: inset 0 0 10px rgba(243, 243, 242, 0.99);
    flex: 0 0 auto;
    max-width: 800px;
    width: 95%;
    transition: all 0.3s ease;
    height: auto;
    min-height: 0;
    overflow: visible;
}

.pay-table .table {
    margin-bottom: 0;
    transition: all 0.3s ease;
    width: 100%;
    table-layout: fixed;
}

.pay-table .table th,
.pay-table .table td {
    padding: 0.5vh;
    text-align: center;
    font-size: clamp(0.6em, 1.2vh, 0.8em);
    transition: all 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pay-table .table th:first-child,
.pay-table .table td:first-child {
    width: auto;
    min-width: 120px;
    text-align: left;
    padding-left: 1vh;
}

.pay-table .table th:not(:first-child),
.pay-table .table td:not(:first-child) {
    width: 60px;
    min-width: 60px;
}

/* Game Display Area */
.game-display {
    background: linear-gradient(to bottom, #1101f2, #1101f2);
    border: 0px solid #1101f2;
    box-shadow: inset 0 0 15px rgba(0, 255, 0, 0.4);
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-height: 0;
    padding: 0;
    position: relative;
    overflow: hidden;
    height: auto;
}

/* Cards Container */
.cards-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1vw;
    margin: 1vh auto;
    padding: 0;
    flex: 0 0 auto;
    min-height: 20vh;
    width: 100%;
    max-width: 800px;
    position: relative;
    z-index: 1;
    /* Drag-to-hold support (Game King style) */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: pan-y; /* Allow vertical scroll but enable horizontal drag */
}

/* Card Styles */
.card {
    width: 15%;
    height: auto;
    aspect-ratio: 0.7;
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    flex: 0 0 auto;
    margin: 0;
    cursor: pointer;
    /* Prevent drag image on desktop browsers */
    -webkit-user-drag: none;
    user-drag: none;
}

/* Subtle hover effect during draw phase */
.card:hover {
    box-shadow: 0 4px 12px rgba(255, 255, 0, 0.3);
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Prevent image dragging during card drag-to-hold */
    pointer-events: none;
    -webkit-user-drag: none;
    user-drag: none;
}

.card.held::after {
    content: 'HELD';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    color: yellow;
    font-weight: bold;
    font-size: clamp(12px, 1.5vh, 14px);
    z-index: 2;
    text-shadow: 0 0 8px rgba(255, 255, 0, 0.8);
    animation: holdPulse 0.3s ease-out;
}

.card.held {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(255, 255, 0, 0.5);
    /* Faster transition for immediate drag feedback */
    transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
}

/* Animation when card becomes held */
@keyframes holdPulse {
    0% {
        transform: translateX(-50%) scale(1.3);
        opacity: 0;
    }
    50% {
        transform: translateX(-50%) scale(1.1);
        opacity: 1;
    }
    100% {
        transform: translateX(-50%) scale(1);
        opacity: 1;
    }
}

/* Hold Buttons */
.hold-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1vw;
    margin: 0;
    padding: 0;
    flex: 0 0 auto;
    min-height: 4vh;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.hold-btn {
    width: 15%;
    font-size: clamp(12px, 1.5vh, 14px);
    padding: 0.5vh;
    margin: 0;
}

/* Game Controls */
.game-controls {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 1vw;
    margin: 0;
    padding: 0;
    flex: 0 0 auto;
    min-height: 6vh;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.game-controls button {
    width: clamp(100px, 12vw, 120px);
    padding: 0.5vh;
    font-size: clamp(12px, 1.5vh, 14px);
    font-weight: bold;
    text-transform: uppercase;
    border: 2px solid #000;
    cursor: pointer;
    transition: all 0.3s ease;
}

.game-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.game-controls button:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(255, 255, 0, 0.5);
}

/* Game Stats */
.game-stats {
    display: flex;
    flex-direction: column;
    padding: 0;
    width: 100%;
    color: white;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
    font-size: clamp(14px, 1.8vh, 20px);
    z-index: 1;
    flex: 0 0 auto;
    min-height: 4vh;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid #c79d05;
    position: relative;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
}

.game-stats-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.3vh 10px;
}

.win-amount {
    font-size: clamp(12px, 1.5vh, 16px);
    color: white;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
    min-width: 70px;
    text-align: left;
}

.bet {
    font-size: clamp(12px, 1.5vh, 16px);
    color: white;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
    min-width: 70px;
    text-align: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.credits {
    font-size: clamp(12px, 1.5vh, 16px);
    color: white;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
    min-width: 70px;
    text-align: right;
}

.game-variant {
    font-size: clamp(10px, 1.2vh, 14px);
    color: #c79d05;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
    padding: 0.3vh 10px;
    margin-bottom: 0.3vh;
}

/* Win Display */
.win-display {
    text-align: center;
    margin: 1.5vh 0;
    font-size: 20px;
    color: red;
    text-shadow:
        1px 1px 0px yellow,
        -1px -1px 0px yellow,
        1px -1px 0px yellow,
        -1px 1px 0px yellow;
    position: relative;
    z-index: 3;
    width: 100%;
}

.hand-result {
    position: relative;
    z-index: 3;
    text-align: center;
}

/* Animations */
@keyframes win-flash {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

@keyframes dealCard {
    0% {
        opacity: 0;
        transform: scale(0.9) rotateY(-10deg);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.95) rotateY(0deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotateY(0deg);
    }
}

.card-dealing {
    animation: dealCard 0.15s ease-out forwards;
}

.winning-hand {
    animation: win-flash 1s infinite;
}

/* Highlight Styles */
.highlight-row {
    background-color: rgba(255, 215, 0, 0.2) !important;
    animation: win-flash 1s infinite;
}

.highlight-pay {
    color: yellow !important;
}

.highlight-pay td {
    color: yellow !important;
}

.highlight-hand-name {
    color: yellow !important;
}

.highlight-bet-column {
    background-color: rgba(255, 0, 0, 0.5) !important;
}

/* Deal/Draw Button */
#deal-draw {
    background-color: #e0b003;
    color: black;
    border: 2px solid black;
}

/* Yellow Button Style */
.btn-yellow {
    background-color: #e0b003;
    color: black;
    border: 2px solid black;
    padding: 8px 10px;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-yellow:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-yellow:not(:disabled):hover {
    background-color: #f0c003;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(255, 255, 0, 0.5);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
}

.modal-content {
    background-color: #002a54;
    margin: 15% auto;
    padding: 20px;
    border: 2px solid #c79d05;
    width: 80%;
    max-width: 800px;
    position: relative;
    border-radius: 10px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    color: #c79d05;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5em;
}

.close {
    color: #c79d05;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #e0b003;
}

.modal-body {
    display: flex;
    justify-content: center;
    align-items: center;
    color: #ffffff;
}

.game-grid, .denom-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    width: 100%;
}

.game-option, .denom-option {
    background-color: #e0b003;
    color: black;
    border: 2px solid black;
    padding: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 5px;
}

.game-option:hover, .denom-option:hover {
    background-color: #f0c003;
    transform: scale(1.05);
}

/* Denomination Selector */
.denom-selector {
    max-width: 300px;
    margin: 0 auto;
}

#game-variant, #denom-select {
    background-color: #8f8f8f;
    color: rgb(255, 255, 255);
    border: 2px solid rgb(255, 255, 255);
}

#denom-select {
    width: 120px;
    padding: 5px;
    border-radius: 5px;
}

.game-over-text {
    display: none;
}

/* Bet Container */
.betContainer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #c79d05;
    margin: 5px auto;
    width: 90%;
    max-width: 800px;
    color: white;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
    font-size: 24px;
    z-index: 1;
    flex: 0 0 auto;
}

/* Disabled Overlay */
.disabled-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

/* Optimal Strategy Toggle */
.optimal-strategy-toggle {
    margin-left: 30px;
    display: inline-block;
}

.optimal-strategy-toggle .form-check {
    margin: 0;
    padding: 0;
}

.optimal-strategy-toggle .form-check-input {
    background-color: #ffffff;
    border-color: #ffffff;
    font-size: 12px;
}

.optimal-strategy-toggle .form-check-input:checked {
    background-color: #4682B4;
    border-color: #4682B4;
}

.optimal-strategy-toggle .form-check-label {
    color: white;
    font-size: clamp(10px, 1.2vh, 12px);
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
    margin-left: 5px;
}

/* Strategy Warning Content */
.strategy-warning-content {
    color: #ffffff;
    text-align: center;
}

.strategy-warning-content p {
    margin-bottom: 15px;
}

.strategy-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px 0;
    text-align: left;
}

.ev-difference {
    grid-column: 1 / -1;
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    background-color: rgba(255, 0, 0, 0.2);
    border: 1px solid #ff6b6b;
    border-radius: 5px;
}

.optimal-play, .your-play {
    padding: 15px;
    border-radius: 5px;
}

.optimal-play {
    background-color: rgba(0, 255, 0, 0.1);
    border: 1px solid #4caf50;
}

.your-play {
    background-color: rgba(255, 255, 0, 0.1);
    border: 1px solid #ffc107;
}

.optimal-play h4 {
    color: #4caf50;
    margin-bottom: 10px;
}

.your-play h4 {
    color: #ffc107;
    margin-bottom: 10px;
}

.loss-amount {
    color: #ff6b6b;
    font-weight: bold;
}

/* Modal Footer */
.modal-footer {
    display: flex;
    justify-content: space-between;
    padding: 20px;
    border-top: 1px solid #c79d05;
}

.modal-footer button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

/* Loading Spinner */
.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #c79d05;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

/* Strategy Loading Modal */
.strategy-loading-content {
    text-align: center;
    background-color: #002a54;
    border: 2px solid #c79d05;
    border-radius: 10px;
    max-width: 400px;
    padding: 30px;
}

.loading-header h3 {
    color: #c79d05;
    margin-bottom: 20px;
    font-size: 1.2em;
}

.loading-body p {
    color: #ffffff;
    margin-top: 15px;
    font-size: 0.9em;
}

/* Modal Cards Display */
.modal-cards-display {
    margin: 20px 0;
}

.modal-cards-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.modal-card {
    position: relative;
    width: 60px;
    height: auto;
    border-radius: 8px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.modal-card img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.modal-card.hold-highlight {
    border: 3px solid #4caf50;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.6);
    transform: scale(1.05);
}

.modal-card.hold-highlight::after {
    content: 'HOLD';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    color: #4caf50;
    font-weight: bold;
    font-size: 10px;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.modal-card.discard-dim {
    opacity: 0.4;
    filter: grayscale(100%);
}

.modal-card.discard-dim::after {
    content: 'DISCARD';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    color: #ff6b6b;
    font-weight: bold;
    font-size: 8px;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.card-number {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    color: #ffffff;
    font-weight: bold;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.7);
    padding: 2px 6px;
    border-radius: 3px;
}

/* Strategy Legend */
.strategy-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    font-size: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-highlight {
    width: 20px;
    height: 12px;
    background: #4caf50;
    border: 2px solid #4caf50;
    border-radius: 3px;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

.legend-discard {
    width: 20px;
    height: 12px;
    background: #666;
    border: 2px solid #666;
    border-radius: 3px;
    opacity: 0.4;
    filter: grayscale(100%);
}

.optimal-ev-display {
    margin-top: 15px;
    padding: 15px;
    background-color: rgba(0, 255, 0, 0.1);
    border: 1px solid #4caf50;
    border-radius: 5px;
}

.optimal-ev-display p {
    margin: 0;
    color: #4caf50;
    font-weight: bold;
}

/* EV Comparison Display */
.ev-comparison {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ev-item {
    padding: 12px;
    border-radius: 5px;
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.ev-item.optimal-ev {
    border-color: #4caf50;
    background-color: rgba(76, 175, 80, 0.15);
}

.ev-item.player-ev {
    border-color: #ff9800;
    background-color: rgba(255, 152, 0, 0.15);
}

.ev-item.ev-difference {
    border-color: #f44336;
    background-color: rgba(244, 67, 54, 0.15);
}

.ev-item strong {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9em;
    color: #ffffff;
}

.ev-amount {
    font-size: 1.4em;
    font-weight: bold;
    color: #4caf50;
    margin: 5px 0;
}

.ev-amount.loss {
    color: #f44336;
}

.ev-amount.gain {
    color: #4caf50;
}

.ev-credits {
    font-size: 0.85em;
    color: #aaaaaa;
    font-style: italic;
}

.ev-item.optimal-ev .ev-amount {
    color: #4caf50;
}

.ev-item.player-ev .ev-amount {
    color: #ff9800;
}

.ev-item.ev-difference .ev-amount.loss {
    color: #f44336;
}

.ev-item.ev-difference .ev-amount.gain {
    color: #4caf50;
}

/* Dark Mode Support for EV Comparison */
body.dark-mode .ev-item {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

body.dark-mode .ev-item.optimal-ev {
    border-color: #4caf50;
    background-color: rgba(76, 175, 80, 0.2);
}

body.dark-mode .ev-item.player-ev {
    border-color: #ff9800;
    background-color: rgba(255, 152, 0, 0.2);
}

body.dark-mode .ev-item.ev-difference {
    border-color: #f44336;
    background-color: rgba(244, 67, 54, 0.2);
}

body.dark-mode .ev-item strong {
    color: #ffffff;
}

body.dark-mode .ev-credits {
    color: #cccccc;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .video-poker-container {
        padding: 0.5vh;
    }

    .card {
        width: 18%;
    }

    .hold-btn {
        width: 18%;
    }

    .cards-container {
        min-height: 18vh;
    }

    .hold-buttons {
        min-height: 3vh;
    }

    .game-controls {
        min-height: 5vh;
    }

    .game-stats {
        min-height: 3vh;
        font-size: clamp(12px, 1.5vh, 16px);
    }

    .pay-table {
        width: 98%;
    }

    .pay-table .table th:first-child,
    .pay-table .table td:first-child {
        min-width: 100px;
    }

    .pay-table .table th:not(:first-child),
    .pay-table .table td:not(:first-child) {
        width: 50px;
        min-width: 50px;
    }

    .game-grid, .denom-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 5px;
    }

    .game-option, .denom-option {
        font-size: 12px;
        padding: 8px;
    }

}

@media (max-width: 480px) {
    .cards-container {
        min-height: 16vh;
    }

    .hold-buttons {
        min-height: 3vh;
    }

    .game-controls {
        min-height: 4vh;
    }

    .game-stats {
        min-height: 3vh;
        font-size: clamp(10px, 1.2vh, 14px);
    }

    .card {
        width: 18%;
    }

    .hold-btn {
        width: 18%;
    }

    .pay-table {
        width: 100%;
    }

    .pay-table .table th:first-child,
    .pay-table .table td:first-child {
        min-width: 80px;
    }

    .pay-table .table th:not(:first-child),
    .pay-table .table td:not(:first-child) {
        width: 40px;
        min-width: 40px;
    }

}
