/**
 * DevCraft Studio - 移动端全局优化
 * 针对移动设备的额外优化和修复
 */

/* ==================== Header移动端修复 ==================== */
@media (max-width: 480px) {
  /* 修复logo显示问题 */
  .header .logo a {
    display: flex;
    align-items: center;
    font-size: 0; /* 隐藏文字 */
    white-space: nowrap;
  }

  .header .logo a::after {
    content: '';
    display: none;
  }

  .header .logo img,
  .header .logo svg {
    /* height: 32px !important;
    width: auto; */
  }

  /* 优化header高度 */
  .header .nav {
    min-height: 52px;
  }

  /* 优化按钮间距 */
  .header .logo-switches {
    gap: 4px;
    width: 50px;
    height: 50px;
  }

  .header #theme-toggle {
    padding: 6px;
  }
}

/* ==================== 全局移动端设置 ==================== */
@media (max-width: 768px) {
  /* 防止横向滚动 */
  body {
    overflow-x: hidden;
  }

  /* 改善触摸体验 */
  a,
  button,
  .btn,
  input,
  textarea {
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.2);
  }

  /* 优化字体大小 */
  html {
    font-size: 16px; /* 确保基础字体大小适合移动端 */
  }

  /* 改善间距 */
  .main,
  main {
    padding-top: calc(var(--header-height) + 0px);
  }
}

/* ==================== 小屏幕优化 (≤480px) ==================== */
@media (max-width: 480px) {
  /* 减小全局字体 */
  html {
    font-size: 15px;
  }

  /* 优化容器内边距 */
  .container,
  .post-content,
  article {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* 优化标题大小 */
  h1 {
    font-size: 1.75rem;
    line-height: 1.2;
  }

  h2 {
    font-size: 1.5rem;
    line-height: 1.3;
  }

  h3 {
    font-size: 1.25rem;
    line-height: 1.4;
  }

  /* 优化图片 */
  img {
    max-width: 100%;
    height: auto;
  }

  /* 优化表格 */
  table {
    font-size: 0.875rem;
  }

  /* 优化代码块 */
  pre,
  code {
    font-size: 0.8125rem;
  }
}

/* ==================== 触摸优化 ==================== */
@media (hover: none) and (pointer: coarse) {
  /* 增加可点击区域 */
  .btn,
  a.btn,
  button {
    min-height: 44px; /* iOS推荐的最小触摸目标 */
    min-width: 44px;
  }

  /* 移除hover效果,改为active */
  .btn:hover,
  .glass-card:hover,
  .article-card:hover {
    transform: none;
  }

  .btn:active,
  .glass-card:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }
}

/* ==================== 横屏模式优化 ==================== */
@media (max-width: 896px) and (orientation: landscape) {
  .hero-banner {
    min-height: 400px;
    padding: calc(var(--gap) * 1.5) 20px;
  }

  .header {
    height: 56px;
  }

  .mobile-drawer {
    max-height: 80vh;
    overflow-y: auto;
  }
}

/* ==================== 小高度设备优化 ==================== */
@media (max-height: 600px) {
  .hero-banner {
    min-height: auto;
    padding: calc(var(--gap) * 1.5) 20px;
  }

  .cta-section {
    padding: calc(var(--gap) * 2) 0;
  }
}

/* ==================== 文本选择优化 ==================== */
@media (max-width: 768px) {
  /* 改善文本选择体验 */
  ::selection {
    background-color: rgba(59, 130, 246, 0.3);
    color: var(--primary);
  }

  /* 优化表单元素 */
  input,
  textarea,
  select {
    font-size: 16px; /* 防止iOS自动放大 */
  }
}

/* ==================== 性能优化 ==================== */
@media (max-width: 768px) {
  /* 减少动画和过渡以提升性能 */
  .floating-shape {
    animation: none;
  }

  /* 简化玻璃态效果 */
  .glass-card {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}

/* ==================== 安全区域适配 (刘海屏) ==================== */
@supports (padding: max(0px)) {
  @media (max-width: 768px) {
    body {
      padding-left: max(0px, env(safe-area-inset-left));
      padding-right: max(0px, env(safe-area-inset-right));
    }

    .header {
      padding-left: max(16px, env(safe-area-inset-left));
      padding-right: max(16px, env(safe-area-inset-right));
    }

    .footer {
      padding-bottom: max(var(--gap), env(safe-area-inset-bottom));
    }
  }
}

/* ==================== 可访问性增强 ==================== */
@media (max-width: 768px) {
  /* 确保焦点可见 */
  *:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  /* 改善链接可见性 */
  a {
    text-decoration-thickness: 2px;
  }
}
