/* ================================================================
   factor-multiple-systematic.css
   ----------------------------------------------------------------
   Styles for the "Finding Factors and Multiples Systematically"
   skill group (Tier 2) on the Class 5 Math page:

     - A.1  Factor Hunt — a resizable array of counters attempts to
            arrange N into rows of d; complete rows fill green, any
            leftover counters spill into a highlighted red partial
            row so the child can literally see "how many are left
            over" (new .ffm-hunt-* classes).

     - A.2  Factor Rainbow — every factor of N drawn as a bubble in
            a row, with SVG arcs connecting each factor pair
            (1<->N, 2<->N/2, ...); one bubble is hidden behind a "?"
            and the child completes the rainbow (new .ffm-rainbow-*
            classes).

     - A.3  Multiples Table Builder — a growing tower of stacked
            unit blocks, one level per multiple, built by repeated
            addition; the child predicts the next level (new
            .ffm-tower-* classes).

     - A.4  Multiples on a Number Line — a shared 0-30 number line;
            the child taps the exact spot for the k-th multiple of
            a chosen number (new .ffm-line-* classes, sized up from
            the same tick/hit-target pattern as decimal-rwv.css's
            .drw-line-*).

     - A.5  Factor or Not? Speed Sort — a quick-fire 4-chip round
            sorting numbers against a fixed anchor (20): "which one
            IS a factor?" / "which one is NOT a factor?" (new
            .ffm-sort-* classes).

   Every skill here shares the same 5-question-per-slot / star-
   reward / "practice more?" quiz shell as the rest of the site (via
   the .bq- / .quiz- classes from quiz-popup-theme.css and quiz-
   modal-responsive.css, loaded elsewhere). This file defines its
   own self-contained "ffm-" prefixed classes, including its own
   answer-chip wrapper (.ffm-picker), so it has no hidden cross-file
   dependency — same philosophy as decimal-rwv.css's .drw- classes.
   Load this file after the shared quiz shell stylesheets, e.g.:

     <link rel="stylesheet" th:href="@{/css/quiz-popup-theme.css}" />
     <link rel="stylesheet" th:href="@{/css/quiz-modal-responsive.css}" />
     <link rel="stylesheet" th:href="@{/css/factor-multiple-systematic.css}" />
   ================================================================ */

/* ---------- shared: answer-chip picker row ---------- */
/* flex-wrap is intentionally "nowrap": there are always exactly 4
   chips and they must always sit in a single row on every screen
   size, including small Android phone browsers. Each .ffm-opt is a
   flexible (not fixed-width) item so the row shrinks to fit the
   quiz card instead of wrapping to a second line. */
.ffm-picker {
    display: flex;
    align-items: stretch;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 10px;
    margin: 18px auto 4px;
    width: 100%;
    max-width: 400px;
}
.ffm-opt {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    min-width: 0;
    max-width: 160px;
    padding: 12px 6px;
    height: auto !important;
    min-height: 52px !important;
    max-height: none !important;
    box-sizing: border-box !important;
    white-space: normal !important;
    overflow: visible;
    font-weight: 800;
    font-size: 17px;
    color: var(--secondary);
    text-align: center;
    line-height: 1.2;
    word-break: break-word;
}
.quiz-number-opt.ffm-opt.is-correct {
    border-color: #10b981;
    background: rgba(16,185,129,0.08);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.18);
}
.quiz-number-opt.ffm-opt.is-wrong {
    border-color: #ef4444;
    background: rgba(239,68,68,0.08);
    box-shadow: 0 0 0 3px rgba(239,68,68,0.18);
}

/* ---------- shared: target / instruction caption ---------- */
.ffm-target-caption {
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    text-align: center;
    margin: 4px auto 2px;
    max-width: 340px;
}
.ffm-target-caption .ffm-target-val {
    font-weight: 800;
    color: var(--secondary);
    font-size: 17px;
}

/* ================================================================
   A.1 Factor Hunt
   ================================================================ */
