/**
 * Memory Game CSS - Memoria Quiz
 * Styles pour le jeu de mémoire avec animations et effets
 */

/* ==========================================================================
   Container principal
   ========================================================================== */

.memoria-memory-game {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    position: relative;
}

/* ==========================================================================
   Header et informations
   ========================================================================== */

.memoria-memory-header {
    text-align: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 20px;
    backdrop-filter: blur(10px);
}

.memoria-memory-title {
    font-size: 28px;
    color: #2c3e50;
    margin: 0 0 10px 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.memoria-memory-instructions {
    margin-bottom: 20px;
}

.memoria-memory-instructions p {
    font-size: 16px;
    color: #34495e;
    margin: 0;
    line-height: 1.6;
}

.memoria-memory-stats {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 20px;
}

.memoria-stat {
    background: rgba(52, 152, 219, 0.1);
    padding: 10px 15px;
    border-radius: 10px;
    min-width: 120px;
    text-align: center;
}

.memoria-stat-label {
    display: block;
    font-size: 12px;
    color: #7f8c8d;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 5px;
}

.memoria-stat-value {
    font-size: 18px;
    font-weight: bold;
    color: #2c3e50;
}

.memoria-stat-total {
    font-size: 14px;
    color: #95a5a6;
}

/* ==========================================================================
   Plateau de jeu
   ========================================================================== */

.memoria-memory-board {
    display: grid;
    gap: 15px;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    backdrop-filter: blur(5px);
}

/* Grilles selon la difficulté */
.memoria-memory-board.grid-4x2 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.memoria-memory-board.grid-4x3 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.memoria-memory-board.grid-4x4 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

/* ==========================================================================
   Cartes
   ========================================================================== */

.memoria-card {
    aspect-ratio: 1;
    cursor: pointer;
    transition: transform 0.3s ease;
    perspective: 1000px;
}

.memoria-card:hover {
    transform: translateY(-5px);
}

.memoria-card.matched {
    cursor: default;
    opacity: 0.8;
}

.memoria-card.matched:hover {
    transform: none;
}

.memoria-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.memoria-card.flipped .memoria-card-inner {
    transform: rotateY(180deg);
}

.memoria-card-front,
.memoria-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    box-sizing: border-box;
}

