/*
 * 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-number-line
 */
/*
 * number-line — horizontal SVG number line with one or more draggable
 * markers. Range and tick spacing configurable. Teaches counting,
 * positioning, jumping, fractions and decimals on a line, integer
 * ordering. The highest-frequency primary-maths scaffold.
 */

.maths-activity .nl-stage {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
}

.maths-activity .nl-svg {
    width: 100%;
    height: auto;
    max-height: 220px;
    background: #fffaf0;
    border: 1px solid var(--maths-border, #e0e7ef);
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(20, 40, 80, 0.05);
    user-select: none;
    touch-action: none;
}

.maths-activity .nl-axis {
    stroke: #1b5e20;
    stroke-width: 3;
    stroke-linecap: round;
}

.maths-activity .nl-axis-arrow { fill: #1b5e20; }

.maths-activity .nl-tick-major {
    stroke: #1b5e20;
    stroke-width: 2;
    stroke-linecap: round;
}

/* The minor ticks ARE the task on a fractions/decimals line — pupils count the
   equal jumps between the whole numbers — so they have to read from the back of
   the room. At 1px / 0.45 opacity they were nearly invisible on an IWB. */
.maths-activity .nl-tick-minor {
    stroke: #1b5e20;
    stroke-width: 1.5;
    opacity: 0.75;
    stroke-linecap: round;
}

.maths-activity .nl-tick-label {
    fill: #1f2937;
    font-family: "Nunito", sans-serif;
    font-weight: 700;
    font-size: 13px;
    text-anchor: middle;
    dominant-baseline: hanging;
    user-select: none;
}

/* The minor marks carry names too on a decimals / fractions line, but the whole
   numbers have to stay the anchors you read first from the back of the room. */
.maths-activity .nl-tick-label-minor {
    font-weight: 600;
    font-size: 11px;
    fill: #4b5563;
}

/* Names what one small step is worth on a line whose marks are left bare — a
   challenge line (naming them would hand over the placement), or one divided
   too finely to label every mark. Without it a 0-to-2 line in tenths reads
   "0, 1, 2" and nothing on screen says the little marks are tenths. */
.maths-activity .nl-scale-caption {
    fill: #4b5563;
    font-family: "Nunito", sans-serif;
    font-weight: 700;
    font-size: 12px;
    text-anchor: start;
    dominant-baseline: hanging;
    user-select: none;
}

.maths-activity .nl-marker {
    cursor: grab;
    transition: filter 120ms ease-out;
}

.maths-activity .nl-marker:active,
.maths-activity .nl-marker.nl-marker-dragging { cursor: grabbing; }

.maths-activity .nl-marker:hover { filter: brightness(1.1); }
.maths-activity .nl-marker:focus { outline: none; filter: drop-shadow(0 0 4px var(--maths-primary, #2E7D32)); }

.maths-activity .nl-marker-pin { fill: #d84315; stroke: #8d2a0b; stroke-width: 2; }
.maths-activity .nl-marker-flag { fill: #fff; stroke: #8d2a0b; stroke-width: 1.5; }
/* Stem from a stacked flag back down to its pin (see markerRows): only drawn
   when markers sit too close to share a row, so the value never floats free of
   the mark it names. Inherits the marker's colour from the rules below. */
.maths-activity .nl-marker-stem { stroke: #8d2a0b; stroke-width: 2; }

.maths-activity .nl-marker-text {
    fill: #1f2937;
    font-family: "Nunito", sans-serif;
    font-weight: 800;
    font-size: 15px;
    text-anchor: middle;
    dominant-baseline: middle;
    user-select: none;
    pointer-events: none;
}

.maths-activity .nl-marker-2 .nl-marker-pin { fill: #1565c0; stroke: #0b3a73; }
.maths-activity .nl-marker-2 .nl-marker-flag,
.maths-activity .nl-marker-2 .nl-marker-stem { stroke: #0b3a73; }

.maths-activity .nl-marker-3 .nl-marker-pin { fill: #6a1b9a; stroke: #3d0f5b; }
.maths-activity .nl-marker-3 .nl-marker-flag,
.maths-activity .nl-marker-3 .nl-marker-stem { stroke: #3d0f5b; }

/* Markers 4-6 — for sequence lines (e.g. 3, 6, 9, 12) that plot one per term. */
.maths-activity .nl-marker-4 .nl-marker-pin { fill: #2e7d32; stroke: #1b5e20; }
.maths-activity .nl-marker-4 .nl-marker-flag,
.maths-activity .nl-marker-4 .nl-marker-stem { stroke: #1b5e20; }
.maths-activity .nl-marker-5 .nl-marker-pin { fill: #e65100; stroke: #ac3d00; }
.maths-activity .nl-marker-5 .nl-marker-flag,
.maths-activity .nl-marker-5 .nl-marker-stem { stroke: #ac3d00; }
.maths-activity .nl-marker-6 .nl-marker-pin { fill: #00838f; stroke: #005661; }
.maths-activity .nl-marker-6 .nl-marker-flag,
.maths-activity .nl-marker-6 .nl-marker-stem { stroke: #005661; }

.maths-activity .nl-readouts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.875rem;
}

/* `display: grid` above beats the UA stylesheet's `[hidden] { display: none }`,
   so a bare display line (no marker, nothing to read out) needs this to
   actually hide its readouts rather than show an empty box. */
.maths-activity .nl-readouts[hidden] { display: none; }

.maths-activity .nl-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);
}

/* The SAME trap one level down, and it shipped: `display: flex` above beats
   `[hidden] { display: none }`, so the "As a fraction" box was visible on every
   number line in the corpus reading a bare em dash, however the step was
   configured. Three separate rounding lessons were flagged with "remove As a
   Fraction" (QA #243/#245/#247/#249/#250), and on a fractions lesson the same
   empty box read as the fraction "still not showing" (#80). The JS sets
   `hidden` correctly; only the CSS was wrong. */
.maths-activity .nl-readout[hidden] { display: none; }

.maths-activity .nl-readout-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--maths-text-muted, #6b7280);
}

.maths-activity .nl-readout-value-text {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--maths-primary-dark, #1b5e20);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.maths-activity .nl-readout-fraction .nl-readout-value-text sup,
.maths-activity .nl-readout-fraction .nl-readout-value-text sub { font-size: 0.6em; font-weight: 700; }

.maths-activity .nl-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 .nl-target-label {
    font-weight: 800;
    color: #8d4e0b;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.maths-activity .nl-target-prompt { flex: 1; font-weight: 700; color: #1f2937; }

.maths-activity .nl-your-turn {
    margin-top: 1.25rem;
    background: #f1f8e9;
    border: 1px solid #aed581;
    border-radius: 14px;
    padding: 1rem 1.25rem;
}

.maths-activity .nl-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 .nl-your-turn-list {
    margin: 0;
    padding-left: 1.25rem;
    color: #1f2937;
    font-weight: 600;
}

.maths-activity .nl-your-turn-list li { margin-bottom: 0.25rem; }

/* Rounding commit — the "which nearest ten / hundred / thousand?" choice that
   appears under the line once the marker is placed (and revealed in display). */
.maths-activity .nl-round-choice {
    margin-top: 1rem;
    background: #fff8e1;
    border: 1px solid #ffcc80;
    border-radius: 14px;
    padding: 0.9rem 1.1rem;
    text-align: center;
}
.maths-activity .nl-round-prompt {
    font-weight: 800;
    color: #8d4e0b;
    margin-bottom: 0.6rem;
    font-size: 1.02rem;
}
.maths-activity .nl-round-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}
.maths-activity .nl-round-btn {
    min-width: 96px;
    padding: 0.6rem 1.3rem;
    font-size: 1.15rem;
    font-weight: 800;
    font-family: inherit;
    color: #1b5e20;
    background: #fff;
    border: 2px solid var(--maths-primary, #2E7D32);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.12s, transform 0.08s;
}
.maths-activity .nl-round-btn:hover:not(:disabled) { background: #e8f5e9; transform: translateY(-1px); }
.maths-activity .nl-round-btn:disabled { cursor: default; }
.maths-activity .nl-round-btn.is-correct {
    background: var(--maths-primary, #2E7D32);
    border-color: var(--maths-primary, #2E7D32);
    color: #fff;
}
.maths-activity .nl-round-btn.is-wrong {
    background: #fdecea;
    border-color: #d84315;
    color: #b71c1c;
}

/* Display mode — hide controls, lock interaction */

body.display-mode .activity-header .controls-container,
body.display-mode .nl-target-panel,
/* The readouts track a single dragged marker — in display mode the values are
 * already on the marker flags, and a static line with several markers made the
 * one-value readout misleading (QA #137 on the mixed-number lines). */
body.display-mode .nl-readouts,
body.display-mode .nl-your-turn { display: none !important; }

body.display-mode .nl-marker { cursor: default !important; pointer-events: none; }

@media (max-width: 720px) {
    .maths-activity .nl-tick-label { font-size: 11px; }
    .maths-activity .nl-marker-text { font-size: 13px; }
}
