/* ==========================================================================
   Responsive Adaptations for Mobile & Small Displays
   --------------------------------------------------------------------------
   Phones get the iPhone version of each idea rather than a shrunken Mac:
   windows become full-width sheets, sidebars become swipeable tab strips,
   list/detail apps (Mail, Notes) push to the detail and offer a Back
   button, and the Dock keeps the apps that matter most (everything is still
   one tap away in Launchpad).
   ========================================================================== */

/* Back buttons only exist on phones. */
.mobile-back-btn { display: none; }

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    /* ── Windows: full-width sheets between the menu bar and the Dock ── */
    .window:not(.is-maximized) {
        left: 6px !important;
        top: 34px !important;
        width: calc(100vw - 12px) !important;
        height: calc(100dvh - 34px - 88px) !important;
        min-width: 0;
        min-height: 0;
        border-radius: 14px;
    }

    .window-title { font-size: 12.5px; padding: 0 64px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

    /* ── Sidebars become horizontal, swipeable tab strips ── */
    .finder-main-layout,
    .settings-layout,
    .music-body,
    .appstore-layout { flex-direction: column; }

    .finder-sidebar-v2,
    .settings-sidebar,
    .music-sidebar,
    .appstore-sidebar {
        display: flex !important;
        flex-direction: row !important;
        align-items: center;
        gap: 6px !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0;
        flex-shrink: 0;
        padding: 8px 10px !important;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: none !important;
        border-bottom: 1px solid var(--window-border);
        scrollbar-width: none;
    }
    .finder-sidebar-v2::-webkit-scrollbar,
    .settings-sidebar::-webkit-scrollbar,
    .music-sidebar::-webkit-scrollbar,
    .appstore-sidebar::-webkit-scrollbar { display: none; }

    .finder-sidebar-v2 .sidebar-v2-section { display: contents; }
    .finder-sidebar-v2 .sidebar-v2-heading,
    .music-sidebar .music-sidebar-title,
    .settings-user-card { display: none !important; }

    .finder-sidebar-v2 .sidebar-v2-item,
    .settings-sidebar .sidebar-item,
    .music-sidebar .music-nav-item,
    .appstore-sidebar .sidebar-item {
        flex-shrink: 0;
        white-space: nowrap;
        margin: 0 !important;
        padding: 6px 11px !important;
        border-radius: 999px !important;
    }

    .settings-pane-container { padding: 16px; }

    /* Sidebars that don't carry navigation on a phone */
    .photos-sidebar, .notes-sidebar, .mail-sidebar { display: none !important; }

    /* ── Mail: list → message, with Back ── */
    .mail-list-container { width: 100%; }
    .mail-reader { display: none; }
    .mail-layout.show-detail .mail-list-container { display: none; }
    .mail-layout.show-detail .mail-reader { display: flex; width: 100%; }

    /* ── Notes: list → note, with Back ── */
    .notes-list-column { width: 100%; border-right: none; }
    .notes-canvas { display: none; }
    .notes-layout.show-detail .notes-list-column { display: none; }
    .notes-layout.show-detail .notes-canvas { display: block; width: 100%; }

    .mobile-back-btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        border: none;
        background: none;
        color: var(--accent);
        font: inherit;
        font-size: 14px;
        padding: 4px 0 10px;
        cursor: pointer;
    }

    .safari-nav-cluster { margin-left: 50px; }
    .safari-url-bar { max-width: 260px; }

    /* ── Dock: curated, scrollable, no hover magnification ── */
    .dock-container { left: 6px; right: 6px; bottom: 8px; }
    .dock {
        max-width: 100%;
        padding: 6px;
        gap: 5px;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .dock::-webkit-scrollbar { display: none; }
    #dock-missioncontrol, #dock-breakout, #dock-snake, #dock-photobooth,
    #dock-appstore, #dock-settings, #dock-terminal, #dock-trash, .dock-divider { display: none; }
    .dock-item { width: 40px; height: 40px; flex-shrink: 0; }
    .dock-item img { width: 40px !important; height: 40px !important; }
    .dock-item::before { display: none; }
    .dock-item:hover,
    .dock-item:hover + .dock-item,
    .dock-item:has(+ .dock-item:hover),
    .dock-item:hover + .dock-item + .dock-item,
    .dock-item:has(+ .dock-item + .dock-item:hover) { transform: none; }
}
