/**
 * IELTS LMS — Mobile App Experience
 * ====================================
 * Transforms all module & mock-test pages into a native-app-like experience on mobile.
 * Loaded on: reading, listening, writing, speaking templates + mock hub
 *
 * Design principles
 *   1. Safe-area-inset awareness (iOS notch + home bar)
 *   2. 44 px minimum touch targets everywhere
 *   3. Glass / backdrop-blur chrome (top bar, bottom bar, modals)
 *   4. Tactile feedback via subtle scale + shadow transitions
 *   5. Bottom-sheet modals instead of centered overlays on mobile
 *   6. Native scroll momentum + overscroll-behavior containment
 *   7. System-status-bar colour via theme-color meta (handled in template)
 */

/* =====================================================================
   1. ROOT TOKENS — mobile-only overrides
   ===================================================================== */
@media (max-width: 768px) {
    :root {
        /* Safe-area shims — real values provided by the browser if supported */
        --ielts-safe-top:    env(safe-area-inset-top, 0px);
        --ielts-safe-bottom: env(safe-area-inset-bottom, 0px);
        --ielts-safe-left:   env(safe-area-inset-left, 0px);
        --ielts-safe-right:  env(safe-area-inset-right, 0px);

        /* App shell dimensions */
        --ielts-app-header-height: 52px;
        --ielts-app-footer-height: 56px;

        /* Typography scale-down for small screens */
        --ielts-lms-text-base: 15px;
        --ielts-lms-text-sm:   13px;
    }
}

/* =====================================================================
   2. GLOBAL APP SHELL — body & html in standalone test mode
   ===================================================================== */
