/* ============================================================
   WenzFlow 官网手机端适配（对齐设计稿 design/web/v7）
   ≤768px：抽屉导航 + 单列栅格 + 浮层目录；≤380px：收紧内边距与字号。
   仅公开页面引入，桌面端样式不受影响。

   渐进增强：抽屉、文档目录浮层、隐私目录折叠都依赖
   assets/wenzflow-mobile.js 追加的 html.mobile-nav-ready 类；
   脚本未加载时退回原有桌面/窄屏样式，内容仍可访问。
   ============================================================ */

/* ── 手机端图标按钮：默认隐藏，仅手机端出现 ── */
.mobile-nav-toggle,
.docs-nav-toggle { display: none; }

/* ── 抽屉导航 ── */
.mobile-nav-drawer { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 70; }
.mobile-nav-drawer[hidden] { display: none !important; }
.mobile-nav-scrim { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: rgba(9, 9, 11, 0.44); }
.mobile-nav-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: 84%;
  max-width: 330px;
  border-left: 1px solid var(--border);
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  animation: mobileDrawerIn 0.32s var(--ease-out);
}
@keyframes mobileDrawerIn {
  from { transform: translateX(18px); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}
.mobile-nav-head { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--border); }
.mobile-nav-title { font-size: 14px; font-weight: 600; }
.mobile-nav-close { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--text-secondary); }
.mobile-nav-close:hover { background: var(--bg-muted); color: var(--text); }
.mobile-nav-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mobile-nav-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px; }
.mobile-nav-body > a,
.mobile-nav-parent {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  font-weight: 400;
  color: var(--text);
  text-align: left;
}
.mobile-nav-body > a:hover,
.mobile-nav-parent:hover { background: var(--bg-muted); }
.mobile-nav-body > a[aria-current="page"] { color: var(--accent); }
.mobile-nav-parent[aria-expanded="true"] { color: var(--accent); }
svg.mobile-nav-caret { flex: 0 0 auto; width: 16px; height: 16px; transition: transform 0.2s ease; }
.mobile-nav-parent[aria-expanded="true"] .mobile-nav-caret { transform: rotate(180deg); }
.mobile-nav-sub { margin: 2px 0 8px 12px; padding-left: 12px; border-left: 1px solid var(--border); }
.mobile-nav-sub[hidden] { display: none !important; }
.mobile-nav-sub-head { margin: 12px 0 4px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); }
.mobile-nav-sub a { display: block; min-height: 44px; padding: 10px; border-radius: 8px; font-size: 14px; color: var(--text); overflow-wrap: anywhere; }
.mobile-nav-sub a:hover { background: var(--accent-soft); color: var(--accent); }
.mobile-nav-sub a span { display: block; margin-top: 2px; font-size: 12px; color: var(--text-secondary); }
.mobile-nav-sub-status { margin: 4px 0 0; padding: 0 10px; font-size: 12px; line-height: 1.7; color: var(--text-muted); }
.mobile-nav-sub-status[hidden] { display: none !important; }
.mobile-nav-foot { flex: 0 0 auto; display: grid; gap: 10px; padding: 14px 16px calc(18px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border); }
.mobile-nav-foot .btn { min-height: 48px; }
.mobile-nav-note { font-size: 12px; line-height: 1.7; color: var(--text-muted); }
svg.nav-glyph { flex: 0 0 auto; width: 20px; height: 20px; }
@media (min-width: 769px) { .mobile-nav-drawer { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .mobile-nav-panel { animation: none; } }

/* ── 手机端顶栏、触控与页脚 ── */
@media (max-width: 768px) {
  .site-header .container-wide { padding: 0 16px; }
  .site-header .bar { height: 56px; gap: 8px; }
  .brand { min-width: 0; gap: 10px; font-size: 15px; }
  /* 品牌图标固定 28px，窄屏只压缩文字，不缩放 logo。 */
  .brand img { flex: 0 0 auto; }
  .brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .header-actions { flex: 0 0 auto; gap: 6px; }
  .theme-toggle { width: 40px; height: 40px; }
  .theme-toggle svg { width: 17px; height: 17px; }
  html.mobile-nav-ready .nav-icon-btn,
  html.mobile-nav-ready .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: transparent;
    color: var(--text);
  }
  html.mobile-nav-ready .nav-icon-btn:hover,
  html.mobile-nav-ready .mobile-nav-toggle:hover { background: var(--bg-muted); }
  html.mobile-nav-ready .nav-icon-btn:focus-visible,
  html.mobile-nav-ready .mobile-nav-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  /* 触控尺寸：主按钮 ≥44px，次要按钮 ≥40px */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 40px; }
  .grid-bg { background-size: 44px 44px; }

  /* 抽屉可用时把登录入口收进抽屉底部，并锁定背景滚动 */
  html.mobile-nav-ready .header-actions [data-auth-entry],
  html.mobile-nav-ready .header-actions [data-mobile-auth-entry] { display: none; }
  html.mobile-nav-ready body.mobile-nav-open { overflow: hidden; }

  /* 页脚链接双列 */
  .site-footer { padding: 32px 0; }
  .site-footer .cols { gap: 20px; }
  .site-footer .flex,
  .site-footer nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 16px; width: 100%; }
  .site-footer .flex a,
  .site-footer nav a { display: flex; align-items: center; min-height: 40px; font-size: 13px; }
  .section { padding: 40px 0; }
}

