/*
 * Booking search and its calendar (inc/cercador.php, cercador.js). Mobile first.
 * Colours follow the theme: text colour, the base background and accent-3 for
 * the shaded period, so each child gets its own look without code.
 * A child can retouch: --od-cal-marca (check-in and check-out days),
 * --od-cal-periode (shaded period) and --od-cal-rastre (trail).
 */

.od-cercador,
.od-cal--mobil {
	--od-cal-marca: var(--wp--preset--color--contrast, #1f1f1f);
	--od-cal-periode: var(--wp--preset--color--accent-3, #d9d9d9);
	--od-cal-rastre: var(--wp--preset--color--accent-4, #f2f2f2);
}

.od-cercador {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	align-items: flex-end;
}

/* Phones: dates on one row, people side by side, code and button full width. */
.od-cercador > * {
	flex: 1 1 100%;
}

.od-cercador > .od-cercador__camp--persones {
	flex: 1 1 5rem;
}

.od-cercador__dates {
	position: relative;
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.75rem;
}

.od-cercador__camp {
	display: grid;
	gap: 0.3rem;
	min-width: 0;
}

.od-cercador__etiqueta {
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	font-weight: 600;
}

.od-cercador input:not([type="hidden"]),
.od-cercador select,
.od-cercador__data {
	box-sizing: border-box;
	width: 100%;
	min-width: 0; /* the native date input has its own minimum width and overflowed at 390 px (found by the Florinda, 2026-12-01) */
	min-height: 2.9rem;
	padding: 0.55rem 0.75rem;
	border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
	border-radius: 4px;
	background: var(--wp--preset--color--base, #fff);
	color: var(--wp--preset--color--contrast, #1f1f1f);
	font: inherit;
}

.od-cercador__data {
	text-align: start;
	cursor: pointer;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.od-cercador__data[aria-expanded="true"] {
	border-color: var(--wp--preset--color--contrast, #1f1f1f);
}

.od-cercador__boto {
	min-height: 2.9rem;
	white-space: nowrap;
}

@media (min-width: 782px) {
	.od-cercador > .od-cercador__dates {
		flex: 2 1 17rem;
	}

	.od-cercador > .od-cercador__camp--persones {
		flex: 0 1 6rem;
	}

	.od-cercador > .od-cercador__camp--codi {
		flex: 1 1 9rem;
	}

	.od-cercador > .od-cercador__boto {
		flex: 0 0 auto;
	}
}

/* ---------- Calendar ---------- */

.od-cal {
	position: fixed;
	z-index: 60;
	box-sizing: border-box;
	width: max-content;
	max-width: calc(100vw - 2rem);
	padding: 1rem 1.25rem 1.25rem;
	border-radius: 8px;
	background: var(--wp--preset--color--base, #fff);
	color: var(--wp--preset--color--contrast, #1f1f1f);
	box-shadow: 0 8px 32px rgb(0 0 0 / 0.18);
}

.od-cal[hidden] {
	display: none;
}

.od-cal__cap {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 0.5rem;
}

.od-cal__estat {
	margin: 0;
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	text-align: center;
}

.od-cal__fletxa {
	position: relative;
	width: 2.5rem;
	height: 2.5rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.od-cal__fletxa:hover:not(:disabled) {
	background: var(--od-cal-rastre);
}

.od-cal__fletxa::before {
	content: "";
	position: absolute;
	inset: 0;
	margin: auto;
	width: 0.6rem;
	height: 0.6rem;
	border-top: 2px solid currentColor;
	border-right: 2px solid currentColor;
}

.od-cal__fletxa--ant::before { transform: translateX(15%) rotate(-135deg); }
.od-cal__fletxa--seg::before { transform: translateX(-15%) rotate(45deg); }

.od-cal__fletxa:disabled {
	opacity: 0.25;
	cursor: default;
}

.od-cal__mesos {
	display: flex;
	gap: 2rem;
}

.od-cal__titol {
	margin: 0 0 0.5rem;
	font-weight: 600;
	text-align: center;
}

/* "enero de 2027" becomes "Enero de 2027": only the first letter. */
.od-cal__titol::first-letter {
	text-transform: uppercase;
}

.od-cal__taula {
	border-collapse: collapse;
}

.od-cal__taula th {
	padding: 0 0 0.35rem;
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: capitalize;
	opacity: 0.7;
}

.od-cal__taula td {
	padding: 1px 0;
}

.od-cal__dia {
	display: block;
	width: 2.6rem;
	height: 2.6rem;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 0.9rem;
	cursor: pointer;
}

.od-cal__dia:hover:not(:disabled) {
	outline: 1px solid currentColor;
	outline-offset: -1px;
}

.od-cal__dia.is-passat {
	opacity: 0.3;
	cursor: default;
}

.od-cal__dia.is-avui {
	font-weight: 700;
	text-decoration: underline;
	text-underline-offset: 0.25em;
}

.od-cal__dia.is-rastre,
.od-cal__dia.is-rastre-fi {
	background: var(--od-cal-rastre);
}

.od-cal__dia.is-periode {
	background: var(--od-cal-periode);
}

.od-cal__dia.is-entrada,
.od-cal__dia.is-sortida {
	background: var(--od-cal-marca);
	color: var(--wp--preset--color--base, #fff);
}

.od-cal__dia.is-entrada {
	border-radius: 4px 0 0 4px;
}

.od-cal__dia.is-sortida {
	border-radius: 0 4px 4px 0;
}

/* ---------- Calendar on phones and touch tablets: a full-screen sheet ---------- */

.od-cal--mobil {
	inset: 0;
	z-index: 2147483000; /* over the fixed header, the booking bar, floating buttons and the admin bar */
	display: flex;
	flex-direction: column;
	width: auto;
	max-width: none;
	padding: 0;
	border-radius: 0;
	box-shadow: none;
}

.od-cal--mobil[hidden] {
	display: none;
}

.od-cal--mobil .od-cal__cap {
	margin: 0;
	padding: 0.5rem 0.5rem 0.5rem 1rem;
	border-bottom: 1px solid color-mix(in srgb, currentColor 12%, transparent);
}

.od-cal--mobil .od-cal__estat {
	font-size: 1rem;
	font-weight: 600;
	text-align: start;
}

.od-cal__tanca {
	position: relative;
	flex: none;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.od-cal__tanca::before,
.od-cal__tanca::after {
	content: "";
	position: absolute;
	inset: 0;
	margin: auto;
	width: 1.1rem;
	height: 2px;
	background: currentColor;
	transform: rotate(45deg);
}

.od-cal__tanca::after {
	transform: rotate(-45deg);
}

/* Week days once, on top, while the months scroll under them. */
.od-cal__setmana {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	padding: 0.5rem 1rem;
	border-bottom: 1px solid color-mix(in srgb, currentColor 12%, transparent);
	font-size: 0.75rem;
	font-weight: 600;
	text-align: center;
	text-transform: capitalize;
	opacity: 0.7;
}

.od-cal--mobil .od-cal__mesos {
	position: relative; /* months measure their offsetTop from here */
	flex: 1 1 auto;
	display: block;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding: 0 1rem 1rem;
}

.od-cal--mobil .od-cal__mes {
	padding-top: 1.25rem;
}

.od-cal--mobil .od-cal__titol {
	text-align: start;
}

.od-cal--mobil .od-cal__taula {
	width: 100%;
	table-layout: fixed;
}

/* The week days are already on top: each month keeps them for screen readers only. */
.od-cal--mobil .od-cal__taula thead {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
}

.od-cal--mobil .od-cal__dia {
	width: 100%;
	height: 2.9rem;
	font-size: 1rem;
}

.od-cal--mobil .od-cal__dia:hover:not(:disabled) {
	outline: 0;
}

.od-cal__peu {
	padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
	border-top: 1px solid color-mix(in srgb, currentColor 12%, transparent);
}

.od-cal__fet {
	width: 100%;
	min-height: 2.9rem;
}

.od-cal__fet:disabled {
	opacity: 0.4;
	cursor: default;
}

/* The page under the sheet does not scroll while it is open. */
html.od-cal-bloqueja,
html.od-cal-bloqueja body {
	overflow: hidden;
}

/* ---------- Vertical layout (right column of room pages) ---------- */

.od-cercador--vertical {
	box-sizing: border-box;
	padding: 1.25rem;
	border: 1px solid color-mix(in srgb, currentColor 15%, transparent);
	border-radius: 6px;
	background: var(--wp--preset--color--base, #fff);
	color: var(--wp--preset--color--contrast, #1f1f1f);
}

@media (min-width: 782px) {
	.od-cercador--vertical {
		position: sticky;
		top: calc(var(--od-capcalera-h, 5rem) + 1rem);
	}

	.od-cercador--vertical > .od-cercador__dates,
	.od-cercador--vertical > .od-cercador__camp--codi,
	.od-cercador--vertical > .od-cercador__boto {
		flex: 1 1 100%;
	}

	.od-cercador--vertical > .od-cercador__camp--persones {
		flex: 1 1 5rem;
	}
}

/* Phones: no search on the room page, the fixed booking bar does that job. */
@media (max-width: 781px) {
	.od-cercador--vertical:not(.od-barra-reserva .od-cercador) {
		display: none;
	}
}

/* ---------- Fixed booking bar on phones ---------- */

.od-barra-reserva {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 55;
	padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
	background: var(--wp--preset--color--base, #fff);
	box-shadow: 0 -2px 16px rgb(0 0 0 / 0.12);
}

.od-barra-reserva .wp-block-buttons,
.od-barra-reserva .wp-block-button,
.od-barra-reserva .wp-block-button__link,
.od-barra-reserva__obre {
	width: 100%;
	margin: 0;
	text-align: center;
}

.od-barra-reserva__panell {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 100%;
	max-height: calc(100vh - 8rem);
	overflow-y: auto;
	padding: 2.75rem 1rem 1rem;
	background: var(--wp--preset--color--base, #fff);
	box-shadow: 0 -8px 24px rgb(0 0 0 / 0.15);
}

.od-barra-reserva__panell[hidden] {
	display: none;
}

.od-barra-reserva__panell .od-cercador--vertical {
	padding: 0;
	border: 0;
}

.od-barra-reserva__tanca {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	width: 2.25rem;
	height: 2.25rem;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--wp--preset--color--contrast, #1f1f1f);
	cursor: pointer;
}

.od-barra-reserva__tanca::before,
.od-barra-reserva__tanca::after {
	content: "";
	position: absolute;
	inset: 0;
	margin: auto;
	width: 1.1rem;
	height: 2px;
	background: currentColor;
	transform: rotate(45deg);
}

.od-barra-reserva__tanca::after {
	transform: rotate(-45deg);
}

/* --od-barra-h is the bar's real height, measured by cercador.js; 5rem until then. */
body:has(.od-barra-reserva) {
	padding-bottom: var(--od-barra-h, 5rem);
}

@media (min-width: 782px) {
	.od-barra-reserva {
		display: none;
	}

	body:has(.od-barra-reserva) {
		padding-bottom: 0;
	}
}

@media print {
	.od-barra-reserva {
		display: none;
	}
}