@media (max-width: 768px) {
    /* Disable iOS long-press / double-tap highlight on UI chrome */
    .ielts-final-wrapper,
    .ielts-top-bar,
    .ielts-pagination-footer,
    .ielts-prestart-layout,
    .ielts-mock-fullscreen-shell,
    .imh-wrap,
    .imh-entry-wrap,
    .ielts-mock-step-shell {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }

    /* Prevent body bounce on iOS while the test is running — ONLY in runtime shell context */
    body.ielts-mock-standalone--runtime.ielts-focus-active {
        overscroll-behavior: none;
        position: fixed;
        width: 100%;
    }

    /* In shortcode and hub contexts, allow normal scrolling but prevent iOS bouncing */
    body.ielts-focus-active:not(.ielts-mock-standalone--runtime) {
        overscroll-behavior: none;
        position: relative;
        width: 100%;
    }

    /* Smooth momentum scroll for scrollable areas */
    .ielts-passage-text,
    .ielts-question-area,
    .processed-questions-container,
    .ielts-writing-editor-area,
    .ielts-screen-content,
    .ielts-part-content {
        overscroll-behavior-y: contain;
    }

    /* Disable text selection on buttons and nav chrome */
    .ielts-top-bar button,
    .ielts-pagination-footer button,
    .palette-btn,
    .part-box {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Tap response on every interactive element */
    .ielts-final-wrapper button:active,
    .ielts-final-wrapper a:active,
    .palette-btn:active,
    .part-box:active,
    .ielts-btn:active {
        transform: scale(0.95);
        transition: transform 80ms ease;
    }

    /* Touch optimisation — remove 300 ms tap delay */
    .ielts-final-wrapper button,
    .ielts-final-wrapper a,
    .ielts-pagination-footer button {
        touch-action: manipulation;
    }
}

/* =====================================================================
   3. APP HEADER (top bar) — glass morphism + safe-area-inset-top
   ===================================================================== */
@media (max-width: 768px) {

    /* The header itself — add glass effect WITHOUT fighting existing height !important */
    .ielts-final-wrapper .ielts-top-bar,
    .ielts-final-wrapper .ielts-widget-header {
        /* Glass chrome — uses !important to override module-specific backgrounds */
        background: rgba(255, 255, 255, 0.88) !important;
        -webkit-backdrop-filter: blur(20px) saturate(160%);
        backdrop-filter: blur(20px) saturate(160%);
        border-bottom: 1px solid rgba(226, 232, 240, 0.8) !important;
        box-shadow: 0 1px 0 rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04) !important;

        /* Safe-area: push down from notch / status bar */
        padding-top: calc(4px + var(--ielts-safe-top, 0px)) !important;
    }

    /* Title */
    .ielts-top-bar-title {
        font-size: 15px;
        font-weight: 700;
        letter-spacing: -0.01em;
        color: #0f172a;
    }

    /* Timer */
    .ielts-timer-display {
        font-size: 15px;
        font-weight: 800;
        gap: 4px;
    }

    /* Right icon buttons — 40 × 40 circle tappable area */
    .ielts-top-bar-right .ielts-review-button,
    .ielts-top-bar-right .icon-btn-toggle {
        width: 40px;
        height: 40px;
        min-height: 40px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Submit button — green pill */
    .ielts-final-answer-button {
        border-radius: 20px;
        font-weight: 700;
        background: linear-gradient(135deg, #10b981, #059669);
        color: #fff;
        border: none;
        box-shadow: 0 2px 8px rgba(16,185,129,0.3);
    }
}

/* =====================================================================
   4. APP BOTTOM BAR — safe-area-inset-bottom + glass
   ===================================================================== */
@media (max-width: 768px) {
    .ielts-pagination-footer {
        /* Add home-bar safe area */
        padding-bottom: calc(8px + var(--ielts-safe-bottom, 0px));
        height: calc(var(--ielts-app-footer-height, 56px) + var(--ielts-safe-bottom, 0px));

        /* Glass */
        background: rgba(255, 255, 255, 0.9);
        -webkit-backdrop-filter: blur(20px) saturate(160%);
        backdrop-filter: blur(20px) saturate(160%);
        border-top: 1px solid rgba(226, 232, 240, 0.8);
        box-shadow: 0 -2px 12px rgba(0,0,0,0.06);

        /* Ensure it stays above home indicator */
        padding-left: calc(10px + var(--ielts-safe-left, 0px));
        padding-right: calc(10px + var(--ielts-safe-right, 0px));
    }

    /* Adjust content padding to account for taller footer */
    .ielts-final-wrapper.test-started .ielts-main-interface-container {
        padding-bottom: calc(var(--ielts-app-footer-height, 56px) + var(--ielts-safe-bottom, 0px)) !important;
    }
}

/* =====================================================================
   5. READING / LISTENING — split panel mobile UX
   ===================================================================== */
@media (max-width: 768px) {

    /* Panel labels shown at the top of each panel — app-like tab indicator */
    .ielts-final-wrapper .ielts-final-container::before {
        content: '';
        display: block;
    }

    /* Drag handle — keep centering for the SVG icon (height/rotation fixed in reading.css) */
    .ielts-final-wrapper .ielts-final-dragger {
        align-items: center;
        justify-content: center;
    }

    /* Ensure SVG icon is visible and centred; no rotation override needed (fixed in reading.css) */
    .ielts-final-wrapper .ielts-final-dragger::before {
        width: 24px !important;
        height: 24px !important;
        border-radius: 0 !important;
        display: block !important;
    }

    /* Passage text — comfortable reading on mobile */
    .ielts-passage-text {
        font-size: 15px;
        line-height: 1.8;
        color: #1e293b;
    }
}

/* =====================================================================
   6. WRITING — task pill tabs + editor improvements
   ===================================================================== */
@media (max-width: 768px) {

    /* Writing drag handle — keep centering (height/rotation fixed in writing.css) */
    .ielts-final-wrapper .ielts-writing-dragger {
        background: #f1f5f9;
        align-items: center;
        justify-content: center;
    }

    /* Textarea — full native feel */
    .ielts-writing-textarea,
    .ielts-writing-box .ielts-writing-textarea {
        font-size: 16px !important; /* Prevents iOS auto-zoom on focus */
        line-height: 1.7;
        padding: 12px 14px !important;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-top: none;
        border-bottom: 1px solid #e2e8f0;
        background: #fff;
        -webkit-appearance: none;
        appearance: none;
    }

    /* Word count badge — bottom of editor, sticky */
    .ielts-word-count-display {
        font-size: 12px;
        padding: 4px 12px;
        background: rgba(255,255,255,0.9);
    }

    /* Toolbar collapses to a scrollable row */
    .ielts-editor-toolbar {
        overflow-x: auto;
        flex-wrap: nowrap;
        gap: 6px;
        padding: 6px 10px;
    }
    .ielts-editor-toolbar::-webkit-scrollbar { display: none; }

    .ielts-editor-toolbar button {
        flex-shrink: 0;
        min-width: 36px;
        height: 36px;
        border-radius: 8px;
    }

    /* ── WRITING: fill box to footer ── */

    /* The answer area has desktop padding-bottom (95px) to clear a non-fixed footer.
       On mobile the footer is position:fixed and .ielts-main-interface-container already
       carries padding-bottom:50px — so no extra clearance is needed here. */
    .ielts-answer-area {
        padding-bottom: 8px !important;
    }

    /* The editors carry the same desktop footer clearance — remove it. */
    .ielts-writing-box .ielts-plain-editor {
        padding-bottom: 8px !important;
        min-height: 0 !important;  /* allow flex to determine height */
    }

    .ielts-writing-box .ql-editor {
        padding-bottom: 8px !important;
        min-height: 0 !important;
    }

    /* Allow the active writing box to shrink below its content size (flex handles height) */
    .ielts-writing-box.active {
        min-height: 0 !important;
    }
}

/* =====================================================================
   7. SPEAKING — hero record button + waveform
   ===================================================================== */
@media (max-width: 768px) {

    /* Main record area — centered app feel */
    .ielts-final-wrapper.speaking-mode .ielts-record-area,
    .ielts-final-wrapper.speaking-mode .ielts-spk-record-zone {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 20px 14px;
        gap: 18px;
    }

    /* Hero record button */
    .ielts-final-wrapper.speaking-mode #record-btn,
    .ielts-final-wrapper.speaking-mode .ielts-spk-record-btn,
    .ielts-final-wrapper.speaking-mode #ielts-spk-record-btn {
        width: 88px !important;
        height: 88px !important;
        border-radius: 50% !important;
        font-size: 0 !important;
        background: linear-gradient(145deg, #10b981, #059669) !important;
        box-shadow: 0 6px 32px rgba(16,185,129,0.45),
                    0 0 0 0 rgba(16,185,129,0.3) !important;
        border: none !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        position: relative;
        transition: transform 200ms ease, box-shadow 200ms ease;
    }

    /* Pulse ring when recording */
    .ielts-final-wrapper.speaking-mode #record-btn.recording,
    .ielts-final-wrapper.speaking-mode .ielts-spk-record-btn.recording,
    .ielts-final-wrapper.speaking-mode #ielts-spk-record-btn.recording {
        animation: ielts-pulse-ring 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
        background: linear-gradient(145deg, #ef4444, #dc2626) !important;
        box-shadow: 0 6px 32px rgba(239,68,68,0.45) !important;
    }

    @keyframes ielts-pulse-ring {
        0%   { box-shadow: 0 0 0 0   rgba(239,68,68,0.45), 0 6px 32px rgba(239,68,68,0.45); }
        50%  { box-shadow: 0 0 0 18px rgba(239,68,68,0),   0 6px 32px rgba(239,68,68,0.3); }
        100% { box-shadow: 0 0 0 0   rgba(239,68,68,0),   0 6px 32px rgba(239,68,68,0.45); }
    }

    /* Mic icon inside record button */
    .ielts-final-wrapper.speaking-mode #record-btn::before,
    .ielts-final-wrapper.speaking-mode .ielts-spk-record-btn::before,
    .ielts-final-wrapper.speaking-mode #ielts-spk-record-btn::before {
        content: '🎤';
        font-size: 32px;
        line-height: 1;
    }

    /* Waveform container */
    .ielts-final-wrapper.speaking-mode .ielts-waveform,
    .ielts-final-wrapper.speaking-mode #ielts-waveform,
    .ielts-final-wrapper.speaking-mode .audio-waveform {
        height: 56px;
        border-radius: 16px;
        background: #f0fdf4;
        border: 1px solid #bbf7d0;
        overflow: hidden;
    }

    /* Part card — full width, no scrolled overflow */
    .ielts-final-wrapper.speaking-mode .ielts-spk-part-card,
    .ielts-final-wrapper.speaking-mode .ielts-part-card {
        border-radius: 16px;
        padding: 18px 16px;
        margin: 0 0 12px;
    }

    /* Part navigation row */
    .ielts-final-wrapper.speaking-mode .ielts-spk-nav-row,
    .ielts-final-wrapper.speaking-mode .ielts-part-nav {
        position: fixed;
        bottom: calc(var(--ielts-app-footer-height, 56px) + var(--ielts-safe-bottom, 0px) + 8px);
        left: 14px;
        right: 14px;
        z-index: 50;
    }

    /* Timer for speaking parts */
    .ielts-final-wrapper.speaking-mode .ielts-spk-part-timer,
    .ielts-final-wrapper.speaking-mode .ielts-countdown {
        font-size: 42px;
        font-weight: 900;
        color: #0f172a;
        letter-spacing: -0.03em;
        text-align: center;
    }
}

/* =====================================================================
   8. LISTENING — audio player
   ===================================================================== */
@media (max-width: 768px) {

    /* Audio player card */
    .ielts-audio-player-bar,
    .ielts-audio-widget,
    .ielts-audio-controls {
        border-radius: 16px;
        padding: 12px 16px;
        background: rgba(255,255,255,0.95);
        border: 1px solid #e2e8f0;
        box-shadow: 0 4px 16px rgba(0,0,0,0.06);
        margin: 8px 12px;
    }

    /* Play / Pause button — app-like circle */
    .ielts-audio-play-btn,
    .ielts-play-pause-btn,
    #play-pause-btn {
        width: 52px !important;
        height: 52px !important;
        border-radius: 50% !important;
        background: linear-gradient(135deg, #10b981, #059669) !important;
        border: none !important;
        color: #fff !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-shadow: 0 4px 12px rgba(16,185,129,0.35) !important;
        flex-shrink: 0;
    }

    /* Progress track */
    .ielts-audio-progress,
    .ielts-progress-bar,
    #audio-progress {
        height: 6px;
        border-radius: 6px;
        background: #e2e8f0;
        cursor: pointer;
    }

    /* Volume — hide on mobile (use device controls) */
    .volume-control-group,
    .ielts-volume-control {
        display: none !important;
    }
}

