/**
 * Match Activity Styles
 * Mode séquentiel : une image à la fois avec choix multiples
 * Mobile-first design
 *
 * @package Crowdaa_Challenges_Calendar
 * @since 4.12.313
 * @updated 4.12.314 - Refonte UX mobile (mode séquentiel)
 * @updated 4.12.319 - Carousel récap avec contextes
 */

/* ========== CONTAINER ========== */

.match-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 16px;
}

/* ========== HEADER ========== */

.match-header {
    text-align: center;
    margin-bottom: 20px;
}

.match-header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-radius: 16px;
    margin-bottom: 12px;
    color: white;
}

.match-title {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 6px 0;
}

.match-subtitle {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}

/* ========== PROGRESS BAR ========== */

.match-progress {
    margin-bottom: 20px;
}

.match-progress-bar {
    background: #e5e7eb;
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 12px;
}

.match-progress-fill {
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    height: 100%;
    border-radius: 10px;
    transition: width 0.4s ease;
}

.match-progress-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.match-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.match-stat svg {
    color: #3b82f6;
}

.match-stat-timer {
    color: #1e40af;
}

.match-stat-timer svg {
    color: #1e40af;
}

#match-timer {
    font-family: 'SF Mono', 'Monaco', monospace;
}

#match-timer.warning {
    color: #dc2626;
    animation: timerPulse 1s ease infinite;
}

@keyframes timerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.match-stat-errors {
    color: #dc2626;
}

.match-stat-errors svg {
    color: #dc2626;
}

/* ========== GAME AREA ========== */

.match-game-area {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ========== CURRENT IMAGE ========== */

.match-current-image {
    text-align: center;
}

.match-image-wrapper {
    position: relative;
    background: white;
    border: 3px solid #e5e7eb;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

.match-image-wrapper img {
    display: block;
    width: 100%;
    max-height: 250px;
    object-fit: contain;
    background: #f9fafb;
}

.match-image-wrapper.loading {
    opacity: 0.7;
    position: relative;
}

.match-image-wrapper.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: matchSpinner 0.8s linear infinite;
    z-index: 10;
}

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

.match-image-wrapper.loaded {
    animation: imageAppear 0.3s ease;
}

@keyframes imageAppear {
    0% { opacity: 0.5; transform: scale(0.98); }
    100% { opacity: 1; transform: scale(1); }
}

.match-image-wrapper.success {
    border-color: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2);
}

.match-image-wrapper.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2);
    animation: shakeImage 0.4s ease;
}

@keyframes shakeImage {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.match-image-label {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
}

/* ========== MESSAGE FEEDBACK ========== */

.match-message {
    display: none;
    padding: 12px 16px;
    border-radius: 10px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
}

.match-message.success {
    display: block;
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    color: #166534;
}

.match-message.error {
    display: block;
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #dc2626;
}

.match-message.info {
    display: block;
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #1e40af;
}

/* ========== CHOICES ========== */

.match-choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.match-choice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 16px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    color: #374151;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.match-choice:hover:not(.matched):not(.disabled) {
    border-color: #93c5fd;
    background: #f0f9ff;
}

.match-choice:active:not(.matched):not(.disabled) {
    transform: scale(0.98);
}

.match-choice-text {
    flex: 1;
    line-height: 1.4;
}

.match-choice-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 12px;
}

/* Choice states */
.match-choice.matched.correct {
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    border-color: #22c55e;
    color: #166534;
    cursor: default;
    pointer-events: none;
}

.match-choice.matched.correct .match-choice-icon svg {
    stroke: #22c55e;
}

.match-choice.error {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    border-color: #ef4444;
    color: #dc2626;
    animation: shakeChoice 0.4s ease;
}

@keyframes shakeChoice {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

.match-choice.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ========== SCORING INFO ========== */

.match-scoring-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #f3f4f6;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 12px;
    color: #6b7280;
    margin-top: 16px;
}

.match-scoring-info svg {
    flex-shrink: 0;
    color: #9ca3af;
}

/* ========== COMPLETED STATE ========== */

.match-completed {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-radius: 16px;
}

/* Results header */
.match-container.match-completed .results-header {
    margin-bottom: 24px;
    text-align: center;
}

.match-container.match-completed .results-header h3 {
    font-size: 22px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

/* Results icon - triple sélecteur pour écraser tous les contextes */
.match-container .results-icon,
.match-container .match-results-icon,
.crowdaa-modal .match-container .results-icon,
.crowdaa-modal .match-container .match-results-icon,
.quiz-completed-results .match-container .results-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-radius: 50%;
    margin-bottom: 16px;
    color: white;
    font-size: 0;
    animation: none;
}

.match-container .results-icon svg,
.match-container .match-results-icon svg,
.crowdaa-modal .match-container .results-icon svg {
    width: 48px;
    height: 48px;
    stroke: white;
}

