/**
 * Wordz.org - Custom Styles
 * Light/Dark theme support with solid colors
 */

/* ==========================================
   Base & Reset
   ========================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    height: 100%;
    /* Allow scrolling only when content overflows on very small screens */
    overflow-x: hidden;
    overflow-y: auto;
}

/* ==========================================
   Theme Transitions
   ========================================== */

html {
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==========================================
   Card Styles
   ========================================== */

.language-card.selected {
    border-color: #6366f1 !important;
    background-color: #eef2ff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.dark .language-card.selected {
    background-color: rgba(99, 102, 241, 0.2);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* ==========================================
   Custom Animations
   ========================================== */

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in-scale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-in {
    animation: fade-in-up 0.6s ease forwards;
}

.animate-in-scale {
    animation: fade-in-scale 0.5s ease forwards;
}

/* ==========================================
   Game Mode & Difficulty Chips
   ========================================== */

.game-mode-chip,
.difficulty-chip {
    transition: all 0.3s ease;
    position: relative;
}

.game-mode-chip:hover,
.difficulty-chip:hover {
    transform: translateY(-2px);
}

/* Selected state - Game Mode Chips */
.game-mode-chip.selected {
    transform: scale(1.05);
    border-color: #6366f1 !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Word Scramble - Indigo */
.game-mode-chip:nth-child(1).selected {
    background-color: #c7d2fe !important;
}

.dark .game-mode-chip:nth-child(1).selected {
    background-color: rgba(99, 102, 241, 0.4) !important;
}

/* Multiple Choice - Cyan */
.game-mode-chip:nth-child(2).selected {
    background-color: #a5f3fc !important;
    border-color: #06b6d4 !important;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.dark .game-mode-chip:nth-child(2).selected {
    background-color: rgba(6, 182, 212, 0.4) !important;
}

/* Fill in the Blank - Purple */
.game-mode-chip:nth-child(3).selected {
    background-color: #e9d5ff !important;
    border-color: #a855f7 !important;
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

.dark .game-mode-chip:nth-child(3).selected {
    background-color: rgba(168, 85, 247, 0.4) !important;
}

/* Selected state - Difficulty Chips */
.difficulty-chip.selected {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Beginner - Emerald */
.difficulty-chip:nth-child(1).selected {
    background-color: #a7f3d0 !important;
    border-color: #10b981 !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.dark .difficulty-chip:nth-child(1).selected {
    background-color: rgba(16, 185, 129, 0.4) !important;
}

/* Intermediate - Amber */
.difficulty-chip:nth-child(2).selected {
    background-color: #fde68a !important;
    border-color: #f59e0b !important;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.dark .difficulty-chip:nth-child(2).selected {
    background-color: rgba(245, 158, 11, 0.4) !important;
}

/* Advanced - Rose */
.difficulty-chip:nth-child(3).selected {
    background-color: #fecdd3 !important;
    border-color: #f43f5e !important;
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
}

.dark .difficulty-chip:nth-child(3).selected {
    background-color: rgba(244, 63, 94, 0.4) !important;
}

/* Selected indicator checkmark */
.game-mode-chip.selected::after,
.difficulty-chip.selected::after {
    content: '✓';
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    background-color: #10b981;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ==========================================
   Button Styles
   ========================================== */

button {
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* ==========================================
   Scrollbar (hidden but functional)
   ========================================== */

::-webkit-scrollbar {
    width: 0;
    height: 0;
}

/* ==========================================
   Selection
   ========================================== */

::selection {
    background: rgba(99, 102, 241, 0.3);
    color: inherit;
}

/* ==========================================
   Responsive Adjustments
   ========================================== */

/* Extra small devices */
@media (max-height: 600px) {
    .language-card {
        padding: 0.375rem !important;
    }

    .language-card span:first-child {
        font-size: 1.25rem;
    }

    .game-mode-chip,
    .difficulty-chip {
        padding: 0.375rem 0.625rem !important;
    }

    #main-cta button {
        padding: 0.75rem 1.5rem !important;
    }
}

/* Tablet landscape */
@media (min-width: 768px) and (max-height: 700px) {
    #hero-text h1 {
        font-size: 2.25rem;
    }

    #hero-text p {
        font-size: 0.875rem;
    }
}

/* Large screens */
@media (min-width: 1280px) {
    .language-card:hover {
        transform: scale(1.08) translateY(-4px);
    }
}

/* ==========================================
   Accessibility
   ========================================== */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {

    .language-card,
    .game-mode-chip,
    .difficulty-chip {
        border-width: 3px;
    }
}

/* ==========================================
   Entrance Animations (initial state)
   ========================================== */

#logo,
#hero-text,
#language-grid,
#features-grid,
#main-cta {
    opacity: 0;
}

/* ==========================================
   Theme Toggle Button
   ========================================== */

#theme-toggle {
    transition: transform 0.3s ease, background-color 0.3s ease;
}

#theme-toggle:hover {
    transform: rotate(15deg);
}

#theme-toggle:active {
    transform: scale(0.95);
}

