/* ============================================================================
   layout.css — 页面骨架层
   依赖 tokens.css + base.css
   结构：顶部命令栏 .cmdbar（sticky 毛玻璃）→ .page 容器（max 1440px）
        → .grid-3/.grid-2 响应式栅格（>1200三栏 / 640-1200两栏 / <640单栏）
        → 手机底部Tab .bottom-tabs；票档案抽屉 .drawer；Ctrl+K搜索面板 .search-modal
   ============================================================================ */

/* ---------- 锚点滚动留白：hash 跳转目标不被毛玻璃命令栏盖住 ---------- */
[id] { scroll-margin-top: calc(var(--cmdbar-h) + var(--sp-2)); }

/* ============================================================================
   顶部命令栏 .cmdbar（sticky + 毛玻璃）
   内容：.brand 标识区 | .search-trigger 假搜索框 | .cmdbar-nav 导航组 | .meta 生成时间+状态灯
   ============================================================================ */
.cmdbar {
  position: sticky;
  top: 0;
  z-index: var(--z-bar);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  height: var(--cmdbar-h);
  padding: 0 var(--sp-5);
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.3);        /* 毛玻璃感 */
  -webkit-backdrop-filter: blur(14px) saturate(1.3); /* Safari */
  border-bottom: 1px solid var(--bd);
}
/* 视觉2.0：命令栏底部蓝→金渐变发光细线 */
.cmdbar::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, var(--blue) 0%, transparent 45%, transparent 55%, var(--gold) 100%);
  opacity: .55;
  pointer-events: none;
}

/* 标识区：渐变主标 + 金点 + 小字副标 */
.brand { display: flex; align-items: baseline; gap: 10px; flex-shrink: 0; }
.brand-name {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: .5px;
  white-space: nowrap;
  background: linear-gradient(120deg, #dbe7ff 20%, var(--blue) 75%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;   /* 渐变文字 */
}
.brand-name::before { content: '◆'; color: var(--gold); font-size: var(--fs-xs); margin-right: 6px; vertical-align: 2px; }
.brand-sub { font-size: var(--fs-xs); color: var(--txt-3); white-space: nowrap; }

/* Ctrl+K 假搜索框（点击唤起搜索面板） */
.search-trigger {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 250px;
  flex-shrink: 1;
  padding: 6px 12px;
  background: var(--grad-blue);               /* 蓝渐变实底——顶栏最显眼入口（用户要求"更显眼的颜色"） */
  border: 1px solid rgba(111, 178, 255, .55);
  border-radius: 999px;                       /* 胶囊搜索框（视觉2.0） */
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(76, 157, 255, .30);
  transition: filter var(--t-fast), box-shadow var(--t-fast);
}
.search-trigger::before { content: '🔍'; font-size: var(--fs-sm); opacity: .95; }
.search-trigger:hover { filter: brightness(1.12); box-shadow: 0 2px 16px rgba(76, 157, 255, .50); }
.search-trigger .st-txt { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-trigger kbd { flex-shrink: 0; border-color: rgba(255, 255, 255, .4); color: #fff; background: rgba(255, 255, 255, .12); }

/* 导航按钮组（5页） */
.cmdbar-nav { display: flex; gap: var(--sp-1); margin-left: var(--sp-2); flex: 1; min-width: 0; }
.cmdbar-nav .btn { padding: 6px 14px; font-size: var(--fs-md); }

/* 右侧元信息：生成时间 + 数据状态灯 */
.meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--txt-3);
  white-space: nowrap;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ============================================================================
   页面容器与响应式栅格
   ============================================================================ */
.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-6) var(--sp-6);
}

/* 栅格工具类：三栏 / 两栏（纵向起始对齐，避免拉伸） */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); align-items: start; }

/* ============================================================================
   票档案抽屉 .drawer（右侧滑入）+ 遮罩 .overlay
   ============================================================================ */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 94vw);
  z-index: var(--z-drawer);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--bd-2);
  box-shadow: var(--shadow-3);
  transform: translateX(105%);
  transition: transform var(--t-mid);
}
.drawer.open { transform: none; }
/* 视觉2.0：抽屉左缘金色发光细线 */
.drawer::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: -1px;
  width: 2px;
  background: linear-gradient(180deg, var(--blue), var(--gold));
  opacity: .7;
  pointer-events: none;
}
.drawer-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--bd);
  flex-shrink: 0;
}
.drawer-t { font-size: var(--fs-lg); font-weight: 700; }
.drawer-x {
  padding: 4px 8px;
  border-radius: var(--r-sm);
  color: var(--txt-3);
  font-size: var(--fs-lg);
  line-height: 1;
  cursor: pointer;
}
.drawer-x:hover { color: var(--txt); background: var(--tbl-hover); }
.drawer-b { flex: 1; overflow-y: auto; padding: var(--sp-4); overscroll-behavior: contain; }

