/*
 * C'est Bon shop UI.
 * Mobile catalog grid, sort bottom sheet, left menu drawer, and load more.
 * Desktop keeps the existing WooCommerce block presentation.
 */

/* ---------------------------------------------------------
   Shared controls
   --------------------------------------------------------- */
.cb-menu-trigger {
	display: none;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	padding: 0;
	background: transparent;
	border: 0;
	border-radius: 50%;
	color: var(--cb-ink, #171717);
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease;
}

.cb-menu-trigger svg {
	width: 22px;
	height: 22px;
}

.cb-menu-trigger:hover {
	background: var(--cb-bone, #f5f5f1);
	color: var(--cb-forest, #174d3a);
}

.cb-sort-trigger {
	display: none;
	align-items: center;
	justify-content: center;
	gap: 7px;
	height: 40px;
	padding: 0 14px;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	color: #111;
	font-family: var(--wp--preset--font-family--body, "Manrope", sans-serif);
	font-size: 13px;
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
	transition: border-color 0.2s ease, background 0.2s ease;
}

.cb-sort-trigger svg {
	flex: 0 0 18px;
	width: 18px;
	height: 18px;
}

.cb-sort-trigger:hover {
	background: #f9fafb;
	border-color: #111;
}

.cb-sort-noscript {
	margin-left: 8px;
	padding: 8px 12px;
	background: #fff;
	border: 1px solid #111;
	border-radius: 10px;
	font-size: 13px;
	font-weight: 700;
	cursor: pointer;
}

/* ---------------------------------------------------------
   Overlays and scroll lock
   --------------------------------------------------------- */
.cb-menu-overlay,
.cb-sheet-overlay {
	position: fixed;
	inset: 0;
	z-index: 1000;
	background: rgba(0, 0, 0, 0.5);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.25s ease, visibility 0.25s ease;
}

.cb-sheet-overlay {
	background: rgba(0, 0, 0, 0.35);
}

.cb-menu-overlay.is-open,
.cb-sheet-overlay.is-open {
	opacity: 1;
	visibility: visible;
}

html.cb-overlay-open,
body.cb-overlay-open {
	overflow: hidden !important;
}

/* ---------------------------------------------------------
   Left menu drawer
   --------------------------------------------------------- */
.cb-menu-drawer {
	position: fixed;
	top: 0;
	left: 0;
	z-index: 1001;
	width: 85%;
	max-width: 360px;
	height: 100vh;
	height: 100dvh;
	padding: 16px;
	padding-bottom: calc(16px + env(safe-area-inset-bottom));
	background: #fff;
	overflow-x: hidden;
	overflow-y: auto;
	box-sizing: border-box;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
	transform: translateX(-100%);
	visibility: hidden;
	transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.28s ease;
}

.cb-menu-drawer.is-open {
	transform: translateX(0);
	visibility: visible;
}

.cb-menu-drawer__top {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding-bottom: 16px;
	border-bottom: 1px solid #f3f4f6;
}

.cb-menu-drawer__brand {
	display: block;
	color: #171717;
	font-family: var(--wp--preset--font-family--display, "Fraunces", serif);
	font-size: 24px;
	font-weight: 700;
	letter-spacing: -0.04em;
	line-height: 1;
	text-decoration: none;
}

.cb-menu-drawer__brand:hover {
	color: #174d3a;
	text-decoration: none;
}

.cb-menu-drawer__brand span {
	display: block;
	margin-top: 5px;
	color: #6b7280;
	font-family: var(--wp--preset--font-family--body, "Manrope", sans-serif);
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.12em;
	line-height: 1.3;
	text-transform: uppercase;
}

.cb-menu-drawer__close {
	display: inline-flex;
	flex: 0 0 40px;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 50%;
	color: #111;
	cursor: pointer;
}

.cb-menu-drawer__close:hover {
	background: #f9fafb;
	border-color: #111;
}

.cb-drawer__title {
	margin: 16px 0 8px;
	color: #6b7280;
	font-family: var(--wp--preset--font-family--body, "Manrope", sans-serif);
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0.08em;
	line-height: 1.3;
	text-transform: uppercase;
}

.cb-drawer__cats {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

.cb-drawer__cat {
	display: flex;
	align-items: center;
	gap: 10px;
	height: 52px;
	min-width: 0;
	padding: 8px 12px;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	color: #171717;
	font-family: var(--wp--preset--font-family--body, "Manrope", sans-serif);
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	transition: background 0.2s ease, border-color 0.2s ease;
}

.cb-drawer__cat:hover {
	background: #f9fafb;
	border-color: #111;
	color: #171717;
	text-decoration: none;
}

.cb-drawer__cat-icon {
	display: inline-flex;
	flex: 0 0 24px;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	color: #174d3a;
}

.cb-drawer__cat-icon svg {
	display: block;
	width: 24px;
	height: 24px;
}

.cb-drawer__cat-label {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.cb-drawer__links {
	margin: 0;
	padding: 0;
	border-top: 1px solid #f3f4f6;
	list-style: none;
}

.cb-drawer__links li {
	margin: 0;
	border-bottom: 1px solid #f3f4f6;
}

.cb-drawer__links a {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	min-height: 48px;
	padding: 0 2px;
	color: #171717;
	font-family: var(--wp--preset--font-family--body, "Manrope", sans-serif);
	font-size: 14px;
	font-weight: 600;
	line-height: 1.3;
	text-decoration: none;
}

.cb-drawer__links a::after {
	content: "→";
	color: #9ca3af;
	font-weight: 400;
}

.cb-drawer__links a:hover {
	color: #174d3a;
	text-decoration: none;
}

.cb-menu-drawer__foot {
	margin-top: 24px;
	padding-top: 16px;
	border-top: 1px solid #f3f4f6;
	color: #6b7280;
	font-size: 12px;
	line-height: 1.55;
}

.cb-menu-drawer__foot p {
	margin: 0 0 4px;
}

.cb-menu-drawer__location {
	color: #171717;
	font-weight: 700;
}

/* ---------------------------------------------------------
   Sort bottom sheet
   --------------------------------------------------------- */
.cb-sort-sheet {
	position: fixed;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 1001;
	max-height: 60vh;
	padding: 16px;
	padding-bottom: calc(16px + env(safe-area-inset-bottom));
	background: #fff;
	border-radius: 16px 16px 0 0;
	box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	box-sizing: border-box;
	transform: translateY(100%);
	visibility: hidden;
	transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.28s ease;
}

.cb-sort-sheet.is-open {
	transform: translateY(0);
	visibility: visible;
}

.cb-sort-sheet__handle {
	width: 40px;
	height: 4px;
	margin: 0 auto 12px;
	background: #e5e7eb;
	border-radius: 999px;
}

.cb-sort-sheet__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 4px;
}

.cb-sort-sheet__title {
	margin: 0;
	color: #111;
	font-family: var(--wp--preset--font-family--body, "Manrope", sans-serif);
	font-size: 16px;
	font-weight: 800;
	letter-spacing: 0;
	line-height: 1.3;
}

.cb-sort-sheet__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 50%;
	color: #111;
	cursor: pointer;
}

.cb-sort-sheet__close:hover {
	background: #f9fafb;
	border-color: #111;
}

.cb-sort-option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: 48px;
	margin: 0;
	padding: 0;
	border-bottom: 1px solid #f3f4f6;
	color: #111;
	font-family: var(--wp--preset--font-family--body, "Manrope", sans-serif);
	font-size: 14px;
	font-weight: 500;
	line-height: 1.3;
	cursor: pointer;
}

.cb-sort-option:last-of-type {
	border-bottom: 0;
}

.cb-sort-option input[type="radio"] {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

.cb-sort-option__label {
	flex: 1 1 auto;
	min-width: 0;
}

.cb-sort-option__radio {
	position: relative;
	display: inline-flex;
	flex: 0 0 20px;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	border: 1.5px solid #d1d5db;
	border-radius: 50%;
	transition: border-color 0.2s ease;
}

.cb-sort-option input[type="radio"]:checked ~ .cb-sort-option__radio {
	border-color: #111;
}

.cb-sort-option input[type="radio"]:checked ~ .cb-sort-option__radio::after {
	content: "";
	width: 10px;
	height: 10px;
	background: #111;
	border-radius: 50%;
}

.cb-sort-option input[type="radio"]:focus-visible ~ .cb-sort-option__radio {
	outline: 3px solid rgba(23, 77, 58, 0.28);
	outline-offset: 2px;
}

.cb-sort-apply {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 48px;
	margin-top: 12px;
	background: #111;
	border: 1px solid #111;
	border-radius: 12px;
	color: #fff;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
}

/* ---------------------------------------------------------
   Load more
   --------------------------------------------------------- */
.cb-loadmore {
	margin: 24px 0 8px;
}

.cb-loadmore__count {
	margin: 0 0 8px;
	color: #6b7280;
	font-family: var(--wp--preset--font-family--body, "Manrope", sans-serif);
	font-size: 13px;
	font-weight: 500;
	line-height: 1.4;
	text-align: center;
}

.cb-loadmore__button {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	max-width: 420px;
	height: 48px;
	margin: 0 auto;
	padding: 0 16px;
	background: #fff;
	border: 1px solid #111;
	border-radius: 12px;
	color: #111;
	font-family: var(--wp--preset--font-family--body, "Manrope", sans-serif);
	font-size: 14px;
	font-weight: 700;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	transition: background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.cb-loadmore__action {
	margin: 0;
}

.cb-loadmore__button:hover {
	background: #111;
	color: #fff;
	text-decoration: none;
}

.cb-loadmore__button.is-loading {
	opacity: 0.55;
	pointer-events: none;
}

.cb-loadmore__button[hidden] {
	display: none;
}

.cb-loadmore__error {
	margin: 8px 0 0;
	color: #b91c1c;
	font-size: 13px;
	line-height: 1.4;
	text-align: center;
}

/* ---------------------------------------------------------
   Mobile catalog
   --------------------------------------------------------- */
@media (max-width: 782px) {
	html.cb-js .cb-menu-trigger {
		display: inline-flex;
	}

	html.cb-js .cb-nav {
		display: none !important;
	}

	.cb-shop .cb-shop__body {
		padding-right: 16px !important;
		padding-left: 16px !important;
	}

	html.cb-js .cb-shop-toolbar {
		display: flex !important;
		flex-direction: row !important;
		align-items: center !important;
		justify-content: flex-end !important;
		gap: 8px;
		margin: 0 0 12px;
		padding: 0;
	}

	html.cb-js .cb-shop-toolbar .wc-block-product-results-count,
	html.cb-js .cb-shop-toolbar .wc-block-catalog-sorting {
		display: none !important;
	}

	html.cb-js .cb-sort-trigger {
		display: inline-flex;
	}

	.cb-product-collection .wc-block-product-template {
		display: grid !important;
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
		gap: 12px !important;
	}

	.cb-product-collection .wp-block-query-pagination {
		display: none !important;
	}

	.cb-product-collection .wc-block-product {
		border-radius: 14px;
	}

	.cb-loadmore {
		margin: 0 -16px 8px;
	}

	.cb-loadmore__count {
		margin: 16px 0 8px;
		font-size: 13px;
	}

	.cb-loadmore__button {
		width: calc(100% - 32px);
		max-width: none;
		margin: 0 16px;
		height: 48px;
		font-size: 14px;
	}
}

@media (max-width: 360px) {
	.cb-product-collection .wc-block-product-template {
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
	}
}

@media (min-width: 783px) {
	.cb-menu-drawer,
	.cb-sort-sheet,
	.cb-menu-overlay,
	.cb-sheet-overlay,
	.cb-loadmore {
		display: none !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cb-menu-drawer,
	.cb-sort-sheet,
	.cb-menu-overlay,
	.cb-sheet-overlay {
		transition: none;
	}
}
