/* 公共移动端布局与触控优化 */

/* 旧版底部导航已停用：移动端统一使用侧边栏抽屉 */
.mobile-nav { display: none !important; }

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .sidebar { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
}

.mobile-menu-btn {
  display: none;
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg-surface) 94%, transparent);
  color: var(--text-primary);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  backdrop-filter: blur(12px);
  cursor: pointer;
  z-index: 1001;
  -webkit-tap-highlight-color: transparent;
  transition: transform 160ms cubic-bezier(0.16, 1, 0.3, 1), background 160ms ease, border-color 160ms ease;
}

.mobile-menu-btn:hover { background: var(--bg-muted); }
.mobile-menu-btn:active { transform: scale(0.96); }
.mobile-menu-btn i { color: currentColor; font-size: 21px; line-height: 1; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(16, 18, 20, 0.48);
  opacity: 0;
  backdrop-filter: blur(2px);
  transition: opacity 220ms ease;
}

.sidebar-overlay.visible,
body.sidebar-open .sidebar-overlay { opacity: 1; }

@media (hover: none) and (pointer: coarse) {
  .sidebar-nav-item,
  .post-title-link,
  .note-item,
  .resource-item,
  .project-item { min-height: 44px; }

  button,
  .btn,
  a.btn { min-height: 44px; }

  input,
  textarea,
  select { font-size: 16px; }
}

@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: min(-88vw, -320px);
    width: min(88vw, 320px);
    height: 100dvh;
    z-index: 1000;
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: none;
    transition: left 240ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 240ms ease;
  }

  .sidebar.open,
  body.sidebar-open .sidebar {
    left: 0 !important;
    box-shadow: 12px 0 36px rgba(0,0,0,0.18);
  }

  .content {
    margin-left: 0;
    width: 100%;
    max-width: none;
    padding: 68px 18px max(28px, env(safe-area-inset-bottom));
  }

  .content-inner {
    width: 100%;
    max-width: 720px;
    margin-inline: auto;
    padding: 0;
  }

  .page-header {
    margin-top: 0;
    margin-bottom: 24px;
    padding-right: 52px;
  }

  .page-header h1 {
    font-size: clamp(1.55rem, 7vw, 1.9rem);
    line-height: 1.2;
  }

  .page-header p {
    max-width: 36rem;
    margin-top: 7px;
    font-size: 0.9rem;
    line-height: 1.65;
  }

  .post-list { gap: 10px; }
  .post-item { padding: 13px 0; }

  .resources-grid,
  .projects-grid,
  .notes-grid { grid-template-columns: minmax(0, 1fr); }

  .article-body {
    font-size: 16px;
    line-height: 1.82;
  }

  .article-body h1 { font-size: 1.65rem; }
  .article-body h2 { font-size: 1.35rem; }
  .article-body h3 { font-size: 1.16rem; }

  .article-body pre {
    max-width: 100%;
    padding: 14px;
    border-radius: 8px;
    font-size: 13px;
    overflow-x: auto;
  }

  .comment-form,
  .comment-item { padding: 14px; }

  .table-responsive,
  .admin-nav {
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }

  .search-box { width: 100%; }
  .tool-card { min-height: auto; }
  .tool-body { padding: 14px; }
  .admin-header { padding: 12px; }
  .admin-nav { flex-wrap: nowrap; }
  .admin-nav-item { flex-shrink: 0; white-space: nowrap; }
  .card { padding: 14px; }
  .form-group { margin-bottom: 14px; }

  input,
  textarea,
  select {
    width: 100%;
    padding: 11px 12px;
    font-size: 16px;
  }
}

@media (max-width: 390px) {
  .content { padding-inline: 14px; }
  .page-header { margin-bottom: 20px; }
  .post-title { font-size: 1rem; }
  .note-item { padding: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-menu-btn,
  .sidebar,
  .sidebar-overlay { transition: none; }
}