/* =====================================================================
   9. MOCK HUB — app-like launcher cards + entry screen
   ===================================================================== */
@media (max-width: 768px) {

    /* Full-bleed shell inner padding */
    .ielts-mock-fullscreen-shell__inner {
        padding: 12px 12px calc(12px + var(--ielts-safe-bottom, 0px)) !important;
    }

    /* Entry card — softer radius, card-style */
    .imh-entry-card,
    .ielts-mock-step-card,
    .imh-card {
        border-radius: 20px;
        padding: 20px 18px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.07);
        border: 1px solid #f1f5f9;
    }

    /* Module status cards (grid of 4 tiles on mobile) */
    .imh-module-card {
        border-radius: 16px;
        padding: 14px 12px;
        min-height: 80px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
        text-align: center;
    }

    /* Primary CTA button — full width */
    .imh-primary-btn,
    .ielts-mock-step-btn.primary {
        width: 100%;
        height: 52px;
        border-radius: 16px;
        font-size: 17px;
        font-weight: 800;
        background: linear-gradient(135deg, #10b981, #059669);
        color: #fff;
        border: none;
        box-shadow: 0 6px 20px rgba(16,185,129,0.35);
        letter-spacing: 0.01em;
    }

    .imh-primary-btn:active,
    .ielts-mock-step-btn.primary:active {
        transform: scale(0.97);
        box-shadow: 0 3px 10px rgba(16,185,129,0.25);
    }

    /* Candidate info grid — compact */
    .ielts-mock-candidate-grid {
        gap: 8px;
    }

    .ielts-mock-candidate-item {
        border-radius: 12px;
        padding: 12px;
    }

    /* Picker row */
    .imh-picker-row {
        flex-direction: column;
        gap: 10px;
    }

    /* Sound check panel */
    .ielts-mock-audio-tools {
        flex-direction: column;
        gap: 10px;
    }

    /* Exit button — secondary style */
    .imh-entry-exit {
        width: 100%;
        height: 48px;
        border-radius: 14px;
        font-weight: 700;
    }
}

