/* Custom animations and styles for Slide Puzzles */

/* Tile styles */
.tile {
    background: linear-gradient(135deg, #4B5B9F 0%, #6B7FC8 50%, #9BA8DD 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 16px rgba(31, 33, 72, 0.4), 
                0 4px 8px rgba(0, 0, 0, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    user-select: none;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    aspect-ratio: 1;
    width: 100%;
    min-height: 50px;
    font-size: clamp(28px, 8vw, 48px);
}

.tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s;
}

.tile:hover::before {
    left: 100%;
}

.tile:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 24px rgba(31, 33, 72, 0.5), 
                0 6px 12px rgba(0, 0, 0, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.2);
}

.tile:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 4px 8px rgba(31, 33, 72, 0.4), 
                0 2px 4px rgba(0, 0, 0, 0.2);
}

.tile.empty {
    background: linear-gradient(135deg, rgba(51, 65, 85, 0.4) 0%, rgba(30, 41, 59, 0.4) 100%);
    cursor: default;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.tile.empty:hover {
    transform: none;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Slide animation for tiles */
@keyframes slideIn {
    from {
        transform: translateX(0) translateY(0);
        opacity: 0.8;
    }
    to {
        transform: translateX(0) translateY(0);
        opacity: 1;
    }
}

.tile {
    animation: slideIn 0.3s ease-out;
}

/* Win celebration animation */
@keyframes confetti {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) rotate(360deg);
        opacity: 0;
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Number counter animation */
@keyframes countUp {
    from {
        transform: scale(1.2);
        opacity: 0.5;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

#step-counter,
#timer {
    animation: countUp 0.3s ease-out;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Keyboard key styling */
kbd {
    display: inline-block;
    padding: 6px 10px;
    font-size: 11px;
    line-height: 1;
    color: #e2e8f0;
    background: linear-gradient(135deg, rgba(51, 65, 85, 0.6) 0%, rgba(30, 41, 59, 0.6) 100%);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    font-family: 'Courier New', monospace;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Modal animation */
#win-modal > div {
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.8) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .tile {
        font-size: 14px;
        border-radius: 12px;
        box-shadow: 0 6px 12px rgba(31, 33, 72, 0.35), 
                    0 3px 6px rgba(0, 0, 0, 0.15);
    }
    
    .tile:hover {
        transform: translateY(-1px) scale(1.01);
        box-shadow: 0 8px 16px rgba(31, 33, 72, 0.4), 
                    0 4px 8px rgba(0, 0, 0, 0.2);
    }
    
    #game-board {
        padding: 12px !important;
    }
}

/* Level dropdown styling */
#level-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e2e8f0' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1em;
    padding-right: 2.5rem;
}

#level-select:hover {
    background-color: rgba(51, 65, 85, 0.7);
    border-color: rgba(148, 163, 184, 0.4);
}

#level-select:focus {
    background-color: rgba(51, 65, 85, 0.8);
}

/* Smooth transitions for all interactive elements */
button, .tile {
    -webkit-tap-highlight-color: transparent;
}

/* Prevent text selection during gameplay */
#game-board {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Loading state (if needed) */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Success state for tiles */
.tile.success {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    animation: pulse 0.5s ease-in-out;
    box-shadow: 0 8px 16px rgba(16, 185, 129, 0.4), 
                0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Start overlay */
#start-overlay {
    animation: fadeIn 0.4s ease-out;
}

#start-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-out;
}

/* Details/Summary styling */
details summary {
    list-style: none;
}

details summary::-webkit-details-marker {
    display: none;
}

details summary::marker {
    display: none;
}

/* Smooth page load animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body > div {
    animation: fadeIn 0.6s ease-out;
}

/* Improved focus states for accessibility */
button:focus-visible,
.level-btn:focus-visible {
    outline: 2px solid rgba(107, 127, 200, 0.8);
    outline-offset: 2px;
}

/* Glass morphism effect enhancement */
.bg-slate-800\/60 {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

