/*
 * 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-equal-groups
 */
/*
 * equal-groups activity styles.
 *
 * Layout: dividend pool at the top (counters waiting to be shared);
 * group circles below (where counters land); readouts panel to the
 * right; optional repeated-subtraction tally below.
 *
 * Counter visual: small coloured disc. When a counter is "broken
 * into tenths" in decimal-remainder mode, it visually splits into
 * ten thin slivers within a smaller disc.
 */

.eg-mode-chip {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    background: var(--maths-surface-alt);
    color: var(--maths-primary-dark);
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.eg-target-label {
    font-weight: 800;
    color: #8a5a00;
    font-size: 0.95rem;
    margin-right: 0.5rem;
}

.eg-target-prompt {
    flex: 1 1 auto;
    color: #6b4500;
    font-weight: 700;
    font-size: 1rem;
}

.eg-controls {
    background: var(--maths-surface);
    border: 1px solid var(--maths-border);
    border-radius: 12px;
    padding: 0.9rem 1.1rem;
    margin-bottom: 1rem;
}

.eg-control-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.9rem;
    font-size: 1.05rem;
}

.eg-control-label {
    font-weight: 700;
    color: var(--maths-ink);
}

.eg-stepper {
    display: inline-flex;
    align-items: stretch;
    border: 2px solid var(--maths-border);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

.eg-step-btn {
    min-width: 44px;
    min-height: 44px;
    border: 0;
    background: var(--maths-surface-alt);
    color: var(--maths-primary-dark);
    font-weight: 800;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.4rem;
}

.eg-step-btn:hover { background: var(--maths-surface); }
.eg-step-btn:active { background: var(--maths-primary); color: #fff; }

.eg-step-value {
    min-width: 3.6rem;
    min-height: 44px;
    border: 0;
    border-left: 1px solid var(--maths-border);
    border-right: 1px solid var(--maths-border);
    background: #fff;
    color: var(--maths-primary-dark);
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1.4rem;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    padding: 0 0.6rem;
}

.eg-step-value:hover { background: var(--maths-surface-alt); }

.eg-group-chips {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.eg-group-chip {
    min-width: 2.6rem;
    min-height: 2.6rem;
    padding: 0.25rem 0.55rem;
    background: var(--maths-surface);
    border: 2px solid var(--maths-border);
    border-radius: 8px;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--maths-primary-dark);
    cursor: pointer;
    transition: background-color 140ms ease, transform 80ms ease;
}

.eg-group-chip:hover { background: var(--maths-surface-alt); }
.eg-group-chip:active { transform: scale(0.96); }
.eg-group-chip.is-active {
    background: var(--maths-primary);
    color: #fff;
    border-color: var(--maths-primary-dark);
}

.eg-equation {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--maths-primary-dark);
    padding: 0.25rem 0.85rem;
    background: var(--maths-surface-alt);
    border-radius: 8px;
    font-variant-numeric: tabular-nums;
    margin-left: auto;
}

.eg-stage {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 1rem;
    align-items: start;
}

.eg-pool-wrap,
.eg-groups-wrap {
    background: var(--maths-surface);
    border: 1px solid var(--maths-border);
    border-radius: 12px;
    padding: 0.85rem 1rem;
}

.eg-pool-label,
.eg-groups-label {
    font-weight: 800;
    color: var(--maths-primary-dark);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.eg-pool-wrap {
    grid-column: 1;
}

.eg-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    min-height: 80px;
    padding: 0.6rem;
    background: #FAF8F0;
    border: 2px dashed #E5D9B6;
    border-radius: 10px;
}

.eg-groups-wrap {
    grid-column: 1;
}

.eg-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.5rem;
}

/* Only added while a click will actually deal a counter (pupil mode, pool not
   empty) — see renderGroups. An affordance that does nothing sent two QA
   testers hunting for a drag that never existed; don't repeat that. */
.eg-group.is-droppable {
    cursor: pointer;
}
.eg-group.is-droppable:hover,
.eg-group.is-droppable:focus-visible {
    border-color: var(--maths-primary);
    border-style: solid;
    outline: none;
}

.eg-group {
    background: var(--maths-surface-alt);
    border: 2px dashed var(--maths-border);
    border-radius: 10px;
    padding: 0.55rem;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    position: relative;
}