/* ── 首页 ── */
@media (max-width: 768px) {
  .home-hero { min-height: auto; padding: 104px 20px 56px; }
  .home-hero h1 { margin: 16px 0; font-size: 40px; line-height: 1.14; }
  .home-subtitle { min-height: 0; margin: 0 auto 16px; font-size: 16px; line-height: 1.75; white-space: normal; overflow-wrap: anywhere; }
  .home-intro { font-size: 15px; line-height: 1.85; }
  .home-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 24px; }
  .home-actions .btn { min-height: 48px; width: 100%; }
  .home-caption { margin-top: 16px; }
  .home-section { padding: 40px 20px; }
  .home-section .h2 { font-size: 24px; line-height: 1.36; }
  .home-section-intro { margin-top: 12px; font-size: 14px; line-height: 1.85; }
  .home-grid { gap: 12px; margin-top: 20px; }
  .home-feature,
  .home-step { padding: 20px; }
  .home-feature h3,
  .home-step h3 { margin-top: 10px; font-size: 17px; }
  .home-feature p,
  .home-step p { font-size: 13.5px; line-height: 1.85; }
  .home-memory { padding: 20px; }
  .home-ending { padding: 40px 20px; }
  .home-ending .h2 { font-size: 24px; line-height: 1.4; }
}

/* ── 产品与工具 ── */
@media (max-width: 768px) {
  .products-wrap { padding: 96px 16px 40px; }
  .product-tabs { gap: 8px; margin-bottom: 14px; padding-bottom: 12px; }
  .product-tab { min-height: 40px; padding: 8px 16px; font-size: 13px; }
  .product-hero { padding: 20px; }
  .product-detail-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .product-section { padding: 20px; }
  .product-file { display: flex; flex-direction: column; gap: 8px; padding: 16px; }
  .product-file .btn { width: 100%; min-height: 44px; justify-content: flex-start; text-align: left; white-space: normal; overflow-wrap: anywhere; line-height: 1.5; }
  .product-hash { margin-top: 0; font-size: 11px; line-height: 1.6; word-break: break-all; }
  .product-copy { font-size: 14px; line-height: 1.85; }
  .product-download { flex-wrap: wrap; max-width: 100%; }
  .product-platform-menu { right: auto; left: 0; width: max-content; max-width: calc(100vw - 32px); }
  .product-platform-item { min-height: 44px; }
  #product-releases .card { padding: 20px; }
  #product-downloads .flex { gap: 8px; }
}

