/* ============================================================
   ebooks（アーカイブ／個別 共通）
   Release CSS（重複排除・影響範囲を明確化）
   ============================================================ */

:root {
  --gutter-sp: 16px;
  --gutter-tab: 24px;

  --card-radius: 12px;
  --card-shadow: 0 3px 12px rgba(0,0,0,.06);

  --ku-bg: #ff9900;
  --ku-fg: #ffffff;

  --amazon-bg: #005aff;
  --amazon-bg-hover: #0046cc;
  --amazon-fg: #ffffff;

  --thumb-border: #eee;
  --thumb-radius: 3px;
}

/* ============================================================
   アーカイブ：1列化（Lightningデフォルト停止）
   ============================================================ */
.post-type-archive-ebooks .vk_posts{
  display: block !important;
  margin: 0 !important;
}
.post-type-archive-ebooks .vk_post{
  width: 100% !important;
  float: none !important;
  margin-bottom: 15px !important;
}
.post-type-archive-ebooks .vk_post::after{
  display: none !important;
}

/* ============================================================
   カード（土台）
   - ここは「一覧も詳細も」共通で効く
   - 一覧が壊れないよう padding/gap を必ず持たせる
   ============================================================ */
.post-type-archive-ebooks .ebook-hbox,
.single-ebooks .ebook-hbox{
  display: flex;
  gap: 20px;                 /* ← 一覧の基本間隔（重要） */
  padding: 15px 18px;        /* ← 一覧の基本余白（重要） */
  background: #fff;
  border: 1px solid #eee;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  width: 100%;
  box-sizing: border-box;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* ============================================================
   書影（共通）
   ============================================================ */
.post-type-archive-ebooks .ebook-thumb,
.single-ebooks .ebook-thumb{
  border: 1px solid var(--thumb-border);
  border-radius: var(--thumb-radius);
  padding: 0;
  background: #fff;
  box-sizing: border-box;
  align-self: flex-start;
}

/* ============================================================
   書影：切れ防止（一覧・詳細 共通）
   - 表紙を切らずに全体表示
   ============================================================ */
.post-type-archive-ebooks .ebook-thumb img,
.single-ebooks .ebook-thumb img{
  height: auto;
  display: block;
  border-radius: var(--thumb-radius) !important;
  object-fit: contain;     /* cover → contain */
  aspect-ratio: auto;     /* 2/3 固定を解除 */
  background: #fff;       /* 余白が出た場合の保険 */
  margin: 0;
}

/* 一覧：書影は従来どおり 160px */
.post-type-archive-ebooks .ebook-thumb img{
  width: 160px;
  max-width: 160px;
}

/* 詳細：書影は 280px に統一（確定仕様） */
.single-ebooks .ebook-thumb img{
  width: 280px !important;
  max-width: 280px !important;
}

/* ============================================================
   情報エリア（右カラム）
   ============================================================ */
.post-type-archive-ebooks .ebook-info,
.single-ebooks .ebook-info{
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  align-items: flex-start;
}

/* ============================================================
   タイトル
   ============================================================ */
.post-type-archive-ebooks .ebook-title,
.single-ebooks .ebook-title{
  font-weight: 700;
  margin: 10px 0 10px;
}

.post-type-archive-ebooks .ebook-title{
  font-size: 1.15rem;
}

.single-ebooks .ebook-title{
  font-size: 1.6rem !important;  /* 反映競合対策：最終値 */
  line-height: 1.35 !important;
  margin: 14px 0 16px !important;
}

.post-type-archive-ebooks .ebook-title a,
.single-ebooks .ebook-title a{
  color: #222;
  text-decoration: none;
  word-break: break-word;
}

/* ============================================================
   （一覧で使っている場合のみ）サマリー
   ※ 詳細は本文をカード内表示のため、基本的に未使用
   ============================================================ */
.post-type-archive-ebooks .ebook-summary,
.single-ebooks .ebook-summary{
  color: #444;
  margin-bottom: 20px;
  flex-grow: 0;
}

/* ============================================================
   パンくず（カード内）
   ============================================================ */
.post-type-archive-ebooks .ebooks-card-cat,
.single-ebooks .ebooks-card-cat{
  font-size: .8rem;
  color: #666;
  margin: 2px 0;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-type-archive-ebooks .ebooks-card-cat a,
.single-ebooks .ebooks-card-cat a{
  color: #222;
  text-decoration: none;
}
.post-type-archive-ebooks .ebooks-card-cat a:hover,
.single-ebooks .ebooks-card-cat a:hover{
  text-decoration: underline;
}

.post-type-archive-ebooks .ebooks-card-cat .sep,
.single-ebooks .ebooks-card-cat .sep{
  margin: 0 6px;
  color: #999;
}

/* ============================================================
   シリーズ（詳細のみ）
   ============================================================ */
/* ============================================================
   シリーズ（詳細のみ）
   - タグ/バッジ風（黒地×白文字）
   - 角丸は控えめ（999pxではなく小さめ）
   ============================================================ */
.single-ebooks .ebooks-series{
  display: flex;
  align-items: center;
  gap: 10px !important;
  margin: 6px 0 10px !important;     /* タイトル下に置く前提で少し余白 */
  padding: 0 !important;
  border: none !important;
  background: none !important;
}

.single-ebooks .ebooks-series__label{
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  font-size: .72rem !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  color: #fff !important;
  background: #111827 !important;    /* 黒寄り */
  border-radius: 6px !important;     /* 角丸は最小限 */
  letter-spacing: .04em !important;
  white-space: nowrap;
}

.single-ebooks .ebooks-series__name{
  font-size: .86rem !important;
  font-weight: 400 !important;
  color: #555 !important;
  line-height: 1.4 !important;
  word-break: break-word;
}

/* ============================================================
   属性行（KU + DRM + タグ）
   ============================================================ */
.ebooks-attributes{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}

.ebooks-tag{
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: .78rem;
  line-height: 1;
  color: #1a1a1a;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  text-decoration: none;
  white-space: nowrap;
}
.ebooks-tag:hover{
  background: #e9ecf2;
}

/* KUバッジ（タグ化版） */
.ku-badge.as-tag{
  display: inline-flex !important;
  align-items: center;
  padding: 6px 12px !important;
  border-radius: 999px !important;
  font-size: .78rem !important;
  line-height: 1 !important;
  gap: 6px;
  background: var(--ku-bg) !important;
  color: var(--ku-fg) !important;
  white-space: nowrap;
  border: none !important;
  margin: 0 !important;
}

/* DRMフリー バッジ（KUと同列表示） */
.drmfree-badge.as-tag{
  display: inline-flex !important;
  align-items: center;
  padding: 6px 12px !important;
  border-radius: 999px !important;
  font-size: .78rem !important;
  line-height: 1 !important;
  gap: 6px;
  background: #eef6f1 !important;
  color: #2f6f55 !important;
  border: 1px solid #cfe7db !important;
  white-space: nowrap;
  margin: 0 !important;
}

/* ============================================================
   Amazon ボタン（共通）
   ============================================================ */
.post-type-archive-ebooks .btn-amazon,
.single-ebooks .btn-amazon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--amazon-bg);
  color: var(--amazon-fg);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
  transition: background-color .15s ease, transform .15s ease;
}

