/* ================================================================
   禾客穆 HAKIM·HALAL — 响应式增强 & 交互体验优化
   responsive-enhance.css  v2.0
   ================================================================ */

/* ================================================================
   1. 汉堡菜单 / 移动端导航
   ================================================================ */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  cursor: pointer;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 6px;
  transition: background .2s;
  gap: 5px;
  flex-shrink: 0;
}
.hamburger-btn:hover { background: var(--green-50); }
.hamburger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--green-700);
  border-radius: 2px;
  transition: transform .3s cubic-bezier(.16,1,.3,1), opacity .3s, width .3s;
  transform-origin: center;
}
/* 激活状态：X 形 */
.hamburger-btn.is-active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.is-active span:nth-child(2) { opacity: 0; width: 14px; }
.hamburger-btn.is-active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* 手机端抽屉导航 */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,30,20,0.55);
  z-index: 998;
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity .3s;
}
.mobile-nav-overlay.is-open { opacity: 1; }

.mobile-nav-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(300px, 80vw);
  background: #fff;
  z-index: 999;
  padding: 0;
  transform: translateX(100%);
  transition: transform .35s cubic-bezier(.16,1,.3,1);
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 32px rgba(10,54,30,0.18);
}
.mobile-nav-drawer.is-open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--neutral-100);
  background: linear-gradient(135deg, #0a3622, #1a6b3c);
}
.drawer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.drawer-brand img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
}
.drawer-brand-text strong {
  display: block;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
}
.drawer-brand-text span {
  font-size: 10px;
  color: rgba(255,255,255,0.6);
  letter-spacing: 1px;
}
.drawer-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
  flex-shrink: 0;
}
.drawer-close:hover { background: rgba(255,255,255,0.22); }

.drawer-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}
.drawer-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  font-size: 15px;
  color: var(--neutral-700);
  text-decoration: none;
  transition: all .2s;
  border-left: 3px solid transparent;
  font-weight: 500;
}
.drawer-nav a:hover, .drawer-nav a.active {
  background: var(--green-50);
  color: var(--green-700);
  border-left-color: var(--green-500);
}
.drawer-nav a .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--green-500);
}
.drawer-nav .nav-divider {
  height: 1px;
  background: var(--neutral-100);
  margin: 8px 16px;
}

.drawer-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--neutral-100);
  display: flex;
  gap: 10px;
}
.drawer-footer a {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all .2s;
}
.drawer-footer .btn-drawer-cart {
  background: var(--green-50);
  color: var(--green-600);
  border: 1px solid var(--green-200);
}
.drawer-footer .btn-drawer-login {
  background: linear-gradient(135deg, var(--green-600), var(--green-500));
  color: #fff;
}
.drawer-footer .btn-drawer-cart:hover { background: var(--green-100); }
.drawer-footer .btn-drawer-login:hover { background: linear-gradient(135deg, var(--green-500), var(--green-400)); }

/* ================================================================
   2. 导航栏滚动吸附 & 磨砂效果
   ================================================================ */
.main-header {
  transition: box-shadow .3s, background .3s;
}
.main-header.is-scrolled {
  box-shadow: 0 2px 24px rgba(10,54,30,0.1);
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.96) !important;
}

/* ================================================================
   3. 滚动进度条
   ================================================================ */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--green-500), var(--gold-400));
  z-index: 1001;
  width: 0%;
  transition: width .1s linear;
  border-radius: 0 2px 2px 0;
}

/* ================================================================
   4. Hero 入场动画
   ================================================================ */
@keyframes heroFadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes heroFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes pillFloat {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-4px); }
}
@keyframes shimmerPulse {
  0%, 100% { opacity: 0.8; }
  50%       { opacity: 1; }
}

