/* Gift Wrap for WooCommerce (Lightblack) – product page card.
   Colours come from the settings as CSS variables on .lbgw:
   --lbgw-accent (border, icon, subtitle, tick), --lbgw-tint / --lbgw-tint-on (background), --lbgw-line (dashed border). */

.lbgw {
	--lbgw-accent: #aa2327;
	--lbgw-tint: #fbf0f0;
	--lbgw-tint-on: #f7e9e9;
	--lbgw-line: #d89a9c;

	box-sizing: border-box;
	flex: 0 0 100%;
	width: 100%;
	max-width: 100%;
	margin: 0 0 14px;
	padding: 14px 18px;
	border: 1px dashed var(--lbgw-line);
	border-radius: 8px;
	background: var(--lbgw-tint);
	text-align: start;
	transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

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

.lbgw:hover {
	border-color: var(--lbgw-accent);
}

.lbgw.lbgw-on,
.lbgw:has(.lbgw-checkbox:checked) {
	border-style: solid;
	border-color: var(--lbgw-accent);
	background: var(--lbgw-tint-on);
	box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}

/* Elementor Pro and many themes put the form on one flex row (quantity + button) without
   wrapping: let the gift box take its own full-width line above them.
   - row-gap 0: the box's own bottom margin is the space above the quantity row (else the theme's
     gap is added to it and the space doubles).
   - WooCommerce's clearfix ::before / ::after become empty flex items: ::before adds a gap above the
     box; ::after (order 0) lands in front of the quantity when the theme orders quantity / button
     (Elementor: 1 / 2) and pushes it in from the left. ::before off, ::after moved to the end
     ("order" does nothing outside flex, so float layouts still clear). */
form.cart:has(> .lbgw),
.woocommerce-variation-add-to-cart:has(> .lbgw),
.lbgw-wrap-parent {
	flex-wrap: wrap !important;
	row-gap: 0 !important;
}

form.cart:has(> .lbgw)::before,
.woocommerce-variation-add-to-cart:has(> .lbgw)::before,
.lbgw-wrap-parent::before {
	display: none !important;
}

form.cart:has(> .lbgw)::after,
.woocommerce-variation-add-to-cart:has(> .lbgw)::after,
.lbgw-wrap-parent::after {
	order: 999;
}

/* Header: icon | title + subtitle | tick box. The whole row is the clickable label. */
.lbgw .lbgw-head {
	display: flex;
	align-items: center;
	gap: 14px;
	width: 100%;
	margin: 0;
	padding: 0;
	cursor: pointer;
	font-weight: normal;
	line-height: 1.3;
	-webkit-tap-highlight-color: transparent;
}

.lbgw .lbgw-icon {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: #fff;
	color: var(--lbgw-accent);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.lbgw .lbgw-icon svg {
	display: block;
	width: 22px;
	height: 22px;
}

.lbgw .lbgw-text {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 3px;
	min-width: 0;
}

.lbgw .lbgw-title {
	color: #1f1f1f;
	font-size: 16px;
	font-weight: 700;
}

.lbgw .lbgw-price {
	display: inline-block;
	margin-inline-start: 6px;
	color: var(--lbgw-accent);
	font-weight: 700;
	white-space: nowrap;
}

.lbgw .lbgw-sub {
	color: var(--lbgw-accent);
	font-size: 14px;
}

.lbgw .lbgw-checkbox {
	-webkit-appearance: none;
	appearance: none;
	flex: 0 0 auto;
	width: 24px;
	height: 24px;
	margin: 0;
	padding: 0;
	border: 2px solid var(--lbgw-line);
	border-radius: 6px;
	background: #fff center / 14px 14px no-repeat;
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.lbgw .lbgw-head:hover .lbgw-checkbox {
	border-color: var(--lbgw-accent);
}

.lbgw .lbgw-checkbox:checked {
	border-color: var(--lbgw-accent);
	background-color: var(--lbgw-accent);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round' d='M3 8.5l3.2 3L13 4.5'/%3E%3C/svg%3E");
}

.lbgw .lbgw-checkbox:focus {
	outline: none;
}

.lbgw .lbgw-checkbox:focus-visible {
	outline: 2px solid var(--lbgw-accent);
	outline-offset: 2px;
}

/* Message field, inside the card under a dashed line. */
.lbgw .lbgw-fields {
	margin-top: 14px;
	padding-top: 14px;
	border-top: 1px dashed var(--lbgw-line);
}

.lbgw .lbgw-message-label {
	display: block;
	margin: 0 0 6px;
	color: #1f1f1f;
	font-size: 14px;
	font-weight: 600;
}

.lbgw .lbgw-message-label .required {
	color: var(--lbgw-accent);
	text-decoration: none;
	border: 0;
}

.lbgw .lbgw-message {
	overflow-wrap: anywhere;
	display: block;
	width: 100%;
	max-width: 100%;
	min-height: 76px;
	margin: 0;
	padding: 10px 12px;
	border: 1px solid var(--lbgw-line);
	border-radius: 6px;
	background: #fff;
	color: #1f1f1f;
	font: inherit;
	font-size: 15px;
	line-height: 1.4;
	resize: vertical;
	box-shadow: none;
}

.lbgw .lbgw-message:focus {
	border-color: var(--lbgw-accent);
	outline: none;
	box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.04);
}

.lbgw .lbgw-counter {
	display: block;
	margin-top: 5px;
	color: #6b6b6b;
	font-size: 13px;
	text-align: end;
}

/* Message field only while the box is ticked. Current browsers decide from the checkbox itself
   (no JavaScript needed, always in step, also when the browser restores a ticked box after a
   reload or Back). Older browsers without :has() use the class set by the JavaScript. */
.lbgw:has(.lbgw-checkbox:not(:checked)) .lbgw-fields {
	display: none;
}

@supports not selector(:has(a)) {
	.lbgw.lbgw-ready:not(.lbgw-on) .lbgw-fields {
		display: none;
	}
}

@media (max-width: 480px) {
	.lbgw {
		padding: 12px 14px;
	}

	.lbgw .lbgw-head {
		gap: 12px;
	}

	.lbgw .lbgw-icon {
		width: 40px;
		height: 40px;
	}

	.lbgw .lbgw-title {
		font-size: 15px;
	}

	.lbgw .lbgw-sub {
		font-size: 13px;
	}
}
