/* Chinese reading-speed test — /tools/reading-speed (growth plan D84).

   Colour comes from Bootstrap variables so both themes work without a second palette, the way
   vocabulary-test.css does it. Every animation here is decoration and is switched off under
   prefers-reduced-motion at the bottom of the file — the test is fully usable with none of it. */

.rs-stage {
    min-height: 22rem;
}

/* ── Level picker ─────────────────────────────────────────────────────────────────────── */

.rs-level {
    display: block;
    width: 100%;
    text-align: left;
    border: 2px solid var(--bs-border-color);
    border-radius: 0.75rem;
    background-color: var(--bs-body-bg);
    color: inherit;
    padding: 0.85rem 1rem;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.rs-level:hover {
    border-color: var(--bs-primary);
    transform: translateY(-2px);
}

.rs-level-on {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.2);
}

.rs-level-rank {
    font-weight: 700;
    font-size: 1.05rem;
}

.rs-level-meta {
    font-size: 0.8rem;
    opacity: 0.75;
}

/* Expert mode. Selectable, but set apart from the four levels: it is the top rung read strictly,
   not a fifth rung, and choosing it awards nothing by itself. */
.rs-level-expert {
    border-style: dashed;
    background-image: linear-gradient(135deg, rgba(13, 110, 253, 0.06), rgba(102, 16, 242, 0.08));
}

.rs-level-expert.rs-level-on {
    border-style: solid;
    border-color: #6610f2;
    box-shadow: 0 0 0 0.2rem rgba(102, 16, 242, 0.2);
}

.rs-level-expert .fa-trophy {
    color: #6610f2;
}

.rs-pinyin-option .form-check-input:disabled ~ .form-check-label {
    opacity: 0.6;
}

/* "This is a reading test, not a speaking test" — set apart from the picker without an alert
   colour, because it is information rather than a warning. */
.rs-speaking-note {
    border-left: 4px solid var(--bs-info);
    background-color: var(--bs-tertiary-bg);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
}

/* ── Countdown ────────────────────────────────────────────────────────────────────────── */

.rs-countdown {
    min-height: 16rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rs-count-num {
    font-size: clamp(4rem, 22vw, 8rem);
    font-weight: 700;
    line-height: 1;
    color: var(--bs-primary);
}

/* ── The passage ──────────────────────────────────────────────────────────────────────── */

/* Sized for reading rather than for display: a reading-speed figure measured on 14px text in a
   narrow column is not a reading speed anybody can compare with anything. */
.rs-passage {
    font-size: clamp(1.25rem, 3.4vw, 1.6rem);
    line-height: 2;
    letter-spacing: 0.02em;
    max-width: 38rem;
    margin: 0 auto;
    text-align: left;
}

.rs-passage p {
    margin-bottom: 0.65rem;
}

/* Pinyin under the characters. The ruby markup is always there; the switch toggles
   .rs-show-pinyin on the stage and the <rt> is hidden without it, so switching mid-passage never
   re-renders the text. Under rather than over, so the eye keeps landing on the hanzi first. */
.rs-ruby-host ruby {
    ruby-position: under;
    -webkit-ruby-position: after;
}

.rs-ruby-host rt {
    font-size: 0.5em;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--bs-secondary-color);
}

.rs-ruby-host:not(.rs-show-pinyin) rt {
    display: none;
}

.rs-show-pinyin .rs-passage {
    line-height: 2.6;
}

.rs-line {
    animation: rs-fade-in 0.35s ease both;
}

@keyframes rs-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

.rs-clock {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 1.5rem;
}

/* The pace bar: fills over the time this passage would take at its level's promotion pace. A
   target, not a limit — running past it turns it amber and costs nothing but the promotion. */
.rs-pace-track {
    height: 0.6rem;
    background-color: var(--bs-secondary-bg);
    border-radius: 999px;
    overflow: hidden;
}