.hero-home .hero-content h2 {
  animation: heroFadeUp .8s cubic-bezier(.16,1,.3,1) .1s both;
}
.hero-home .hero-sub {
  animation: heroFadeUp .8s cubic-bezier(.16,1,.3,1) .22s both;
}
.hero-home .hero-pills {
  animation: heroFadeUp .8s cubic-bezier(.16,1,.3,1) .34s both;
}
.hero-home .hero-actions {
  animation: heroFadeUp .8s cubic-bezier(.16,1,.3,1) .46s both;
}
.hero-home .hero-stats {
  animation: heroFadeIn .9s cubic-bezier(.16,1,.3,1) .6s both;
}
.hero-pill {
  animation: pillFloat 4s ease-in-out infinite;
}
.hero-pill:nth-child(2) { animation-delay: .8s; }
.hero-pill:nth-child(3) { animation-delay: 1.6s; }
.hero-pill:nth-child(4) { animation-delay: 2.4s; }
.hero-pill:nth-child(5) { animation-delay: 3.2s; }

/* ================================================================
   5. 数字计数器动效（stat 数字区域）
   ================================================================ */
.hero-stat .num {
  transition: transform .3s;
}
.hero-stat:hover .num { transform: scale(1.08); }

/* 数字滚动效果 - 通过 JS 控制 */
.stat-counter {
  display: inline-block;
}

/* ================================================================
   6. 区块滚动淡入
   ================================================================ */
.reveal-section {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .7s cubic-bezier(.16,1,.3,1), transform .7s cubic-bezier(.16,1,.3,1);
}
.reveal-section.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.reveal-section.delay-1 { transition-delay: .1s; }
.reveal-section.delay-2 { transition-delay: .2s; }
.reveal-section.delay-3 { transition-delay: .3s; }

/* ================================================================
   7. 产品卡片悬浮增强
   ================================================================ */
.product-card {
  position: relative;
  overflow: hidden;
}
/* 光泽扫描效果 */
.product-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    105deg,
    transparent 30%,
    rgba(255,255,255,0.18) 50%,
    transparent 70%
  );
  transition: left .5s cubic-bezier(.16,1,.3,1);
  pointer-events: none;
  z-index: 1;
}
.product-card:hover::after { left: 150%; }

/* 图片缩放优化 */
.product-img {
  overflow: hidden;
}
.product-img img {
  transition: transform .5s cubic-bezier(.16,1,.3,1);
}
.product-card:hover .product-img img {
  transform: scale(1.08);
}

/* ================================================================
   8. 分类卡片图标跳跃
   ================================================================ */
@keyframes iconBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-6px) scale(1.08); }
  70% { transform: translateY(-3px) scale(1.04); }
}
.cat-card:hover .cat-icon {
  animation: iconBounce .5s cubic-bezier(.34,1.56,.64,1) forwards;
}

/* ================================================================
   9. Toast 通知升级
   ================================================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 32px rgba(10,54,30,0.14), 0 2px 8px rgba(0,0,0,0.06);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  pointer-events: auto;
  min-width: 260px;
  max-width: 340px;
  border-left: 4px solid var(--green-500);
  transform: translateX(120%);
  opacity: 0;
  transition: transform .4s cubic-bezier(.16,1,.3,1), opacity .4s;
}
.toast-item.is-show {
  transform: translateX(0);
  opacity: 1;
}
.toast-item.is-hide {
  transform: translateX(120%);
  opacity: 0;
}
.toast-item.toast-success { border-left-color: var(--green-500); }
.toast-item.toast-error   { border-left-color: var(--error); }
.toast-item.toast-warning { border-left-color: var(--warning); }
.toast-item.toast-info    { border-left-color: var(--info); }
.toast-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
}
.toast-success .toast-icon { background: var(--success-light); color: var(--green-600); }
.toast-error   .toast-icon { background: var(--error-light);   color: #c0392b; }
.toast-warning .toast-icon { background: var(--warning-light); color: #b86c00; }
.toast-info    .toast-icon { background: var(--info-light);    color: #2980b9; }
.toast-msg { flex: 1; line-height: 1.4; }
.toast-close {
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--neutral-400);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all .15s;
  flex-shrink: 0;
}
.toast-close:hover { background: var(--neutral-100); color: var(--neutral-700); }

/* ================================================================
   10. 返回顶部按钮美化
   ================================================================ */