.eg-group-label {
    font-weight: 700;
    color: var(--maths-ink-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.eg-group-counters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    flex: 1 1 auto;
}

.eg-group-count {
    position: absolute;
    top: 0.45rem;
    right: 0.55rem;
    font-weight: 800;
    color: var(--maths-primary-dark);
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
}

.eg-counter {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--maths-primary);
    border: 2px solid var(--maths-primary-dark);
    transition: transform 200ms ease;
    /* No `cursor: grab` — counters are not draggable. Sharing is driven by the
       "Deal one" / "Deal all" buttons; there are no drag handlers in the JS, and
       promising a grab that does nothing sent two QA testers hunting for it. */
}

.eg-counter.is-pool { background: #E86A33; border-color: #BA4C1A; }

.eg-counter.is-leftover {
    background: #B04A3F;
    border-color: #7a1f17;
}

.eg-counter.is-tenth {
    background: linear-gradient(to right,
        #E86A33 0%, #E86A33 10%, #F0c14b 10%, #F0c14b 20%,
        #E86A33 20%, #E86A33 30%, #F0c14b 30%, #F0c14b 40%,
        #E86A33 40%, #E86A33 50%, #F0c14b 50%, #F0c14b 60%,
        #E86A33 60%, #E86A33 70%, #F0c14b 70%, #F0c14b 80%,
        #E86A33 80%, #E86A33 90%, #F0c14b 90%, #F0c14b 100%);
    width: 24px;
    height: 24px;
    border-color: #BA4C1A;
}

.eg-readouts {
    grid-column: 2;
    grid-row: 1 / 3;
    background: var(--maths-surface);
    border: 1px solid var(--maths-border);
    border-radius: 12px;
    padding: 0.9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.eg-readout {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.eg-readout-label {
    font-weight: 700;
    color: var(--maths-ink-muted);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.eg-readout-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--maths-primary-dark);
    font-variant-numeric: tabular-nums;
}

.eg-group-count {
    font-size: 1.3rem !important;
}

.eg-subtraction {
    margin-top: 1rem;
    background: var(--maths-surface);
    border: 1px solid var(--maths-border);
    border-radius: 12px;
    padding: 0.9rem 1.1rem;
}

.eg-subtraction[hidden] { display: none; }

/* "Subtraction view" is a toggle, and the panel it opens is the last block on
 * the page — embedded in a lesson that reveal can sit below the fixed iframe
 * edge, so the button looked dead to two QA passes. Give the button an "on"
 * state so pressing it always changes something in the eye line. ID + attribute
 * beats `.maths-activity .btn-control`, so no !important needed. */
#repeatedToggle[aria-pressed="true"] {
    background: var(--maths-primary);
    border-color: var(--maths-primary-dark);
    color: #fff;
}

.eg-subtraction-title {
    font-weight: 800;
    color: var(--maths-primary-dark);
    margin-bottom: 0.5rem;
}

.eg-subtraction-body {
    font-family: 'Nunito', monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--maths-ink);
    white-space: pre;
    font-size: 1rem;
    line-height: 1.4;
}

.eg-your-turn {
    background: #FFF7DE;
    border: 1px solid #F0C14B;
    border-radius: 12px;
    padding: 0.9rem 1.1rem;
    margin-top: 1rem;
}

.eg-your-turn-label {
    font-weight: 800;
    color: #8a5a00;
    margin-bottom: 0.4rem;
}

.eg-your-turn-list {
    margin: 0;
    padding-left: 1.2rem;
    color: #5e3c00;
    font-weight: 600;
}

/* A display snapshot is a finished, read-only picture: Deal one, Subtraction
 * view, Break remainder and Reset have nothing to do on it, and Fullscreen is
 * dead too because of the pointer-events rule below. Leaving all five on screen
 * meant a row of ordinary-looking buttons that silently swallowed every click,
 * which is how a QA pass came to report a step of three snapshots as
 * "activities aren't working". Hide the row instead of disabling it: never
 * advertise an affordance that does nothing — the same rule the group circles
 * already follow (see .eg-group.is-droppable). */
body.display-mode .controls-container { display: none; }

body.display-mode .btn-control {
    pointer-events: none;
}

body.display-mode .eg-step-btn { display: none; }
body.display-mode .eg-step-value {
    background: transparent;
    border: 0;
    cursor: default;
    pointer-events: none;
}
body.display-mode .eg-group-chip { pointer-events: none; }
body.display-mode .eg-group-chip:not(.is-active) { display: none; }

/* Display snapshots preset the counters, so the dashed pool / group boxes
 * should hug their contents instead of holding the interactive floor. */
body.display-mode .eg-pool,
body.display-mode .eg-group { min-height: 0; }

/* Bus-stop bracket — Irish primary long-division notation. The
 * dividend sits to the right of a vertical pipe, with a horizontal
 * bar overhead carrying the quotient digits. Working steps render
 * below when the teacher toggles "Working". */

.eg-busstop {
    margin-top: 1rem;
    background: #FFFDF6;
    border: 1px solid #E5D9B6;
    border-radius: 12px;
    padding: 0.9rem 1.1rem;
}

.eg-busstop[hidden] { display: none; }

.eg-busstop-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.7rem;
}