.memoria-card-front {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.memoria-card-back {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    transform: rotateY(180deg);
    color: white;
}

.memoria-card-back-pattern {
    font-size: 32px;
    opacity: 0.7;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.memoria-card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.memoria-card-main {
    font-size: 24px;
    margin-bottom: 5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.memoria-card-label {
    font-size: 11px;
    opacity: 0.9;
    font-weight: 600;
    text-transform: uppercase;
    line-height: 1.2;
}

/* Types de contenu */
.memoria-card-content[data-type="image"] .memoria-card-main {
    font-size: 32px;
}

.memoria-card-content[data-type="text"] .memoria-card-main {
    font-size: 14px;
    font-weight: bold;
}

/* ==========================================================================
   Effets de succès et d'échec
   ========================================================================== */

.memoria-card.match-success {
    animation: matchSuccess 0.6s ease-out;
}

.memoria-card.match-fail {
    animation: matchFail 0.4s ease-out;
}

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

@keyframes matchFail {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
    100% { transform: translateX(0); }
}

.memoria-card.matched .memoria-card-back {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%);
}

.memoria-card.matched .memoria-card-inner {
    box-shadow: 0 0 20px rgba(86, 171, 47, 0.5);
}

/* ==========================================================================
   Footer et boutons
   ========================================================================== */

.memoria-memory-footer {
    text-align: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

.memoria-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.memoria-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.memoria-btn-secondary {
    background: linear-gradient(135deg, #a8a8a8 0%, #7f7f7f 100%);
}

.memoria-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* ==========================================================================
   Overlay de fin de jeu
   ========================================================================== */

.memoria-completion-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    z-index: 100;
    animation: fadeIn 0.3s ease-out;
}

.memoria-completion-message {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.5s ease-out;
}

.memoria-completion-message h3 {
    margin: 0 0 20px 0;
    font-size: 24px;
    color: #2c3e50;
}

.memoria-completion-message p {
    margin: 0 0 20px 0;
    color: #7f8c8d;
    font-size: 16px;
}

.memoria-completion-stats {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    gap: 10px;
}

.memoria-completion-stats .memoria-stat {
    background: #f8f9fa;
    flex: 1;
    min-width: auto;
}

.memoria-completion-actions {
    margin-top: 20px;
}

.memoria-completion-overlay.timeout .memoria-completion-message {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
}

.memoria-completion-overlay.timeout h3 {
    color: white;
}

.memoria-completion-overlay.timeout p {
    color: rgba(255, 255, 255, 0.9);
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-30px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Thèmes
   ========================================================================== */

/* Thème Monuments */
.memoria-memory-game[data-theme="monuments"] {
    background: linear-gradient(135deg, #ffeaa7 0%, #fab1a0 100%);
}

.memoria-memory-game[data-theme="monuments"] .memoria-card-front {
    background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
}

.memoria-memory-game[data-theme="monuments"] .memoria-card-back {
    background: linear-gradient(135deg, #fd79a8 0%, #fdcb6e 100%);
}

/* Thème Artistes */
.memoria-memory-game[data-theme="artistes"] {
    background: linear-gradient(135deg, #dda0dd 0%, #98d8c8 100%);
}

.memoria-memory-game[data-theme="artistes"] .memoria-card-front {
    background: linear-gradient(135deg, #e17055 0%, #fdcb6e 100%);
}

.memoria-memory-game[data-theme="artistes"] .memoria-card-back {
    background: linear-gradient(135deg, #00b894 0%, #00cec9 100%);
}

/* Thème Régions */
.memoria-memory-game[data-theme="regions"] {
    background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
}

.memoria-memory-game[data-theme="regions"] .memoria-card-front {
    background: linear-gradient(135deg, #00b894 0%, #00cec9 100%);
}

.memoria-memory-game[data-theme="regions"] .memoria-card-back {
    background: linear-gradient(135deg, #fd79a8 0%, #e84393 100%);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .memoria-memory-game {
        padding: 15px;
        margin: 10px;
    }
    
    .memoria-memory-board {
        gap: 10px;
        padding: 15px;
    }
    
    .memoria-memory-board.grid-4x2,
    .memoria-memory-board.grid-4x3,
    .memoria-memory-board.grid-4x4 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .memoria-memory-stats {
        flex-direction: column;
        gap: 10px;
    }
    
    .memoria-stat {
        min-width: auto;
    }
    
    .memoria-card-main {
        font-size: 20px;
    }
    
    .memoria-card-content[data-type="image"] .memoria-card-main {
        font-size: 28px;
    }
    
    .memoria-card-content[data-type="text"] .memoria-card-main {
        font-size: 12px;
    }
    
    .memoria-card-label {
        font-size: 10px;
    }
    
    .memoria-completion-message {
        margin: 20px;
        padding: 30px;
    }
    
    .memoria-completion-stats {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .memoria-memory-board.grid-4x2,
    .memoria-memory-board.grid-4x3,
    .memoria-memory-board.grid-4x4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .memoria-memory-title {
        font-size: 24px;
    }
    
    .memoria-btn {
        padding: 10px 20px;
        font-size: 12px;
        margin: 5px;
    }
}

/* ==========================================================================
   Accessibilité
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .memoria-card,
    .memoria-card-inner,
    .memoria-btn {
        transition: none;
    }
    
    .memoria-card:hover {
        transform: none;
    }
    
    .memoria-card.match-success,
    .memoria-card.match-fail {
        animation: none;
    }
    
    .memoria-completion-overlay,
    .memoria-completion-message {
        animation: none;
    }
}

/* Focus pour accessibilité clavier */
.memoria-card:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

.memoria-btn:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* ==========================================================================
   États de difficulté
   ========================================================================== */

.memoria-memory-game[data-difficulty="easy"] {
    filter: brightness(1.1);
}

.memoria-memory-game[data-difficulty="hard"] {
    filter: brightness(0.9);
}

.memoria-memory-game[data-difficulty="hard"] .memoria-card-inner {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Animations d'entrée
   ========================================================================== */

.memoria-card {
    animation: cardEntry 0.6s ease-out;
    animation-fill-mode: both;
}

.memoria-card:nth-child(1) { animation-delay: 0.1s; }
.memoria-card:nth-child(2) { animation-delay: 0.2s; }
.memoria-card:nth-child(3) { animation-delay: 0.3s; }
.memoria-card:nth-child(4) { animation-delay: 0.4s; }
.memoria-card:nth-child(5) { animation-delay: 0.5s; }
.memoria-card:nth-child(6) { animation-delay: 0.6s; }
.memoria-card:nth-child(7) { animation-delay: 0.7s; }
.memoria-card:nth-child(8) { animation-delay: 0.8s; }
.memoria-card:nth-child(9) { animation-delay: 0.9s; }
.memoria-card:nth-child(10) { animation-delay: 1.0s; }
.memoria-card:nth-child(11) { animation-delay: 1.1s; }
.memoria-card:nth-child(12) { animation-delay: 1.2s; }
.memoria-card:nth-child(13) { animation-delay: 1.3s; }
.memoria-card:nth-child(14) { animation-delay: 1.4s; }
.memoria-card:nth-child(15) { animation-delay: 1.5s; }
.memoria-card:nth-child(16) { animation-delay: 1.6s; }

@keyframes cardEntry {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ==========================================================================
   Tableau des scores
   ========================================================================== */

.memoria-score-table {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    text-align: center;
    animation: scoreTableEntry 0.5s ease-out;
}

.memoria-score-table h3 {
    font-size: 32px;
    color: #2c3e50;
    margin: 0 0 20px 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.memoria-score-global-status {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    padding: 10px 20px;
    margin-bottom: 20px;
    text-align: center;
    border: 1px solid #e9ecef;
}

.memoria-global-score-included {
    color: #28a745;
    font-weight: bold;
    font-size: 16px;
}

.memoria-global-score-excluded {
    color: #dc3545;
    font-weight: bold;
    font-size: 16px;
}

.memoria-score-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.memoria-score-item {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.memoria-score-item:hover {
    transform: translateY(-5px);
}

.memoria-score-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    opacity: 0.9;
}

.memoria-score-value {
    display: block;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.memoria-score-details {
    margin-top: 30px;
}

.memoria-score-breakdown {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.memoria-score-breakdown th,
.memoria-score-breakdown td {
    padding: 15px 20px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.memoria-score-breakdown th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.memoria-score-breakdown tbody tr:hover {
    background: rgba(102, 126, 234, 0.1);
}

.memoria-score-breakdown .total-row {
    background: rgba(102, 126, 234, 0.1);
    font-weight: bold;
}

.memoria-score-breakdown .total-row td {
    border-bottom: none;
    font-size: 16px;
}

@keyframes scoreTableEntry {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Responsive design pour le tableau des scores */
@media (max-width: 768px) {
    .memoria-score-summary {
        grid-template-columns: 1fr;
    }
    
    .memoria-score-item {
        padding: 15px;
    }
    
    .memoria-score-value {
        font-size: 20px;
    }
    
    .memoria-score-breakdown th,
    .memoria-score-breakdown td {
        padding: 12px 15px;
        font-size: 14px;
    }
}

/* ==========================================================================
   Nouveau tableau des scores détaillé
   ========================================================================== */

.memoria-detailed-stats {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 25px;
    margin: 20px 0;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.memoria-detailed-stats h4 {
    text-align: center;
    color: #2c3e50;
    margin: 0 0 20px 0;
    font-size: 20px;
    font-weight: 600;
}

.memoria-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.memoria-stat-item {
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.memoria-stat-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.memoria-stat-icon {
    font-size: 24px;
    margin-right: 12px;
    min-width: 30px;
    text-align: center;
}

.memoria-stat-content {
    flex: 1;
}

.memoria-stat-content .memoria-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
    opacity: 0.9;
    margin-bottom: 4px;
    color: rgba(255, 255, 255, 0.9);
}

.memoria-stat-content .memoria-stat-value {
    font-size: 18px;
    font-weight: bold;
    color: white;
}

.memoria-stat-value.memoria-highlight {
    color: #f1c40f;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    font-size: 22px;
}

.memoria-score-breakdown {
    background: rgba(52, 152, 219, 0.1);
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
}

.memoria-score-breakdown h5 {
    text-align: center;
    color: #2c3e50;
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
}

.memoria-breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(52, 152, 219, 0.2);
    font-size: 14px;
}

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

.memoria-breakdown-item.memoria-total {
    font-weight: bold;
    font-size: 16px;
    color: #2c3e50;
    border-top: 2px solid #3498db;
    border-bottom: none;
    padding-top: 15px;
    margin-top: 10px;
}

.memoria-simple-stats {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 15px;
    margin: 20px 0;
}

.memoria-simple-stats .memoria-stat {
    background: rgba(52, 152, 219, 0.1);
    padding: 15px 20px;
    border-radius: 12px;
    min-width: 120px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.2);
}

/* Animation d'entrée pour les statistiques */
.memoria-detailed-stats {
    animation: statsEntry 0.8s ease-out forwards;
}

@keyframes statsEntry {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.memoria-stat-item {
    animation: statItemEntry 0.6s ease-out forwards;
    opacity: 0;
    transform: translateX(-20px);
}

.memoria-stat-item:nth-child(1) { animation-delay: 0.1s; }
.memoria-stat-item:nth-child(2) { animation-delay: 0.2s; }
.memoria-stat-item:nth-child(3) { animation-delay: 0.3s; }
.memoria-stat-item:nth-child(4) { animation-delay: 0.4s; }
.memoria-stat-item:nth-child(5) { animation-delay: 0.5s; }
.memoria-stat-item:nth-child(6) { animation-delay: 0.6s; }

@keyframes statItemEntry {
    0% {
        opacity: 0;
        transform: translateX(-20px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Responsive pour le tableau détaillé */
@media (max-width: 768px) {
    .memoria-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .memoria-stat-item {
        padding: 12px;
    }
    
    .memoria-stat-icon {
        font-size: 20px;
        margin-right: 8px;
    }
    
    .memoria-stat-content .memoria-stat-value {
        font-size: 16px;
    }
    
    .memoria-breakdown-item {
        font-size: 13px;
        padding: 8px 0;
    }
}

@media (max-width: 480px) {
    .memoria-stats-grid {
        grid-template-columns: 1fr;
    }
    
    .memoria-detailed-stats {
        padding: 15px;
    }
    
    .memoria-score-breakdown {
        padding: 15px;
    }
}