/**
 * Numbers Practice Widget styles.
 *
 * Brought in line with the fleet (2026-07-24): the merged header + settings
 * gear + directive-blue instruction band + task field are rendered by
 * universal-header (createExerciseLayout); pips use the shared .ex-* classes;
 * colors come from the fleet --as-* design tokens (cyan = audio, green = tap/
 * action, blue = read, amber = hint). Reference widgets: math-practice
 * (standalone/topicless container + settings-behind-gear), listening-practice
 * (cyan audio + green choice grid), naming-practice (clinician ✓/✗ pattern).
 *
 * No !important; interactive selectors prefixed with `.numbers-practice-root`
 * to beat the Elementor kit the clean way (math-practice pattern); >=44px
 * touch targets; mobile-first-ish with 768/380 breakpoints.
 */

/* ====================================================================== */
/* ROOT + CONTAINER                                                       */
/* ====================================================================== */

.numbers-practice-root {
    /* Align the merged header card to this widget's 720px container. */
    --as-header-max: 720px;
    font-family: var(--as-font);
    color: var(--as-text);
    box-sizing: border-box;
}

.numbers-practice-root *,
.numbers-practice-root *::before,
.numbers-practice-root *::after {
    box-sizing: inherit;
}

.numbers-practice-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 20px;
    background: var(--as-surface, #fff);
    border-radius: 12px;
    border: 1px solid var(--as-border, #e5e7eb);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.numbers-practice-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--as-text-muted, #64748b);
}

.numbers-practice-loading .loading-spinner {
    width: 32px;
    height: 32px;
    margin: 0 auto 12px;
    border: 3px solid var(--as-border, #e5e7eb);
    border-top-color: var(--as-read-accent, #2563eb);
    border-radius: 50%;
    animation: np-spin 0.8s linear infinite;
}

@keyframes np-spin { to { transform: rotate(360deg); } }

/* ====================================================================== */
/* STIMULUS — cyan round Play (HEAR) or big number (READ)                 */
/* ====================================================================== */

.np-stimulus {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 120px;
}

/* The target number itself is the tap-to-hear button (no visible icon). */
.numbers-practice-root .np-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    padding: 6px 14px;
    background: none;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    font-size: 48px;
    font-weight: 800;
    letter-spacing: 0.01em;
    line-height: 1.1;
    text-align: center;
    text-transform: none;
    color: var(--as-text, #1f2937);
    font-variant-numeric: tabular-nums;
    transition: background 0.12s;
}

.numbers-practice-root .np-number:hover {
    background: var(--as-audio-soft, #e0f5f9);
    color: var(--as-text, #1f2937);
}

/* Fleet audio grammar: cyan + circular, never a rectangle. */
.numbers-practice-root .np-play {
    width: 72px;
    height: 72px;
    padding: 0;
    min-width: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--as-audio-soft, #e0f5f9);
    border: 2px solid var(--as-audio, #0e9bb5);
    color: var(--as-audio-deep, #0b7e93);
    cursor: pointer;
    line-height: 1;
    text-transform: none;
    transition: box-shadow 0.15s, background 0.15s;
}

.numbers-practice-root .np-play:hover {
    background: #d3eef3;
    color: var(--as-audio-deep, #0b7e93);
    box-shadow: 0 2px 10px rgba(14, 155, 181, 0.28);
}

.numbers-practice-root .np-play.is-playing {
    animation: npAudioPulse 1.5s infinite;
}

.np-play-icon { font-size: 30px; }

@keyframes npAudioPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(14, 155, 181, 0); }
    50% { box-shadow: 0 0 0 8px rgba(14, 155, 181, 0.25); }
}

/* ====================================================================== */
/* PROGRESS — shared fleet pips (.ex-nav-pips / .ex-pip / .ex-nav-counter) */
/* ====================================================================== */

.np-progress-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 24px;
}

/* ====================================================================== */
/* ANSWER ZONE                                                            */
/* ====================================================================== */

.np-answer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 140px;
}

/* ---- Tap the number (choice grid) — green action on tap ---- */
.np-choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    width: 100%;
    max-width: 380px;
}

.numbers-practice-root .np-choice-btn {
    min-height: 64px;
    padding: 14px 12px;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--as-surface, #fff);
    border: 2px solid var(--as-border, #e5e7eb);
    border-radius: 12px;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.15;
    color: var(--as-text, #1f2937);
    font-variant-numeric: tabular-nums;
    white-space: normal;
    text-transform: none;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.numbers-practice-root .np-choice-btn:hover {
    border-color: var(--as-action-border, #10b981);
    background: var(--as-action-bg, #ecfdf5);
    color: var(--as-action-text, #047857);
}

/* ---- Type the number ---- */
.np-type {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    width: 100%;
}

.numbers-practice-root .np-input {
    width: 100%;
    max-width: 280px;
    min-height: 56px;
    padding: 0 12px;
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    color: var(--as-text, #1f2937);
    background: var(--as-surface, #fff);
    border: 2px solid var(--as-border, #e5e7eb);
    border-radius: 12px;
    font-variant-numeric: tabular-nums;
}

.numbers-practice-root .np-input:focus-visible {
    outline: 2px solid var(--as-read-accent, #2563eb);
    outline-offset: -1px;
    border-color: var(--as-border, #e5e7eb);
}

/* Primary green (Check / Next) — belt-and-suspenders over shared .ex-btn. */
.numbers-practice-root .np-check,
.numbers-practice-root .np-next {
    min-height: 48px;
    padding: 0 28px;
    min-width: 0;
    border-radius: 12px;
    background: var(--as-primary-bg, #15803d);
    border: 2px solid var(--as-primary-bg, #15803d);
    color: var(--as-primary-text, #fff);
    font-size: 16px;
    font-weight: 700;
    text-transform: none;
    cursor: pointer;
}

.numbers-practice-root .np-check:hover,
.numbers-practice-root .np-next:hover {
    background: var(--as-action-deep, #15803d);
    border-color: var(--as-action-deep, #15803d);
    color: #fff;
}

/* ---- Say it (speak / clinician / self-check) ---- */
.np-speak {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.np-speak-prompt {
    margin: 0;
    font-weight: 700;
    text-align: center;
    color: var(--as-text, #1f2937);
}

/* Speaking mic = green action (matches Naming). */
.numbers-practice-root .np-mic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 280px;
    min-height: 60px;
    padding: 0 24px;
    min-width: 0;
    background: var(--as-action-bg, #ecfdf5);
    border: 2px solid var(--as-action-border, #10b981);
    color: var(--as-action-text, #047857);
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    text-transform: none;
    cursor: pointer;
}

.numbers-practice-root .np-mic:hover {
    background: var(--as-action-bg-strong, #d1fae5);
    color: var(--as-action-text, #047857);
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.25);
}

.numbers-practice-root .np-mic.listening {
    background: var(--as-danger-bg, #fef2f2);
    border-color: #ef4444;
    color: var(--as-danger, #dc2626);
    animation: npMicPulse 1.5s infinite;
}

.np-mic-icon { font-size: 22px; }

@keyframes npMicPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.3); }
}

/* Self-check / clinician ✓ ✗ (Naming pattern). */
.np-assess-row {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 360px;
    justify-content: center;
}

.numbers-practice-root .np-assess-btn {
    flex: 1;
    min-width: 0;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 12px;
    border: 2px solid var(--as-border, #e5e7eb);
    background: var(--as-surface, #fff);
    font-size: 15px;
    font-weight: 600;
    text-transform: none;
    cursor: pointer;
}

.numbers-practice-root .np-assess-correct {
    background: var(--as-success-bg, #f0fdf4);
    border-color: #86efac;
    color: var(--as-success, #15803d);
}

.numbers-practice-root .np-assess-correct:hover {
    background: var(--as-choice-bg, #dcfce7);
    border-color: var(--as-action-border, #10b981);
    color: var(--as-success, #15803d);
}

.numbers-practice-root .np-assess-incorrect {
    background: var(--as-surface-soft, #f8fafc);
    border: 1.5px solid var(--as-border, #e5e7eb);
    color: var(--as-text-muted, #64748b);
}

.numbers-practice-root .np-assess-incorrect:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: var(--as-text-muted, #64748b);
}

.numbers-practice-root .np-hear-again {
    min-width: 0;
    padding: 4px 8px;
    background: none;
    border: none;
    color: var(--as-audio-deep, #0b7e93);
    font-size: 14px;
    font-weight: 600;
    text-transform: none;
    cursor: pointer;
}

.numbers-practice-root .np-hear-again:hover { color: var(--as-audio, #0e9bb5); }

.np-speech-err {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    color: var(--as-text-muted, #64748b);
}

.np-speech-err p { margin: 0; }

/* ---- Feedback: replaces the action in-place ---- */
.np-feedback {
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    border-radius: 12px;
    animation: npFadeIn 0.2s ease-out;
}

.np-feedback--correct {
    background: var(--as-success-bg, #f0fdf4);
    border: 2px solid #22c55e;
}

.np-feedback--incorrect {
    background: var(--as-danger-bg, #fef2f2);
    border: 2px solid #fca5a5;
}

.np-feedback-icon { font-size: 28px; line-height: 1; }
.np-feedback-text { font-size: 16px; font-weight: 600; text-align: center; }

.np-feedback--correct .np-feedback-icon,
.np-feedback--correct .np-feedback-text { color: var(--as-success, #15803d); }
.np-feedback--incorrect .np-feedback-icon,
.np-feedback--incorrect .np-feedback-text { color: var(--as-danger, #dc2626); }

@keyframes npFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ====================================================================== */
/* SETTINGS PANEL CONTENT (rendered inside .te-mh-settings by the header)  */
/* ====================================================================== */

.numbers-practice-root .np-settings-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.np-set-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.np-set-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--as-text, #1f2937);
}

.numbers-practice-root .np-select {
    min-height: 44px;
    min-width: 220px;
    padding: 0 12px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    color: #374151;
    background: var(--as-surface, #fff);
    border: 1px solid var(--as-border, #e5e7eb);
    border-radius: 8px;
}

.numbers-practice-root .np-select:hover { border-color: #cbd5e1; }
.numbers-practice-root .np-select:focus {
    outline: 2px solid var(--as-read-accent, #2563eb);
    outline-offset: -1px;
    border-color: var(--as-border, #e5e7eb);
}

.np-set-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 44px;
    font-size: 14px;
    color: var(--as-text, #1f2937);
    cursor: pointer;
}

.np-set-toggle input { width: 20px; height: 20px; flex: 0 0 auto; }

/* ====================================================================== */
/* COMPLETE + FALLBACK                                                    */
/* ====================================================================== */

.np-complete { text-align: center; padding: 24px 16px; }
.np-empty { text-align: center; padding: 40px 20px; color: var(--as-text-muted, #64748b); }

.np-fallback-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0 12px;
}

.numbers-practice-root .np-fallback-gear {
    min-width: 44px;
    min-height: 44px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
}

/* ====================================================================== */
/* RESPONSIVE                                                             */
/* ====================================================================== */

@media (max-width: 768px) {
    /* universal-header stacks the layout to a column at <=768 but leaves
       .te-main-col content-width (it doesn't stretch), so a topicless widget
       renders cramped/narrow. Force the column full-width for this widget. */
    .numbers-practice-root .te-main-col { width: 100%; }

    .numbers-practice-container { padding: 14px; gap: 12px; }
    .numbers-practice-root .np-number { font-size: 40px; }
    .numbers-practice-root .np-play { width: 64px; height: 64px; }
    .np-play-icon { font-size: 26px; }
}

@media (max-width: 380px) {
    .numbers-practice-root .np-number { font-size: 34px; }
    .numbers-practice-root .np-choice-btn { font-size: 20px; min-height: 60px; }
}

@media (prefers-reduced-motion: reduce) {
    .numbers-practice-root .np-play.is-playing,
    .numbers-practice-root .np-mic.listening { animation: none; }
    .np-feedback { animation: none; }
    .numbers-practice-root .np-choice-btn { transition: none; }
}

/* ====================================================================== */
/* HINT LADDER (amber; one escalating button + fixed hint zone)          */
/* ====================================================================== */

/* Fixed-height zone so escalating a rung never shifts the layout. */
.np-hint-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60px;
    padding: 4px 0;
}

/* Rung 1 replay + chunk chips + reveal all sit inside the amber family. */
.numbers-practice-root .np-hint-replay {
    min-height: 44px;
    min-width: 0;
    padding: 0 16px;
    border-radius: 10px;
    border: 1.5px solid var(--as-hint-border, #ca8a04);
    background: var(--as-hint-bg-soft, #fffbeb);
    color: var(--as-hint-text, #92400e);
    font-size: 1rem;
    font-weight: 600;
    text-transform: none;
    cursor: pointer;
}
.numbers-practice-root .np-hint-replay:hover {
    background: var(--as-hint-bg, #fef3c7);
    color: var(--as-hint-text, #92400e);
}

/* Rung 2 — chunk chips, each tappable to hear that part. */
.np-hint-chunks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: center;
}
.numbers-practice-root .np-hint-chip {
    min-height: 44px;
    min-width: 0;
    padding: 0 14px;
    border-radius: 999px;
    border: 1.5px solid var(--as-hint-border, #ca8a04);
    background: var(--as-hint-bg, #fef3c7);
    color: var(--as-hint-text, #92400e);
    font-size: 1.15rem;
    font-weight: 700;
    text-transform: none;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}
.numbers-practice-root .np-hint-chip:hover {
    background: #fde68a;
    color: var(--as-hint-text, #92400e);
}

/* Rung 3 — terminal reveal (type/say). */
.np-hint-answer {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--as-hint-text, #92400e);
    text-align: center;
}
.np-hint-answerbox {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.np-hint-label {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--as-text-muted, #64748b);
    text-transform: uppercase;
}
.np-hint-say {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--as-text, #1f2937);
}
.np-hint-big {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--as-primary, #185fa5);
    font-variant-numeric: tabular-nums;
}
.np-hint-tiles {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.np-htile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 40px;
    padding: 0 4px;
    border-radius: 8px;
    border: 2px solid var(--as-hint-border, #ca8a04);
    background: var(--as-hint-bg-soft, #fffbeb);
    color: var(--as-text, #1f2937);
    font-size: 1.5rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.np-hsep {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--as-text-muted, #64748b);
    padding: 0 1px;
}

/* Correct tile glows when 'Show answer' is reached in a tap mode. */
.numbers-practice-root .np-choice-btn.np-choice-answer {
    border-color: var(--as-hint-border, #ca8a04);
    background: var(--as-hint-bg-soft, #fffbeb);
    box-shadow: 0 0 0 3px rgba(202, 138, 4, 0.25);
}

/* The one hint button — amber, in a centered help row at the bottom. */
.np-help-row {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 48px;
}
.numbers-practice-root .np-hint-btn {
    min-height: 44px;
    min-width: 0;
    padding: 0 18px;
    border-radius: 999px;
    border: 1.5px solid var(--as-hint-border, #ca8a04);
    background: var(--as-hint-bg, #fef3c7);
    color: var(--as-hint-text, #92400e);
    font-size: 1rem;
    font-weight: 700;
    text-transform: none;
    cursor: pointer;
}
.numbers-practice-root .np-hint-btn:hover {
    background: #fde68a;
    color: var(--as-hint-text, #92400e);
}

@media (prefers-reduced-motion: reduce) {
    .numbers-practice-root .np-choice-btn.np-choice-answer { box-shadow: none; }
}

/* ============================================================
   Desktop size pass (2026-08-17, Lyda: "nice and big").
   769px+ covers tablet landscape + desktop — iPad is a primary
   device, so it gets the big numerals too.
   ============================================================ */
@media (min-width: 769px) {
    .numbers-practice-root .np-stimulus {
        min-height: 170px;
    }
    .numbers-practice-root .np-number {
        font-size: 88px;
        padding: 10px 24px;
    }
    .numbers-practice-root .np-input {
        font-size: 36px;
    }
    .numbers-practice-root .np-choice-btn {
        font-size: 30px;
    }
    .numbers-practice-root .np-hint-big {
        font-size: 2rem;
    }
    .numbers-practice-root .np-htile {
        font-size: 1.9rem;
    }
}

/* Empty typing field = the "type here" invitation (Lyda 08-17): darker outline
   shadow + a gentle pulse while empty and unfocused. The input carries a
   single-space placeholder purely so :placeholder-shown can target emptiness. */
.numbers-practice-root .np-input:placeholder-shown:not(:focus) {
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25);
    animation: np-input-invite 2s ease-in-out infinite;
}
@keyframes np-input-invite {
    0%, 100% { box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25); }
    50%      { box-shadow: 0 3px 14px rgba(15, 23, 42, 0.40); }
}
@media (prefers-reduced-motion: reduce) {
    .numbers-practice-root .np-input:placeholder-shown:not(:focus) {
        animation: none;
    }
}

/* Review-mode chip (§1.1-1.2, letters template). */
.numbers-practice-container .np-review-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #2563eb;
    background: #dbeafe;
    border-radius: 999px;
    padding: 4px 12px;
    white-space: nowrap;
}
