/**
 * The lease cards on [homewood_properties type="leasing"], and the lightbox
 * each one opens.
 *
 * The lightbox is a <dialog> opened with showModal(), so the page behind it is
 * inert and Escape closes it without any help. Images on the left, one at a
 * time; the lease on the right. Below the tablet width the two stack and the
 * dialog scrolls.
 *
 * @package homewood_theme
 */

/* -- The card ------------------------------------------------------------- */

/*
 * A lease card is a button around the same figure every other card is, so it
 * is stripped back to look like one.
 */
.hw-properties__open {
	display: block;
	width: 100%;
	margin: 0;
	padding: 0;
	font: inherit;
	color: inherit;
	text-align: inherit;
	background: none;
	border: 0;
	cursor: pointer;
}

.hw-properties__open:focus-visible {
	outline: 2px solid var(--hw-property-text);
	outline-offset: 4px;
	border-radius: var(--hw-property-radius);
}

/*
 * On hover the picture washes back under a More Info button, as in the
 * mockup. The wash covers the photo's border too, so it fades with the rest.
 */
.hw-properties__frame {
	position: relative;
	display: block;
}

.hw-properties__more {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	background: rgba(246, 241, 234, 0.63);
	border-radius: var(--hw-property-radius);
	opacity: 0;
	transition: opacity 0.35s ease;
}

.hw-properties__open:hover .hw-properties__more,
.hw-properties__open:focus-visible .hw-properties__more {
	opacity: 1;
}

/* Drawn as the theme's outline button, closed into a solid loop. */
.hw-properties__more-label {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: min(100%, 280px);
	min-height: 50px;
	padding: 0.5rem 0.8rem;
	font-size: var(--wp--preset--font-size--h-4, 1.25rem);
	line-height: 1.3;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	text-align: center;
	color: var(--hw-property-text);
	border: 2px solid var(--hw-property-rule);
	border-radius: 15px;
}

/* -- The dialog ----------------------------------------------------------- */

