/**
 * 移动端自适应样式优化
 * 隆相.中国Web - Mobile Responsive CSS
 */

/* ========== 基础移动端优化 ========== */

/* 防止移动端文本大小调整 */
html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* 移动端触摸优化 */
body {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

/* 优化移动端字体渲染 */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 优化移动端点击区域 */
a, button, input, select, textarea {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  touch-action: manipulation;
}

/* ========== 刘海屏/异形屏适配 ========== */

/* 支持安全区域 */
body {
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
}

/* iOS 刘海屏适配 */
@supports (padding: max(0px)) {
  .header {
    padding-top: max(0px, env(safe-area-inset-top));
  }
  
  .footer {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
}

/* ========== 响应式断点 ========== */

/* 超小屏幕（手机，小于 576px） */
@media (max-width: 575.98px) {
  body {
    font-size: 14px;
  }
  
  .container {
    padding-left: 15px;
    padding-right: 15px;
  }
  
  /* 优化图片显示 */
  img {
    max-width: 100%;
    height: auto;
  }
  
  /* 优化表格横向滚动 */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* 优化导航栏 */
  .nav {
    width: 100%;
  }
  
  /* 优化按钮大小（最小点击区域 44x44px） */
  button, .btn, a.button {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 20px;
  }
}

/* 小屏幕（平板，576px - 767.98px） */
@media (min-width: 576px) and (max-width: 767.98px) {
  body {
    font-size: 15px;
  }
  
  .container {
    max-width: 540px;
  }
}

/* 中等屏幕（平板横向，768px - 991.98px） */
@media (min-width: 768px) and (max-width: 991.98px) {
  body {
    font-size: 16px;
  }
  
  .container {
    max-width: 720px;
  }
}

/* 大屏幕（桌面，992px - 1199.98px） */
@media (min-width: 992px) and (max-width: 1199.98px) {
  .container {
    max-width: 960px;
  }
}

/* 超大屏幕（大桌面，1200px 及以上） */
@media (min-width: 1200px) {
  .container {
    max-width: 1140px;
  }
}

/* ========== 移动端特殊优化 ========== */

/* 仅移动端 */
@media (max-width: 767.98px) {
  /* 隐藏桌面端特有元素 */
  .desktop-only {
    display: none !important;
  }
  
  /* 优化标题大小 */
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
  h4 { font-size: 1.1rem; }
  h5 { font-size: 1rem; }
  h6 { font-size: 0.9rem; }
  
  /* 优化间距 */
  .box, .section {
    padding: 30px 0;
  }
  
  /* 优化卡片布局 */
  .card, .item {
    margin-bottom: 15px;
  }
  
  /* 优化表单输入 */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  input[type="search"],
  textarea,
  select {
    font-size: 16px; /* 防止 iOS 缩放 */
    padding: 12px;
    width: 100%;
    box-sizing: border-box;
  }
  
  /* 优化模态框 */
  .modal {
    width: 95% !important;
    margin: 10px auto;
  }
  
  /* 优化悬浮按钮位置 */
  .suspension {
    right: 10px;
    bottom: 10px;
  }
  
  /* 优化导航菜单 */
  .nav-list1 li {
    display: block;
    width: 100%;
  }
  
  /* 优化轮播图高度 */
  .banner,
  .slickbanner {
    height: auto;
    min-height: 200px;
  }
  
  /* 优化产品列表 */
  .product ul li {
    width: 100% !important;
    float: none;
  }
}

/* ========== 横屏/竖屏适配 ========== */

/* 横屏模式 */
@media (orientation: landscape) and (max-height: 500px) {
  .banner {
    height: 60vh;
  }
  
  .header .top {
    display: none; /* 横屏时隐藏顶部信息栏 */
  }
}

/* 竖屏模式 */
@media (orientation: portrait) {
  .banner {
    height: 40vh;
    min-height: 250px;
  }
}

/* ========== 触摸设备优化 ========== */

@media (hover: none) and (pointer: coarse) {
  /* 移除 hover 效果，使用 active 代替 */
  a:hover,
  button:hover {
    opacity: 1;
  }
  
  a:active,
  button:active {
    opacity: 0.8;
  }
  
  /* 优化触摸反馈 */
  .item:active,
  .card:active {
    transform: scale(0.98);
    transition: transform 0.1s;
  }
}

/* ========== PWA 模式优化 ========== */

/* PWA 独立模式样式 */
.pwa-mode {
  /* 可以添加 PWA 模式特有样式 */
}

@media (display-mode: standalone) {
  /* 隐藏浏览器提示 */
  .browser-notice {
    display: none !important;
  }
  
  /* 调整顶部间距（因为没有地址栏） */
  body {
    padding-top: 0;
  }
  
  /* 优化全屏体验 */
  .header {
    position: sticky;
    top: 0;
    z-index: 1000;
  }
}

/* ========== 高分辨率屏幕优化 ========== */

@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi) {
  /* 为高 DPI 屏幕优化图像 */
  img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* ========== 小屏幕特殊处理 ========== */

/* iPhone SE / 小型手机 (宽度小于 375px) */
@media (max-width: 374.98px) {
  body {
    font-size: 13px;
  }
  
  .container {
    padding-left: 10px;
    padding-right: 10px;
  }
  
  button, .btn {
    font-size: 14px;
    padding: 10px 15px;
  }
}

/* ========== 无障碍优化 ========== */

/* 支持暗色模式 */
@media (prefers-color-scheme: dark) {
  /* 可根据需要添加暗色主题 */
}

/* 支持减少动画 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========== 滚动优化 ========== */

/* 平滑滚动 */
html {
  scroll-behavior: smooth;
}

/* iOS 弹性滚动 */
body,
.modal,
.sidebar {
  -webkit-overflow-scrolling: touch;
}

/* 隐藏滚动条但保持功能（移动端） */
@media (max-width: 767.98px) {
  ::-webkit-scrollbar {
    width: 4px;
    height: 4px;
  }
  
  ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
  }
  
  ::-webkit-scrollbar-track {
    background: transparent;
  }
}

/* ========== 性能优化 ========== */

/* 优化动画性能 */
.animated {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-perspective: 1000px;
  perspective: 1000px;
}

/* GPU 加速 */
.gpu-accelerated {
  transform: translateZ(0);
  will-change: transform;
}

/* ========== 加载状态优化 ========== */

/* 骨架屏/加载占位符 */
.skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========== 打印优化 ========== */

@media print {
  /* 隐藏不需要打印的元素 */
  .no-print,
  .header .top,
  .nav,
  .suspension,
  .footer {
    display: none !important;
  }
  
  /* 优化打印布局 */
  body {
    font-size: 12pt;
    line-height: 1.5;
  }
  
  a[href]:after {
    content: " (" attr(href) ")";
  }
}

/* ========== 调试辅助（开发时使用） ========== */

/* 显示当前断点（开发时取消注释） */
/*
body::before {
  content: "XS (<576px)";
  position: fixed;
  top: 0;
  left: 0;
  background: red;
  color: white;
  padding: 5px 10px;
  z-index: 99999;
  font-size: 12px;
}

@media (min-width: 576px) {
  body::before { content: "SM (≥576px)"; background: orange; }
}

@media (min-width: 768px) {
  body::before { content: "MD (≥768px)"; background: green; }
}

@media (min-width: 992px) {
  body::before { content: "LG (≥992px)"; background: blue; }
}

@media (min-width: 1200px) {
  body::before { content: "XL (≥1200px)"; background: purple; }
}
*/

