/* ==========================================================================
   Responsive Adaptations (Mobile, Tablet, Small Laptops)
   ========================================================================== */

@media (max-width: 768px) {
  /* Boot Screen */
  .xp-boot-content {
    width: 90%;
  }

  /* Login Screen Stack */
  .login-header-bar,
  .login-footer-bar {
    padding: 0 16px;
    height: 50px;
  }

  .login-instruction {
    display: none;
  }

  .login-body {
    flex-direction: column;
    padding: 20px 16px;
    gap: 20px;
  }

  .login-divider {
    width: 80%;
    height: 1px;
    margin: 10px 0;
  }

  .login-left-col {
    width: 100%;
    text-align: center;
    align-items: center;
  }

  .login-welcome-title {
    font-size: 24px;
  }

  .login-right-col {
    width: 100%;
    max-width: 320px;
  }

  .user-card {
    padding: 12px 14px;
  }

  /* Desktop: icons fill the screen as a grid instead of one long column */
  .desktop-container {
    /* The grid sits at the top, so the shade runs from the top instead of the left.
       Portrait phones see a narrow slice of bg.jpg: center it on the fox at the laptop. */
    background-image: linear-gradient(180deg, rgba(0, 0, 0, 0.3) 0, rgba(0, 0, 0, 0.12) 30%, transparent 50%),
      url('../assets/backgrounds/bg.jpg');
    background-position: center, 77% center;
  }

  .desktop-icons-area {
    top: 12px;
    left: 8px;
    right: 8px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    grid-auto-rows: min-content;
    justify-items: center;
    gap: 8px 4px;
  }

  .desktop-icon {
    width: 84px;
    height: auto;
    min-height: 84px;
  }

  .desktop-icon-img {
    width: 48px;
    height: 48px;
    --icon-glyph: 28px;
  }

  .desktop-icon-label {
    font-size: 12px;
    max-width: 84px;
  }

  .desktop-watermark {
    display: none;
  }

  /* Windows fill the space above the taskbar with a 4px margin,
     so they still read as windows on the desktop */
  .window-container {
    top: 4px !important;
    left: 4px !important;
    right: 4px !important;
    width: calc(100vw - 8px) !important;
    height: calc(100vh - var(--taskbar-height) - 8px) !important;
    height: calc(100dvh - var(--taskbar-height) - 8px) !important;
    max-width: none !important;
    border-width: 2px;
    border-radius: 6px 6px 2px 2px;
  }

  .window-resizer {
    display: none; /* Disable manual corner resizing on mobile touch */
  }

  .btn-maximize {
    display: none; /* Windows already fill the screen */
  }

  .window-titlebar {
    height: 34px;
    font-size: 13px;
  }

  .window-btn {
    width: 30px;
    height: 26px;
    font-size: 13px;
  }

  /* The decorative File/Edit menu and status bar do nothing on a touch screen */
  .window-menubar,
  .window-statusbar {
    display: none;
  }

  /* Taskbar */
  :root {
    --taskbar-height: 44px;
  }

  .start-button {
    padding: 0 12px 0 8px;
    font-size: 13px;
  }

  .taskbar-tasks-area {
    gap: 2px;
    padding: 0 4px;
  }

  .task-item {
    height: 34px;
    min-width: 70px;
    max-width: 120px;
    font-size: 10px;
    padding: 0 4px;
  }

  .tray-icons {
    display: none; /* Hide tray icon cluster, keep clock */
  }

  .tray-clock {
    font-size: 10px;
    padding: 0 4px;
  }

  /* Start menu: full width, columns stacked, finger-sized items */
  .start-menu {
    width: 100vw;
    border-radius: 0;
  }

  .start-menu-body {
    flex-direction: column;
    max-height: calc(100dvh - var(--taskbar-height) - 140px);
    overflow-y: auto;
  }

  .start-left-col,
  .start-right-col {
    width: 100%;
    border-left: none;
    border-top: 1px solid #dcdcdc;
  }

  .start-item {
    min-height: 44px;
    padding: 6px 10px;
    font-size: 14px;
  }

  .start-item-icon {
    width: 28px;
    height: 28px;
  }

  .start-item-desc {
    font-size: 12px;
  }

  /* Explorer layout */
  .app-explorer-container {
    flex-direction: column;
  }

  .app-explorer-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #4a6bb5;
    padding: 8px;
    gap: 8px;
  }

  /* Browser: compact chrome so the page gets the space */
  .browser-tabs-bar {
    height: 28px;
  }

  .browser-tab-item {
    height: 22px;
    min-width: 70px;
    max-width: 110px;
    padding: 0 6px;
    font-size: 10px;
  }

  .browser-nav-toolbar {
    height: 32px;
    padding: 0 4px;
    gap: 4px;
  }

  .nav-circle-btn {
    width: 24px;
    height: 24px;
    font-size: 14px;
  }

  .browser-search-pill {
    height: 24px;
    padding: 0 6px;
    gap: 4px;
    font-size: 11px;
  }

  .browser-bookmarks-bar {
    height: 22px;
    overflow-x: auto;
    white-space: nowrap;
    padding: 0 6px;
    gap: 8px;
    font-size: 10px;
    scrollbar-width: none;
  }

  .browser-bookmarks-bar::-webkit-scrollbar {
    display: none;
  }

  /* cmd.exe: a 16px input stops iOS from zooming in on focus */
  .terminal-container {
    padding: 8px;
  }

  .terminal-input-row {
    flex-wrap: wrap;
  }

  .terminal-input {
    font-size: 16px;
  }

  /* ==========================================================================
     Windows Media Player (wmplayer.exe) Mobile Adaptation
     ========================================================================== */
  .wmp-left-nav {
    display: none !important; /* Hide left 115px column on phone to maximize player */
  }

  .wmp-playlist-sidebar {
    display: none; /* Hidden by default; opens as overlay when toggle button is clicked */
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 200px;
    z-index: 30;
    box-shadow: -3px 0 10px rgba(0, 0, 0, 0.6);
  }

  .wmp-top-menubar {
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    gap: 4px;
    padding: 0 4px;
  }

  .wmp-top-menubar::-webkit-scrollbar {
    display: none;
  }

  .wmp-menu-btn,
  .wmp-open-file-btn {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .wmp-now-playing-banner {
    height: auto;
    padding: 4px 8px;
  }

  .wmp-artist-name {
    font-size: 10px;
  }

  .wmp-track-title {
    font-size: 12px;
  }

  .wmp-viewport-bottom-bar {
    height: 28px;
    padding: 0 6px;
    font-size: 9px;
  }

  .wmp-bottom-deck {
    height: auto;
    min-height: 52px;
    padding: 6px 10px;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .wmp-seeker-container {
    order: -1;
    width: 100%;
    flex-basis: 100%;
    margin-bottom: 2px;
  }

  .wmp-circle-play-btn {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }

  .wmp-deck-btns {
    gap: 3px;
  }

  .wmp-chrome-btn {
    width: 22px;
    height: 22px;
  }

  .wmp-volume-deck {
    display: none; /* Handled by device physical volume rocker */
  }

  .wmp-green-lcd-time {
    font-size: 11px;
    padding: 1px 4px;
  }

  /* ==========================================================================
     My Computer & Folder Explorer Mobile Adaptation
     ========================================================================== */
  .explorer-toolbar {
    height: auto;
    flex-wrap: wrap;
    padding: 4px 6px;
    gap: 4px;
  }

  .exp-tool-btn {
    white-space: nowrap;
    padding: 3px 6px;
  }

  .exp-address-bar-row {
    width: 100%;
    margin-left: 0;
    margin-top: 2px;
  }

  .exp-address-input {
    min-width: 0;
    flex: 1;
  }

  .explorer-sidebar-pane {
    display: none !important; /* Hide left 190px tasks pane on mobile so drives/files take 100% width */
  }

  .explorer-files-pane {
    flex: 1;
    padding: 8px;
  }

  /* ==========================================================================
     Windows Task Manager (taskmgr.exe) Mobile Adaptation
     ========================================================================== */
  .taskmgr-tabs-bar {
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
  }

  .taskmgr-tabs-bar::-webkit-scrollbar {
    display: none;
  }

  .taskmgr-tab-btn {
    white-space: nowrap;
    padding: 4px 8px;
    font-size: 10.5px;
  }

  .tm-btn-actions {
    flex-wrap: wrap;
    justify-content: stretch;
    gap: 6px;
  }

  .tm-btn-actions .xp-dialog-btn {
    flex: 1;
    min-height: 32px;
    white-space: nowrap;
    text-align: center;
    justify-content: center;
  }

  .col-proc-pid {
    display: none; /* Hide PID column on narrow screen */
  }

  /* ==========================================================================
     Settings & Properties Dialog Mobile Adaptation
     ========================================================================== */
  .xp-prop-tab {
    white-space: nowrap;
    padding: 4px 8px !important;
    font-size: 10.5px !important;
  }

  /* ==========================================================================
     Windows Picture & Fax Viewer Mobile Adaptation
     ========================================================================== */
  .xp-iv-bottombar {
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    justify-content: flex-start;
    padding: 0 6px;
  }

  .xp-iv-bottombar::-webkit-scrollbar {
    display: none;
  }

  .xp-iv-btn {
    flex-shrink: 0;
  }
}

@media (max-width: 480px) {
  /* Only one window fits anyway: show task buttons as icons */
  .task-item {
    min-width: 40px;
    max-width: 44px;
    justify-content: center;
  }

  .task-item-title {
    display: none;
  }
}

/* Short screens (phone/tablet landscape): compact window title bar */
@media (max-height: 500px) and (max-width: 1024px) {
  .window-titlebar {
    height: 34px;
  }
}

/* ==========================================================================
   Large screens: scale icons, labels and taskbar up so they are not tiny
   ========================================================================== */
@media (min-width: 1600px) {
  :root {
    --taskbar-height: 42px;
  }

  .desktop-icons-area {
    top: 18px;
    left: 18px;
    gap: 18px 16px;
  }

  .desktop-icon {
    width: 100px;
    height: 104px;
  }

  .desktop-icon-img {
    width: 56px;
    height: 56px;
    --icon-glyph: 32px;
  }

  .desktop-icon-label {
    font-size: 13px;
    max-width: 96px;
  }

  .start-button {
    font-size: 16px;
  }

  .start-icon {
    width: 24px;
    height: 24px;
  }

  .task-item {
    height: 32px;
    font-size: 12px;
    max-width: 200px;
  }

  .system-tray,
  .tray-clock,
  .tray-lang-switcher {
    font-size: 12px;
  }

  .window-titlebar {
    height: 34px;
    font-size: 13px;
  }

  .window-btn {
    width: 24px;
    height: 24px;
  }
}

/* 2K / 4K screens */
@media (min-width: 2200px) {
  :root {
    --taskbar-height: 48px;
  }

  .desktop-icon {
    width: 116px;
    height: 120px;
  }

  .desktop-icon-img {
    width: 64px;
    height: 64px;
    --icon-glyph: 38px;
  }

  .desktop-icon-label {
    font-size: 14px;
    max-width: 112px;
  }

  .start-button {
    font-size: 18px;
  }

  .task-item {
    height: 38px;
    font-size: 13px;
  }
}
