/* KS Free Cover – popup */
html.ksfc-open,
html.ksfc-open body { overflow: hidden; }

.ksfc-overlay {
	--ksfc-accent: #1f6f5c;
	--ksfc-text: #1d2327;
	--ksfc-muted: #5f6b73;
	--ksfc-border: #e3e6e8;
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba(17, 24, 28, 0.6);
	opacity: 0;
	transition: opacity 0.2s ease;
	-webkit-tap-highlight-color: transparent;
}
.ksfc-overlay[hidden] { display: none; }
.ksfc-overlay.is-visible { opacity: 1; }

.ksfc-modal {
	position: relative;
	box-sizing: border-box;
	width: 100%;
	max-width: 460px;
	max-height: calc(100vh - 40px);
	max-height: calc(100dvh - 40px);
	display: flex;
	flex-direction: column;
	background: #fff;
	color: var(--ksfc-text);
	border-radius: 16px;
	box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
	transform: translateY(12px) scale(0.98);
	transition: transform 0.2s ease;
	font-size: 16px;
	line-height: 1.45;
	text-align: center;
	outline: none;
}
.ksfc-overlay.is-visible .ksfc-modal { transform: none; }
.ksfc-modal *, .ksfc-modal *::before, .ksfc-modal *::after { box-sizing: border-box; }

.ksfc-close {
	position: absolute;
	top: 10px;
	right: 10px;
	width: 36px;
	height: 36px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.05);
	color: var(--ksfc-text);
	font-size: 24px;
	line-height: 36px;
	cursor: pointer;
	z-index: 2;
}
.ksfc-close:hover, .ksfc-close:focus-visible { background: rgba(0, 0, 0, 0.1); }

.ksfc-header { padding: 26px 48px 8px; }
.ksfc-title {
	margin: 0 0 6px;
	padding: 0;
	font-size: 22px;
	line-height: 1.25;
	font-weight: 700;
	color: var(--ksfc-text);
}
.ksfc-subtitle { margin: 0; color: var(--ksfc-muted); font-size: 15px; white-space: pre-line; }