.post-type-archive-ebooks .btn-amazon:hover,
.single-ebooks .btn-amazon:hover{
  background: var(--amazon-bg-hover);
  transform: translateY(-1px);
}

.post-type-archive-ebooks .ebook-btn-wrap,
.single-ebooks .ebook-btn-wrap{
  margin: 0 !important;
  padding: 0;
}

/* ✅ 詳細：右カラム配置のCTA（一覧と同じ“情報側”に揃える） */
.single-ebooks .ebook-info .ebook-btn-wrap{
  margin-top: 8px !important;
}

/* ============================================================
   ebooks 詳細ページ：カード（最終レイアウト）
   ============================================================ */
.single-ebooks .ebook-hbox{
  padding: 26px 34px !important;
  gap: 36px !important;
}

/* 詳細：左カラム幅を 280px に固定 */
.single-ebooks .ebook-side{
  flex: 0 0 280px !important;
  width: 280px !important;
}

/* 詳細：本文（カード内） */
.single-ebooks .ebook-body{
  margin-top: 18px !important;
}

/* ============================================================
   書誌（書影の下）
   ============================================================ */
.ebooks-spec{
  margin-top: 18px;
  width: 100%;
}

.ebooks-spec__dl{
  margin: 0;
  width: 100%;
  display: grid;
  gap: 8px;
}

