/* ================================================================
   grid-area-counting.css
   ----------------------------------------------------------------
   Styling for the "Counting Squares (Grid-based Area)" skill
   quizzes on the Class 5 Math page:

     - B.1 Grid Cover-Up            (.grid-stage)
     - B.2 Half-Squares & Almost-Squares (.grid-stage, half-cell triangles)
     - B.3 Build a Shape With N Squares  (.grid-stage)
     - B.4 Compare by Counting      (.grid-compare-stage / .grid-compare-pane)
     - B.5 Real Object Grids        (.grid-stage, themed cell fills)

   Independent stylesheet (own "grid-" prefixed classes, does not
   reuse area-foundations.css's ".area-*" classes) but mirrors the
   same bordered "stage" card language (rings green/red via
   .is-correct/.is-wrong once graded) and the same shared answer-chip
   row: a 4-column CSS Grid \u2014 not a wrapping flex row \u2014 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 every other skill's CSS.
   ================================================================ */

/* ---------- shared visual "stage" (single-shape skills: B.1, B.2, B.3, B.5) ---------- */
.grid-stage {
    width: clamp(220px, 74vw, 340px);
    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;
}
.grid-stage.is-correct {
    border-color: #22c08d;
    box-shadow: 0 0 0 4px rgba(34,192,141,0.18);
}
.grid-stage.is-wrong {
    border-color: #f5427d;
    box-shadow: 0 0 0 4px rgba(245,66,125,0.15);
}
.grid-stage svg {
    width: 92%;
    height: 92%;
    display: block;
}

/* ---------- two-shape comparison "stage" (B.4) ----------
   Same border/ring/shadow language as .grid-stage so it reads as the
   same family of card, but wider and split into two side-by-side
   panes instead of one square. */
.grid-compare-stage {
    width: clamp(240px, 86vw, 480px);
    min-height: clamp(160px, 50vw, 250px);
    margin: 14px auto 6px;
    border: 3px solid var(--line);
    border-radius: 20px;
    background: var(--bg-light);
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: clamp(6px, 2vw, 16px);
    padding: clamp(8px, 2.5vw, 16px);
    box-shadow: 0 4px 0 rgba(0,0,0,0.06);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
    overflow: hidden;
}
.grid-compare-stage.is-correct {
    border-color: #22c08d;
    box-shadow: 0 0 0 4px rgba(34,192,141,0.18);
}
.grid-compare-stage.is-wrong {
    border-color: #f5427d;
    box-shadow: 0 0 0 4px rgba(245,66,125,0.15);
}
.grid-compare-pane {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
}
.grid-compare-pane svg {
    width: 100%;
    height: auto;
    max-height: clamp(140px, 42vw, 220px);
    display: block;
}
.grid-compare-divider {
    width: 2px;
    align-self: stretch;
    background: repeating-linear-gradient(to bottom, #d7dee6 0, #d7dee6 6px, transparent 6px, transparent 12px);
    flex: 0 0 2px;
}
.grid-compare-label {
    margin-top: 6px;
    font-size: clamp(11px, 3vw, 14px);
    font-weight: 800;
    color: #8a7a68;
    letter-spacing: 0.03em;
}

/* ---------- shared grid-paper lines (all five skills) ---------- */
.grid-line {
    stroke: #cfd8e3;
    stroke-width: 1;
}
.grid-bounds {
    fill: none;
    stroke: #b7c2cf;
    stroke-width: 1.5;
}

/* ---------- B.1 Grid Cover-Up: plain full unit-cell fills ---------- */
.grid-cell-full {
    fill: #7ecbff;
    stroke: #4a90c9;
    stroke-width: 1.2;
}

/* ---------- B.2 Half-Squares & Almost-Squares ---------- */
.grid-cell-half {
    fill: #ffb672;
    stroke: #d9863a;
    stroke-width: 1.2;
    stroke-linejoin: round;
}

/* ---------- B.3 Build a Shape With N Squares ---------- */
.grid-cell-build {
    fill: #8fe0b8;
    stroke: #33a874;
    stroke-width: 1.2;
}

/* ---------- B.4 Compare by Counting (two independently-colored shapes) ---------- */
.grid-cell-compare-a {
    fill: #7ecbff;
    stroke: #4a90c9;
    stroke-width: 1;
}
.grid-cell-compare-b {
    fill: #c8a2f0;
    stroke: #9463cf;
    stroke-width: 1;
}

/* ---------- B.5 Real Object Grids (themed fills per object) ---------- */
.grid-cell-rug {
    fill: #ff8fa3;
    stroke: #d84f6b;
    stroke-width: 1.2;
}
.grid-cell-garden {
    fill: #94d97e;
    stroke: #4f9e3a;
    stroke-width: 1.2;
}
.grid-cell-frame {
    fill: #f0c96e;
    stroke: #c99a2e;
    stroke-width: 1.2;
}

/* ---------- shared answer-chip row (all five skills' chips) ----------
   4-column grid = guaranteed single line at every width; never
   switches to flex-wrap, so the four chips can't stack. */
.grid-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: clamp(6px, 2vw, 14px);
    width: 100%;
    max-width: 580px;
    margin: 18px auto 4px;
}
.grid-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;
}
.grid-opt:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 0 rgba(0,0,0,0.08);
}
.grid-opt:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}
.grid-opt:focus-visible {
    outline: 3px solid #4a90e2;
    outline-offset: 2px;
}
.grid-opt:disabled { cursor: default; }
.grid-opt.is-correct {
    border-color: #22c08d;
    background: #eafff6;
    box-shadow: 0 0 0 4px rgba(34,192,141,0.18);
}
.grid-opt.is-wrong {
    border-color: #f5427d;
    background: #fff0f4;
    box-shadow: 0 0 0 4px rgba(245,66,125,0.15);
}

/* Number chips (B.1, B.2, B.5) can afford slightly larger digits since
   the label is always short. */
.grid-opt.grid-opt-number {
    font-size: clamp(14px, 4.4vw, 20px);
    font-weight: 800;
}

/* ---------- responsive tuning ---------- */
@media (max-width: 380px) {
    .grid-stage { width: clamp(180px, 80vw, 270px); margin: 10px auto 4px; }
    .grid-compare-stage { min-height: clamp(130px, 46vw, 195px); padding: 6px; gap: 4px; margin: 10px auto 4px; }
    .grid-compare-pane svg { max-height: clamp(110px, 38vw, 175px); }
    .grid-options { gap: 5px; margin: 12px auto 4px; }
    .grid-opt { min-height: 50px; padding: 6px 3px; font-size: clamp(10px, 3.2vw, 13px); border-width: 2px; border-radius: 12px; }
    .grid-opt.grid-opt-number { font-size: clamp(13px, 4.2vw, 18px); }
}

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

@media (min-width: 700px) {
    .grid-options { gap: 16px; }
    .grid-opt { min-height: 74px; font-size: 17px; }
    .grid-opt.grid-opt-number { font-size: 21px; }
    .grid-compare-pane svg { max-height: clamp(180px, 26vw, 250px); }
}

@media (min-width: 900px) {
    .grid-stage { width: clamp(270px, 36vw, 360px); }
    .grid-compare-stage { width: clamp(340px, 46vw, 540px); }
    .grid-opt { min-height: 80px; }
}

@media (max-height: 700px) {
    .grid-stage { width: clamp(180px, 48vw, 250px); margin: 8px auto 4px; }
    .grid-compare-stage { min-height: clamp(130px, 34vw, 185px); margin: 8px auto 4px; }
    .grid-options { margin: 10px auto 4px; }
    .grid-opt { min-height: 48px; }
}