/* =====================================================================
   10. BOTTOM-SHEET MODALS — review, confirm, notes
   ===================================================================== */
@media (max-width: 768px) {

    /* Confirm / alert modals → slide up bottom sheet */
    .ielts-confirm-modal-overlay {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    .ielts-confirm-modal-content {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 28px 28px 0 0 !important;
        padding: 28px 24px calc(28px + var(--ielts-safe-bottom, 0px)) !important;
        margin: 0 !important;
        /* Bottom sheet slide-up animation */
        animation: ielts-sheet-up 280ms cubic-bezier(0.32, 0.72, 0, 1) both;
    }

    @keyframes ielts-sheet-up {
        from { transform: translateY(100%); opacity: 0.8; }
        to   { transform: translateY(0);    opacity: 1;   }
    }

    /* Sheet handle pill at top of every bottom sheet */
    .ielts-confirm-modal-content::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        border-radius: 4px;
        background: #cbd5e1;
        margin: 0 auto 22px;
    }

    /* Review modal → bottom sheet */
    .ielts-review-modal-overlay {
        align-items: flex-end !important;
    }

    .ielts-review-modal-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 85vh !important;
        border-radius: 24px 24px 0 0 !important;
        padding-bottom: calc(20px + var(--ielts-safe-bottom, 0px)) !important;
        animation: ielts-sheet-up 280ms cubic-bezier(0.32, 0.72, 0, 1) both;
        overflow-y: auto;
    }

    .ielts-review-modal-content::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        border-radius: 4px;
        background: #cbd5e1;
        margin: 18px auto 0;
    }

    /* Notes sidebar → bottom sheet on mobile */
    .ielts-notes-sidebar {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 72vh !important;
        border-radius: 24px 24px 0 0 !important;
        border-left: none !important;
        box-shadow: 0 -8px 40px rgba(0,0,0,0.12) !important;
        transform: translateY(100%);
        transition: transform 300ms cubic-bezier(0.32, 0.72, 0, 1) !important;
        padding-bottom: var(--ielts-safe-bottom, 0px);
    }

    .ielts-notes-sidebar.open {
        transform: translateY(0) !important;
        right: 0 !important; /* override the desktop open: right:0 */
    }

    .ielts-notes-sidebar::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        border-radius: 4px;
        background: #cbd5e1;
        margin: 14px auto 6px;
        flex-shrink: 0;
    }

    /* AI feedback modal → bottom sheet */
    #ielts-ai-feedback-modal .ielts-modal-content,
    .speaking-modal-content {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 24px 24px 0 0 !important;
        padding: 28px 20px calc(28px + var(--ielts-safe-bottom, 0px)) !important;
        animation: ielts-sheet-up 280ms cubic-bezier(0.32, 0.72, 0, 1) both;
    }

    /* Sheet handle on AI modal */
    #ielts-ai-feedback-modal .ielts-modal-content::before,
    .speaking-modal-content::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        border-radius: 4px;
        background: #cbd5e1;
        margin: 0 auto 20px;
    }
}

