/*
 * maths-bingo — three views.
 *   - Teacher view (caller card + prev/next nav + called-prompts sidebar).
 *   - Student view (this player's seeded bingo card + BINGO button).
 *   - Snapshot view (display mode — editorial / dashboard anchor).
 * Role split mirrors MFL bingo. Per-user role detection happens via
 * the parent page's hidden #activityUserRole field.
 */

/* The view containers below set display:flex / grid, which would beat the
 * browser's default `[hidden] { display: none }` on specificity. Override
 * once so the JS can hide / show views with the `hidden` attribute. */
.maths-activity [hidden] { display: none !important; }

/* ----- Start overlay ----- */
.maths-activity .mb-start-overlay {
    position: relative;
    background: linear-gradient(180deg, #ffffff, #fffaf0);
    border: 1px solid var(--maths-border, #e0e7ef);
    border-radius: 14px;
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(20, 40, 80, 0.05);
    margin-bottom: 1rem;
}

.maths-activity .mb-start-icon {
    font-size: 3rem;
    color: var(--maths-primary, #2E7D32);
    margin-bottom: 0.5rem;
}

.maths-activity .mb-start-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    color: var(--maths-primary-dark, #1b5e20);
    margin-bottom: 0.5rem;
}

.maths-activity .mb-start-text {
    color: var(--maths-text, #1f2937);
    font-weight: 600;
    margin-bottom: 1.25rem;
}

.maths-activity .mb-start-btn { font-size: 1.1rem; padding: 0.75rem 1.75rem; }

/* ----- Mode chip ----- */
.maths-activity .mb-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;
}

/* ----- Teacher view ----- */
.maths-activity .mb-teacher-view {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 1rem;
    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);
}

.maths-activity .mb-caller-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.maths-activity .mb-caller-card {
    width: 100%;
    background: var(--maths-primary, #2E7D32);
    color: #fff;
    border-radius: 18px;
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: 0 4px 16px rgba(20, 40, 80, 0.12);
}

.maths-activity .mb-caller-eyebrow {
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.85;
    margin-bottom: 0.75rem;
}

.maths-activity .mb-caller-question {
    font-family: 'Nunito', sans-serif;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 800;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    margin-bottom: 0.75rem;
}

.maths-activity .mb-caller-answers {
    margin-top: 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.maths-activity .mb-caller-answers-label {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.85;
    margin-right: 0.4rem;
}

.maths-activity .mb-answer-chip {
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
    font-variant-numeric: tabular-nums;
}

.maths-activity .mb-caller-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.maths-activity .mb-nav-btn {
    background: #fff;
    border: 2px solid var(--maths-border, #e0e7ef);
    color: var(--maths-primary-dark, #1b5e20);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.maths-activity .mb-nav-btn:hover:not(:disabled) {
    background: #fff8e1;
    border-color: #f0c14b;
}

.maths-activity .mb-nav-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.maths-activity .mb-caller-counter {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--maths-text, #1f2937);
    min-width: 80px;
    text-align: center;
}

.maths-activity .mb-show-answers-toggle {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--maths-text-muted, #6b7280);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}

.maths-activity .mb-end-round-btn {
    margin-top: 0.75rem;
    padding: 0.6rem 1.2rem;
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    background: var(--maths-primary-dark, #1b5e20);
    border: 2px solid var(--maths-primary-dark, #1b5e20);
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: background-color 0.15s ease, transform 0.05s ease;
}

.maths-activity .mb-end-round-btn:hover {
    background: #14491a;
}

.maths-activity .mb-end-round-btn:active {
    transform: translateY(1px);
}

.maths-activity .mb-called-sidebar {
    background: #fff;
    border: 1px solid var(--maths-border, #e0e7ef);
    border-radius: 12px;
    padding: 0.875rem;
    box-shadow: 0 2px 8px rgba(20, 40, 80, 0.04);
    max-height: 480px;
    overflow-y: auto;
}

.maths-activity .mb-called-sidebar h4 {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--maths-primary-dark, #1b5e20);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 0.625rem 0;
}

.maths-activity .mb-called-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.maths-activity .mb-called-badge {
    background: #fff8e1;
    border: 1px solid #f0c14b;
    border-radius: 8px;
    padding: 0.3rem 0.55rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #4e342e;
    font-size: 0.95rem;
}

.maths-activity .mb-called-badge.mb-called-current {
    background: var(--maths-primary, #2E7D32);
    border-color: var(--maths-primary-dark, #1b5e20);
    color: #fff;
}

@media (max-width: 720px) {
    .maths-activity .mb-teacher-view {
        grid-template-columns: 1fr;
    }
    .maths-activity .mb-called-sidebar { max-height: 200px; }
}

/* ----- Student view ----- */
.maths-activity .mb-student-view {
    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 .mb-bingo-btn-row {
    display: flex;
    justify-content: center;
}

.maths-activity .mb-bingo-btn {
    font-size: 1.4rem;
    padding: 1rem 2.5rem;
    background: #d84315;
    color: #fff;
    border-radius: 14px;
    border: none;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(216, 67, 21, 0.3);
}

.maths-activity .mb-bingo-btn:hover:not(:disabled) {
    background: #bf360c;
}

.maths-activity .mb-bingo-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* ----- Snapshot view (display mode) ----- */
.maths-activity .mb-snapshot-view {
    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 .mb-snapshot-prompt {
    background: var(--maths-primary, #2E7D32);
    color: #fff;
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.maths-activity .mb-snapshot-eyebrow {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.85;
}

.maths-activity .mb-snapshot-question {
    font-family: 'Nunito', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

/* ----- Card (shared by student + snapshot views) ----- */
.maths-activity .mb-card-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
}

.maths-activity .mb-card {
    display: grid;
    gap: 6px;
    background: #1b5e20;
    padding: 6px;
    border-radius: 10px;
}

.maths-activity .mb-cell {
    background: #fff;
    border: none;
    border-radius: 6px;
    padding: 4px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(1rem, 3vw, 1.5rem);
    color: var(--maths-text, #1f2937);
    cursor: pointer;
    user-select: none;
    transition: background-color 120ms ease-out, color 120ms ease-out, transform 120ms ease-out;
    font-variant-numeric: tabular-nums;
    text-align: center;
    line-height: 1.1;
}

.maths-activity .mb-cell:hover { background: #fff8e1; }

.maths-activity .mb-cell.mb-marked {
    background: #d84315;
    color: #fff;
    transform: scale(0.96);
}

.maths-activity .mb-cell.mb-marked:hover { background: #bf360c; }

.maths-activity .mb-cell.mb-free {
    background: #fbc02d;
    color: #1f2937;
    cursor: default;
}

.maths-activity .mb-cell.mb-free.mb-marked { background: #f9a825; }

/* Snapshot cells aren't buttons — strip interactive affordances */
.maths-activity .mb-snapshot-view .mb-cell { cursor: default; pointer-events: none; }

/* ----- Celebration overlay ----- */
.maths-activity .mb-celebration {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
}

.maths-activity .mb-celebration-content {
    background: #fff;
    border-radius: 18px;
    padding: 2rem 2.5rem;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    max-width: 480px;
}

.maths-activity .mb-celebration-icon {
    font-size: 4rem;
    color: #f9a825;
    margin-bottom: 0.5rem;
}

.maths-activity .mb-celebration-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 3rem;
    color: var(--maths-primary-dark, #1b5e20);
    margin: 0 0 0.5rem 0;
}

.maths-activity .mb-celebration-text {
    font-weight: 700;
    color: var(--maths-text, #1f2937);
    margin-bottom: 1.25rem;
}

/* ----- Display mode (snapshot view) -----
 * The widget renders its own .mb-snapshot-view in display mode (see
 * maths-bingo.js renderSnapshot). Lock cells, hide the challenge runner,
 * and tighten the card so a snapshot doesn't dominate the lesson page.
 */
body.display-mode #challengeRunner { display: none !important; }

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

body.display-mode .mb-snapshot-view {
    padding: 0.5rem;
    gap: 0.6rem;
}

body.display-mode .mb-card {
    max-width: 320px;
}
