/* base.css — 手写基础设施样式（WEB-SPEC §2/§3/§7）
 * 1. WXML 标签 shim（view/text/scroll-view 等 display 规则）
 * 2. wx.* UI：toast / loading / modal / action-sheet / picker（深空风格，复用 tokens 变量）
 * 3. 桌面 backdrop + 手机壳（375×812、刘海、假状态栏）+ 移动端全屏
 * 注：:root 变量镜像 tokens.css，供手机壳/弹层等 .mp-page 之外的元素使用。
 */

/* ---------- 0. 全局 reset + token 镜像 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

:root {
  --bg-deep: #0B0D10;
  --bg-card: #12151B;
  --bg-elevated: #1A1F27;
  --brand-orange: #E45A1B;
  --brand-blue: #2C71E8;
  --brand-gold: #D99A2B;
  --text-primary: #F4F2EA;
  --text-secondary: #9AA3AF;
  --text-tertiary: #67707C;
  --divider: #232A34;
  --success: #2FA86E;
  --danger: #D64541;
  --light-bg: #F4F2EA;
  --radius-card: 14px;
  --radius-btn: 12px;
  --space-page: 16px;
  /* 手机壳内度量（供 vh / safe-area 换算） */
  --mp-vh: 8.12px;        /* 812 / 100 */
  --mp-safe-bottom: 17px; /* 模拟 iPhone Home 指示条 */
  --mp-status-h: 24px;
  --mp-tabbar-h: 50px;
}

body {
  background: #05070A;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', 'Helvetica Neue', Arial, sans-serif;
  overflow: hidden;
}

/* ---------- 1. WXML 标签 shim（§2 原文） ---------- */
view, text, scroll-view, swiper, swiper-item { display: block; box-sizing: border-box; }
text { display: inline; }
scroll-view { overflow-y: auto; -webkit-overflow-scrolling: touch; }
scroll-view[scroll-x] { overflow-x: auto; overflow-y: hidden; }
image { display: inline-block; }
button { border: none; background: none; padding: 0; font: inherit; color: inherit; }
/* 兼容其余 WXML 标签 */
block { display: contents; }
input, textarea {
  display: block; box-sizing: border-box;
  background: none; border: none; outline: none;
  font: inherit; color: var(--text-primary);
}
picker, switch { display: block; box-sizing: border-box; }

/* ---------- 2. 桌面 backdrop（§7） ---------- */
#backdrop {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(600px 400px at 18% 12%, rgba(228, 90, 27, 0.14) 0%, transparent 60%),
    radial-gradient(700px 500px at 85% 85%, rgba(44, 113, 232, 0.13) 0%, transparent 60%),
    radial-gradient(400px 300px at 70% 20%, rgba(217, 154, 43, 0.07) 0%, transparent 60%),
    #05070A;
}
#backdrop::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(154, 163, 175, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(154, 163, 175, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
}
#backdrop-caption {
  position: fixed; left: 24px; bottom: 20px; z-index: 1;
  font-size: 12px; color: var(--text-tertiary); letter-spacing: 1px;
}

/* ---------- 3. 手机壳（§7） ---------- */
#stage { width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center; }
#phone { width: 100vw; height: 100vh; overflow: hidden; position: relative; background: var(--bg-deep); margin: 0; border: none; border-radius: 0; box-shadow: none; }
/* 刘海条 */
#phone-notch {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  width: 120px; height: 22px; border-radius: 12px;
  background: #05070A; z-index: 60; pointer-events: none;
}
/* 假状态栏：9:41 / 信号 / 电池（覆盖在页面之上，与小程序沉浸式一致） */
#phone-statusbar {
  position: absolute; top: 0; left: 0; right: 0; height: var(--mp-status-h);
  z-index: 55; pointer-events: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px 0 28px;
  font-size: 11px; font-weight: 600; color: var(--text-primary);
}
#phone-statusbar .sb-icons { display: flex; align-items: center; gap: 5px; font-weight: 400; }
#phone-statusbar .sb-battery {
  display: inline-block; width: 18px; height: 9px;
  border: 1px solid rgba(244, 242, 234, 0.55); border-radius: 2.5px; position: relative;
}
#phone-statusbar .sb-battery::after {
  content: ''; position: absolute; inset: 1px; right: 4px;
  background: var(--text-primary); border-radius: 1px;
}
/* 壳内品牌小字 */
#phone-brand {
  position: absolute; top: 30px; right: 12px; z-index: 54; pointer-events: none;
  font-size: 9px; color: var(--text-tertiary); opacity: 0.75; letter-spacing: 0.5px;
  writing-mode: vertical-rl;
}