.ffm-hunt-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 14px auto 4px;
}
.ffm-hunt-label {
    font-weight: 800;
    font-size: 15px;
    color: var(--text);
    text-align: center;
}
.ffm-hunt-label .ffm-hunt-n { color: var(--secondary); font-size: 17px; }
.ffm-hunt-label .ffm-hunt-d { color: var(--pink-deep, #d6336c); font-size: 17px; }

.ffm-hunt-grid {
    display: grid;
    gap: 5px;
    justify-content: center;
    padding: 10px;
    background: #fff;
    border: 3px solid var(--line);
    border-radius: 14px;
    max-width: 300px;
}
.ffm-hunt-cell {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--line);
    opacity: 0.35;
}
.ffm-hunt-cell.is-filled {
    background: var(--mint-bright, var(--mint));
    opacity: 1;
}
.ffm-hunt-cell.is-leftover {
    background: #ef4444;
    opacity: 1;
}
.ffm-hunt-grid.is-complete {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16,185,129,0.18);
}
.ffm-hunt-note {
    font-weight: 700;
    font-size: 12.5px;
    color: var(--text);
    opacity: 0.75;
    text-align: center;
    max-width: 280px;
}

/* ================================================================
   A.2 Factor Rainbow
   ================================================================ */
.ffm-rainbow-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin: 18px auto 8px;
    width: 100%;
}
.ffm-rainbow-n {
    font-weight: 800;
    font-size: 15px;
    color: var(--text);
    text-align: center;
}
.ffm-rainbow-n span { color: var(--secondary); font-size: 18px; }
.ffm-rainbow-stage {
    position: relative;
    width: min(380px, 94%);
    height: 130px;
}
.ffm-rainbow-arcs {
    position: absolute;
    left: 0; top: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}
.ffm-rainbow-arc {
    fill: none;
    stroke: var(--purple);
    stroke-width: 2.5;
    opacity: 0.55;
}
.ffm-rainbow-arc.is-target {
    stroke: var(--sun);
    stroke-dasharray: 6 5;
    opacity: 0.9;
    stroke-width: 3;
}
.ffm-rainbow-bubbles {
    position: absolute;
    left: 0; bottom: 6px;
    width: 100%;
    height: 40px;
}
.ffm-rainbow-bubble {
    position: absolute;
    top: 0;
    width: 36px;
    height: 36px;
    margin-left: -18px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--purple);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 13px;
    color: var(--purple);
}
.ffm-rainbow-bubble.is-hidden {
    border-style: dashed;
    border-color: var(--sun);
    color: var(--sun);
    font-size: 18px;
    background: #fff8e8;
}
.ffm-rainbow-bubble.is-anchor {
    background: var(--purple);
    color: #fff;
}

/* ================================================================
   A.3 Multiples Table Builder
   ================================================================ */
.ffm-tower-wrap {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 4px;
    margin: 12px auto 6px;
    width: 100%;
    max-width: 300px;
}
.ffm-tower-level {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}
.ffm-tower-blocks {
    display: flex;
    gap: 2px;
    flex: 1 1 auto;
    justify-content: center;
}
.ffm-tower-block {
    width: 18px;
    height: 22px;
    border-radius: 4px;
    background: var(--sky);
    border: 1px solid rgba(0,0,0,0.08);
}
.ffm-tower-level.is-next .ffm-tower-block {
    background: transparent;
    border: 2px dashed var(--sun);
}
.ffm-tower-value {
    flex: 0 0 auto;
    width: 74px;
    font-weight: 800;
    font-size: 13px;
    color: var(--secondary);
    text-align: right;
}
.ffm-tower-level.is-next .ffm-tower-value {
    color: var(--sun);
}
.ffm-tower-plus {
    font-weight: 800;
    font-size: 12.5px;
    color: var(--text);
    opacity: 0.7;
    text-align: center;
    margin-top: 4px;
}

/* ================================================================
   A.4 Multiples on a Number Line (0-30)
   ================================================================ */
