@charset "UTF-8";

/* =========================
  記事検索ページ専用CSS
===========================*/
@layer pages {
  :root {
    --gap: 16px;
    --sidebar: 320px;
  }

  /* フォーム */
  .field {
    margin-bottom: 12px;
  }

  .field label {
    display: block;
    font-size: .9rem;
    color: #444;
    margin-bottom: 6px;
  }

  input[type="text"],
  input[type="date"],
  select,
  textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
  }

  /* 結果カード */
  .cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    list-style: none;
    padding: 0;
    margin: 0;
  }

  .card {
    border: 1px solid #eee;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    display: flex;
    flex-direction: column;
  }

  .card a.card-link {
    display: block;
    text-decoration: none;
    color: inherit;
  }

  /* タグの並び（本文下、リンクの外） */
  .card>.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 12px 12px;
    /* カード内の既存余白に合わせる */
    padding: 0;
    list-style: none;
  }

  .card>.tags li {
    background: #f3f3f3;
    color: #555;
    border-radius: 9999px;
    padding: 2px 8px;
    font-size: .8rem;
    line-height: 1.4;
    white-space: nowrap;
  }
}

.thumb {
  width: 100%;
  aspect-ratio: 3/2;
  background: #f3f3f3;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb.is-yt {
  background: #000;
}

/* 余白の色（好みで #f3f3f3 等に変更可） */
.thumb.is-yt img {
  object-fit: contain;
}

/* 16:9 を枠内に収める（上下に余白） */
.meta {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.title {
  font-size: 1rem;
  margin: 0;
  line-height: 1.35;
}

.sub {
  font-size: .85rem;
  color: #666;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.summary {
  font-size: .9rem;
  color: #333;
  margin: 0;
  text-align: left;
}

/* ページネーション */
.pager {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}

.pager a,
.pager span {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: .9rem;
  text-decoration: none;
  color: #333;
  background: #fff;
}

.pager .active {
  background: #333;
  color: #fff;
  border-color: #333;
}

.pager .disabled {
  opacity: .5;
  pointer-events: none;
}

/* ステータス */
.count {
  font-size: .9rem;
  color: #555;
  margin: 0 0 12px;
}

.options {
  display: flex;
  gap: 0px;
  align-items: center;
}

.btn-search {
  display: inline-block;
  padding: 8px 12px 6px 12px;
  margin-right: 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  text-decoration: none;
}

.btn-clear {
  display: inline-block;
  padding: 4px 12px 7px 12px;
  margin-top: 8px;
  margin-right: 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  text-decoration: none;
}

.btn-wrap {
  display: inline-block;
  gap: 20px;
  margin-top: 12px;
  text-align: center;
  max-width: 720px;
  /*  margin: 0 auto; */
}

/* メタ行（左：日付・投稿者、右：種別バッジ） */
.meta-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .25rem;
}

.meta-left {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.meta-right {
  margin-left: auto;
}

/* バッジ */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
  border: 1px solid transparent;
}

/* 種別ごとの色（必要に応じて調整） */
.badge--yamareco {
  background: #eef9f0;
  border-color: #c8e9d0;
  color: #2f7d46;
}

.badge--sanko {
  background: #ffffdd;
  border-color: #eeee77;
  color: #8d8548;
}

.badge--youtube {
  background: #ffeeee;
  border-color: #ffd6d6;
  color: #b3261e;
}

.badge--blog {
  background: #f0f7ff;
  border-color: #cfe2ff;
  color: #0b5ed7;
}

.badge--smaho {
  background: #fff0ff;
  border-color: #dd7ed4;
  color: #ed5be7;
}

.badge--other {
  background: #f6f6f6;
  border-color: #e5e5e5;
  color: #555;
}

main#search {
  padding-top: calc(var(--header-h) + var(--crumb-height));
}

.search-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  /* 見た目上：左=結果 / 右=条件 */
  grid-template-areas: "results filters";
  gap: 24px;
  align-items: start;
  margin: 16px auto 40px;
  max-width: var(--container-max);
}

.results {
  grid-area: results;
}

.filters {
  grid-area: filters;
  position: sticky;
  top: calc(var(--header-h) + 12px);
}

.results .result-meta {
  margin: 8px 0 12px;
  color: #555;
}

.result-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.pager .btn {
  background: #eee;
}

.pager .page-info {
  color: #555;
}

.filters .card {
  text-align: left;
}

.filters .field {
  margin: 10px 0;
}

.filters .field.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.filters .actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.filters .tips {
  margin-top: 10px;
}

/* スマホは縦積み（結果→条件の順で自然） */
@media (max-width: 800px) {
  .search-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "results"
      "filters";
  }

  .result-list {
    grid-template-columns: 1fr;
  }

  .filters {
    position: static;
  }
}

.tags-list {
  width: 100%;
  font-family: monospace;
  white-space: pre;
  font-size: 0.9rem;

  /* ←ここが重要 */
  max-height: 40vh;
  /* スマホで画面の4割までの高さに制限 */
  overflow: auto;
  /* 内部スクロールを有効にする */
  -webkit-overflow-scrolling: touch;
  /* iOSで慣性スクロール */
  overscroll-behavior: contain;
  /* スクロールを親に伝播させない（連鎖防止） */

  padding: .5rem;
  border: 1px solid #ddd;
  border-radius: 6px;
}

/* WebKit系のスクロールバー太さ（可能な端末のみ反映） */
.tags-list::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.tags-list::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 6px;
}

.tags-list::-webkit-scrollbar-track {
  background: #f0f0f0;
}

details {
  background: #eee;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px 10px;
  margin-bottom: 10px;
}

