/*
 * place-value-blocks — visual Dienes-style place-value mat with one column
 * per place (thousands, hundreds, tens, ones, tenths, hundredths, ...).
 * Tap + / − under each column to add or remove blocks. Live total,
 * expanded-form, and in-words readouts. Supports decimals via
 * "decimalMode" — block visuals stay the same, labels relabel.
 */

.maths-activity .pvb-mat {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 0.75rem;
    background: #fffaf0;
    border: 1px solid var(--maths-border, #e0e7ef);
    border-radius: 14px;
    padding: 1rem;
    box-shadow: 0 2px 10px rgba(20, 40, 80, 0.05);
    margin-bottom: 1rem;
}

.maths-activity .pvb-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    border-right: 2px dashed var(--maths-border, #e0e7ef);
    padding: 0.5rem 0.25rem;
    min-width: 0;
}

.maths-activity .pvb-column:last-child { border-right: none; }

.maths-activity .pvb-column.pvb-decimal-divider {
    border-left: 3px solid var(--maths-primary, #2E7D32);
    margin-left: 0.5rem;
    padding-left: 0.5rem;
}

.maths-activity .pvb-col-header {
    text-align: center;
    font-weight: 800;
    color: var(--maths-primary-dark, #1b5e20);
}

.maths-activity .pvb-col-name {
    font-size: 0.95rem;
    line-height: 1.1;
}

.maths-activity .pvb-col-value {
    font-size: 0.7rem;
    color: var(--maths-text-muted, #6b7280);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.maths-activity .pvb-blocks {
    min-height: 180px;             /* fits 3 rows of 56px cubes + gaps */
    display: flex;
    flex-wrap: wrap-reverse;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    width: 100%;
    box-sizing: border-box;
}

/* Block visuals — Dienes-style.
   Each block has a shape class (cube/flat/rod/unit) that sets dimensions
   and the Dienes grid pattern, plus an identity class (per-place colour). */

.maths-activity .pvb-block {
    background: var(--pvb-block-bg, #f9b900);
    border: 1.5px solid var(--pvb-block-border, #8b6300);
    border-radius: 2px;
    box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.18);
}

.maths-activity .pvb-block-cube {
    width: min(56px, calc((100% - 6px) / 3));
    aspect-ratio: 1;
    background-image:
        linear-gradient(135deg, rgba(255, 255, 255, 0.35) 0%, transparent 50%),
        repeating-linear-gradient(0deg, transparent 0 5.6px, rgba(0, 0, 0, 0.15) 5.6px 6px),
        repeating-linear-gradient(90deg, transparent 0 5.6px, rgba(0, 0, 0, 0.15) 5.6px 6px);
}

.maths-activity .pvb-block-flat {
    width: min(48px, calc((100% - 6px) / 3));
    aspect-ratio: 1;
    background-image:
        repeating-linear-gradient(0deg, transparent 0 4.7px, rgba(0, 0, 0, 0.18) 4.7px 5px),
        repeating-linear-gradient(90deg, transparent 0 4.7px, rgba(0, 0, 0, 0.18) 4.7px 5px);
}

.maths-activity .pvb-block-rod {
    width: min(12px, calc((100% - 24px) / 9));
    height: 56px;
    background-image: repeating-linear-gradient(0deg, transparent 0 5.4px, rgba(0, 0, 0, 0.18) 5.4px 5.6px);
}

.maths-activity .pvb-block-unit {
    width: min(11px, calc((100% - 24px) / 9));
    aspect-ratio: 1;
}

/* Identity / colour — period-based.
   Ones period (U/T/H/decimals) keeps the historic yellow so existing
   lessons look unchanged. Thousands period uses three blue shades so
   Th/TTh/HTh are distinguishable despite all being cubes. Millions
   gets its own purple to mark the next period. */

.maths-activity .pvb-block-one,
.maths-activity .pvb-block-ten,
.maths-activity .pvb-block-hundred,
.maths-activity .pvb-block-decimal {
    --pvb-block-bg: #f9b900;
    --pvb-block-border: #8b6300;
}

.maths-activity .pvb-block-thousand {
    --pvb-block-bg: #60a5fa;
    --pvb-block-border: #1e3a8a;
}

.maths-activity .pvb-block-ten-thousand {
    --pvb-block-bg: #3b82f6;
    --pvb-block-border: #1e3a8a;
}

.maths-activity .pvb-block-hundred-thousand {
    --pvb-block-bg: #1d4ed8;
    --pvb-block-border: #0c1e5a;
}

.maths-activity .pvb-block-million {
    --pvb-block-bg: #9333ea;
    --pvb-block-border: #4c1d95;
}

.maths-activity .pvb-counter-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    justify-content: space-between;
}

.maths-activity .pvb-btn {
    flex: 1;
    background: var(--maths-primary, #2E7D32);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.4rem 0;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    line-height: 1;
}

.maths-activity .pvb-btn:hover { filter: brightness(1.08); }
.maths-activity .pvb-btn:disabled { background: #cbd5e1; cursor: not-allowed; }
.maths-activity .pvb-btn-minus { background: #d84315; }
.maths-activity .pvb-btn-minus:hover { background: #bf360c; }
.maths-activity .pvb-btn-minus:disabled { background: #cbd5e1; }

.maths-activity .pvb-count {
    min-width: 2.25rem;
    text-align: center;
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--maths-primary-dark, #1b5e20);
    font-variant-numeric: tabular-nums;
}

.maths-activity .pvb-readouts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.875rem;
}

.maths-activity .pvb-readout {
    background: #fff;
    border: 1px solid var(--maths-border, #e0e7ef);
    border-radius: 14px;
    padding: 0.875rem 1.125rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    box-shadow: 0 2px 8px rgba(20, 40, 80, 0.04);
}

.maths-activity .pvb-readout-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--maths-text-muted, #6b7280);
}

.maths-activity .pvb-readout-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--maths-primary-dark, #1b5e20);
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.maths-activity .pvb-readout-expanded-text { font-size: 1.05rem; font-weight: 700; }
.maths-activity .pvb-readout-words-text { font-size: 1.05rem; font-weight: 700; line-height: 1.3; }

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

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

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

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

.maths-activity .pvb-your-turn-list li { margin-bottom: 0.25rem; }

/* Display mode — hide controls, lock interaction */

body.display-mode .activity-header .controls-container,
body.display-mode .pvb-counter-row,
body.display-mode .pvb-target-panel,
body.display-mode .pvb-your-turn { display: none !important; }

@media (max-width: 720px) {
    /* Block widths now scale via min()/calc() — only the rod height and the
       container min-height need a mobile override. */
    .maths-activity .pvb-blocks { min-height: 130px; }
    .maths-activity .pvb-block-rod { height: 40px; }
    .maths-activity .pvb-mat { padding: 0.5rem; gap: 0.4rem; }
}
