/*
 * The property archive and the single property page.
 *
 * These selectors are the module's, not a demo's: they style what the two
 * templates below print, and they are enqueued only where those templates or
 * the [itdcompanion_featured_properties] shortcode run. Colours come from the theme's
 * palette slots, so a recoloured site recolours these too.
 */

/*
 * Property archive grid + filters (property CPT). Unlike every other
 * top-level element in `.content-area` (.page-header, .entry-content, the
 * pagination), `archive-property.php` renders these as direct children of
 * `.content-area` with no `.entry-content` wrapper at all — so without
 * their own max-width/padding here they ran flush to the viewport edge on
 * every side. Scoped to `.content-area` so the same class reused inside
 * the Home "Featured Properties" pattern (which already sets its own
 * max-width/padding inline) is unaffected.
 */
.content-area .itd-property-filters,
.content-area .itd-property-grid,
.content-area .itd-property-empty {
	max-width: var( --wp--style--global--wide-size, 1300px );
	margin-inline: auto;
	padding-inline: var( --wp--preset--spacing--30 );
}

.content-area .itd-property-filters {
	padding-top: var( --wp--preset--spacing--40 );
}

/*
 * Text colour and the end of the page. The base theme paints `.site-content`
 * with the primary slot and gives it no bottom padding: its pages are built
 * from sections that set both themselves. These two templates and the card
 * grid are not sections, so they inherited primary - terracotta body text on
 * a real estate palette, invisible only where primary is almost black - and
 * ran into the footer. Contrast and 3rem, as the real-estate theme had them.
 */
.itd-property-archive,
.itd-property-single,
.itd-property-grid {
	color: var( --wp--preset--color--contrast );
}

.itd-property-archive,
.itd-property-single {
	padding-bottom: var( --wp--preset--spacing--60 );
}

.content-area .itd-property-grid {
	padding-bottom: var( --wp--preset--spacing--50 );
}

.content-area .itd-property-empty {
	padding-block: var( --wp--preset--spacing--30 ) var( --wp--preset--spacing--50 );
}

/*
 * Filter bar as a soft card (same shadow recipe as `.itd-card-soft`,
 * inlined rather than reusing that class so it doesn't also pick up its
 * hover lift/rotate — a filter panel isn't a clickable card) instead of a
 * bare row of native selects. Labeled fields in a responsive grid, plus a
 * "Sort by" and a min/max price range beyond the original 3 taxonomy
 * dropdowns.
 */
