/* =============================================================
   site-enhancements.css
   商品カード・一覧表示の見やすさ改善レイヤー（site.css に追加）
   A. カード内情報の階層整理
   B. カード密度・区切りの調整
   C. ビュー切替（list / grid / compact）
   D. フィルタ・ソート強化（Sticky / アクティブチップ / ソートpill）
   ============================================================= */


/* ============================================================
   A. カード内情報の階層整理
   ============================================================ */

/* A-1. 割引率バッジ強化（既存 .discount を badge 化） */
.discount {
  display: inline-block;
  background: var(--danger);
  color: #ffffff;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 18px;
  font-weight: 1000;
  letter-spacing: -0.02em;
  line-height: 1.3;
  box-shadow: 0 2px 6px rgba(209, 11, 30, 0.25);
}

@media (min-width: 980px) {
  .discount {
    font-size: 20px;
  }
}

/* A-1b. カバー上部の割引率チップ（JSで .coverRibbon を挿入）
   サムネイルにかぶせず、その上の行に配置 */
.bookCover {
  position: relative;
}

/* チップが1つでも存在する場合のみグリッドに切り替え、
   1行目をチップ用、2行目をカバー画像用にする */
.bookCover:has(.coverRibbon, .exclusiveBadge) {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  row-gap: 4px;
  align-items: start;
}

.bookCover .coverLink {
  grid-row: 2;
  grid-column: 1 / -1;
}

.coverRibbon {
  position: static;
  grid-row: 1;
  grid-column: 1;
  justify-self: start;
  background: var(--danger);
  color: #ffffff;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 1000;
  letter-spacing: -0.01em;
  line-height: 1.2;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

/* A-1c. カバー上部右の専売チップ（黄色地に黒文字） */
.exclusiveBadge {
  position: static;
  grid-row: 1;
  grid-column: 2;
  justify-self: end;
  background: #ffd400;
  color: #000;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 1000;
  letter-spacing: 0.04em;
  line-height: 1.2;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

/* ミニカード（トップページ）用の専売バッジ */
.miniExclusive {
  position: absolute;
  right: 5px;
  bottom: 5px;
  background: #ffd400;
  color: #000;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: 0.04em;
  line-height: 1.2;
  pointer-events: none;
}


/* A-2. 価格ブロックの分離（priceCard 化） */
.line4price {
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(209, 11, 30, 0.05);
  border-left: 3px solid var(--danger);
  border-radius: 8px;
  align-items: center;
  font-variant-numeric: tabular-nums;
}

.priceNow,
.priceOld {
  font-variant-numeric: tabular-nums;
}

html[data-mode="dark"] .line4price {
  background: rgba(251, 113, 133, 0.08);
}

/* セールがない価格（priceStatic/priceFallback）の場合は背景控えめに */
.line4price:has(.priceStatic),
.line4price:has(.priceFallback) {
  background: transparent;
  border-left-color: transparent;
  padding-left: 0;
}


/* ============================================================
   B. カード密度・区切りの調整
   ============================================================ */

/* .results 内の productList を「カード並び」に */
.results .productList {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--pageBg);
}

.results .productCard {
  border: 1px solid var(--line);
  border-top: 1px solid var(--line); /* first-of-type 打ち消し */
  border-radius: 12px;
  background: var(--bg);
  box-shadow: 0 1px 3px rgba(2, 6, 23, 0.04);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.results .productCard:hover {
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.08);
  transform: translateY(-1px);
}

html[data-mode="dark"] .results .productCard:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

/* B-2. zebra（.productList--zebra が付いたとき） */
.productList--zebra .productCard:nth-child(even) {
  background: var(--pageBg);
}

html[data-mode="dark"] .productList--zebra .productCard:nth-child(even) {
  background: rgba(148, 163, 184, 0.04);
}


/* ============================================================
   C. ビュー切替
   ============================================================ */

/* C-1. トグルボタン群 */
.viewToggle {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
  gap: 0;
}

.viewBtn {
  background: transparent;
  border: 0;
  padding: 5px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  cursor: pointer;
  white-space: nowrap;
}

.viewBtn:hover {
  color: var(--text);
}

.viewBtn[aria-pressed="true"] {
  background: var(--text);
  color: var(--bg);
  font-weight: 900;
}

.viewBtnIcon {
  margin-right: 4px;
  font-size: 12px;
}


/* C-2. グリッドビュー */
.productList--grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding: 12px;
  background: var(--pageBg);
}

