/* search-filter.css — 書籍検索（トップ/検索ページ 共通レイアウト・879/880統一） */

/* =========================================================
   外枠
========================================================= */
.book-search {
  background: #eef6ff;
  padding: 56px 0 72px;
}
.book-search .container {
  max-width: 100%;
  margin: 0 auto;
  padding: 60px 40px;
}

/* 見出し（整列のみ） */
.book-search__heading-en,
.book-search__heading-ja { text-align: center; }

/* フォームカード（共通） */
.book-search__form {
  background: #fff;
  border-radius: 12px;
  padding: 40px 30px;
}

/* =========================================================
   グループ行
========================================================= */
.book-search__group{
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 24px 0;
  margin: 0;
  border-top: 1px solid #e6edf6;
}
.book-search__group--series,
.book-search__group:first-of-type{
  border-top: 0;
  padding-top: 0;
}
.book-search__group--subject{
  padding-bottom: 24px;
  margin-bottom: 0;
}

/* 科目ブロック（点線） */
.js-category-block{
  border-top: 2px dashed #d9e2ef;
  margin-top: 0;
  padding-top: 16px;
}

/* 左ラベル／右オプション */
.book-search__label{
  width: 200px;
  flex-shrink: 0;
  font-weight: 700;
  color: #0072ba;
  line-height: 1.6;
  white-space: nowrap;
}
.book-search__group--keyword .book-search__label{ padding-top: 0; }