/* ==========================================
   Game Page Styles
   ========================================== */

/* Game Header */
.game-header {
    position: sticky;
    top: 0;
    z-index: 50;
}

/* Letter Tiles (Word Scramble) */
.letter-tile {
    transition: all 0.2s ease;
    user-select: none;
}

.letter-tile:hover:not(.used):not(:disabled) {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.letter-tile.used {
    opacity: 0.4;
    cursor: not-allowed;
    transform: scale(0.95);
}

/* Option Buttons (Multiple Choice / Fill in Blank) */
.option-btn {
    transition: all 0.2s ease;
}

.option-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.option-btn:disabled {
    cursor: not-allowed;
}

/* Correct/Incorrect Answer Highlights */
.option-btn.correct {
    background-color: #d1fae5 !important;
    border-color: #10b981 !important;
}

.dark .option-btn.correct {
    background-color: rgba(16, 185, 129, 0.3) !important;
}

.option-btn.incorrect {
    background-color: #fee2e2 !important;
    border-color: #f43f5e !important;
}

.dark .option-btn.incorrect {
    background-color: rgba(244, 63, 94, 0.3) !important;
}

/* Loading Spinner */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Shake Animation (Wrong Answer) */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-4px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(4px);
    }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

/* Pulse Animation (Correct Answer) */
@keyframes pulse-success {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02);
    }

    100% {
        transform: scale(1);
    }
}

.pulse-success {
    animation: pulse-success 0.3s ease-in-out;
}

/* Score Update Animation */
@keyframes score-pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}

.score-pop {
    animation: score-pop 0.3s ease-out;
}

/* Results Screen Confetti Background */
#results-screen {
    position: relative;
    overflow: hidden;
}

/* Game Container Full Height */
#game-container {
    min-height: 100vh;
    min-height: 100dvh;
}

/* Input Styles for Fill in the Blank */
#blank-input {
    font-family: inherit;
}

#blank-input:focus {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Progress Bar Animation */
#progress-bar {
    transition: width 0.5s ease-out;
}

/* Responsive Game Adjustments */
@media (max-width: 640px) {
    .letter-tile {
        width: 2.75rem;
        height: 2.75rem;
        font-size: 1.125rem;
    }

    .option-btn {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
}

/* Dark Mode Game Enhancements */
.dark #question-card {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.dark #results-screen {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

/* ==========================================
   Enhanced Polish Effects
   ========================================== */

/* Smooth page transitions */
body {
    transition: opacity 0.3s ease;
}

/* Enhanced loading spinner with gradient */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.loading-shimmer {
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(99, 102, 241, 0.1) 50%,
            transparent 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Premium button glow effect */
#submit-btn:hover,
#next-btn:hover,
#play-again-btn:hover {
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}

#submit-btn:active,
#next-btn:active,
#play-again-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

/* Language card hover enhancement */
.language-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.language-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.dark .language-card:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* Floating animation for hero elements */
@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.float-animation {
    animation: float 3s ease-in-out infinite;
}

/* Pulse animation for CTA button */
@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    }

    50% {
        box-shadow: 0 8px 30px rgba(99, 102, 241, 0.6);
    }
}

#main-cta button:not(:hover) {
    animation: pulse-glow 2s ease-in-out infinite;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Selection highlight */
::selection {
    background-color: rgba(99, 102, 241, 0.3);
    color: inherit;
}

/* Focus visible states for accessibility */
*:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* Enhanced option buttons for game */
.option-btn {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.option-btn:hover:not(.correct):not(.incorrect) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

/* Toast notification styles */
#toast {
    backdrop-filter: blur(10px);
}

/* Header fixed shadow on scroll */
.game-header {
    transition: box-shadow 0.3s ease;
}

.game-header.scrolled {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.dark .game-header.scrolled {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}