/* brandx 検索UI（スマホの検索バー＋せり上がりパネル）
   2026-08-18・BAN承認

   考え方
   - PCは今までどおり。GENSENの4段の検索をそのまま出す。検索バーは出さない。
   - スマホ・タブレット（1024px以下）は、GENSENの4段を隠して1段の検索バーに置き換える。
     黒帯そのものは残す（PCと揃えるため）。
   - パネルは本文の外側に置いた重ね型。背後のページは動かない。
   - 位置や高さを決める値に transition を使わない。動きは .bxs-motion の中だけに書く
     （描画が止まった環境で、動きの指定が途中の値を残して位置が狂うのを防ぐ）。
*/

/* ---------- 検索バー ---------- */
.bxs-bar { display: none; }

@media screen and (max-width: 1024px) {
	/* GENSENはトップ以外のページでスマホの検索を丸ごと隠している。
	   1段のバーに置き換えるので、ここでは出す。 */
	body.bxs-on #header_search,
	body.bxs-on #index_header_search { display: block; }

	/* GENSENはスマホで黒帯を「本文の上にかぶさる垂れ幕」（絶対配置）にしている。
	   常に出しておくバーにするので、流れの中に戻して場所を取らせる。
	   #header の高さも決め打ちのままだと黒帯がはみ出して本文と重なる（2026-08-19 BAN指摘）。 */
	body.bxs-on #header_search { position: static; }
	body.bxs-on #header { height: auto; }

	/* GENSENの4段は隠す。黒帯そのものは残す */
	body.bxs-on #index_header_search .inner > form,
	body.bxs-on #header_search .inner > form { display: none; }

	/* 黒帯そのものは残すが、4段ぶんの余白（上下25px）は1段には広すぎる。
	   ここを詰めた分だけ商品カードが上に来る。 */
	body.bxs-on #index_header_search,
	body.bxs-on #header_search { padding-top: 10px; padding-bottom: 10px; }

	body.bxs-on #index_header_search .inner,
	body.bxs-on #header_search .inner { padding: 0 12px; }

	.bxs-bar {
		display: flex;
		align-items: center;
		gap: 8px;
		width: 100%;
		margin: 0;
		padding: 11px 13px;
		border-radius: 8px;
		font-family: inherit;
		font-size: 13px;
		line-height: 1.4;
		color: var(--bx-ink, #31494a);
		text-align: left;
		cursor: pointer;
		-webkit-appearance: none;
		appearance: none;
	}
	/* 入力欄の枠の強さ（brandx > 設定で切替） */
	.bxs-bar.bxs-frame-line      { background: transparent; border: 1px solid rgba(255,255,255,.55); color: #fff; }
	.bxs-bar.bxs-frame-fill-line { background: #fff; border: 1px solid var(--bx-hairline, #e6dfd2); }
	.bxs-bar.bxs-frame-fill      { background: #fff; border: 1px solid transparent; }

	.bxs-bar .bxs-ico { flex: 0 0 auto; display: flex; color: var(--bx-accent-text, #8a6a24); }
	.bxs-bar.bxs-frame-line .bxs-ico { color: #fff; }
	.bxs-bar .bxs-txt {
		flex: 1 1 auto; min-width: 0;
		overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
	}
	.bxs-bar .bxs-cnt {
		flex: 0 0 auto; font-size: 12px; font-weight: bold; white-space: nowrap;
		color: var(--bx-accent-text, #8a6a24);
	}
	.bxs-bar.bxs-frame-line .bxs-cnt { color: #fff; }
	.bxs-bar .bxs-caret { flex: 0 0 auto; font-size: 10px; color: var(--bx-muted, #9a9080); }
	.bxs-bar.bxs-frame-line .bxs-caret { color: rgba(255,255,255,.8); }
}

/* ---------- 追従 ----------
   PC: ロゴ行も検索も出したまま固定する。
   スマホ: 検索バーだけ残し、ロゴ行は下スクロールで隠れ、上スクロールで戻る。

   【この構造の要点】黒帯の位置がページで違う。
   - トップ: 黒帯は #header の外（#main_contents の先頭）→ bxs-band-out
   - それ以外: 黒帯は #header の中 → bxs-band-in
   外にあるときだけ黒帯を別に固定し、ロゴ行を隠すときに黒帯の top を 0 へ下げる。
   中にあるときは #header ごと動くので、黒帯側は何もしない。
   どちらの型かは JS が実際のDOMを見て body に付ける。 */
/* 重なり順は子テーマの層の変数を使う（子テーマの先頭に一覧がある）。
   ヘッダーは黒帯より1つ上。同じ値にすると、後ろに書かれた黒帯が前に出て、
   ヘッダーの吹き出し（会員登録の案内）が隠れる（2026-08-19に実測して確認）。 */
/* 管理バー（運営がログイン中に出る画面上部の黒い帯）の高さ。
   会員・業者には管理バーを出さないので 0 のまま。運営のときだけ下へずらす。
   本体の決まり: 783px以上=32px固定 / 601〜782px=46px固定 / 600px以下は画面に固定されず
   一緒にスクロールして消えるため 0（2026-08-21 に本体CSSを確認）。 */
body { --bxs-abar: 0px; }
body.admin-bar { --bxs-abar: 32px; }
@media screen and (max-width: 782px) {
	body.admin-bar { --bxs-abar: 46px; }
}
@media screen and (max-width: 600px) {
	body.admin-bar { --bxs-abar: 0px; }
}

body.bxs-on #header {
	position: -webkit-sticky;
	position: sticky;
	top: var(--bxs-abar, 0px);
	z-index: var(--bxz-sticky-header, 801);
	transform: none;
}
body.bxs-on.bxs-band-out #index_header_search,
body.bxs-on.bxs-band-out #header_search {
	position: -webkit-sticky;
	position: sticky;
	top: calc(var(--bxs-headtop, 62px) + var(--bxs-abar, 0px));
	z-index: var(--bxz-sticky-band, 800);
}

@media screen and (max-width: 1024px) {
	/* :not(.active) は必須。GENSENはメニューを開くと #header に .active を付ける。
	   transform の付いた要素の中では position:fixed が画面基準でなくなるため、
	   メニューが開いている間はずらさない（開いたメニューが飛ぶ事故を防ぐ）。 */
	body.bxs-on.bxs-headhide #header:not(.active) {
		transform: translateY(calc(var(--bxs-headtop, 62px) * -1));
	}
	body.bxs-on.bxs-band-out.bxs-headhide #index_header_search,
	body.bxs-on.bxs-band-out.bxs-headhide #header_search { top: var(--bxs-abar, 0px); }
}

/* PCで固定するのは検索バーだけ。ロゴ行は流れていく（2026-08-19 BAN指示）。
   黒帯が #header の中にあるページは、#header ごと固定したうえで
   ロゴ行のぶん上へずらし、黒帯だけが画面の上に残るようにする。 */
@media screen and (min-width: 1025px) {
	body.bxs-on.bxs-band-out #header { position: static; }
	body.bxs-on.bxs-band-out #index_header_search,
	body.bxs-on.bxs-band-out #header_search { top: var(--bxs-abar, 0px); }
	body.bxs-on.bxs-band-in #header { top: calc(var(--bxs-headtop, 70px) * -1 + var(--bxs-abar, 0px)); }
}

/* ---------- せり上がるパネル ---------- */
.bxs-ov[hidden] { display: none !important; }
.bxs-ov {
	display: block;
	position: fixed;
	inset: 0;
	z-index: 100000;
	overscroll-behavior: contain;
	/* パネルを開けている間、背後のページを指で動かせないようにする。
	   動かせると、閉じたときに別の場所に戻ってしまう。 */
	touch-action: none;
}
.bxs-veil { position: absolute; inset: 0; background: rgba(24, 20, 14, .46); }

.bxs-pnl {
	position: absolute;
	left: 0; right: 0; bottom: 0;
	height: 66%;
	max-height: 640px;
	background: #fff;
	border-radius: 16px 16px 0 0;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	box-shadow: 0 -8px 30px rgba(0, 0, 0, .28);
}
/* PCで開いたときは中央の帯にする（幅いっぱいに伸びると読みにくいため） */
@media screen and (min-width: 1025px) {
	.bxs-pnl { left: 50%; right: auto; width: 460px; transform: translateX(-50%); }
}

.bxs-grip {
	position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
	width: 36px; height: 4px; border-radius: 2px; background: var(--bx-hairline, #e6dfd2);
}
.bxs-hd {
	flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
	padding: 16px 12px 10px; border-bottom: 1px solid var(--bx-hairline, #e6dfd2);
}
.bxs-ttl { flex: 1 1 auto; font-size: 14px; font-weight: bold; color: var(--bx-ink, #31494a); }
.bxs-x {
	flex: 0 0 auto; width: 32px; height: 32px; border: 0; border-radius: 50%;
	background: var(--bx-surface, #efe9dd); color: var(--bx-label, #6b6353);
	font-size: 15px; line-height: 1; cursor: pointer; font-family: inherit;
}
.bxs-body {
	flex: 1 1 auto; min-height: 0; overflow-y: auto;
	-webkit-overflow-scrolling: touch; padding: 4px 14px 8px;
	touch-action: pan-y;            /* パネルの中だけは縦に動かせる */
	overscroll-behavior: contain;   /* 端まで行っても背後に伝わらない */
}
.bxs-row { margin-top: 10px; }
.bxs-lab { display: block; font-size: 11px; color: var(--bx-label, #6b6353); margin: 0 0 4px; }
.bxs-inp, .bxs-sel, .bxs-find {
	width: 100%; height: 42px; padding: 0 12px; font-size: 15px; font-family: inherit;
	border: 1px solid var(--bx-hairline, #e6dfd2); border-radius: 8px;
	background: #fff; color: var(--bx-ink, #31494a);
	-webkit-appearance: none; appearance: none;
}
.bxs-find { height: 36px; font-size: 13px; margin-bottom: 6px; background: var(--bx-page-bg, #f7f4ee); }
.bxs-sel {
	padding-right: 34px;
	background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%239a9080' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
	background-repeat: no-repeat; background-position: right 12px center; background-size: 11px;
}
.bxs-ft {
	flex: 0 0 auto; background: #fff;
	padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
	border-top: 1px solid var(--bx-hairline, #e6dfd2);
}
.bxs-go {
	width: 100%; height: 46px; border: 0; border-radius: 8px;
	background: var(--bx-accent, #a9812e); color: #fff;
	font-size: 15px; font-weight: bold; font-family: inherit; cursor: pointer;
}
.bxs-clr {
	display: block; width: 100%; margin-top: 8px; padding: 4px;
	background: none; border: 0; font-family: inherit; font-size: 12px;
	color: var(--bx-muted, #9a9080); text-decoration: underline; cursor: pointer;
}

/* ---------- 動き（画面が実際に表示されているときだけ） ---------- */
html.bxs-motion body.bxs-on #header { transition: transform .2s ease; }
html.bxs-motion body.bxs-on #index_header_search,
html.bxs-motion body.bxs-on #header_search { transition: top .2s ease; }
html.bxs-motion .bxs-ov:not([hidden]) .bxs-veil { animation: bxs-fade .18s ease; }
html.bxs-motion .bxs-ov:not([hidden]) .bxs-pnl { animation: bxs-up .22s ease; }
@keyframes bxs-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bxs-up { from { transform: translateY(30px); } to { transform: none; } }
@media screen and (min-width: 1025px) {
	html.bxs-motion .bxs-ov:not([hidden]) .bxs-pnl { animation: bxs-up-pc .22s ease; }
	@keyframes bxs-up-pc {
		from { transform: translateX(-50%) translateY(30px); }
		to   { transform: translateX(-50%); }
	}
}
