/* ================================================================
   decimal-fraction-unified.css
   ----------------------------------------------------------------
   Styles for the "Decimals, Fractions, and Place Value Unified"
   skill group on the Class 4 Math page:

     - A.1  Decimal <-> Fraction Conversion (Visual, both directions)
            — the same shaded 10-strip or 100-grid shown alongside
            EITHER a fraction OR a decimal label (direction is
            random each question); the child picks the matching
            value in the other notation. A small looping "slide"
            pill under the feedback reinforces that the fraction and
            the decimal are one amount, two spellings (new
            .dfu-bridge-* classes).

     - A.2  Decimal <-> Percent Preview — the same 100-grid used for
            hundredths, doubling as a percent grid; the child
            matches a shaded amount to a decimal or a percent (new
            .dfu-percent-* classes).

     - A.3  Rounding by Zooming — a magnified segment of a number
            line between two neighboring tenths benchmarks (e.g.
            2.3 to 2.4) with a marker dropped at a hundredths value;
            the child picks which benchmark the marker sits closer
            to, reasoning from the picture rather than a digit rule
            (new .dfu-zoom-* 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 "dfu-" prefixed classes (including its own
   answer-chip wrapper, .dfu-picker) instead of reusing any other
   skill file's markup, 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/decimal-fraction-unified.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,
   phone included — each .dfu-opt is a flexible (not fixed-width)
   item so the row shrinks to fit instead of wrapping. */
.dfu-picker {
    display: flex;
    align-items: stretch;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 10px;
    margin: 18px auto 4px;
    width: 100%;
    max-width: 380px;
}
.dfu-opt {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    min-width: 0;
    max-width: 160px;
    padding: 12px 8px;
    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: 16px;
    color: var(--secondary);
    text-align: center;
    line-height: 1.2;
}
.quiz-number-opt.dfu-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.dfu-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: caption + "given value" label ---------- */
.dfu-caption {
    font-weight: 700;
    font-size: 13.5px;
    color: var(--text);
    text-align: center;
    max-width: 300px;
}
.dfu-given {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 2px auto 0;
    font-weight: 800;
    color: var(--secondary);
}
.dfu-given-decimal {
    font-size: 26px;
    letter-spacing: 0.01em;
}
.dfu-given-percent {
    font-size: 26px;
    letter-spacing: 0.01em;
}
.dfu-given-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text);
    opacity: 0.65;
}
.dfu-given-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

/* stacked fraction display, e.g. 7 over a line over 10 */
.dfu-fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    font-size: 22px;
    font-weight: 800;
}
.dfu-fraction .dfu-num,
.dfu-fraction .dfu-den {
    padding: 1px 4px;
}
.dfu-fraction .dfu-frac-line {
    width: 100%;
    height: 3px;
    background: var(--secondary);
    border-radius: 2px;
    margin: 2px 0;
}

/* ================================================================
   A.1 Decimal <-> Fraction Conversion (Visual, both directions)
   ================================================================ */
.dfu-bridge-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: 14px auto 6px;
}
.dfu-bridge-bar {
    display: flex;
    width: min(320px, 90%);
    height: 56px;
    border-radius: 12px;
    overflow: hidden;
    border: 3px solid var(--line);
    background: #fff;
}
.dfu-bridge-seg {
    flex: 1 1 0;
    border-right: 2px solid var(--line);
    background: transparent;
}
.dfu-bridge-seg:last-child { border-right: none; }
.dfu-bridge-seg.is-shaded { background: var(--sun); }

.dfu-bridge-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    gap: 1px;
    background: var(--line);
    border: 2px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    width: 200px;
    height: 200px;
}
.dfu-bridge-cell { background: #fff; }
.dfu-bridge-cell.is-shaded { background: var(--sun); }

/* the looping "slide" pill shown in the feedback area once a
   question is answered — a purely visual reinforcement that the
   fraction and the decimal are the same amount, two spellings. */
.dfu-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 10px auto 0;
    padding: 6px 10px;
    max-width: 260px;
    border-radius: 999px;
    background: rgba(46,155,245,0.08);
    border: 1px solid var(--line);
}
.dfu-slide-value {
    font-weight: 800;
    font-size: 15px;
    color: var(--secondary);
    min-width: 64px;
    text-align: center;
    transition: opacity .5s ease, transform .5s ease;
}
.dfu-slide-arrow {
    font-size: 13px;
    color: var(--text);
    opacity: 0.55;
    position: relative;
    width: 28px;
    height: 14px;
    overflow: hidden;
}
.dfu-slide-arrow::before {
    content: "\21c4";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    animation: dfuSlidePulse 2.2s ease-in-out infinite;
    display: inline-block;
}
@keyframes dfuSlidePulse {
    0%   { transform: translate(-50%, -50%) scale(1); opacity: 0.55; }
    50%  { transform: translate(-70%, -50%) scale(1.15); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0.55; }
}
.dfu-slide.is-animating .dfu-slide-value.left  { animation: dfuSlideLeft 2.2s ease-in-out infinite; }
.dfu-slide.is-animating .dfu-slide-value.right { animation: dfuSlideRight 2.2s ease-in-out infinite; }
@keyframes dfuSlideLeft {
    0%, 100% { opacity: 1; transform: translateX(0); }
    50%      { opacity: 0.45; transform: translateX(-4px); }
}
@keyframes dfuSlideRight {
    0%, 100% { opacity: 0.45; transform: translateX(4px); }
    50%      { opacity: 1; transform: translateX(0); }
}

