/* ==============================================================================
 * Mentifyll: Töltsd fel az elméd! — Mobil nézet (v0.16.2)
 * A vízszintes túlcsúszás megszüntetése 320–767 px között: fejléc, alsó menü + „Több” lap, modalok.
 * Utolsóként töltődik be. Ellenőrzés: tests/e2e_mobile_overflow.py (320–430 px, minden fül).
 * ============================================================================== */

/* ---------- Védőháló: az oldal soha ne legyen szélesebb a képernyőnél ---------- */
html {
    overflow-x: clip;
}

body {
    overflow-x: hidden; /* régebbi böngészők */
    overflow-x: clip;
    max-width: 100%;
}

/* ---------- „Több” lap: asztalon és tableten rejtett ---------- */
.nav-more,
.nav-more-sheet,
.nav-more-backdrop {
    display: none;
}

/* ---------- Mobil (< 768 px) ---------- */
@media (max-width: 767px) {
    /* Alsó sáv: csak a fő menüpontok; a többi a „Több” lapon */
    .bottom-nav .nav-item.nav-secondary {
        display: none;
    }

    .bottom-nav .nav-item.nav-more {
        display: flex;
        background: none;
        border: 0;
        font-family: inherit;
        cursor: pointer;
    }

    .nav-more-backdrop:not([hidden]) {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 205;
        background: rgba(0, 0, 0, 0.35);
    }

    .nav-more-sheet:not([hidden]) {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: calc(68px + env(safe-area-inset-bottom, 0px));
        z-index: 210;
        padding: 10px;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.3);
        max-height: 60vh;
        overflow-y: auto;
    }

    .nav-more-item {
        position: relative;
        display: flex;
        align-items: center;
        gap: 10px;
        min-height: 46px;
        padding: 8px 12px;
        background: var(--color-surface-variant);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        color: var(--color-text-main);
        font: inherit;
        font-size: 0.9rem;
        font-weight: 600;
        text-align: left;
        cursor: pointer;
    }

    .nav-more-item > span:first-child {
        font-size: 1.15rem;
        line-height: 1;
    }

    .nav-more-item .nav-badge {
        left: auto;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
    }

    /* Fejléc: semmi sem lóghat ki; a márkanév és a jobb oldali sáv zsugorodhat */
    .app-header {
        gap: 6px;
        min-width: 0;
    }

    .brand-wrapper {
        flex-shrink: 1;
        min-width: 0;
    }

    .brand-text {
        min-width: 0;
    }

    .brand-text h1 {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-status {
        flex-shrink: 1;
        min-width: 0;
    }

    .energy-badge {
        flex-shrink: 1;
        min-width: 0;
        overflow: hidden;
    }

    /* Görgethető fülsorok: halvány kifutás jelzi, hogy van még tovább */
    .settings-subnav,
    .tt-tabs,
    .ms-tabs,
    .std-tabs,
    .exam-nav-pills,
    .help-cats,
    .tutor-threads-strip,
    .tutor-quick-prompts-bar {
        -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
        mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    }

    /* Tankönyvolvasó: az oldalsáv az oldalkép alá kerül */
    .tb-reader-body {
        flex-direction: column;
    }

    #tb-reader-canvas-container {
        flex: 1 1 auto;
        min-height: 0;
    }

    #tb-reader-sidebar {
        width: 100% !important;
        max-height: 40vh;
        border-left: 0 !important;
        border-top: 1px solid var(--color-border);
        flex: 0 0 auto;
    }

    /* Szűrőgombok: hosszú felirat törhet */
    .filter-btn {
        white-space: normal;
        flex: 1 1 140px;
    }
}

/* ---------- Keskeny telefon (≤ 480 px): a fejléc másodlagos elemei a „Több” lapra költöznek ---------- */
@media (max-width: 480px) {
    #btn-toggle-sound,
    #btn-toggle-theme-header,
    .btn-header-tutor #header-tutor-btn-text {
        display: none !important;
    }

    .app-header {
        padding: 0 6px;
    }

    /* a „Kérdezz!” gomb csak az ikon: négyzet alakú, nem pazarol helyet */
    .btn-header-tutor {
        width: 32px;
        padding: 0 !important;
        justify-content: center;
    }
}

@media (max-width: 360px) {
    .brand-text,
    #header-user-avatar-img {
        display: none !important;
    }
}

/* ---------- Órarend-szerkesztő: kis kijelzőn napkártyák a 680 px-es tábla helyett ---------- */
.tt-lessons-table {
    min-width: 680px;
}

@media (max-width: 640px) {
    .tt-lessons-table {
        min-width: 0;
    }

    .tt-lessons-table thead {
        display: none;
    }

    .tt-lessons-table,
    .tt-lessons-table tbody,
    .tt-lessons-table tr {
        display: block;
        width: 100%;
    }

    .tt-lessons-table tr {
        border-bottom: 2px solid var(--color-border);
        padding-bottom: 6px;
    }

    .tt-lessons-table td {
        display: grid;
        grid-template-columns: 82px minmax(0, 1fr);
        align-items: center;
        gap: 8px;
        border-bottom: 0 !important;
    }

    .tt-lessons-table td[data-label]::before {
        content: attr(data-label);
        font-size: 0.75rem;
        font-weight: 700;
        color: var(--color-text-muted);
    }

    .tt-lessons-table td:first-child {
        display: block;
    }
}
