/* IDL Learn – phone and tablet layout (Nov 2026 redesign). Loaded after every other stylesheet except app.css.
 * Goals: the main thing on each screen is visible without scrolling (the question, the class, the numbers);
 * one level of cards, not cards inside cards; 44px touch targets; tables turn into readable cards;
 * nothing decorative behind content. Desktop is only touched where noted ("all sizes"). */

/* ---------- all sizes ---------- */
.top__menu .mi { stroke-width: 2; }
.table-wrap { -webkit-overflow-scrolling: touch; }
/* the drawer and its shade sit above the learner tab bar */
body.has-shell.nav-open .side { z-index: 95; }
body.has-shell.nav-open::after { z-index: 90; }
/* tables are solid so a theme scene never shows through them */
.table-wrap { background-color: #fff; }

/* ---------- tablets and phones ---------- */
@media (max-width: 1024px) {
    body.has-shell .side { width: min(86vw, 300px); }
    .side__link { min-height: 44px; font-size: 15px; }
}

/* ---------- phones ---------- */
@media (max-width: 720px) {
    /* canvas: plain, no scene, no shell animation jump */
    .bgfx, .hello::before { display: none !important; }
    body { background: #F4F5F8; font-size: 15px; }
    .wrap { padding: 0 12px; }
    .page { padding-top: 14px; padding-bottom: 28px; }
    body.role-learner #app { padding-bottom: 84px; }

    /* top bar */
    .top { gap: 8px; height: 56px; padding: 0 12px; }
    .top__menu, .top__search { width: 42px; height: 42px; border-radius: 12px; }
    .top__title { font-size: 16px; font-weight: 700; }
    .user__btn .avatar { width: 34px; height: 34px; }
    .user__menu { position: fixed; left: 12px; right: 12px; top: 60px; width: auto; }

    /* type */
    h1 { font-size: 23px; line-height: 1.2; }
    .page-head { margin-bottom: 14px; }
    .page-head .muted, .page-head p { font-size: 14px; }
    .crumbs { margin-bottom: 6px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

    /* one level of cards */
    .panel { margin-bottom: 14px; padding: 16px; border-radius: 16px; border: 1px solid #E9EBF0; box-shadow: none; }
    .panel__head { margin-bottom: 10px; }
    .panel__head h2, .panel > h2 { font-size: 16px; }
    .panel .panel { padding: 0; border: 0; margin-bottom: 10px; }

    /* buttons and fields: full-size touch targets; 16px text stops iPhone zooming into fields */
    .btn { min-height: 44px; padding-left: 16px; padding-right: 16px; border-radius: 12px; }
    .btn--sm { min-height: 36px; }
    input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { font-size: 16px !important; min-height: 44px; }
    input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
    .row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
    .row-actions > .btn, .row-actions > a.btn, .row-actions > button { flex: 1 1 calc(50% - 4px); justify-content: center; }
    .field, .grid2 > * { min-width: 0; }
    .grid2 { grid-template-columns: 1fr !important; }

    /* tabs: one swipeable row */
    .tabs { flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity; margin-left: -12px; margin-right: -12px; padding: 0 12px; scrollbar-width: none; }
    .tabs::-webkit-scrollbar { display: none; }
    .tab { flex: none; scroll-snap-align: start; min-height: 44px; }
    .atabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .atab { flex: none; }

    /* number tiles: two per row, compact */
    .dash-kpis { grid-template-columns: 1fr 1fr !important; gap: 8px; margin-bottom: 14px; }
    .dash-kpi { padding: 12px 14px !important; border-radius: 14px; gap: 2px; min-width: 0; }
    .dash-kpi__i { width: 28px; height: 28px; margin-bottom: 4px; }
    .dash-kpi b { font-size: 21px; } .dash-kpi__l { font-size: 12.5px; }
    .dash-kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
    .dash-hero__txt > p:not(.eyebrow) { font-size: 14px; }
    .dash-actions { gap: 6px; } .dash-actions .btn { flex: 1 1 auto; min-height: 40px; }
    .kpis, .hq-kpis, .hq-kpis--sm { grid-template-columns: 1fr 1fr !important; gap: 8px; }
    .kpis > *, .hq-kpi { padding: 12px 14px !important; border-radius: 14px; min-width: 0; }
    .kpis b, .hq-kpi b, .hq-kpi strong { font-size: 20px !important; line-height: 1.2; word-break: break-word; }
    .kpis span, .kpis small, .hq-kpi span, .hq-kpi small { font-size: 12px !important; line-height: 1.35; }
    .hq-kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }

    /* tables become cards (core/responsive.js adds .rt and the data-label of each cell) */
    .table-wrap { margin-left: 0; margin-right: 0; border-radius: 14px; }
    table.rt { display: block; width: 100%; border: 0; }
    table.rt thead { display: none; }
    table.rt tbody { display: grid; gap: 8px; }
    table.rt tr { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 12px 14px; border: 1px solid #E9EBF0; border-radius: 14px; background: #fff; }
    table.rt td { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; min-height: 0; padding: 0 !important; border: 0 !important; font-size: 14px; text-align: left; word-break: break-word; }
    table.rt td::before { content: attr(data-label); color: var(--muted); font-size: 11.5px; font-weight: 500; line-height: 1.3; }
    table.rt td[data-label=""]::before, table.rt td.rt-first::before, table.rt td.rt-check::before { display: none; }
    table.rt td.rt-first { grid-column: 1 / -1; font-size: 15.5px; font-weight: 600; color: var(--ink); }
    table.rt tr:has(> td.rt-check) > td.rt-first { padding-right: 36px !important; }
    table.rt td.rt-check { position: absolute; top: 12px; right: 12px; }
    table.rt td:empty { display: none; }
    /* a panel that only frames a card list loses its own frame (no cards inside cards) */
    .panel:has(> .table-wrap > table.rt), .panel:has(> table.rt) { padding: 0; border: 0; background: none; }
    .panel:has(> .table-wrap > table.rt) > .panel__head, .panel:has(> .table-wrap > table.rt) > h2 { padding: 0 2px; }
    .table-wrap:has(> table.rt) { overflow: visible; border: 0; background: none; box-shadow: none; }
    .reg-tools { display: flex; flex-wrap: wrap; gap: 8px; }
    .reg-tools .reg-search { flex: 1 1 100%; width: 100% !important; max-width: none; }
    .reg-tools select { flex: 1 1 calc(50% - 4px); min-width: 0; }
    table.rt td:last-child:not(.rt-first):has(.btn, button, .row-actions) { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; gap: 6px; }
    table.rt td:last-child:has(.btn, button, .row-actions)::before { display: none; }

    /* modals: bottom sheets */
    .modal { align-items: flex-end; padding: 0 !important; }
    .modal__box { max-width: none !important; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); animation: sheetUp .22s ease; }
    @keyframes sheetUp { from { transform: translateY(40px); opacity: .6; } }

    /* learner tab bar */
    body.role-learner .tabbar { padding-top: 4px; background: rgba(255, 255, 255, .97); box-shadow: 0 -6px 18px -12px rgba(16, 24, 40, .25); }
    .tabbar__a { min-height: 52px; justify-content: center; font-size: 11px; }
    .tabbar__a.is-on { background: none; }
    .tabbar__a.is-on .mi { stroke-width: 2.2; }

    /* ---- learner home ---- */
    .hello { flex-direction: column; align-items: stretch; gap: 0; margin-bottom: 12px; padding: 18px 16px !important; border-radius: 20px; }
    .hello .eyebrow { margin-bottom: 4px; font-size: 12px; }
    .hello h1 { font-size: 22px; }
    .hello__main > .muted { display: none; }
    .hello__world { margin-bottom: 8px; font-size: 12px; padding: 3px 10px; }
    .hello__row { flex-wrap: wrap; gap: 12px; margin-top: 12px; }
    .goal { gap: 10px; } .goal svg { width: 52px; height: 52px; } .goal b { font-size: 15px; } .goal span { font-size: 12.5px; }
    .week { gap: 4px; } .week__day { font-size: 10.5px; } .week__day i, .week__day span:first-child { width: 22px; height: 22px; }
    .hello__main .hello__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; }
    .hello__stats div { min-width: 0; padding: 10px 8px; border-radius: 12px; text-align: center; }
    .hello__stats b { font-size: 18px; }
    .hello__stats span { display: block; font-size: 11px; line-height: 1.25; }
    .cont { margin: 0 0 12px; padding: 12px 14px; gap: 12px; border-radius: 16px; }
    .cont__ring svg { width: 48px; height: 48px; }
    .cont__txt b { font-size: 16px; } .cont__txt em { font-size: 12.5px; }
    /* recommendation and exam cards: a swipeable row instead of a long column */
    .rec-grid { display: grid !important; grid-auto-flow: column; grid-auto-columns: 78%; grid-template-columns: none !important; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 2px 16px 6px; scrollbar-width: none; }
    .rec-grid::-webkit-scrollbar { display: none; }
    .rec-grid > * { scroll-snap-align: start; }
    .rec-grid:has(> :only-child) { grid-auto-columns: 100%; }
    .rec-card { padding: 14px; border-radius: 14px; }
    .rec-card__why { font-size: 13px; }
    /* subjects: two per row */
    .subject-grid { grid-template-columns: 1fr 1fr !important; gap: 10px; }
    .subject-card { padding: 14px; border-radius: 16px; gap: 2px; }
    .subject-card__icon { width: 40px; height: 40px; border-radius: 12px; margin-bottom: 6px; }
    .subject-card b, .subject-card h3, .subject-card strong { font-size: 15px; line-height: 1.25; }
    .subject-card span, .subject-card small, .subject-card p { font-size: 12px; }
    .skill-link { padding: 12px; border-radius: 12px; }

    /* ---- learn: years as one swipeable row per stage, skills as a tidy list ---- */
    .stages { gap: 8px; margin-bottom: 16px; }
    .stage { flex-wrap: nowrap; overflow-x: auto; gap: 6px; margin: 0 -12px; padding: 0 12px 2px; scrollbar-width: none; }
    .stage::-webkit-scrollbar { display: none; }
    .stage__name { flex: none; min-width: 0 !important; width: auto; margin-right: 4px; font-size: 11px; }
    .stage .chip, .stage a, .stage button { flex: none; }
    .chip { min-height: 36px; display: inline-flex; align-items: center; }
    .seg { display: flex; width: 100%; overflow-x: auto; }
    .seg__btn { flex: 1 0 auto; min-height: 40px; }
    .topic { padding: 14px; border-radius: 16px; }
    .topic__skills a, .topic__skills li { min-height: 44px; }

    /* ---- practice: the question first, the numbers in one slim strip ---- */
    .practice .crumbs { display: none; }
    .practice__head { gap: 10px; margin-bottom: 10px; }
    .practice__head h1 { font-size: 19px; }
    .practice__code { padding: 4px 8px; font-size: 13px; border-radius: 8px; }
    .practice__grid { gap: 10px; }
    .practice__side { position: static !important; order: -1; display: grid !important; grid-template-columns: 1fr 1fr 1.3fr !important; gap: 6px; }
    .practice__side .side-box { display: flex; flex-direction: column; justify-content: center; min-height: 58px; padding: 6px 8px !important; border-radius: 12px; box-shadow: none; }
    .practice__side .side-box--score { grid-column: auto !important; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 6px; }
    .side-box__label { font-size: 11px; line-height: 1.2; }
    .practice__side .side-box b { font-size: 18px !important; }
    .side-box--score #s-ring { order: 2; margin: 0 !important; }
    .side-box--score #s-ring svg { width: 40px !important; height: 40px !important; }
    .side-box--score .side-box__label { order: 1; width: 100%; text-align: center; }
    .side-box__level, .practice__side .zones { display: none !important; }
    .info-btn { width: 18px; height: 18px; font-size: 11px; }
    .qcard { padding: 16px !important; border-radius: 18px; }
    .qcard__top { display: block; height: 0; margin: 0; }
    .qcard__top .streak { position: relative; z-index: 1; }
    .sound-btn span { display: none; }
    .sound-btn { float: right; position: relative; z-index: 1; min-height: 36px; margin: -4px -4px 4px 10px; padding: 4px 10px; }
    .q { font-size: 18px; }
    .answer { flex-wrap: wrap; gap: 8px; }
    .answer input { flex: 1 1 140px; min-width: 0; font-size: 20px !important; min-height: 52px; }
    .answer .btn, .multi + .btn { flex: 1 1 100%; min-height: 52px; font-size: 16px; }
    .multi { display: grid; gap: 8px; width: 100%; }
    .multi__f { display: flex; align-items: center; gap: 8px; }
    .multi__f input { flex: 1; min-width: 0; }
    .choices { gap: 8px; }
    .choice { min-height: 52px; }
    .choices--grid, .choices--row { grid-template-columns: 1fr 1fr !important; }
    .fb { padding: 14px; border-radius: 14px; }
    .fb__cmp { grid-template-columns: 1fr 1fr; gap: 8px; }
    .fb__explain { font-size: 15px; }
    #got-it { width: 100%; min-height: 52px; }
    /* learning screens: the tab bar hides so the answer button is never covered by it */
    body.is-focus .tabbar-wrap { display: none; }
    body.is-focus.role-learner #app { padding-bottom: 20px; }

    /* ---- staff: class page, classes, dashboards ---- */
    .class-grid { grid-template-columns: 1fr !important; gap: 10px; }
    .class-card { padding: 14px; border-radius: 16px; }
    .page-head .row-actions { margin-top: 10px; }
    .reg-head { flex-wrap: wrap; gap: 8px; }
    .reg-head .btn { flex: 1 1 calc(50% - 4px); }
    .pg__find, .pg__find input, .reg-head input[type=search], .reg-head input[type=text] { width: 100% !important; flex: 1 1 100%; }
    .reg-head select { flex: 1 1 calc(50% - 4px); min-width: 0; }
    .trouble__item { padding: 10px 0; }
    .dash-hero { padding: 18px 16px !important; border-radius: 18px; }

    /* HQ */
    .hq-head { gap: 10px; }
    .hq-head .row-actions .btn { flex: 1 1 100%; }
    .hq-setup { padding: 14px; }
    .hq-setup__list { display: flex; flex-wrap: wrap; gap: 6px; }

    /* AI assistant button stays clear of the tab bar */
    body.role-learner .asst-fab, body.role-learner .ai-fab { bottom: 92px; }
}

/* very small phones */
@media (max-width: 360px) {
    .subject-grid { grid-template-columns: 1fr !important; }
    .hello__stats b { font-size: 16px; }
    .practice__side { grid-template-columns: 1fr 1fr !important; }
    .practice__side .side-box--score { grid-column: 1 / -1 !important; }
}
