/**
 * Chic Seekers Hat Bar picker.
 *
 * Everything is scoped under .cschb so it cannot leak into the theme, and every
 * colour is a variable so the whole thing can be re-skinned from a child theme
 * without touching this file.
 */

.cschb {
	--cschb-teal: #1F7C80;
	--cschb-teal-dark: #0F4446;
	--cschb-brown: #4E2E1B;
	--cschb-ink: #2B180D;
	--cschb-ink-soft: #5B4433;
	--cschb-ink-faint: #8A7360;
	--cschb-surface: #FFFCF6;
	--cschb-band: #F0E1C8;
	--cschb-line: rgba( 43, 24, 13, 0.16 );
	--cschb-ok: #3F7A4B;
	--cschb-warn: #A8442F;
	--cschb-radius: 14px;
	--cschb-shadow: 0 2px 4px rgba( 43, 24, 13, 0.06 ), 0 12px 28px rgba( 43, 24, 13, 0.1 );

	container-type: inline-size;
	color: var( --cschb-ink );
	margin: 0 0 26px;
	clear: both;
}

.cschb *,
.cschb *::before,
.cschb *::after {
	box-sizing: border-box;
}

.cschb img {
	max-width: 100%;
	display: block;
}

/* Anything this script hides with the hidden attribute must actually vanish.
   The browser's own [hidden] rule is display:none, but a class here that sets
   display (the patch tiles are display:grid) has equal specificity and wins,
   because an author stylesheet beats the user agent one. Without this, filtered
   patches stay on screen. */
.cschb [hidden] {
	display: none !important;
}

.cschb-intro {
	color: var( --cschb-ink-soft );
	margin: 0 0 20px;
	max-width: 62ch;
}

.cschb-notice {
	background: var( --cschb-band );
	border-radius: var( --cschb-radius );
	padding: 16px;
	margin: 0 0 20px;
}

.cschb-layout {
	display: grid;
	gap: 22px;
	align-items: start;
}

/* Two columns only when the picker actually has room for them. The product
   summary column in most themes does not, so this stays stacked there. */
@container ( min-width: 760px ) {
	.cschb-layout {
		grid-template-columns: 320px 1fr;
		gap: 28px;
	}

	.cschb-side {
		position: sticky;
		top: 24px;
	}
}

.cschb-side {
	display: grid;
	gap: 16px;
}

.cschb-card {
	background: var( --cschb-surface );
	border: 1px solid var( --cschb-line );
	border-radius: 18px;
	padding: 18px;
	display: grid;
	gap: 14px;
}

.cschb-summary {
	box-shadow: var( --cschb-shadow );
}

.cschb-h {
	font-size: 12px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	font-weight: 700;
	color: var( --cschb-ink-faint );
	margin: 0 0 8px;
	line-height: 1.3;
}

/* ---------- hats ---------- */

.cschb-hatgrid {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 84px, 1fr ) );
	gap: 10px;
}

.cschb-hat {
	background: none;
	border: 2px solid var( --cschb-line );
	border-radius: 12px;
	padding: 6px 6px 8px;
	cursor: pointer;
	text-align: center;
	display: grid;
	gap: 5px;
	font: inherit;
	color: inherit;
	transition: border-color 0.15s ease, transform 0.15s ease;
}

.cschb-hat:hover {
	transform: translateY( -2px );
	border-color: var( --cschb-teal );
}

.cschb-hat[aria-checked="true"] {
	border-color: var( --cschb-teal );
	box-shadow: 0 0 0 3px rgba( 31, 124, 128, 0.2 );
}

.cschb-hatname {
	font-size: 12px;
	font-weight: 600;
	line-height: 1.25;
}

.cschb-thumb {
	display: block;
	border-radius: 8px;
	overflow: hidden;
	background: var( --cschb-band );
	aspect-ratio: 1;
}

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

.cschb-extra {
	font-size: 11px;
	font-weight: 700;
	color: var( --cschb-teal );
}

/* ---------- summary ---------- */

.cschb-tierline {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
}

.cschb-tiername {
	font-weight: 700;
	font-size: 16px;
	line-height: 1.2;
}

.cschb-amount {
	font-size: 30px;
	font-weight: 700;
	color: var( --cschb-teal );
	line-height: 1;
	white-space: nowrap;
}

.cschb-countrow {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 12px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	font-weight: 700;
	color: var( --cschb-ink-faint );
}

.cschb-bar {
	flex: 1;
	height: 8px;
	border-radius: 999px;
	background: var( --cschb-band );
	overflow: hidden;
	display: block;
}

.cschb-bar > span {
	display: block;
	height: 100%;
	width: 0;
	background: var( --cschb-teal );
	border-radius: 999px;
	transition: width 0.28s ease;
}

.cschb-nudge {
	background: var( --cschb-band );
	border-left: 4px solid var( --cschb-teal );
	border-radius: 10px;
	padding: 11px 13px;
	margin: 0;
	font-size: 14px;
	line-height: 1.5;
	color: var( --cschb-ink-soft );
	min-height: 44px;
}

.cschb-nudge b {
	color: var( --cschb-ink );
}

.cschb-nudge.is-warn {
	border-left-color: var( --cschb-warn );
	color: var( --cschb-warn );
	font-weight: 600;
}

.cschb-tray {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	min-height: 8px;
}

.cschb-trayempty {
	font-size: 13px;
	font-style: italic;
	color: var( --cschb-ink-faint );
}

.cschb-trayitem {
	width: 48px;
	height: 48px;
	border-radius: 9px;
	border: 1px solid var( --cschb-line );
	background: var( --cschb-band );
	overflow: hidden;
	position: relative;
	padding: 0;
	cursor: pointer;
	transition: transform 0.14s ease, border-color 0.14s ease;
}

