/**
 * Month calendar: the grid, day states, availability bar and reason tooltip.
 */

.avco-widget__months {
	display: grid;
	grid-template-columns: repeat(1, minmax(0, 1fr));
	gap: var(--avco-w-s5);
	touch-action: pan-y;
}

.avco-widget__months.is-two {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.avco-widget__mcol {
	display: flex;
	flex-direction: column;
	gap: var(--avco-w-s2);
	min-width: 0;
}

.avco-widget__mhead {
	display: flex;
	align-items: center;
	gap: var(--avco-w-s2);
	min-height: var(--avco-w-tap);
}

.avco-widget__mhead .avco-widget__title {
	flex: 1;
	text-align: center;
}

.avco-widget__navgap {
	flex-shrink: 0;
	width: var(--avco-w-tap);
	height: var(--avco-w-tap);
}

.avco-widget__grid {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
	gap: var(--avco-w-s1);
}

.avco-widget__wd {
	padding: 0 0 var(--avco-w-s1);
	color: var(--avco-w-text-2);
	font-size: 0.875em;
	text-align: center;
}

.avco-widget__cell {
	display: flex;
	justify-content: center;
	min-width: 0;
}

.avco-widget__day {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: var(--avco-w-s1);
	width: 100%;
	height: auto;
	min-height: var(--avco-w-day-min);
	aspect-ratio: 1 / 1;
	padding: 0;
	border: 1px solid var(--avco-w-border);
	border-radius: var(--avco-w-r-day);
	background: var(--avco-w-surface);
	color: var(--avco-w-text);
	font-variant-numeric: proportional-nums;
	text-align: center;
	cursor: pointer;
}

@container (min-width: 640px) {

	.avco-widget__day {
		height: var(--avco-w-day);
		aspect-ratio: auto;
	}
}

.avco-widget__day:disabled {
	cursor: default;
}

/* Panels and sheets keep square days. */
.avco-widget__shell.is-pop .avco-widget__day,
.avco-widget__shell.is-sheet .avco-widget__day {
	height: auto;
	aspect-ratio: 1 / 1;
}

.avco-widget__day.is-today,
.avco-widget__card.is-today {
	border-color: var(--avco-w-brand);
}

.avco-widget__day.is-today,
.avco-widget__day.is-selected {
	font-weight: 600;
}

.avco-widget:not([data-button-style="water_drop"]) .avco-widget__day.is-open:hover {
	border-color: currentcolor;
}

/* Picked, in-range, minimum-stay and preview days: Brand fill. */
.avco-widget__day.is-selected,
.avco-widget__day.is-in-range,
.avco-widget__day.is-preview,
.avco-widget__day.is-min {
	border-color: var(--avco-w-brand);
	background: var(--avco-w-brand);
	color: var(--avco-w-on-brand);
}

/* Closed, too far, full: Off fill and faded number. */
.avco-widget__day.is-off {
	border-color: var(--avco-w-off);
	background: var(--avco-w-off);
	color: var(--avco-w-text-off);
	cursor: help;
}

.avco-widget__day.is-off.is-today {
	border-color: var(--avco-w-brand);
}

.avco-widget__day.is-past {
	border-color: transparent;
	background: var(--avco-w-hatch);
	color: var(--avco-w-text-off);
	cursor: default;
}

.avco-widget__day.is-loading {
	border-color: var(--avco-w-off);
	color: var(--avco-w-text-off);
}

.avco-widget__pips {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--avco-w-s1);
	height: 6px;
}

.avco-widget__pips:empty {
	display: none;
}

/* Availability bar. */
.avco-widget__pip {
	width: var(--avco-w-bar-w);
	height: var(--avco-w-bar-h);
	border-radius: var(--avco-w-r-bar);
	background: var(--avco-w-success);
	box-shadow: 0 0 0 2px var(--avco-w-surface);
}

.avco-widget__pip.is-full {
	background: var(--avco-w-error);
}

/* Reason tooltip, on hover and keyboard focus. */
.avco-widget__tip {
	position: absolute;
	bottom: calc(100% + 8px);
	left: 50%;
	z-index: 20;
	padding: var(--avco-w-s1) var(--avco-w-s2);
	border-radius: var(--avco-w-r-tip);
	background: var(--avco-w-text);
	box-shadow: var(--avco-w-tip-shadow);
	color: var(--avco-w-surface);
	font-size: 0.875em;
	font-weight: 400;
	line-height: 1.3;
	white-space: nowrap;
	visibility: hidden;
	opacity: 0;
	transform: translateX(-50%);
	pointer-events: none;
}

/* Tips on the outer two columns align to the day's edge so they stay inside the grid. */
.avco-widget__cell:is(:nth-child(7n + 1), :nth-child(7n + 2)) .avco-widget__tip {
	left: auto;
	inset-inline-start: 0;
	transform: none;
}

.avco-widget__cell:is(:nth-child(7n), :nth-child(7n - 1)) .avco-widget__tip {
	left: auto;
	inset-inline-end: 0;
	transform: none;
}

@media (hover: hover) {

	.avco-widget__day.has-tip:hover .avco-widget__tip {
		visibility: visible;
		opacity: 1;
	}

	.avco-widget__day.has-tip:hover {
		z-index: 6;
	}
}

.avco-widget__day.has-tip:focus-visible .avco-widget__tip {
	visibility: visible;
	opacity: 1;
}

.avco-widget__day.has-tip:focus-visible {
	z-index: 6;
}
