/*
 * Competition: Ticket picker: structure only.
 *
 * Text colour, size and spacing are the block's own supports, set by the
 * theme in theme.json styles.blocks["zapc/ticket-picker"]. The slider track
 * reads the progress bar's tokens (`settings.custom.progress`), so the two
 * bars match, and the figures' captions read the Label look's
 * (`settings.custom.label`). Its own tokens, from
 * `settings.custom.ticketPicker`, each with a fallback:
 *   --wp--custom--ticket-picker--gap         between the strip and the slider (XS)
 *   --wp--custom--ticket-picker--accent      the odds figure
 *   --wp--custom--ticket-picker--surface     the strip behind the figures, and the minus and plus
 *   --wp--custom--ticket-picker--border      the lines between the figures (the framework's
 *                                            border, `settings.custom.border`)
 *   --wp--custom--ticket-picker--step-border round the minus and plus (the form fields'
 *                                            border, `settings.custom.input`)
 *   --wp--custom--ticket-picker--fill        the slider's filled part (accent)
 *   --wp--custom--ticket-picker--thumb       the slider handle
 *   --wp--custom--ticket-picker--thumb-ring  a ring round the handle (none)
 *   --wp--custom--ticket-picker--thumb-shadow  a shadow under the handle (none)
 */

.wp-block-zapc-ticket-picker {
	display: grid;
	/* Its own gap: the inherited block gap is the page's, far wider than a control wants. */
	gap: var(--wp--custom--ticket-picker--gap, var(--wp--preset--spacing--xs, 0.5rem));
	/* em: the handle scales with the block's font size. */
	--zapc-ticket-picker-thumb: 1.75em;
	--zapc-ticket-picker-track: var(--wp--custom--progress--height, 0.5rem);
}

/*
 * The Add to Cart button under the picker sits one picker gap away. The form
 * has no block gap setting of its own, and a margin set on the button block
 * lands on its inner button, on top of the page's gap.
 */
.wp-block-zapc-ticket-picker + .wp-block-button {
	margin-block-start: var(--wp--custom--ticket-picker--gap, var(--wp--preset--spacing--xs, 0.5rem));
}

/* Each figure takes a third, and grows past it before its number wraps. */
.wp-block-zapc-ticket-picker__strip {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: minmax(max-content, 1fr);
	border-radius: var(--wp--preset--border-radius--m, 0.5rem);
	background: var(--wp--custom--ticket-picker--surface, var(--wp--custom--surface--tint, color-mix(in srgb, currentColor 8%, transparent)));
}

.wp-block-zapc-ticket-picker__figure {
	display: grid;
	padding: var(--wp--preset--spacing--xs, 0.5rem) var(--wp--preset--spacing--s, 0.75rem);
}

.wp-block-zapc-ticket-picker__figure + .wp-block-zapc-ticket-picker__figure {
	border-inline-start: var(--wp--custom--border--width, 1px) solid var(--wp--custom--ticket-picker--border, var(--wp--custom--border--color, color-mix(in srgb, currentColor 10%, transparent))); /* px: hairline fallback */
}

.wp-block-zapc-ticket-picker__key {
	font-size: var(--wp--custom--label--font-size, 0.7em);
	font-weight: var(--wp--custom--label--font-weight, 700);
	letter-spacing: var(--wp--custom--label--letter-spacing, 0.08em);
	text-transform: uppercase;
	color: var(--wp--custom--label--color, color-mix(in srgb, currentColor 70%, transparent));
}

