/**
 * Wolf Product Fields 1.3.0 — product option cards (simple products) and the confirmation popup.
 *
 * Inherits the theme's font, size and colours (currentColor); the accent is the theme's primary
 * colour where it publishes one (Woodmart: --wd-primary-color), otherwise the text colour.
 * Logical properties only, so the layout mirrors itself in RTL and LTR. No !important.
 */

.wpf-options,
.wpf-opt-modal {
	--wpf-opt-accent: var(--wd-primary-color, currentColor);
	--wpf-opt-line: rgba(127, 127, 127, 0.35);
	--wpf-opt-radius: var(--wd-brd-radius, 10px);
}

@supports (color: color-mix(in srgb, red 50%, blue)) {
	.wpf-options,
	.wpf-opt-modal {
		--wpf-opt-line: color-mix(in srgb, currentColor 22%, transparent);
	}
}

.wpf-options {
	inline-size: 100%;
	max-inline-size: 100%;
	box-sizing: border-box;
	margin: 0 0 1rem;
	text-align: start;
}

.wpf-opt-group {
	margin: 0 0 1rem;
	padding: 0;
	border: 0;
	min-inline-size: 0;
}

.wpf-opt-group__title {
	margin: 0 0 0.5rem;
	font-weight: 600;
	line-height: 1.4;
}

.wpf-opt-group__hint {
	font-weight: 400;
	font-size: 0.85em;
	opacity: 0.7;
}

.wpf-opt-group .wpf-required {
	color: #c0392b;
}

.wpf-opt-group__error,
.wpf-opt-error {
	margin: 0.4rem 0 0;
	color: #c0392b;
	font-size: 0.9em;
}

.wpf-opt-error {
	margin: 0 0 0.75rem;
}

.wpf-opt-group.is-error .wpf-opt-card {
	border-color: #c0392b;
}

.wpf-opt-cards {
	display: grid;
	gap: 0.5rem;
	inline-size: 100%;
	min-inline-size: 0;
}

