/*
 * measurement-rulers — drag-the-cursor reading on a virtual ruler,
 * tape measure, weighing scales, or measuring jug. Stages 2-4
 * (compare-mode for stage 1 deferred until 1st/2nd-class courses
 * are authored — see measurement-rulers.js).
 */

/* See maths-bingo: class selectors with `display: flex|grid` beat the
 * browser default `[hidden] { display: none }`. Override once so the
 * JS can hide / show panels (target panel, callout) with `.hidden`. */
.maths-activity [hidden] { display: none !important; }

.maths-activity .mr-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;
    align-items: center;
}

.maths-activity .mr-tool-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.maths-activity .mr-tool-wrap svg {
    max-width: 100%;
    height: auto;
    overflow: visible;
}

/* Cap each tool so it fits inside the embedding iframe (560px display / 680px explore) */
.maths-activity .mr-stage[data-tool="jug"]    .mr-tool-wrap svg { max-width: 240px; }
.maths-activity .mr-stage[data-tool="scales"] .mr-tool-wrap svg { max-width: 460px; }
.maths-activity .mr-stage[data-tool="ruler"]  .mr-tool-wrap svg,
.maths-activity .mr-stage[data-tool="tape"]   .mr-tool-wrap svg { max-width: 700px; }

/* ----- Ruler / tape ----- */

.maths-activity .mr-scale-bar { fill: #ffe082; stroke: #b07a05; stroke-width: 1; }
.maths-activity .mr-scale-bar.mr-tape { fill: #fff59d; }

.maths-activity .mr-tick { stroke: #4e342e; stroke-width: 1; }
.maths-activity .mr-tick.mr-major { stroke-width: 1.5; }

.maths-activity .mr-tick-label {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 11px;
    fill: #3e2723;
    font-variant-numeric: tabular-nums;
    text-anchor: middle;
}

.maths-activity .mr-object-rect {
    fill: #1565c0;
    fill-opacity: 0.18;
    stroke: #0d47a1;
    stroke-width: 1.5;
    rx: 4;
}

.maths-activity .mr-object-label {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 13px;
    fill: #0d47a1;
    text-anchor: middle;
}

/* Cursor — vertical line + arrow handle */
.maths-activity .mr-cursor-line {
    stroke: #d84315;
    stroke-width: 2;
    pointer-events: none;
}

.maths-activity .mr-cursor-handle {
    fill: #d84315;
    stroke: #6a1b09;
    stroke-width: 1.5;
    cursor: ew-resize;
}

.maths-activity .mr-cursor-handle:hover { fill: #bf360c; }

.maths-activity .mr-cursor-readout {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 13px;
    fill: #fff;
    text-anchor: middle;
    pointer-events: none;
}

/* ----- Scales (weighing dial) ----- */

.maths-activity .mr-dial-bg { fill: #fffaf0; stroke: #6d4c41; stroke-width: 2; }
.maths-activity .mr-dial-pivot { fill: #4e342e; }
.maths-activity .mr-dial-needle {
    stroke: #d84315;
    stroke-width: 3;
    stroke-linecap: round;
    cursor: grab;
}
.maths-activity .mr-dial-needle:active { cursor: grabbing; }

.maths-activity .mr-dial-pan {
    fill: #c0c0c0;
    stroke: #616161;
    stroke-width: 1.5;
}

/* ----- Measuring jug ----- */

.maths-activity .mr-jug-body {
    fill: #ffffff;
    stroke: #4e342e;
    stroke-width: 2;
}

.maths-activity .mr-jug-liquid {
    fill: #4fc3f7;
    fill-opacity: 0.75;
    cursor: ns-resize;
}

.maths-activity .mr-jug-liquid-top {
    stroke: #0277bd;
    stroke-width: 2;
    cursor: ns-resize;
}

/* ----- Readouts ----- */

.maths-activity .mr-readouts {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) 2fr;
    gap: 0.75rem;
    width: 100%;
    max-width: 540px;
}

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

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

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

.maths-activity .mr-readout-value-text {
    font-weight: 700;
    color: var(--maths-text, #1f2937);
    font-size: 0.95rem;
    line-height: 1.3;
}

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

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

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

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

/* Display mode — read-only reading. Target panel, callout and
 * challenge runner hidden; cursor/needle/jug locked. Tighten the stage
 * so the tool + readout fit compactly. Your-turn prompts stay — those
 * are display-only discussion prompts.
 */
body.display-mode .mr-target-panel,
body.display-mode .mr-callout,
body.display-mode #challengeRunner { display: none !important; }

body.display-mode .mr-cursor-handle,
body.display-mode .mr-dial-needle,
body.display-mode .mr-jug-liquid,
body.display-mode .mr-jug-liquid-top {
    pointer-events: none !important;
    cursor: default !important;
}

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

body.display-mode .mr-readout {
    padding: 0.55rem 0.85rem;
}

body.display-mode .mr-readout-value {
    font-size: 1.3rem;
}
