/* 首页 / 书目页 — 主内容区搜索条 */

/* 顶栏：仅 Logo + 登录，搜索放到主内容区 */
.page-home .header-main--simple .header-search--compact,
.page-books .header-main--simple .header-search--compact {
  display: none;
}

.page-home .header-main--simple .header-main-inner,
.page-books .header-main--simple .header-main-inner {
  justify-content: space-between;
}

/* —— 图书搜索区 —— */
.home-search-zone {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 16px;
  padding: 8px 0 16px;
}

.home-books-title {
  flex-shrink: 0;
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  line-height: 1;
  font-weight: normal;
}

.home-books-title .title-cn {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 2px;
}

.home-books-title .title-en {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  opacity: 0.42;
  letter-spacing: 2px;
}

.home-search-form {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}

.home-search-field {
  flex: 1;
  min-width: 0;
  position: relative;
}

.home-search-form input {
  width: 100%;
  height: 42px;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0 40px 0 16px;
  font-size: 16px;
  outline: none;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.home-search-form input::placeholder {
  color: #999999;
  opacity: 1;
}

/* 仅使用自定义清除图标，隐藏浏览器自带 search 清除钮 */
.home-search-form input[type="search"]::-webkit-search-cancel-button,
.home-search-form input[type="search"]::-webkit-search-decoration,
.home-search-form input[type="search"]::-webkit-search-results-button {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.home-search-form input[type="search"]::-ms-clear {
  display: none;
  width: 0;
  height: 0;
}

.home-search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s;
}

.home-search-clear:hover {
  background: rgba(0, 0, 0, 0.06);
}

.home-search-clear img {
  display: block;
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.home-search-clear[hidden] {
  display: none !important;
}

.home-search-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.12);
}

.home-search-btns {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.home-search-form .btn-search-main,
.home-search-form .btn-search-brief {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 26px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  white-space: nowrap;
}

.home-search-form .btn-search-main {
  background: var(--primary);
  color: #fff;
}

.home-search-form .btn-search-main:hover {
  background: var(--primary-dark);
}

.home-search-form .btn-search-brief {
  background: var(--primary-light);
  color: #fff;
}

.home-search-form .btn-search-brief:hover {
  background: var(--primary);
}

/* —— 主视觉：分类横条 + 轮播 —— */
.home-hero {
  --home-cat-bar-h: 46px;
  --home-carousel-h: 420px;
  --home-hero-gap: 10px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--home-hero-gap);
  margin-bottom: 20px;
  width: 100%;
}

.home-categories-wrap {
  position: relative;
  z-index: 41;
  width: 100%;
  min-width: 0;
}