/* em: the figure scales with the block's font size. */
.wp-block-zapc-ticket-picker__value {
	font-size: 1.25em;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.wp-block-zapc-ticket-picker__value.is-accent {
	color: var(--wp--custom--ticket-picker--accent, currentColor);
}

.wp-block-zapc-ticket-picker__row {
	display: flex;
	align-items: center;
	gap: var(--wp--preset--spacing--s, 0.75rem);
}

.wp-block-zapc-ticket-picker__range {
	-webkit-appearance: none;
	appearance: none;
	flex: 1;
	min-inline-size: 0;
	block-size: var(--zapc-ticket-picker-thumb);
	margin: 0;
	background: transparent;
	cursor: pointer;
}

/* The fill stops at the handle's centre: the handle travels the track less its own width. */
.wp-block-zapc-ticket-picker__range::-webkit-slider-runnable-track {
	--zapc-ticket-picker-stop: calc(var(--zapc-ticket-picker-thumb) / 2 + (100% - var(--zapc-ticket-picker-thumb)) * var(--zapc-ticket-picker-fill, 0));
	height: var(--zapc-ticket-picker-track);
	border-radius: var(--wp--custom--progress--radius, 999px);
	background:
		linear-gradient(var(--wp--custom--ticket-picker--fill, var(--wp--custom--ticket-picker--accent, currentColor)) 0 0) 0 / var(--zapc-ticket-picker-stop) 100% no-repeat,
		var(--wp--custom--progress--track, color-mix(in srgb, currentColor 15%, transparent));
}

.wp-block-zapc-ticket-picker__range::-moz-range-track {
	height: var(--zapc-ticket-picker-track);
	border-radius: var(--wp--custom--progress--radius, 999px);
	background: var(--wp--custom--progress--track, color-mix(in srgb, currentColor 15%, transparent));
}

.wp-block-zapc-ticket-picker__range::-moz-range-progress {
	height: var(--zapc-ticket-picker-track);
	border-radius: var(--wp--custom--progress--radius, 999px);
	background: var(--wp--custom--ticket-picker--fill, var(--wp--custom--ticket-picker--accent, currentColor));
}

.wp-block-zapc-ticket-picker__range::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	inline-size: var(--zapc-ticket-picker-thumb);
	block-size: var(--zapc-ticket-picker-thumb);
	margin-block-start: calc((var(--zapc-ticket-picker-track) - var(--zapc-ticket-picker-thumb)) / 2);
	border: 0;
	border-radius: 50%;
	background: var(--wp--custom--ticket-picker--thumb, currentColor);
	box-shadow: 0 0 0 0.1875em var(--wp--custom--ticket-picker--thumb-ring, transparent), var(--wp--custom--ticket-picker--thumb-shadow, 0 0 transparent);
}

.wp-block-zapc-ticket-picker__range::-moz-range-thumb {
	box-sizing: border-box;
	inline-size: var(--zapc-ticket-picker-thumb);
	block-size: var(--zapc-ticket-picker-thumb);
	border: 0;
	border-radius: 50%;
	background: var(--wp--custom--ticket-picker--thumb, currentColor);
	box-shadow: 0 0 0 0.1875em var(--wp--custom--ticket-picker--thumb-ring, transparent), var(--wp--custom--ticket-picker--thumb-shadow, 0 0 transparent);
}

.wp-block-zapc-ticket-picker__range:focus-visible {
	outline: 2px solid currentColor; /* px: focus ring */
	outline-offset: 2px;
}

.wp-block-zapc-ticket-picker__step {
	flex: none;
	inline-size: 2.25em;
	block-size: 2.25em;
	padding: 0;
	border: var(--wp--custom--input--border-width, var(--wp--custom--border--width, 1px)) solid var(--wp--custom--ticket-picker--step-border, var(--wp--custom--input--border-color, color-mix(in srgb, currentColor 30%, transparent))); /* px: hairline fallback */
	border-radius: var(--wp--preset--border-radius--m, 0.5rem);
	background: var(--wp--custom--ticket-picker--surface, var(--wp--custom--surface--tint, color-mix(in srgb, currentColor 8%, transparent)));
	color: inherit;
	font: inherit;
	font-size: 1.125em;
	line-height: 1;
	cursor: pointer;
}

.wp-block-zapc-ticket-picker__step:disabled {
	opacity: 0.4;
	cursor: default;
}
