/* layout.css — 顶栏 / 首页搜索 / 网格 / 分页圆点 / 风车 */

/* ---------- 顶栏 ---------- */
#topbar {
  position: fixed; top: 18px; right: 20px;
  z-index: 30;
  display: flex; align-items: center; gap: 10px;
}
#menu-btn { width: 38px; height: 38px; }

/* ---------- 首页 ---------- */
#home {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center;
  overflow: hidden;
  padding-bottom: 90px;
  scrollbar-width: none;
  touch-action: pan-y; /* 触屏上横向拖动交给翻页手势，纵向滚动保留 */
}
#home::-webkit-scrollbar { display: none; }

/* 搜索区 */
#search-wrap {
  position: relative;
  margin-top: clamp(64px, 12vh, 132px);
  display: flex; flex-direction: column; align-items: center;
  flex: 0 0 auto;
  width: 100%;
  z-index: 20;
}
#search-cats {
  display: flex; align-items: center; justify-content: center;
  gap: clamp(18px, 2.4vw, 34px);
  margin-bottom: 17px;
  height: 20px;
}
#search-cats button {
  font-size: 14px; font-weight: 300;
  color: var(--icon-font-color);
  opacity: 0.5;
  padding: 0;
  transition: opacity var(--dur-fast);
}
#search-cats button:hover { opacity: 0.85; }
#search-cats button.active { opacity: 1; font-weight: 400; }

#search-card {
  position: relative;
  display: flex; align-items: center;
  width: var(--search-width);
  height: 53px;
  background: rgba(255, 255, 255, var(--search-opacity));
  border-radius: var(--search-radius);
  box-shadow: var(--shadow-search);
  transform: scale(var(--search-scale));
  transform-origin: center top;
  overflow: hidden;
  transition: box-shadow var(--dur-fast);
}
#search-card:focus-within { box-shadow: var(--shadow-search), 0 6px 22px rgba(0, 0, 0, 0.14); }
.cell:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 3px;
  border-radius: 14px;
}
.cell:focus-visible .icon { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35); }
#engine-btn {
  display: flex; align-items: center; gap: 4px;
  height: 100%; padding: 0 10px 0 14px;
  flex: 0 0 auto; color: #8b909c;
}
#engine-logo {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700; color: #fff;
  background: #4c8bf5;
}
#engine-btn .caret { width: 9px; height: 6px; color: #9aa0ac; }
#search-input {
  flex: 1; min-width: 0; height: 100%;
  font-size: 15px; color: #2b2f36;
  padding: 0 6px 0 4px;
  background: transparent;
}
#search-input::placeholder { color: #9aa0ac; }
#search-clear {
  width: 30px; height: 30px; flex: 0 0 auto;
  border-radius: 50%; display: none; place-items: center;
  color: #8b909c; margin-right: 4px;
}
#search-clear.visible { display: grid; }
#search-clear:hover { background: #f0f1f4; color: #444; }
#search-clear svg { width: 14px; height: 14px; }
#search-submit {
  width: 52px; height: 100%; flex: 0 0 auto;
  display: none; place-items: center;
  background: var(--c-accent); color: #fff;
}
#search-submit.visible { display: grid; }
#search-submit svg { width: 18px; height: 18px; }

/* 搜索建议 */
#suggest-list {
  position: absolute;
  top: calc(100% + 6px);
  width: var(--search-width);
  padding: 6px;
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-pop);
  z-index: 60;
  transform: scale(var(--search-scale));
  transform-origin: center top;
  max-height: 292px; overflow: auto;
}
#suggest-list button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px; color: #3a3f48; text-align: left;
}
#suggest-list button:hover, #suggest-list button.active { background: var(--c-panel-soft); }
#suggest-list .s-ico { width: 14px; height: 14px; color: #9aa0ac; flex: 0 0 auto; }
#suggest-list .s-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-hint { padding: 6px 10px 8px; font-size: 11px; color: #9aa0ac; }

/* ---------- 网格（三层轮播轨道） ---------- */
#pager-track {
  position: relative;
  width: 100%;
  flex: 0 0 auto;
  margin-top: calc(clamp(26px, 4.4vh, 46px) + var(--grid-offset, 0px));
  will-change: transform;
  touch-action: pan-y; /* 双保险：#home 已有，轨道层面再显式声明 */
  /* 高度由 JS 同步为当前层内容高度，避免空页/满页切换时布局跳动 */
}

