/*
 * Jerusalem Hills - Backgammon Game CSS
 * ======================================
 * Local multiplayer backgammon with Jerusalem theme
 */

@import url('/css/theme.css');

/* Game Container */
.backgammon-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-lg);
    background: var(--jerusalem-stone-light);
    min-height: 100vh;
}

/* Game Header */
.game-header {
    background: linear-gradient(135deg, var(--jerusalem-gold), var(--jerusalem-gold-dark));
    color: white;
    padding: var(--space-lg);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.game-title {
    font-family: var(--font-secondary);
    font-size: var(--text-3xl);
    margin-bottom: var(--space-sm);
}

.game-subtitle {
    font-size: var(--text-lg);
    opacity: 0.9;
}

/* Game Board */
.game-board-wrapper {
    background: var(--color-surface);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-lg);
}

#backgammon-board {
    width: 100%;
    max-width: 900px;
    aspect-ratio: 16/11;
    margin: 0 auto;
    position: relative;
    background: linear-gradient(
        90deg,
        #8B4513 0%,
        #A0522D 48%,
        #654321 50%,
        #A0522D 52%,
        #8B4513 100%
    );
    border: 8px solid #4A2C17;
    border-radius: var(--radius-md);
    display: grid;
    grid-template-columns: repeat(14, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 0;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.3);
}

/* Bar (middle divider) */
.bar {
    grid-column: 7 / 9;
    grid-row: 1 / 4;
    background: linear-gradient(
        180deg,
        #4A2C17 0%,
        #654321 50%,
        #4A2C17 100%
    );
    border-left: 2px solid #2A1810;
    border-right: 2px solid #2A1810;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
}

/* Points (triangles) */
.point {
    position: relative;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.point::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    transition: all var(--transition-fast);
}

/* Top row points */
.point.top::before {
    clip-path: polygon(50% 100%, 0% 0%, 100% 0%);
}

/* Alternating colors for points */
.point:nth-child(odd)::before {
    background: var(--jerusalem-olive-dark);
}

.point:nth-child(even)::before {
    background: var(--jerusalem-gold-dark);
}

.point:hover::before {
    filter: brightness(1.2);
}

.point.valid-move::before {
    box-shadow: inset 0 0 20px rgba(82, 196, 26, 0.5);
    animation: pulse 1s infinite;
}

/* Checkers */
.checker {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    position: absolute;
    cursor: grab;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: var(--text-lg);
}

.checker.white {
    background: radial-gradient(circle at 30% 30%,
        #FFFFFF 0%,
        #F5E6D3 50%,
        #E8D4BC 100%);
    border: 2px solid var(--jerusalem-stone-dark);
    color: var(--jerusalem-olive-dark);
}

.checker.black {
    background: radial-gradient(circle at 30% 30%,
        #4B3B75 0%,
        #6B5B95 50%,
        #8B7BAB 100%);
    border: 2px solid var(--jerusalem-purple-dark);
    color: white;
}

.checker:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
    cursor: grab;
}

.checker.dragging {
    opacity: 0.8;
    transform: scale(1.2);
    cursor: grabbing;
    z-index: 1000;
}

.checker.selected {
    box-shadow: 0 0 20px var(--jerusalem-gold);
    animation: pulse 1s infinite;
}

/* Dice */
.dice-container {
    display: flex;
    gap: var(--space-lg);
    justify-content: center;
    margin: var(--space-xl) 0;
}

.die {
    width: 60px;
    height: 60px;
    background: white;
    border: 2px solid var(--jerusalem-gold-dark);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-2xl);
    font-weight: bold;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.die:hover {
    transform: rotate(15deg) scale(1.1);
}

.die.rolling {
    animation: rollDice 0.5s ease-in-out;
}

@keyframes rollDice {
    0% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(90deg) scale(1.2); }
    50% { transform: rotate(180deg) scale(1); }
    75% { transform: rotate(270deg) scale(1.2); }
    100% { transform: rotate(360deg) scale(1); }
}

/* Player Info */
.player-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
    margin-top: var(--space-xl);
}

.player-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    border: 2px solid transparent;
}

.player-card.active {
    border-color: var(--jerusalem-gold);
    box-shadow: var(--shadow-md);
    background: var(--jerusalem-stone-light);
}

