/* Al Mahjar Core — Custom size on the product page (Almahjar_Custom_Size): the switch, then the panel with the figure on top
   (it follows what is typed) and the measurement fields under it. While it is on, the attributes it replaces are shown
   switched off. Tokens only. */
.almahjar-cs,
.almahjar-comp {
	--cs-ink: var(--almahjar-ink, #1d1a17);
	--cs-acc: var(--almahjar-copper, #b98770);
	--cs-card: var(--almahjar-card, #fff);
	--cs-soft: color-mix(in srgb, var(--cs-ink) 4.5%, var(--cs-card));
	--cs-line: var(--almahjar-line, rgba(0, 0, 0, 0.12));
	--cs-muted: var(--almahjar-taupe-deep, #6f665e);
	--cs-r: var(--almahjar-radius, 14px);
	flex: 1 1 100%;
	width: 100%;
	margin: 0 0 calc(14px * var(--almahjar-sp, 1));
	color: var(--cs-ink);
}

/* the switch */
.almahjar-cs .almahjar-cs-tog {
	all: unset;
	box-sizing: border-box;
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	align-items: center;
	gap: calc(12px * var(--almahjar-sp, 1));
	width: 100%;
	padding: 8px 14px 8px 8px;
	border: 1px solid var(--cs-line);
	border-radius: var(--cs-r);
	background: var(--cs-card);
	cursor: pointer;
	transition:
		border-color 0.2s,
		box-shadow 0.2s,
		background 0.2s;
}
.almahjar-cs .almahjar-cs-tog:hover {
	border-color: color-mix(in srgb, var(--cs-acc) 60%, var(--cs-line));
}
.almahjar-cs .almahjar-cs-tog:focus-visible {
	outline: 2px solid var(--cs-acc);
	outline-offset: 2px;
}
.almahjar-cs.is-on .almahjar-cs-tog {
	border-color: var(--cs-acc);
	background: color-mix(in srgb, var(--cs-acc) 6%, var(--cs-card));
}
.almahjar-cs-art {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: color-mix(in srgb, var(--cs-acc) 14%, var(--cs-card));
	color: var(--almahjar-copper-deep, var(--cs-acc));
}
.almahjar-cs-art svg {
	display: block;
	width: 22px;
	height: 22px;
}
.almahjar-cs-art .almahjar-cs-tape {
	transition: stroke-dashoffset 0.6s ease;
}
.almahjar-cs-tog:hover .almahjar-cs-tape,
.almahjar-cs.is-on .almahjar-cs-tape {
	stroke-dashoffset: -6.4;
}
.almahjar-cs.is-on .almahjar-cs-art {
	background: var(--cs-acc);
	color: var(--almahjar-on-copper, #fff);
}
.almahjar-cs-tt {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
	line-height: 1.3;
}
.almahjar-cs-tt b {
	font-size: calc(14px * var(--almahjar-fs, 1));
	font-weight: 600;
}
.almahjar-cs-tt small {
	font-size: calc(12.5px * var(--almahjar-fs, 1));
	color: var(--cs-muted);
}
.almahjar-cs-sw {
	position: relative;
	width: 40px;
	height: 23px;
	border-radius: 999px;
	background: var(--cs-line);
	transition: background 0.2s;
}
.almahjar-cs-sw i {
	position: absolute;
	top: 3px;
	left: 3px;
	width: 17px;
	height: 17px;
	border-radius: 50%;
	background: var(--cs-card);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
	transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.almahjar-cs.is-on .almahjar-cs-sw {
	background: var(--cs-acc);
}
.almahjar-cs.is-on .almahjar-cs-sw i {
	transform: translateX(17px);
}

/* the panel */
.almahjar-cs-panel {
	display: flex;
	flex-direction: column;
	gap: calc(12px * var(--almahjar-sp, 1));
	margin-top: calc(8px * var(--almahjar-sp, 1));
	padding: calc(14px * var(--almahjar-sp, 1));
	border: 1px solid var(--cs-line);
	border-radius: var(--cs-r);
	background: var(--cs-card);
	animation: almahjar-cs-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.almahjar-cs-panel[hidden] {
	display: none;
}
@keyframes almahjar-cs-in {
	from {
		opacity: 0;
		transform: translateY(-6px);
	}
}
.almahjar-cs-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}
.almahjar-cs-lbl {
	margin: 0;
	font-size: calc(12px * var(--almahjar-fs, 1));
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--cs-muted);
}
.almahjar-cs-unit {
	display: inline-flex;
	padding: 3px;
	border-radius: 999px;
	background: var(--cs-soft);
}
.almahjar-cs-unit label {
	margin: 0;
	cursor: pointer;
}
.almahjar-cs-unit input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}
.almahjar-cs-unit span {
	display: block;
	padding: 3px 12px;
	border-radius: 999px;
	font-size: calc(12.5px * var(--almahjar-fs, 1));
	font-weight: 600;
	color: var(--cs-muted);
}
.almahjar-cs-unit input:checked + span {
	background: var(--cs-ink);
	color: var(--almahjar-on-ink, #fff);
}
.almahjar-cs-unit input:focus-visible + span {
	outline: 2px solid var(--cs-acc);
}

/* the figure: centred above the fields */
.almahjar-cs-fig {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	margin: 0;
	padding: calc(10px * var(--almahjar-sp, 1)) 8px 8px;
	border-radius: calc(var(--cs-r) * 0.8);
	background: var(--cs-soft);
}
.almahjar-cs-fig .almahjar-sg-fig {
	display: block;
	width: auto;
	max-width: 100%;
	height: min(300px, 44vh);
	margin: 0 auto;
}
.almahjar-cs-fig .almahjar-sg-m {
	cursor: pointer;
}
.almahjar-cs-tip {
	margin: 0;
	font-size: calc(12px * var(--almahjar-fs, 1));
	color: var(--cs-muted);
	text-align: center;
	transition: opacity 0.2s;
}
.almahjar-cs-fig.has-v .almahjar-cs-tip {
	opacity: 0;
	height: 0;
	overflow: hidden;
}

/* the fields */
.almahjar-cs-list {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
}
.almahjar-cs-f {
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin: 0;
	padding: 6px 6px 6px 12px;
	border: 1px solid var(--cs-line);
	border-radius: calc(var(--cs-r) * 0.7);
	transition:
		border-color 0.15s,
		box-shadow 0.15s;
}
.almahjar-cs-f:focus-within {
	border-color: var(--cs-acc);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--cs-acc) 18%, transparent);
}
.almahjar-cs-f.is-bad {
	border-color: var(--almahjar-brick-deep, #9b3b2e);
}
.almahjar-cs-f.is-text {
	flex-direction: column;
	align-items: stretch;
	padding: 10px 12px;
}
.almahjar-cs-n {
	min-width: 0;
	font-size: calc(13.5px * var(--almahjar-fs, 1));
	font-weight: 500;
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.almahjar-cs-in {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 6px;
}
.almahjar-cs .almahjar-cs-in input,
.almahjar-cs .almahjar-cs-f input[type="text"],
.almahjar-cs .almahjar-cs-note textarea {
	box-sizing: border-box;
	width: 100%;
	min-height: 36px;
	margin: 0;
	padding: 6px 10px;
	border: 1px solid var(--cs-line);
	border-radius: calc(var(--cs-r) * 0.55);
	background: var(--cs-soft);
	color: inherit;
	font: inherit;
	font-size: calc(15px * var(--almahjar-fs, 1));
	box-shadow: none;
}
.almahjar-cs .almahjar-cs-in input {
	width: 72px;
	min-height: 34px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	text-align: center;
}
.almahjar-cs-u {
	flex: none;
	min-width: 20px;
	font-style: normal;
	font-size: calc(12.5px * var(--almahjar-fs, 1));
	color: var(--cs-muted);
}
.almahjar-cs-note {
	font-size: calc(13px * var(--almahjar-fs, 1));
}
.almahjar-cs-note summary {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
	list-style: none;
	color: var(--cs-muted);
	text-decoration: underline;
	text-underline-offset: 3px;
}
.almahjar-cs-note summary::-webkit-details-marker {
	display: none;
}
.almahjar-cs-note[open] summary {
	margin-bottom: 8px;
}
.almahjar-cs .almahjar-cs-note textarea {
	display: block;
	font-size: calc(14px * var(--almahjar-fs, 1));
}
.almahjar-cs-err {
	margin: 0;
	color: var(--almahjar-brick-deep, #9b3b2e);
	font-size: calc(13px * var(--almahjar-fs, 1));
}
.almahjar-cs-err[hidden] {
	display: none;
}

/* lists the shop adds (lining, fabric…): the same box as the measurements, with its own arrow */
.almahjar-cs .almahjar-cs-f select {
	box-sizing: border-box;
	min-height: 38px;
	margin: 0;
	padding: 6px 34px 6px 12px;
	border: 1px solid var(--cs-line);
	border-radius: calc(var(--cs-r) * 0.55);
	background: var(--cs-card, #fff)
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")
		no-repeat right 10px center/16px;
	color: inherit;
	font: inherit;
	line-height: 1.3;
	-webkit-appearance: none;
	appearance: none;
	box-shadow: none;
}
[dir="rtl"] .almahjar-cs .almahjar-cs-f select {
	padding: 6px 12px 6px 34px;
	background-position: left 10px center;
}
.almahjar-cs .almahjar-cs-f select:focus {
	outline: none;
	border-color: var(--cs-acc);
}

/* narrow: the name above its box, still two to a row; boxes a finger can hit, with 16px text so phones do not zoom in */
@media (max-width: 440px) {
	.almahjar-cs-f {
		flex-direction: column;
		align-items: stretch;
		gap: 6px;
		padding: 10px;
	}
	.almahjar-cs-in {
		width: 100%;
	}
	.almahjar-cs .almahjar-cs-in input {
		flex: 1;
		width: auto;
		min-width: 0;
	}
	.almahjar-cs .almahjar-cs-in input,
	.almahjar-cs .almahjar-cs-f input[type="text"],
	.almahjar-cs .almahjar-cs-f select,
	.almahjar-cs .almahjar-cs-note textarea {
		min-height: 44px;
		font-size: 16px;
		background-color: var(--cs-card, #fff);
	}
	.almahjar-cs-n {
		white-space: normal;
	}
	.almahjar-cs-fig .almahjar-sg-fig {
		height: min(220px, 36vh);
	}
}

/* the attributes the custom size replaces: switched off while it is on */
.almahjar-cs-off {
	position: relative;
}
.almahjar-cs-off > *:not(.label, th) {
	opacity: 0.38;
	filter: grayscale(1);
	pointer-events: none;
}
.almahjar-cs-off .almahjar-pp-sel {
	display: none;
}
.almahjar-cs-off .almahjar-pp-sw[aria-pressed="true"] {
	border-color: var(--almahjar-line, rgba(0, 0, 0, 0.12));
	background: var(--almahjar-card, #fff);
	color: inherit;
	box-shadow: none;
} /* the hidden stand-in choice does not look picked */
.almahjar-cs-off td.value,
.almahjar-cs-off .value {
	position: relative;
}
.almahjar-cs-off::after {
	content: attr(data-cs-off);
	position: absolute;
	right: 0;
	top: 4px;
	padding: 2px 10px;
	border-radius: 999px;
	background: color-mix(in srgb, var(--almahjar-copper, #b98770) 14%, var(--almahjar-card, #fff));
	color: var(--almahjar-copper-deep, #8a5d48);
	font-size: calc(11.5px * var(--almahjar-fs, 1));
	font-weight: 600;
	white-space: nowrap;
	opacity: 1;
	filter: none;
}
tr.almahjar-cs-off::after {
	top: 6px;
}

@media (prefers-reduced-motion: reduce) {
	.almahjar-cs-art .almahjar-cs-tape,
	.almahjar-cs-panel {
		transition: none;
		animation: none;
	}
}
/* admin pill */
.almahjar-cs-pill {
	border-style: dashed;
}
/* extra fields the shop asks for (number with a unit, list, colour, pictures, yes / no) */
.almahjar-cs-f.is-x {
	margin-top: 10px;
}
.almahjar-cs-f.is-x select,
.almahjar-cs-f.is-x input[type="text"] {
	width: 100%;
}
.almahjar-cs-n small {
	font-weight: 400;
	opacity: 0.65;
}
.almahjar-cs-u2 {
	font-style: normal;
	opacity: 0.7;
	margin-left: 6px;
}
.almahjar-cs-f.is-color input[type="color"] {
	width: 56px;
	height: 36px;
	padding: 2px;
	border-radius: 8px;
}
.almahjar-cs-yn {
	display: flex;
	gap: 16px;
}
.almahjar-cs-yn label {
	display: inline-flex;
	gap: 6px;
	align-items: center;
}
.almahjar-cs-pics {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}
.almahjar-cs-pics label {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	width: 76px;
	cursor: pointer;
	text-align: center;
	font-size: 11px;
}
.almahjar-cs-pics input {
	position: absolute;
	opacity: 0;
}
.almahjar-cs-pics img {
	width: 72px;
	height: 72px;
	object-fit: cover;
	border-radius: 10px;
	border: 1px solid var(--almahjar-line, #e3ddd6);
}
.almahjar-cs-pics label:has(input:checked) img {
	border-color: var(--almahjar-ink, #111);
	box-shadow: 0 0 0 2px var(--almahjar-ink, #111);
}
.almahjar-cs-pics label:has(input:focus-visible) img {
	outline: 2px solid var(--almahjar-copper, #b98770);
	outline-offset: 2px;
}
.almahjar-cs-f.is-x select {
	width: auto;
	flex: 0 1 220px;
	min-width: 140px;
}
.almahjar-cs-f.is-x > .almahjar-cs-n {
	flex: 1 1 auto;
	min-width: 90px;
}
.almahjar-cs-f.is-x .almahjar-cs-in input {
	width: 84px;
}

/* reference photos (Almahjar_Custom_Size: photos of the style wanted) */
.almahjar-cs-ph .almahjar-cs-phs {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 6px 0;
}
.almahjar-cs-phi {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 64px;
	height: 64px;
	border-radius: 10px;
	overflow: hidden;
	background: var(--almahjar-tint, #f6f2ed);
	font-size: 11px;
	color: var(--almahjar-taupe-deep, #6f665e);
}
.almahjar-cs-phi img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.almahjar-cs-phi.is-busy {
	animation: almahjar-cs-pulse 1s ease-in-out infinite alternate;
}
@keyframes almahjar-cs-pulse {
	to {
		opacity: 0.55;
	}
}
.almahjar-cs-phx {
	position: absolute;
	top: 3px;
	inset-inline-end: 3px;
	width: 20px;
	height: 20px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	font-size: 13px;
	line-height: 20px;
	cursor: pointer;
}
.almahjar-cs-phadd {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	border: 1px dashed currentColor;
	border-radius: var(--almahjar-pill, 999px);
	cursor: pointer;
	font-size: 13px;
	width: max-content;
}
.almahjar-cs-phadd input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	pointer-events: none;
}
.almahjar-cs-phadd[hidden] {
	display: none;
}
.almahjar-cs-phadd:focus-within {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* narrow, after the extra-field rules above: in a column the 220px basis of a list would become its height */
@media (max-width: 440px) {
	.almahjar-cs-f.is-x select {
		flex: none;
		width: 100%;
		min-width: 0;
	}
	.almahjar-cs-f.is-x .almahjar-cs-in input {
		width: auto;
	}
}
/* the photos field: its label on its own line (it was cut short beside the button in narrow places like the quick view), the photos and "+ Add a photo" under it */
.almahjar-cs-f.almahjar-cs-ph {
	flex-wrap: wrap;
	align-items: center;
	row-gap: 10px;
}
.almahjar-cs-ph > .almahjar-cs-n {
	flex: 1 1 100%;
	min-width: 0;
	white-space: normal;
	overflow: visible;
	text-overflow: clip;
}
.almahjar-cs-ph .almahjar-cs-phs {
	margin: 0;
}
.almahjar-cs-ph .almahjar-cs-phs:empty {
	display: none;
}
.almahjar-cs-ph .almahjar-cs-phadd {
	white-space: nowrap;
}
/* Confirm measurements, and the summary that takes the panel's place once confirmed */
.almahjar-cs-ok {
	width: 100%;
	min-height: 48px;
	border-radius: var(--almahjar-pill, 999px) !important;
	text-transform: none;
}
.almahjar-cs-panel.is-done > :not(.almahjar-cs-sum) {
	display: none !important;
}
.almahjar-cs-sum[hidden] {
	display: none;
}
.almahjar-cs-sum {
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.almahjar-cs-sum-t {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	font-weight: 600;
	color: #1f6b3d;
}
.almahjar-cs-sum-l {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
	gap: 6px 14px;
	font-size: calc(14px * var(--almahjar-fs, 1));
}
.almahjar-cs-sum-l li {
	display: flex;
	justify-content: space-between;
	gap: 8px;
	border-bottom: 1px dashed var(--almahjar-line, #e6e1d8);
	padding: 4px 0;
	unicode-bidi: plaintext;
}
.almahjar-cs-sum-l li span {
	color: var(--almahjar-muted, #777);
}
.almahjar-cs-edit {
	align-self: flex-start;
	background: none !important;
	border: 0 !important;
	padding: 0 !important;
	min-height: 0 !important;
	color: inherit !important;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}
