/**
 * book.css - 商品詳細ページ
 */

.book-detail-section {
  padding: 2rem 1.5rem;
  max-width: 1000px;
  margin: 0 auto;
}

.book-detail-header {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.book-detail-cover {
  position: relative;
}

.book-detail-cover img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: transform 0.2s;
}

.book-detail-cover img:hover {
  transform: scale(1.02);
}

.book-detail-info h1 {
  font-size: 1.5rem;
  margin: 0 0 1rem;
  line-height: 1.4;
}

.book-detail-meta {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-size: 0.95rem;
}

.book-detail-meta .meta-row {
  display: flex;
  gap: 0.5rem;
}

.book-detail-meta .meta-label {
  color: var(--color-text-muted);
  min-width: 80px;
  flex-shrink: 0;
}

.book-detail-meta .meta-value {
  color: var(--color-text);
}

.book-price {
  font-weight: 600;
  font-size: 1.1rem;
}

.book-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.book-tag {
  background: var(--color-bg-gray);
  color: var(--color-text);
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
  font-size: 0.8rem;
  border: 1px solid var(--color-border);
}

.book-sales-links {
  margin-top: 1rem;
}

.book-sales-links ul {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.book-sales-links a {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  text-decoration: none;
  transition: background 0.2s, transform 0.2s;
}

.book-sales-links a:hover {
  background: var(--color-accent);
  color: #fff;
  transform: translateY(-2px);
}

/* スティッキーヘッダー */
.book-sticky-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--color-bg);
  margin: 0 -1.5rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

/* スティッキータイトル（スクロール時に表示） */
.book-sticky-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
}

.book-sticky-title.visible {
  max-height: 3rem;
  opacity: 1;
}

/* セクションナビ */
.book-section-nav {
  display: flex;
  gap: 1.5rem;
}

.book-section-nav a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  outline: none;
}

.book-section-nav a:hover {
  color: var(--color-primary);
}

.book-section-nav a.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* セクション */
.book-section {
  margin-top: 2rem;
  padding-top: 1rem;
  scroll-margin-top: 120px;
}

.book-section h2 {
  font-size: 1.1rem;
  margin: 0 0 1rem;
  font-weight: 600;
}

.book-description-body {
  line-height: 1.8;
}

.book-bonus-img {
  text-align: center;
}

.book-bonus-img img {
  max-width: 100%;
  max-height: 60vh;
  width: auto;
  height: auto;
  border-radius: 12px;
  cursor: pointer;
}

/* サンプルビューワー */
.sample-viewer {
  max-width: 100%;
  margin: 0 auto;
}

.sample-viewer-main {
  position: relative;
  background: #CCC;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 画面高さの60%を超えない */
  max-height: 60vh;
}

.sample-viewer-track {
  position: relative;
  cursor: grab;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.sample-page {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
}

.sample-page.active {
  display: flex;
}

.sample-page img {
  max-width: 100%;
  max-height: 60vh;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
}

.sample-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s, opacity 0.2s;
  opacity: 0;
}

.sample-viewer-main:hover .sample-nav {
  opacity: 1;
}

.sample-nav:hover {
  background: #fff;
}

.sample-prev {
  left: 1rem;
}

.sample-next {
  right: 1rem;
}

.sample-viewer-indicator {
  text-align: center;
  padding: 0.75rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.sample-thumbnails {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem;
  background: var(--color-bg-gray);
  border-radius: 8px;
  scrollbar-width: thin;
}

.sample-thumbnails::-webkit-scrollbar {
  height: 6px;
}

.sample-thumbnails::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.sample-thumb {
  flex-shrink: 0;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  background: none;
  transition: border-color 0.2s, opacity 0.2s;
  opacity: 0.7;
}

.sample-thumb:hover {
  opacity: 1;
}

.sample-thumb.active {
  border-color: var(--color-primary);
  opacity: 1;
}

.sample-thumb img {
  display: block;
  width: 60px;
  height: auto;
  border-radius: 4px;
}

/* モーダル */
.img-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
}

.img-modal.show {
  display: flex;
}

.img-modal img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
}

.img-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
}

/* レスポンシブ */
@media screen and (max-width: 768px) {
  .book-detail-header {
    grid-template-columns: 1fr;
  }

  .book-detail-cover {
    max-width: 280px;
    margin: 0 auto;
  }

  .book-section-nav {
    gap: 1rem;
    font-size: 0.9rem;
  }

  .sample-nav {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
    opacity: 1;
  }

  .sample-prev {
    left: 0.5rem;
  }

  .sample-next {
    right: 0.5rem;
  }

  .sample-thumb img {
    width: 50px;
  }
}