/* The date strip picker of a recurring event's booking form (forms/bookingform/recurring/dates.php): a side-scrolling row of dates that reads as a row of tabs, the chosen date the open one, and that date's times under it as buttons. Included by the inline booking form and by the booking checkout, each of which sets the --em-dates-* colors it draws with. */
@mixin booking-dates {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 20px;
	align-items: start;
	width: 100%;

	.em-booking-dates {
		min-width: 0;
	}

	.em-booking-dates-nav {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 12px;
		margin: 0 0 6px;
	}

	.em-booking-dates-month {
		appearance: none !important;
		box-sizing: content-box !important;
		width: auto;
		min-width: 0 !important;
		min-height: 22px !important;
		height: auto !important;
		margin: 0 !important;
		padding: 4px 24px 4px 4px !important;
		border: 0 !important;
		border-radius: var(--em-dates-radius) !important;
		background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23707070' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center !important;
		box-shadow: none !important;
		color: var(--em-dates-strong) !important;
		font-family: inherit !important;
		font-size: 15px !important;
		font-weight: 600 !important;
		line-height: 1.5 !important;
		cursor: pointer;

		&:hover {
			background-color: var(--em-dates-hover) !important;
		}

		&:focus-visible {
			outline: 2px solid var(--em-dates-accent);
			outline-offset: 1px;
		}

		// the device's own month picker opens from anywhere on the field, not only its small icon
		&[type="month"] {
			position: relative;

			&::-webkit-calendar-picker-indicator {
				position: absolute;
				inset: 0;
				width: 100%;
				height: 100%;
				margin: 0;
				padding: 0;
				background: transparent;
				cursor: pointer;
			}
		}
	}

	.em-booking-dates-arrows {
		display: flex;
		gap: 6px;

		button {
			display: flex !important;
			align-items: center;
			justify-content: center;
			width: 32px !important;
			min-width: 0 !important;
			height: 32px !important;
			margin: 0 !important;
			padding: 0 !important;
			border: 1px solid var(--em-dates-border) !important;
			border-radius: 50% !important;
			background: var(--em-dates-surface) !important;
			box-shadow: none !important;
			color: var(--em-dates-text) !important;
			line-height: 1 !important;
			cursor: pointer;

			svg {
				width: 13px;
				height: 13px;
				fill: none;
			}

			&:hover:not(:disabled) {
				border-color: var(--em-dates-accent) !important;
				color: var(--em-dates-accent) !important;
			}

			&:disabled {
				opacity: 0.35;
				cursor: default;
			}
		}
	}

	[dir="rtl"] & .em-booking-dates-arrows svg {
		transform: scaleX(-1);
	}

	[dir="rtl"] & .em-booking-dates-month {
		padding: 4px 4px 4px 24px !important;
		background-position: left 8px center !important;
	}

	.em-booking-dates.loading .em-booking-dates-arrows button {
		cursor: progress;
	}

	// the dates sit on one baseline like a row of tabs, and fade out at an end the strip continues past
	.em-booking-dates-list {
		display: flex;
		align-items: flex-end;
		gap: 2px;
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x proximity;
		scrollbar-width: none;
		border-bottom: 1px solid var(--em-dates-border);
		mask-image: linear-gradient(to right, transparent 0, #000 28px, #000 calc(100% - 28px), transparent 100%);

		&::-webkit-scrollbar {
			display: none;
		}

		&.at-start {
			mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent 100%);
		}

		&.at-end {
			mask-image: linear-gradient(to right, transparent 0, #000 28px);
		}

		&.at-start.at-end {
			mask-image: none;
		}
	}

	[dir="rtl"] & .em-booking-dates-list.at-start:not(.at-end) {
		mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent 100%);
	}

	[dir="rtl"] & .em-booking-dates-list.at-end:not(.at-start) {
		mask-image: linear-gradient(to left, transparent 0, #000 28px);
	}

	.em-booking-dates-divider {
		display: flex;
		flex: 0 0 auto;
		align-items: center;
		align-self: stretch;
		margin: 6px 4px 8px 8px;
		padding-inline-start: 6px;
		border-inline-start: 1px solid var(--em-dates-border);
		color: var(--em-dates-muted);
		font-size: 11px;
		font-weight: 600;
		letter-spacing: 0.06em;
		line-height: 1.2;
		text-transform: uppercase;
		white-space: nowrap;

		span {
			writing-mode: vertical-rl;
			transform: rotate(180deg);
		}
	}

	.em-booking-date {
		display: grid !important;
		flex: 0 0 auto;
		justify-items: center;
		gap: 1px;
		width: 60px !important;
		min-width: 0 !important;
		height: auto !important;
		margin: 0 !important;
		padding: 8px 2px 7px !important;
		border: 0 !important;
		border-bottom: 3px solid transparent !important;
		border-radius: var(--em-dates-radius) var(--em-dates-radius) 0 0 !important;
		background: none !important;
		box-shadow: none !important;
		color: var(--em-dates-text) !important;
		font-family: inherit !important;
		font-size: inherit;
		font-weight: normal !important;
		letter-spacing: 0 !important;
		line-height: 1.2 !important;
		text-transform: none !important;
		scroll-snap-align: start;
		cursor: pointer;
		transition: background-color 0.15s ease, border-color 0.15s ease;

		.em-booking-date-weekday {
			color: var(--em-dates-muted);
			font-size: 12px;
		}

		.em-booking-date-day {
			color: var(--em-dates-strong);
			font-size: 20px;
			font-weight: 600;
			font-variant-numeric: tabular-nums;
		}

		.em-booking-date-status {
			max-width: 100%;
			min-height: 13px;
			overflow: hidden;
			color: var(--em-dates-muted);
			font-size: 10.5px;
			text-overflow: ellipsis;
			white-space: nowrap;
		}

		&:not(:disabled):hover {
			background: var(--em-dates-hover) !important;
		}

		&:focus-visible {
			outline: 2px solid var(--em-dates-accent);
			outline-offset: -2px;
		}

		&.selected {
			border-bottom-color: var(--em-dates-accent) !important;
			background: var(--em-dates-accent-tint) !important;

			.em-booking-date-weekday,
			.em-booking-date-day {
				color: var(--em-dates-accent);
			}
		}

		&.scarce .em-booking-date-status {
			color: #a15c00;
		}

		&:disabled {
			opacity: 1 !important;
			cursor: default;
		}

		&.fully-booked .em-booking-date-day {
			color: var(--em-dates-muted);
			font-weight: 400;
			text-decoration: line-through;
		}

		&.unavailable .em-booking-date-weekday,
		&.unavailable .em-booking-date-day {
			color: var(--em-dates-faint);
			font-weight: 400;
		}
	}

	// a theme's own ring on anything focused is kept for the keyboard, where the rings above show
	.em-booking-date:focus:not(:focus-visible),
	.em-booking-dates-month:focus:not(:focus-visible),
	.em-booking-dates-arrows button:focus:not(:focus-visible) {
		outline: none;
	}

	// the chosen date's times
	.em-booking-recurrences {
		display: grid;
		grid-template-columns: minmax(0, 1fr);
		gap: 12px;
		width: 100%;

		// the strip already shows the date chosen
		> h3 {
			display: none !important;
		}

		// the timezone is one quiet line under the times, which becomes the list of timezones when clicked
		p.em-timezone {
			--em-iconified-font-size: 13px;
			margin: 0 !important;

			button.em-selectize-iconified {
				color: var(--em-dates-muted) !important;
			}

			.selectize-control {
				max-width: 360px;
			}
		}

		p.more-recurrenes {
			display: none;
		}

		.no-recurrences {
			color: var(--em-dates-muted);
			font-size: 14px;
		}

		.em-booking-timeslots-list,
		&.skeleton {
			display: grid;
			grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)) !important;
			gap: 8px;
		}

		&.skeleton > h3,
		&.skeleton > p {
			grid-column: 1 / -1;
		}

		.em-booking-recurrence {
			display: grid !important;
			align-content: center;
			justify-content: center;
			justify-items: center;
			gap: 1px;
			box-sizing: border-box;
			width: 100%;
			min-height: 46px;
			margin: 0 !important;
			padding: 8px 10px !important;
			border-radius: var(--em-dates-radius) !important;
			font-size: 14px;
			line-height: 1.3;
			text-align: center;
			transform: none !important;

			&:not(.skeleton-item) {
				border: 1px solid var(--em-dates-border) !important;
				background: var(--em-dates-surface) !important;
				box-shadow: none !important;
				color: var(--em-dates-text) !important;
				text-decoration: none !important;
				opacity: 1 !important;
				cursor: pointer;
			}

			&.skeleton-item {
				height: auto;
			}

			* {
				margin: 0 !important;
				padding: 0 !important;
			}

			.em-icon {
				display: none !important;
			}

			.em-booking-recurrence-date {
				color: var(--em-dates-muted);
				font-size: 12px;
			}

			.em-booking-recurrence-time {
				font-weight: 500;
				font-variant-numeric: tabular-nums;
			}

			.em-booking-recurrence-spaces {
				color: var(--em-dates-muted);
				font-size: 11.5px;
				font-style: normal;
			}

			&:not([disabled]):not(.skeleton-item):hover,
			&:not([disabled]):not(.skeleton-item):focus-visible {
				border-color: var(--em-dates-accent) !important;
				outline: none;
			}

			&.selected:not(.skeleton-item) {
				border-color: var(--em-dates-accent) !important;
				background: var(--em-dates-accent-tint) !important;
				box-shadow: inset 0 0 0 1px var(--em-dates-accent) !important;
				color: var(--em-dates-accent) !important;
			}

			&[disabled]:not(.skeleton-item) {
				background: var(--em-dates-hover) !important;
				color: var(--em-dates-muted) !important;
				cursor: not-allowed;

				.em-booking-recurrence-time {
					font-weight: 400;
					text-decoration: line-through;
				}
			}
		}
	}

	// an event booked by date alone has one time a date, which loads as soon as the date is chosen, so as in the booking checkout a date's times and timezone show only when it has several, or none that can be booked
	.em-booking-dates[data-picker="date"] ~ .em-booking-recurrences:not(.several) {
		display: none !important;
	}
}
