/**
 * Games 2D - Styles CSS
 * Arcade WeWorkWeb
 * 
 * @description Styles pour les jeux 2D Canvas et l'arcade
 * @author Ayoub Kahouadji
 */

/* =====================================================
   VARIABLES JEUX
   ===================================================== */

:root {
    /* Couleurs des jeux par catégorie */
    --game-2d-color: #22c55e;
    --game-3d-color: #8b5cf6;
    --game-ai-color: #0ea5e9;
    
    /* Tailles */
    --game-border-radius: 16px;
    --game-padding: 16px;
    
    /* Transitions */
    --game-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =====================================================
   WRAPPER DU JEU
   ===================================================== */

.www-game-wrapper {
    position: relative;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    background: linear-gradient(
        135deg,
        rgba(3, 7, 17, 0.95) 0%,
        rgba(15, 23, 42, 0.9) 50%,
        rgba(30, 27, 75, 0.85) 100%
    );
    border: 1px solid rgba(94, 234, 212, 0.2);
    border-radius: var(--game-border-radius);
    overflow: hidden;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
}

/* =====================================================
   HEADER DU JEU
   ===================================================== */

.www-game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.www-game-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.www-game-icon {
    font-size: 24px;
    line-height: 1;
}

.www-game-title {
    font-family: var(--font-display, 'Space Grotesk', sans-serif);
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.www-game-controls {
    display: flex;
    gap: 8px;
}

.www-game-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: var(--game-transition);
}

.www-game-btn:hover {
    background: rgba(94, 234, 212, 0.2);
    border-color: rgba(94, 234, 212, 0.4);
    color: var(--color-primary-cyan, #5eead4);
    transform: scale(1.05);
}

.www-game-btn:active {
    transform: scale(0.95);
}

/* =====================================================
   HUD (Heads-Up Display)
   ===================================================== */

.www-game-hud {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.www-game-score,
.www-game-time,
.www-game-lives {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.www-game-hud .label {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.5);
}

.www-game-hud .value {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 18px;
    font-weight: 700;
    color: white;
}

.www-game-score .value {
    color: var(--color-primary-cyan, #5eead4);
}

.www-game-lives .value {
    font-size: 16px;
}

/* =====================================================
   CONTAINER DU JEU (Canvas)
   ===================================================== */

.www-game-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #030711;
    overflow: hidden;
}

.www-game-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Loading */
.www-game-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: rgba(3, 7, 17, 0.95);
    z-index: 100;
}

.www-game-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(94, 234, 212, 0.2);
    border-top-color: var(--color-primary-cyan, #5eead4);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.www-game-loading p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* =====================================================
   ÉCRANS DE JEU (Menu, Pause, Game Over, Win)
   ===================================================== */

.www-game-menu,
.www-game-pause,
.www-game-over,
.www-game-win {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 24px;
    background: rgba(3, 7, 17, 0.95);
    backdrop-filter: blur(10px);
    z-index: 50;
    text-align: center;
}

.www-game-menu[hidden],
.www-game-pause[hidden],
.www-game-over[hidden],
.www-game-win[hidden] {
    display: none;
}

.www-game-menu h2,
.www-game-pause h2,
.www-game-over h2,
.www-game-win h2 {
    font-family: var(--font-display, 'Space Grotesk', sans-serif);
    font-size: 28px;
    font-weight: 700;
    color: white;
    margin: 0;
}

.www-game-menu p,
.www-game-pause p,
.www-game-over p,
.www-game-win p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    max-width: 400px;
    margin: 0;
}

/* Boutons principaux */
.www-game-btn-primary,
.www-game-btn-secondary {
    padding: 12px 32px;
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--game-transition);
}

.www-game-btn-primary {
    background: linear-gradient(135deg, var(--color-primary-cyan, #5eead4), var(--color-primary-indigo, #818cf8));
    color: #030711;
    box-shadow: 0 4px 20px -5px rgba(94, 234, 212, 0.5);
}

.www-game-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px -5px rgba(94, 234, 212, 0.6);
}

.www-game-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.www-game-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Difficulté */
.www-game-difficulty {
    display: flex;
    align-items: center;
    gap: 12px;
}

.www-game-difficulty label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.www-game-difficulty select {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 14px;
    cursor: pointer;
}

.www-game-difficulty select:focus {
    outline: none;
    border-color: var(--color-primary-cyan, #5eead4);
}

/* Contrôles aide */
.www-game-controls-help {
    margin-top: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    text-align: left;
}

.www-game-controls-help h4 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.5);
    margin: 0 0 12px 0;
}

.www-game-controls-help ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.www-game-controls-help li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
}