.eg-busstop-title {
    font-weight: 800;
    color: #8a5a00;
    font-size: 1.1rem;
    flex: 1 1 auto;
}

.eg-busstop-stage {
    font-family: 'Nunito', sans-serif;
    font-variant-numeric: tabular-nums;
    color: var(--maths-primary-dark);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.eg-bs-quotient,
.eg-bs-row {
    display: inline-flex;
    align-items: center;
}

.eg-bs-quotient {
    /* The quotient digits sit on top of a 4px black bar (top border of
     * the bracket row below). We mirror the divisor + pipe width here
     * so digits land directly above their dividend digits. */
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1;
    min-height: 2.4rem;
    padding-bottom: 0.15rem;
    margin-bottom: 0;
}

.eg-bs-quotient-digit {
    display: inline-block;
    min-width: 1.5em;
    text-align: center;
    opacity: 0;
    transition: opacity 220ms ease;
}

.eg-bs-quotient-digit.is-revealed { opacity: 1; }

.eg-bs-row {
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1;
    border-top: 4px solid #2b3a4c;
    padding-top: 0.25rem;
    padding-left: 0.1rem;
}

.eg-bs-divisor {
    display: inline-block;
    padding-right: 0.5rem;
    color: var(--maths-primary-dark);
}

.eg-bs-pipe {
    display: inline-block;
    width: 4px;
    height: 2.4rem;
    background: #2b3a4c;
    border-radius: 2px;
    margin-right: 0.5rem;
}

.eg-bs-dividend {
    display: inline-flex;
}

.eg-bs-dividend-digit {
    display: inline-block;
    min-width: 1.5em;
    text-align: center;
    transition: color 200ms ease, background-color 200ms ease;
    border-radius: 6px;
}

.eg-bs-dividend-digit.is-current {
    background: rgba(232, 106, 51, 0.18);
    color: #8c3110;
}

.eg-bs-spacer { display: inline-block; }
.eg-bs-spacer-divisor { padding-right: 0.5rem; }
.eg-bs-spacer-pipe { display: inline-block; width: calc(4px + 0.5rem); }

.eg-bs-working {
    margin-top: 0.7rem;
    background: #fff;
    border: 1px dashed #E5D9B6;
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    font-size: 1rem;
    font-weight: 600;
    color: #5e3c00;
    width: 100%;
    box-sizing: border-box;
}

.eg-bs-working-line {
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
}

.eg-bs-summary {
    margin-top: 0.7rem;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--maths-primary-dark);
}

/* Numeric keypad popover — same pattern as area-model. */
.eg-keypad {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: #fff;
    border: 2px solid var(--maths-primary);
    border-radius: 14px;
    box-shadow: 0 10px 32px rgba(15, 23, 42, 0.18);
    padding: 0.8rem;
    width: min(360px, 92vw);
}

.eg-keypad[hidden] { display: none; }

.eg-keypad-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.eg-keypad-prompt {
    font-weight: 800;
    color: var(--maths-primary-dark);
    font-size: 1rem;
}

.eg-keypad-close {
    border: 0;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--maths-ink-muted);
    padding: 0 0.4rem;
}

.eg-keypad-display {
    text-align: center;
    background: var(--maths-surface-alt);
    border-radius: 10px;
    padding: 0.6rem;
    font-size: 2rem;
    font-weight: 800;
    color: var(--maths-primary-dark);
    font-variant-numeric: tabular-nums;
    margin-bottom: 0.6rem;
}

.eg-keypad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
}

.eg-key {
    min-height: 54px;
    border: 2px solid var(--maths-border);
    border-radius: 10px;
    background: #fff;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1.4rem;
    color: var(--maths-primary-dark);
    cursor: pointer;
}

.eg-key:hover { background: var(--maths-surface-alt); }
.eg-key:active { background: var(--maths-primary); color: #fff; }

.eg-key-back { color: var(--maths-danger); border-color: var(--maths-danger); }
.eg-key-ok {
    color: #fff;
    background: var(--maths-primary);
    border-color: var(--maths-primary-dark);
}

@media (max-width: 720px) {
    .eg-stage { grid-template-columns: 1fr; }
    .eg-readouts { grid-column: 1; grid-row: auto; flex-direction: row; }
    .eg-readout { flex: 1 1 0; }
}
