/**
 * ギャラリー一覧
 *
 * 色は先頭のカスタムプロパティにまとめている。
 * ページ側の配色に合わせるときはここだけ直せばよい。
 */

.kstc-index {
	/* PC用の列数はショートコードから渡される。既定は4列 */
	--kstc-index-columns: var(--kstc-index-columns-pc, 4);
	--kstc-index-gap: 16px;
	--kstc-index-ratio: 3 / 4;
	--kstc-fg: #2c241f;
	--kstc-line: rgba(44, 36, 31, 0.3);
	--kstc-accent: #47382e;

	/* プルダウン。高級感を出すため濃茶に白文字＋金の細枠 */
	--kstc-select-bg: #47382e;
	--kstc-select-fg: #ffffff;
	--kstc-select-border: #c7a776;

	/* スマートフォンで下から出るパネルの地色 */
	--kstc-sheet-bg: #f3e7cd;

	width: 100%;
	color: var(--kstc-fg);
}

/**
 * Snow Monkey のセクションは中身の幅に合わせて縮む flex アイテム。
 * 絞り込みで写真が0件になるとグリッドが潰れ、
 * 絞り込みボタンの幅まで縮んで中央に寄ってしまう。
 * 件数によってページの見た目が変わらないよう、幅を固定する。
 */
.smb-section__contents-wrapper:has(.kstc-index),
.smb-section__body:has(> .kstc-index) {
	width: 100%;
}

/* 絞り込み --------------------------------------------------------- */

/**
 * 「条件から探す」の開閉ボタン。
 * スマートフォンでのみ表示する。PCでは絞り込みを常に開いておく。
 */
.kstc-index__toggle {
	display: none;
	width: 100%;
	align-items: center;
	gap: 12px;
	margin: 0 0 16px;
	padding: 15px 20px;
	border: 1px solid var(--kstc-select-border);
	border-radius: 2px;
	background: var(--kstc-select-bg);
	color: var(--kstc-select-fg);
	font-family: inherit;
	cursor: pointer;
	/* タップ時に端末標準の色が乗ると誤作動に見えるので消す */
	-webkit-tap-highlight-color: transparent;
	transition: border-color 0.25s ease;
}

/* 開いているあいだは枠を明るくして、状態が一目で分かるようにする */
.is-filters-open .kstc-index__toggle {
	border-color: var(--kstc-select-fg);
}

.kstc-index__toggle:focus-visible {
	outline: 2px solid var(--kstc-select-border);
	outline-offset: 2px;
}

.kstc-index__toggle-icon {
	display: inline-flex;
	flex: none;
	align-items: center;
}

.kstc-index__toggle-en {
	font-family: Georgia, "Times New Roman", serif;
	font-size: 1.5rem;
	letter-spacing: 0.14em;
}

.kstc-index__toggle-ja {
	padding-left: 12px;
	border-left: 1px solid rgba(255, 255, 255, 0.4);
	font-size: 1.2rem;
	letter-spacing: 0.08em;
}

.kstc-index__toggle-caret {
	flex: none;
	width: 10px;
	height: 10px;
	margin-left: auto;
	margin-top: -5px;
	border-right: 1.5px solid var(--kstc-select-fg);
	border-bottom: 1.5px solid var(--kstc-select-fg);
	transform: rotate(45deg);
	transition: transform 0.25s ease;
}

.is-filters-open .kstc-index__toggle-caret {
	margin-top: 3px;
	transform: rotate(-135deg);
}

/**
 * PCでは横に並べる。1つずつ縦に積むと全幅まで伸びて間延びするため。
 * 項目が増えたら折り返す。スマートフォンでは縦積みに戻す。
 */
.kstc-index__filters {
	margin: 0 0 28px;
}

.kstc-index__filters-inner {
	display: flex;
	flex-wrap: wrap;
	gap: 16px 20px;
}

/* パネルの見出しと閉じるボタンはスマートフォンでのみ使う */
.kstc-index__sheet-head,
.kstc-index__sheet-apply {
	display: none;
}

