/**
 * 検索ボックスの開閉（Figma 詳細検索 7022:90633 / 119992 / 120002）
 * ヘッダー＝「🔍 条件で絞り込む ＋/−」。デフォルト閉→トグルで本文(height)アニメ展開。
 * 箱の地色/枠/角丸/余白は各検索ボックス側で持つ（bg #F5F2F0・白枠4・角丸PC32/SP24）。
 */

/* ---- 開閉する本文：デフォルト閉（height:0） ---- */
[data-search-collapse-body] {
    overflow: hidden;
    height: 0;
    transition: height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: height;
}

/* 開閉ラッパ内の縦間隔：ラッパ導入で親 flex の gap が本文内の兄弟（rows→actions 等）に
   届かなくなり、最後の罫線とボタン行が密着していた（先方指摘「線ギリギリ」）。
   Figma 実測: PC(7022:90633)=gap32 / SP(7022:120002)=rows末尾707→actions y723=16 */
[data-search-collapse-body] > * + * {
    margin-top: 32rem;
}

/* products は自前の .page-products-index .products-search__actions { margin-top } が
   後読みタイで勝つため、特異度 0,3,0 で明示上書き */
[data-search-collapse] [data-search-collapse-body] > .products-search__actions {
    margin-top: 32rem;
}

@media (max-width: 767.98px) {
    [data-search-collapse-body] > * + *,
    [data-search-collapse] [data-search-collapse-body] > .products-search__actions {
        margin-top: 16rem;
    }
}

/* ヘッダー（バー＋罫線を1グループに） */
.search-collapse-header {
    display: block;
    width: 100%;
}

/* ---- 箱の縦余白（Figma(3) 7084:263341/263848/262056/262432）----
   閉: PC h88=py26 / SP h70=py18（白枠4remはFigmaストローク非消費→CSS 22/14rem）。
   各検索ボックスのpaddingはページ側CSSが持つため、属性2連で特異度を上げて縦だけ上書き。 */
[data-search-collapse][data-search-collapse] .products-search__view,
[data-search-collapse][data-search-collapse] .works-search__panel {
    /* 閉時の上下 padding は 24（先方コメント: Figma の 26 は border2+24 の意） */
    padding-top: 24rem;
    padding-bottom: 24rem;
    /* PC(7084:263848): px48（白枠4は非消費→CSS44）・角丸はアコーディオン準拠16 */
    padding-left: 44rem;
    padding-right: 44rem;
    border-radius: 16rem;
}

@media (max-width: 767.98px) {
    [data-search-collapse][data-search-collapse] .products-search__view,
    [data-search-collapse][data-search-collapse] .works-search__panel {
        /* SP: 18 = border2+16 の意 → 16 */
        padding-top: 16rem;
        padding-bottom: 16rem;
        /* SP(7084:262432): px24（白枠4非消費→CSS20）・角丸16 */
        padding-left: 20rem;
        padding-right: 20rem;
        border-radius: 16rem;
    }
}

/* 開いた時の下paddingは PC32 / SP24（先方コメント: Figma の 34/26 は border 込みの意）。
   箱の padding-bottom(24/16) + 本文末尾 margin 8 = 32/24。body 内 margin なので閉時は隠れ、開閉アニメに追従 */
[data-search-collapse-body] > :last-child {
    margin-bottom: 8rem;
}

/* ---- 検索ボックス内のアクションボタンを Figma ボタン仕様に合わせる ----
   PC(2220:28279): リセット=hug(h56/pl32/pr20/gap16) / 検索=w180(h56/pl40/pr20)。
   SP(7022:120074): リセット h52/pl24/pr20/gap8/文字14 / 検索 h52。ペアは中央・gap PC24/SP16。
   c-button は全サイト共有のため、検索ボックス配下にスコープして上書きする。 */
[data-search-collapse] .c-button--search,
[data-search-collapse] .products-search__submit {
    min-width: 0;
    width: 180rem;
    box-sizing: border-box;
}

@media (max-width: 767.98px) {
    [data-search-collapse] .c-button--search,
    [data-search-collapse] .c-button--close,
    [data-search-collapse] .products-search__submit,
    [data-search-collapse] .products-search__reset {
        height: 52rem;
    }

    /* SP のボタン行は行全幅を リセット:検索 = 125:170 の比率で分け合う
       （Figma 7022:120074 実測: 行310 = リセット125 + gap16 + 検索170）。
       検索だけ flex:1 にするとリセットが取り残されて比率が崩れる（先方NG）。
       flex-basis:0 + grow比率で、どの幅でも両ボタンが Figma と同じ割合で伸びる。 */
    [data-search-collapse] .c-button--close,
    [data-search-collapse] .products-search__reset {
        gap: 8rem;
        padding-left: 24rem;
        flex: 125 0 0;
        min-width: 0;
    }

    [data-search-collapse] .c-button--search,
    [data-search-collapse] .products-search__submit {
        flex: 170 0 0;
        width: auto;
        min-width: 0;
    }

    /* SP のチップ寸法を Figma に合わせる（radio_btn h36 pl10/pr14 / CheckBox_list h38 pl12/pr14）。
       文字は Figma 実測から約12.7px（パーツ製品=チップ幅113・生活雑貨=101 が 13px 相当で一致）＝13rem。
       現状 14rem/px16/h44 と大きく、区分ラジオ2個（パーツ製品+オリジナルグッズ製作）が
       1行に収まらず縦落ちしていた（7022:120002 は 2個ずつ横並び） */
    /* チップの白枠2rem も Figma ストローク非消費のため padding から差し引く（-2rem/辺） */
    [data-search-collapse] .c-field__radio {
        height: 36rem;
        padding: 0 12rem 0 8rem;
    }

    [data-search-collapse] .c-field__check {
        min-height: 0;
        height: 38rem;
        padding: 0 12rem 0 10rem;
    }

    [data-search-collapse] .c-field__check-text {
        /* Figma(3) 7084:262432: チップ文字 12px / 字間 0.72（radio_btn=113/177 幅と一致） */
        font-size: 12rem;
        letter-spacing: 0.72rem;
    }

}

