/**
 * UI Components CSS - Touch controls and visual feedback styles
 * Styles for pawn selection, move previews, and interactive elements
 */

/* Pawn Selection Styles */
.card.selected-pawn {
    border: 3px solid #FFD700;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
    transform: scale(1.05);
    z-index: 10;
    position: relative;
}

.card.selected-pawn::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: inherit;
    animation: pulse-glow 1.5s ease-in-out infinite alternate;
}

@keyframes pulse-glow {
    0% {
        opacity: 0.4;
        transform: scale(1);
    }
    100% {
        opacity: 0.8;
        transform: scale(1.02);
    }
}

/* Valid Destination Highlighting */
.card.valid-destination {
    border: 2px solid #28A745;
    background-color: rgba(40, 167, 69, 0.1);
    cursor: pointer;
    transition: all 0.15s ease-out;
}

.card.valid-destination:hover {
    background-color: rgba(40, 167, 69, 0.2);
    transform: translateY(-1px);
}

.card.joker-valid-destination {
    border: 2px solid #17A2B8;
    background-color: rgba(23, 162, 184, 0.1);
    cursor: pointer;
    transition: all 0.15s ease-out;
}

.card.joker-valid-destination:hover {
    background-color: rgba(23, 162, 184, 0.2);
    transform: translateY(-1px);
}

.card.immediate-destination {
    border-width: 3px;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

/* Distance Indicators for Numbered Cards */
.card.distance-1::before { content: '1'; }
.card.distance-2::before { content: '2'; }
.card.distance-3::before { content: '3'; }
.card.distance-4::before { content: '4'; }

.card[class*="distance-"]::before {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(40, 167, 69, 0.8);
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

/* Invalid Move Feedback */
.card.invalid-selection-shake,
.card.invalid-move-shake {
    animation: shake-error 0.3s ease-in-out;
    border: 2px solid #DC3545;
    background-color: rgba(220, 53, 69, 0.1);
}

@keyframes shake-error {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

/* Touch Target Accessibility */
.card {
    min-width: 44px;
    min-height: 44px;
    position: relative;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* Prevent text selection during touch interactions */
.game-board {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Pulse Animation for Valid Destinations */
.card.pulse {
    animation: destination-pulse 1.2s ease-in-out infinite;
}

@keyframes destination-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(40, 167, 69, 0.1);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

.card.joker-valid-destination.pulse {
    animation: joker-destination-pulse 1.2s ease-in-out infinite;
}

@keyframes joker-destination-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(23, 162, 184, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(23, 162, 184, 0.1);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(23, 162, 184, 0);
    }
}

/* Invalid Destinations (Disabled Look) */
.card.invalid-destination {
    opacity: 0.5;
    filter: grayscale(0.3);
    cursor: not-allowed;
}

/* Move Completion Feedback */
.card.move-completed {
    border: 3px solid #28A745;
    background-color: rgba(40, 167, 69, 0.2);
    animation: move-completion-flash 1s ease-out;
}

@keyframes move-completion-flash {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.8);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 20px 10px rgba(40, 167, 69, 0.3);
        transform: scale(1.05);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
        transform: scale(1);
    }
}

/* Turn Indicator Styles */
.turn-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: bold;
    font-size: 14px;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-width: 44px;
    text-align: center;
}

.turn-indicator.red-turn {
    border-color: #DC3545;
    color: #DC3545;
}

.turn-indicator.blue-turn {
    border-color: #007BFF;
    color: #007BFF;
}

/* Hamburger Menu Styles */
.hamburger-menu {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.15s ease-out;
}

.hamburger-menu:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.hamburger-line {
    width: 20px;
    height: 2px;
    background: #333;
    margin: 2px 0;
    transition: all 0.15s ease-out;
}

.hamburger-menu.open .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-menu.open .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.open .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Dropdown Menu */
.menu-dropdown {
    position: fixed;
    top: 70px;
    left: 20px;
    min-width: 150px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    z-index: 99;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.2s ease-out;
    pointer-events: none;
}

.menu-dropdown.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.menu-item {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.15s ease-out;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover {
    background-color: #f8f9fa;
}

/* Joker Controls */
.joker-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #17A2B8;
    border-radius: 8px;
    padding: 12px 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    z-index: 100;
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    transition: all 0.25s ease-out;
    pointer-events: none;
}

.joker-controls.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.joker-progress {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
    text-align: center;
}

.end-turn-button {
    background: #17A2B8;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    transition: all 0.15s ease-out;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.end-turn-button:hover {
    background: #138496;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(19, 132, 150, 0.3);
}

.end-turn-button:active {
    transform: translateY(0);
    background: #0f6674;
}

/* Game Notification Styles */
.game-notification {
    position: fixed;
    top: 70px;
    right: 20px;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    color: white;
    z-index: 101;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    animation: notification-slide-in 0.3s ease-out;
}

.game-notification.success {
    background-color: #28A745;
}

.game-notification.error {
    background-color: #DC3545;
}

.game-notification.info {
    background-color: #17A2B8;
}

@keyframes notification-slide-in {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Rules Dialog Styles */
.rules-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-out;
    padding: 20px;
    box-sizing: border-box;
}

.rules-dialog.visible {
    opacity: 1;
    visibility: visible;
}

.rules-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    max-height: 80vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.3s ease-out;
}

.rules-dialog.visible .rules-content {
    transform: translateY(0);
}

.rules-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px;
    border-bottom: 2px solid #f0f0f0;
    flex-shrink: 0;
}

.rules-title {
    margin: 0;
    font-size: 24px;
    font-weight: bold;
    color: #333;
}

