/* 关注微信 — 纯 CSS 悬停二维码浮窗 */
.wechat-hover {
  position: relative;
  display: inline-block;
  vertical-align: middle;
}

.wechat-hover > a {
  cursor: default;
}

.wechat-qr-popup {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 200;
  width: 168px;
  padding: 12px 12px 10px;
  background: #fff;
  border: 1px solid rgba(107, 142, 35, 0.35);
  border-radius: 6px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.96);
  transition:
    opacity 0.28s ease,
    transform 0.28s ease,
    visibility 0.28s ease;
}

.wechat-qr-popup::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 18px;
  width: 10px;
  height: 10px;
  background: #fff;
  border-left: 1px solid rgba(107, 142, 35, 0.35);
  border-top: 1px solid rgba(107, 142, 35, 0.35);
  transform: rotate(45deg);
}

.wechat-qr-popup img {
  display: block;
  width: 132px;
  height: 132px;
  margin: 0 auto 8px;
  border-radius: 4px;
  object-fit: contain;
}

.wechat-qr-popup p {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: #556b2f;
}

.wechat-hover:hover .wechat-qr-popup,
.wechat-hover:focus-within .wechat-qr-popup {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* 手机端通用优化 */
@media (max-width: 767px) {
  html {
    overflow-x: hidden;
  }

  body {
    overflow-x: hidden;
    max-width: 100%;
  }

  .topbar-hide-sm {
    display: none !important;
  }

  .topbar-hide-sm + .text-gray-400 {
    display: none !important;
  }

  .topbar-right {
    gap: 0.35rem !important;
  }

  .float-cs-desktop {
    display: none !important;
  }

  .mobile-safe-bottom {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  /* 图片随屏幕缩放，避免撑破布局 */
  img {
    max-width: 100%;
  }

  figure img,
  .article-body img,
  article img,
  main section img {
    height: auto;
  }

  #hero-viewport img,
  [class*='aspect-'] img.h-full.object-cover {
    max-width: 100%;
    height: 100%;
  }

  [class*='aspect-'] img.object-contain {
    width: 100%;
    height: auto;
    max-height: 100%;
  }

  /* 头部标语文案换行，避免横向溢出 */
  header .font-slogan {
    white-space: normal;
    word-break: keep-all;
  }

  /* 主导航：四列网格，适合手指点击的小方塊 */
  nav[aria-label='主导航'] > div,
  nav.shrink-0.border-t-2 > div.flex.overflow-x-auto {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow-x: visible !important;
  }

  nav[aria-label='主导航'] > div > a,
  nav.shrink-0.border-t-2 > div.flex.overflow-x-auto > a {
    flex: none !important;
    min-width: 0 !important;
    white-space: normal !important;
    word-break: keep-all;
    padding: 0.6rem 0.25rem;
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.25;
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  }

  nav[aria-label='主导航'] > div > a:nth-child(4n),
  nav.shrink-0.border-t-2 > div.flex.overflow-x-auto > a:nth-child(4n) {
    border-right: none;
  }

  /* 首页首屏在手机端允许纵向滚动 */
  .min-h-screen.flex.flex-col > main.flex-1.min-h-0 {
    overflow: visible;
    min-height: auto;
  }
}

/* 桌面端：保持原有横向导航排版 */
@media (min-width: 768px) {
  nav[aria-label='主导航'] > div,
  nav.shrink-0.border-t-2 > div.flex.overflow-x-auto {
    display: flex !important;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  nav[aria-label='主导航'] > div > a,
  nav.shrink-0.border-t-2 > div.flex.overflow-x-auto > a {
    flex: 1 1 0%;
    min-width: 4.5rem;
    white-space: nowrap;
    border: none;
    min-height: 0;
    display: block;
  }

  nav.shrink-0.border-t-2 > div.flex.overflow-x-auto > a {
    min-width: 4rem;
  }
}

@media (min-width: 768px) {
  .float-cs-mobile-only {
    display: none !important;
  }
}

/* 表单页 */
.form-card {
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
}

.form-msg {
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  display: none;
}

.form-msg.is-show {
  display: block;
}

.form-msg.ok {
  background: #ecfdf5;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.form-msg.err {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