.kstc-index__group {
	flex: 1 1 200px;
	max-width: 260px;
	min-width: 0;
}

.kstc-index__group-label {
	display: block;
	margin: 0 0 8px;
	font-family: Georgia, "Times New Roman", serif;
	font-size: 1.5rem;
	font-weight: 400;
	letter-spacing: 0.06em;
	color: var(--kstc-fg);
}

/**
 * プルダウン
 *
 * ブラウザ標準の白い見た目だとサイトの雰囲気から浮くため、
 * appearance を切って自前で描く。矢印も擬似要素で作る。
 */
.kstc-index__select-wrap {
	position: relative;
	display: block;
}

.kstc-index__select {
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	width: 100%;
	margin: 0;
	padding: 15px 52px 15px 20px;
	border: 1px solid var(--kstc-select-border);
	border-radius: 2px;
	background: var(--kstc-select-bg);
	color: var(--kstc-select-fg);
	font-family: inherit;
	font-size: 1.5rem;
	line-height: 1.5;
	letter-spacing: 0.06em;
	cursor: pointer;
	transition: border-color 0.2s ease;
}

.kstc-index__select:hover {
	border-color: var(--kstc-select-fg);
}

.kstc-index__select:focus-visible {
	outline: 2px solid var(--kstc-select-border);
	outline-offset: 2px;
}

/* 展開したときの一覧。対応するブラウザでのみ効く */
.kstc-index__select option {
	background: var(--kstc-select-bg);
	color: var(--kstc-select-fg);
}

/* 矢印 */
.kstc-index__caret {
	position: absolute;
	top: 50%;
	right: 20px;
	width: 11px;
	height: 11px;
	margin-top: -7px;
	border-right: 1.5px solid var(--kstc-select-fg);
	border-bottom: 1.5px solid var(--kstc-select-fg);
	transform: rotate(45deg);
	pointer-events: none;
}

/* 件数と導線 ------------------------------------------------------- */

.kstc-index__status {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 20px;
	margin: 0 0 20px;
	padding-top: 16px;
	border-top: 1px solid var(--kstc-line);
}

.kstc-index__count {
	margin: 0;
	font-size: 1.3rem;
	letter-spacing: 0.08em;
}

.kstc-index__brand-link {
	margin: 0;
}

.kstc-index__brand-link a {
	color: var(--kstc-accent);
	font-size: 1.3rem;
	text-decoration: underline;
	text-underline-offset: 4px;
}

.kstc-index__reset {
	margin-left: auto;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--kstc-fg);
	font-size: 1.2rem;
	text-decoration: underline;
	text-underline-offset: 4px;
	cursor: pointer;
	opacity: 0.7;
}

.kstc-index__reset:hover {
	opacity: 1;
}

/* 写真グリッド ----------------------------------------------------- */

