/* ============================================================
   响应式布局 — PC / 平板 / 手机
   断点：1200+ 大屏 | 1024 桌面 | 768 平板 | 480 手机
   ============================================================ */

/* ---------- 通用 ---------- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.prose-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.2em 0;
}

.novel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.novel-actions .btn-primary,
.novel-actions .btn-secondary {
  margin-right: 0;
}

/* 仅悬停设备显示 hover 动效 */
@media (hover: hover) and (pointer: fine) {
  .card-link:hover {
    transform: translateY(-4px);
  }
}

@media (hover: none) {
  .card-link:active {
    transform: scale(0.98);
    transition: transform 100ms ease;
  }

  .icon-btn,
  .text-btn,
  .btn-primary,
  .btn-secondary,
  .nav-btn,
  .mobile-nav-btn {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ---------- 大屏 PC (≥1200px) ---------- */
@media (min-width: 1200px) {
  .site-main {
    max-width: 1280px;
  }

  .shelf {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-xl);
  }

  .novel-header {
    grid-template-columns: 260px 1fr;
    gap: var(--space-2xl);
  }
}

/* 阅读页 ≤1024px 改用侧滑目录，避免左侧栏挤压正文（见 reader-mobile.css） */

/* ---------- 平板竖屏 (≤768px) ---------- */
@media (max-width: 768px) {
  :root {
    --header-height: 52px;
  }

  .site-header {
    padding: 0 var(--space-md);
    gap: var(--space-sm);
  }

  .brand span {
    font-size: 1rem;
  }

  .site-main {
    padding: var(--space-lg) var(--space-md) var(--space-xl);
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .hero-sub {
    font-size: 0.9rem;
  }

  /* 书库：双列卡片 */
  .shelf {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
  }

  .shelf-card {
    margin-bottom: var(--space-md);
  }

  .card-body {
    padding: var(--space-sm) var(--space-md) var(--space-md);
  }

  .card-title {
    font-size: 0.95rem;
  }

  /* 小说详情：封面 + 信息横排 */
  .novel-header {
    grid-template-columns: 120px 1fr;
    gap: var(--space-md);
    align-items: start;
    margin-bottom: var(--space-xl);
  }

  .novel-cover {
    max-width: none;
  }

  .cover-placeholder.large {
    min-height: 160px;
    aspect-ratio: 3 / 4;
  }

  .novel-meta h1 {
    font-size: 1.35rem;
  }

  .novel-author {
    font-size: 0.95rem;
    margin-bottom: var(--space-sm);
  }

  .novel-desc {
    font-size: 0.9rem;
    margin: var(--space-sm) 0;
  }

  .novel-actions {
    flex-direction: column;
  }

  .novel-actions .btn-primary,
  .novel-actions .btn-secondary {
    width: 100%;
    justify-content: center;
    padding: 14px 20px;
  }

  .chapter-list a {
    padding: 16px var(--space-md);
  }

  .ch-title {
    font-size: 0.95rem;
  }

  /* 设置面板：底部抽屉 */
  .settings-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: 85vh;
    border-left: none;
    border-top: 1px solid var(--color-border);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: 0 -8px 32px var(--color-shadow);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .settings-body {
    max-height: calc(85vh - 60px);
  }

  /* 阅读页见 reader-mobile.css */
}

/* ---------- 手机 (≤480px) ---------- */
@media (max-width: 480px) {
  .site-header {
    flex-wrap: nowrap;
    height: var(--header-height);
  }

  .header-actions {
    flex: 1;
    justify-content: flex-end;
    min-width: 0;
  }

  .search-box {
    flex: 1;
    min-width: 0;
    max-width: none;
    padding: 6px 12px;
  }

  .search-box input {
    font-size: 16px; /* 防止 iOS 自动缩放 */
  }

  .hero {
    margin-bottom: var(--space-lg);
  }

  .hero h1 {
    font-size: 1.4rem;
  }

  /* 书库：单列列表式（大屏封面左置） */
  .shelf {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }

  .shelf-card .card-link {
    flex-direction: row;
    min-height: 110px;
  }

  .shelf-card .cover-wrap {
    width: 80px;
    flex-shrink: 0;
    aspect-ratio: 3 / 4;
  }

  .shelf-card .card-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--space-sm) var(--space-md);
  }

  .shelf-card .card-link:hover {
    transform: none;
  }

  .resume-btn {
    left: auto;
    right: var(--space-md);
    bottom: var(--space-sm);
    transform: none;
  }

  /* 小说详情全宽居中 */
  .novel-header {
    grid-template-columns: 100px 1fr;
  }

  .novel-meta h1 {
    font-size: 1.2rem;
  }

  .chapter-list-section h2 {
    font-size: 1.1rem;
  }

  .ch-index {
    width: 28px;
    font-size: 0.8rem;
  }

  .theme-options {
    gap: var(--space-xs);
  }

  .theme-btn {
    padding: 10px 6px;
    font-size: 0.8rem;
  }
}

@media (max-width: 768px) and (orientation: landscape) {
  .settings-panel {
    max-height: 90vh;
  }
}