.cschb-trayitem img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.cschb-trayitem::after {
	content: "\00d7";
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	background: rgba( 168, 68, 47, 0.85 );
	color: #fff;
	font-size: 20px;
	font-weight: 700;
	opacity: 0;
	transition: opacity 0.14s ease;
}

.cschb-trayitem:hover::after,
.cschb-trayitem:focus-visible::after {
	opacity: 1;
}

.cschb-chainrow {
	display: flex;
	align-items: center;
	gap: 9px;
	font-size: 13px;
	color: var( --cschb-ink-soft );
	border-top: 1px dashed var( --cschb-line );
	padding-top: 12px;
}

.cschb-pill {
	background: var( --cschb-ok );
	color: #fff;
	font-size: 10.5px;
	font-weight: 700;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	padding: 3px 9px;
	border-radius: 999px;
	white-space: nowrap;
}

.cschb-pill.is-off {
	background: var( --cschb-band );
	color: var( --cschb-ink-faint );
}

/* ---------- chains ---------- */

.cschb-chaingrid {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 82px, 1fr ) );
	gap: 9px;
}

.cschb-chain {
	background: none;
	border: 2px solid var( --cschb-line );
	border-radius: 11px;
	padding: 7px;
	cursor: pointer;
	font: inherit;
	color: inherit;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.25;
	display: grid;
	gap: 4px;
	align-content: center;
	text-align: center;
	transition: border-color 0.15s ease;
}

.cschb-chain:hover {
	border-color: var( --cschb-teal );
}

.cschb-chain.is-on {
	border-color: var( --cschb-teal );
	box-shadow: 0 0 0 3px rgba( 31, 124, 128, 0.18 );
}

.cschb-chaincost {
	font-size: 11px;
	color: var( --cschb-teal );
	font-weight: 700;
}

/* ---------- gallery ---------- */

.cschb-main {
	display: grid;
	gap: 14px;
	align-content: start;
}

.cschb-search {
	display: block;
}

.cschb-search input {
	width: 100%;
	padding: 11px 16px;
	border-radius: 999px;
	border: 1px solid var( --cschb-line );
	background: var( --cschb-surface );
	color: var( --cschb-ink );
	font: inherit;
	font-size: 15px;
}

.cschb-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
}

.cschb-chip {
	padding: 7px 14px;
	border-radius: 999px;
	border: 1px solid var( --cschb-line );
	background: none;
	cursor: pointer;
	font: inherit;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: inherit;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cschb-chip:hover {
	border-color: var( --cschb-teal );
}

.cschb-chip[aria-pressed="true"] {
	background: var( --cschb-teal );
	border-color: var( --cschb-teal );
	color: #fff;
}

.cschb-patches {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 132px, 1fr ) );
	gap: 12px;
}

.cschb-patch {
	position: relative;
	background: var( --cschb-surface );
	border: 2px solid var( --cschb-line );
	border-radius: var( --cschb-radius );
	padding: 9px 9px 11px;
	cursor: pointer;
	font: inherit;
	color: inherit;
	text-align: center;
	display: grid;
	gap: 5px;
	align-content: start;
	transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.cschb-patch:hover {
	transform: translateY( -3px );
	box-shadow: var( --cschb-shadow );
	border-color: var( --cschb-teal );
}

.cschb-patch[aria-pressed="true"] {
	border-color: var( --cschb-teal );
	box-shadow: 0 0 0 3px rgba( 31, 124, 128, 0.2 );
}

.cschb-patch.is-locked {
	opacity: 0.4;
	cursor: not-allowed;
}

.cschb-patch.is-locked:hover {
	transform: none;
	box-shadow: none;
	border-color: var( --cschb-line );
}

.cschb-patchname {
	font-size: 13px;
	font-weight: 700;
	line-height: 1.25;
}

.cschb-patchcat {
	font-size: 10px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	font-weight: 700;
	color: var( --cschb-ink-faint );
}

.cschb-tick {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 25px;
	height: 25px;
	border-radius: 999px;
	background: var( --cschb-teal );
	color: #fff;
	display: grid;
	place-items: center;
	opacity: 0;
	transform: scale( 0.6 );
	transition: opacity 0.16s ease, transform 0.16s ease;
	z-index: 1;
}

.cschb-patch[aria-pressed="true"] .cschb-tick {
	opacity: 1;
	transform: scale( 1 );
}

.cschb-empty {
	text-align: center;
	color: var( --cschb-ink-faint );
	padding: 30px 0;
	margin: 0;
}

/* Focus rings, because these are all real buttons. */
.cschb button:focus-visible,
.cschb input:focus-visible {
	outline: 2px solid var( --cschb-teal );
	outline-offset: 2px;
}

/* Dark themes. Opt in by putting data-cschb-theme="dark" on the picker or any
   ancestor, so a light theme is never guessed wrong. */
[ data-cschb-theme="dark" ] .cschb,
.cschb[ data-cschb-theme="dark" ] {
	--cschb-ink: #F6E9D5;
	--cschb-ink-soft: #D4BEA3;
	--cschb-ink-faint: #9E8B74;
	--cschb-surface: #251810;
	--cschb-band: #2B1C11;
	--cschb-line: rgba( 246, 233, 213, 0.18 );
	--cschb-teal: #5FBEC0;
	--cschb-shadow: 0 2px 4px rgba( 0, 0, 0, 0.4 ), 0 12px 28px rgba( 0, 0, 0, 0.4 );
}
