/* ================================================================
   perimeter-foundations.css
   ----------------------------------------------------------------
   Styling for the "What is Perimeter? (Foundations \u2014 no measuring
   yet)" skill quizzes on the Class 5 Math page:

     - A.1 Walk the Edge            (.perim-stage / .perim-outline-svg)
     - A.2 Fence the Field          (.perim-thumb-opt thumbnails)
     - A.3 Inside vs Outside        (.perim-fill-inside / .perim-stroke-boundary)
     - A.4 Count the Steps          (.perim-count-grid-svg)

   All four share one visual "stage" card (.perim-stage, styled like
   fraction.css's .frac-parts-stage: a bordered box that rings green/
   red via .is-correct/.is-wrong once a question is graded) and one
   answer-chip row (.perim-options / .perim-opt). The chip row is a
   4-column CSS Grid \u2014 not a wrapping flex row \u2014 specifically so all
   four answers are FORCED onto a single line at every viewport width
   down to small Android phones; text inside a chip shrinks (via
   clamp()) and may wrap to a second line inside its own cell, but the
   row itself never breaks into two rows. Loaded as a plain stylesheet
   link, independent of fraction.css/fraction-rwv.css.
   ================================================================ */

/* ---------- shared visual "stage" (shape / grid / thumbnails live here) ---------- */
.perim-stage {
    width: clamp(220px, 70vw, 320px);
    aspect-ratio: 1 / 1;
    margin: 14px auto 6px;
    border: 3px solid var(--line);
    border-radius: 20px;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 0 rgba(0,0,0,0.06);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    overflow: hidden;
}
.perim-stage.is-correct {
    border-color: #22c08d;
    box-shadow: 0 0 0 4px rgba(34,192,141,0.18);
}
.perim-stage.is-wrong {
    border-color: #f5427d;
    box-shadow: 0 0 0 4px rgba(245,66,125,0.15);
}
.perim-stage svg {
    width: 92%;
    height: 92%;
    display: block;
}

/* ---------- A.1 Walk the Edge: shape outline + animated ant ---------- */
.perim-field-shape {
    fill: #fff8ec;
    stroke: var(--line);
    stroke-width: 3;
    stroke-linejoin: round;
}
.perim-boundary-path {
    fill: none;
    stroke: #ff8a3d;
    stroke-width: 5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 10 8;
}
.perim-ant-emoji {
    font-size: 20px;
    text-anchor: middle;
    dominant-baseline: middle;
}

/* ---------- A.2 Fence the Field: reference field + candidate fence overlay ---------- */
.perim-field-reference {
    fill: #eef2f6;
    stroke: #c8d0da;
    stroke-width: 2;
    stroke-dasharray: 4 4;
}
.perim-fence-line {
    fill: none;
    stroke: #4a3323;
    stroke-width: 6;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.perim-fence-post {
    fill: #4a3323;
}

/* ---------- A.3 Inside vs Outside (trap questions) ---------- */
.perim-stroke-boundary {
    fill: none;
    stroke: #ff8a3d;
    stroke-width: 8;
    stroke-linejoin: round;
}
.perim-fill-inside {
    fill: #7ecbff;
    stroke: var(--line);
    stroke-width: 2;
}

/* ---------- A.4 Count the Steps: grid + counted boundary dots ---------- */
.perim-grid-line {
    stroke: #d7dee6;
    stroke-width: 1;
}
.perim-count-boundary {
    fill: none;
    stroke: #2f8f5b;
    stroke-width: 5;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.perim-count-dot {
    fill: #2f8f5b;
    stroke: #fff;
    stroke-width: 1.5;
}

/* ---------- shared answer-chip row (A.1, A.3, A.4 text/number chips + A.2 thumbnails) ----------
   4-column grid = guaranteed single line at every width; never
   switches to flex-wrap, so the four chips can't stack. */
.perim-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: clamp(6px, 2vw, 14px);
    width: 100%;
    max-width: 560px;
    margin: 18px auto 4px;
}
.perim-opt {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 58px;
    padding: 8px 4px;
    border-radius: 14px;
    border: 3px solid var(--line);
    background: #fff;
    font-family: inherit;
    font-weight: 700;
    color: #3a2c1f;
    font-size: clamp(11px, 3.3vw, 16px);
    line-height: 1.15;
    text-align: center;
    word-break: break-word;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.perim-opt:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 0 rgba(0,0,0,0.08);
}
.perim-opt:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}
.perim-opt:focus-visible {
    outline: 3px solid #4a90e2;
    outline-offset: 2px;
}
.perim-opt:disabled { cursor: default; }
.perim-opt.is-correct {
    border-color: #22c08d;
    background: #eafff6;
    box-shadow: 0 0 0 4px rgba(34,192,141,0.18);
}
.perim-opt.is-wrong {
    border-color: #f5427d;
    background: #fff0f4;
    box-shadow: 0 0 0 4px rgba(245,66,125,0.15);
}

/* A.2's chips carry a small thumbnail svg + a bare "A/B/C/D" label
   underneath, instead of plain text \u2014 same grid cell, same forced
   single-line row. */
.perim-opt.perim-thumb-opt {
    padding: 6px 4px 8px;
}
.perim-opt.perim-thumb-opt svg {
    width: clamp(44px, 11vw, 74px);
    aspect-ratio: 1 / 1;
    display: block;
}
.perim-opt.perim-thumb-opt .perim-thumb-label {
    font-size: clamp(10px, 2.6vw, 13px);
    color: #8a7a68;
    font-weight: 800;
    letter-spacing: 0.03em;
}

/* ---------- responsive tuning ---------- */
@media (max-width: 380px) {
    .perim-stage { width: clamp(180px, 78vw, 260px); margin: 10px auto 4px; }
    .perim-options { gap: 5px; margin: 12px auto 4px; }
    .perim-opt { min-height: 50px; padding: 6px 3px; font-size: clamp(10px, 3.2vw, 13px); border-width: 2px; border-radius: 12px; }
    .perim-opt.perim-thumb-opt svg { width: clamp(38px, 15vw, 58px); }
}

@media (min-width: 480px) {
    .perim-opt { min-height: 64px; }
}

@media (min-width: 700px) {
    .perim-options { gap: 16px; }
    .perim-opt { min-height: 74px; font-size: 17px; }
    .perim-opt.perim-thumb-opt svg { width: clamp(60px, 9vw, 84px); }
}

@media (min-width: 900px) {
    .perim-stage { width: clamp(260px, 34vw, 340px); }
    .perim-opt { min-height: 80px; }
}

@media (max-height: 700px) {
    .perim-stage { width: clamp(180px, 46vw, 240px); margin: 8px auto 4px; }
    .perim-options { margin: 10px auto 4px; }
    .perim-opt { min-height: 48px; }
}