.page-layer {
  position: absolute;
  top: 0;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  column-gap: var(--col-gap);
  row-gap: var(--row-gap);
  justify-content: center;
  align-content: start;
}

.page-layer[data-role="prev"] { left: 0; }
.page-layer[data-role="current"] { left: 100%; }
.page-layer[data-role="next"] { left: 200%; }

.page-layer.drop-url {
  outline: 1px dashed rgba(255, 255, 255, 0.45);
  outline-offset: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
}

.cell {
  position: relative;
  width: var(--cell); height: var(--row-h);
  display: flex; flex-direction: column; align-items: center;
  padding: 0; background: none;
  color: inherit;
  cursor: pointer;
}
.cell .icon {
  position: relative;
  width: var(--icon-size); height: var(--icon-size);
  border-radius: var(--icon-radius);
  display: grid; place-items: center;
  background: #fff;
  color: #fff;
  opacity: var(--icon-opacity);
  box-shadow: var(--icon-shadow);
  overflow: hidden;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast);
  will-change: transform;
  flex: 0 0 auto;
}
.cell:hover .icon { transform: translateY(-3px) scale(1.07); box-shadow: 0 10px 22px rgba(0, 0, 0, 0.26); }
.cell:active .icon { transform: scale(0.97); }
.cell .label {
  margin-top: 8px;
  max-width: calc(var(--cell) * 0.96);
  font-size: var(--icon-font-size);
  line-height: 1.35;
  color: var(--icon-font-color);
  text-shadow: var(--icon-text-shadow, none);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: center;
}
body.hide-label .cell .label { display: none; }
body.no-anim .cell { animation: none !important; }

.cell.start-animate { animation: card-zoom var(--dur-slow) var(--ease) backwards; }
body.anim-fade .cell.start-animate { animation-name: card-fade; }
body.anim-bounce .cell.start-animate { animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1); }

/* 真实图标 */
.cell .favicon {
  width: 62%; height: 62%;
  object-fit: contain;
  border-radius: 8px;
  display: block;
  pointer-events: none;
}
/* 只在首次入场时做一次缩放淡入；翻页/重排的重建不再重播，避免整屏闪 */
.cell.start-animate .favicon { animation: fav-in 180ms ease-out both; }
/* 深色品牌底上的单色图标反白 */
.cell .favicon.mono { filter: invert(1); }
@keyframes fav-in { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: none; } }
.cell .letter {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  font-size: calc(var(--icon-size) * 0.36);
  font-weight: 600; color: #fff;
  letter-spacing: 0.01em;
}

/* 图标右上角编辑按钮 */
.cell .cell-menu {
  position: absolute; top: -4px; right: calc((var(--cell) - var(--icon-size)) / 2 - 4px);
  width: 24px; height: 24px; border-radius: 50%;
  display: none; place-items: center;
  background: #fff; color: #5b6270;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 3;
}
.cell:hover .cell-menu { display: grid; }
.cell .cell-menu:hover { color: var(--c-accent); }

