/* ===== MOBILE LANDSCAPE ADAPTATION ===== */
/* 覆盖所有手机横屏场景 (orientation:landscape, max-height<=500px)
   及小屏竖屏 (portrait, max-width<=600px)                        */

/* ─────────────────────────────────────────
   1. 通用变量 & 基础 reset
───────────────────────────────────────── */
@media screen and (max-width: 900px) {
  :root {
    --taskbar-h: 40px;
    --win-title-h: 30px;
  }
}

/* ─────────────────────────────────────────
   2. 横屏主样式
───────────────────────────────────────── */
@media screen and (orientation: landscape) and (max-height: 500px) {

  html, body {
    overflow: hidden;
    touch-action: none;
    -webkit-overflow-scrolling: touch;
  }

  /* === 任务栏 === */
  .taskbar {
    height: 36px;
  }
  .taskbar-start {
    width: 38px;
    height: 36px;
    font-size: 16px;
  }
  .taskbar-btn {
    height: 26px;
    padding: 0 7px;
    font-size: 10px;
    gap: 4px;
    max-width: 90px;
  }
  .taskbar-tray { gap: 5px; padding: 0 8px; }
  .tray-item { font-size: 11px; }
  #tray-clock { font-size: 10px; min-width: 50px; }

  /* === 开始菜单 === */
  .start-menu {
    bottom: 36px;
    width: 170px;
    border-radius: 6px 6px 0 0;
  }
  .start-menu-header { padding: 8px 12px; }
  .start-user { font-size: 12px; }
  .start-user-sub { font-size: 10px; }
  .start-menu-items { padding: 4px 0; }
  .start-item { padding: 6px 12px; font-size: 11px; }

  /* === 桌面图标 === */
  .desktop-icons {
    top: 6px;
    left: 6px;
    gap: 3px;
    max-height: calc(100vh - 40px);
    flex-direction: column;
    flex-wrap: wrap;
  }
  .desktop-icon {
    width: 52px;
    padding: 4px 2px;
    border-radius: 5px;
  }
  .icon-img {
    font-size: 20px;
    width: 30px;
    height: 30px;
  }
  .icon-img img {
    width: 28px !important;
    height: 28px !important;
  }
  .icon-label { font-size: 9px; margin-top: 2px; line-height: 1.2; }
  .icon-locked-badge { font-size: 10px; bottom: 14px; right: 4px; }

  /* === 桌面便签 === */
  .desktop-note {
    top: 4px;
    right: 4px;
    max-width: 110px;
    font-size: 9px;
    padding: 6px 8px;
    transform: rotate(1deg);
  }
  .desktop-note .note-pin { font-size: 12px; }

  /* === 通知 === */
  .notification-container { top: 4px; left: 4px; gap: 4px; }
  .game-notification {
    font-size: 10px;
    max-width: 180px;
    padding: 4px 10px 4px 7px;
  }

  /* === 图片遮罩 === */
  .img-overlay img {
    max-width: 96vw;
    max-height: 88vh;
  }
  .img-overlay-hint { font-size: 10px; margin-top: 8px; }

  /* === 注册遮罩 === */
  .register-modal {
    width: 280px;
    padding: 20px;
  }

  /* === 应用窗口（通用）=== */
  .app-window {
    min-width: 220px;
    min-height: 140px;
  }
  .win-titlebar {
    height: 28px;
    padding: 0 8px;
  }
  .win-title-icon { font-size: 13px; }
  .win-title-text { font-size: 11px; }
  .win-controls { gap: 5px; }
  .win-btn { width: 10px; height: 10px; }

  /* 横屏时窗口默认最大化（占满可用区域）*/
  .app-window.landscape-fullscreen {
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: calc(100vh - 36px) !important;
    border-radius: 0 !important;
  }

  /* === QQ === */
  .qq-app { flex-direction: row; }
  .qq-sidebar { width: 42px; padding-top: 6px; gap: 6px; }
  .qq-sidebar-icon { width: 32px; height: 32px; font-size: 14px; }
  .qq-sidebar-avatar { width: 30px; height: 30px; font-size: 12px; }
  .qq-nav { width: 160px; }
  .qq-nav-header { padding: 8px; }
  .qq-search { font-size: 11px; padding: 4px 8px; }
  .qq-contact { padding: 7px 8px; gap: 7px; }
  .qq-avatar { width: 28px; height: 28px; font-size: 12px; }
  .qq-contact-name { font-size: 11px; }
  .qq-contact-preview { font-size: 10px; }
  .qq-chat-header { padding: 8px 10px; }
  .qq-chat-name { font-size: 12px; }
  .qq-messages { padding: 10px; gap: 10px; }
  .qq-bubble { font-size: 11px; padding: 6px 9px; }
  .qq-msg-avatar { width: 26px; height: 26px; font-size: 12px; }
  .qq-chat-input-area { padding: 6px 8px; }
  .qq-input-bar { font-size: 11px; padding: 5px 8px; }
  /* QQ空间 */
  .qq-space { padding: 10px; }
  .qq-space-post { padding: 10px; margin-bottom: 10px; border-radius: 6px; }
  .qq-space-text { font-size: 11px; }
  .qq-space-img-grid { grid-template-columns: repeat(3, 64px); gap: 4px; }
  .qq-space-img-item { width: 64px; height: 64px; font-size: 22px; }
  /* QQ chat list */
  .qq-main { flex: 1; min-width: 0; }
  .qq-chat-list { overflow-y: auto; }
  .qq-chat-item { padding: 7px 10px; gap: 8px; }
  .qq-chat-avatar { width: 30px; height: 30px; font-size: 12px; }
  .qq-chat-name { font-size: 11px; }
  .qq-chat-preview { font-size: 10px; }
  .qq-chat-time { font-size: 10px; }

  /* === 抖音 === */
  .douyin-app { flex-direction: row; }
  .douyin-sidebar { width: 100px; padding: 6px 0; }
  .dy-logo { font-size: 13px; padding: 6px 8px; }
  .dy-nav-item { padding: 7px 8px; font-size: 11px; }
  .douyin-main { flex: 1; overflow-y: auto; }
  .dy-section-title { font-size: 12px; padding: 8px 12px; }
  .dy-feed { padding: 0 8px 8px; gap: 10px; }
  .dy-post { padding: 10px; }
  .dy-post-text { font-size: 11px; }
  .dy-post-video { height: 80px; border-radius: 6px; }
  .dy-post-stats { font-size: 10px; gap: 10px; }
  .dy-post-user { font-size: 12px; }
  .dy-post-avatar { width: 28px; height: 28px; font-size: 12px; }
  .dy-profile-header { padding: 12px; gap: 10px; }
  .dy-profile-avatar { width: 50px; height: 50px; font-size: 24px; }
  .dy-profile-name { font-size: 14px; }
  .dy-profile-handle { font-size: 11px; }
  .dy-stat-num { font-size: 14px; }
  .dy-video-grid { grid-template-columns: repeat(3, 1fr); gap: 3px; }
  .dy-video-item { height: 80px; }
  .dy-search-bar { font-size: 12px; padding: 6px 10px; }
  .dy-search-btn { font-size: 12px; padding: 6px 12px; }

  /* === 网易云音乐 === */
  .music-app { flex-direction: row; }
  .music-sidebar { width: 120px; padding: 8px 0; }
  .music-logo { font-size: 12px; padding: 6px 8px 10px; }
  .music-nav-item { padding: 7px 8px; font-size: 11px; }
  .music-nav-label { font-size: 10px; padding: 4px 8px; }
  .music-main { flex: 1; overflow-y: auto; }
  .music-banner { padding: 14px; border-radius: 0; }
  .music-banner-title { font-size: 14px; }
  .music-banner-sub { font-size: 11px; }
  .music-section-title { font-size: 12px; padding: 8px 10px; }
  .music-playlist-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 10px 10px; }
  .music-playlist-card { padding: 10px; border-radius: 6px; }
  .music-playlist-cover { font-size: 24px; margin-bottom: 6px; }
  .music-playlist-name { font-size: 11px; }
  .music-playlist-count { font-size: 10px; }
  .music-track-list { padding: 0 8px; }
  .music-track { padding: 7px 8px; gap: 8px; }
  .music-track-num { font-size: 10px; width: 16px; }
  .music-track-name { font-size: 12px; }
  .music-track-duration { font-size: 10px; }
  .music-player { padding: 8px 12px; height: 64px; }
  .music-player-info { gap: 8px; }
  .music-player-cover { width: 38px; height: 38px; font-size: 18px; }
  .music-player-name { font-size: 12px; }
  .music-player-artist { font-size: 10px; }
  .music-player-controls { gap: 10px; }
  .music-btn { font-size: 14px; }
  .music-btn-play { font-size: 18px; width: 32px; height: 32px; }
  .music-progress-bar { height: 2px; }
  .music-search-bar { font-size: 12px; }
  .music-search-btn { font-size: 12px; }

  /* netease-app (旧版结构) */
  .netease-app { flex-direction: column; }
  .netease-header { padding: 8px 12px; }
  .netease-logo { font-size: 16px; }
  .netease-nav { padding: 0 4px; }
  .netease-nav-item { padding: 7px 8px; font-size: 11px; }

  /* === 浏览器 === */
  .browser-app { flex-direction: column; }
  .browser-toolbar { padding: 4px 6px; gap: 4px; height: 34px; }
  .browser-nav-btn { padding: 0 6px; font-size: 13px; height: 26px; }
  .browser-url-bar { font-size: 11px; padding: 4px 8px; }
  .browser-body { flex: 1; overflow-y: auto; }

  /* === 记事本 === */
  .notepad-app { flex-direction: column; }
  .notepad-toolbar { padding: 4px 8px; gap: 6px; }
  .notepad-btn { font-size: 11px; padding: 4px 8px; }
  .notepad-content { font-size: 12px; padding: 10px; }

  /* === 图书馆 === */
  .library-app { flex-direction: column; }
  .library-header { padding: 10px 12px; }
  .library-body { flex: 1; overflow-y: auto; }
  .library-search-bar { padding: 8px 10px; gap: 6px; }
  .library-input { font-size: 12px; }
  .library-btn { font-size: 11px; padding: 5px 10px; }
  .library-result-card { padding: 10px; margin-bottom: 10px; }

  /* === 回收站 === */
  .recycle-app { flex-direction: column; }
  .recycle-toolbar { padding: 6px 10px; }
  .recycle-grid { gap: 8px; padding: 10px; }
  .recycle-item { padding: 8px; }

  /* === 设置 === */
  .settings-app { flex-direction: row; }
  .settings-sidebar { width: 120px; }
  .settings-sidebar-title { font-size: 12px; padding: 6px 10px 10px; }
  .settings-nav-item { padding: 7px 10px; font-size: 11px; }
  .settings-main { padding: 12px; gap: 12px; }
  .settings-section { padding: 10px 12px; }
  .settings-section-title { font-size: 10px; margin-bottom: 8px; }
  .settings-clue-row { padding: 5px 6px; }
  .settings-clue-label { font-size: 11px; }
  .settings-btn, .settings-btn-danger { font-size: 11px; padding: 5px 10px; }
}

