/*
 * 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-measurement-rulers
 */
/*
 * 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;
    -webkit-touch-callout: none;
    touch-action: none;
}

/* The whole tool takes the drag (measurement-rulers.js, "Drag plumbing"). */
.maths-activity .mr-stage[data-tool="ruler"] .mr-tool-wrap svg,
.maths-activity .mr-stage[data-tool="tape"] .mr-tool-wrap svg { cursor: ew-resize; }
.maths-activity .mr-stage[data-tool="jug"] .mr-tool-wrap svg { cursor: ns-resize; }
.maths-activity .mr-stage[data-tool="scales"] .mr-tool-wrap svg { cursor: grab; }

/* Taken hold of: the pupil at the board can see the marker is theirs. */
.maths-activity .mr-stage.is-dragging .mr-cursor-handle { fill: #bf360c; }
.maths-activity .mr-stage.is-dragging .mr-cursor-line { stroke-width: 3; }
.maths-activity .mr-stage.is-dragging .mr-dial-needle { stroke-width: 4; }

.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, max-content) 1fr;
    gap: 0.75rem;
    width: 100%;
    max-width: 540px;
}

/* One step either way, either side of the reading. */
.maths-activity .mr-reading-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Wide enough for the longest reading, so the buttons either side stay put
   as the number changes under the pupil's finger. */
body:not(.display-mode) .mr-reading-row .mr-readout-value {
    min-width: 4.4em;
    text-align: center;
}

.maths-activity .mr-nudge {
    flex: 0 0 auto;
    width: 2.9rem;
    height: 2.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1.15rem;
    color: #8d4e0b;
    background: #fff7e6;
    border: 2px solid #f0c987;
    border-radius: 10px;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.maths-activity .mr-nudge:hover:not(:disabled) { border-color: #d89a2b; }
.maths-activity .mr-nudge:active:not(:disabled) { background: #ffe0a3; }
.maths-activity .mr-nudge:disabled { opacity: 0.35; cursor: default; }

.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 .mr-nudge,
body.display-mode #challengeRunner { display: none !important; }

/* Nothing to drag, so a swipe across the tool scrolls the lesson on a
   tablet as it would anywhere else on the page. */
body.display-mode .mr-tool-wrap { touch-action: auto; }
body.display-mode .mr-tool-wrap svg { cursor: default !important; }

body.display-mode .mr-readouts { grid-template-columns: minmax(160px, 1fr) 2fr; }

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;
}

/* ---------- Competition layout (board) ----------
 * A ruler is long and thin, so on a wide board it gets most of the width rather than 700px of
 * it: its numbers were 10px from the back of the room. In rem, so the shared fit can still shrink
 * it; as a share of the frame it grew taller than the board.
 */
html.mcr-compete .maths-activity .mr-stage[data-tool="ruler"] .mr-tool-wrap svg,
html.mcr-compete .maths-activity .mr-stage[data-tool="tape"] .mr-tool-wrap svg { max-width: 64rem; width: 100%; }
/* ---------- end competition layout ---------- */
