/* ========== Rakuten Widget Slider ========== */
/* 2025-01-19: 楽天商品スライダーウィジェット */

.rakuten-widget {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.rakuten-widget-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.rakuten-widget-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: #bf0000;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 4px;
}

.rakuten-widget-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* スライダーコンテナ */
.rakuten-widget-slider {
  position: relative;
  overflow: hidden;
}

.rakuten-widget-track {
  display: flex;
  transition: transform 0.3s ease;
}

/* 商品カード */
.rakuten-widget-item {
  flex: 0 0 100%;
  min-width: 100%;
  padding: 0 0.5rem;
  box-sizing: border-box;
}

.rakuten-widget-item a {
  display: flex;
  gap: 1rem;
  text-decoration: none;
  color: inherit;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border-radius: 8px;
  border-bottom: none;
  transition: box-shadow 0.2s ease;
}

.rakuten-widget-item a:hover {
  box-shadow: var(--shadow-md);
  text-decoration: none;
  border-bottom: none;
}

/* 商品画像 */
.rakuten-widget-image {
  flex-shrink: 0;
  width: 124px;
  height: 144px;
  padding: 12px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
}

.rakuten-widget-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.rakuten-widget-noimage {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* 商品情報 */
.rakuten-widget-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.rakuten-widget-item-title {
  margin: 0 0 0.5rem 0;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rakuten-widget-author {
  margin: 0 0 0.25rem 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.rakuten-widget-price {
  margin: 0 0 0.25rem 0;
  font-size: 1rem;
  font-weight: 700;
  color: #bf0000;
}

.rakuten-widget-shop {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ナビゲーションボタン */
.rakuten-widget-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  font-size: 1.2rem;
  color: var(--text-primary);
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.rakuten-widget-nav:hover {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

.rakuten-widget-prev {
  left: 0;
}

.rakuten-widget-next {
  right: 0;
}

/* インジケーター */
.rakuten-widget-indicators {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.rakuten-widget-dot {
  width: 8px;
  height: 8px;
  background: var(--border-color);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s ease;
}

.rakuten-widget-dot.active {
  background: var(--accent-primary);
}

.rakuten-widget-dot:hover {
  background: var(--accent-secondary);
}

/* フッター */
.rakuten-widget-footer {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.rakuten-widget-more {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--accent-primary);
  text-decoration: none;
  border-bottom: none;
  transition: color 0.2s ease;
}

.rakuten-widget-more:hover {
  color: var(--accent-hover);
  text-decoration: none;
  border-bottom: none;
}

/* 空の状態 */
.rakuten-widget-empty {
  text-align: center;
  padding: 2rem 1rem;
}

.rakuten-widget-empty p {
  margin: 0 0 1rem 0;
  color: var(--text-muted);
}

.rakuten-widget-empty a {
  color: var(--accent-primary);
  text-decoration: none;
}

.rakuten-widget-empty a:hover {
  text-decoration: underline;
}

/* スマホ対応 */
@media (max-width: 768px) {
  .rakuten-widget {
    margin: 1rem 0;
    padding: 0.75rem;
  }
  
  .rakuten-widget-header {
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
  }
  
  .rakuten-widget-title {
    font-size: 0.85rem;
  }
  
  .rakuten-widget-item a {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
  }
  
  .rakuten-widget-image {
    width: 144px;
    height: 164px;
    padding: 12px;
  }
  
  .rakuten-widget-item-title {
    font-size: 0.8rem;
    -webkit-line-clamp: 3;
  }
  
  .rakuten-widget-nav {
    width: 28px;
    height: 28px;
    font-size: 1rem;
  }
  
  .rakuten-widget-footer {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
  }
  
  .rakuten-widget-more {
    font-size: 0.8rem;
  }
}

/* ========== Amazon・楽天ボタン（書籍用） ========== */
.rakuten-widget-card {
  display: flex;
  gap: 1rem;
  text-decoration: none;
  color: inherit;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border-radius: 8px;
  border-bottom: none;
  transition: box-shadow 0.2s ease;
}

.rakuten-widget-card:hover {
  box-shadow: var(--shadow-md);
}

a.rakuten-widget-card:hover {
  text-decoration: none;
  border-bottom: none;
}

.rakuten-widget-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0 0.5rem;
}

.rakuten-widget-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.75rem !important;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 4px;
  border-bottom: none !important;
  transition: opacity 0.2s ease;
}

.rakuten-widget-btn:hover {
  opacity: 0.85;
  text-decoration: none;
  border-bottom: none !important;
}

.rakuten-widget-btn-amazon {
  background: #ff9900 !important;
  color: #111 !important;
}

.rakuten-widget-btn-amazon:hover {
  color: #111 !important;
}

.rakuten-widget-btn-rakuten {
  background: #bf0000 !important;
  color: #fff !important;
}

.rakuten-widget-btn-rakuten:hover {
  color: #fff !important;
}

/* スマホ対応：ボタン */
@media (max-width: 768px) {
  .rakuten-widget-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
  }
  
  .rakuten-widget-buttons {
    justify-content: center;
  }
  
  .rakuten-widget-btn {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
  }
}

/* ========== 小説カテゴリ専用（縦書きページ対応） ========== */
/* 2026-02-03: 小説ページでのみ横書きを強制 */

body.category-novels .rakuten-widget {
  writing-mode: horizontal-tb !important;
  text-orientation: mixed !important;
  direction: ltr !important;
  max-width: 600px;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

body.category-novels .rakuten-widget-slider,
body.category-novels .rakuten-widget-track {
  max-width: 100%;
}

body.category-novels .rakuten-widget-item {
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

body.category-novels .rakuten-widget-item a {
  max-width: 100%;
  box-sizing: border-box;
}

body.category-novels .rakuten-widget-info {
  overflow: hidden;
}

body.category-novels .rakuten-widget-item-title {
  word-break: break-word;
}

/* 小説カテゴリ：スマホ対応 */
@media (max-width: 768px) {
  body.category-novels .rakuten-widget {
    max-width: 100%;
  }
  
  body.category-novels .rakuten-widget-item a {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
  }
}
