/* P02 作品一覧（群 A）。見せ場は壁そのもの。道具の行はスクロールしても上に残る。 */
@layer page {
  /* ① 見出し（上 89） */
  .ghead { padding-top: var(--es-space-89); }
  .ghead__row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; column-gap: var(--es-space-34); row-gap: var(--es-space-21); }
  .ghead__t { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: var(--es-space-34); row-gap: var(--es-space-8); min-width: 0; }
  .ghead__h { font-size: var(--es-text-55); line-height: var(--es-lh-55); }
  .ghead__lead { font-size: var(--es-text-21); line-height: var(--es-lh-21); color: var(--es-text); }

  /* ② 道具の行：上に残る（高さ 68・墨・下に燻の 1px） */
  .tools { position: sticky; top: var(--hh); z-index: 40; margin-top: var(--es-space-34); background: var(--es-bg); border-bottom: var(--es-line-1) solid var(--es-rule); }
  .tools__in { display: flex; align-items: center; column-gap: var(--es-space-21); min-height: 68px; }
  /* 入力欄：1597 から 3 列。それより狭い 8 列の幅では 2 列（選択肢が入りきるように） */
  .tools__q { position: relative; flex: 0 0 calc((100% - 7 * var(--es-gutter)) / 8 * 2 + var(--es-gutter)); min-width: 0; }
  @media (min-width: 1597px) { .tools__q { flex-basis: calc((100% - 7 * var(--es-gutter)) / 8 * 3 + 2 * var(--es-gutter)); } }
  .tools__q > .ico { position: absolute; left: var(--es-space-13); top: 50%; transform: translateY(-50%); color: var(--es-text-sub); pointer-events: none; }
  .tools__input { width: 100%; height: 44px; padding: 0 var(--es-space-13) 0 calc(var(--es-space-13) + 20px + var(--es-space-8)); border-radius: var(--es-radius-m); border: var(--es-line-1) solid var(--es-border); background: var(--es-surface); color: var(--es-text-strong); font-size: var(--es-text-16); line-height: var(--es-lh-16); }
  .tools__input::placeholder { color: var(--es-text-sub); opacity: 1; }
  .tools__input::-webkit-search-cancel-button { display: none; }
  .tools__input:focus-visible { outline: var(--es-line-2) solid var(--es-focus); outline-offset: 0; border-color: transparent; }
  /* 選択肢：入りきらない言語・幅では横にスクロール（右端の選択肢が切れて、続きがあると分かる） */
  .tools__chips { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: var(--es-space-8); overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; padding: var(--es-space-5); margin: 0 calc(-1 * var(--es-space-5)); }
  .tools__chips::-webkit-scrollbar { display: none; }
  .tools__grp { display: flex; gap: var(--es-space-8); flex: 0 0 auto; padding-left: var(--es-space-13); }
  .chip--menu { gap: var(--es-space-5); padding-right: var(--es-space-8); }
  .chip--menu[aria-expanded="true"] { color: var(--es-text-strong); box-shadow: inset 0 0 0 var(--es-line-1) var(--es-text-strong); }
  .chip--menu.is-on, .chip--menu.is-on[aria-expanded="true"] { box-shadow: inset 0 0 0 var(--es-line-2) var(--es-accent); color: var(--es-text-strong); }
  .tools__clear { flex: 0 0 auto; padding: 0 var(--es-space-8); white-space: nowrap; font-size: var(--es-text-16); }
  .tools__end { flex: 0 0 auto; display: flex; align-items: center; gap: var(--es-space-13); }
  .tools__sort { position: relative; }
  .sortbtn { display: inline-flex; align-items: center; gap: var(--es-space-8); min-height: 44px; padding: 0 var(--es-space-8); color: var(--es-text-strong); font-size: var(--es-text-16); white-space: nowrap; border-radius: var(--es-radius-full); }
  .tools__view, .sheet__vbtns { display: flex; }
  .vbtn { border-radius: 0; color: var(--es-text-sub); }
  .vbtn[aria-pressed="true"] { color: var(--es-text-strong); box-shadow: inset 0 calc(-1 * var(--es-line-2)) 0 var(--es-accent); }
  @media (hover: hover) and (pointer: fine) {
    .sortbtn:hover .sortbtn__t { text-decoration: underline; text-underline-offset: 0.25em; }
    .vbtn:hover { color: var(--es-text-strong); }
    .sopt:hover { background: color-mix(in srgb, var(--es-text-strong) 10%, transparent); }
  }

  /* 並び（と、狭い幅では表示）：広い幅は、ボタンの下の小さな一覧。609 までは、下から開く面 */
  .sheet { position: absolute; right: 0; top: calc(100% + var(--es-space-8)); z-index: 60; width: 233px; padding: var(--es-space-8); background: var(--es-surface); border: var(--es-line-1) solid var(--es-border); border-radius: var(--es-radius-l); }
  .sheet__top, .sheet__view, .sheet__k { display: none; }
  .sopt { display: flex; align-items: center; gap: var(--es-space-8); width: 100%; min-height: 44px; padding: 0 var(--es-space-13); border-radius: var(--es-radius-m); font-size: var(--es-text-16); text-align: left; color: var(--es-text-strong); }
  .sopt .ico { visibility: hidden; color: var(--es-accent); }
  .sopt[aria-pressed="true"] { font-weight: var(--es-fw-bold); }
  .sopt[aria-pressed="true"] .ico { visibility: visible; }

  /* ジャンルの面：道具の行のすぐ下、幅いっぱい */
  .gpanel { border-top: var(--es-line-1) solid var(--es-rule); background: var(--es-bg); }
  .gpanel__in { display: flex; flex-wrap: wrap; gap: var(--es-space-13) var(--es-space-8); padding-top: var(--es-space-21); padding-bottom: var(--es-space-21); max-height: 50vh; overflow-y: auto; }

  /* ③ 結果（道具の行の下 34） */
  .gres { padding-top: var(--es-space-34); padding-bottom: var(--es-space-89); }
  html:not(.js) .gres { padding-top: var(--es-space-55); }
  .glist { border-top: var(--es-line-1) solid var(--es-rule); }
  .glist > li { border-bottom: var(--es-line-1) solid var(--es-rule); }
  .glist .rcard { min-height: 165px; padding: var(--es-space-13) 0; }
  .gempty { padding-top: var(--es-space-55); padding-bottom: var(--es-space-55); }
  .gempty__t { font-size: var(--es-text-26); line-height: var(--es-lh-26); font-weight: var(--es-fw-bold); color: var(--es-text-strong); }
  .gempty__s { margin-top: var(--es-space-8); color: var(--es-text); }
  .gempty__act { margin-top: var(--es-space-21); display: flex; flex-wrap: wrap; gap: var(--es-space-13); }

  /* ---- 1280 から：選択肢が 1 行に入らない言語は、横に送らず 2 段に折る（並びの手前で切らない。G-C R2 の 9）。
     987〜1279 は 986 までと同じ形（入力欄を 1 行まるごと・選択肢は横に送る。右端の半分見せは core.js の peekRows） ---- */
  @media (min-width: 987px) and (max-width: 1279px) {
    .tools__in { flex-wrap: wrap; row-gap: 0; column-gap: var(--es-space-8); padding-top: var(--es-space-8); padding-bottom: var(--es-space-5); min-height: 0; }
    .tools__q { flex: 1 0 100%; }
    .tools__chips { flex: 1 1 0; }
  }
  @media (min-width: 1280px) {
    .tools__chips { flex-wrap: wrap; overflow-x: visible; row-gap: var(--es-space-8); }
    .tools__in { padding-top: var(--es-space-8); padding-bottom: var(--es-space-8); }
  }

  /* ---- 986 まで：入力欄は 1 行まるごと。選択肢と並びは 2 行目 ---- */
  @media (max-width: 986px) {
    .tools__in { flex-wrap: wrap; row-gap: 0; column-gap: var(--es-space-8); padding-top: var(--es-space-8); padding-bottom: var(--es-space-5); min-height: 0; }
    .tools__q { flex: 1 0 100%; }
    .tools__chips { flex: 1 1 0; }
  }
  @media (max-width: 609px) {
    .ghead { padding-top: var(--es-space-55); }
    .ghead__h { font-size: var(--es-text-42); line-height: var(--es-lh-42); }
    .ghead__lead { font-size: var(--es-text-16); line-height: var(--es-lh-16); }
    .ghead__random { width: 100%; }
    .tools__view, .sortbtn__t { display: none; }
    .sortbtn { width: 44px; justify-content: center; padding: 0; }
    .tools__end { gap: 0; margin-right: calc(-1 * var(--es-space-8)); }
    /* 下から開く面（並びと表示） */
    .sheet { position: fixed; left: 0; right: 0; top: auto; bottom: 0; width: auto; z-index: 90; border-radius: var(--es-radius-l) var(--es-radius-l) 0 0; border-width: var(--es-line-1) 0 0; padding: var(--es-space-8) max(var(--es-margin), env(safe-area-inset-right)) calc(var(--es-space-21) + env(safe-area-inset-bottom)) max(var(--es-margin), env(safe-area-inset-left)); }
    .sheet__top { display: flex; align-items: center; justify-content: space-between; margin-right: -12px; }
    .sheet__h { font-size: var(--es-text-16); line-height: var(--es-lh-16); font-weight: var(--es-fw-bold); color: var(--es-text-strong); }
    .sheet__k { display: block; margin-top: var(--es-space-13); font-size: var(--es-text-13); line-height: var(--es-lh-13); color: var(--es-text-sub); }
    .sheet__view { display: block; }
    .sopt { padding: 0; }
    .sheet__vbtns { gap: var(--es-space-8); }
    /* 一覧：絵（幅いっぱい・16:9）の下に字 */
    .glist .rcard { grid-template-columns: minmax(0, 1fr); row-gap: var(--es-space-13); min-height: 0; padding: var(--es-space-21) 0; }
    .glist .rcard__img { width: 100%; }
    .glist .rcard__play { grid-column: 1; }
    .gempty__act .btn { width: 100%; }
  }
}