/* ---------- 4. 路由视口 ---------- */
#viewport {
  position: absolute; inset: 0; z-index: 10;
  background: var(--bg-deep);
  overflow: hidden;
}
.mp-page {
  position: absolute; inset: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* 注意:不要在这里加 transform/filter —— 会让 fixed 元素随内容滚动;锚定已上移到 #phone */
  scrollbar-width: none;
}
.mp-page::-webkit-scrollbar { display: none; }
/* tab 页：为 tab bar 让出底部 */
#viewport.has-tabbar .mp-page { bottom: calc(var(--mp-tabbar-h) + var(--mp-safe-bottom)); }

/* ---------- 5. Tab Bar（PRD 3.6：SVG 图标 + 中间凸起发布钮） ---------- */
#tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--mp-tabbar-h) + var(--mp-safe-bottom));
  padding-bottom: var(--mp-safe-bottom);
  display: none;
  background: linear-gradient(180deg, #161A21 0%, #12151B 100%);
  border-top: 0.5px solid rgba(244, 242, 234, 0.07);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.28);
}
#viewport.has-tabbar ~ #tabbar, #tabbar.show { display: flex; }
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; cursor: pointer; color: #67707C; user-select: none;
  transition: color 150ms ease;
}
.tab-item .tab-icon { display: flex; align-items: center; justify-content: center; line-height: 1; }
.tab-item .tab-text { font-size: 10px; }
.tab-item.active { color: #E45A1B; }
/* 中间「发布」凸起圆钮：56px、超出 tab bar 上缘、橙底白 plus、柔和高光 */
.tab-item.tab-center { overflow: visible; }
.tab-fab {
  width: 56px; height: 56px; border-radius: 50%;
  margin-top: -30px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  background: linear-gradient(145deg, #F06823 0%, #E45A1B 60%, #D34E14 100%);
  border: 3px solid var(--bg-deep);
  box-shadow:
    0 8px 20px rgba(228, 90, 27, 0.42),
    0 2px 6px rgba(0, 0, 0, 0.35),
    inset 0 2px 3px rgba(255, 255, 255, 0.30),
    inset 0 -3px 6px rgba(120, 40, 5, 0.35);
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.tab-item.tab-center:active .tab-fab {
  transform: scale(0.93);
  box-shadow:
    0 4px 10px rgba(228, 90, 27, 0.38),
    0 2px 6px rgba(0, 0, 0, 0.35),
    inset 0 2px 3px rgba(255, 255, 255, 0.30),
    inset 0 -3px 6px rgba(120, 40, 5, 0.35);
}
/* Home 指示条 */
#home-indicator {
  position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%);
  width: 120px; height: 4px; border-radius: 2px;
  background: rgba(244, 242, 234, 0.35); z-index: 56; pointer-events: none;
}

/* ---------- 6. wx.* UI 弹层（§3，深空风格） ---------- */
#wx-overlay { position: absolute; inset: 0; z-index: 90; pointer-events: none; }
#wx-overlay > * { pointer-events: auto; }

/* toast：顶部居中黑色胶囊 */
.wx-toast {
  position: absolute; top: 88px; left: 50%; transform: translateX(-50%);
  max-width: 280px; padding: 9px 18px;
  background: rgba(18, 21, 27, 0.96);
  border: 0.5px solid var(--divider);
  border-radius: 999px;
  color: var(--text-primary); font-size: 13px; line-height: 1.4;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  animation: wx-toast-in 160ms ease-out;
  display: flex; align-items: center; gap: 6px;
}
.wx-toast .wx-toast-icon { font-size: 14px; }
.wx-toast .wx-toast-icon.success { color: var(--success); }
.wx-toast .wx-toast-icon.error { color: var(--danger); }
@keyframes wx-toast-in { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* loading */
.wx-loading-mask {
  position: absolute; inset: 0; background: rgba(5, 7, 10, 0.35);
  display: flex; align-items: center; justify-content: center;
}
.wx-loading {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 20px 26px; border-radius: 14px;
  background: rgba(18, 21, 27, 0.96); border: 0.5px solid var(--divider);
}
.wx-loading .wx-spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--bg-elevated); border-top-color: var(--brand-orange);
  animation: wx-spin 700ms linear infinite;
}
.wx-loading .wx-loading-text { font-size: 13px; color: var(--text-secondary); }
@keyframes wx-spin { to { transform: rotate(360deg); } }

