/**
 * Booking panel on the product page.
 *
 * Colours come from the theme: the panel inherits the surrounding text colour
 * and builds every line, tint and state from it, so it stays legible on a light
 * theme, a dark theme or a child theme with its own palette. Only the state
 * colours (closed / limited) are faint tints, kept translucent for that reason.
 */

.wcsba-panel {
	--wcsba-line: rgba(128, 128, 128, 0.4);
	--wcsba-line-strong: rgba(128, 128, 128, 0.65);
	--wcsba-muted: rgba(128, 128, 128, 1);
	--wcsba-tint: rgba(128, 128, 128, 0.08);
	box-sizing: border-box;
	margin: 1em 0 1.25em;
	padding: 1em;
	border: 1px solid var(--wcsba-line);
	border-radius: 4px;
	max-width: 100%;
}

.wcsba-panel *,
.wcsba-panel *::before,
.wcsba-panel *::after {
	box-sizing: border-box;
}

@supports ( border-color: color-mix( in srgb, currentColor 30%, transparent ) ) {
	.wcsba-panel {
		--wcsba-line: color-mix( in srgb, currentColor 30%, transparent );
		--wcsba-line-strong: color-mix( in srgb, currentColor 55%, transparent );
		--wcsba-tint: color-mix( in srgb, currentColor 8%, transparent );
	}
}

.wcsba-panel__heading {
	margin: 0 0 0.75em;
	font-size: 1.05em;
}

.wcsba-field {
	margin-bottom: 1em;
}

.wcsba-field__label {
	display: block;
	margin-bottom: 0.35em;
	font-weight: 600;
}

/* Calendar. */
.wcsba-calendar {
	max-width: 22em;
	border: 1px solid var(--wcsba-line);
	border-radius: 4px;
	padding: 0.5em;
}

.wcsba-calendar__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5em;
	margin-bottom: 0.4em;
}

.wcsba-calendar__title {
	font-weight: 600;
	text-align: center;
	flex: 1 1 auto;
}

.wcsba-calendar__nav {
	background: none;
	border: 1px solid var(--wcsba-line);
	border-radius: 4px;
	color: inherit;
	cursor: pointer;
	font-size: 1.1em;
	line-height: 1;
	min-width: 44px;
	min-height: 44px;
}

.wcsba-calendar__weekdays,
.wcsba-calendar__grid {
	display: grid;
	grid-template-columns: repeat( 7, minmax( 0, 1fr ) );
	gap: 2px;
}

.wcsba-calendar__weekday {
	text-align: center;
	font-size: 0.75em;
	color: var(--wcsba-muted);
	padding: 0.25em 0;
}

.wcsba-calendar__pad {
	min-height: 44px;
}

.wcsba-panel .wcsba-calendar__day {
	appearance: none;
	-webkit-appearance: none;
	background: none;
	border: 1px solid transparent;
	border-radius: 4px;
	color: inherit;
	cursor: pointer;
	font: inherit;
	min-height: 44px;
	min-width: 44px;
	padding: 0.25em;
	position: relative;
	text-decoration: none;
}

/* On a phone the seven columns have to share a narrow panel: give back the
   side padding and the gaps so every day stays a 44px tap target. */
@media ( max-width: 480px ) {
	.wcsba-calendar__weekdays,
	.wcsba-calendar__grid {
		gap: 0;
		margin-inline: -0.75em;
	}
}

.wcsba-calendar__day:hover:not( :disabled ) {
	border-color: var(--wcsba-line-strong);
}

.wcsba-calendar__day.is-today {
	border-color: var(--wcsba-line-strong);
}

.wcsba-calendar__day.is-limited::after {
	content: "";
	position: absolute;
	left: 50%;
	bottom: 4px;
	width: 6px;
	height: 6px;
	margin-left: -3px;
	border-radius: 50%;
	background: currentColor;
	opacity: 0.55;
}

/*
 * The chosen day.
 *
 * A faint tint is easy to lose — the theme paints its own buttons, and a
 * translucent background over a dark theme is invisible — so the chosen state
 * also carries a solid outline, a border and a weight change. The rule matches
 * the state the script puts on the element (`aria-pressed`) as well as the
 * class, so a stylesheet or a script that drops classes still shows the choice.
 */
.wcsba-panel .wcsba-calendar__day.is-selected,
.wcsba-panel .wcsba-calendar__day[aria-pressed="true"] {
	background: var(--wcsba-tint);
	border-color: currentColor;
	color: inherit;
	font-weight: 700;
	opacity: 1;
	box-shadow: inset 0 0 0 2px currentColor;
	outline: 2px solid currentColor;
	outline-offset: -2px;
}