.kstc-index__list {
	display: grid;
	/*
	 * minmax(0, 1fr) にする。ただの 1fr は「中身より小さくなれない」ため、
	 * 「Ermenegildo」のような折り返せない長い単語を持つ列だけが広がってしまう。
	 */
	grid-template-columns: repeat(var(--kstc-index-columns), minmax(0, 1fr));
	gap: var(--kstc-index-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

.kstc-index__item {
	margin: 0;
	padding: 0;
	list-style: none;
}

.kstc-index__thumb {
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
	cursor: zoom-in;
	text-align: left;
	font: inherit;
}

.kstc-index__figure {
	display: block;
	overflow: hidden;
	background: rgba(128, 128, 128, 0.08);
	aspect-ratio: var(--kstc-index-ratio);
}

.kstc-index__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.6s ease;
}

.kstc-index__thumb:hover .kstc-index__img {
	transform: scale(1.04);
}

/* ブランド名と「＋」。現行ページの見た目に合わせる */
.kstc-index__meta {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px;
	margin-top: 10px;
}

.kstc-index__brand {
	font-size: 1.3rem;
	line-height: 1.5;
	letter-spacing: 0.06em;
	/* 「Ermenegildo」のような長い語も途中で折り返して、はみ出させない */
	min-width: 0;
	overflow-wrap: anywhere;
}

/* 丸で囲んだ「＋」 */
.kstc-index__plus {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	border: 1px solid currentColor;
	border-radius: 50%;
	font-size: 1.1rem;
	line-height: 1;
	opacity: 0.75;
}

.kstc-index__thumb:focus-visible {
	outline: 2px solid var(--kstc-accent);
	outline-offset: 3px;
}

.kstc-index__empty {
	margin: 40px 0;
	font-size: 1.4rem;
	text-align: center;
}

.kstc-index__more-wrap {
	margin-top: 40px;
	text-align: center;
}

.kstc-index__more {
	min-width: 260px;
	padding: 16px 30px;
	border: 1px solid var(--kstc-accent);
	background: transparent;
	color: var(--kstc-accent);
	font-size: 1.3rem;
	letter-spacing: 0.08em;
	cursor: pointer;
	transition: background-color 0.25s ease, color 0.25s ease;
}

.kstc-index__more:hover {
	background: var(--kstc-accent);
	color: #fff;
}

/* ポップアップ ----------------------------------------------------- */

body.kstc-lightbox-open,
body.kstc-sheet-open {
	overflow: hidden;
}

.kstc-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
}

.kstc-lightbox[hidden] {
	display: none;
}

.kstc-lightbox__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(20, 15, 12, 0.92);
	cursor: zoom-out;
}

.kstc-lightbox__panel {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(1000px, 92vw);
	max-height: 92vh;
}

.kstc-lightbox__close {
	position: absolute;
	top: -44px;
	right: 0;
	width: 36px;
	height: 36px;
	border: 0;
	background: transparent;
	color: #fff;
	font-size: 30px;
	line-height: 1;
	cursor: pointer;
}

.kstc-lightbox__stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
}

.kstc-lightbox__img {
	display: block;
	max-width: 100%;
	max-height: 74vh;
	width: auto;
	height: auto;
	object-fit: contain;
}

.kstc-lightbox__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 48px;
	height: 48px;
	border: 0;
	background: rgba(0, 0, 0, 0.45);
	color: #fff;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
}

.kstc-lightbox__nav[hidden] {
	display: none;
}

.kstc-lightbox__nav--prev {
	left: 8px;
}

.kstc-lightbox__nav--next {
	right: 8px;
}

.kstc-lightbox__foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 20px;
	padding-top: 16px;
	color: #fff;
}

.kstc-lightbox__label,
.kstc-lightbox__counter {
	margin: 0;
	font-size: 1.3rem;
	letter-spacing: 0.06em;
}

.kstc-lightbox__counter {
	opacity: 0.6;
}

.kstc-lightbox__detail {
	margin-left: auto;
	padding: 11px 22px;
	border: 1px solid rgba(255, 255, 255, 0.7);
	color: #fff;
	font-size: 1.2rem;
	letter-spacing: 0.06em;
	text-decoration: none;
	transition: background-color 0.25s ease, color 0.25s ease;
}

.kstc-lightbox__detail:hover {
	background: #fff;
	color: #2c241f;
}

/* aspect-ratio 未対応ブラウザ向けの保険 */
@supports not (aspect-ratio: 1) {
	.kstc-index__figure {
		position: relative;
		padding-top: 133.33%;
	}

	.kstc-index__img {
		position: absolute;
		inset: 0;
	}
}