/* Results stats */
.match-container .results-stats,
.match-container .match-results-stats,
.crowdaa-modal .match-container .results-stats {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.match-container .result-card,
.crowdaa-modal .match-container .result-card {
    background: white;
    border-radius: 16px;
    padding: 16px 20px;
    text-align: center;
    border: 2px solid #93c5fd;
    min-width: 90px;
}

.match-container .result-card .result-icon,
.crowdaa-modal .match-container .result-card .result-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    margin-bottom: 10px;
    color: #3b82f6;
}

.match-container .result-card .result-icon svg,
.crowdaa-modal .match-container .result-card .result-icon svg {
    width: 22px;
    height: 22px;
    stroke: #3b82f6;
}

.match-container .result-card .result-value,
.crowdaa-modal .match-container .result-card .result-value {
    font-size: 24px;
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 4px;
}

.match-container .result-card .result-label,
.crowdaa-modal .match-container .result-card .result-label {
    font-size: 12px;
    color: #6b7280;
}

/* Completion message */
.match-container .completion-message,
.crowdaa-modal .match-container .completion-message {
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

.match-container .completion-message p,
.crowdaa-modal .match-container .completion-message p {
    margin: 0;
}

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

@media (min-width: 480px) {
    .match-container {
        padding: 20px;
    }

    .match-image-wrapper img {
        max-height: 300px;
    }

    .match-choice {
        padding: 16px 20px;
    }
}

/* ========== TOUCH DEVICES ========== */

@media (hover: none), (pointer: coarse) {
    .match-choice:hover:not(.matched):not(.disabled) {
        border-color: #e5e7eb;
        background: white;
    }

    .match-choice:active:not(.matched):not(.disabled) {
        border-color: #93c5fd;
        background: #f0f9ff;
        transform: scale(0.98);
    }
}

/* ========== CAROUSEL RECAP ========== */

.match-recap-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid rgba(59, 130, 246, 0.2);
}

.match-recap-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #1e40af;
    margin-bottom: 16px;
}

.match-recap-header svg {
    color: #3b82f6;
}

/* Carousel container */
.match-carousel {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    background: white;
    border: 2px solid #93c5fd;
}

/* Track (slides wrapper) */
.match-carousel-track {
    display: flex;
    transition: transform 0.3s ease-out;
    touch-action: pan-y pinch-zoom;
}

/* Individual slide */
.match-carousel-slide {
    flex: 0 0 100%;
    min-width: 100%;
    display: flex;
    flex-direction: column;
}

/* Slide image */
.match-carousel-image {
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: #f8fafc;
    position: relative;
}

/* Loader pour images carousel */
.match-carousel-image::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: matchSpinner 0.8s linear infinite;
    z-index: 1;
}

.match-carousel-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: relative;
    z-index: 2;
    background: #f8fafc;
}

/* Slide content */
.match-carousel-content {
    padding: 16px;
    text-align: center;
}

.match-carousel-title {
    font-size: 16px;
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 8px;
    line-height: 1.3;
}

.match-carousel-context {
    font-size: 13px;
    color: #4b5563;
    line-height: 1.5;
}

/* Navigation buttons */
.match-carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #3b82f6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    z-index: 10;
}

.match-carousel-nav:hover {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.match-carousel-nav:active {
    transform: translateY(-50%) scale(0.95);
}

.match-carousel-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.match-carousel-prev {
    left: 8px;
}

.match-carousel-next {
    right: 8px;
}

/* Indicators (dots) */
.match-carousel-indicators {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    background: #f8fafc;
    border-top: 1px solid #e5e7eb;
    flex-wrap: wrap;
}

.match-carousel-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    max-width: 8px;
    max-height: 8px;
    min-width: 8px;
    min-height: 8px;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 50%;
    background: #cbd5e1;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.match-carousel-dot:hover {
    background: #94a3b8;
}

.match-carousel-dot.active {
    background: #3b82f6;
    transform: scale(1.2);
}

/* Counter */
.match-carousel-counter {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    z-index: 10;
}

/* Smaller dots on many slides */
.match-carousel-indicators.many-slides .match-carousel-dot {
    width: 6px;
    height: 6px;
    max-width: 6px;
    max-height: 6px;
    min-width: 6px;
    min-height: 6px;
}

/* Swipe hint on mobile */
@media (hover: none), (pointer: coarse) {
    .match-carousel-nav {
        width: 36px;
        height: 36px;
    }

    .match-carousel-prev {
        left: 4px;
    }

    .match-carousel-next {
        right: 4px;
    }
}

/* Larger screens */
@media (min-width: 480px) {
    .match-carousel-image {
        height: 220px;
    }

    .match-carousel-content {
        padding: 20px;
    }

    .match-carousel-title {
        font-size: 18px;
    }

    .match-carousel-context {
        font-size: 14px;
    }
}
