/* =====================================================================
 * home-layout.css
 * 主界面 4+4 布局 + Dock + 小组件 样式
 * 覆盖 style.css 中的 3×3 布局，作用域限定在 #home-screen
 * ===================================================================== */

/* ---------- 主屏幕整体结构 ---------- */
#home-screen .content {
  height: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  box-sizing: border-box;
  overflow: hidden;
}

#home-screen .header-content {
  flex: 0 0 auto;
  padding-top: calc(env(safe-area-inset-top, 0px) + 30px);
  padding-bottom: 4px;
}

/* 略微缩小主屏时钟，给 Dock 留出空间 */
#home-screen .clock span {
  font-size: 84px;
}

#home-screen .motto-container {
  margin-top: 6px;
  margin-bottom: 14px;
}

/* ---------- 上半区：2×2 网格 (可滚动) + 2×2 小组件 ---------- */
#home-screen .home-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  width: 100%;
  padding: 0 18px 14px; /* 底部留白 = 整体上移量，越大整体越靠上 */
  gap: 12px;
  box-sizing: border-box;
}

/* 左侧 App 网格：2 列，可上下滚动 (含 5 个 App) */
#home-screen .app-grid {
  flex: 0 0 50%;
  width: 50%;
  min-height: 0;
  height: 190px; /* 固定两行 (4 个 App)，多余的 App 下滑查看 */
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: min-content;
  gap: 22px 10px;
  padding: 6px 2px 14px;
  margin: 0;
  justify-items: center;
  align-content: start;

  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
#home-screen .app-grid::-webkit-scrollbar { display: none; }

/* 右侧 2×2 小组件容器 */
#home-screen .home-widget-area {
  flex: 0 0 50%;
  width: 50%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* ---------- 图标归一化 ---------- */
#home-screen .app-icon {
  width: 54px;
  height: 54px;
  margin-bottom: 0;
}
#home-screen .app-icon img {
  width: 100%;
  height: 100%;
}
#home-screen .app-name {
  transform: translateY(0);
  margin-top: 7px;
  font-size: 11px;
  font-weight: 500;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* ---------- Dock 底栏 ---------- */
#home-screen .home-dock {
  flex: 0 0 auto;
  margin: 8px 16px calc(env(safe-area-inset-bottom, 0px) + 18px);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 10px 8px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.5);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.10);
}

#home-screen .home-dock .app-icon {
  width: 48px;
  height: 48px;
}
#home-screen .home-dock .app-name {
  margin-top: 5px;
  font-size: 10px;
}

/* Dock 内单个 App 容器 */
#home-screen .home-dock .app-container {
  min-width: 0;
}

/* =====================================================================
 * 小组件容器
 * ===================================================================== */
#home-screen .home-widget {
  width: 100%;
  height: 170px; /* 与 grid 两行内容等高 */
  margin-bottom: 14px; /* 对齐 grid 底部 padding(14px)，让卡片底部对齐第二行 App 名字 */
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.15s ease;
}
#home-screen .home-widget:active {
  transform: scale(0.97);
}

/* 长按菜单 / 小组件切换 Action Sheet */
.hw-sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 9990;
  background: rgba(0, 0, 0, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.hw-sheet-mask.show { opacity: 1; pointer-events: auto; }

.hw-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9991;
  margin: 0 auto;
  max-width: 360px;
  padding: 8px 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-radius: 22px 22px 0 0;
  transform: translateY(100%);
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  box-sizing: border-box;
}
.hw-sheet.show { transform: translateY(0); pointer-events: auto; }

.hw-sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.16);
  margin: 4px auto 10px;
}

.hw-sheet-title {
  text-align: center;
  font-size: 13px;
  color: #8a8a8e;
  margin-bottom: 6px;
  font-weight: 500;
}

.hw-sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 8px;
  border: none;
  background: transparent;
  border-radius: 14px;
  font-size: 15px;
  color: #111;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.hw-sheet-item:active { background: rgba(0, 0, 0, 0.06); }
.hw-sheet-item .hw-sheet-item-icon {
  font-size: 22px;
  width: 28px;
  text-align: center;
}
.hw-sheet-item .hw-sheet-item-icon svg {
  vertical-align: middle;
  flex: none;
}
.hw-sheet-item .hw-sheet-item-arrow {
  margin-left: auto;
  color: #c7c7cc;
  font-size: 16px;
}
.hw-sheet-item.disabled { color: #c7c7cc; }

.hw-sheet-cancel {
  width: 100%;
  margin-top: 6px;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.05);
  font-size: 15px;
  font-weight: 600;
  color: #111;
  cursor: pointer;
}
.hw-sheet-cancel:active { background: rgba(0, 0, 0, 0.10); }

/* ---------- App 网格首屏滑动提示 ---------- */
#home-screen .app-grid-scroll-hint {
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  z-index: 40;
}
#home-screen .app-grid-scroll-hint.show { opacity: 1; }