.player-name {
    font-family: var(--font-secondary);
    font-size: var(--text-xl);
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.player-color {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--jerusalem-gold-dark);
}

.player-stats {
    display: flex;
    gap: var(--space-lg);
    margin-top: var(--space-md);
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: var(--text-xs);
    color: var(--color-text-light);
    text-transform: uppercase;
}

.stat-value {
    font-size: var(--text-lg);
    font-weight: bold;
    color: var(--jerusalem-gold-dark);
}

/* Game Controls */
.game-controls {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    margin-top: var(--space-xl);
}

.btn-game {
    padding: var(--space-md) var(--space-xl);
    font-family: var(--font-primary);
    font-size: var(--text-base);
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-roll {
    background: linear-gradient(135deg, var(--jerusalem-gold), var(--jerusalem-gold-dark));
    color: white;
}

.btn-roll:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-roll:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-undo {
    background: var(--jerusalem-olive);
    color: white;
}

.btn-undo:hover {
    background: var(--jerusalem-olive-light);
}

.btn-new-game {
    background: var(--jerusalem-purple);
    color: white;
}

.btn-new-game:hover {
    background: var(--jerusalem-purple-light);
}

/* Home and bear-off areas */
.home-area {
    grid-column: 14;
    background: rgba(212, 165, 116, 0.3);
    border: 2px dashed var(--jerusalem-gold);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm);
}

.home-white {
    grid-row: 3;
}

.home-black {
    grid-row: 1;
}

/* Game Messages */
.game-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: var(--z-modal);
    text-align: center;
    min-width: 300px;
    border: 3px solid var(--jerusalem-gold);
    animation: fadeIn var(--transition-slow);
}

.game-message h2 {
    font-family: var(--font-secondary);
    font-size: var(--text-2xl);
    color: var(--jerusalem-gold-dark);
    margin-bottom: var(--space-md);
}

.game-message p {
    color: var(--color-text-secondary);
    margin-bottom: var(--space-lg);
}

/* Responsive Design */
@media (max-width: 768px) {
    .backgammon-container {
        padding: var(--space-sm);
    }

    #backgammon-board {
        grid-template-columns: repeat(14, 1fr);
        gap: 0;
    }

    .checker {
        width: 35px;
        height: 35px;
        font-size: var(--text-sm);
    }

    .die {
        width: 45px;
        height: 45px;
        font-size: var(--text-xl);
    }

    .player-info {
        grid-template-columns: 1fr;
    }

    .game-controls {
        flex-wrap: wrap;
    }
}

/* Animations */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -60%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
}

/* Move History */
.move-history {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-top: var(--space-xl);
    max-height: 200px;
    overflow-y: auto;
}

.move-history h3 {
    font-family: var(--font-secondary);
    font-size: var(--text-lg);
    margin-bottom: var(--space-md);
    color: var(--jerusalem-gold-dark);
}

.move-item {
    padding: var(--space-sm);
    border-left: 3px solid var(--jerusalem-olive);
    margin-bottom: var(--space-sm);
    background: var(--jerusalem-stone-light);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
}

.move-item.white {
    border-left-color: #E8D4BC;
}

.move-item.black {
    border-left-color: var(--jerusalem-purple);
}

/* Sound Controls */
.sound-toggle {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    padding: var(--space-sm);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sound-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Loading Animation */
.loading {
    text-align: center;
    padding: var(--space-xl);
}

.loading::after {
    content: '⚀⚁⚂⚃⚄⚅';
    display: block;
    font-size: var(--text-2xl);
    animation: rollDice 2s infinite;
}

/* Tutorial/Help Overlay */
.help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s;
}

.help-content {
    background: white;
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.help-content h2 {
    color: var(--jerusalem-gold-dark);
    margin-bottom: var(--space-md);
}

.help-content ul {
    list-style: none;
    padding: 0;
}

.help-content li {
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--jerusalem-stone);
}

.help-content li:before {
    content: '🎲 ';
    margin-right: var(--space-sm);
}

.btn-close-help {
    margin-top: var(--space-lg);
    width: 100%;
    padding: var(--space-md);
    background: var(--jerusalem-gold);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
}

.btn-close-help:hover {
    background: var(--jerusalem-gold-dark);
}