@media (min-width: 980px) {
  .productList--grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

.productList--grid .productCard {
  grid-template-columns: 1fr !important;
  grid-template-areas:
    "cover"
    "main"
    "buy" !important;
  padding: 10px;
  gap: 8px;
}

.productList--grid .bookCover {
  width: 100%;
}

.productList--grid .coverLink {
  aspect-ratio: 1 / 1;
  max-width: 180px;
  margin: 0 auto;
}

.productList--grid .bookBuy {
  justify-self: stretch;
  align-items: stretch;
}

.productList--grid .bookBuy .storeBtn {
  width: 100%;
  min-width: 0;
  height: 38px;
  font-size: 13px;
}

.productList--grid .titleLink {
  font-size: 15px;
  -webkit-line-clamp: 2;
}

.productList--grid .line2stats,
.productList--grid .line3creator,
.productList--grid .line6meta {
  font-size: 12px;
}

.productList--grid .priceNow {
  font-size: 18px;
}

.productList--grid .discount {
  font-size: 14px;
  padding: 1px 6px;
}


/* C-3. コンパクトビュー */
.productList--compact {
  display: flex !important;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: var(--bg);
}

.productList--compact .productCard {
  grid-template-columns: 64px minmax(0, 1fr) auto !important;
  grid-template-areas: "cover main buy" !important;
  padding: 10px 12px;
  gap: 10px;
  border-radius: 0;
  border: none;
  border-top: 1px solid var(--line);
  box-shadow: none;
  background: var(--bg);
}

.productList--compact .productCard:hover {
  box-shadow: none;
  transform: none;
  background: var(--pageBg);
}

.productList--compact .productCard:first-of-type {
  border-top: none;
}

.productList--compact .coverLink {
  aspect-ratio: 1 / 1;
  border-radius: 6px;
}

.productList--compact .titleLink {
  font-size: 14px;
  -webkit-line-clamp: 1;
  line-height: 1.4;
}

.productList--compact .contextSlot,
.productList--compact .line3creator,
.productList--compact .line5sale,
.productList--compact .line6meta {
  display: none;
}

.productList--compact .line2stats {
  margin-top: 4px;
  font-size: 12px;
  gap: 10px;
}

.productList--compact .line4price {
  margin-top: 4px;
  padding: 2px 8px;
  background: transparent;
  border-left: 0;
  font-size: 14px;
}

.productList--compact .priceNow {
  font-size: 16px;
}

.productList--compact .discount {
  font-size: 13px;
  padding: 1px 6px;
  box-shadow: none;
}

.productList--compact .bookBuy .storeBtn {
  height: 32px;
  min-width: 140px;
  font-size: 12px;
  padding: 0 32px 0 12px;
}

.productList--compact .bookBuy .storeBtn .label {
  font-size: 12px;
}


/* ============================================================
   D. フィルタ・ソート強化
   ============================================================ */

/* D-1. Sticky フィルタバー */
.filterBar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.93);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

html[data-mode="dark"] .filterBar {
  background: rgba(11, 18, 32, 0.93);
}


/* D-2. アクティブフィルタチップの表示行 */
.activeFilters {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  background: rgba(148, 163, 184, 0.03);
}

.activeFilters:empty {
  display: none;
}

.activeFiltersLabel {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-right: 2px;
}

.activeFilter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  background: var(--text);
  color: var(--bg);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.activeFilterRemove {
  background: rgba(255, 255, 255, 0.22);
  border: 0;
  border-radius: 999px;
  color: inherit;
  width: 18px;
  height: 18px;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.activeFilterRemove:hover {
  background: rgba(255, 255, 255, 0.4);
}

.activeFilterClear {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--line);
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.activeFilterClear:hover {
  color: var(--text);
  border-color: var(--text);
}


/* D-3. ソート pill（主要ソートを前面に） */
.sortPills {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
  flex-wrap: nowrap;
}

.sortPill {
  background: transparent;
  border: 0;
  padding: 5px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  cursor: pointer;
  white-space: nowrap;
}

.sortPill:hover {
  color: var(--text);
}

.sortPill[aria-pressed="true"] {
  background: var(--danger);
  color: #ffffff;
  font-weight: 900;
}

.sortPillIcon {
  margin-right: 4px;
}

/* sortLimitRow をフィルタバーの中に展開する用 */
.filterBar .sortGroup {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}


/* ============================================================
   E. トップページ（index.html）反映
   ============================================================ */

/* 既存の .miniOff バッジをより目立たせる */
.miniOff {
  padding: 3px 8px;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  letter-spacing: -0.02em;
}

/* ミニカードのホバー演出 */
.miniCard {
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.miniCard:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(2, 6, 23, 0.1);
  border-color: #93c5fd;
}

html[data-mode="dark"] .miniCard:hover {
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.45);
}

.miniNow {
  font-variant-numeric: tabular-nums;
}

/* ヒーロー/カテゴリセクション見出しの視認性UP */
.catSectionTitle {
  font-size: 18px;
}

.catSectionTitle::before {
  content: "▸ ";
  color: var(--danger);
  font-weight: 900;
}

.catSectionTitle a {
  color: inherit;
  text-decoration: none;
}

.catSectionTitle a:hover {
  text-decoration: underline;
}

.catMore {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  font-weight: 700;
  font-size: 12px;
  color: var(--text);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.catMore:hover {
  border-color: #93c5fd;
  color: var(--dlsite);
}


/* ============================================================
   F. モバイル微調整
   ============================================================ */

@media (max-width: 720px) {
  .filterBar {
    padding: 8px;
    gap: 8px;
  }

  /* スマホでは「カテゴリ」を次の行に追い出すため、divider を全幅・高さ0の不可視ブレーカーに */
  .filterDivider {
    flex-basis: 100%;
    width: 100%;
    height: 0;
    background: transparent;
    border: 0;
  }

  .filterRight {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .viewToggle,
  .sortPills {
    font-size: 12px;
  }

  .viewBtn,
  .sortPill {
    padding: 4px 10px;
    font-size: 12px;
  }

  .productList--grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ============================================================
   P. ebook ポイント還元バッジ（books-daily の pointRate）
   価格行（.line4price）内にインライン配置。割引の赤バッジとは
   色・形を分け、「ポイント還元」と判別しやすくする。
   ============================================================ */
.pointBadge {
  display: inline-block;
  background: rgba(16, 137, 62, 0.1);
  color: #0a7a37;
  border: 1px solid rgba(16, 137, 62, 0.35);
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.5;
  white-space: nowrap;
}

/* ミニカード（ホームのランキング）内では小さめに */
.miniPrice .pointBadge {
  font-size: 11px;
  padding: 1px 7px;
  font-weight: 700;
}

html[data-mode="dark"] .pointBadge {
  background: rgba(52, 211, 153, 0.14);
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.4);
}