.hw-lease {
	--hw-lease-border: var(--wp--preset--color--wheat, #c3a87f);
	--hw-lease-ground: var(--wp--preset--color--sand, #e9e4d4);
	--hw-lease-text: var(--wp--preset--color--ink, #252b23);
	--hw-lease-eyebrow: var(--wp--preset--color--sage, #4b5649);
	--hw-lease-radius: 5px;
	--hw-lease-pad: clamp(1.25rem, 3vw, 2.5rem);
	--hw-lease-arrow: clamp(2.75rem, 7vw, 6.25rem);

	width: min(80rem, calc(100% - 2rem));
	max-width: none;
	max-height: calc(100% - 2rem);
	margin: auto;
	padding: 0;
	color: var(--hw-lease-text);
	background: #fff;
	border: 0;
	box-shadow: 0 2px 18px rgba(37, 43, 35, 0.12);
	overflow: auto;
	overscroll-behavior: contain;
}

/*
 * The theme sets no box-sizing of its own, and the button block's stylesheet,
 * which would give the buttons border-box, only loads on a page with a button
 * block in it. Without it a button's padding is added on top of its width and
 * the right-hand one spills past the edge of the dialog, so the dialog sets it
 * for everything inside.
 */
.hw-lease,
.hw-lease *,
.hw-lease *::before,
.hw-lease *::after {
	box-sizing: border-box;
}

/* The page stays in view, washed back, as in the mockup. */
.hw-lease::backdrop {
	background: rgba(246, 241, 234, 0.72);
}

/* Nothing behind an open lightbox should scroll along with it. */
html:has(.hw-lease[open]) {
	overflow: hidden;
}

.hw-lease__panel {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
	gap: clamp(1.5rem, 6vw, 5rem);
	padding: var(--hw-lease-pad);
}

.hw-lease__close {
	position: absolute;
	top: 0.75rem;
	right: 0.75rem;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.5rem;
	height: 2.5rem;
	padding: 0;
	color: var(--hw-lease-text);
	background: transparent;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	transition: background-color 0.35s ease;
}

.hw-lease__close svg {
	width: 1.25rem;
	height: 1.25rem;
}

.hw-lease__close:hover,
.hw-lease__close:focus-visible {
	background: var(--hw-lease-ground);
}

.hw-lease__close:focus-visible {
	outline: 2px solid var(--hw-lease-text);
	outline-offset: 2px;
}

/* -- Images --------------------------------------------------------------- */

.hw-lease__frame {
	position: relative;
	overflow: hidden;
	border: 2px solid var(--hw-lease-border);
	border-radius: var(--hw-lease-radius);
	background: var(--hw-lease-ground);
}

.hw-lease__track {
	display: flex;
	margin: 0;
	padding: 0;
	list-style: none;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	overscroll-behavior-x: contain;
}

.hw-lease__track::-webkit-scrollbar {
	display: none;
}

.hw-lease__track:focus-visible {
	outline: 2px solid var(--hw-lease-text);
	outline-offset: -4px;
}

.hw-lease__slide {
	flex: 0 0 100%;
	margin: 0;
	scroll-snap-align: start;
}

.hw-lease__image {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 7 / 9;
	object-fit: cover;
}

/* The drawn house, when a lease has no picture of any kind. */
.hw-lease__image--none {
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--wp--preset--color--bronze, #896d44);
}

/*
 * Half circles riding the edges of the photograph: each is a whole circle
 * centred on the edge, with the frame's overflow cutting off the outer half.
 */
.hw-lease__arrow {
	position: absolute;
	top: 50%;
	display: flex;
	align-items: center;
	width: var(--hw-lease-arrow);
	height: var(--hw-lease-arrow);
	padding: 0 calc(var(--hw-lease-arrow) * 0.08);
	color: var(--hw-lease-text);
	background: rgba(233, 228, 212, 0.85);
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	transform: translateY(-50%);
	transition: background-color 0.35s ease;
}

.hw-lease__arrow--prev {
	left: calc(var(--hw-lease-arrow) / -2);
	justify-content: flex-end;
}

.hw-lease__arrow--next {
	right: calc(var(--hw-lease-arrow) / -2);
	justify-content: flex-start;
}

.hw-lease__arrow svg {
	width: calc(var(--hw-lease-arrow) * 0.34);
	height: calc(var(--hw-lease-arrow) * 0.34);
}

.hw-lease__arrow:hover,
.hw-lease__arrow:focus-visible {
	background: var(--hw-lease-border);
}

.hw-lease__arrow:focus-visible {
	outline: 2px solid var(--hw-lease-text);
	outline-offset: -4px;
}

.hw-lease__count {
	margin: 0.75rem 0 0;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

/* -- The lease ------------------------------------------------------------ */

.hw-lease__body {
	padding-top: clamp(0rem, 2vw, 1.25rem);
	padding-right: 1.5rem;
}

.hw-lease__body > * {
	margin: 0;
}

.hw-lease__body > * + * {
	margin-top: clamp(1.25rem, 2.5vw, 1.75rem);
}

.hw-lease__eyebrow {
	font-size: var(--wp--preset--font-size--h-4, 1.25rem);
	line-height: 1.3;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--hw-lease-eyebrow);
}

.hw-lease__body > .hw-lease__title {
	margin-top: clamp(1.75rem, 4vw, 3rem);
	font-size: var(--wp--preset--font-size--h-3, 1.5rem);
	font-weight: 600;
	line-height: 1.25;
}

.hw-lease__details,
.hw-lease__description {
	line-height: 1.55;
}

.hw-lease__description p {
	margin: 0;
}

.hw-lease__description p + p {
	margin-top: 1em;
}

/*
 * Stacked and left aligned, as in the mockup. The one column is as wide as
 * the longer label needs (and no narrower than the button block's 280px),
 * and both buttons fill it, so they come out the same width. On a phone too
 * narrow for that, the column shrinks to fit and the labels wrap.
 */
.hw-lease__body > .hw-lease__actions {
	display: grid;
	grid-template-columns: fit-content(100%);
	gap: 1rem;
	margin-top: clamp(2rem, 5vw, 3.5rem);
}

.hw-lease__actions .wp-block-button .wp-block-button__link {
	--hw-btn-radius: 15px;

	width: 100%;
	min-width: min(100%, 280px);
	padding: 0.8125rem 1.5rem;
}

.hw-lease .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	border: 0;
	white-space: nowrap;
}

/* -- Narrow --------------------------------------------------------------- */

@media (max-width: 920px) {
	.hw-lease__panel {
		grid-template-columns: minmax(0, 1fr);
		padding-top: 3.5rem;
	}

	.hw-lease__body {
		padding-right: 0;
	}

	/* A shorter picture, so the lease starts on the first screen. */
	.hw-lease__image {
		aspect-ratio: 4 / 3;
	}
}

@media (prefers-reduced-motion: reduce) {
	.hw-lease__arrow,
	.hw-lease__close,
	.hw-properties__more {
		transition: none;
	}
}
