/*
 * 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-drag-sort
 */
/*
 * drag-sort — sort cards into labelled buckets. Pointer-event drag
 * (works on touch + mouse). Card → bucket → if it matches the
 * bucket's accept rule it sticks; otherwise it bounces back. Use
 * cases: numbers by parity / multiple-of / prime; shapes by sides
 * / symmetry; fractions by size; times in order.
 */

.maths-activity [hidden] { display: none !important; }

.maths-activity .ds-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;
}

.maths-activity .ds-section-label {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--maths-text-muted, #6b7280);
    margin-bottom: 0.4rem;
}

.maths-activity .ds-source {
    background: #fff;
    border: 1px solid var(--maths-border, #e0e7ef);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    box-shadow: 0 2px 8px rgba(20, 40, 80, 0.04);
}

.maths-activity .ds-source-tray {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 64px;
    align-items: center;
}

.maths-activity .ds-buckets {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.maths-activity .ds-bucket {
    background: #fff;
    border: 2px dashed #cfd8dc;
    border-radius: 12px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 140px;
    transition: background-color 120ms ease-out, border-color 120ms ease-out;
}

.maths-activity .ds-bucket.ds-bucket-active {
    background: #fff8e1;
    border-color: #f0c14b;
    border-style: solid;
}

.maths-activity .ds-bucket-label {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    color: var(--maths-primary-dark, #1b5e20);
    text-align: center;
    font-size: 0.95rem;
}

.maths-activity .ds-bucket-tray {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-height: 56px;
    align-content: flex-start;
    flex: 1;
}

/* Cards */
.maths-activity .ds-card {
    overflow-wrap: anywhere;  /* a web address on a card wraps instead of running over its edge */
    background: #fff;
    border: 2px solid #455a64;
    border-radius: 10px;
    padding: 0.5rem 0.875rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--maths-ink, #1F2933);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    font-variant-numeric: tabular-nums;
    min-width: 56px;
    text-align: center;
    transition: transform 120ms ease-out, box-shadow 120ms ease-out;
}

.maths-activity .ds-card:hover { box-shadow: 0 2px 6px rgba(20, 40, 80, 0.12); }

/* Sentence-long cards (drag-sort.js sets these classes when any card is over 40 characters) */
.maths-activity .ds-buckets--text .ds-card,
.maths-activity .ds-source-tray--text .ds-card {
    font-size: 1rem;
    font-weight: 700;
    text-align: left;
    line-height: 1.35;
}

/* The result line now sits on its own, above the stage */
.maths-activity > .activity-container > .ds-callout,
.maths-activity .activity-container > #resultCallout { margin-bottom: 1rem; flex-wrap: wrap; }
.maths-activity .ds-card:active { cursor: grabbing; }

.maths-activity .ds-card.ds-dragging {
    opacity: 0.85;
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    z-index: 1000;
    position: fixed;
    pointer-events: none;
}

.maths-activity .ds-card.ds-correct {
    border-color: #2E7D32;
    background: #e8f5e9;
}

.maths-activity .ds-card.ds-wrong {
    border-color: #c62828;
    background: #ffebee;
}

/* markEachDrop: a placed card says right or wrong in a word and an icon, not
   only in its colour, and the card the line under the boxes is about is ringed. */
.maths-activity .ds-mark {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.85rem;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
}
.maths-activity .ds-mark i { margin-right: 0.3rem; }
.maths-activity .ds-mark--right { color: #1b5e20; }
.maths-activity .ds-mark--wrong { color: #b71c1c; }
.maths-activity .ds-card.ds-card--latest { box-shadow: 0 0 0 3px #f0c14b; }

/* A picture card has no room for the words: a round badge in its corner, a
   tick or a cross, and its accessible name says which. */
.maths-activity .ds-card--shape { position: relative; }
.maths-activity .ds-card--shape .ds-mark {
    position: absolute;
    top: -9px;
    right: -9px;
    width: 26px;
    height: 26px;
    margin: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.85rem;
}
.maths-activity .ds-card--shape .ds-mark i { margin: 0; }
.maths-activity .ds-card--shape .ds-mark--right { background: #2E7D32; }
.maths-activity .ds-card--shape .ds-mark--wrong { background: #c62828; }
.maths-activity .ds-card--shape .ds-mark-word { display: none; }

/* The line under the boxes. Sticky, so it stays in view at the foot of the
   activity while the class looks down a long set of boxes. */
.maths-activity .ds-feedback {
    position: sticky;
    bottom: 0.5rem;
    z-index: 5;
    border: 2px solid;
    border-radius: 12px;
    padding: 0.7rem 1rem;
    font-size: 1.1rem;
    line-height: 1.4;
    color: var(--maths-ink, #1F2933);
    box-shadow: 0 -2px 10px rgba(20, 40, 80, 0.08);
}
.maths-activity .ds-feedback--right { border-color: #2E7D32; background: #e8f5e9; }
.maths-activity .ds-feedback--wrong { border-color: #c62828; background: #ffebee; }
.maths-activity .ds-feedback-verdict { font-weight: 600; }
.maths-activity .ds-feedback-verdict i { margin-right: 0.35rem; }
.maths-activity .ds-feedback--right .ds-feedback-verdict i,
.maths-activity .ds-feedback--right .ds-feedback-verdict strong { color: #1b5e20; }
.maths-activity .ds-feedback--wrong .ds-feedback-verdict i,
.maths-activity .ds-feedback--wrong .ds-feedback-verdict strong { color: #b71c1c; }
.maths-activity .ds-feedback-card {
    margin: 0.3rem 0 0;
    padding-left: 0.6rem;
    border-left: 3px solid rgba(31, 41, 51, 0.25);
    font-size: 0.95em;
    color: #374151;
}
.maths-activity .ds-feedback-why { margin-top: 0.3rem; font-weight: 800; }
body.display-mode .ds-feedback { display: none !important; }

/* Picture cards (`cardShapes`): the drawn shape is the whole card, and every
   card is the same size so a tiny circle looks tiny beside a huge one. */
.maths-activity .ds-card.ds-card--shape {
    width: 84px;
    height: 84px;
    min-width: 0;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.maths-activity .ds-card--shape .ds-card-shape {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}

/* A picture whose number is part of the task ("88 degrees") carries it below. */
.maths-activity .ds-card.ds-card--captioned {
    flex-direction: column;
    height: auto;
    min-height: 84px;
    gap: 2px;
}

.maths-activity .ds-card--captioned .ds-card-shape {
    height: 64px;
}

.maths-activity .ds-card-caption {
    font-size: 0.9rem;
    line-height: 1.1;
    font-weight: 800;
}

.maths-activity .ds-venn-region .ds-card.ds-card--shape {
    width: 56px;
    height: 56px;
    padding: 2px;
}

/* Status + check */
.maths-activity .ds-status-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

.maths-activity .ds-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 .ds-score-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--maths-text-muted, #6b7280);
}

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

.maths-activity .ds-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 .ds-your-turn {
    margin-top: 1.25rem;
    background: #f1f8e9;
    border: 1px solid #aed581;
    border-radius: 14px;
    padding: 1rem 1.25rem;
}

.maths-activity .ds-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 .ds-your-turn-list { margin: 0; padding-left: 1.25rem; color: #1f2937; font-weight: 600; }
.maths-activity .ds-your-turn-list li { margin-bottom: 0.25rem; }

/* Display mode — pin the buckets with preset sort. Hide the status row
 * (sorted count + check), target panel, callout and challenge runner;
 * lock cards. Tighten bucket min-height since display lessons preset
 * the contents. Your-turn prompts stay — those are display-only
 * discussion prompts.
 */
body.display-mode .ds-target-panel,
body.display-mode .ds-callout,
body.display-mode .ds-status-row,
body.display-mode #challengeRunner { display: none !important; }

/* The teacher's reveal. Its own row, because .ds-status-row is hidden
   wholesale in display mode. Empty and invisible until the button unhides,
   so it costs no space on a step that has nothing to reveal. */
.ds-reveal-row {
    display: flex;
    justify-content: center;
    margin-top: 0.5rem;
}
.ds-reveal-row:has(> [hidden]) { margin-top: 0; }
.ds-reveal-left { opacity: 0.75; font-weight: 400; }

body.display-mode .ds-card { cursor: default !important; pointer-events: none; }
/* ...but the reveal button is the one control display mode still needs. */
body.display-mode .ds-reveal-row .ds-check-btn { pointer-events: auto; }

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

body.display-mode .ds-bucket {
    min-height: 100px;
}

body.display-mode .ds-source-tray {
    min-height: 48px;
}

/* What the finished sort adds up to, printed with the success callout. Sorting
   the cards into x-terms and plain numbers is only half of a simplifying step:
   without this the class never sees 7x + 3 written anywhere (QA #857). Supplied
   by the lesson as `resultNote`; absent on every sort that has no such answer. */
.maths-activity .ds-result-note {
    display: block;
    margin-top: 0.35rem;
    font-weight: 700;
}

/* ---------- Competition layout (board) ----------
 * The cards are what the class reads and sorts; they were 18px.
 */
html.mcr-compete .maths-activity .ds-card { font-size: 2rem; padding: 0.45rem 1.1rem; min-width: 5rem; }
html.mcr-compete .maths-activity .ds-bucket-label { font-size: 1.5rem; }
html.mcr-compete .maths-activity .ds-card.ds-card--shape { width: 120px; height: 120px; padding: 6px; min-width: 0; }
html.mcr-compete .maths-activity .ds-feedback { font-size: 1.5rem; }
/* ---------- end competition layout ---------- */