/* ── 定价与套餐 ── */
@media (max-width: 768px) {
  .pricing-wrap { padding: 96px 16px 40px; }
  .pricing-head { padding-bottom: 20px; margin-bottom: 20px; }
  .pricing-head h1 { font-size: 24px; }
  .pricing-layout { display: block; }
  .pricing-sidebar { position: static; margin-bottom: 20px; }
  .pricing-sidebar nav { display: flex; gap: 8px; margin-top: 10px; max-height: none; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
  .pricing-sidebar nav::-webkit-scrollbar { display: none; }
  .pricing-product { flex: 0 0 auto; min-height: 40px; padding: 8px 16px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 13px; }
  .pricing-product-name { flex: 0 0 auto; overflow: visible; white-space: nowrap; }
  .pricing-product[aria-current] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
  .pricing-product[aria-current] small { color: rgba(255, 255, 255, 0.82); }
  .pricing-card { padding: 20px; }
  .pricing-card h2 { font-size: 20px; }
  .pricing-price-block { padding: 20px 0; }
  .pricing-amount { font-size: 30px; }
  .pricing-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .pricing-actions .btn { width: 100%; min-width: 0; min-height: 48px; }
  .pricing-trial { padding: 20px; }
  .pricing-trial-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .pricing-trial-row .input,
  .pricing-trial-row .btn { width: 100%; min-width: 0; min-height: 44px; }
  .product-plan-grid { grid-template-columns: minmax(0, 1fr); }
  .product-plan-card { padding: 20px; }
  .product-plan-price { font-size: 30px; }
  .product-plan-card .btn { align-self: stretch; min-height: 48px; }
}

/* ── 文档中心：正文占满屏宽，目录收进浮层 ── */
@media (max-width: 768px) {
  .docs-layout { padding: calc(56px + 20px) 16px 40px; }
  .docs-reader { padding: 0 0 32px; }
  .docs-reader h1 { margin: 10px 0 6px; font-size: 22px; }
  .docs-content { margin-top: 24px; font-size: 15px; line-height: 1.9; }
  .docs-content pre { padding: 14px; }
  .docs-content table { max-width: 100%; overflow-x: auto; }
  .docs-content td,
  .docs-content th { padding: 8px 12px; }
}
@media (max-width: 768px) {
  html.mobile-nav-ready .docs-page { --docs-header-height: 56px; }
  html.mobile-nav-ready .docs-page .site-header .bar { height: 56px; flex-wrap: nowrap; }
  html.mobile-nav-ready .docs-page .docs-nav-toggle { flex: 0 0 auto; }
  html.mobile-nav-ready .docs-page .brand { margin-right: auto; }
  html.mobile-nav-ready .docs-page .site-nav { display: none; }
  html.mobile-nav-ready .docs-layout { display: block; }
  html.mobile-nav-ready .docs-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 70;
    display: block;
    width: min(84%, 330px);
    max-height: none;
    /* 显式给视口高度：.docs-layout 的入场动画会让 fixed 的包含块退化，仅靠 top/bottom 铺不满。 */
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    padding: 14px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    border: 0;
    border-right: 1px solid var(--border);
    background: var(--bg);
    box-shadow: var(--shadow-lg);
    transform: translateX(-101%);
    transition: transform 0.28s var(--ease-out);
  }
  html.mobile-nav-ready .docs-sidebar nav { margin-top: 14px; max-height: none; overflow: visible; }
  html.mobile-nav-ready .docs-sidebar summary { min-height: 44px; align-items: center; }
  html.mobile-nav-ready .docs-tree-label { padding: 10px 10px 10px 25px; }
  html.mobile-nav-ready .docs-link { min-height: 44px; display: flex; align-items: center; }
  html.mobile-nav-ready body.docs-nav-open .docs-sidebar { transform: none; }
  html.mobile-nav-ready body.docs-nav-open { overflow: hidden; }
  html.mobile-nav-ready body.docs-nav-open::before { content: ""; position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 65; background: rgba(9, 9, 11, 0.44); }
}
@media (prefers-reduced-motion: reduce) { html.mobile-nav-ready .docs-sidebar { transition: none; } }

/* ── 隐私协议：目录折叠 + 正文单列 ── */
.privacy-toc-toggle { display: none; }
@media (max-width: 768px) {
  .privacy-wrap { padding: 96px 16px 40px; }
  .privacy-heading { margin-bottom: 20px; }
  .privacy-heading h1 { font-size: 30px; }
  .privacy-layout { display: block; }
  .privacy-toc { position: static; margin-bottom: 20px; padding: 0; background: var(--surface); }
  .privacy-toc ol { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0 4px 8px; }
  .privacy-toc a { display: flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 8px; font-size: 14px; }
  .privacy-toc a:hover { background: var(--bg-muted); }
  .privacy-toc.is-collapsible h2 { display: none; }
  .privacy-toc.is-collapsible .privacy-toc-toggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 48px; padding: 0 14px; border: 0; border-radius: var(--radius-sm); background: transparent; font-family: inherit; font-size: 14px; font-weight: 600; color: var(--text); text-align: left; }
  .privacy-toc.is-collapsible .privacy-toc-toggle:hover { background: var(--bg-muted); }
  .privacy-toc.is-collapsible ol { display: none; }
  .privacy-toc.is-collapsible.is-open ol { display: grid; }
  svg.privacy-toc-caret { flex: 0 0 auto; width: 16px; height: 16px; color: var(--text-muted); transition: transform 0.18s ease; }
  .privacy-toc.is-open .privacy-toc-caret { transform: rotate(180deg); }
  .privacy-content { font-size: 15px; }
  .privacy-content h2 { font-size: 19px; }
  .privacy-content section { scroll-margin-top: 72px; }
  .privacy-summary { padding: 18px; }
}

/* ── 窄屏收紧（≤380px） ── */
@media (max-width: 380px) {
  .mobile-nav-panel { width: 92%; }
  .home-hero { padding: 100px 16px 48px; }
  .home-hero h1 { font-size: 34px; }
  .home-section { padding: 32px 16px; }
  .home-section .h2,
  .home-ending .h2 { font-size: 22px; }
  .home-feature,
  .home-step,
  .home-memory { padding: 16px; }
  .products-wrap { padding: 92px 14px 40px; }
  .product-hero,
  .product-section,
  #product-releases .card { padding: 16px; }
  .pricing-wrap { padding: 92px 14px 40px; }
  .pricing-card { padding: 18px; }
  .pricing-amount { font-size: 28px; }
  .privacy-wrap { padding: 92px 14px 40px; }
  .privacy-heading h1 { font-size: 26px; }
  .privacy-summary { padding: 16px; }
  .docs-layout { padding: calc(56px + 16px) 12px 32px; }
}