.www-game-controls-help kbd {
    display: inline-block;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    font-family: var(--font-mono, monospace);
    font-size: 11px;
    color: var(--color-primary-cyan, #5eead4);
}

/* Score final */
.www-game-final-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 40px;
    background: rgba(94, 234, 212, 0.1);
    border: 1px solid rgba(94, 234, 212, 0.3);
    border-radius: 16px;
}

.www-game-final-score .label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.www-game-final-score .value {
    font-family: var(--font-mono, monospace);
    font-size: 48px;
    font-weight: 700;
    color: var(--color-primary-cyan, #5eead4);
    text-shadow: 0 0 30px rgba(94, 234, 212, 0.5);
}

/* Highscore notification */
.www-game-highscore {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.2));
    border: 1px solid rgba(251, 191, 36, 0.4);
    border-radius: 12px;
    animation: pulse-gold 2s infinite;
}

.www-game-highscore span {
    font-size: 16px;
    font-weight: 600;
    color: #fbbf24;
}

@keyframes pulse-gold {
    0%, 100% {
        box-shadow: 0 0 20px rgba(251, 191, 36, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(251, 191, 36, 0.5);
    }
}

/* Stars */
.www-game-stars {
    font-size: 32px;
    animation: stars-bounce 0.5s ease-out;
}

@keyframes stars-bounce {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* =====================================================
   ARCADE (liste des jeux)
   ===================================================== */

.www-arcade {
    padding: 24px;
}

/* Filtres */
.www-arcade-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 32px;
    justify-content: center;
}

.www-arcade-filter {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: var(--game-transition);
}

.www-arcade-filter:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.www-arcade-filter.active {
    background: linear-gradient(135deg, var(--color-primary-cyan, #5eead4), var(--color-primary-indigo, #818cf8));
    border-color: transparent;
    color: #030711;
}

/* Grille des jeux */
.www-arcade-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.www-arcade[data-columns="2"] .www-arcade-grid {
    grid-template-columns: repeat(2, 1fr);
}

.www-arcade[data-columns="4"] .www-arcade-grid {
    grid-template-columns: repeat(4, 1fr);
}

/* Carte de jeu */
.www-arcade-card {
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    overflow: hidden;
    transition: var(--game-transition);
}

.www-arcade-card:hover {
    transform: translateY(-4px);
    border-color: var(--game-color, rgba(94, 234, 212, 0.3));
    box-shadow: 
        0 20px 40px -15px rgba(0, 0, 0, 0.4),
        0 0 40px -10px var(--game-color, rgba(94, 234, 212, 0.3));
}

.www-arcade-card-visual {
    position: relative;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(
        135deg,
        rgba(var(--game-color, 94, 234, 212), 0.1) 0%,
        rgba(var(--game-color, 94, 234, 212), 0.05) 100%
    );
}

.www-arcade-card-icon {
    font-size: 64px;
    line-height: 1;
    filter: drop-shadow(0 4px 20px var(--game-color, rgba(94, 234, 212, 0.4)));
}

.www-arcade-card-category {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: white;
}

.www-arcade-card[data-category="2d"] .www-arcade-card-category {
    color: var(--game-2d-color);
}

.www-arcade-card[data-category="3d"] .www-arcade-card-category {
    color: var(--game-3d-color);
}

.www-arcade-card[data-category="ai"] .www-arcade-card-category {
    color: var(--game-ai-color);
}

.www-arcade-card-content {
    padding: 20px;
}

.www-arcade-card-title {
    font-family: var(--font-display, 'Space Grotesk', sans-serif);
    font-size: 18px;
    font-weight: 600;
    color: white;
    margin: 0 0 8px 0;
}

.www-arcade-card-desc {
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.6);
    margin: 0 0 16px 0;
}

.www-arcade-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.www-arcade-card-difficulty {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.www-arcade-card-difficulty[data-difficulty="easy"] {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.www-arcade-card-difficulty[data-difficulty="medium"] {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.www-arcade-card-difficulty[data-difficulty="hard"] {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.www-arcade-card-difficulty[data-difficulty="expert"] {
    background: rgba(139, 92, 246, 0.2);
    color: #8b5cf6;
}

.www-arcade-card-duration {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.www-arcade-card-play {
    display: block;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--game-color, #5eead4), color-mix(in srgb, var(--game-color, #5eead4), #818cf8 30%));
    border-radius: 10px;
    text-align: center;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    color: #030711;
    transition: var(--game-transition);
}

.www-arcade-card-play:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 20px -5px var(--game-color, rgba(94, 234, 212, 0.4));
}

/* =====================================================
   MESSAGES D'ERREUR
   ===================================================== */

.www-game-error {
    padding: 20px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    color: #ef4444;
    text-align: center;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {
    .www-game-wrapper {
        border-radius: 12px;
    }
    
    .www-game-header {
        padding: 10px 12px;
    }
    
    .www-game-title {
        font-size: 14px;
    }
    
    .www-game-btn {
        width: 32px;
        height: 32px;
    }
    
    .www-game-hud {
        padding: 10px 12px;
    }
    
    .www-game-hud .value {
        font-size: 16px;
    }
    
    .www-game-container {
        aspect-ratio: 16 / 10;
    }
    
    .www-game-menu h2,
    .www-game-pause h2,
    .www-game-over h2,
    .www-game-win h2 {
        font-size: 24px;
    }
    
    .www-game-final-score .value {
        font-size: 36px;
    }
    
    .www-arcade-grid {
        grid-template-columns: 1fr;
    }
    
    .www-arcade[data-columns="2"] .www-arcade-grid,
    .www-arcade[data-columns="4"] .www-arcade-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .www-game-controls-help ul {
        grid-template-columns: 1fr;
    }
    
    .www-game-btn-primary,
    .www-game-btn-secondary {
        width: 100%;
        padding: 14px 20px;
    }
    
    .www-arcade-filters {
        gap: 8px;
    }
    
    .www-arcade-filter {
        padding: 8px 16px;
        font-size: 12px;
    }
}

/* =====================================================
   PRÉFÉRENCE MOUVEMENT RÉDUIT
   ===================================================== */

@media (prefers-reduced-motion: reduce) {
    .www-game-btn,
    .www-game-btn-primary,
    .www-game-btn-secondary,
    .www-arcade-card,
    .www-arcade-card-play {
        transition: none;
    }
    
    .www-game-spinner,
    .www-game-highscore,
    .www-game-stars {
        animation: none;
    }
}

/* =====================================================
   ÉTATS DE FILTRAGE ARCADE
   ===================================================== */

.www-arcade-card.filtered-out {
    display: none;
}

/* Animation d'apparition des cartes */
.www-arcade-card {
    animation: card-appear 0.3s ease-out;
    animation-fill-mode: backwards;
}

.www-arcade-card:nth-child(1) { animation-delay: 0.05s; }
.www-arcade-card:nth-child(2) { animation-delay: 0.1s; }
.www-arcade-card:nth-child(3) { animation-delay: 0.15s; }
.www-arcade-card:nth-child(4) { animation-delay: 0.2s; }
.www-arcade-card:nth-child(5) { animation-delay: 0.25s; }
.www-arcade-card:nth-child(6) { animation-delay: 0.3s; }

@keyframes card-appear {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