/* modal：居中弹层 */
.wx-mask {
  position: absolute; inset: 0; background: rgba(5, 7, 10, 0.62);
  display: flex; align-items: center; justify-content: center;
  animation: wx-fade-in 150ms ease-out;
}
@keyframes wx-fade-in { from { opacity: 0; } to { opacity: 1; } }
.wx-modal {
  width: 292px; border-radius: 16px; overflow: hidden;
  background: var(--bg-card); border: 0.5px solid var(--divider);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
  animation: wx-pop-in 180ms ease-out;
}
@keyframes wx-pop-in { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
.wx-modal-title {
  padding: 20px 20px 0; text-align: center;
  font-size: 16px; font-weight: 600; color: var(--text-primary);
}
.wx-modal-content {
  padding: 12px 20px 20px; text-align: center;
  font-size: 14px; line-height: 1.6; color: var(--text-secondary);
}
.wx-modal-btns { display: flex; border-top: 0.5px solid var(--divider); }
.wx-modal-btn {
  flex: 1; padding: 13px 0; text-align: center; font-size: 15px;
  color: var(--text-secondary); cursor: pointer; user-select: none;
}
.wx-modal-btn + .wx-modal-btn { border-left: 0.5px solid var(--divider); }
.wx-modal-btn.confirm { color: var(--brand-orange); font-weight: 600; }
.wx-modal-btn:active { background: var(--bg-elevated); }

/* action-sheet：底部弹层 */
.wx-sheet-mask {
  position: absolute; inset: 0; background: rgba(5, 7, 10, 0.62);
  display: flex; align-items: flex-end; justify-content: center;
  animation: wx-fade-in 150ms ease-out;
}
.wx-sheet {
  width: 100%; border-radius: 18px 18px 0 0; overflow: hidden;
  background: var(--bg-card); border-top: 0.5px solid var(--divider);
  padding-bottom: var(--mp-safe-bottom);
  animation: wx-slide-up 200ms ease-out;
}
@keyframes wx-slide-up { from { transform: translateY(40%); opacity: 0.4; } to { transform: translateY(0); opacity: 1; } }
.wx-sheet-item {
  padding: 15px 0; text-align: center; font-size: 15px;
  color: var(--text-primary); cursor: pointer; user-select: none;
  border-bottom: 0.5px solid var(--divider);
}
.wx-sheet-item:active { background: var(--bg-elevated); }
.wx-sheet-cancel {
  margin-top: 8px; padding: 15px 0; text-align: center; font-size: 15px;
  color: var(--text-tertiary); cursor: pointer; user-select: none;
  background: var(--bg-elevated);
}

/* picker：底部滚动选择层（UI.picker 用） */
.wx-picker { width: 100%; background: var(--bg-card); border-radius: 18px 18px 0 0; overflow: hidden; animation: wx-slide-up 200ms ease-out; }
.wx-picker-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 16px; border-bottom: 0.5px solid var(--divider);
}
.wx-picker-head .pk-cancel { color: var(--text-tertiary); font-size: 14px; cursor: pointer; }
.wx-picker-head .pk-title { font-size: 14px; color: var(--text-secondary); }
.wx-picker-head .pk-confirm { color: var(--brand-orange); font-size: 14px; font-weight: 600; cursor: pointer; }
.wx-picker-list { max-height: 260px; overflow-y: auto; padding-bottom: var(--mp-safe-bottom); }
.wx-picker-option {
  padding: 14px 20px; font-size: 15px; color: var(--text-primary);
  border-bottom: 0.5px solid var(--divider); cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
}
.wx-picker-option.selected { color: var(--brand-orange); }
.wx-picker-option.selected::after { content: '✓'; color: var(--brand-orange); }
.wx-picker-option:active { background: var(--bg-elevated); }

/* ---------- 7. 路由级通用元素 ---------- */
/* 非 tab 页返回箭头（router 渲染，页面无自定义 nav 时兜底） */
.mp-router-back {
  position: absolute; top: calc(var(--mp-status-h) + 6px); left: 10px; z-index: 40;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(18, 21, 27, 0.72); border: 0.5px solid var(--divider);
  color: var(--text-primary); font-size: 18px; cursor: pointer; user-select: none;
  backdrop-filter: blur(6px);
}
/* 占位页（页面建设中） */
.mp-placeholder {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; padding: 32px;
}
.mp-placeholder .ph-icon { font-size: 44px; }
.mp-placeholder .ph-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.mp-placeholder .ph-route { font-size: 12px; color: var(--text-tertiary); font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }
.mp-placeholder .ph-btn {
  margin-top: 8px; padding: 9px 26px; border-radius: 999px;
  border: 1px solid var(--brand-orange); color: var(--brand-orange);
  font-size: 14px; cursor: pointer; user-select: none;
}
.mp-placeholder .ph-btn:active { background: rgba(228, 90, 27, 0.12); }