/* ─────────────────────────────────────────
   3. 竖屏小屏（portrait <= 600px）
───────────────────────────────────────── */
@media screen and (orientation: portrait) and (max-width: 600px) {

  .desktop-icons {
    top: 8px;
    left: 8px;
    gap: 5px;
    max-height: calc(100vh - 48px);
    flex-direction: column;
    flex-wrap: wrap;
  }
  .desktop-icon { width: 60px; padding: 5px 3px; }
  .icon-img { font-size: 26px; width: 38px; height: 38px; }
  .icon-img img { width: 34px !important; height: 34px !important; }
  .icon-label { font-size: 10px; }

  .desktop-note {
    top: 8px;
    right: 8px;
    max-width: 130px;
    font-size: 10px;
    padding: 8px 10px;
  }

  /* 竖屏窗口强制全宽 */
  .app-window {
    left: 0 !important;
    width: 100% !important;
    min-width: unset;
    border-radius: 0 !important;
  }

  /* 窗口高度留出任务栏 */
  .app-window {
    max-height: calc(100vh - 40px);
  }

  .taskbar-btn { max-width: 80px; font-size: 10px; }
  #tray-clock { font-size: 10px; min-width: 50px; }
}

/* ─────────────────────────────────────────
   4. 触摸友好 — 增大可点击区域
───────────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  .desktop-icon { min-height: 56px; }
  .taskbar-btn { min-height: 28px; }
  .win-btn { width: 16px !important; height: 16px !important; }
  .qq-contact, .qq-chat-item, .dy-nav-item, .music-nav-item,
  .start-item, .settings-nav-item, .library-btn { min-height: 36px; }
  /* 滚动容器允许触摸滑动 */
  .qq-messages, .qq-contact-list, .qq-chat-list,
  .qq-space, .douyin-main, .music-main, .browser-body,
  .library-results, .recycle-grid, .settings-main,
  .app-shell { -webkit-overflow-scrolling: touch; overflow-y: auto; touch-action: pan-y; }
}
