/* ============================================
   修復：佈局重疊、分類頁面、小說系列分組
   ============================================ */

/* --- 修復Grid溢出（防止圖片重疊側欄）--- */
.shell > main {
  min-width: 0;
  max-width: 100%;
}

.shell > .sidebar {
  min-width: 0;
}

.article-card {
  min-width: 0;
  max-width: 100%;
}

.article-card a {
  display: block;
  min-width: 0;
}

.thumb {
  width: 100%;
  max-width: 100%;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.grid-2, .grid-3, .grid-4 {
  min-width: 0;
}

.grid-2 > *, .grid-3 > *, .grid-4 > * {
  min-width: 0;
}

/* 確保所有圖片不溢出容器 */
main img, .prose img, .article-card img {
  max-width: 100%;
  height: auto;
}

/* --- 增加佈局間距（解決左右框太貼）--- */
.shell {
  gap: 40px !important;
  padding: 32px 0 80px !important;
}

@media (min-width: 981px) {
  .shell {
    grid-template-columns: 300px 1fr !important;
  }
}

.grid-2 {
  gap: 24px !important;
}

.grid-3 {
  gap: 20px !important;
}

.grid-4 {
  gap: 18px !important;
}

/* 卡片內邊距增加 */
.card.pad {
  padding: 24px !important;
}

.article-card .pad {
  padding: 20px !important;
}

/* 各區塊之間的間距 */
main > section,
main > .card,
main > .series-group {
  margin-bottom: 32px !important;
}

main > section:last-child,
main > .card:last-child {
  margin-bottom: 0 !important;
}

/* 側邊欄卡片間距 */
.sidebar .card {
  margin-bottom: 20px !important;
}

.sidebar .card:last-child {
  margin-bottom: 0 !important;
}

/* 統計數字區間距 */
.stats {
  gap: 16px !important;
  padding: 24px !important;
  margin-bottom: 28px !important;
}

/* 分類入口卡片間距 */
.portal {
  padding: 20px 16px !important;
  gap: 10px !important;
}

/* 文章列表頁標題與內容間距 */
.page-title {
  margin-bottom: 12px !important;
}

.chip-row {
  margin: 20px 0 28px !important;
}

/* 熱門排行卡片間距 */
.rank-list {
  gap: 4px !important;
}

.rank-row {
  padding: 14px 12px !important;
  border-radius: 10px !important;
}

/* 最新消息列表間距 */
.news-row {
  padding: 16px 12px !important;
  border-radius: 10px !important;
  gap: 16px !important;
}

/* 活動列表間距 */
.event-row {
  padding: 16px 12px !important;
  border-radius: 10px !important;
  gap: 16px !important;
}

/* 友情連結卡片間距 */
.links-grid .portal {
  padding: 18px 14px !important;
}

/* 訂閱區塊間距 */
.subscribe-block {
  padding: 32px !important;
  margin-top: 36px !important;
}

/* --- 分類標籤行優化 --- */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 24px;
  align-items: center;
}

.chip-divider {
  width: 1px;
  height: 20px;
  background: var(--line);
  margin: 0 4px;
}

/* --- 小說系列分組樣式 --- */
.series-group {
  margin-bottom: 36px;
}

.series-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--line);
  position: relative;
}

.series-header::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 80px;
  height: 2px;
  background: linear-gradient(90deg, var(--navy), var(--gold));
}

.series-title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--navy-deep);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.series-title i {
  color: var(--gold);
  font-size: 18px;
}

.series-count {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  background: rgba(38, 65, 92, 0.08);
  padding: 3px 10px;
  border-radius: 999px;
  margin-left: 8px;
}

/* --- 頁面標題優化 --- */
.page-title {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
  color: var(--navy-deep);
  margin: 0 0 8px;
}

/* --- 麵包屑優化 --- */
.crumbs {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.crumbs a {
  color: var(--navy);
  text-decoration: none;
}

.crumbs a:hover {
  text-decoration: underline;
}

/* --- 文章卡片在分類頁面的優化 --- */
.article-card .thumb {
  height: 180px;
}

.article-card h3 {
  font-size: 17px;
  line-height: 1.4;
  margin-bottom: 6px;
}

.article-card .excerpt,
.article-card p.muted {
  font-size: 13px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-card .meta {
  font-size: 11px;
  margin-top: 8px;
  flex-wrap: wrap;
  gap: 6px;
}

/* --- 側邊欄在桌面端的固定定位優化 --- */
@media (min-width: 981px) {
  .sidebar {
    position: sticky;
    top: 90px;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
  }
}

/* --- 分類徽章樣式 --- */
.category-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  backdrop-filter: blur(6px);
  z-index: 2;
}

/* --- 空狀態提示 --- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

/* --- 分頁優化 --- */
.pager-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 32px;
  flex-wrap: wrap;
}

.pager-row a,
.pager-row span {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 13px;
  text-decoration: none;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  transition: all 0.2s;
}

.pager-row a:hover {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.pager-row .current {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
  font-weight: 600;
}

/* --- 小說系列子導航 --- */
.series-subnav {
  background: linear-gradient(135deg, rgba(38, 65, 92, 0.04), rgba(196, 163, 90, 0.06));
  border: 1px solid rgba(38, 65, 92, 0.1);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 28px;
}

.series-subnav-label {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 600;
  color: var(--navy-deep);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.series-subnav-label i {
  color: var(--gold);
}

.series-subnav .chip-row {
  margin: 0 !important;
  gap: 6px;
}

.chip-sm {
  font-size: 12px !important;
  padding: 6px 14px !important;
  border-radius: 999px !important;
  transition: all 0.2s ease;
}

.chip-sm i {
  font-size: 11px;
  margin-right: 4px;
}

.chip-sm.is-on {
  background: var(--navy) !important;
  color: #fff !important;
  border-color: var(--navy) !important;
}

.chip-sm.is-on i {
  color: var(--gold);
}

.series-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  margin-left: 4px;
}

.chip-sm:not(.is-on) .series-badge {
  background: rgba(38, 65, 92, 0.1);
  color: var(--muted);
}

/* 系列子導航響應式 */
@media (max-width: 640px) {
  .series-subnav {
    padding: 12px 14px;
  }
  
  .series-subnav-label {
    font-size: 13px;
  }
  
  .chip-sm {
    font-size: 11px !important;
    padding: 5px 12px !important;
  }
}


/* --- Admin 編輯按鈕 --- */
.admin-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff !important;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
  white-space: nowrap;
}

.admin-edit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.45);
  color: #fff !important;
  text-decoration: none;
}

.admin-edit-btn i {
  font-size: 11px;
}

@media (max-width: 640px) {
  .admin-edit-btn {
    padding: 4px 10px;
    font-size: 11px;
  }
}