.rules-close-button {
    background: none;
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.15s ease-out;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rules-close-button:hover {
    background: #f5f5f5;
    color: #333;
}

.rules-body {
    padding: 20px 24px 24px;
    overflow-y: auto;
    flex: 1;
}

.rules-section {
    margin-bottom: 24px;
}

.rules-section:last-child {
    margin-bottom: 0;
}

.rules-section h3 {
    margin: 0 0 12px 0;
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.rules-section p {
    margin: 0 0 12px 0;
    line-height: 1.6;
    color: #555;
}

.rules-section p:last-child {
    margin-bottom: 0;
}

.rules-section ul {
    margin: 0 0 12px 0;
    padding-left: 20px;
}

.rules-section li {
    margin-bottom: 8px;
    line-height: 1.6;
    color: #555;
}

.rules-section li:last-child {
    margin-bottom: 0;
}

.rules-section strong {
    color: #333;
    font-weight: 600;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .turn-indicator,
    .hamburger-menu {
        top: 10px;
    }
    
    .hamburger-menu {
        left: 10px;
    }
    
    .turn-indicator {
        right: 10px;
    }
    
    .menu-dropdown {
        top: 60px;
        left: 10px;
    }
    
    .joker-controls {
        bottom: 10px;
        left: 10px;
        right: 10px;
        transform: none;
    }
    
    .joker-controls.visible {
        transform: none;
    }
    
    .game-notification {
        top: 60px;
        right: 10px;
        left: 10px;
        text-align: center;
    }
    
    .rules-dialog {
        padding: 10px;
    }
    
    .rules-content {
        max-height: 90vh;
    }
    
    .rules-header {
        padding: 16px 20px 12px;
    }
    
    .rules-title {
        font-size: 20px;
    }
    
    .rules-body {
        padding: 16px 20px 20px;
    }
    
    .rules-section {
        margin-bottom: 20px;
    }
    
    .rules-section h3 {
        font-size: 16px;
    }
}

/* Winner Modal Styles */
.winner-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s ease-out;
    padding: 20px;
    box-sizing: border-box;
}

.winner-dialog.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.winner-content {
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
    max-width: 400px;
    width: 100%;
    display: flex;
    flex-direction: column;
    transform: translateY(30px) scale(0.9);
    transition: transform 0.3s ease-out;
    overflow: hidden;
    position: relative;
}

.winner-dialog.visible .winner-content {
    transform: translateY(0) scale(1);
}

.winner-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 16px;
    background: linear-gradient(135deg, #28A745 0%, #20C997 100%);
    color: white;
    position: relative;
}

.winner-header.red-winner {
    background: linear-gradient(135deg, #DC3545 0%, #E74C3C 100%);
}

.winner-header.blue-winner {
    background: linear-gradient(135deg, #007BFF 0%, #0056B3 100%);
}

.winner-title {
    margin: 0;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    flex: 1;
    text-align: center;
}

.winner-close-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 24px;
    color: white;
    cursor: pointer;
    padding: 8px 12px;
    line-height: 1;
    border-radius: 50%;
    transition: all 0.15s ease-out;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.winner-close-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.winner-body {
    padding: 24px;
    text-align: center;
}

.winner-message {
    margin-bottom: 24px;
}

.winner-message p {
    margin: 0 0 12px 0;
    font-size: 16px;
    line-height: 1.5;
    color: #555;
}

.winner-message p:last-child {
    margin-bottom: 0;
}

.winner-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.new-game-button {
    background: linear-gradient(135deg, #28A745 0%, #20C997 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    transition: all 0.15s ease-out;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.new-game-button:hover {
    background: linear-gradient(135deg, #218838 0%, #1ABC9C 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(40, 167, 69, 0.4);
}

.new-game-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

/* Confetti Animation */
.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: -1;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #FFD700;
    animation: confetti-fall 3s linear infinite;
}

.confetti-piece:nth-child(2n) { background: #FF6B6B; }
.confetti-piece:nth-child(3n) { background: #4ECDC4; }
.confetti-piece:nth-child(4n) { background: #45B7D1; }
.confetti-piece:nth-child(5n) { background: #96CEB4; }
.confetti-piece:nth-child(6n) { background: #FFEAA7; }

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Game Over State Styles */
.turn-indicator.game-over {
    background: linear-gradient(135deg, #28A745 0%, #20C997 100%);
    color: white;
    border-color: #28A745;
    animation: victory-pulse 2s ease-in-out infinite;
}

.turn-indicator.game-over.winner-red {
    background: linear-gradient(135deg, #DC3545 0%, #E74C3C 100%);
    border-color: #DC3545;
}

.turn-indicator.game-over.winner-blue {
    background: linear-gradient(135deg, #007BFF 0%, #0056B3 100%);
    border-color: #007BFF;
}

@keyframes victory-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 4px 16px rgba(40, 167, 69, 0.3);
    }
}

/* Game Board Disabled State */
.game-board.game-ended {
    opacity: 0.7;
    filter: grayscale(0.3);
    position: relative;
}

.game-board.game-ended::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    z-index: 10;
    pointer-events: none;
}

/* Responsive adjustments for winner modal */
@media (max-width: 480px) {
    .winner-dialog {
        padding: 10px;
    }
    
    .winner-content {
        max-width: 100%;
        margin: 0 auto;
    }
    
    .winner-header {
        padding: 20px 20px 12px;
    }
    
    .winner-title {
        font-size: 20px;
    }
    
    .winner-body {
        padding: 20px;
    }
    
    .winner-message p {
        font-size: 14px;
    }
    
    .new-game-button {
        font-size: 14px;
        padding: 10px 20px;
    }
}