/* ==========================================================================
   Rockcent Base Layer v1.0  |  2026-11-12
   全站基础层：只含「不改变既有视觉」的兜底规则，可安全注入所有页面。

   刻意不放进本文件的规则（避免视觉回归，留待第二阶段组件重构时接入）：
     * { box-sizing: border-box }     会改变既有盒模型
     body { background/color/font }   会覆盖各页现有排版
     html { scroll-behavior: smooth } 会改变锚点行为
   ========================================================================== */

/* 评估实测：覆盖 40+ 页的 partner.css / blog.css 中 focus-visible 为 0。
   这一条是全站兜底；任何组件都不许覆盖为 outline: none 而不给替代焦点态。 */
:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 3px;
  border-radius: var(--r-card);
}

/* 评估实测：prefers-reduced-motion 只在 3 套 CSS 中有覆盖，此条全站生效。 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* 跳转到主要内容：新类名，不与既有样式冲突；页面接入时按此契约使用。 */
.rc-skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -100px;
  z-index: var(--z-toast);
  padding: var(--sp-2) var(--sp-4);
  color: var(--on-accent);
  background: var(--accent);
  border-radius: var(--r-card);
  font-family: var(--font-sans);
  font-size: var(--fs-label);
  text-decoration: none;
}
.rc-skip-link:focus {
  top: var(--sp-4);
}

/* ==========================================================================
   企微顾问入口（浮动形态） | 2026-11-13
   由 js/wecom-line-qr.js 在没有页脚二维码节点的页面自动注入：
   右下角「加企业微信」按钮 + 点击展开的二维码面板。
   放在基础层的原因：全站 46 页都加载 base.css，注入的 DOM 需要全站一致的兜底样式。
   命名统一用 rc-wecom-fab-* 前缀，与既有 .rc-cta-container / #lechen-chat-button 不冲突。
   ========================================================================== */

.rc-wecom-fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: var(--z-float);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--sp-2);
  font-family: var(--font-sans);
}

/* 按钮本体 */
.rc-wecom-fab-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 0 var(--sp-4);
  border: 1px solid var(--accent);
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-sans);
  font-size: var(--fs-label);
  font-weight: var(--fw-semibold);
  letter-spacing: .02em;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .38);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.rc-wecom-fab-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
}
.rc-wecom-fab-btn:active {
  transform: translateY(0);
}