.ksfc-body {
	padding: 12px 24px 8px;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.ksfc-image-wrap {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0 auto 14px;
	width: 100%;
	max-width: 280px;
	aspect-ratio: 1 / 1;
	background: #f6f7f7;
	border-radius: 12px;
	overflow: hidden;
}
.ksfc-image {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	margin: 0 auto;
	object-fit: contain;
}
.ksfc-product-name {
	margin: 0 0 4px;
	padding: 0;
	font-size: 17px;
	font-weight: 600;
	line-height: 1.3;
	color: var(--ksfc-text);
}
.ksfc-price { margin: 0 0 16px; font-size: 17px; min-height: 1.45em; }
.ksfc-price .ksfc-regular { font-weight: 400; }
.ksfc-price .ksfc-regular .amount, .ksfc-price .ksfc-regular bdi { text-decoration: line-through; }
.ksfc-price del,
.ksfc-price .ksfc-regular { color: var(--ksfc-muted); text-decoration: line-through; margin-right: 4px; }
.ksfc-price .ksfc-free-label { font-weight: 800; color: var(--ksfc-accent); letter-spacing: 0.02em; }
.ksfc-price ins { text-decoration: none; }

.ksfc-label {
	display: block;
	margin: 0 0 6px;
	text-align: left;
	font-size: 14px;
	font-weight: 600;
	color: var(--ksfc-text);
}
.ksfc-select-wrap { position: relative; }
.ksfc-select-wrap::after {
	content: '';
	position: absolute;
	right: 16px;
	top: 50%;
	width: 8px;
	height: 8px;
	margin-top: -6px;
	border-right: 2px solid var(--ksfc-muted);
	border-bottom: 2px solid var(--ksfc-muted);
	transform: rotate(45deg);
	pointer-events: none;
}
.ksfc-select {
	display: block;
	width: 100%;
	min-height: 48px;
	margin: 0;
	padding: 10px 40px 10px 14px;
	border: 1px solid var(--ksfc-border);
	border-radius: 10px;
	background: #fff;
	color: var(--ksfc-text);
	font-size: 16px; /* 16px stops iOS zooming on focus */
	line-height: 1.3;
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	background-image: none;
	cursor: pointer;
}
.ksfc-select:focus { outline: none; border-color: var(--ksfc-accent); box-shadow: 0 0 0 3px rgba(31, 111, 92, 0.18); }

.ksfc-error { margin: 10px 0 0; color: #b32d2e; font-size: 14px; }
.ksfc-error[hidden] { display: none; }

.ksfc-actions {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 14px 24px 22px;
	border-top: 1px solid transparent;
}
.ksfc-btn {
	display: block;
	width: 100%;
	min-height: 50px;
	margin: 0;
	padding: 12px 18px;
	border-radius: 10px;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.2;
	text-transform: none;
	letter-spacing: normal;
	cursor: pointer;
	transition: filter 0.15s ease, background 0.15s ease;
}
.ksfc-btn-primary { border: 0; background: var(--ksfc-accent); color: #fff; }
.ksfc-btn-primary:hover { filter: brightness(1.08); }
.ksfc-btn-primary:disabled { opacity: 0.7; cursor: wait; }
.ksfc-btn-secondary { border: 1px solid var(--ksfc-border); background: #fff; color: var(--ksfc-text); }
.ksfc-btn-secondary:hover { background: #f6f7f7; }
.ksfc-btn:focus-visible { outline: 3px solid var(--ksfc-accent); outline-offset: 2px; }

/* Mobile: bottom sheet */
@media (max-width: 600px) {
	.ksfc-overlay { align-items: flex-end; padding: 0; }
	.ksfc-modal {
		max-width: none;
		max-height: 92vh;
		max-height: 92dvh;
		border-radius: 18px 18px 0 0;
		transform: translateY(100%);
		transition: transform 0.25s ease;
	}
	.ksfc-header { padding: 22px 52px 6px; }
	.ksfc-title { font-size: 20px; }
	.ksfc-body { padding: 10px 18px 6px; }
	.ksfc-image-wrap { max-width: 220px; }
	.ksfc-actions {
		position: sticky;
		bottom: 0;
		background: #fff;
		border-top-color: var(--ksfc-border);
		padding: 12px 18px calc(16px + env(safe-area-inset-bottom));
	}
}
@media (max-width: 600px) and (max-height: 640px) {
	.ksfc-image-wrap { max-width: 150px; }
}

/* Cart: free item styling */
.ksfc-full-price { opacity: 0.7; margin-right: 4px; text-decoration: line-through; }
.ksfc-full-price .amount, .ksfc-full-price bdi { text-decoration: line-through; }
ins.ksfc-free-price, .ksfc-free-price { text-decoration: none; background: none; font-weight: 700; }
.ksfc-locked-qty { display: inline-block; min-width: 2em; text-align: center; }

@media (prefers-reduced-motion: reduce) {
	.ksfc-overlay, .ksfc-modal { transition: none; }
}

/* Free items in carts / Bricks fly-in cart rows: full price struck out, then $0.00 */
del.ksfc-full-price,
del.ksfc-full-price *,
.ksfc-free-item del,
.ksfc-free-item del *,
.ksfc-free-item .woocommerce-Price-amount,
.ksfc-free-item .woocommerce-Price-amount * { text-decoration: line-through !important; }
.ksfc-free-item .ksfc-free-price,
.ksfc-free-item .ksfc-free-price *,
.ksfc-free-price .woocommerce-Price-amount,
.ksfc-free-price .woocommerce-Price-amount *,
ins.ksfc-free-price,
ins.ksfc-free-price * { text-decoration: none !important; }
.ksfc-free-item del, del.ksfc-full-price { opacity: 0.7; margin-right: 4px; }

/* "No free products configured" */
.ksfc-empty-body { padding: 40px 28px 8px; }
.ksfc-empty-body[hidden], .ksfc-body[hidden], .ksfc-header[hidden], .ksfc-btn[hidden] { display: none !important; }
.ksfc-empty-message { margin: 0; font-size: 18px; font-weight: 600; color: var(--ksfc-text); }