/* ---------- 8. 移动端（宽 < 480px）：去壳全屏（§7） ---------- */
@media (max-width: 480px) {
  #backdrop, #backdrop-caption, #phone-notch, #phone-brand, #phone-statusbar, #home-indicator { display: none; }
  body { overflow: auto; }
  #stage { width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center; }
  #phone { width: 100vw; height: 100vh; overflow: hidden; position: relative; background: var(--bg-deep); margin: 0; border: none; border-radius: 0; box-shadow: none; }
  :root { --mp-vh: 1vh; --mp-status-h: env(safe-area-inset-top, 24px); --mp-safe-bottom: env(safe-area-inset-bottom, 0px); }
}

/* 桌面高度不足时整体缩放手机壳(保留 translateZ 以维持 fixed 锚定) */
@media (min-width: 481px) and (max-height: 880px) {
  #phone { width: 100vw; height: 100vh; overflow: hidden; position: relative; background: var(--bg-deep); margin: 0; border: none; border-radius: 0; box-shadow: none; }
}

/* 隐藏 WebKit 滚动条（保持小程序观感） */
scroll-view::-webkit-scrollbar, .mp-page::-webkit-scrollbar, .hscroll::-webkit-scrollbar { display: none; width: 0; height: 0; }
scroll-view, .mp-page, .hscroll { scrollbar-width: none; }

/* ==================================================================
 * 9. 视觉打磨（SVG 图标系统配套 + 质感提升，追加于原 base 之后）
 * ================================================================== */

/* ---------- 9.1 全局字体渲染 ---------- */
body, .mp-page {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
/* 中文长文行高优化（阅读区） */
.pc-content, .comment-content, .desc-para, .overlay-text, .result-desc {
  line-height: 1.7;
}

/* ---------- 9.2 SVG 图标基础对齐（.ic 由 Icons.get 输出） ---------- */
svg.ic {
  display: inline-block;
  vertical-align: -0.15em; /* 与相邻文字基线对齐 */
  flex: none;              /* flex 容器内不被压缩 */
}
view > svg.ic:only-child, text > svg.ic:only-child,
button > svg.ic:only-child { vertical-align: 0; }
/* 仅含图标的 flex 容器居中 */
.info-icon, .search-icon, .locate-icon, .nav-search,
.service-icon, .grid-icon, .reminder-icon, .interact-icon, .entry-icon,
.draft-icon, .car-emoji, .model-icon, .mask-tip-icon, .example-emoji,
.verify-icon, .mg-icon, .msg-icon, .id-icon, .illus, .result-emoji,
.related-icon, .ph-icon, .empty-icon, .cover-icon-btn, .tab-icon,
.wx-toast-icon, .mate-checked, .id-check, .cover-opt-check, .checkbox {
  display: flex;
  align-items: center;
  justify-content: center;
}
text.wx-toast-icon, text.mate-checked, text.cover-opt-check { display: inline-flex; }
/* 旋转加载图标（toast loading） */
.ic-spin { animation: wx-spin 800ms linear infinite; }

/* ---------- 9.3 主按钮按下态（在 tokens 的 opacity 之上叠加缩放反馈） ---------- */
.btn-primary, .btn-secondary, .btn-danger {
  transition: transform 120ms ease, opacity 150ms ease, background 150ms ease;
}
.btn-primary:active { transform: scale(0.97); }

/* ---------- 9.4 深色卡片微高光（ inset 顶部亮边， tokens .card 无 box-shadow 不冲突） ---------- */
.mp-page .card {
  box-shadow: inset 0 1px 0 rgba(244, 242, 234, 0.04);
}

/* ---------- 9.5 toast / modal 入场动画统一 150ms fade+scale ---------- */
.wx-toast { animation: wx-toast-in 150ms ease-out; }
.wx-modal { animation: wx-pop-in 150ms cubic-bezier(0.2, 0.9, 0.3, 1.2); }

/* ---------- 9.6 页面导航统一：毛玻璃 + 标题层级一致 ---------- */
.page-nav {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.page-nav .page-nav-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.page-nav .page-nav-back { cursor: pointer; }

/* ---------- 9.7 占位页图标配色 ---------- */
.mp-placeholder .ph-icon { color: var(--text-tertiary); }

/* ---------- 9.8 tab bar 图标/文字间距微调 ---------- */
.tab-item .tab-icon svg.ic { vertical-align: 0; }

/* ---------- 10. 真实图片接入（AI 品牌视觉 assets/img） ---------- */
/* 通用封面图：父容器需 position:relative + 固定尺寸/宽高比 + overflow:hidden */
.cover-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}


