/*
 * wecom.css — 微信公众号二维码（页脚二维码块 + 点击放大弹层）
 *
 * 4 个页面共用：
 *   - index.html              （首页，页脚第 2 列）
 *   - templates/layout.html   （内容页布局，页脚第 2 列）
 *   - 404.html                （404 页，页脚第 2 列）
 *   - decompile/index.html    （子页面，紧凑版）
 *
 * ⚠ 关于图片本身
 *   assets/brand/wechat-qr.png 是从原始 JPEG **重建**的 516×516 PNG
 *   （43 模块 × 12px，Version 6 尺寸的整数倍设计）。
 *   516 能被 129（页脚）与 258（弹层）整除，配合 image-rendering: pixelated
 *   做最近邻缩放，码点保持锐利、不出现插值灰边 —— 这是二维码能被手机识别的关键。
 *   ⚠ 不要再把这个图走 optimize.mjs（会 resize + 转有损 avif/webp，码点会被毁掉）。
 *
 * ⚠ 关于 CSS 变量
 *   index.html / decompile/index.html 用的是各自内联的 :root，
 *   **没有** --radius-* 与 --shadow-* （只有 tokens.css 才有）。
 *   所以本文件里凡是用到这两个族的变量，都必须带 fallback。
 */

/* =============================================================
 * 1. 页脚二维码块
 * ============================================================= */

.wechat-qr {
  /* 显示尺寸 = 原图 516 的整数分之一 */
  --wechat-qr-size: 129px;

  display: block;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md, 10px);
  background: #fff;
  line-height: 0;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.wechat-qr:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(20, 23, 30, 0.06));
}

.wechat-qr:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.wechat-qr__img {
  display: block;
  width: var(--wechat-qr-size);
  height: var(--wechat-qr-size);
  image-rendering: pixelated;
}

/* 二维码下方的说明文字（扫码关注 + 账号名） */
.wechat-qr__caption {
  margin: 10px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-4);
}

.wechat-qr__name {
  color: var(--ink);
  font-weight: 600;
}

/* =============================================================
 * 2. 紧凑版（decompile 子页面：页脚是单行居中布局）
 * ============================================================= */

/* ⚠ 这里必须用 **块级** flex（display: flex），不能用 inline-flex。
 *   decompile 页脚的版权行后面紧跟着 .icp（也是 inline-flex）。
 *   两个 inline-flex 兄弟节点之间只有空白，会被排到**同一行**上 ——
 *   实测结果：二维码块中心在 574px、.icp 中心在 805px，
 *   而容器中心是 720px，两者都偏了。
 *   改成块级 flex 后它独占一行，用 justify-content 居中。 */
.wechat-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
  text-align: left;
}

.wechat-qr--sm {
  --wechat-qr-size: 72px;
  padding: 4px;
  border-radius: 8px;
}

.wechat-inline__text {
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-4);
}

/* =============================================================
 * 3. 放大弹层
 * ============================================================= */

.wecom-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(20, 23, 30, 0.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.wecom-lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

.wecom-lightbox__card {
  position: relative;
  padding: 22px 22px 20px;
  max-width: 100%;
  background: #fff;
  border-radius: var(--radius-lg, 14px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  text-align: center;
  transform: scale(0.94);
  transition: transform 0.18s ease;
}

.wecom-lightbox.is-open .wecom-lightbox__card {
  transform: scale(1);
}

.wecom-lightbox__img {
  display: block;
  width: 258px;
  height: auto;
  max-width: 72vw;
  image-rendering: pixelated;
}

.wecom-lightbox__title {
  margin: 14px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.wecom-lightbox__hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-4);
}

.wecom-lightbox__close {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-3);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.wecom-lightbox__close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink);
}

.wecom-lightbox__close:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* 弹层打开时锁住背景滚动 */
body.wecom-lock {
  overflow: hidden;
}

/* =============================================================
 * 4. 响应式
 * ============================================================= */

/* 平板及以下：二维码列独占一行并居中 */
@media (max-width: 900px) {
  .foot-col--wechat {
    grid-column: 1 / -1;
    text-align: center;
    /* 桌面端二维码排在「产品」左侧；窄屏改回排在最后独占一行 ——
       否则 2 列网格里会空出一格（品牌那行右侧没内容）。 */
    order: 1;
  }

  .wechat-qr {
    margin: 0 auto;
  }

  .wechat-inline {
    margin-top: 12px;
  }
}

@media (max-width: 560px) {
  .wecom-lightbox {
    padding: 16px;
  }

  .wecom-lightbox__card {
    padding: 18px 18px 16px;
  }
}

/* =============================================================
 * 5. 无障碍：尊重「减少动态效果」偏好
 * ============================================================= */

@media (prefers-reduced-motion: reduce) {
  .wechat-qr,
  .wecom-lightbox,
  .wecom-lightbox__card,
  .wecom-lightbox__close {
    transition: none;
  }

  .wechat-qr:hover {
    transform: none;
  }
}
