/* ==========================================================
   TypingTutor.Online
   Mobile Lesson Experience v11.6
========================================================== */

/*
 * Mobile priorities:
 * 1. Lesson text
 * 2. Time and progress
 * 3. Pause, End, and Restart
 *
 * The full keyboard, hand illustration, and live-statistics sidebar
 * are hidden on small screens. Complete results remain available
 * when the lesson ends.
 */

@media (max-width: 760px) {

    body {
        padding-bottom: 0;
    }

    /* ------------------------------------------------------
       COMPACT HEADER
    ------------------------------------------------------ */

    #header {
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    .header-inner {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 9px 12px;
        align-items: center;

        width: 100%;
        padding: 9px 12px 7px;
    }

    .logo {
        min-width: 0;
    }

    .site-logo-image {
        width: 180px !important;
        max-width: 100%;
        height: auto;
    }

    .header-tools {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 6px;
    }

    .more-practice-toggle,
    #themeButton {
        min-height: 38px;
        padding: 7px 9px;
        border-radius: 9px;
        font-size: 10px;
        white-space: nowrap;
    }

    .more-practice-toggle {
        font-size: 0;
    }

    .more-practice-toggle::before {
        content: "More";
        font-size: 10px;
    }

    .more-practice-dropdown {
        position: fixed;
        top: 58px;
        right: 10px;
        left: 10px;
        width: auto;
        max-height: calc(100vh - 76px);
        overflow-y: auto;
    }

    /* ------------------------------------------------------
       TOP MODE MENU
    ------------------------------------------------------ */

    #modeSwitcher {
        grid-column: 1 / -1;
        position: static;
        min-width: 0;
        width: 100%;
        overflow: hidden;

        background: transparent;
        border: 0;
        box-shadow: none;
        backdrop-filter: none;
    }

    .mode-switcher-inner {
        width: 100% !important;
        max-width: none !important;
        padding: 0 !important;
    }

    .mode-navigation {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 4px;
        width: 100%;
    }

    .mode-button {
        display: grid;
        place-items: center;
        gap: 2px;

        min-width: 0;
        min-height: 46px;
        padding: 5px 2px;

        border-radius: 9px;
    }

    .mode-button-icon {
        font-size: 15px;
    }

    .mode-button-text {
        width: 100%;
        overflow: hidden;
        font-size: 8px;
        font-weight: 750;
        line-height: 1.1;
        text-align: center;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* ------------------------------------------------------
       COURSE AND LESSON BARS
    ------------------------------------------------------ */

    #courseProgressBar,
    .course-progress-bar {
        margin-top: 8px;
    }

    .lesson-dashboard-bar {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px;
        align-items: center;
    }

    .lesson-meta-pills {
        grid-column: 1 / -1;
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 5px;
    }

    .lesson-meta-pills > *:nth-child(1),
    .lesson-meta-pills > *:nth-child(2) {
        display: none !important;
    }

    .lesson-meta-pills > * {
        min-width: 0;
        padding: 7px 6px !important;
    }

    /* ------------------------------------------------------
       LESSON AREA
    ------------------------------------------------------ */

    .lesson-practice-grid {
        display: block !important;
    }

    .typing-practice-card {
        width: 100%;
        border-radius: 14px;
    }

    .practice-toolbar {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 7px 10px;
        align-items: center;
        padding: 10px 12px;
    }

    .stage-label {
        min-width: 0;
        overflow: hidden;
        font-size: 10px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .time-left {
        font-size: 11px;
        white-space: nowrap;
    }

    #viewFullTextButton {
        display: none !important;
    }

    #lessonText {
        height: clamp(270px, 48vh, 430px) !important;
        min-height: 270px !important;
        max-height: 430px !important;

        padding: 20px 16px 34px !important;

        font-size: clamp(23px, 7vw, 34px) !important;
        line-height: 1.82 !important;
    }

    .practice-footer {
        display: grid !important;
        grid-template-columns: 1fr auto;
        gap: 8px;
        padding: 8px 10px 10px;
    }

    .character-progress-wrap {
        grid-column: 1 / -1;
    }

    .practice-footer-controls {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 7px;
        width: 100%;
    }

    .control-button {
        min-height: 42px;
        padding: 8px;
        font-size: 11px;
    }

    .practice-footer-actions {
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    #resetLessonButton {
        min-height: 42px;
        padding: 7px 9px;
        font-size: 10px;
    }

    /* ------------------------------------------------------
       HIDE DISTRACTIONS DURING MOBILE LESSONS
    ------------------------------------------------------ */

    #statistics,
    .statistics-panel,
    .typing-controls-grid,
    .keyboard-guidance-card,
    .hands-guidance-card,
    #keyboardContainer,
    #handsContainer,
    #targetRowGuide {
        display: none !important;
    }

    /* Results and statistics pages remain visible */
    [data-mode-panel="statistics"] .statistics-panel,
    .statistics-dashboard,
    .results-card,
    .results-overlay {
        display: block;
    }

    /* Avoid excessive blank area after hiding keyboard */
    #courseModePanel,
    .course-mode-panel {
        min-height: 0;
    }

    .more-typing-resources {
        padding-top: 24px;
    }

    .resource-section-heading h2 {
        font-size: 21px;
    }

    /* ------------------------------------------------------
       DARK MODE MOBILE
    ------------------------------------------------------ */

    html[data-theme="dark"] .mode-button {
        color: #cbd5e1;
    }

    html[data-theme="dark"] .mode-button-active {
        color: #fff;
    }
}

/* Very small phones */
@media (max-width: 390px) {

    .site-logo-image {
        width: 150px !important;
    }

    .header-inner {
        padding-inline: 8px;
    }

    .mode-button-text {
        font-size: 7px;
    }

    #lessonText {
        padding-inline: 12px !important;
        font-size: clamp(21px, 7.2vw, 29px) !important;
    }

    .practice-footer {
        grid-template-columns: 1fr;
    }

    .practice-footer-actions {
        justify-content: center;
    }
}


/* ==========================================================
   MOBILE NATIVE KEYBOARD INPUT v11.7
========================================================== */

.mobile-typing-input,
.mobile-keyboard-button {
    display: none;
}

@media (max-width: 760px) {

    .mobile-keyboard-button {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 7px;

        width: calc(100% - 20px);
        min-height: 44px;
        margin: 9px auto 0;
        padding: 9px 12px;

        color: #ffffff;
        background: var(--primary);
        border: 0;
        border-radius: 10px;

        font: inherit;
        font-size: 11px;
        font-weight: 800;
        cursor: text;
    }

    .mobile-keyboard-button.keyboard-open {
        color: var(--primary);
        background:
            color-mix(
                in srgb,
                var(--primary) 10%,
                var(--surface)
            );
        border: 1px solid var(--primary);
    }

    .mobile-keyboard-button.keyboard-open::after {
        content: "Keyboard ready";
        font-size: 9px;
        font-weight: 700;
    }

    .mobile-keyboard-button.keyboard-open {
        font-size: 0;
    }

    .mobile-keyboard-button.keyboard-open > span {
        font-size: 15px;
    }

    .mobile-typing-input {
        display: block;
        position: fixed;
        z-index: -1;

        left: 50%;
        bottom: 1px;

        width: 2px;
        height: 2px;
        padding: 0;

        opacity: .01;
        color: transparent;
        background: transparent;
        border: 0;
        outline: 0;

        font-size: 16px;
        caret-color: transparent;

        transform: translateX(-50%);
        resize: none;
    }

    #lessonText {
        cursor: text;
        touch-action: manipulation;
    }
}
