/* 搜索结果页 — 参考布局：居中内容区 + 左分类 + 右双列结果 */

.page-books .page-wrap {
  background: var(--bg-page);
}

.page-books .main-content.books-page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px 24px 32px;
  width: 100%;
  box-sizing: border-box;
}

.books-page .home-search-zone {
  margin-bottom: 18px;
  padding: 8px 0 18px;
}

/* 左栏 + 结果区：与首页一致，中间留 hero 间距 */
.books-page-layout {
  --books-sidebar-h: 340px;
  --books-layout-gap: 14px;
  --books-cat-col: 210px;
  --home-hero-gap: var(--books-layout-gap); /* 复用 index.css 飞层滑入动画 */
  position: relative;
  display: grid;
  grid-template-columns: var(--books-cat-col) minmax(0, 1fr);
  gap: var(--books-layout-gap);
  align-items: start;
  width: 100%;
}

.books-categories-wrap {
  position: relative;
  z-index: 41;
  height: var(--books-sidebar-h);
}

/* 左侧分类卡片（样式同首页 .home-categories） */
.books-sidebar {
  display: flex;
  flex-direction: column;
  height: var(--books-sidebar-h);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}

.books-results-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.books-results-heading {
  margin: 0 0 12px;
  padding: 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-muted);
  font-weight: normal;
}

.books-results-heading[data-mode="path"] {
  color: var(--text-secondary);
}

.books-sidebar-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
  gap: 6px;
  background: #fff;
  overflow-y: auto;
  min-height: 0;
  box-sizing: border-box;
}

.books-sidebar-list .home-cat-trigger {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 34px;
  padding: 6px 12px;
  line-height: 1.45;
  text-align: center;
  font-size: var(--font-size-sidebar);
  color: var(--text);
  box-sizing: border-box;
  border: 1px solid transparent;
  background: #fff;
  cursor: default;
  font-family: inherit;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.books-sidebar-list .home-cat-trigger.is-on {
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-bg);
}

.books-sidebar-list .home-cat-trigger:focus {
  outline: none;
}

@media (hover: hover) {
  .books-sidebar-list .home-cat-trigger:hover:not(.is-on) {
    color: var(--primary);
    background: #fff;
    border-color: var(--primary);
  }
}

/* 书目页分类悬停拉起（覆盖右侧结果区，间距同 grid gap） */
.books-cat-flyout-slot {
  position: absolute;
  top: 0;
  left: var(--books-cat-col);
  right: 0;
  height: var(--books-sidebar-h);
  padding-left: var(--books-layout-gap);
  box-sizing: border-box;
  z-index: 40;
  pointer-events: none;
}

.books-page-layout.is-books-cat-open .books-cat-flyout-slot {
  pointer-events: auto;
}

.books-cat-flyout-slot .home-cat-flyout {
  transform: translateX(calc(-1 * var(--books-layout-gap)));
}

.books-page-layout.is-books-cat-open .books-cat-flyout-slot .home-cat-flyout {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
}

/* 右侧结果面板（独立白卡片） */
.books-results-panel {
  position: relative;
  z-index: 1;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 18px 28px 28px;
  min-width: 0;
}

.books-results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 48px;
  row-gap: 24px;
}

/* 单条结果：整卡可点，封面左 + 信息右 */
.search-result-card {
  min-width: 0;
  margin: 0 -10px;
  border-radius: 4px;
}

.search-result-card-link {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  min-width: 0;
  padding: 10px 12px 10px 10px;
  border-radius: 4px;
  border: 1px solid transparent;
  color: inherit;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
  cursor: pointer;
}

.search-result-card:hover .search-result-card-link,
.search-result-card-link:focus-visible {
  background: var(--primary-bg);
  border-color: transparent;
}

.search-result-card-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.search-result-cover {
  flex-shrink: 0;
  display: block;
  width: 128px;
  line-height: 0;
  overflow: hidden;
}

.search-result-cover img {
  display: block;
  width: 128px;
  height: auto;
  object-fit: contain;
  border: none;
  border-radius: 0;
  background: transparent;
  transform-origin: center center;
  transition: transform 0.35s ease;
}

.search-result-card:hover .search-result-cover img {
  transform: scale(1.08);
}

.search-result-card:active .search-result-cover img {
  transform: scale(1.04);
}

.search-result-info {
  flex: 1;
  min-width: 0;
  padding-top: 2px;
}

.search-result-title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  min-width: 0;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-card:hover .search-result-title {
  color: var(--primary);
}