/* 文件夹卡片：3×3 迷你九宫格，一眼看清里面有什么 */
.cell .icon.folder-icon {
  background: rgba(255, 255, 255, 0.86);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4.5%;
  padding: 11%;
  backdrop-filter: blur(10px);
}
.folder-mini {
  width: 100%; height: 100%;
  border-radius: calc(var(--icon-size) * 0.06);
  background: #eef0f4; overflow: hidden;
  display: grid; place-items: center;
  color: #fff; font-size: calc(var(--icon-size) * 0.11); font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
.folder-mini img { width: 76%; height: 76%; object-fit: contain; }
.folder-empty-ico { width: 34%; height: 34%; color: #b9bec9; }

/* 小组件 */
.cell .icon.widget-icon { background: #fff; }
.widget-icon svg { width: 52%; height: 52%; }
.cell.widget-weather .icon { background: linear-gradient(160deg, #2ca8ff 0%, #1677ff 100%); color: #fff; }
.widget-weather .icon svg { width: 60%; height: 60%; }
.cell.widget-todo .icon { background: linear-gradient(160deg, #65d67f 0%, #21b95c 100%); color: #fff; }
.cell.widget-note .icon { background: linear-gradient(160deg, #6aa8ff 0%, #2f77f2 100%); color: #fff; }
.cell.widget-settings .icon { background: linear-gradient(160deg, #f2f3f6 0%, #e6e8ee 100%); color: #7b8290; }
.cell.widget-folder .icon { background: rgba(255, 255, 255, 0.9); color: #8b909c; }
.cell.widget-walls .icon { background: linear-gradient(160deg, #7b8cff 0%, #6a5cff 100%); color: #fff; }
.widget-folder .icon svg { width: 48%; height: 48%; }
 .widget-badge {
  position: absolute; top: 0; right: calc((var(--cell) - var(--icon-size)) / 2 - 2px);
  min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: var(--radius-pill);
  background: #ff3b30; color: #fff;
  font-size: 11px; font-weight: 600; line-height: 19px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.24);
}
.widget-weather .label { font-weight: 500; }

/* 添加卡片 */
.add-cell .icon {
  background: rgba(255, 255, 255, 0.18);
  border: 2px dashed rgba(255, 255, 255, 0.6);
  color: rgba(255, 255, 255, 0.92);
  box-shadow: none;
  backdrop-filter: blur(4px);
}
.add-cell .icon svg { width: 34%; height: 34%; }
.add-cell .label { color: rgba(255, 255, 255, 0.9); }
.add-cell:hover .icon { background: rgba(255, 255, 255, 0.28); }

/* 拖拽 */
.cell.dragging { opacity: 0.35; }
.cell.drop-before::before,
.cell.drop-after::after {
  content: ""; position: absolute; top: 8%; height: 62%;
  width: 3px; border-radius: 3px; background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.cell.drop-before::before { left: calc(var(--col-gap) / -2 - 1px); }
.cell.drop-after::after { right: calc(var(--col-gap) / -2 - 1px); }
.cell.drop-into .icon { box-shadow: 0 0 0 3px var(--c-accent); }

/* 空网格提示 */
.grid-empty {
  grid-column: 1 / -1;
  text-align: center; color: rgba(255, 255, 255, 0.72);
  font-size: 13px; padding: 30px 0 6px;
}

/* ---------- 空白处按住左键拖动翻页 ---------- */
body.swiping, body.swiping .cell, body.swiping .label {
  user-select: none; -webkit-user-select: none;
  cursor: grabbing;
}

/* ---------- 分页圆点 ---------- */
#pager {
  position: fixed; left: 0; right: 0; bottom: 22px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  z-index: 25;
  pointer-events: none;
  transition: opacity var(--dur-base), transform var(--dur-base);
}
#pager > * { pointer-events: auto; }
#dots { display: flex; align-items: center; gap: 10px; }
#dots:empty { display: none; }
/* Dock 出现时把圆点抬到 Dock 上方，避免被 Dock 盖住 */
body.has-dock #pager { bottom: calc(var(--dock-bottom) + var(--dock-i) * 1.5 * var(--dock-scale, 1) + 14px); }
.page-num { font-size: 11.5px; letter-spacing: 0.02em; color: rgba(255, 255, 255, 0.82); }
.page-dot {
  width: 8px; height: 8px; border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.42);
  transition: width var(--dur-base) var(--ease), background var(--dur-base);
  position: relative;
}
/* 视觉仍是 8px，但命中区域向外扩 7px，底部小点不再难点 */
.page-dot::before { content: ""; position: absolute; inset: -7px -5px; }
.page-dot:hover { background: rgba(255, 255, 255, 0.7); }
.page-dot.active { width: 20px; background: #fff; }
.page-dot.dragging { opacity: 0.4; }
.page-dot.drop-target { background: var(--c-accent); }
.dot-add {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.9);
  margin-left: 2px;
  transition: background var(--dur-fast);
}
.dot-add svg { width: 12px; height: 12px; }
.dot-add:hover { background: rgba(255, 255, 255, 0.4); }
.page-arrow {
  width: 30px; height: 30px; border-radius: 50%;
  display: none; place-items: center;
  color: #fff; background: rgba(255, 255, 255, 0.16);
}
.page-arrow.visible { display: grid; }
.page-arrow svg { width: 16px; height: 16px; }
#page-prev { position: fixed; left: 18px; top: 50%; transform: translateY(-50%); }
#page-next { position: fixed; right: 18px; top: 50%; transform: translateY(-50%); }

/* ---------- 拖拽边缘翻页热区 ---------- */
/* 宽度覆盖左右各 78px，拖拽时出现，松手或停留 550ms 即把图标移入相邻分页 */
.page-drop {
  position: fixed; top: 0; bottom: 0;
  width: 78px; height: auto;
  display: grid; place-items: center;
  z-index: 45;
  color: #fff;
  opacity: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(20, 24, 32, 0.22), rgba(20, 24, 32, 0));
  transition: opacity 150ms, background 150ms;
}
#page-drop-left { left: 0; }
#page-drop-right { right: 0; background: linear-gradient(270deg, rgba(20, 24, 32, 0.22), rgba(20, 24, 32, 0)); }
.page-drop svg { width: 26px; height: 26px; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.4)); }
body.dragging .page-drop { opacity: 1; pointer-events: auto; }
.page-drop.active { background: rgba(255, 255, 255, 0.22); }
/* 拖拽时侧边的常驻箭头让位给热区，避免两个箭头叠在一起 */
body.dragging .page-arrow { opacity: 0; pointer-events: none; }

/* 面板打开时淡出分页/风车 */
body.panel-open #pager,
body.panel-open #windmill { opacity: 0; pointer-events: none; }

/* ---------- 风车 ---------- */
#windmill {
  position: fixed; right: 22px; bottom: 22px; z-index: 26;
  width: 44px; height: 44px;
  background: #fff;
  color: #ff5a5f;
}
#windmill svg { width: 24px; height: 24px; }
#windmill.spinning svg { animation: spin var(--dur-slow) var(--ease); }
#windmill.disabled { opacity: 0.4; pointer-events: none; }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  :root { --cell: clamp(96px, 10.6vw, 124px); --col-gap: clamp(18px, 2vw, 28px); --row-gap: 22px; }
}
@media (max-height: 880px) {
  #search-wrap { margin-top: 9vh; }
  #pager-track { margin-top: calc(26px + var(--grid-offset, 0px)); }
  :root { --cell: clamp(108px, 9vw, 132px); --row-gap: 20px; --row-h: calc(var(--cell) * 0.93); }
}
@media (max-height: 740px) {
  #search-wrap { margin-top: 56px; }
  #pager-track { margin-top: calc(26px + var(--grid-offset, 0px)); }
  :root { --row-h: calc(var(--cell) * 0.92); }
}

/* ---------- macOS 风格 Dock ---------- */
:root {
  --dock-bottom: clamp(12px, 2.4vh, 22px);
  /* 实际图标尺寸由 dock.js 按图标数量与视口宽度写入，这里只给兜底值 */
  --dock-i: var(--dock-size, 48px);
}

#dock {
  position: fixed; left: 50%; bottom: var(--dock-bottom);
  transform: translateX(-50%) scale(var(--dock-scale, 1));
  transform-origin: bottom center;
  z-index: 36;
  display: flex; align-items: flex-end; justify-content: center;
  gap: clamp(3px, 0.55vw, 8px);
  padding: calc(var(--dock-i) * 0.14) clamp(7px, 0.9vw, 13px);
  border-radius: calc(var(--dock-i) * 0.44);
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(26px) saturate(185%);
  -webkit-backdrop-filter: blur(26px) saturate(185%);
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.28),
    0 3px 10px rgba(0, 0, 0, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 0 0 1px rgba(255, 255, 255, 0.24);
  transition: background var(--dur-fast), box-shadow var(--dur-fast), opacity var(--dur-base);
}
#dock.hidden { display: none; }
/* 水平位置：左 / 居中 / 右 */
body.dock-align-left #dock {
  left: 20px; transform: scale(var(--dock-scale, 1)); transform-origin: bottom left;
}
body.dock-align-right #dock {
  left: auto; right: 20px; transform: scale(var(--dock-scale, 1)); transform-origin: bottom right;
}
#dock.dock-drop {
  background: rgba(255, 255, 255, 0.4);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.3), inset 0 0 0 2px rgba(45, 107, 254, 0.85);
}
.dock-empty {
  padding: calc(var(--dock-i) * 0.2) calc(var(--dock-i) * 0.38);
  font-size: 12px; color: rgba(255, 255, 255, 0.92);
  white-space: nowrap; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.dock-item {
  position: relative;
  width: var(--dock-i); height: var(--dock-i);
  flex: 0 0 auto;
  display: flex; align-items: flex-end; justify-content: center;
  background: none; border: 0; padding: 0;
  transform-origin: bottom center;
  transition: transform 180ms var(--ease-out);
}
.dock-item .dock-icon {
  width: calc(var(--dock-i) * 0.82);
  height: calc(var(--dock-i) * 0.82);
  border-radius: calc(var(--dock-i) * 0.24);
  overflow: hidden;
  display: grid; place-items: center;
  background: #fff;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.22), inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  color: #fff;
  transition: box-shadow 180ms var(--ease-out);
}
.dock-item:hover .dock-icon {
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}
.dock-item .dock-icon .favicon { width: 62%; height: 62%; }
.dock-item .dock-icon .letter { font-size: calc(var(--dock-i) * 0.34); font-weight: 600; }
.dock-item:hover { transform: scale(1.32) translateY(-8px); }
.dock-item:hover + .dock-item,
.dock-item:has(+ .dock-item:hover) { transform: scale(1.1) translateY(-3px); }
.dock-item .dock-label {
  position: absolute; left: 50%; bottom: calc(100% + 10px);
  transform: translateX(-50%) translateY(4px);
  padding: 5px 9px; border-radius: 7px;
  background: rgba(24, 28, 36, 0.86); color: #fff;
  font-size: 11.5px; line-height: 1.2; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity 120ms, transform 120ms;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.dock-item:hover .dock-label { opacity: 1; transform: translateX(-50%) translateY(0); }
.dock-item.dragging { opacity: 0.4; }
.dock-item.drop-before::before,
.dock-item.drop-after::after {
  content: ""; position: absolute; top: 10%; bottom: 10%;
  width: 3px; border-radius: 3px; background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.dock-item.drop-before::before { left: -5px; }
.dock-item.drop-after::after { right: -5px; }
.dock-folder {
  width: 100%; height: 100%;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  gap: 2px; padding: calc(var(--dock-i) * 0.09);
  background: rgba(255, 255, 255, 0.92);
}
.dock-folder > svg { grid-column: 1 / -1; grid-row: 1 / -1; width: 55%; height: 55%; margin: auto; color: #9aa0ac; }
.dock-mini {
  width: 100%; height: 100%;
  border-radius: 4px; overflow: hidden;
  display: grid; place-items: center;
  font-size: calc(var(--dock-i) * 0.16); color: #fff; font-weight: 600;
  background: #eef0f4;
}
.dock-mini img { width: 70%; height: 70%; object-fit: contain; }

/* Dock 独立悬浮，不推动分页圆点 / 风车 / 网格 */
body.panel-open #dock,
body.panel-open #pager { opacity: 0; pointer-events: none; }
@media (max-height: 720px) {
  :root { --dock-bottom: 10px; }
  .dock-item .dock-label { font-size: 11px; padding: 4px 7px; }
}
body.dock-no-magnify .dock-item:hover,
body.dock-no-magnify .dock-item:hover + .dock-item,
body.dock-no-magnify .dock-item:has(+ .dock-item:hover) { transform: none; }
/* Dock 里的内置小组件 */
.dock-item .dock-icon.widget { color: #fff; }
.dock-item .dock-icon.widget svg { width: 56%; height: 56%; }
.dock-item .dock-icon.widget-weather { background: linear-gradient(160deg, #2ca8ff, #1677ff); }
.dock-item .dock-icon.widget-todo { background: linear-gradient(160deg, #65d67f, #21b95c); }
.dock-item .dock-icon.widget-note { background: linear-gradient(160deg, #6aa8ff, #2f77f2); }
.dock-item .dock-icon.widget-settings { background: linear-gradient(160deg, #f2f3f6, #e6e8ee); color: #7b8290; }
.dock-item .dock-icon.widget-walls { background: linear-gradient(160deg, #7b8cff, #6a5cff); }
.dock-item .dock-icon.widget-folder { background: rgba(255, 255, 255, 0.92); color: #8b909c; }