.ebooks-spec__row{
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  align-items: start;
}

.ebooks-spec__row dt{
  font-size: 12px;
  color: #666;
}

.ebooks-spec__row dd{
  margin: 0;
  color: #222;
  word-break: break-word;
}

/* ============================================================
   下部セクション（本書について / 特徴 / サポート / 関連）
   ============================================================ */
.ebooks-section{
  margin: 22px 0;
  padding: 14px 16px;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 12px;
  background: #fff;
}

.ebooks-section__title{
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.ebooks-subtitle{
  margin: 14px 0 8px;
  font-size: .95rem;
}

.ebooks-text{
  color: #333;
  line-height: 1.7;
}

.ebooks-kv{
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid rgba(0,0,0,.06);
}

.ebooks-kv:first-child{
  border-top: none;
  padding-top: 0;
}

.ebooks-kv__k{
  font-size: 12px;
  color: #666;
}

.ebooks-kv__v{
  color: #222;
}

.ebooks-support,
.ebooks-related{
  margin: 0;
  padding-left: 18px;
}

.ebooks-support__item,
.ebooks-related__item{
  margin: 8px 0;
}

.ebooks-support__link,
.ebooks-related__link{
  text-decoration: underline;
}

.ebooks-support__meta{
  font-size: 12px;
  color: #666;
  margin-top: 4px;
}

.ebooks-support__desc{
  margin-top: 6px;
  color: #333;
}

/* ============================================================
   タブレット：コンテナ余白
   ============================================================ */
@media (min-width: 768px) and (max-width: 1024px){
  .post-type-archive-ebooks .container,
  .single-ebooks .container,
  .post-type-archive-ebooks .l-container,
  .single-ebooks .l-container{
    padding-left: var(--gutter-tab) !important;
    padding-right: var(--gutter-tab) !important;
  }
}

/* ============================================================
   スマホ（後で調整予定：現状は最低限の維持）
   ============================================================ */
@media (max-width: 767px){

  .post-type-archive-ebooks .ebook-hbox,
  .single-ebooks .ebook-hbox{
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-left: 16px !important;
    margin-right: 16px !important;
    width: auto;
    gap: 6px !important;
    padding: 15px 18px;
  }

  .post-type-archive-ebooks .ebook-info,
  .single-ebooks .ebook-info{
    align-items: center !important;
    padding-right: 16px;
  }

  .post-type-archive-ebooks .ebook-info{
    padding-right: 0 !important;
    padding-left: 0 !important;
  }

  .post-type-archive-ebooks .ebook-title,
  .single-ebooks .ebook-title{
    margin-bottom: 10px !important;
  }

  .post-type-archive-ebooks .ebook-title,
  .post-type-archive-ebooks .ebooks-attributes{
    text-align: left;
  }

  .post-type-archive-ebooks .ebooks-attributes{
    justify-content: flex-start;
  }

  .ebooks-attributes{
    margin-top: 0 !important;
    margin-bottom: 14px !important;
    justify-content: center;
  }

  .post-type-archive-ebooks .ebook-thumb,
  .single-ebooks .ebook-thumb{
    align-self: center !important;
    margin-bottom: 0 !important;
  }

  .post-type-archive-ebooks .ebook-thumb img,
  .single-ebooks .ebook-thumb img{
    display: block !important;
    margin: 0 !important;
  }

  .post-type-archive-ebooks .ebook-summary,
  .single-ebooks .ebook-summary{
    text-align: left !important;
  }

  .post-type-archive-ebooks .ebook-btn-wrap,
  .single-ebooks .ebook-btn-wrap{
    text-align: center;
    width: 100%;
  }

  .post-type-archive-ebooks .ebooks-card-cat,
  .single-ebooks .ebooks-card-cat{
    display: none !important;
  }

  .single-ebooks .ebook-thumb img{
    width: 240px !important;
    max-width: 240px !important;
  }

  .ebooks-spec__row{
    grid-template-columns: 78px 1fr;
  }

  .ebooks-section{
    margin: 18px 16px;
    padding: 12px 12px;
  }
}

/* ============================================================
   ebooks 詳細：前後ナビ非表示（Lightning G3）
   ============================================================ */
.single-ebooks .vk_posts.next-prev,
.single-ebooks .next-prev,
.single-ebooks .next-prev-prev,
.single-ebooks .next-prev-next{
  display: none !important;
}

/* 保険：テーマ側パンくずは非表示（カード内パンくずを使用） */
.single-ebooks #breadcrumb{
  display: none !important;
}

