/* =================================================================
   AUDIO MATCH MODULE STYLES
   Version 4.0 - November 2025
   Updated with loading states to prevent answer reveal
   ================================================================= */

.module-match-sound {
    animation: fadeIn 0.3s ease;
}

.matching-container-sound {
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: relative;
    min-height: 400px;
    margin: 24px 0;
    align-items: center;
}

.pictures-row {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: nowrap;
}

.pictures-row .item {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 110px;
    height: 165px;
    position: relative;
}

.pictures-row .item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.pictures-row .item img,
.pictures-row .item video {
    width: 90%;
    height: 90%;
    object-fit: contain;
    object-position: center;
    border-radius: 4px;
    transition: opacity 0.3s ease;
}

.pictures-row .item.matched {
    opacity: 0.5;
    pointer-events: none;
}

.pictures-row .item .dot {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    transition: all 0.2s;
}

.pictures-row .item .dot.selected {
    background: var(--primary);
    border-color: var(--primary);
}

.pictures-row .item .dot.matched {
    background: var(--success);
    border-color: var(--success);
}

/* =================================================================
   LOADING STATE - Prevents answer reveal during image load
   ================================================================= */

.pictures-row .item.loading {
    pointer-events: none; /* Prevent clicks while loading */
}

.pictures-row .item.loading img,
.pictures-row .item.loading video {
    opacity: 0; /* Hide image/video until loaded */
}

.pictures-row .item.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Error state for failed image loads */
.pictures-row .item.load-error {
    background: var(--bg-secondary);
}

.pictures-row .item.load-error img,
.pictures-row .item.load-error video {
    opacity: 0.3;
}

.pictures-row .item.load-error::after {
    content: '?';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    color: var(--text-secondary);
    opacity: 0.5;
}

/* =================================================================
   AUDIO SECTION
   ================================================================= */

.audio-section {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 24px 0;
}

.audio-speaker-big {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.audio-speaker-big i {
    font-size: 48px;
    color: white;
}

.audio-speaker-big:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 20px -5px rgba(79, 70, 229, 0.4);
}

.audio-speaker-big .dot {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 16px;
    height: 16px;
    background: white;
    border: 3px solid var(--primary);
    border-radius: 50%;
    transition: all 0.2s;
}

.audio-speaker-big .dot.selected {
    background: var(--success);
    border-color: var(--success);
}

/* Picture-only mode (single large picture without dot) */
.picture-only {
    cursor: default !important;
    min-height: 300px;
    min-width: 300px;
    background: var(--bg-primary) !important;
    border-radius: 12px !important;
    border: 2px solid var(--border-color) !important;
    box-shadow: var(--shadow-md) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.picture-only:hover {
    transform: none !important;
    box-shadow: var(--shadow-md) !important;
}

.audio-section .picture-only {
    padding: 20px;
}

.picture-only img,
.picture-only video {
    border-radius: 8px;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

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

body.mobile-phone .pictures-row {
    flex-wrap: wrap;
    gap: 12px;
}

body.mobile-phone .pictures-row .item {
    width: 90px;
    height: 135px;
    flex: 0 0 calc(50% - 6px);
}

body.mobile-phone .audio-speaker-big {
    width: 100px;
    height: 100px;
}

body.mobile-phone .audio-speaker-big i {
    font-size: 40px;
}

body.mobile-phone .picture-only {
    min-height: 200px;
    min-width: 200px;
}

/* Smaller loading spinner on mobile */
body.mobile-phone .pictures-row .item.loading::before {
    width: 30px;
    height: 30px;
    border-width: 2px;
}

body.mobile-tablet .pictures-row {
    gap: 16px;
}

body.mobile-tablet .pictures-row .item {
    width: 100px;
    height: 150px;
}

body.mobile-tablet.landscape .pictures-row {
    flex-wrap: nowrap;
}

body.touch-device .dot {
    width: 20px;
    height: 20px;
}

body.touch-device .pictures-row .item .dot {
    width: 20px;
    height: 20px;
}

@media (max-width: 968px) {
    .pictures-row {
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .picture-only {
        min-height: 200px;
        min-width: 200px;
    }
}