@media screen and (max-width: 767px) {
	.kstc-index {
		--kstc-index-columns: 2;
		--kstc-index-gap: 8px;
	}

	.kstc-index__toggle {
		display: flex;
	}

	/*
	 * 絞り込みは画面下から出るパネルにする。
	 *
	 * バーの下に開く形だと、
	 * ・写真が下へ押し出される
	 * ・バーとプルダウンが同じ見た目で、押すものと選ぶものの区別がつかない
	 * ・中身の高さを測って動かす必要があり、動きが不安定になりやすい
	 * という問題がある。
	 *
	 * 別の面として重ねれば、高さを測らずに動かせて役割の違いもはっきりする。
	 */
	.kstc-index__filters {
		position: fixed;
		inset: 0;
		z-index: 99999;
		display: flex;
		align-items: flex-end;
		margin: 0;
		visibility: hidden;
	}

	.is-filters-open .kstc-index__filters {
		visibility: visible;
	}

	/* 背景の覆い */
	.kstc-index__filters::before {
		content: "";
		position: absolute;
		inset: 0;
		background: rgba(20, 15, 12, 0.6);
		opacity: 0;
		transition: opacity 0.3s ease;
	}

	.is-filters-open .kstc-index__filters::before {
		opacity: 1;
	}

	/* せり上がる面 */
	.kstc-index__sheet {
		position: relative;
		width: 100%;
		max-height: 82vh;
		overflow-y: auto;
		padding: 0 20px 24px;
		background: var(--kstc-sheet-bg);
		border-radius: 12px 12px 0 0;
		transform: translateY(100%);
		transition: transform 0.3s ease;
	}

	.is-filters-open .kstc-index__sheet {
		transform: translateY(0);
	}

	.kstc-index__sheet-head {
		position: sticky;
		top: 0;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 18px;
		padding: 18px 0 14px;
		border-bottom: 1px solid var(--kstc-line);
		background: var(--kstc-sheet-bg);
	}

	.kstc-index__sheet-title {
		font-family: Georgia, "Times New Roman", serif;
		font-size: 1.6rem;
		letter-spacing: 0.16em;
		color: var(--kstc-fg);
	}

	.kstc-index__sheet-close {
		width: 36px;
		height: 36px;
		margin-right: -8px;
		padding: 0;
		border: 0;
		background: transparent;
		color: var(--kstc-fg);
		font-size: 26px;
		line-height: 1;
		cursor: pointer;
		-webkit-tap-highlight-color: transparent;
	}

	.kstc-index__sheet-apply {
		display: block;
		width: 100%;
		margin-top: 24px;
		padding: 16px;
		border: 1px solid var(--kstc-select-bg);
		border-radius: 2px;
		background: var(--kstc-select-bg);
		color: var(--kstc-select-fg);
		font-family: inherit;
		font-size: 1.4rem;
		letter-spacing: 0.08em;
		cursor: pointer;
		-webkit-tap-highlight-color: transparent;
	}

	.kstc-index__filters-inner {
		flex-direction: column;
		gap: 14px;
	}

	/*
	 * 縦積みでは flex-basis が「高さ」に効く。
	 * 横並び用の flex: 1 1 200px を残すと各項目が200pxの高さになり、
	 * 項目の間に大きな余白ができてしまう。
	 */
	.kstc-index__group {
		flex: 0 0 auto;
		max-width: none;
	}

	.kstc-index__group-label {
		font-size: 1.4rem;
	}

	/* 件数の上の罫線はPCのみ。スマートフォンでは詰めて見せる */
	.kstc-index__status {
		margin-bottom: 16px;
		padding-top: 0;
		border-top: 0;
	}

	.kstc-index__select {
		padding: 14px 46px 14px 16px;
		font-size: 1.4rem;
	}

	.kstc-index__more {
		width: 100%;
		min-width: 0;
	}

	.kstc-lightbox__panel {
		width: 94vw;
	}

	.kstc-lightbox__img {
		max-height: 64vh;
	}

	.kstc-lightbox__nav {
		width: 40px;
		height: 40px;
		font-size: 24px;
	}

	.kstc-lightbox__detail {
		width: 100%;
		margin-left: 0;
		text-align: center;
	}
}

@media (prefers-reduced-motion: reduce) {
	.kstc-index__img {
		transition: none;
	}

	.kstc-index__thumb:hover .kstc-index__img {
		transform: none;
	}

	.kstc-index__filters::before,
	.kstc-index__sheet,
	.kstc-index__toggle-caret {
		transition: none;
	}
}
