/* =====================================================================
   responsive.css — 断点兜底
   桌面优先，≤1024 / ≤768 / ≤480 三档收窄。窗口拖拽在移动端关闭（见 windows.js）。
   ===================================================================== */

/* ---------- ≤1024px：窗口收窄，侧栏保持纵向 ---------- */
@media (max-width: 1024px) {
  #window-main,
  #window-works,
  #window-detail,
  #window-timeline,
  #window-now,
  #window-lab,
  #window-help,
  #window-about,
  #window-contact {
    max-width: calc(100vw - 144px);
  }
}

/* ---------- ≤860px：侧栏图标縮小，为窗口让位 ---------- */
@media (max-width: 860px) {
  .sidebar__icon {
    width: 68px;
  }

  .sidebar__glyph {
    width: 26px;
    height: 26px;
  }

  .sidebar__label {
    font-size: 10px;
  }

  .main-window__hero {
    flex-direction: column;
  }

  .main-window__art {
    width: 100%;
  }

  .hero-image {
    flex-direction: row;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    text-align: left;
  }

  .hero-image__portrait {
    width: 64px;
    height: 64px;
  }
}

/* =====================================================================
   ≤768px：移动端 —— 侧栏变横向图标条，窗口铺满一层
   ===================================================================== */
@media (max-width: 768px) {
  body.is-mobile,
  body {
    --taskbar-h: 38px;
  }

  /* 侧栏：横向可滑动的图标条 */
  .sidebar {
    top: 0;
    left: 0;
    right: 0;
    bottom: auto;
    height: 72px;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 2px;
    padding: 4px 6px;
    overflow-x: auto;
    overflow-y: hidden;
    background: linear-gradient(180deg, rgba(26, 5, 37, 0.96), rgba(13, 0, 21, 0.6));
    border-bottom: 1px solid rgba(139, 61, 255, 0.35);
    z-index: var(--z-sidebar);
    scrollbar-width: none;
  }

  .sidebar::-webkit-scrollbar {
    display: none;
  }

  .sidebar__icon {
    flex: 0 0 auto;
    width: 62px;
    padding: 2px;
    gap: 1px;
  }

  .sidebar__glyph {
    width: 28px;
    height: 28px;
  }

  .sidebar__label {
    font-size: 9.5px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  /* 底部安全区（iPhone home indicator）：任务栏和窗口层同步下移 */
  .taskbar {
    height: calc(var(--taskbar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: calc(3px + env(safe-area-inset-bottom, 0px));
  }

  /* 窗口层让出顶部图标条 */
  .windows-layer {
    inset: 74px 0 calc(var(--taskbar-h) + env(safe-area-inset-bottom, 0px)) 0;
  }

  /* 窗口：铺满一层，禁止 JS 像素定位带来的偏移 */
  .windows-layer > .win9x-window {
    left: 6px !important;
    top: 6px !important;
    width: calc(100% - 12px) !important;
    max-width: none !important;
    max-height: calc(100% - 12px) !important;
    height: auto;
    transform: none !important;
  }

  .win9x-window__titlebar {
    cursor: default;
    height: 26px;
  }

  .main-window__title {
    font-size: 18px;
  }

  .main-window__stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main-window__actions .win9x-button {
    flex: 1 1 calc(50% - var(--space-2));
  }

  .works-grid {
    grid-template-columns: minmax(0, 1fr);
    max-height: none;
    padding: var(--space-2);
  }

  .works-detail__meta {
    grid-template-columns: minmax(0, 1fr);
  }

  .status-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .contact-list__row {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .notepad__text {
    font-size: 12px;
    padding: var(--space-3);
  }

  .word__page {
    padding: var(--space-3);
  }

  /* 任务栏瘦身 */
  .taskbar__tray-icon {
    display: none;
  }

  .taskbar__clock {
    min-width: 56px;
    font-size: 13px;
  }

  .taskbar-item {
    max-width: 118px;
  }

  /* 开始菜单铺满宽度 */
  .start-menu {
    right: 6px;
    left: 6px;
    bottom: calc(var(--taskbar-h) + 2px);
  }

  .start-menu__body {
    flex: 1;
    min-width: 0;
  }

  .start-menu__list {
    max-height: 52vh;
  }

  /* 助手气泡：贴底整条 */
  .barkley {
    left: 6px;
    right: 6px;
    width: auto;
    bottom: calc(var(--taskbar-h) + 6px);
  }

  .boot__log {
    font-size: 13px;
    min-height: 84px;
  }

  .boot__title {
    font-size: 10px;
  }

  .shutdown {
    font-size: 10px;
  }
}

/* ---------- ≤420px：进一步压缩 ---------- */
@media (max-width: 420px) {
  .main-window__status {
    font-size: 14px;
    gap: var(--space-1) var(--space-2);
  }

  .main-window__status .win9x-status-bar__item:last-child {
    display: none;
  }

  .works-toolbar__count {
    margin-left: 0;
  }

  .taskbar__start-text {
    display: none;
  }

  .works-card__title {
    font-size: 12px;
  }

  .excel__table {
    font-size: 11px;
  }
}

/* ---------- 横屏手机：顶部条更薄 ---------- */
@media (max-width: 768px) and (orientation: landscape) and (max-height: 480px) {
  .sidebar {
    height: 56px;
  }

  .sidebar__label {
    display: none;
  }

  .windows-layer {
    inset: 58px 0 var(--taskbar-h) 0;
  }
}

/* ---------- 打印：只留正文 ---------- */
@media print {
  .desktop__stars,
  .desktop__grid,
  .crt-overlay,
  .sidebar,
  .taskbar,
  .start-menu,
  .barkley {
    display: none !important;
  }
}