.home-categories {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.home-categories ul {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  margin: 0;
  padding: 0;
  gap: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scroll-padding-inline: 12px;
  scrollbar-width: none;
}

.home-categories ul::-webkit-scrollbar {
  display: none;
}

.home-categories li {
  flex: 0 0 auto;
  display: flex;
  min-width: 0;
  border-right: 1px solid var(--border);
}

.home-categories li:last-child {
  border-right: none;
}

.home-cat-trigger {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-height: var(--home-cat-bar-h);
  padding: 8px 14px;
  font-size: 15px;
  line-height: 1.35;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
  box-sizing: border-box;
  border: none;
  border-bottom: 2px solid transparent;
  background: #fff;
  cursor: default;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

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

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

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

.home-hero-body {
  position: relative;
  height: var(--home-carousel-h);
  min-width: 0;
}

/* 悬停展开的子分类面板：覆盖轮播区域 */
.home-cat-flyout-slot {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

.home-cat-flyout {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  transform: translateY(8px);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.28s ease, opacity 0.28s ease, visibility 0.28s;
}

.home-hero.is-cat-open .home-cat-flyout-slot {
  pointer-events: auto;
}

.home-hero.is-cat-open .home-cat-flyout {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

.home-cat-panels {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #d0d0d0 transparent;
}

.home-cat-panels::-webkit-scrollbar {
  width: 6px;
}

.home-cat-panels::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 3px;
}

.home-cat-panels::-webkit-scrollbar-thumb:hover {
  background: #b8b8b8;
}

.home-cat-panel {
  display: none;
  padding: 8px 0;
}

.home-cat-panel.is-active {
  display: block;
}

.home-cat-section {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 16px 20px;
}

.home-cat-section:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 0;
  height: 1px;
  background: var(--border);
}

.home-cat-section-title {
  flex: 0 0 108px;
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.45;
}

.home-cat-section-items {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 22px 48px;
  min-width: 0;
  padding-top: 1px;
}

.home-cat-section-items a {
  font-size: 15px;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.55;
  white-space: nowrap;
  padding: 2px 0;
}

.home-cat-section-items a:hover {
  color: var(--primary);
}

/* 轮播 */
.home-hero-body .home-carousel-wrap {
  position: relative;
  z-index: 1;
  min-width: 0;
  height: 100%;
}

.home-carousel-wrap {
  position: relative;
  min-width: 0;
}

.home-hero-body .home-slider {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.home-slider {
  width: 100%;
  height: 100%;
  min-height: var(--home-carousel-h);
  background: linear-gradient(120deg, #fff8f3 0%, #ffefe4 45%, #fff5ee 100%);
  border-radius: 4px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.carousel-slides {
  position: relative;
  width: 100%;
  height: 100%;
}

.carousel-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.65s ease-in-out;
  z-index: 0;
  pointer-events: none;
}

.carousel-slide.is-active {
  opacity: 1;
  z-index: 1;
  pointer-events: auto;
}

.carousel-slide .carousel-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.carousel-slide .slider-content {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 48px;
  max-width: 55%;
  box-sizing: border-box;
}

.carousel-slide--image-only .slider-content {
  display: none;
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 36px;
  height: 56px;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text-secondary);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.carousel-arrow:hover {
  background: #fff;
  color: var(--primary);
}

.carousel-prev {
  left: 0;
  border-radius: 0 4px 4px 0;
}

.carousel-next {
  right: 0;
  border-radius: 4px 0 0 4px;
}

.slider-content {
  position: relative;
  z-index: 2;
}

.slider-tag {
  display: inline-block;
  font-size: 14px;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 8px;
}

.slider-content h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.35;
}

.slider-content p {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}

.slider-dots {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 3;
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 0;
  transform: translateX(-50%);
}

.slider-dots span {
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.25s, width 0.25s;
}

.slider-dots span.active {
  background: #fff;
  width: 22px;
  border-radius: 4px;
}

/* —— 新书推荐（自适应列数，数量不限） —— */
.home-new-books {
  margin-top: 28px;
  margin-bottom: 32px;
  width: 100%;
  min-width: 0;
}

.home-new-books-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding: 8px 0 4px;
}

.home-new-books-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.home-new-books-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  transition: color 0.2s;
}

.home-new-books-more:hover {
  color: var(--primary);
}

.home-new-books-more img {
  display: block;
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.book-grid-new {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
  min-width: 0;
}

.book-card-new {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 16px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: none;
  transition: border-color 0.2s, color 0.2s;
  height: 100%;
  min-width: 0;
  box-sizing: border-box;
  color: inherit;
  text-decoration: none;
}

.book-card-new:hover {
  border-color: var(--primary);
  color: var(--text);
}

.book-card-new:active {
  border-color: var(--primary-dark);
}

.book-card-new-cover {
  width: 100%;
  max-width: 120px;
  min-height: 120px;
  margin: 0 auto 12px;
  flex-shrink: 0;
  align-self: center;
  background: #f5f5f5;
  overflow: hidden;
  border-radius: 2px;
}

.book-card-new-cover.is-empty {
  background: linear-gradient(145deg, #f0f0f0 0%, #e8e8e8 100%);
}

.book-card-new-cover img {
  width: 100%;
  height: auto;
  min-height: 120px;
  object-fit: cover;
  display: block;
  vertical-align: top;
  transform-origin: center center;
  transition: transform 0.35s ease;
}

.book-card-new:hover .book-card-new-cover img {
  transform: scale(1.08);
}

.book-card-new-title,
.book-card-new h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
  line-height: 1.45;
  width: 100%;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-card-new .author {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin: 0;
  line-height: 1.35;
  width: 100%;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 移动端分类条默认隐藏 */
.home-categories-mobile {
  display: none;
}

/* —— 响应式 —— */
@media (max-width: 1100px) {
  .book-grid-new {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
  }

  .home-cat-trigger {
    font-size: 14px;
    padding: 8px 6px;
  }
}

@media (max-width: 992px) {
  .home-cat-flyout-slot {
    position: static;
    inset: auto;
    height: auto;
    padding: 0;
    pointer-events: none;
    display: none;
  }

  .home-hero.is-cat-open .home-cat-flyout-slot {
    display: block;
    pointer-events: auto;
    margin-bottom: 8px;
  }

  .home-hero.is-cat-open .home-cat-flyout,
  .home-cat-flyout-slot .home-cat-flyout {
    transform: none;
    opacity: 1;
    visibility: visible;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  }

  .home-cat-flyout-slot .home-cat-panels,
  .home-hero-body .home-cat-panels {
    max-height: min(52vh, 360px);
  }

  .home-cat-section {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 14px 16px;
  }

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

  .home-cat-section-items {
    gap: 8px 12px;
  }

  .home-cat-section-items a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 6px 12px;
    font-size: 14px;
    white-space: normal;
    background: #f7f7f7;
    border-radius: 6px;
    border: 1px solid transparent;
  }

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

  .page-home .header-main--simple .header-search--compact {
    display: flex;
  }

  .home-search-zone {
    display: none;
  }

  .home-categories-mobile {
    display: flex;
  }

  .home-hero {
    display: block;
    width: 100%;
    max-width: 100%;
    margin-bottom: 12px;
  }

  .home-categories-wrap {
    display: none !important;
  }

  .home-hero-body {
    height: auto;
  }

  .home-hero-body .home-carousel-wrap {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 1;
    min-height: 160px;
    max-height: 240px;
    border-radius: 8px;
    overflow: hidden;
  }

  .home-hero-body .home-slider {
    height: 100%;
    min-height: 0;
    padding: 0;
    border-radius: 8px;
  }

  .home-carousel-wrap .carousel-arrow {
    width: 28px;
    height: 36px;
    font-size: 18px;
    background: rgba(255, 255, 255, 0.82);
  }

  .home-carousel-wrap .carousel-prev {
    left: 0;
    border-radius: 0 4px 4px 0;
  }

  .home-carousel-wrap .carousel-next {
    right: 0;
    border-radius: 4px 0 0 4px;
  }

  .book-grid-new {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  .book-card-new-cover {
    max-width: 100%;
    min-height: 100px;
  }

  .book-card-new-cover img {
    min-height: 100px;
  }

  .home-new-books {
    margin-top: 16px;
    margin-bottom: 24px;
  }

  .home-new-books-head {
    margin-bottom: 12px;
    gap: 8px;
  }

  .home-new-books-title {
    font-size: 17px;
  }
}

@media (max-width: 768px) {
  .home-hero-body .home-carousel-wrap {
    aspect-ratio: 16 / 9;
    min-height: 150px;
    max-height: 210px;
  }

  .book-grid-new {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .book-card-new {
    padding: 10px 8px;
    min-width: 0;
  }

  .book-card-new-cover {
    max-width: 100%;
    min-height: 88px;
    margin-bottom: 8px;
  }

  .book-card-new-cover img {
    min-height: 88px;
  }

  .book-card-new-title,
  .book-card-new h4 {
    font-size: 13px;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .book-card-new .author {
    font-size: 12px;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}

@media (max-width: 480px) {
  .book-grid-new {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .book-card-new-cover {
    min-height: 76px;
  }

  .book-card-new-cover img {
    min-height: 76px;
  }

  .home-hero-body .home-carousel-wrap {
    min-height: 140px;
    max-height: 190px;
  }

  .carousel-arrow {
    width: 24px;
    height: 32px;
    font-size: 16px;
  }

  .home-categories-mobile a {
    padding: 6px 12px;
    font-size: 13px;
  }
}