/* 微信图标：用 SVG 背景画，不引入图标字体，也不写死颜色 */
.rc-wecom-fab-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.2 3.4c-4 0-7.2 2.7-7.2 6 0 1.9 1.1 3.6 2.8 4.7l-.7 2.1 2.4-1.2c.8.2 1.6.4 2.5.4h.5a5.3 5.3 0 0 1-.2-1.4c0-3.2 3.2-5.8 7.2-5.8h.6c-.6-2.9-3.6-4.8-7.9-4.8zm-2.4 3.4a.9.9 0 1 1 0 1.8.9.9 0 0 1 0-1.8zm4.8 0a.9.9 0 1 1 0 1.8.9.9 0 0 1 0-1.8zM14.8 9.1c-3.4 0-6.1 2.2-6.1 4.9s2.7 4.9 6.1 4.9c.7 0 1.4-.1 2-.3l1.9 1-.5-1.7c1.4-.9 2.3-2.3 2.3-3.9 0-2.7-2.7-4.9-5.7-4.9zm-2 2.9a.8.8 0 1 1 0 1.6.8.8 0 0 1 0-1.6zm4 0a.8.8 0 1 1 0 1.6.8.8 0 0 1 0-1.6z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.2 3.4c-4 0-7.2 2.7-7.2 6 0 1.9 1.1 3.6 2.8 4.7l-.7 2.1 2.4-1.2c.8.2 1.6.4 2.5.4h.5a5.3 5.3 0 0 1-.2-1.4c0-3.2 3.2-5.8 7.2-5.8h.6c-.6-2.9-3.6-4.8-7.9-4.8zm-2.4 3.4a.9.9 0 1 1 0 1.8.9.9 0 0 1 0-1.8zm4.8 0a.9.9 0 1 1 0 1.8.9.9 0 0 1 0-1.8zM14.8 9.1c-3.4 0-6.1 2.2-6.1 4.9s2.7 4.9 6.1 4.9c.7 0 1.4-.1 2-.3l1.9 1-.5-1.7c1.4-.9 2.3-2.3 2.3-3.9 0-2.7-2.7-4.9-5.7-4.9zm-2 2.9a.8.8 0 1 1 0 1.6.8.8 0 0 1 0-1.6zm4 0a.8.8 0 1 1 0 1.6.8.8 0 0 1 0-1.6z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* 二维码面板 */
.rc-wecom-fab-panel {
  width: 264px;
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: var(--surface-2);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
  text-align: center;
}
.rc-wecom-fab-panel[hidden] {
  display: none;
}
.rc-wecom-fab-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.rc-wecom-fab-title {
  margin: 0;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  line-height: 1.5;
  text-align: left;
}
.rc-wecom-fab-close {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: var(--r-input);
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-lead);
  line-height: 1;
  cursor: pointer;
}
.rc-wecom-fab-close:hover {
  color: var(--text);
  background: var(--surface);
}
.rc-wecom-fab-qr {
  display: block;
  width: 196px;
  height: 196px;
  margin: 0 auto;
  padding: var(--sp-2);
  border-radius: var(--r-card);
  background: #fff;
}
.rc-wecom-fab-qr[hidden] {
  display: none;
}
.rc-wecom-fab-badge {
  margin: var(--sp-2) 0 0;
  color: var(--accent-strong);
  font-family: var(--font-sans);
  font-size: var(--fs-caption);
  line-height: 1.5;
  /* 徽标可能较长，允许两行但不出现孤字换行 */
  text-wrap: pretty;
}
.rc-wecom-fab-badge[hidden] {
  display: none;
}
.rc-wecom-fab-fallback {
  margin: var(--sp-2) 0 0;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: var(--fs-caption);
  line-height: 1.6;
}
.rc-wecom-fab-fallback[hidden] {
  display: none;
}
.rc-wecom-fab-fallback a {
  color: var(--accent-strong);
}
.rc-wecom-fab-hint {
  margin: var(--sp-3) 0 0;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: var(--fs-caption);
  line-height: 1.5;
}

/* 与 AI 聊天挂件（#lechen-chat-button）错开：聊天在右下，企微在其上方。
   聊天挂件只在 6 个页面存在，其余页面不受影响。 */
body:has(#lechen-chat-button) .rc-wecom-fab {
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 64px);
}

@media (max-width: 640px) {
  .rc-wecom-fab-btn {
    padding: 0 var(--sp-3);
  }
  .rc-wecom-fab-panel {
    width: min(248px, calc(100vw - 32px));
  }
  .rc-wecom-fab-qr {
    width: 168px;
    height: 168px;
  }
  /* 移动端面板靠右，避免遮住页面左侧的标题与正文 */
  .rc-wecom-fab {
    right: max(12px, env(safe-area-inset-right));
  }
  /* 移动端改成底部抽屉：贴底居中，避开正文标题区，
     并且给页面留出安全区高度，不遮住底部内容。 */
  .rc-wecom-fab-panel {
    position: fixed;
    left: 50%;
    right: auto;
    bottom: max(16px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: min(300px, calc(100vw - 24px));
  }
  .rc-wecom-fab-qr {
    width: 176px;
    height: 176px;
  }
  /* 面板打开时把按钮藏起来，避免按钮压在抽屉上方挡住二维码 */
  .rc-wecom-fab.is-open .rc-wecom-fab-btn {
    display: none;
  }
}
