/**
 * Trivia Matching Game Styles
 *
 * @package AIML_Games_TriviaMatching
 * @since 1.0.0
 */

/* Game Stats */
.aiml-tm-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.aiml-tm-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 50px;
}

.aiml-tm-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: #1d1d1f;
}

.aiml-tm-stat-label {
    font-size: 11px;
    color: #86868b;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Cards Grid */
.aiml-tm-cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    max-width: 700px;
    margin: 0 auto;
    padding: 20px;
}

/* Card Styling */
.aiml-tm-card {
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    padding: 16px;
    height: 120px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.03);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.aiml-tm-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #0073aa, #00a0d2);
    opacity: 0;
    transition: opacity 0.25s;
}

.aiml-tm-card:hover::before {
    opacity: 1;
}

.aiml-tm-card-number {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #28a745, #34c759);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s ease;
}

.aiml-tm-card.aiml-tm-matched .aiml-tm-card-number {
    opacity: 1;
    transform: scale(1);
}

.aiml-tm-card:hover:not(.aiml-tm-matched):not(.aiml-tm-disabled) {
    border-color: rgba(0, 115, 170, 0.3);
    box-shadow: 0 8px 24px rgba(0, 115, 170, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

/* Card States */
.aiml-tm-card.aiml-tm-selected {
    border-color: #0073aa;
    background: linear-gradient(145deg, #e8f4fc 0%, #f0f7fc 100%);
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2), 0 4px 12px rgba(0, 115, 170, 0.1);
    transform: translateY(-1px);
}

.aiml-tm-card.aiml-tm-selected::before {
    opacity: 1;
}

.aiml-tm-card.aiml-tm-matched {
    border-color: #28a745;
    background: linear-gradient(145deg, #f0fff4 0%, #e8f5e9 100%);
    cursor: default;
    opacity: 0.85;
}

.aiml-tm-card.aiml-tm-matched::before {
    background: linear-gradient(90deg, #28a745, #34c759);
    opacity: 1;
}

.aiml-tm-card.aiml-tm-revealed {
    border-color: #ff9500;
    background: linear-gradient(145deg, #fff9f0 0%, #fff3e0 100%);
    cursor: default;
    opacity: 0.85;
}

.aiml-tm-card.aiml-tm-revealed::before {
    background: linear-gradient(90deg, #ff9500, #ffb340);
    opacity: 1;
}

.aiml-tm-card.aiml-tm-revealed .aiml-tm-card-number {
    background: linear-gradient(135deg, #ff9500, #e68900);
    opacity: 1;
    transform: scale(1);
}

.aiml-tm-card.aiml-tm-error {
    border-color: #ff3b30;
    background: linear-gradient(145deg, #fff5f5 0%, #ffebee 100%);
    animation: shake 0.4s ease-in-out;
}

.aiml-tm-card.aiml-tm-error::before {
    background: linear-gradient(90deg, #ff3b30, #ff6b6b);
    opacity: 1;
}

.aiml-tm-card.aiml-tm-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.aiml-tm-card.aiml-tm-name {
    font-weight: 700;
    font-size: 1.15em;
    color: #1d1d1f;
    background: linear-gradient(145deg, #ffffff 0%, #f5f5f7 100%);
}

.aiml-tm-card.aiml-tm-prompt {
    font-style: italic;
    color: #424245;
    background: linear-gradient(145deg, #fafafa 0%, #f0f0f2 100%);
}

.aiml-tm-card-prompt,
.aiml-tm-card-name {
    padding: 2px;
    width: 100%;
}

/* No words message */
.aiml-tm-no-words {
    grid-column: 1 / -1;
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-size: 16px;
}

.aiml-tm-no-words p {
    margin: 0;
}

/* Loading state */
.aiml-tm-loading {
    grid-column: 1 / -1;
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-size: 16px;
}

/* Image Card Styles */
.aiml-tm-card-has-image {
    padding: 8px;
}

.aiml-tm-card-image-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
}

.aiml-tm-card-image {
    max-width: 100%;
    max-height: 70px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
}

.aiml-tm-card-fallback-text {
    display: none;
    font-style: italic;
    color: #555;
    text-align: center;
    font-size: 13px;
    line-height: 1.3;
    word-break: break-word;
}

.aiml-tm-card-fallback-text.aiml-tm-visible {
    display: block;
}

/* Shake Animation */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

/* Hint Button Styles */
.aiml-tm-hint-stat {
    margin-left: auto;
}

.aiml-tm-hint-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(145deg, #fff9e6 0%, #fff3cd 100%);
    border: 1px solid rgba(255, 193, 7, 0.4);
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #856404;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(255, 193, 7, 0.15);
}

.aiml-tm-hint-btn:hover {
    background: linear-gradient(145deg, #ffecb3 0%, #ffd54f 100%);
    border-color: rgba(255, 193, 7, 0.6);
    box-shadow: 0 4px 8px rgba(255, 193, 7, 0.25);
    transform: translateY(-1px);
}

.aiml-tm-hint-btn:active {
    transform: translateY(0);
}

.aiml-tm-hint-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.aiml-tm-hint-icon {
    font-size: 16px;
}

.aiml-tm-hint-text {
    white-space: nowrap;
}

/* Hint Flash Animation */
.aiml-tm-card.aiml-tm-hint {
    border-color: #ff9500 !important;
    background: linear-gradient(145deg, #fff8e1 0%, #ffecb3 100%) !important;
    box-shadow: 0 0 16px rgba(255, 149, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    animation: hintPulse 0.5s ease-in-out infinite;
}

.aiml-tm-card.aiml-tm-hint::before {
    background: linear-gradient(90deg, #ff9500, #ffb340) !important;
    opacity: 1 !important;
}

@keyframes hintPulse {
    0%, 100% {
        box-shadow: 0 0 16px rgba(255, 149, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.1);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 24px rgba(255, 149, 0, 0.6), 0 6px 16px rgba(0, 0, 0, 0.15);
        transform: scale(1.01);
    }
}

/* Responsive Styles */
@media (max-width: 600px) {
    .aiml-tm-cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 12px;
    }

    .aiml-tm-card {
        height: 100px;
        padding: 10px;
        font-size: 12px;
    }

    .aiml-tm-card-image {
        max-height: 55px;
    }

    .aiml-tm-stats {
        gap: 12px;
        padding: 10px;
    }

    .aiml-tm-stat-value {
        font-size: 20px;
    }
}

@media (max-width: 400px) {
    .aiml-tm-cards-grid {
        grid-template-columns: 1fr;
    }

    .aiml-tm-card {
        height: 80px;
    }
}