/* ---- 開閉バー（クリック領域＝ヘッダー行） ---- */
.search-collapse-bar {
    display: flex;
    align-items: center;
    gap: 12rem;
    width: 100%;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    cursor: pointer;
    font: inherit;
    color: inherit;
    text-align: left;
    -webkit-appearance: none;
    appearance: none;
}

.search-collapse-bar__main {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10rem;
    flex: 1 1 auto;
    min-width: 0;
}

.search-collapse-bar__icon {
    flex: 0 0 auto;
    width: 24rem;
    height: 24rem;
    background-color: var(--color-key);
    -webkit-mask: url("/img/common/icons/search.svg") center / contain no-repeat;
    mask: url("/img/common/icons/search.svg") center / contain no-repeat;
}

.search-collapse-bar__text {
    font-family: "Noto Sans JP", Helvetica, sans-serif;
    font-weight: 700;
    font-size: 24rem;
    letter-spacing: 0.96rem;
    line-height: 1.5;
    color: var(--color-neutral-01);
    white-space: nowrap;
}

/* ＋/−（閉=＋ / 開=−）。キーカラーの2本の棒、開いたら縦棒を消す */
.search-collapse-bar__toggle {
    position: relative;
    flex: 0 0 auto;
    width: 18rem;
    height: 18rem;
}

.search-collapse-bar__toggle::before,
.search-collapse-bar__toggle::after {
    content: "";
    position: absolute;
    background-color: var(--color-key);
    border-radius: 2rem;
}

.search-collapse-bar__toggle::before {
    left: 0;
    right: 0;
    top: 50%;
    height: 2rem;
    transform: translateY(-50%);
}

.search-collapse-bar__toggle::after {
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2rem;
    transform: translateX(-50%);
    transition: opacity 0.2s ease;
}

[data-search-collapse].is-open .search-collapse-bar__toggle::after {
    opacity: 0;
}

/* ヘッダー下の罫線：閉じた時は非表示・開いた時のみ表示（Figma(3) 閉=line hidden / 開=全幅1px） */
.search-collapse-bar__line {
    display: none;
    width: 100%;
    height: 1px;
    margin-top: 8rem;
    background-color: rgba(217, 217, 217, 0.88);
}

[data-search-collapse].is-open .search-collapse-bar__line {
    display: block;
}

/* ---- SP：アイコン+テキストは左寄せ（Figma 7022:119992 icon x0/text x30）、
   トグルは右端に固定 ---- */
@media (max-width: 767.98px) {
    .search-collapse-bar {
        position: relative;
        min-height: 34rem; /* Figma 7084:262056 バー枠34 */
    }

    .search-collapse-bar__icon {
        width: 20rem;
        height: 20rem;
    }

    .search-collapse-bar__text {
        font-size: 20rem;
        letter-spacing: 0.8rem;
    }

    .search-collapse-bar__toggle {
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
    }

    /* 開いた時の下線位置（Figma 7084:262432: バー44→線44 = 密着気味） */
    .search-collapse-bar__line {
        margin-top: 4rem;
    }
}

/* ── 翻訳版（GTranslate: html の lang が ja 以外）───────────────
   「Search for products」等の英文ラベルが JA 前提の固定幅/比率からはみ出すため、
   翻訳時のみボタンを内容幅（hug）＋折返し可にする */
html:not([lang="ja"]) [data-search-collapse] .works-search__actions,
html.translated-ltr [data-search-collapse] .works-search__actions,
html.translated-rtl [data-search-collapse] .works-search__actions,
html:not([lang="ja"]) [data-search-collapse] .products-search__actions,
html.translated-ltr [data-search-collapse] .products-search__actions,
html.translated-rtl [data-search-collapse] .products-search__actions {
    flex-wrap: wrap;
}

html:not([lang="ja"]) [data-search-collapse] .c-button--search,
html.translated-ltr [data-search-collapse] .c-button--search,
html.translated-rtl [data-search-collapse] .c-button--search,
html:not([lang="ja"]) [data-search-collapse] .products-search__submit,
html.translated-ltr [data-search-collapse] .products-search__submit,
html.translated-rtl [data-search-collapse] .products-search__submit,
html:not([lang="ja"]) [data-search-collapse] .c-button--close,
html.translated-ltr [data-search-collapse] .c-button--close,
html.translated-rtl [data-search-collapse] .c-button--close,
html:not([lang="ja"]) [data-search-collapse] .products-search__reset,
html.translated-ltr [data-search-collapse] .products-search__reset,
html.translated-rtl [data-search-collapse] .products-search__reset {
    flex: 0 1 auto;
    width: auto;
    min-width: 0;
}

/* 指摘対応(No.346): 閉じているときはカード全面（padding 24/44 含む）を
   クリック可能にする。バー(button)の擬似要素でヒットエリアを箱いっぱいへ拡張。
   開いている間は中の検索フォーム操作を妨げないためバー本体のみに戻す */
.search-collapse-bar {
  position: relative;
}
[data-search-collapse]:not(.is-open) .search-collapse-bar::after {
  content: "";
  position: absolute;
  top: -24rem;
  bottom: -24rem;
  left: -44rem;
  right: -44rem;
}
@media (max-width: 767.98px) {
  [data-search-collapse]:not(.is-open) .search-collapse-bar::after {
    top: -16rem;
    bottom: -16rem;
    left: -20rem;
    right: -20rem;
  }
}