/* ================================================================
   A.2 Decimal <-> Percent Preview
   ================================================================ */
.dfu-percent-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: 14px auto 6px;
}
.dfu-percent-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    gap: 1px;
    background: var(--line);
    border: 2px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    width: 200px;
    height: 200px;
}
.dfu-percent-cell { background: #fff; }
.dfu-percent-cell.is-shaded { background: var(--purple); }
.dfu-percent-badge {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text);
    opacity: 0.6;
}

/* ================================================================
   A.3 Rounding by Zooming
   ================================================================ */
.dfu-zoom-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 26px auto 14px;
    width: 100%;
}
.dfu-zoom-line {
    position: relative;
    width: min(340px, 90%);
    height: 90px;
}
.dfu-zoom-track {
    position: absolute;
    left: 0; right: 0; top: 40px;
    height: 5px;
    border-radius: 3px;
    background: var(--secondary);
    opacity: 0.28;
}
.dfu-zoom-end {
    position: absolute;
    top: 28px;
    width: 3px;
    height: 30px;
    border-radius: 2px;
    background: var(--secondary);
    opacity: 0.85;
    transform: translateX(-1.5px);
}
.dfu-zoom-half {
    position: absolute;
    top: 32px;
    width: 2px;
    height: 22px;
    border-radius: 1px;
    background: var(--secondary);
    opacity: 0.3;
    transform: translateX(-1px);
    border-left: 2px dashed var(--secondary);
    background: transparent;
}
.dfu-zoom-label {
    position: absolute;
    top: 60px;
    transform: translateX(-50%);
    font-weight: 800;
    font-size: 14px;
    color: var(--secondary);
}
.dfu-zoom-half-label {
    position: absolute;
    top: 6px;
    transform: translateX(-50%);
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text);
    opacity: 0.55;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.dfu-zoom-marker {
    position: absolute;
    top: 20px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--pink);
    border: 3px solid #fff;
    box-shadow: 0 0 0 2px var(--pink);
    transform: translate(-50%, 0);
}
.dfu-zoom-marker-label {
    position: absolute;
    top: -22px;
    transform: translateX(-50%);
    font-weight: 800;
    font-size: 14px;
    color: var(--pink);
    white-space: nowrap;
}

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

    .dfu-bridge-bar { height: 44px; }
    .dfu-bridge-grid { width: 160px; height: 160px; }
    .dfu-percent-grid { width: 160px; height: 160px; }

    .dfu-given-decimal, .dfu-given-percent { font-size: 22px; }
    .dfu-fraction { font-size: 19px; }

    .dfu-slide { max-width: 220px; padding: 5px 8px; gap: 8px; }
    .dfu-slide-value { font-size: 13.5px; min-width: 54px; }

    .dfu-zoom-line { height: 78px; }
    .dfu-zoom-track { top: 34px; }
    .dfu-zoom-end { top: 24px; height: 26px; }
    .dfu-zoom-half { top: 27px; height: 20px; }
    .dfu-zoom-label { top: 52px; font-size: 12.5px; }
    .dfu-zoom-half-label { top: 4px; font-size: 9.5px; }
    .dfu-zoom-marker { width: 15px; height: 15px; top: 17px; }
    .dfu-zoom-marker-label { top: -19px; font-size: 12.5px; }
}
@media (max-width: 380px) {
    .dfu-picker { gap: 6px; max-width: 280px; }
    .dfu-opt { padding: 7px 4px; font-size: 13px; }

    .dfu-bridge-grid { width: 136px; height: 136px; }
    .dfu-percent-grid { width: 136px; height: 136px; }

    .dfu-given-decimal, .dfu-given-percent { font-size: 19px; }
    .dfu-fraction { font-size: 16px; }

    .dfu-zoom-line { height: 70px; }
    .dfu-zoom-label { font-size: 11.5px; }
    .dfu-zoom-marker-label { font-size: 11.5px; }
}
@media (max-width: 340px) {
    .dfu-picker { gap: 5px; max-width: 260px; }
    .dfu-opt { padding: 6px 3px; font-size: 12px; min-height: 42px !important; }
}