.wcsba-calendar__day.is-disabled,
.wcsba-calendar__day:disabled {
	color: var(--wcsba-muted);
	/* It still answers a click — with the reason it is unavailable — so the
	   cursor offers help rather than pretending the button is dead. */
	cursor: help;
	opacity: 0.45;
	text-decoration: line-through;
}

.wcsba-calendar__day:focus-visible,
.wcsba-calendar__nav:focus-visible,
.wcsba-slot:focus-visible,
.wcsba-stepper__button:focus-visible,
.wcsba-stepper__input:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 1px;
}

/* Slots. */
.wcsba-slots {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em;
}

.wcsba-slot {
	background: none;
	border: 1px solid var(--wcsba-line-strong);
	border-radius: 999px;
	color: inherit;
	cursor: pointer;
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	font: inherit;
	min-height: 44px;
	min-width: 5.5em;
	padding: 0.4em 0.9em;
}

.wcsba-panel .wcsba-slot.is-selected,
.wcsba-panel .wcsba-slot[aria-checked="true"] {
	background: var(--wcsba-tint);
	border-color: currentColor;
	color: inherit;
	opacity: 1;
	box-shadow: inset 0 0 0 2px currentColor;
	font-weight: 700;
}

/* An empty date: the row stays, so its explanation has somewhere to live. */
.wcsba-field--times[hidden] {
	display: none;
}

.wcsba-slot__remaining {
	font-size: 0.75em;
	color: var(--wcsba-muted);
	font-weight: 400;
}

/* A slot or a submit button the server has refused. */
.wcsba-slot.is-disabled,
.wcsba-slot:disabled {
	border-style: dashed;
	color: var(--wcsba-muted);
	cursor: not-allowed;
	text-decoration: line-through;
}

.woocommerce form.cart button.wcsba-blocked,
.woocommerce form.cart button.wcsba-blocked:hover {
	cursor: not-allowed;
	filter: grayscale( 1 );
	opacity: 0.55;
}

/* Status line. */
.wcsba-status {
	margin: 0 0 0.75em;
	min-height: 1.2em;
	font-size: 0.9em;
}

.wcsba-status:empty {
	margin-bottom: 0;
}

.wcsba-panel--loading .wcsba-status::after {
	content: "";
	display: inline-block;
	width: 0.6em;
	height: 0.6em;
	margin-left: 0.5em;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: wcsba-spin 0.8s linear infinite;
	vertical-align: middle;
}

@keyframes wcsba-spin {
	to {
		transform: rotate( 360deg );
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.wcsba-panel--loading .wcsba-status::after {
		animation: none;
	}
}

/* People. */
.wcsba-stepper {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--wcsba-line-strong);
	border-radius: 4px;
	overflow: hidden;
}

.wcsba-stepper__button {
	background: none;
	border: 0;
	color: inherit;
	cursor: pointer;
	font-size: 1.2em;
	line-height: 1;
	min-height: 44px;
	min-width: 44px;
}

.wcsba-stepper__input {
	background: none;
	border: 0;
	border-left: 1px solid var(--wcsba-line);
	border-right: 1px solid var(--wcsba-line);
	color: inherit;
	font: inherit;
	min-height: 44px;
	text-align: center;
	width: 4em;
	-moz-appearance: textfield;
}

.wcsba-stepper__input::-webkit-outer-spin-button,
.wcsba-stepper__input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.wcsba-unit-price,
.wcsba-note {
	display: block;
	margin-top: 0.4em;
	font-size: 0.9em;
	color: var(--wcsba-muted);
}

.wcsba-total {
	margin: 0;
	font-weight: 600;
}

.wcsba-total__value {
	font-size: 1.1em;
}

.wcsba-noscript {
	border: 1px dashed var(--wcsba-line-strong);
	padding: 0.5em;
	font-size: 0.9em;
}

/* The panel owns the quantity: the theme's own input would be a duplicate. */
.wcsba-bookable form.cart .quantity {
	display: none;
}

/* On a phone: no room to waste, but nothing below a fingertip either. The day
   cell keeps its 44px and the slack comes out of the padding instead. */
@media ( max-width: 480px ) {
	.wcsba-panel {
		padding: 0.75em;
	}

	.wcsba-calendar {
		max-width: 100%;
	}

	.wcsba-slot {
		min-width: 4.5em;
	}
}