.wpf-opt-card {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0.75rem;
	box-sizing: border-box;
	inline-size: 100%;
	min-inline-size: 0;
	min-block-size: 3.5rem;
	margin: 0;
	padding: 0.625rem 0.875rem;
	border: 1px solid var(--wpf-opt-line);
	border-radius: var(--wpf-opt-radius);
	background: transparent;
	color: inherit;
	font: inherit;
	line-height: 1.4;
	text-align: start;
	cursor: pointer;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.wpf-opt-card:hover {
	border-color: var(--wpf-opt-accent);
}

.wpf-opt-card.is-selected,
.wpf-opt-card:has(.wpf-opt-card__input:checked) {
	border-color: var(--wpf-opt-accent);
	box-shadow: inset 0 0 0 1px var(--wpf-opt-accent);
}

@supports (color: color-mix(in srgb, red 50%, blue)) {
	.wpf-opt-card.is-selected,
	.wpf-opt-card:has(.wpf-opt-card__input:checked) {
		background: color-mix(in srgb, var(--wpf-opt-accent) 7%, transparent);
	}
}

.wpf-opt-card.is-focused,
.wpf-opt-card:has(.wpf-opt-card__input:focus-visible) {
	outline: 2px solid var(--wpf-opt-accent);
	outline-offset: 2px;
}

.wpf-opt-card.is-focused:has(.wpf-opt-card__input:not(:focus-visible)) {
	outline: none;
}

/* The real radio / checkbox: invisible but focusable (arrow keys, Space, Tab, screen readers). */
.wpf-opt-card__input {
	position: absolute;
	inset-block-start: 50%;
	inset-inline-start: 0.5rem;
	inline-size: 1px;
	block-size: 1px;
	margin: 0;
	padding: 0;
	opacity: 0;
	pointer-events: none;
	clip-path: inset(50%);
}

/* A check mark shows which add-ons are ticked (not colour alone). */
.wpf-opt-group--multi .wpf-opt-card::before {
	content: "";
	flex: 0 0 auto;
	inline-size: 1.1rem;
	block-size: 1.1rem;
	box-sizing: border-box;
	border: 1.5px solid currentColor;
	border-radius: 4px;
	opacity: 0.6;
}

.wpf-opt-group--multi .wpf-opt-card.is-selected::before {
	opacity: 1;
	border-color: var(--wpf-opt-accent);
	background: var(--wpf-opt-accent);
	box-shadow: inset 0 0 0 2px var(--wp--preset--color--base, #fff);
}

.wpf-opt-group--single .wpf-opt-card::before {
	content: "";
	flex: 0 0 auto;
	inline-size: 1.1rem;
	block-size: 1.1rem;
	box-sizing: border-box;
	border: 1.5px solid currentColor;
	border-radius: 50%;
	opacity: 0.6;
}

.wpf-opt-group--single .wpf-opt-card.is-selected::before {
	opacity: 1;
	border-color: var(--wpf-opt-accent);
	background: var(--wpf-opt-accent);
	box-shadow: inset 0 0 0 3px var(--wp--preset--color--base, #fff);
}

.wpf-opt-card__icon {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	inline-size: 2.5rem;
	block-size: 2.5rem;
	color: var(--wpf-opt-accent);
}

.wpf-opt-card__icon:empty {
	visibility: hidden;
}

.wpf-opt-icon {
	display: block;
	inline-size: 2rem;
	block-size: 2rem;
	overflow: visible;
}

.wpf-opt-icon text {
	font-family: inherit;
}

.wpf-opt-card__text {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 0.125rem;
	min-inline-size: 0;
}

.wpf-opt-card__name {
	font-weight: 600;
	overflow-wrap: anywhere;
}

.wpf-opt-card__desc {
	font-size: 0.85em;
	opacity: 0.75;
	overflow-wrap: anywhere;
}

.wpf-opt-card__price {
	flex: 0 1 auto;
	margin-inline-start: auto;
	font-weight: 600;
	text-align: end;
	white-space: nowrap;
}

.wpf-opt-card__price del {
	font-weight: 400;
}

.wpf-opt-card__plus {
	margin-inline-end: 0.15em;
}

@media (max-width: 420px) {
	.wpf-opt-card {
		gap: 0.5rem;
		padding-inline: 0.625rem;
	}

	.wpf-opt-card__price {
		white-space: normal;
	}
}

/* "يبدأ من" leads even when the converter turns a sale price into a reordered flex row. */
.wpf-price-from {
	font-size: 0.85em;
	font-weight: 400;
	opacity: 0.8;
}

.wsc-price--sale .wpf-price-from {
	order: -2;
}

/* ─── Confirmation popup (1.3.2) ─────────────────────────────────────────────────────────────
   Colours are taken from the page by options.js (surface, text, accent), so the card is light on
   a light page and dark on a dark one (Woodmart dark mode included). */

.wpf-opt-modal {
	box-sizing: border-box;
	inline-size: min(26rem, calc(100vw - 2rem));
	max-block-size: calc(100vh - 2rem);
	margin: auto;
	padding: 0;
	border: 1px solid var(--wpf-opt-line, rgba(127, 127, 127, 0.25));
	border-radius: 20px;
	background: var(--wpf-opt-surface, var(--wp--preset--color--base, #fff));
	color: var(--wpf-opt-text, inherit);
	font: inherit;
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.12);
	overflow: auto;
}

.wpf-opt-modal[open] {
	animation: wpf-opt-modal-in 180ms ease-out;
}

.wpf-opt-modal::backdrop {
	background: rgba(0, 0, 0, 0.55);
	-webkit-backdrop-filter: blur(3px);
	backdrop-filter: blur(3px);
	animation: wpf-opt-backdrop-in 180ms ease-out;
}

@keyframes wpf-opt-modal-in {
	from {
		opacity: 0;
		transform: scale(0.96);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

@keyframes wpf-opt-backdrop-in {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

.wpf-opt-modal--fallback {
	position: fixed;
	inset: 0;
	z-index: 100000;
	block-size: fit-content;
}

.wpf-opt-modal__inner {
	position: relative;
	padding: 24px;
	text-align: center;
}

.wpf-opt-modal .wpf-opt-modal__close {
	position: absolute;
	inset-block-start: 12px;
	inset-inline-end: 12px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	inline-size: 36px;
	block-size: 36px;
	min-block-size: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--wpf-opt-muted, currentColor);
	box-shadow: none;
	line-height: 1;
	cursor: pointer;
}

.wpf-opt-modal .wpf-opt-modal__close:hover {
	background: var(--wpf-opt-line, rgba(127, 127, 127, 0.2));
	color: var(--wpf-opt-text, currentColor);
}

.wpf-opt-modal__badge {
	display: flex;
	align-items: center;
	justify-content: center;
	inline-size: 56px;
	block-size: 56px;
	margin: 4px auto 14px;
	border-radius: 50%;
	background: var(--wpf-opt-accent-soft, rgba(127, 127, 127, 0.15));
	color: var(--wpf-opt-accent, currentColor);
}

.wpf-opt-modal__badge .wpf-opt-icon {
	inline-size: 28px;
	block-size: 28px;
}

.wpf-opt-modal__badge:empty {
	display: none;
}

.wpf-opt-modal .wpf-opt-modal__title {
	margin: 0 0 10px;
	color: var(--wpf-opt-text, inherit);
	font-size: 1.2em;
	font-weight: 700;
	line-height: 1.45;
	text-align: center;
}

.wpf-opt-modal__body {
	color: var(--wpf-opt-muted, inherit);
	line-height: 1.8;
	overflow-wrap: anywhere;
}

.wpf-opt-modal__body strong,
.wpf-opt-modal__body b {
	color: var(--wpf-opt-text, inherit);
	font-weight: 700;
}

.wpf-opt-modal__body a {
	color: var(--wpf-opt-accent, inherit);
	text-decoration: underline;
}

.wpf-opt-modal__body > :first-child {
	margin-block-start: 0;
}

.wpf-opt-modal__body > :last-child {
	margin-block-end: 0;
}

.wpf-opt-modal__body ul,
.wpf-opt-modal__body ol {
	display: inline-block;
	margin-block: 0.5rem;
	padding-inline-start: 1.25rem;
	text-align: start;
}

.wpf-opt-modal__actions {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-block-start: 22px;
}

.wpf-opt-modal .wpf-opt-modal__confirm,
.wpf-opt-modal .wpf-opt-modal__cancel {
	box-sizing: border-box;
	inline-size: 100%;
	min-block-size: 48px;
	margin: 0;
	padding: 10px 16px;
	border-radius: 12px;
	font: inherit;
	font-size: 1em;
	line-height: 1.3;
	letter-spacing: normal;
	text-align: center;
	text-transform: none;
	white-space: nowrap;
	box-shadow: none;
	cursor: pointer;
	transition: filter 0.15s ease, background-color 0.15s ease;
}

.wpf-opt-modal .wpf-opt-modal__confirm {
	border: 1px solid var(--wpf-opt-accent, currentColor);
	background: var(--wpf-opt-accent, currentColor);
	color: var(--wpf-opt-on-accent, #fff);
	font-weight: 700;
}

.wpf-opt-modal .wpf-opt-modal__confirm:hover {
	filter: brightness(1.08);
}

.wpf-opt-modal .wpf-opt-modal__cancel {
	border: 1px solid var(--wpf-opt-line, rgba(127, 127, 127, 0.35));
	background: transparent;
	color: var(--wpf-opt-text, inherit);
	font-weight: 500;
}

.wpf-opt-modal .wpf-opt-modal__cancel:hover {
	background: var(--wpf-opt-line, rgba(127, 127, 127, 0.12));
}

.wpf-opt-modal button:focus-visible {
	outline: 2px solid var(--wpf-opt-accent, currentColor);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.wpf-opt-card,
	.wpf-opt-modal .wpf-opt-modal__confirm,
	.wpf-opt-modal .wpf-opt-modal__cancel {
		transition: none;
	}

	.wpf-opt-modal[open],
	.wpf-opt-modal::backdrop {
		animation: none;
	}
}