.back-to-top {
  position: fixed;
  bottom: 80px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--green-600), var(--green-500));
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(10,54,30,0.28);
  display: none;
  align-items: center;
  justify-content: center;
  transition: all .3s cubic-bezier(.16,1,.3,1);
  z-index: 100;
  color: #fff;
}
.back-to-top.show {
  display: flex;
  animation: heroFadeUp .4s cubic-bezier(.16,1,.3,1);
}
.back-to-top:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 28px rgba(10,54,30,0.38);
}
.back-to-top svg { transition: transform .3s; }
.back-to-top:hover svg { transform: translateY(-2px); }

/* ================================================================
   11. 响应式断点完善 (移动优先)
   ================================================================ */

/* 大屏 1200px+ */
@media (min-width: 1200px) {
  .products-grid { grid-template-columns: repeat(4, 1fr); }
  .adv-grid      { grid-template-columns: repeat(3, 1fr); }
}

/* 平板 768px ~ 1024px */
@media (max-width: 1024px) {
  .adv-grid      { grid-template-columns: repeat(2, 1fr); }
  .market-grid   { grid-template-columns: repeat(2, 1fr); }
  .join-grid     { grid-template-columns: repeat(2, 1fr); }
}

/* 手机 ≤ 768px */
@media (max-width: 768px) {
  /* 显示汉堡按钮，隐藏桌面导航 */
  .hamburger-btn { display: flex; }
  .main-nav { display: none !important; }
  .nav-actions .btn-login { display: none; }

  /* 头部高度优化 */
  .main-header .header-inner {
    padding: 12px 16px;
    flex-wrap: nowrap;
    gap: 8px;
  }
  .logo-text h1 { font-size: 16px; }
  .logo-text span { font-size: 10px; }
  .logo-img { width: 36px; height: 36px; }

  /* Hero 优化 */
  .hero-home { padding: 56px 0 44px; }
  .hero-content { padding: 0 16px; }
  .hero-content h2 { font-size: clamp(22px, 6vw, 32px); letter-spacing: 1px; }
  .hero-sub { font-size: 12px; letter-spacing: 1px; }
  .hero-pills { gap: 8px; }
  .hero-pill { padding: 6px 14px; font-size: 11px; }
  .hero-actions { flex-direction: column; align-items: stretch; gap: 10px; padding: 0 20px; }
  .btn-hero { text-align: center; padding: 13px 24px; }
  .hero-stats { gap: 10px; padding: 0 16px; }
  .hero-stat { padding: 12px 16px; min-width: 80px; flex: 1; }
  .hero-stat .num { font-size: 24px; }
  .hero-stat .label { font-size: 11px; }

  /* 栅格响应 */
  .cat-grid      { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .products-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .adv-grid      { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .vendor-grid   { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .market-grid   { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .join-grid     { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  /* Section 间距缩小 */
  .section { padding: 44px 0; }
  .section-title h2 { font-size: 22px; }

  /* Toast 位置 */
  .toast-container { top: auto; bottom: 80px; left: 16px; right: 16px; }
  .toast-item { min-width: unset; max-width: unset; width: 100%; }

  /* 返回顶部 */
  .back-to-top { bottom: 20px; right: 16px; }
}

/* 小屏 ≤ 480px */
@media (max-width: 480px) {
  .cat-grid      { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .products-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .adv-grid      { grid-template-columns: 1fr; }
  .vendor-grid   { grid-template-columns: 1fr; }
  .market-grid   { grid-template-columns: 1fr; }
  .join-grid     { grid-template-columns: 1fr; }
  .product-img   { height: 150px; }

  .hero-stats { grid-template-columns: repeat(2, 1fr); display: grid; gap: 8px; }
  .hero-stat  { min-width: unset; }

  .section-inner { padding: 0 12px; }
  .hero-actions  { padding: 0 12px; }
}

/* ================================================================
   12. 产品中心页面响应式增强
   ================================================================ */

/* 筛选抽屉（仅移动端生效，桌面端不受影响） */
@media (max-width: 768px) {
.filter-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,30,20,0.5);
  z-index: 800;
  opacity: 0;
  transition: opacity .3s;
  backdrop-filter: blur(2px);
}
.filter-drawer-overlay.is-open { opacity: 1; display: block; }

.filter-sidebar.is-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background: #fff;
  z-index: 801;
  overflow-y: auto;
  padding: 0 0 20px;
  transform: translateX(-100%);
  transition: transform .35s cubic-bezier(.16,1,.3,1);
  box-shadow: 4px 0 32px rgba(10,54,30,0.18);
}
.filter-sidebar.is-drawer.is-open { transform: translateX(0); }
} /* end @media 768 filter drawer */

.filter-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #0a3622, #1a6b3c);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}
.filter-drawer-header button {
  width: 30px;
  height: 30px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.filter-drawer-header button:hover { background: rgba(255,255,255,0.25); }

.btn-filter-mobile {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--green-300);
  background: var(--green-50);
  color: var(--green-700);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.btn-filter-mobile:hover { background: var(--green-100); }
.btn-filter-mobile .filter-count {
  background: var(--green-600);
  color: #fff;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  min-width: 18px;
  text-align: center;
  display: none;
}
.btn-filter-mobile .filter-count.has-count { display: inline-block; }

/* 搜索框增强 */
.search-bar-lg {
  position: relative;
}
.search-bar-lg input {
  transition: border-color .2s, box-shadow .2s, padding-left .2s;
}
.search-bar-lg input:focus {
  border-color: var(--green-400);
  box-shadow: 0 0 0 3px rgba(10,92,54,0.1);
}
.search-clear {
  position: absolute;
  right: 108px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: none;
  background: var(--neutral-300);
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}
.search-clear.is-visible { display: flex; }
.search-clear:hover { background: var(--neutral-500); }

/* 活跃筛选标签 */
.active-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 0;
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s, padding .3s;
}
.active-filters.has-filters {
  max-height: 200px;
  padding: 8px 0 4px;
}
.active-filter-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 12px;
  background: var(--green-50);
  border: 1px solid var(--green-200);
  border-radius: 20px;
  font-size: 12px;
  color: var(--green-700);
  font-weight: 500;
  animation: heroFadeUp .3s cubic-bezier(.16,1,.3,1);
}
.active-filter-tag button {
  width: 16px;
  height: 16px;
  border: none;
  background: var(--green-200);
  color: var(--green-700);
  border-radius: 50%;
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  padding: 0;
  line-height: 1;
}
.active-filter-tag button:hover { background: var(--green-300); }
.active-filters-clear {
  font-size: 12px;
  color: var(--neutral-400);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  background: none;
  border: none;
  transition: color .2s, background .2s;
}
.active-filters-clear:hover { color: var(--error); background: var(--error-light); }

@media (max-width: 768px) {
  .products-layout { flex-direction: column; gap: 0; padding: 0; }
  .filter-sidebar  { display: none; } /* 桌面 sidebar 隐藏 */
  .btn-filter-mobile { display: flex; }
  .products-main { padding: 0 12px; }
  .products-toolbar { flex-wrap: wrap; gap: 8px; }
  .search-bar-lg input { font-size: 16px; } /* 防止 iOS 自动缩放 */
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
@media (max-width: 480px) {
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .search-bar-lg { flex-direction: column; }
  .search-bar-lg button { width: 100%; justify-content: center; }
  .search-clear { display: none !important; }
}

/* ================================================================
   13. 无障碍 & reduced-motion
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
  .hero-home .hero-content h2,
  .hero-home .hero-sub,
  .hero-home .hero-pills,
  .hero-home .hero-actions,
  .hero-home .hero-stats,
  .hero-pill,
  .reveal-section,
  .product-card::after {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