.itd-property-filters {
	margin-bottom: var( --wp--preset--spacing--40, 24px );
	padding: var( --wp--preset--spacing--40, 24px );
	border-radius: 20px;
	background-color: var( --wp--preset--color--base, #ffffff );
	box-shadow: 0 1px 2px color-mix( in srgb, var( --wp--preset--color--primary, #1c3d2e ) 4%, transparent ), 0 12px 32px -8px color-mix( in srgb, var( --wp--preset--color--primary, #1c3d2e ) 12%, transparent );
}

/*
 * Flex, not grid: the Filter button lives in this same row now (as the
 * `__actions` item, last in source order) instead of on its own line
 * below, and it needs to sit at the same baseline as the dropdowns/inputs
 * despite having no label above it — `align-items:flex-end` lines up
 * every item's bottom edge, which puts the button level with the input
 * fields regardless of the label row's height. A grid with
 * `auto-fit`/`minmax` doesn't support that kind of "one item is shorter
 * and should hug the bottom" alignment across a wrapping multi-row
 * layout as predictably as flex does.
 */
.itd-property-filters__grid {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: var( --wp--preset--spacing--30, 16px );
}

.itd-property-filters__field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	/*
	 * A wrapping flex container decides line breaks using each item's
	 * hypothetical (flex-basis) size, before any shrinking is applied —
	 * shrinking only redistributes space among items already assigned to
	 * a line. So a 150px basis on all 7 fields left no room for the
	 * Filter button to even be considered for that first line, no matter
	 * how much `flex-shrink`/`min-width:0` it's given; the fix is a
	 * smaller basis up front, not more room to shrink from.
	 */
	flex: 1 1 120px;
	min-width: 0;
}

.itd-property-filters__field label {
	font-size: 0.8125rem;
	font-weight: 600;
	color: var( --wp--preset--color--muted, #5a6259 );
}

.itd-property-filters select,
.itd-property-filters input[type="number"] {
	width: 100%;
	padding: 10px 14px;
	border: 1px solid var( --wp--preset--color--line, #e5e4df );
	border-radius: 10px;
	background-color: var( --wp--preset--color--base, #ffffff );
	color: var( --wp--preset--color--contrast, #252b26 );
	font-size: 0.9375rem;
	transition: border-color 0.15s ease;
}

.itd-property-filters select:focus,
.itd-property-filters input[type="number"]:focus {
	outline: none;
	border-color: var( --wp--preset--color--primary, #1c3d2e );
}

.itd-property-filters__actions {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	gap: var( --wp--preset--spacing--20, 12px );
}

.itd-property-filters__submit {
	padding: 12px 32px;
	border: 0;
	border-radius: 9999px;
	background-color: var( --wp--preset--color--primary, #1c3d2e );
	color: var( --wp--preset--color--base, #ffffff );
	font-weight: 600;
	font-size: 0.9375rem;
	cursor: pointer;
	transition: background-color 0.15s ease, transform 0.15s ease;
}

.itd-property-filters__submit:hover {
	background-color: var( --itd-primary-dark );
	transform: translateY( -1px );
}

.itd-property-filters__reset {
	color: var( --wp--preset--color--muted, #5a6259 );
	font-size: 0.9375rem;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.itd-property-filters__reset:hover {
	color: var( --wp--preset--color--primary, #1c3d2e );
}

@media ( prefers-reduced-motion: reduce ) {
	.itd-property-filters__submit,
	.itd-property-filters__submit:hover {
		transition: none;
		transform: none;
	}
}

/*
 * `auto-fill` reserves a track for every column that fits the container,
 * even when there's no item for it — so 3 cards in a row wide enough for
 * 4 left an empty phantom 4th track, and `justify-content:center`
 * centered THAT 4-track row as a whole, not the 3 visible cards, which is
 * why they still looked shifted left. `auto-fit` collapses unfilled
 * tracks to zero width instead, so the populated ones (the `1fr` part of
 * minmax) expand to fill the freed space — 3 cards always fill their row
 * evenly, truly centered under whatever sits below them, with no
 * leftover gap to one side.
 */
.itd-property-grid {
	display: grid;
	grid-template-columns: repeat( auto-fit, minmax( 280px, 1fr ) );
	justify-content: center;
	gap: var( --wp--preset--spacing--40, 24px );
}

.itd-property-card {
	display: block;
	color: inherit;
	text-decoration: none;
	border-radius: 16px;
	overflow: hidden;
	background-color: var( --wp--preset--color--base, #ffffff );
}

.itd-property-card__media {
	position: relative;
	aspect-ratio: 4 / 3;
}

.itd-property-card__image,
.itd-property-card__image--placeholder {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: var( --wp--preset--color--tertiary, #f6f4ef );
	color: var( --wp--preset--color--primary, #1c3d2e );
}

.itd-property-card__badge {
	position: absolute;
	top: 12px;
	left: 12px;
	padding: 4px 10px;
	border-radius: 999px;
	background-color: var( --wp--preset--color--primary, #1c3d2e );
	color: var( --wp--preset--color--base, #ffffff );
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
}

.itd-property-card__badge--outline {
	background-color: transparent;
	border: 1px solid var( --wp--preset--color--primary, #1c3d2e );
	color: var( --wp--preset--color--primary, #1c3d2e );
}

.itd-property-single__header .itd-property-card__badge {
	position: static;
	display: inline-block;
	margin: 0 4px 8px;
}

.itd-property-card__body {
	padding: var( --wp--preset--spacing--30, 16px );
}

.itd-property-card__price {
	color: var( --wp--preset--color--primary, #1c3d2e );
	font-weight: 700;
	font-size: 1.125rem;
	margin: 0 0 4px;
}

.itd-property-card__title {
	margin: 0 0 4px;
}

.itd-property-card__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 12px;
	color: var( --wp--preset--color--muted, #5a6259 );
	margin: 0;
	padding: 0;
	list-style: none;
}

.itd-property-card__meta li {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

.itd-property-card__meta svg {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
}

.itd-property-empty {
	color: var( --wp--preset--color--muted, #5a6259 );
}

/* Property single (property CPT) */
.itd-property-single__header {
	text-align: center;
	max-width: 720px;
	margin-inline: auto;
	padding-block: var( --wp--preset--spacing--50, 32px ) var( --wp--preset--spacing--30, 16px );
}

.itd-property-single__breadcrumb {
	text-align: left;
	margin-block-end: var( --wp--preset--spacing--30, 16px );
}

.itd-property-single__breadcrumb a {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	color: var( --wp--preset--color--muted, #5a6259 );
	text-decoration: none;
	font-size: 0.875rem;
}

.itd-property-single__breadcrumb a:hover {
	color: var( --wp--preset--color--primary, #1c3d2e );
	text-decoration: underline;
}

.itd-property-single__address {
	color: var( --wp--preset--color--muted, #5a6259 );
	margin: 4px 0;
}

.itd-property-single__price {
	color: var( --wp--preset--color--primary, #1c3d2e );
	font-size: 1.5rem;
	font-weight: 700;
	margin: 8px 0 0;
}

.itd-property-single__gallery {
	display: grid;
	grid-template-columns: repeat( auto-fit, minmax( 220px, 1fr ) );
	gap: var( --wp--preset--spacing--30, 16px );
	padding-block: var( --wp--preset--spacing--40, 24px );
}

/*
 * Fixed aspect-ratio box regardless of the source photo's own orientation
 * — without it, a portrait photo among landscape ones rendered taller
 * than its row-siblings (grid rows auto-size to their tallest cell), so
 * that one row looked lopsided against the rest of the grid. `overflow:
 * hidden` + `object-fit:cover` on the img crops every photo to the same
 * box instead, same convention as `.itd-media-landscape` and the
 * property card thumbnails elsewhere in this theme.
 */
.itd-property-single__gallery-link {
	display: block;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	border-radius: 16px;
	cursor: zoom-in;
}

.itd-property-single__gallery img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 16px;
}

.itd-property-single__facts {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: var( --wp--preset--spacing--30, 16px );
	list-style: none;
	padding: var( --wp--preset--spacing--20, 12px ) 0 0;
	color: var( --wp--preset--color--contrast, #252b26 );
	font-weight: 700;
}

.itd-property-single__facts li {
	display: flex;
	align-items: center;
	gap: 6px;
}

.itd-property-single__facts svg {
	flex: 0 0 auto;
	width: 20px;
	height: 20px;
	color: var( --wp--preset--color--primary, #1c3d2e );
}

.itd-property-single__content {
	padding-bottom: var( --wp--preset--spacing--40, 24px );
}

.itd-property-single__content-title {
	font-size: 1.5rem;
	color: var( --wp--preset--color--contrast, #252b26 );
	margin: 0 0 var( --wp--preset--spacing--30, 16px );
}

.itd-property-single__specs {
	padding-bottom: var( --wp--preset--spacing--50, 32px );
}

.itd-property-single__specs-title {
	font-size: 1.5rem;
	color: var( --wp--preset--color--contrast, #252b26 );
	margin: 0 0 var( --wp--preset--spacing--40, 24px );
}

.itd-property-single__specs-grid {
	display: grid;
	grid-template-columns: repeat( 2, 1fr );
	column-gap: var( --wp--preset--spacing--50, 32px );
	row-gap: var( --wp--preset--spacing--40, 24px );
}

.itd-property-single__spec {
	display: flex;
	align-items: flex-start;
	gap: var( --wp--preset--spacing--20, 12px );
}

.itd-property-single__spec-icon {
	flex: 0 0 auto;
	width: 26px;
	height: 26px;
	margin-top: 2px;
	color: var( --wp--preset--color--primary, #1c3d2e );
}

.itd-property-single__spec strong {
	display: block;
	color: var( --wp--preset--color--contrast, #252b26 );
}

.itd-property-single__spec span {
	display: block;
	color: var( --wp--preset--color--muted, #5a6259 );
	font-size: 0.9375rem;
}

@media ( max-width: 600px ) {
	.itd-property-single__specs-grid {
		grid-template-columns: 1fr;
	}
}

.itd-property-single__map {
	padding-bottom: var( --wp--preset--spacing--40, 24px );
}

.itd-property-single__map iframe {
	display: block;
	width: 100%;
	height: 420px;
	border: 0;
	border-radius: 16px;
}

/*
 * 2/3 main column + 1/3 sidebar, replacing the old single centered column
 * (each section inside it — gallery/facts/content/specs/map — used to
 * carry its own max-width/margin-inline:auto; that's now set once here on
 * `__main`/`__sidebar` instead). The sidebar's contact form is what used
 * to be a "Request a Viewing" button at the very bottom of a long page —
 * sticky-positioned so it stays reachable while scrolling the listing
 * instead of requiring a scroll to the end to find it.
 */
.itd-property-single__layout {
	display: grid;
	grid-template-columns: 2fr 1fr;
	gap: var( --wp--preset--spacing--60, 40px );
	max-width: var( --wp--style--global--wide-size, 1200px );
	margin-inline: auto;
	padding-inline: var( --wp--preset--spacing--30 );
	align-items: start;
}

.itd-property-single__main {
	min-width: 0;
}

.itd-property-single__sidebar {
	position: sticky;
	top: calc( var( --itd-header-h, 80px ) + var( --wp--preset--spacing--40, 24px ) );
}

.itd-property-single__sidebar-card {
	padding: var( --wp--preset--spacing--50, 32px );
	border-radius: 20px;
	background-color: var( --wp--preset--color--base, #ffffff );
}

.itd-property-single__sidebar-card h2 {
	margin: 0 0 var( --wp--preset--spacing--20, 12px );
	color: var( --wp--preset--color--contrast, #252b26 );
	font-size: 1.25rem;
}

.itd-property-single__sidebar-card > p {
	margin: 0 0 var( --wp--preset--spacing--30, 16px );
	color: var( --wp--preset--color--muted, #5a6259 );
	font-size: 0.9375rem;
}

@media ( max-width: 900px ) {
	.itd-property-single__layout {
		grid-template-columns: 1fr;
	}

	.itd-property-single__sidebar {
		position: static;
	}
}

/*
 * Fullscreen photo lightbox, opened by assets/js/main.js on any gallery
 * photo click. Hidden by the `hidden` attribute (not `display:none` in
 * CSS) so it's removed from the accessibility tree and tab order by
 * default with no extra ARIA bookkeeping — the script only ever toggles
 * that one attribute. `[hidden]` must be spelled out below: it's a UA
 * stylesheet rule, and `.itd-property-single__lightbox {display:flex}

`
 * below is an author-stylesheet rule of the same specificity — cascade
 * order alone would let the author rule win and keep the box visible
 * even while `hidden` is set, since equal specificity falls back to
 * source order rather than origin.
 */
.itd-property-single__lightbox[hidden] {
	display: none;
}

.itd-property-single__lightbox {
	position: fixed;
	inset: 0;
	z-index: 200;
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: rgba( 20, 16, 13, 0.92 );
	padding: var( --wp--preset--spacing--40, 24px );
}

.itd-property-single__lightbox img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	border-radius: 8px;
	object-fit: contain;
}

.itd-property-single__lightbox-close,
.itd-property-single__lightbox-arrow {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 0;
	border-radius: 9999px;
	background-color: rgba( 255, 255, 255, 0.12 );
	color: var( --wp--preset--color--base, #ffffff );
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.itd-property-single__lightbox-close:hover,
.itd-property-single__lightbox-arrow:hover {
	background-color: rgba( 255, 255, 255, 0.24 );
}

.itd-property-single__lightbox-close {
	top: var( --wp--preset--spacing--30, 16px );
	right: var( --wp--preset--spacing--30, 16px );
	width: 44px;
	height: 44px;
}

.itd-property-single__lightbox-arrow {
	top: 50%;
	transform: translateY( -50% );
	width: 52px;
	height: 52px;
}

.itd-property-single__lightbox-arrow--prev {
	left: var( --wp--preset--spacing--30, 16px );
}

.itd-property-single__lightbox-arrow--next {
	right: var( --wp--preset--spacing--30, 16px );
}

.itd-property-single__lightbox-close:focus-visible,
.itd-property-single__lightbox-arrow:focus-visible {
	outline: 2px solid var( --wp--preset--color--base, #ffffff );
	outline-offset: 2px;
}
