/* Shared mobile nav takeover — fix/mobile-nav 2026-08-21
 * Loaded by every site/*.html page that ships <nav class="top">.
 * One rule set, one breakpoint (880px), so all 10 pages collapse the same way:
 * main links + CTA buttons move into a hamburger drawer instead of being
 * hidden with no replacement (old bug) or overflowing the viewport (old bug).
 * See reports/fix-mobile-nav-2026-08-21.md for the audit this answers.
 *
 * Relies on design tokens already defined on every page's own :root
 * (--carbon/--rule/--rule-2/--bone/--gutter/--display etc.) — falls back to
 * literal values if a page is missing one, so this file never depends on
 * load order relative to the page's inline <style>.
 */

.nav-burger {
  display: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--rule-2, rgba(255, 255, 255, 0.16));
  background: transparent;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  flex: 0 0 auto;
  -webkit-tap-highlight-color: transparent;
}
.nav-burger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--bone, #e9e7e2);
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.nav-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.nav-burger:focus-visible { outline: 2px solid var(--ignite, #f4c542); outline-offset: 2px; }

/* Desktop/base: the wrapper is transparent to layout — ul/.cta stay direct
   children of nav.top .inner exactly as before this fix, zero visual change. */
.nav-menu { display: contents; }

/* ── 导航"门店状态"挂件 .yf-nav-status ────────────────────────────────
 * CLS 修复 2026-08-25。这段样式原来由 site/js/store-data.js 在运行时注入
 * <style> 塞进 head，搬到这里是因为**它必须在第一帧就位**：
 *
 * 导航条 .inner 是个固定列数的 grid（首页/careers/catering/account/fridge/locations
 * 是 `auto 1fr auto`，mission/privacy/terms 是 `auto 1fr`），这个挂件是后加的第四格。
 * 以前挂件由脚本在 DOMContentLoaded 之后才插进去，grid 装不下就把它换到第二行，
 * 导航条从 72px 撑到 145px，**底下整页被推下去** —— 实测（冷缓存 + Slow 4G + 960×600）
 * 首页 0.731 / careers 0.7371，正是线上 CLS p75 = 0.737 的全部来源；把 store-data.js
 * 拦掉，同一条件下降到 0.001 / 0.0009。
 * 现在挂件的骨架预置在每页 HTML 的 nav 里，样式跟着这份渲染阻塞的样式表一起到，
 * 第一帧就是最终布局 —— 零跳动。
 *
 * 为什么这个 bug 只在四成访问里出现：快网或热缓存下脚本在首屏画完之前就插完了，
 * 没有"跳"这一下。**热缓存 + 桌面 + 快网量出来的 0 不算数。**
 * 回归测试：site/tests/nav-cls-test.js
 */
.yf-nav-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--soft, rgba(233, 231, 226, 0.62));
  white-space: nowrap;
  margin: 0 8px;
}
.yf-nav-status a { color: inherit; }
.yf-nav-status a:hover { color: var(--white, #fff); }
.yf-nav-status .d { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; }
.yf-nav-status .d.is-open {
  background: var(--signal, #a3d977);
  box-shadow: 0 0 6px var(--signal, #a3d977);
  animation: yf-pulse-dot 1.8s ease-in-out infinite;
}
.yf-nav-status .d.is-closed { background: var(--faint, rgba(233, 231, 226, 0.4)); }
@keyframes yf-pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
/* 隐藏阈值 2026-08-25 从 900px 挪到 880px，跟上面汉堡的断点对齐。
 * 原来 881–900px 这一档是「汉堡还没接管，挂件却已经藏了」——导航条只剩三格排成一行，
 * 而这一行本来就装不下 logo + 7 项菜单 + 两个 CTA 按钮，CTA 被挤出视口右边**裁掉**
 * （实测 900×700 下 CTA 右缘 1108px）。对齐之后：≤880 汉堡收纳，>880 挂件在场、
 * grid 排成两行，CTA 落到第二行，完整可见。 */
@media (max-width: 880px) { .yf-nav-status { display: none; } }

/* ≥1360px 一行就装得下 logo + 菜单 + 挂件 + 两个 CTA 按钮 —— 让多出来的格子
 * **自动新开一列**而不是换行，导航条回到各页 <style> 里本来声明的一行三格。
 * 再窄不许开：1280 及以下一行会把 CTA（Book event / Invest）挤出视口右边被裁掉，
 * 那比导航占两行严重得多。
 *
 * 1360 这个数是逐档量出来的下限（2026-08-25 第二轮）：把导航强制排一行后，
 * 从 881px 起每档量一次「格子之间有没有互相压住 + 内容有没有超出容器」，
 * index / careers 这种「全菜单 + 三个 CTA + 挂件」的页面在 1360 首次装得下；
 * 1300 是 account 的下限，881 是 mission/privacy/terms 那种短菜单的下限。
 * 取全站最大值 1360。原来写 1440 是保守值，中间那 80px 白多占一行。
 * 边界两侧(1359 两行 / 1360 一行)都进了 nav-cls-test.js 的宽度扫描。 */
@media (min-width: 1360px) {
  nav.top .inner { grid-auto-flow: column; }
}

@media (max-width: 880px) {
  nav.top .inner {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    position: relative;
    flex-wrap: nowrap;
  }

  .nav-burger { display: inline-flex; }

  .nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--carbon, #141413);
    border-bottom: 1px solid var(--rule, rgba(255, 255, 255, 0.08));
    padding: 8px var(--gutter, 24px) 24px;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
  }
  .nav-menu.is-open { display: flex; }

  .nav-menu ul {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    gap: 0 !important;
    list-style: none;
    width: 100%;
  }
  .nav-menu ul li { border-bottom: 1px solid var(--rule, rgba(255, 255, 255, 0.08)); }
  .nav-menu ul li:last-child { border-bottom: none; }
  .nav-menu ul a { display: block !important; padding: 14px 4px; }

  /* Product dropdown: no hover on touch, so it's always expanded inline
     inside the drawer instead of behaving like a hover popover. */
  .nav-menu .nav-dd-menu {
    position: static !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: none !important;
    display: block !important;
    box-shadow: none !important;
    background: transparent !important;
    border: none !important;
    padding: 0 0 4px 16px !important;
  }
  .nav-menu .nav-dd-menu a { padding: 10px 4px !important; }
  .nav-menu .nav-dd-toggle .dd-caret { display: none; }

  .nav-menu .cta {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--rule, rgba(255, 255, 255, 0.08));
  }
  .nav-menu .cta .btn { justify-content: center; width: 100%; }

  /* Minimal-tier pages (reserve/software: logo + back-link only, no menu to
     collapse) still get the CTA-overflow safety net via nav.top .inner above. */
  .back-link { white-space: normal; text-align: right; }
}

@media (max-width: 420px) {
  nav.top .inner { padding-left: 20px !important; padding-right: 20px !important; }
}