.search-result-meta {
  margin: 0 0 6px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.search-result-meta .label {
  color: var(--text-muted);
}

.search-result-meta .level-tag {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid #ddd;
  border-radius: 2px;
  background: #fafafa;
  color: var(--text-secondary);
  font-size: 13px;
}

.books-results-empty {
  grid-column: 1 / -1;
  margin: 24px 0;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

.books-pagination {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.books-pagination-summary {
  margin: 0 0 14px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.books-pagination-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.books-pagination .books-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 36px;
  height: 36px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--border-dark);
  border-radius: 4px;
  background: #fff;
  color: var(--text-secondary);
  font-size: 14px;
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  vertical-align: middle;
  -webkit-appearance: none;
  appearance: none;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.books-pagination a.books-page-btn {
  color: var(--text-secondary);
}

.books-pagination a.books-page-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.books-pagination .books-page-btn:hover:not(:disabled):not(.is-active) {
  color: var(--primary);
  border-color: var(--primary);
}

.books-pagination .books-page-btn.is-active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  cursor: default;
}

.books-pagination .books-page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.books-pagination .books-page-ellipsis {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 4px;
  color: var(--text-muted);
  font-size: 14px;
  user-select: none;
}

/* 避免继承全局列表样式 */
.books-pagination ul,
.books-pagination li {
  list-style: none;
  margin: 0;
  padding: 0;
}

@media (max-width: 992px) {
  .page-books .main-content.books-page {
    padding: 16px 16px 24px;
  }

  .books-results-panel {
    padding: 16px 20px 24px;
  }

  .books-results-grid {
    column-gap: 24px;
  }

  .books-page-layout {
    position: relative;
    grid-template-columns: 1fr;
    gap: 10px;
    --books-mobile-cat-bar-h: 46px;
  }

  .books-categories-wrap {
    position: relative;
    z-index: 42;
    height: auto;
    width: 100%;
    min-width: 0;
  }

  .books-sidebar {
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
  }

  .books-sidebar-list {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 0;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scroll-padding-inline: 12px;
    scrollbar-width: none;
  }

  .books-sidebar-list::-webkit-scrollbar {
    display: none;
  }

  .books-sidebar-list .home-cat-trigger {
    flex: 0 0 auto;
    width: auto;
    min-height: 44px;
    padding: 8px 12px;
    margin: 0;
    border: none;
    border-right: 1px solid var(--border);
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: #fff;
    font-size: 14px;
    white-space: nowrap;
  }

  .books-sidebar-list .home-cat-trigger:last-child {
    border-right: none;
  }

  .books-sidebar-list .home-cat-trigger.is-on {
    color: var(--primary);
    font-weight: 600;
    background: var(--primary-bg);
    border-bottom-color: var(--primary);
  }

  .books-cat-flyout-slot {
    display: none;
    position: absolute;
    top: var(--books-mobile-cat-bar-h);
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: auto;
    padding: 6px 0 0;
    margin: 0;
    box-sizing: border-box;
    z-index: 50;
    pointer-events: none;
    overflow: visible;
  }

  .books-page-layout.is-books-cat-open .books-cat-flyout-slot {
    display: block;
    pointer-events: auto;
  }

  .books-cat-flyout-slot .home-cat-flyout,
  .books-page-layout.is-books-cat-open .books-cat-flyout-slot .home-cat-flyout {
    transform: none;
    opacity: 1;
    visibility: visible;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
    overflow: hidden;
  }

  .books-cat-flyout-slot .home-cat-panels {
    max-height: min(50vh, 340px);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .books-cat-flyout-slot .home-cat-section {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px 14px;
    box-sizing: border-box;
    max-width: 100%;
  }

  .books-cat-flyout-slot .home-cat-section:not(:last-child)::after {
    left: 14px;
    right: 14px;
  }

  .books-cat-flyout-slot .home-cat-section-title {
    flex: none;
    width: 100%;
    font-size: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }

  .books-cat-flyout-slot .home-cat-section-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .books-cat-flyout-slot .home-cat-section-items a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 6px 12px;
    font-size: 14px;
    white-space: normal;
    word-break: break-word;
    max-width: 100%;
    box-sizing: border-box;
    background: #f7f7f7;
    border-radius: 6px;
    border: 1px solid transparent;
  }

  .books-cat-flyout-slot .home-cat-section-items a:active,
  .books-cat-flyout-slot .home-cat-section-items a:hover {
    color: var(--primary);
    background: var(--primary-bg);
    border-color: var(--primary-border);
  }

  .books-results-column {
    position: relative;
    z-index: 1;
  }

  .books-results-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 992px) {
  .page-books .page-wrap {
    padding-top: 0;
  }
}

@media (max-width: 768px) {
  .page-books .main-content.books-page {
    padding: 12px 12px 20px;
  }

  .books-results-panel {
    padding: 14px 16px 20px;
  }

  .books-page .home-search-zone {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 12px;
    padding: 0 0 12px;
  }

  .books-page .home-books-title {
    display: none;
  }

  .books-page .home-search-form {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 10px;
  }

  .books-page .home-search-btns {
    display: flex;
    width: 100%;
    gap: 8px;
  }

  .books-page .home-search-form .btn-search-main,
  .books-page .home-search-form .btn-search-brief {
    flex: 1;
    min-height: 40px;
    padding: 0 12px;
    font-size: 15px;
  }

  .books-page .home-search-form input {
    font-size: 16px;
    height: 40px;
  }

  .search-result-cover {
    width: 100px;
  }

  .search-result-cover img {
    width: 100px;
  }
}