summary {
  cursor: pointer;
  font-weight: 700;
}

.type-filter {
  margin: 0 0 10px;
  border: 0;
  padding: 0;
}

.type-filter>legend {
  display: block;
  font-size: .9rem;
  color: #444;
  margin-bottom: 6px;
}

.type-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0;
}

/* === 種別ピル：OFF=灰色 ／ ON=カラー（最小差分上書き） === */

/* OFF の共通見た目（灰色） */
.type-pill input {
  display: none;
}

.type-pill {
  background: #fff;
  border: 1px solid #ccc;
  color: #666;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 8px;
  cursor: pointer;
  user-select: none;
  transition: all .15s ease;
  font-size: 12px;
  margin-top: 8px;
}

/* ON時の共通強調 */
.type-pill:has(input:checked) {
  font-weight: 600;
  border-width: 1px;
  transform: scale(1.02);
}

/* 種別ごとのONカラー（チェック時のみ発火） */
.type-pill--sanko:has(input:checked) {
  background: #ffffdd;
  border-color: #e6e65c;
  color: #665c00;
}

.type-pill--yamareco:has(input:checked) {
  background: #eef9f0;
  border-color: #9ed9ad;
  color: #2f7d46;
}

.type-pill--youtube:has(input:checked) {
  background: #ffeeee;
  border-color: #ffb0b0;
  color: #b3261e;
}

.type-pill--blog:has(input:checked) {
  background: #f0f7ff;
  border-color: #b2d0ff;
  color: #0b5ed7;
}

.type-pill--smaho:has(input:checked) {
  background: #fff0ff;
  border-color: #e19ee8;
  color: #c318c1;
}

/* 任意：ONのときだけ✓を出す */
.type-pill:has(input:checked)::after {
  content: "";
  font-size: .4em;
  margin-left: 2px;
  display: none;
}

.type-filter-row--5cols {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  /* 余白はここで一元管理 */
  width: 100%;
}

/* ピルをセンター寄せ・等幅化 */
.type-filter-row--5cols .type-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  /* 横パディングを詰める */
  white-space: nowrap;
  /* 折り返さない */
  overflow: hidden;
  text-overflow: ellipsis;
}

.type-filter-row--5cols .type-pill span {
  display: block;
  max-width: 100%;
  line-height: 1;
}

/* スマホ時はフォント縮小＆ギャップ微調整 */
@media (max-width: 600px) {
  .type-filter-row--5cols {
    gap: 8px;
  }

  .type-filter-row--5cols .type-pill {
    font-size: .85rem;
    padding: 8px 2px;
  }
}


@layer pages {

  /* ヘッダ＋パンくずの被り対策（既存トークンに合わせて調整可） */
  main#search {
    padding-top: calc(var(--header-h, 64px) + var(--crumb-height, 40px));
  }

  /* 2カラム：左＝結果 / 右＝条件（固定） */
  main#search .search-layout {
    display: grid;
    gap: 24px;
    align-items: start;
  }

  main#search .results {
    grid-area: results;
    min-width: 0;
  }

  main#search .filters {
    grid-area: filters;
    position: sticky;
    top: calc(var(--header-h, 64px) + 12px);
  }

  /* 結果リスト（カード2列 → SPで1列） */
  main#search .result-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  main#search .results .result-meta {
    margin: 8px 0 12px;
    color: #555;
  }

  main#search .pager {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 16px;
  }

  main#search .pager .btn {
    background: #eee;
  }

  main#search .pager .page-info {
    color: #555;
  }

  /* フィルタフォーム */
  main#search .filters .card {
    text-align: left;
  }

  main#search .filters .field {
    margin: 10px 0;
  }

  main#search .filters .field.two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  main#search .filters .actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
  }

  main#search .filters .tips {
    margin-top: 10px;
  }

  /* スマホ：縦積み（結果→条件） */
  @media (max-width: 800px) {
    main#search .search-layout {
      grid-template-columns: 1fr;
      grid-template-areas:
        "results"
        "filters";
    }

    main#search .result-list {
      grid-template-columns: 1fr;
    }

    main#search .filters {
      position: static;
    }
  }

  @media (min-width: 1024px) {
    main#search .search-layout {
      grid-template-columns: 1fr 320px;
      grid-template-areas: "results filters";
    }

  }

  /* 検索画面のタグ（アンカー/ボタン）を反転表示する */
  #search .tag-facets a {
    color: #555;
    border: 1px solid #555;
    padding: .4em .65em;
    border-radius: 999px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: .4em;
    font-size: .85rem;
    line-height: 1.2;
  }

  #search .tag-facets a,
  #search .tag-facets button {
    transition: color .15s ease, background-color .15s ease, border-color .15s ease;
  }

  #search .tag-facets a:hover,
  #search .tag-facets a:focus-visible,
  #search .tag-facets button:hover,
  #search .tag-facets button:focus-visible {
    background-color: #888;
    color: #fff;
    /*    border-color: #0b5ed7; */
  }

}

/* スマホ：検索条件が下にあることを気づかせる */
.mobile-filter-hint {
  display: none;
}

@media (max-width: 768px) {
  .mobile-filter-hint {
    display: block;
    position: sticky;
    top: 8px;
    z-index: 20;
    margin: -8px 0 12px;
  }

  .mobile-filter-hint__btn {
    display: block;
    text-align: center;
    padding: .55rem .75rem;
    border: 1px solid #e6e6e6;
    border-radius: 999px;
    background: rgba(255, 255, 255, .95);
    text-decoration: none;
    font-size: .90rem;
    line-height: 1.2;
  }
}