/* ============================================================
   書誌情報（ebooks-spec）
   - dt を dd に近づけて視覚的ズレを解消（あなたの現状を維持）
   ============================================================ */
.single-ebooks .ebooks-spec{
  margin-top: 20px;
}

.single-ebooks .ebooks-spec__dl{
  gap: 12px;
}

.single-ebooks .ebooks-spec__row{
  grid-template-columns: 88px 1fr;
  gap: 14px;
  align-items: baseline;
}

.single-ebooks .ebooks-spec__row dt{
  font-size: 0.85rem !important;
  font-weight: 600;
  color: #666;
  line-height: 1.5;
  margin: 0;
}

.single-ebooks .ebooks-spec__row dd{
  font-size: 1rem !important;
  font-weight: 400;
  color: #222;
  line-height: 1.5;
  margin: 0;
}

/* CTA は右カラムに移したため、ここでは ebook-side ではなく ebook-info を対象にする */
.single-ebooks .ebook-info .ebook-btn-wrap{
  margin-top: 0 !important;
}

/* ============================================================
   ページタイトル周り（ebooks）
   設計方針：
   - 一覧：場所を示す静かな見出し
   - 詳細：極小の補助ラベル
   - 主役は常にカード
   ============================================================ */


/* ============================================================
   1. site-body（ページ全体の上余白）
   ============================================================ */

/* 一覧 */
.post-type-archive-ebooks .site-body{
  padding-top: 24px !important;
}

/* 詳細 */
.single-ebooks .site-body{
  padding-top: 16px !important;
}


/* ============================================================
   2. page-header（タイトル帯そのもの）
   ============================================================ */

/* 一覧 */
.post-type-archive-ebooks .page-header{
  padding: 20px 0 12px !important;
}

/* 詳細 */
.single-ebooks .page-header{
  padding: 12px 0 8px !important;
}


/* ============================================================
   3. page-header-inner.container（内側の余白）
   ============================================================ */

/* 一覧 */
.post-type-archive-ebooks .page-header-inner.container{
  padding-top: 16px !important;
  padding-bottom: 8px !important;
  margin-bottom: 8px !important;
}

/* 詳細 */
.single-ebooks .page-header-inner.container{
  padding-top: 8px !important;
  padding-bottom: 4px !important;
  margin-bottom: 4px !important;
}


/* ============================================================
   4. page-header-title（文字）
   ============================================================ */

/* 一覧：静かなセクション見出し */
.post-type-archive-ebooks .page-header-title{
  font-size: 1.5rem !important;
  font-weight: 600 !important;
  margin: 0 !important;
  letter-spacing: .02em;
  text-align: center;
}

/* 詳細：極小の補助ラベル */
.single-ebooks .page-header-title{
  font-size: 1.1rem !important;
  font-weight: 500 !important;
  margin: 0 !important;
  color: #666 !important;
  letter-spacing: .02em;
}


/* ============================================================
   5. 詳細：タイトル直下のカードとの距離
   ============================================================ */