/* 遮罩（抽屉/搜索共用） */
.overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: var(--overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-mid);
}
.overlay.show { opacity: 1; pointer-events: auto; }

/* ============================================================================
   Ctrl+K 搜索面板 .search-modal（居中浮层，kbd 导航）
   ============================================================================ */
.search-modal {
  position: fixed;
  top: 10vh;
  left: 50%;
  transform: translate(-50%, -14px) scale(.98);
  width: min(680px, calc(100vw - 2 * var(--sp-4)));
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  z-index: var(--z-modal);
  background: var(--panel);
  border: 1px solid var(--bd-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3), var(--glow-blue);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-mid), transform var(--t-spring);   /* 弹性缩放入场 */
}
.search-modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, 0) scale(1); }

.sm-head { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--bd); flex-shrink: 0; }
.sm-head::before { content: '🔍'; font-size: var(--fs-lg); opacity: .7; }
.sm-input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--txt); font-size: var(--fs-lg); }
.sm-input::placeholder { color: var(--txt-3); }

.sm-results { flex: 1; overflow-y: auto; padding: var(--sp-2); overscroll-behavior: contain; }
.sm-item { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); cursor: pointer; }
.sm-item:hover, .sm-item.active { background: var(--blue-a15); }   /* ↑↓键盘选中态 */
.sm-item .si-t { color: var(--txt); font-size: var(--fs-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-item .si-d { margin-left: auto; color: var(--txt-3); font-size: var(--fs-xs); white-space: nowrap; }
.sm-empty { padding: var(--sp-6) 0; text-align: center; color: var(--txt-3); font-size: var(--fs-md); }

.sm-foot {
  display: flex;
  gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-4);
  border-top: 1px solid var(--bd);
  color: var(--txt-3);
  font-size: var(--fs-xs);
  flex-shrink: 0;
}
.sm-foot .k-hint { display: flex; align-items: center; gap: 4px; }

/* ============================================================================
   手机底部Tab .bottom-tabs（<640 显示；桌面隐藏）
   ============================================================================ */
.bottom-tabs {
  display: none;   /* 仅手机显示，见文末媒体查询 */
}
.btab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: var(--tabs-h);
  color: var(--txt-3);
  font-size: var(--fs-xs);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btab .bi { font-size: var(--fs-lg); line-height: 1; }   /* 图标位（emoji） */
.btab.on { color: var(--blue); font-weight: 600; }

/* ============================================================================
   断点一：≤1200px 平板 —— 三栏降两栏
   ============================================================================ */
@media (max-width: 1200px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cmdbar { gap: var(--sp-3); padding: 0 var(--sp-4); }
  .search-trigger { width: 190px; }
}

/* ============================================================================
   断点二：≤640px 手机 —— 单栏 + 命令栏简化 + 底部Tab接管导航
   ============================================================================ */
@media (max-width: 640px) {
  .page { padding: var(--sp-3) var(--sp-3) var(--sp-5); }

  /* 命令栏简化：藏副标与 kbd 提示，导航交给底部Tab */
  .cmdbar { gap: var(--sp-3); padding: 0 var(--sp-3); }
  .brand-sub { display: none; }
  .search-trigger { flex: 1; width: auto; }
  .search-trigger kbd { display: none; }
  .cmdbar-nav { display: none; }

  /* 单栏 */
  .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }

  /* body 留出底部Tab高度 + 安全区，防内容被遮挡 */
  body { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); }

  /* 底部Tab浮层（视觉2.0：悬浮胶囊Dock——离边留隙+圆角+大阴影+金线） */
  .bottom-tabs {
    display: flex;
    position: fixed;
    left: var(--sp-3);
    right: var(--sp-3);
    bottom: calc(var(--sp-2) + env(safe-area-inset-bottom));
    z-index: var(--z-tabs);
    background: var(--glass);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border: 1px solid var(--bd-2);
    border-radius: 20px;
    box-shadow: var(--shadow-3);
    overflow: hidden;
    padding-bottom: 0;   /* Dock自带安全区偏移，不再内垫 */
  }
  .bottom-tabs::before {
    content: '';
    position: absolute;
    left: 12%; right: 12%; top: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--blue), transparent);
    opacity: .6;
    pointer-events: none;
  }
  .btab { border-radius: 0; }   /* Dock内格子去圆角 */
  .btab.on { background: var(--blue-a15); }   /* 激活格淡蓝底 */

  /* toast 抬到Tab之上 */
  .toast { bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + var(--sp-3)); }

  /* 搜索面板占满近全屏 */
  .search-modal { top: 6vh; max-height: 76vh; }
}