.rs-pace-fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--bs-success), var(--bs-primary));
    transition: width 0.1s linear, background 0.4s ease;
}

.rs-pace-over {
    background: linear-gradient(90deg, var(--bs-warning), var(--bs-danger));
}

/* ── Questions ────────────────────────────────────────────────────────────────────────── */

.rs-option {
    display: block;
    width: 100%;
    text-align: left;
    margin-bottom: 0.5rem;
    padding: 0.7rem 0.9rem;
}

.rs-option-key {
    display: inline-block;
    min-width: 1.6rem;
    margin-right: 0.6rem;
    font-weight: 700;
    opacity: 0.6;
}

.rs-right {
    background-color: var(--bs-success) !important;
    border-color: var(--bs-success) !important;
    color: #fff !important;
    opacity: 1 !important;
    animation: rs-flash 0.45s ease;
}

.rs-wrong {
    background-color: var(--bs-danger) !important;
    border-color: var(--bs-danger) !important;
    color: #fff !important;
    opacity: 1 !important;
    animation: rs-shake 0.4s ease;
}

@keyframes rs-flash {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.03); }
    100% { transform: scale(1); }
}

@keyframes rs-shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-5px); }
    75%      { transform: translateX(5px); }
}

/* ── Verdict ──────────────────────────────────────────────────────────────────────────── */

.rs-verdict {
    border-left: 5px solid var(--bs-border-color);
    animation: rs-slide-in 0.35s ease both;
}

.rs-verdict-good { border-left-color: var(--bs-success); }
.rs-verdict-warn { border-left-color: var(--bs-warning); }

.rs-verdict-icon {
    font-size: 1.6rem;
}

.rs-verdict-good .rs-verdict-icon { color: var(--bs-success); }
.rs-verdict-warn .rs-verdict-icon { color: var(--bs-warning); }

.rs-verdict-cpm {
    font-size: 1.9rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

@keyframes rs-slide-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

.rs-review-line {
    margin-bottom: 0.5rem;
    line-height: 1.7;
}

.rs-key {
    margin: 0 0.35rem 0.35rem 0;
}

/* ── Result ───────────────────────────────────────────────────────────────────────────── */

.rs-gauge {
    width: 100%;
    max-width: 17rem;
    height: auto;
    display: block;
    margin: 0 auto;
}

.rs-gauge-track {
    stroke: var(--bs-secondary-bg);
}

.rs-gauge-arc {
    stroke: url(#rsGaugeGradient);
    stroke-linecap: round;
}

.rs-gauge-needle {
    transform-origin: 100px 100px;
    transform: rotate(-135deg);
    stroke: var(--bs-body-color);
}

.rs-cpm {
    font-size: clamp(3rem, 14vw, 4.75rem);
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.rs-rank {
    display: inline-block;
    font-size: clamp(1.5rem, 6vw, 2.1rem);
    font-weight: 700;
    letter-spacing: 0.01em;
    padding: 0.35rem 1.25rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #0d6efd, #6610f2);
    color: #fff;
}

.rs-pop {
    animation: rs-pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

@keyframes rs-pop {
    from { opacity: 0; transform: scale(0.7); }
    to   { opacity: 1; transform: scale(1); }
}

/* The rank ladder printed on the results screen and in the explanation. */
.rs-ladder {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.rs-ladder li {
    flex: 1 1 6rem;
    text-align: center;
    padding: 0.4rem 0.3rem;
    border-radius: 0.5rem;
    background-color: var(--bs-secondary-bg);
    font-size: 0.85rem;
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    .rs-line,
    .rs-verdict,
    .rs-pop,
    .rs-right,
    .rs-wrong {
        animation: none !important;
    }

    .rs-level,
    .rs-pace-fill,
    .rs-gauge-arc,
    .rs-gauge-needle {
        transition: none !important;
    }

    .rs-level:hover {
        transform: none;
    }
}
