/*
 * Coding Ireland proprietary interactive activity
 * Copyright (c) 2017-2026 Coding Ireland. All rights reserved.
 *
 * Part of the Coding Ireland online learning platform. Licensed for use only
 * as delivered on the platform. Copying, redistributing, or adapting this
 * file, in whole or in part, for use in any other product or service is not
 * permitted. Ref: CI-maths-memory-match
 */
/*
 * memory-match — face-down pairs game on a grid. Cards carry the
 * two halves of an equivalence (fraction ↔ decimal, fact ↔ product,
 * time ↔ duration, unit ↔ unit). Pattern source: MFL matching-pairs.
 * Single self-paced view (no teacher/student split — every pupil
 * plays their own game on their own device).
 */

/* See maths-bingo: class selectors with `display: flex|grid` beat
 * the browser default `[hidden] { display: none }`. Override once. */
.maths-activity [hidden] { display: none !important; }

.maths-activity .mm-stage {
    background: #fffaf0;
    border: 1px solid var(--maths-border, #e0e7ef);
    border-radius: 14px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px rgba(20, 40, 80, 0.05);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.maths-activity .mm-status-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.maths-activity .mm-score {
    background: #fff;
    border: 1px solid var(--maths-border, #e0e7ef);
    border-radius: 12px;
    padding: 0.5rem 0.875rem;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    font-family: 'Nunito', sans-serif;
}

.maths-activity .mm-score-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--maths-text-muted, #6b7280);
}

.maths-activity .mm-score-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--maths-primary-dark, #1b5e20);
    font-variant-numeric: tabular-nums;
}

.maths-activity .mm-board-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
}

.maths-activity .mm-board {
    display: grid;
    gap: 8px;
    background: #1b5e20;
    padding: 8px;
    border-radius: 12px;
    max-width: 100%;
}

/* Card with flip transform. Two faces stacked; rotateY toggles. */
.maths-activity .mm-card {
    position: relative;
    aspect-ratio: 3 / 4;
    perspective: 800px;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    min-width: 70px;
}

.maths-activity .mm-card-inner {
    position: absolute;
    inset: 0;
    transition: transform 320ms cubic-bezier(.4, 0, .2, 1);
    transform-style: preserve-3d;
}

.maths-activity .mm-card.mm-flipped .mm-card-inner,
.maths-activity .mm-card.mm-matched .mm-card-inner {
    transform: rotateY(180deg);
}

.maths-activity .mm-card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(0.95rem, 2.5vw, 1.4rem);
    text-align: center;
    line-height: 1.15;
    padding: 6px;
    font-variant-numeric: tabular-nums;
    user-select: none;
    word-break: break-word;
}

.maths-activity .mm-card-back {
    background: linear-gradient(135deg, #2E7D32, #1b5e20);
    color: #fff;
}

.maths-activity .mm-card-back i {
    font-size: 1.4rem;
    opacity: 0.85;
}

.maths-activity .mm-card-front {
    background: #fff;
    color: var(--maths-ink, #1F2933);
    border: 2px solid #cfd8dc;
    transform: rotateY(180deg);
}

.maths-activity .mm-card.mm-matched .mm-card-front {
    border-width: 3px;
    /* Pair colour is set inline via --mm-pair-colour. Falls back to green. */
    border-color: var(--mm-pair-colour, #66bb6a);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mm-pair-colour, #66bb6a) 25%, transparent);
}

.maths-activity .mm-card.mm-matched {
    cursor: default;
}

.maths-activity .mm-mode-chip {
    display: inline-block;
    background: var(--maths-primary, #2E7D32);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    margin-top: 0.25rem;
}

.maths-activity .mm-callout {
    border-radius: 14px;
    padding: 1rem 1.125rem;
    margin-top: 1rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 1.05rem;
}

.maths-activity .mm-callout.success {
    background: #fff8e1;
    color: #8d4e0b;
    border: 2px solid #f0c14b;
}

.maths-activity .mm-callout.miss {
    background: #ffebee;
    color: #b71c1c;
    border: 1px solid #ef5350;
}

.maths-activity .mm-your-turn {
    margin-top: 1.25rem;
    background: #f1f8e9;
    border: 1px solid #aed581;
    border-radius: 14px;
    padding: 1rem 1.25rem;
}

.maths-activity .mm-your-turn-label {
    font-weight: 800;
    color: #33691e;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.maths-activity .mm-your-turn-list { margin: 0; padding-left: 1.25rem; color: #1f2937; font-weight: 600; }
.maths-activity .mm-your-turn-list li { margin-bottom: 0.25rem; }

/* Display mode — pin the board, disable card flips. Hide the transient
 * callout and challenge runner; tighten the stage. Your-turn prompts
 * stay — those are display-only discussion prompts.
 */
body.display-mode .mm-callout,
body.display-mode #challengeRunner { display: none !important; }

body.display-mode .mm-card { cursor: default !important; pointer-events: none; }

body.display-mode .mm-stage {
    padding: 0.75rem;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}