/* =====================================================================
   11. QUESTION ANSWER — bigger tap targets, cleaner inputs
   ===================================================================== */
@media (max-width: 768px) {

    /* Text inputs inside questions */
    .ielts-text-field,
    .ielts-q-input,
    input[type="text"].ielts-input {
        height: 44px !important;
        font-size: 16px !important; /* Prevent iOS zoom */
        padding: 0 12px !important;
        border-radius: 10px !important;
        border: 1.5px solid #d1d5db;
        background: #fff;
        -webkit-appearance: none;
        appearance: none;
    }

    .ielts-text-field:focus,
    .ielts-q-input:focus,
    input[type="text"].ielts-input:focus {
        border-color: #10b981;
        box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
        outline: none;
    }

    /* Radio / checkbox — bigger tap area */
    .ielts-q-radio input[type="radio"],
    .ielts-q-check input[type="checkbox"],
    .ielts-choice-item input[type="radio"],
    .ielts-choice-item input[type="checkbox"] {
        width: 22px;
        height: 22px;
        margin-right: 10px;
        flex-shrink: 0;
        cursor: pointer;
        accent-color: #10b981;
    }

    /* Choice labels — min 44px touch target */
    .ielts-choice-label,
    .ielts-q-option,
    .ielts-q-radio label,
    .ielts-q-check label {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 10px 12px;
        border-radius: 10px;
        font-size: 15px;
        line-height: 1.4;
        cursor: pointer;
    }

    .ielts-choice-label:active,
    .ielts-q-option:active {
        background: rgba(16,185,129,0.08);
    }

    /* Drag-drop items — bigger on mobile */
    .ielts-drag-item {
        padding: 10px 18px;
        font-size: 15px;
        border-radius: 10px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Select dropdowns */
    .ielts-q-select,
    select.ielts-select {
        height: 44px !important;
        font-size: 16px !important;
        border-radius: 10px !important;
        padding: 0 12px !important;
        -webkit-appearance: none;
        appearance: none;
        accent-color: #10b981;
    }
}

/* =====================================================================
   12. QUESTION NAVIGATION PALETTE — improved for fat fingers
   ===================================================================== */
@media (max-width: 768px) {

    /* Palette buttons — increase to 32px+ */
    .palette-btn {
        width: 28px !important;
        height: 28px !important;
        font-size: 12px !important;
        border-radius: 8px !important;
    }

    .palette-btn.current {
        width: 32px !important;
        height: 32px !important;
    }
}

/* =====================================================================
   13. PRESTART (instruction) SCREEN — app onboarding feel
   ===================================================================== */
@media (max-width: 768px) {

    .ielts-prestart-layout {
        padding: 16px 14px calc(20px + var(--ielts-safe-bottom, 0px));
        gap: 16px;
    }

    .ielts-candidate-card {
        border-radius: 20px;
        padding: 22px 18px;
        box-shadow: 0 4px 16px rgba(0,0,0,0.06);
        border: 1px solid #f1f5f9;
    }

    .ielts-candidate-card .ielts-candidate-name {
        font-size: 20px;
        font-weight: 800;
    }

    .ielts-instruction-section {
        border-radius: 20px;
        padding: 20px 18px;
        box-shadow: 0 4px 16px rgba(0,0,0,0.06);
        border: 1px solid #f1f5f9;
    }

    .ielts-prestart-start-btn,
    .ielts-start-button {
        width: 100%;
        height: 56px;
        border-radius: 18px;
        font-size: 18px;
        font-weight: 800;
        background: linear-gradient(135deg, #10b981, #059669);
        color: #fff;
        border: none;
        box-shadow: 0 6px 20px rgba(16,185,129,0.4);
        letter-spacing: 0.01em;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
    }

    .ielts-prestart-start-btn:active,
    .ielts-start-button:active {
        transform: scale(0.97);
        box-shadow: 0 3px 12px rgba(16,185,129,0.3);
    }
}

/* =====================================================================
   14. RESULT / COMPLETION SCREEN — celebratory app card
   ===================================================================== */
@media (max-width: 768px) {

    .ielts-result-card,
    .ielts-completion-card,
    .ielts-score-card {
        border-radius: 24px;
        padding: 28px 20px;
        margin: 0 0 16px;
        box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    }

    .ielts-band-score,
    .ielts-final-band {
        font-size: 72px;
        font-weight: 900;
        letter-spacing: -0.04em;
        background: linear-gradient(135deg, #10b981, #0891b2);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
        line-height: 1;
    }

    /* Action buttons on result screen */
    .ielts-results-nav,
    .ielts-result-actions {
        flex-direction: column;
        gap: 10px;
        padding: 0 14px calc(14px + var(--ielts-safe-bottom, 0px));
    }

    .ielts-results-nav a,
    .ielts-results-nav button,
    .ielts-result-actions a,
    .ielts-result-actions button {
        width: 100%;
        height: 52px;
        border-radius: 16px;
        font-size: 16px;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* =====================================================================
   15. STUDENT DASHBOARD — app-style improvement
   ===================================================================== */
@media (max-width: 640px) {

    .ielts-lms-dash-wrap,
    .ielts-student-dash {
        padding: 12px;
    }

    /* Module category chips — scrollable horizontal row */
    .ielts-lms-filters {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 4px;
    }
    .ielts-lms-filters::-webkit-scrollbar { display: none; }

    .ielts-lms-filter-btn {
        flex-shrink: 0;
        border-radius: 20px;
        height: 36px;
        padding: 0 16px;
        font-size: 14px;
        font-weight: 600;
        white-space: nowrap;
    }

    /* Test list cards */
    .ielts-lms-test-card {
        border-radius: 16px;
        padding: 16px;
        box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    }

    /* CTA inside test card */
    .ielts-lms-test-card .ielts-lms-start-btn {
        width: 100%;
        height: 44px;
        border-radius: 12px;
        font-size: 15px;
        font-weight: 700;
    }

    /* Stats row — 2 column app-style tiles */
    .ielts-lms-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .ielts-lms-stat-card {
        border-radius: 16px;
        padding: 16px 14px;
    }

    /* Tab bar */
    .ielts-lms-tab-bar {
        position: sticky;
        top: var(--ielts-safe-top, 0px);
        z-index: 50;
        background: rgba(255,255,255,0.92);
        -webkit-backdrop-filter: blur(16px);
        backdrop-filter: blur(16px);
    }
}

/* =====================================================================
   16. MISC — focus ring visible for accessibility on touch
   ===================================================================== */
@media (max-width: 768px) {

    /* Remove desktop outline, use border instead when focused-via-keyboard */
    .ielts-final-wrapper *:focus:not(:focus-visible) {
        outline: none;
    }

    .ielts-final-wrapper *:focus-visible {
        outline: 2px solid #10b981;
        outline-offset: 2px;
    }

    /* Prevent horizontal page scroll during test */
    .ielts-final-wrapper {
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Smooth screen transitions for multi-screen views (speaking parts) */
    .ielts-screen,
    .ielts-spk-screen {
        transition: opacity 220ms ease, transform 220ms ease;
    }

    .ielts-screen.hidden,
    .ielts-spk-screen.hidden {
        opacity: 0;
        pointer-events: none;
    }
}