.ffm-line-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 24px auto 14px;
    width: 100%;
}
.ffm-number-line {
    position: relative;
    width: min(520px, 94%);
    height: 68px;
}
.ffm-line-track {
    position: absolute;
    left: 0; right: 0; top: 28px;
    height: 4px;
    border-radius: 2px;
    background: var(--secondary);
    opacity: 0.25;
}
.ffm-line-tick {
    position: absolute;
    top: 20px;
    width: 2px;
    height: 20px;
    background: var(--secondary);
    opacity: 0.25;
    transform: translateX(-1px);
    pointer-events: none;
}
.ffm-line-tick.is-major {
    opacity: 0.7;
    width: 2.5px;
    height: 26px;
    top: 17px;
}
.ffm-line-label {
    position: absolute;
    top: 44px;
    transform: translateX(-50%);
    font-weight: 800;
    font-size: 11.5px;
    color: var(--secondary);
    opacity: 0.85;
    pointer-events: none;
}
.ffm-line-hit {
    position: absolute;
    top: 15px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    transform: translate(-50%, 0);
    background: transparent;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
}
.ffm-line-hit:hover { background: rgba(46,155,245,0.10); }
.ffm-line-hit-dot {
    position: absolute;
    left: 50%; top: 50%;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--secondary);
    opacity: 0.35;
    transform: translate(-50%, -50%);
}
.ffm-line-hit.is-correct { background: rgba(16,185,129,0.18); border-color: #10b981; }
.ffm-line-hit.is-correct .ffm-line-hit-dot { background: #10b981; opacity: 1; width: 10px; height: 10px; }
.ffm-line-hit.is-wrong { background: rgba(239,68,68,0.18); border-color: #ef4444; }
.ffm-line-hit.is-wrong .ffm-line-hit-dot { background: #ef4444; opacity: 1; width: 10px; height: 10px; }
.ffm-line-hit:disabled { cursor: default; }

/* ================================================================
   A.5 Factor or Not? Speed Sort
   ================================================================ */
.ffm-sort-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 14px auto 6px;
}
.ffm-sort-anchor {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 74px;
    height: 74px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    font-weight: 800;
    font-size: 28px;
    box-shadow: 0 6px 14px rgba(0,0,0,0.15);
}
.ffm-sort-caption {
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
    text-align: center;
    max-width: 280px;
}
.ffm-sort-caption .ffm-sort-mode {
    font-weight: 800;
    color: var(--secondary);
}

/* ---------- phone responsiveness ---------- */
@media (max-width: 560px) {
    .ffm-picker { gap: 7px; margin: 14px auto 4px; max-width: 340px; }
    .ffm-opt { padding: 9px 5px; font-size: 14.5px; min-height: 46px !important; }

    .ffm-hunt-grid { max-width: 250px; padding: 8px; gap: 4px; }
    .ffm-hunt-cell { width: 16px; height: 16px; }

    .ffm-rainbow-stage { height: 112px; }
    .ffm-rainbow-bubble { width: 30px; height: 30px; margin-left: -15px; font-size: 11.5px; }
    .ffm-rainbow-bubble.is-hidden { font-size: 15px; }

    .ffm-tower-wrap { max-width: 260px; }
    .ffm-tower-block { width: 15px; height: 18px; }
    .ffm-tower-value { width: 62px; font-size: 12px; }

    .ffm-number-line { height: 60px; }
    .ffm-line-track { top: 24px; }
    .ffm-line-tick { top: 17px; height: 16px; }
    .ffm-line-tick.is-major { top: 14px; height: 22px; }
    .ffm-line-label { top: 38px; font-size: 10.5px; }
    .ffm-line-hit { width: 18px; height: 18px; top: 14px; }
    .ffm-line-hit-dot { width: 6px; height: 6px; }
    .ffm-line-hit.is-correct .ffm-line-hit-dot,
    .ffm-line-hit.is-wrong .ffm-line-hit-dot { width: 8px; height: 8px; }

    .ffm-sort-anchor { width: 62px; height: 62px; font-size: 23px; }
}
@media (max-width: 380px) {
    .ffm-picker { gap: 5px; max-width: 300px; }
    .ffm-opt { padding: 7px 4px; font-size: 13px; min-height: 44px !important; }

    .ffm-hunt-grid { max-width: 220px; }
    .ffm-hunt-cell { width: 14px; height: 14px; }

    .ffm-rainbow-stage { height: 100px; }
    .ffm-rainbow-bubble { width: 26px; height: 26px; margin-left: -13px; font-size: 10.5px; }

    .ffm-tower-wrap { max-width: 230px; }
    .ffm-tower-block { width: 13px; height: 16px; }
    .ffm-tower-value { width: 54px; font-size: 11px; }

    .ffm-number-line { height: 56px; }
    .ffm-line-label { font-size: 9.5px; }

    .ffm-sort-anchor { width: 54px; height: 54px; font-size: 20px; }
}