.book-search__options{
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* =========================================================
   チップ & 「全て」ボタン
========================================================= */
.book-search__options label,
.chip{
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}
.chip{
  position: relative;
  display: inline-flex;
  align-items: center;
}
.chip input{
  position: absolute;
  width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; opacity: 0;
}
.chip span{
  display: inline-block;
  padding: 14px 18px;
  border: 1px solid #d9e2ef;
  border-radius: 999px;
  background: #fff;
  color: #364a63;
  line-height: 1;
  transition: all .15s ease;
}
/* 選択色（共通） */
.chip:has(input:checked) span,
.chip input:checked + span{
  border-color: #1f77d3;
  color: #1f77d3;
}

/* 「全て」ボタン */
.chip-btn{
  display: inline-block;
  padding: 14px 18px;
  border: 1px solid #d9e2ef;
  border-radius: 999px;
  background: #fff;
  color: #364a63;
  line-height: 1;
  cursor: pointer;
  transition: all .15s ease;
}
.chip-btn[aria-pressed="true"]{ border-color: #1f77d3; color: #1f77d3; }

/* =========================================================
   キーワード行
========================================================= */
.book-search__form-inline{
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  align-items: center;
  background: #f4f4f4;
  height: 50px;
  border-radius: 4px;
  padding: 0 12px;
  width: 100%;
  box-sizing: border-box;
}
.book-search__inputwrap{ flex: 1; }
.book-search__inputwrap input{
  border: none;
  font-size: 16px;
  width: 100%;
  padding: 8px;
  background: transparent;
  outline: none;
  color: #333;
  caret-color: #333;
}
.book-search__inputwrap input::placeholder{ color: #9aa0a6; opacity: 1; }
.book-search__inputwrap input:focus{ -webkit-text-fill-color: #333; }
.book-search__inputwrap input:-webkit-autofill{
  -webkit-text-fill-color: #333;
  transition: background-color 5000s ease-in-out 0s;
}

.btn--search-icon{
  background: none; border: none; cursor: pointer; padding: 0; margin-right: 8px;
  display: flex; align-items: center; justify-content: center;
}
.btn--search-icon img{ width: 21px; height: 20px; display: block; }

/* 送信ボタン（共通） */
.book-search__submit{ text-align: center; }
.book-search__submit button{
  min-width: 220px;
  padding: 14px 48px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: #0072ba;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease;
}

/* =========================================================
   科目の右カラム
========================================================= */
.book-search__catcol{
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.js-category-block .js-cat-group{ margin: 0; width: 100%; }

/* セーフティ */
.book-search__form-inline{ position: relative; z-index: 1; }
.chip{ position: relative; z-index: 0; }

/* =========================================================
   879SP
========================================================= */
@media (max-width: 879px){
  .book-search{ padding: 60px 0 0; }
  .book-search .container{ padding: 0 0 60px; }

  .book-search__group{ flex-direction: column; align-items: flex-start; }
  .book-search__label{ width: auto; padding-bottom: 8px; }
  .book-search__options{ width: 100%; gap: 10px; }
  .book-search__form-inline{ width: 100%; }

  .book-search__heading-en{
    font-size: 12px; color: #0072ba; margin-bottom: 5px; text-align: center;
  }
  .book-search__heading-ja{
    font-size: 22px; font-weight: 500; margin: 0 0 40px; text-align: center;
  }
  .book-search__label{ font-size: 16px; }

  .chip span, .chip-btn{
    padding: 8px 12px; font-size: 12px; border-color: #999; border-width: 1px; color: #999; font-weight: 600;
  }
  .book-search__group{ border-top: 1px solid #999; padding: 12px 0; gap: 0; }
  .book-search__group:first-of-type{ border-top: 0; }

  .book-search__inputwrap input::placeholder{ font-size: 14px; }

  .book-search__submit .js-refine{
    display: inline-block; min-width: 184px; height: 48px; line-height: 48px;
    width: auto; font-size: 18px; font-weight: 500;
    background: #0072ba; color: #fff; border: none; border-radius: 999px;
    padding: 0; transition: none; margin: 10px 0;
  }
}

/* =========================================================
   880PC（トップ専用上書き）
========================================================= */
@media (min-width: 880px){
  body.home .book-search__heading-en{
    font-size: 20px; color: #2a7ccc; letter-spacing: .08em; margin: 0 0 6px;
  }
  body.home .book-search__heading-ja{
    font-size: 36px; font-weight: 500; margin: 0 0 2em;
  }
  body.home .book-search__label{ font-size: 24px; }

  body.home .book-search .chip span,
  body.home .book-search .chip-btn{
    border-color: #999; border-width: 1px; color: #999; font-weight: 600;
  }
  body.home .book-search .chip:has(input:checked) span,
  body.home .book-search .chip input:checked + span{
    border-color: #0072ba; color: #0072ba; border-width: 1px; font-weight: 600;
  }
  body.home .book-search .chip-btn[aria-pressed="true"]{
    border-color: #0072ba; color: #0072ba; border-width: 1px; font-weight: 600;
  }

  /* PC hover（マウス環境のみ） */
  @media (any-hover: hover) and (pointer: fine){
    body.home .book-search .chip:hover span,
    body.home .book-search .chip-btn:hover{ border-color: #0072ba; color: #0072ba; }
  }

  body.home .book-search .book-search__submit .js-refine{
    display: inline-block;
    width: 240px; height: 60px; line-height: 60px;
    background: #0072ba; color: #fff;
    border: none; border-radius: 999px;
    font-size: 24px; font-weight: 500;
    padding: 0; cursor: pointer;
    transition: width .3s ease;
    margin: 30px 0;
  }
  @media (any-hover: hover) and (pointer: fine){
    body.home .book-search .book-search__submit .js-refine:hover{ width: 280px; }
  }

  body.home .book-search .book-search__group{
    border-top: 2px solid #999;
    gap: clamp(16px, 5vw, 70px);
  }
  body.home .book-search .book-search__group:first-of-type{ border-top: 0; }
}

/* =========================================================
   検索ページ専用（/search/） — トップには影響しない
========================================================= */
/* PC */
@media (min-width: 880px){
  .search-page .book-search__heading-en{
    font-size: 20px; color: #2a7ccc; letter-spacing: .08em; margin: 0 0 6px; text-align: center;
  }
  .search-page .book-search__heading-ja{
    font-size: 36px; font-weight: 500; margin: 0 0 2em; text-align: center;
  }
  .search-page .book-search__label{ font-size: 24px; } /* ← 誤記修正（font-size） */

  .search-page .chip span,
  .search-page .chip-btn{
    border-color: #999; border-width: 1px; color: #999; font-weight: 600;
  }
  .search-page .chip:has(input:checked) span,
  .search-page .chip input:checked + span{
    border-color: #0072ba; color: #0072ba; border-width: 1px; font-weight: 600;
  }
  .search-page .chip-btn[aria-pressed="true"]{
    border-color: #0072ba; color: #0072ba; border-width: 1px; font-weight: 600;
  }

  @media (any-hover: hover) and (pointer: fine){
    .search-page .chip:hover span,
    .search-page .chip-btn:hover{ border-color: #0072ba; color: #0072ba; }
  }

  .search-page .book-search__submit .js-refine{
    display: inline-block; width: 240px; height: 60px; line-height: 60px;
    background: #0072ba; color: #fff; border: none; border-radius: 999px;
    font-size: 24px; font-weight: 500; padding: 0; cursor: pointer;
    transition: width .3s ease; margin: 30px 0;
  }
  @media (any-hover: hover) and (pointer: fine){
    .search-page .book-search__submit .js-refine:hover{ width: 280px; }
  }

  .search-page .book-search__group{
    border-top: 2px solid #999;
    gap: clamp(16px, 5vw, 70px);
  }
  .search-page .book-search__group:first-of-type{ border-top: 0; }
}

/* =========================================================
   検索ページ 左アコーディオン
========================================================= */
/* 開閉状態（共通） */
.refine-panel[hidden]{ display: none; }

/* PC：常時展開（トグルは隠す） */
@media (min-width: 880px){
  .refine-panel{ display: block !important; }
  .refine-toggle{ display: none !important; }
}

/* SP：トグルバーとパネル体裁 */
@media (max-width: 879.98px){
  /* ▼ トグルバー（検索ページ＆共通ブロックのどちらでも効くように範囲を広げる） */
  .search-page .refine-toggle,
  .book-search .refine-toggle,
  [data-refine-accordion] .refine-toggle{
    display:flex; align-items:center; justify-content:space-between;
    width:100%; padding:12px 16px; margin:0 0 8px;
    background:#F1F8FF; border:0; border-radius:0;
    color:#0072BA; font-size:16px; font-weight:600;
    cursor:pointer;
  }
  .search-page .refine-toggle:focus-visible,
  .book-search .refine-toggle:focus-visible,
  [data-refine-accordion] .refine-toggle:focus-visible{
    outline:2px solid #0072BA; outline-offset:2px;
  }
  .search-page .refine-toggle__icon,
  .book-search .refine-toggle__icon,
  [data-refine-accordion] .refine-toggle__icon{
    width:10px; height:6px; flex:0 0 10px;
    background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%230072BA' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-size:100% 100%; background-repeat:no-repeat;
    transition:transform .2s; transform:rotate(0deg);
  }
  .search-page .refine-toggle[aria-expanded="true"] .refine-toggle__icon,
  .book-search .refine-toggle[aria-expanded="true"] .refine-toggle__icon,
  [data-refine-accordion] .refine-toggle[aria-expanded="true"] .refine-toggle__icon{
    transform: rotate(180deg);
  }

  /* ▼ 展開パネル：角丸・枠は不要。内部カード枠も打消し */
  .search-page .refine-panel,
  .book-search .refine-panel,
  [data-refine-accordion] .refine-panel{
    display:block;
    background:#fff;
    border:0 !important;
    border-radius:0 !important;
    padding:0;
    margin:0;
  }
  .search-page .search-sidebar .book-search__form,
  .book-search .book-search__form{
    border:0 !important;
    border-radius:0 !important;
    padding:20px; /* SP時だけ少しだけ内側に余白 */
  }

  /* パネル内の見出しはSPでは省略 */
  .refine-panel .book-search__heading-en,
  .refine-panel .book-search__heading-ja{ display:none; }
}

/* =========================================================
   検索ページの2カラム骨格（互換）
========================================================= */
.search-page.container{
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 16px;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
}
.search-sidebar{ position: sticky; top: 16px; align-self: start; }
@media (max-width: 879px){
  .search-page.container{ grid-template-columns: 1fr; }
  .search-sidebar{ position: static; }
}

/* 結果一覧の体裁（互換用） */
.result-meta{
  display:flex; justify-content:space-between; align-items:center;
  margin: 4px 0 16px; gap: 12px;
}
.result-meta__left strong{ font-weight:700; margin-right:6px; }
.result-meta__controls label{ margin-left: 12px; white-space: nowrap; }
.result-meta__controls select{
  padding:.45rem .65rem; border:1px solid #d9e2ef; border-radius:6px; background:#fff;
}
.result-list{ list-style:none; margin:0; padding:0; display:grid; gap:24px; }

.result-card{
  background:#fff; border:1px solid #d9e2ef; border-radius:8px;
  overflow:hidden;
}
.result-card__head{ background:#0f6cbf; color:#fff; padding:14px 16px; }
.result-card__type{ margin:0 0 6px; opacity:.9; font-size:13px; }
.result-card__title{ margin:0; font-size:18px; font-weight:700; }
.result-card__title a{ color:#fff; text-decoration:none; }
.result-card__author{ margin:6px 0 0; font-size:13px; opacity:.95; }

.result-card__body{
  display:grid; grid-template-columns: 180px 1fr 200px; gap:16px;
  padding:16px;
}
@media (max-width: 879px){
  .result-card__body{ grid-template-columns: 120px 1fr; }
  .result-card__side{ grid-column: 1 / -1; display:flex; justify-content:space-between; align-items:center; gap:12px; }
}
.result-card__thumb img{
  display:block; width:100%; height:auto;
  border:1px solid #e6edf6; border-radius:4px; background:#f8fafc;
}
.result-card__summary{ margin:0 0 8px; color:#334e68; line-height:1.6; }
.result-card__defs{ display:grid; grid-template-columns: 120px 1fr; gap:6px 12px; }
.result-card__defs dt{ color:#5a6f86; }
.result-card__defs dd{ margin:0; }

.result-card__price{ font-weight:700; font-size:18px; text-align:right; margin:0 0 12px; }
.result-card__price span{ font-size:24px; }

.result-card__actions{ display:grid; gap:8px; }
.btn{
  display:inline-flex; justify-content:center; align-items:center;
  gap:8px; height:40px; padding:0 16px; border-radius:8px; border:1px solid transparent; /* ← 誤記修正 */
  font-weight:700; text-decoration:none; cursor:pointer; transition:.15s background, .15s color, .15s border-color;
}
.btn--outline{ border-color:#0f6cbf; color:#0f6cbf; background:#fff; }
.btn--outline:hover{ background:#e6f0fb; }
.btn--primary{ background:#0f6cbf; color:#fff; border-color:#0f6cbf; }
.btn--primary:hover{ background:#0c58a0; }

/* PC hover */
@media (any-hover: hover) and (pointer: fine){
  .chip:hover span{ box-shadow: 0 2px 8px rgba(30,60,90,.08); }
  .chip:active span{ transform: translateY(1px); }
  .chip-btn:hover{ box-shadow: 0 2px 8px rgba(30,60,90,.08); }
  .book-search__submit button:hover{ background: #005fa3; }
}
/* タッチ環境（hover貼り付き防止・checked優先） */
@media (hover: none), (pointer: coarse){
  .chip:hover span,
  .chip:active span,
  .chip-btn:hover,
  .chip-btn:active{
    box-shadow: none; transform: none; opacity: 1; background-color: inherit;
  }
  .chip:not(:has(input:checked)):hover span,
  .chip-btn[aria-pressed="false"]:hover{
    color: inherit; border-color: inherit;
  }
  .chip span, .chip-btn{
    transition: border-color .15s ease, color .15s ease, background-color .15s ease;
  }
}
/* iOS/タッチ：最終色の中立化 */
@media (hover: none), (pointer: coarse){
  .chip:not(:has(input:checked)) span,
  .chip input:not(:checked) + span{
    color: #999; border-color: #999; background: #fff;
  }
  .chip:has(input:checked) span,
  .chip input:checked + span{
    color: #0072ba; border-color: #0072ba; background: #fff;
  }
  .chip span, .chip-btn{ transition: none; }
}

/* === 検索ページのフィルタ（左カラム）のチップ類は必ず pointer === */
.search-page .search-sidebar .book-search__form .chip,
.search-page .search-sidebar .book-search__form .chip span,
.search-page .search-sidebar .book-search__form .chip-btn,
.search-page .search-sidebar .book-search__form .chip input{
  cursor: pointer !important;
}
/* === Pointer fix（Home 検索 & /search/ 共通 / 最終勝ち） === */
body.home .book-search .chip,
body.home .book-search .chip span,
body.home .book-search .chip input,
body.home .book-search .chip-btn,
.search-page .book-search__form .chip,
.search-page .book-search__form .chip span,
.search-page .book-search__form .chip input,
.search-page .book-search__form .chip-btn {
  cursor: pointer !important;
}

/* 結果カード内の“表示用チップ”は pointer にしない（保険） */
.search-page .result-card .chip,
.search-page .result-card .chip span {
  cursor: default !important;
}