.single-ebooks .page-header + .ebook-hbox{
  margin-top: 6px !important;
}

.ebooks-backlink {
  margin-bottom: 4px;
  font-size: .8rem;
}

.ebooks-backlink a {
  color: #555;
  text-decoration: none;
}

.ebooks-backlink a:hover {
  text-decoration: underline;
}

/* ============================================================
   詳細（スマホ）：タイトル/シリーズを書影の上へ
   - パーツ単位で並び替え（Grid + display: contents）
   - バッジ・タグは「シリーズの下」
   - PC版非影響
   ============================================================ */
@media (max-width: 767px){

  /* 1) カード全体をGrid化（スマホのみ） */
  .single-ebooks .ebook-hbox{
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    text-align: left !important;
    align-items: start !important;
  }

  /* 2) カラム箱を透明化（子要素を直下として扱う） */
  .single-ebooks .ebook-info,
  .single-ebooks .ebook-side{
    display: contents !important;
  }

  /* 3) 左揃えに統一（見出し/本文/書誌） */
  .single-ebooks .ebook-title,
  .single-ebooks .ebooks-series,
  .single-ebooks .ebooks-attributes,
  .single-ebooks .ebook-body,
  .single-ebooks .ebooks-spec{
    text-align: left !important;
  }

  .single-ebooks .ebooks-attributes{
    justify-content: flex-start !important;
  }

  /* 4) 表示順（小さいほど上） */
  .single-ebooks .ebooks-backlink{ order: 1; }
  .single-ebooks .ebooks-card-cat{ order: 2; }

  .single-ebooks .ebook-title{
    order: 3;
    margin: 0 0 6px !important;
  }

  .single-ebooks .ebooks-series{
    order: 4;
    margin: 0 0 6px !important;
  }

  /* ★ シリーズの下にバッジ・タグ */
  .single-ebooks .ebooks-attributes{
    order: 5;
    margin: 0 0 10px !important; /* ついでの1行：詰めすぎ防止 */
  }

  .single-ebooks .ebook-thumb{
    order: 6;
    justify-self: center;
  }

  .single-ebooks .ebooks-spec{
    order: 7;
  }

  .single-ebooks .ebook-body{
    order: 8;
    margin-top: 10px !important;
  }

  /* CTAは本文の下 */
  .single-ebooks .ebook-btn-wrap{
    order: 9;
    margin-top: 0 !important;
  }

  .single-ebooks .btn-amazon{
    width: 100%;
    justify-content: center;
  }

  /* 行と行の縦間隔を少しだけ詰める */
  .single-ebooks .ebooks-spec__dl{
    gap: 6px;
  }

  /* ラベル（dt）と値（dd）の行高を軽く下げる */
  .single-ebooks .ebooks-spec__row dt,
  .single-ebooks .ebooks-spec__row dd{
    line-height: 1.3;
  }

  .single-ebooks .ebooks-spec{
    padding-bottom: 12px;
    margin-bottom: 14px;
    border-bottom: 1px solid rgba(0,0,0,.06);
  }

  /* ボタンを元のサイズ感に戻す */
  .single-ebooks .btn-amazon{
    width: auto !important;        /* 横100%を解除 */
    min-width: auto !important;
  }

  /* 必要なら中央寄せはラッパーで */
  .single-ebooks .ebook-btn-wrap{
    text-align: center;
  }

  /* 1) ページ全体の上余白（必要ならさらに詰める） */
  .single-ebooks .site-body{
    padding-top: 0 !important;   /* 16px→さらに軽く（好みで 8〜12px） */
  }

  /* 2) タイトル帯（外側） */
  .single-ebooks .page-header{
    padding: 0 !important;
    margin: 0 !important;
  }

  /* 3) タイトル帯（内側コンテナ） */
  .single-ebooks .page-header .page-header-inner.container{
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
  }

  /* 4) タイトル文字（念のため余白ゼロ化） */
  .single-ebooks .page-header-title{
    margin: 0 !important;
  }
}
