/*
  SPDX-FileCopyrightText: 2026 Lukas Körber
  SPDX-License-Identifier: AGPL-3.0-only
*/

/* === Mobile responsive === */
@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }

    /* Two-column field rows (date/select pairs in Calendar, Setup, Planner) stack
       to a single column - keeps date/datetime inputs from being squeezed into a
       half-width column narrower than their native rendered width on mobile. */
    .field-row { flex-direction: column; }

    .sidebar {
        width: 100%;
        height: auto;
        top: auto;
        bottom: 0;
        flex-direction: row;
        /* No padding-bottom for --safe-bottom here on purpose: the bar's background already
           reaches the physical edge on its own (the WebView fills the full screen, see
           SafeAreaEdges="None"). Padding the icons up by the full inset instead of leaving
           them close to the edge looked worse in practice (a dead-looking colored strip
           under them) than the small risk of a tap landing near the home-indicator gesture
           zone - deliberate call, not an oversight. */
        padding: 0;
        border-right: none;
        border-top: 1px solid var(--border);
        z-index: 200;
    }

    .brand { display: none; }
    .sidebar-foot { display: none; }

    /* Float above the 64px-tall bottom tab bar instead of overlapping it. */
    .fab-dial {
        right: 12px;
        bottom: calc(64px + 0.75rem);
    }

    .nav-links {
        flex-direction: row;
        width: 100%;
        padding: 0;
        gap: 0;
    }

    .nav-item {
        flex: 1;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        border-radius: 0;
        padding: 0.75rem 0.5rem;
        gap: 0.25rem;
        font-size: 0.65rem;
    }

    .nav-icon { font-size: 1.25rem; }
    .nav-badge { position: absolute; top: 8px; right: calc(50% - 16px); }

    .main-content {
        margin-left: 0;
        height: calc(100vh - 64px);
        height: calc(100dvh - 64px);
        margin-bottom: 0;
        /* A right lane for the floating action button would cost a phone ~15% of its width,
           so here the button gets bottom clearance instead: the end of every page stays above
           it, nothing is left stuck underneath it. The button sits 0.75rem above the tab bar,
           i.e. above this element's bottom edge. */
        padding-right: 0;
        padding-bottom: var(--fab-clearance);
        /* On mobile the nav bar sits at the bottom, so nothing else reserves the top notch/
           Dynamic Island area - the WebView now covers the full physical screen
           (SafeAreaEdges="None"), so page content needs its own top inset here. Scrolls
           away with the rest of the content, which is correct - it only needs to protect
           the very first paint. */
        padding-top: var(--safe-top);
        overflow-y: auto;
    }

    /* The calendar shell is capped at the viewport and does not scroll, so bottom clearance
       here would only shrink the grid (fewer hours visible). It keeps its plain bottom padding;
       the grid's own scroll area reserves the room instead (.fab-scroll-end below). */
    .app-shell.page-calendar .main-content {
        height: calc(100vh - 64px);
        height: calc(100dvh - 64px);
        padding-right: 0;
        padding-bottom: 1rem;
    }

    /* A scroll area inside a non-scrolling page shell (the calendar grid): padding at the end
       of its own scroll range, so its last rows can be scrolled above the button. */
    .fab-scroll-end { padding-bottom: var(--fab-clearance); }

    .dashboard { padding: 1.25rem 1rem; }
    .dash-grid { grid-template-columns: 1fr; }
    .card-today, .card-next, .card-stats, .card-courses { grid-column: 1; grid-row: auto; }

    .calendar-page { padding: 1rem 0 1rem 1rem; }
    .cal-import-row { padding-right: 1rem; }
    /* The import-review row's course dropdown no longer fits next to title/time on
       narrow viewports - wrap instead of clipping it sideways. */
    .import-review-row { flex-wrap: wrap; }
    .import-review-row .select { width: 100%; flex: 1 1 100%; }
    /* The week/day switcher is added as an extra header element: on
       narrow viewports the header row is allowed to wrap instead of overflowing. */
    .cal-header { padding-right: 1rem; flex-wrap: wrap; gap: 0.5rem; }
    .cal-inner { min-width: 560px; }
    .cal-day-header-cell,
    .cal-day { min-width: 80px; }

    .focus-page { padding: 0.5rem 1rem 1rem; gap: 0.75rem; justify-content: flex-start; padding-top: 1.25rem; min-height: 100%; }
    .mode-switcher { gap: 0.35rem; }
    .mode-opt { padding: 0.3rem 0.5rem; font-size: 0.72rem; }
    .mo-time { display: none; }

    .setup-page { padding: 1.25rem 1rem; }
    .course-grid { grid-template-columns: 1fr; }
    .style-grid { grid-template-columns: 1fr 1fr; }

    .page-focus .main-content {
        height: calc(100vh - 64px);
        height: calc(100dvh - 64px);
        overflow-y: auto;
    }
}

/* === Focus page full-screen override === */
/* (The Focus page used to force overflow: hidden here; that clipped the timer controls at 200% zoom
   and in landscape - audit W-V13. .main-content scrolls like on every other page instead.) */

