/* ================================================
   唯璐科技全站跨浏览器兼容性补丁
   Safari / Chrome / Firefox / Edge / Mobile
   ================================================ */

/* ── 1. CSS Reset / Normalization ── */
*, *::before, *::after {
  -webkit-box-sizing: border-box;
     -moz-box-sizing: border-box;
          box-sizing: border-box;
}

/* ── 2. Safari 100vh 修复（地址栏导致溢出）── */
:root {
  --vh: 1vh; /* JS will update this */
}
.hero, .auth-page, .error-page, .kitchen-hero, .news-hero {
  /* Fallback for browsers that don't support custom properties */
  min-height: 100vh;
  min-height: calc(var(--vh, 1vh) * 100);
}

/* ── 3. iOS Safe Area (iPhone X+ 底部安全区) ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .footer,
  footer,
  .auth-card,
  .footer-bottom {
    padding-bottom: calc(env(safe-area-inset-bottom) + 8px);
  }
  .header,
  .announcement {
    padding-top: env(safe-area-inset-top);
  }
}

/* ── 4. Flexbox 兼容 ── */
.flex {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
}
.flex-wrap {
  -webkit-flex-wrap: wrap;
      -ms-flex-wrap: wrap;
          flex-wrap: wrap;
}

/* ── 5. CSS Grid 兼容（Edge 16+） ── */
/* Grid is well supported now, but add -ms- for older Edge */
.biz-grid,
.entries-grid,
.story-grid,
.product-grid,
.recipe-grid,
.seasonal-grid,
.trace-grid,
.trade-grid,
.news-layout {
  display: -ms-grid;
  display: grid;
}

/* ── 6. 触摸优化 ── */
/* 移除 iOS 点击高亮 */
a, button, input, select, textarea,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

/* 禁止长按弹出菜单（对非文字内容） */
img, .logo-icon, .entry-icon, .qual-icon {
  -webkit-touch-callout: none;
}

/* 滚动优化：减少移动端滚动卡顿 */
.hero-slider,
.nav-inner,
.product-grid,
.ranking-list,
.news-list {
  -webkit-overflow-scrolling: touch;
}

/* ── 7. 字体渲染 ── */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ── 8. 输入框兼容 ── */
input[type="text"],
input[type="tel"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="number"],
textarea,
select {
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  /* iOS 圆角修复 */
  border-radius: 0;
}

/* 保留 select 的下拉箭头（Chrome/Safari） */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 32px;
}

/* ── 9. 按钮兼容 ── */
.btn, .btn-submit, .btn-green, .btn-gold, .btn-outline, .btn-white,
button {
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  cursor: pointer;
  /* 禁止iOS缩放 */
  touch-action: manipulation;
}

/* ── 10. 图片兼容 ── */
img {
  -ms-interpolation-mode: bicubic;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* ── 11. 横屏适配 ── */
@media screen and (orientation: landscape) and (max-height: 500px) {
  .hero {
    min-height: 400px;
    min-height: calc(var(--vh, 1vh) * 100);
    padding-top: 60px;
    padding-bottom: 40px;
  }
  .hero h1, .hero h2, .kitchen-hero h1, .news-hero h1 {
    font-size: 24px !important;
  }
  .hero-content p, .kitchen-hero p, .news-hero p {
    font-size: 13px !important;
  }
}

/* ── 12. 打印优化 ── */
@media print {
  .header, .nav, .announcement, .hero-dots, .back-top,
  footer, .footer, .btn, button {
    display: none !important;
  }
  body {
    font-size: 12pt;
    color: #000;
    background: #fff;
  }
  a {
    color: #000;
    text-decoration: underline;
  }
}

/* ── 13. 强制颜色模式（高对比/暗模式适配） ── */
@media (forced-colors: active) {
  .btn, .btn-submit, a {
    border: 1px solid LinkText;
  }
}

/* ── 14. 减少动画（用户偏好） ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .hero-slide {
    transition: none !important;
  }
}

/* ── 15. Firefox 特有修复 ── */
@-moz-document url-prefix() {
  /* Firefox 不支持 gap in flex, 使用 margin 替代 */
  .flex.gap-16 > * + * { margin-left: 16px; }
  .flex.gap-12 > * + * { margin-left: 12px; }
}

/* ── 16. Edge/IE 修复 ── */
_:-ms-lang(x), _:-webkit-full-screen,
.container {
  max-width: 1100px;
}

/* ── 17. 桌面端缩放适配（150%/200% DPI）── */
@media screen and (-webkit-min-device-pixel-ratio: 1.5),
       screen and (min-resolution: 144dpi) {
  .hero h1 {
    font-size: clamp(24px, 4vw, 42px);
  }
}

/* ── 18. 超窄屏适配（< 375px，如 iPhone SE / 小屏安卓）── */
@media screen and (max-width: 374px) {
  .hero h1, .kitchen-hero h1, .news-hero h1 {
    font-size: 22px !important;
  }
  .container {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  .auth-card {
    padding: 24px 16px !important;
  }
  .biz-grid {
    grid-template-columns: 1fr !important;
  }
  .biz-grid > * {
    grid-column: auto !important;
    max-width: 100% !important;
    justify-self: stretch !important;
  }
}

/* ── 19. 大屏适配（> 1400px）── */
@media screen and (min-width: 1400px) {
  .container {
    max-width: 1200px;
  }
}
