/*
 * pictogram-builder — turn a tally / data set into a pictogram with
 * a chosen scale (1 icon = 1, 1 icon = 2, etc.). Per-category icon
 * stacks to the right of each label; +/- buttons adjust counts;
 * scale selector changes how many units each icon represents.
 * Half-icons (when count doesn't divide evenly into scale) render
 * via a clip-path so primary pupils see the partial unit.
 */

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

.maths-activity .pg-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 .pg-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #fff;
    border: 1px solid var(--maths-border, #e0e7ef);
    border-radius: 12px;
    padding: 0.75rem;
}

.maths-activity .pg-row {
    display: grid;
    grid-template-columns: 110px auto 1fr auto;
    align-items: center;
    gap: 0.625rem;
    padding: 0.4rem 0.25rem;
    border-radius: 8px;
}

.maths-activity .pg-row + .pg-row { border-top: 1px dashed #e0e7ef; }

.maths-activity .pg-row.pg-target-correct { background: #e8f5e9; }
.maths-activity .pg-row.pg-target-incorrect { background: #ffebee; }

.maths-activity .pg-row-label {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    color: var(--maths-ink, #1F2933);
    font-size: 1rem;
}

.maths-activity .pg-row-controls {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.maths-activity .pg-btn {
    background: #fff;
    border: 2px solid #cfd8dc;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1.15rem;
    line-height: 1;
    color: var(--maths-primary-dark, #1b5e20);
    cursor: pointer;
}

.maths-activity .pg-btn:hover:not(:disabled) { background: #fff8e1; border-color: #f0c14b; }
.maths-activity .pg-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.maths-activity .pg-row-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    min-height: 36px;
}

.maths-activity .pg-icon {
    font-size: 28px;
    line-height: 1;
    user-select: none;
    -webkit-user-select: none;
}

.maths-activity .pg-icon.pg-half {
    /* Clip the right half so it reads as "half an icon" */
    clip-path: inset(0 50% 0 0);
    -webkit-clip-path: inset(0 50% 0 0);
}

.maths-activity .pg-row-count {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--maths-primary-dark, #1b5e20);
    font-variant-numeric: tabular-nums;
    min-width: 36px;
    text-align: right;
}

/* Scale selector */
.maths-activity .pg-scale-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #fff;
    border: 1px solid var(--maths-border, #e0e7ef);
    border-radius: 12px;
    padding: 0.5rem 0.875rem;
    box-shadow: 0 2px 8px rgba(20, 40, 80, 0.04);
    flex-wrap: wrap;
}

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

.maths-activity .pg-scale-select {
    padding: 0.4rem 0.5rem;
    border: 2px solid var(--maths-border, #e0e7ef);
    border-radius: 8px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    background: #fff;
    color: var(--maths-ink, #1F2933);
}

.maths-activity .pg-scale-key {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--maths-primary-dark, #1b5e20);
    margin-left: auto;
}

.maths-activity .pg-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 .pg-target-label {
    font-weight: 800;
    color: #8d4e0b;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.maths-activity .pg-target-prompt { flex: 1; font-weight: 700; color: #1f2937; }

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

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

/* Display mode — pin counts, hide controls. Tighten row padding, stack
 * min-height and icon size so a multi-row pictogram fits without
 * scrolling. Your-turn prompts stay — those are display-only
 * discussion prompts.
 */
body.display-mode .pg-target-panel,
body.display-mode .pg-row-controls,
body.display-mode .pg-callout,
body.display-mode #challengeRunner { display: none !important; }

body.display-mode .pg-row {
    grid-template-columns: 110px 1fr auto;
    padding: 0.3rem 0.25rem;
}

body.display-mode .pg-row-stack {
    min-height: 28px;
}

body.display-mode .pg-icon {
    font-size: 22px;
}

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

body.display-mode .pg-rows {
    padding: 0.5rem;
}

body.display-mode .pg-scale-select { pointer-events: none; opacity: 0.7; }

@media (max-width: 560px) {
    .maths-activity .pg-row { grid-template-columns: 90px auto 1fr auto; }
    .maths-activity .pg-row-label { font-size: 0.9rem; }
    .maths-activity .pg-icon { font-size: 22px; }
}
