/*
Theme Name: Better Home
Theme URI: https://upsitedev.com/
Author: UpSiteDev
Author URI: https://upsitedev.com/
Description: Lightweight block theme (Full Site Editing) for Better Home Realty, a boutique brokerage in Northern New Jersey and Rockland County, NY. All pages are built from Gutenberg blocks and ready-made patterns.
Requires at least: 6.6
Tested up to: 6.8
Requires PHP: 7.4
Version: 0.1.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: betterhome
Tags: block-patterns, full-site-editing, real-estate, one-column, wide-blocks
*/

/* Stacking scale: every layer that competes across the page uses these.
   Small numbers inside a component (1–6: a link over a photo, a badge over
   an image) only order its own parts. */
:root {
	--z-sticky: 20;  /* sticky page bars: listing filters, map bar, blog bar, glossary tools */
	--z-float: 50;   /* fixed bars at the bottom, the WhatsApp button, map buttons */
	--z-header: 60;  /* the sticky site header (its mega panels and phone menu live inside it) */
	--z-mega: 70;    /* mega panels and dropdowns of the header menu */
	--z-banner: 80;  /* the cookie banner */
	--z-modal: 100;  /* dialogs: filter drawer, cookie settings, photo lightbox */
	--z-toast: 110;  /* short notices (favorites) */
	/* Height of the site header's bar (logo, menu, burger), without its 1px
	   bottom line; the phone menu's bar uses the same (blocks/site-nav). */
	--bh-header-h: 92px;
}
@media (max-width: 781px) { :root { --bh-header-h: 62px; } }

/* Most styling lives in theme.json. This file only holds what theme.json cannot express. */

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

:where(a, button, input, select, textarea, summary):focus-visible {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 3px;
}

/* Breadcrumbs -----------------------------------------------------------
   Every template's crumbs (.bh-agents-crumbs in the page and blog blocks,
   .bh-breadcrumb on listings, the archive and term pages). Here, not in a
   block stylesheet, so they never fall back to a numbered list. */
:is(.bh-agents-crumbs, .bh-breadcrumb) ol { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 0.8125rem; line-height: 1.5; color: var(--wp--preset--color--slate); }
:is(.bh-agents-crumbs, .bh-breadcrumb) li { margin: 0; padding: 0; }
:is(.bh-agents-crumbs, .bh-breadcrumb) li:not(:last-child)::after { content: "/"; margin-left: 6px; color: var(--wp--preset--color--stone); }
:is(.bh-agents-crumbs, .bh-breadcrumb) a { color: inherit; text-decoration: none; }
:is(.bh-agents-crumbs, .bh-breadcrumb) a:hover { text-decoration: underline; text-underline-offset: 3px; }
:is(.bh-agents-crumbs, .bh-breadcrumb) [aria-current] { font-weight: 600; color: var(--wp--preset--color--primary); }

/* Header ---------------------------------------------------------------- */
.bh-topbar a { text-decoration: none; white-space: nowrap; }
.bh-topbar a:hover { text-decoration: underline; }
/* Text logo (v1): house mark in a frame, "Better Home" over "REALTY". A plain
   paragraph link, so the header needs no site logo or site title settings. */
.bh-brand { margin: 0; flex-shrink: 0; }
.bh-brand a {
	display: inline-grid; grid-template-columns: 40px auto; column-gap: 12px; row-gap: 4px; align-items: center;
	text-decoration: none; color: var(--wp--preset--color--primary);
}
.bh-brand a::before {
	content: ""; grid-row: 1 / span 2; width: 40px; height: 40px;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40' fill='none' stroke='%23000'%3E%3Crect x='.5' y='.5' width='39' height='39'/%3E%3Cpath d='M12.5 19.5 20 13.5l7.5 6M14.5 18.5v8.5h11v-8.5M18.5 27v-4.5h3V27' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 40px 40px no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40' fill='none' stroke='%23000'%3E%3Crect x='.5' y='.5' width='39' height='39'/%3E%3Cpath d='M12.5 19.5 20 13.5l7.5 6M14.5 18.5v8.5h11v-8.5M18.5 27v-4.5h3V27' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 40px 40px no-repeat;
}
.bh-brand__name, .bh-brand__sub { display: block; }
.bh-brand__name { align-self: end; font: 400 1.3125rem/1 var(--wp--preset--font-family--display); letter-spacing: -.01em; }
.bh-brand__sub { align-self: start; font: 700 0.5625rem/1 var(--wp--preset--font-family--body); letter-spacing: .2em; text-transform: uppercase; color: var(--wp--preset--color--muted); }
/* Logo image (Site Logo setting, inc/site-links.php): replaces the text logo of the header. */
.bh-brand--logo a { display: block; line-height: 0; }
.bh-brand--logo a::before { content: none; }
.bh-brand__logo { display: block; width: 250px; max-width: 100%; height: auto; }
/* On navy (footer) */
.bh-brand--light a, .bh-brand--light a:hover { color: var(--wp--preset--color--white); }
.bh-brand--light .bh-brand__sub { color: var(--wp--preset--color--accent-light); }
/* The bar's height comes from --bh-header-h, not from the logo and padding. */
.bh-header { padding-top: 0 !important; padding-bottom: 0 !important; }
.bh-header > .wp-block-group { min-height: var(--bh-header-h); align-items: center; }
/* The whole header template part sticks (a sticky group inside it could not). */
.wp-site-blocks > header.wp-block-template-part { position: sticky; top: 0; z-index: var(--z-header); }
.admin-bar .wp-site-blocks > header.wp-block-template-part { top: 32px; }
@media (max-width: 782px) { .admin-bar .wp-site-blocks > header.wp-block-template-part { top: 46px; } }
/* Below 600px the admin bar scrolls away with the page. */
@media (max-width: 600px) { .admin-bar .wp-site-blocks > header.wp-block-template-part { top: 0; } }

/* Phones and small tablets: no top bar (the phone is in the menu), compact bar. */
@media (max-width: 781px) {
	.bh-topbar { display: none; }
	.bh-brand a { grid-template-columns: 36px auto; }
	.bh-brand a::before { width: 36px; height: 36px; -webkit-mask-size: 36px 36px; mask-size: 36px 36px; }
	.bh-brand__name { font-size: 1.1875rem; }
	.bh-brand__logo { width: 180px; }
}

/* Header CTA "What's my home worth?" (.bh-btn--cta) -----------------------
   On the core Button wrapper of the header; the link inside carries the text. A core Button cannot hold an SVG,
   so the house and the arrow are SVG masks painted in currentColor. In the
   site editor the button text is a div.wp-block-button__link, hence :is().
   Hover / focus: a brass fill slides in from the left (::before of the
   wrapper), the arrow slides in on the right in space kept for it, the text
   moves 4px left. Only transform and opacity animate. White on brass
   (#845C2C) is 5.9:1. */
.bh-btn--cta {
	--bh-cta-ease: cubic-bezier(.2, .7, .2, 1);
	position: relative; isolation: isolate;
	display: inline-flex;
	border-radius: var(--wp--custom--radius);
	background: var(--wp--preset--color--primary);
	transition: transform 150ms var(--bh-cta-ease);
}
.bh-btn--cta::before {
	content: ""; position: absolute; inset: 0; z-index: -1;
	border-radius: inherit;
	background: var(--wp--preset--color--accent);
	transform: scaleX(0); transform-origin: left;
	transition: transform 450ms var(--bh-cta-ease);
}
.bh-btn--cta > :is(a, .wp-block-button__link),
.bh-btn--cta > :is(a, .wp-block-button__link):hover,
.bh-btn--cta > :is(a, .wp-block-button__link):focus {
	position: relative;
	display: inline-flex; align-items: center; gap: 8px;
	padding: 1rem 2.75rem 1rem 1.25rem;
	background: transparent;
	font-weight: 600; line-height: 1.2; text-decoration: none;
	color: var(--wp--preset--color--white);
	transition: transform 450ms var(--bh-cta-ease);
}
/* House icon */
.bh-btn--cta > :is(a, .wp-block-button__link)::before {
	content: ""; flex-shrink: 0; width: 16px; height: 16px;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 11 12 4l8.5 7'/%3E%3Cpath d='M5.5 9.5V20h13V9.5'/%3E%3Cpath d='M10 20v-5.5h4V20'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 11 12 4l8.5 7'/%3E%3Cpath d='M5.5 9.5V20h13V9.5'/%3E%3Cpath d='M10 20v-5.5h4V20'/%3E%3C/svg%3E") center / contain no-repeat;
}
/* Arrow: hidden in the space kept on the right */
.bh-btn--cta > :is(a, .wp-block-button__link)::after {
	content: ""; position: absolute; top: 50%; right: 1.125rem;
	width: 14px; height: 14px;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12h15M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12h15M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
	opacity: 0;
	transform: translate(-6px, -50%);
	transition: opacity 450ms var(--bh-cta-ease), transform 450ms var(--bh-cta-ease);
}
/* The focus ring sits on the whole button, not on the moving link. */
.bh-btn--cta > a:focus-visible { outline: none; }
.bh-btn--cta:has(> a:focus-visible) { outline: 2px solid var(--wp--preset--color--accent); outline-offset: 3px; }

.bh-btn--cta:has(> a:focus-visible)::before { transform: scaleX(1); }
.bh-btn--cta:has(> a:focus-visible) > a { transform: translateX(-4px); }
/* The link moved 4px left, so the arrow goes 4px right to end in place. */
.bh-btn--cta:has(> a:focus-visible) > a::after { opacity: 1; transform: translate(4px, -50%); }
@media (hover: hover) {
	.bh-btn--cta:hover::before { transform: scaleX(1); }
	.bh-btn--cta:hover > :is(a, .wp-block-button__link) { transform: translateX(-4px); }
	.bh-btn--cta:hover > :is(a, .wp-block-button__link)::after { opacity: 1; transform: translate(4px, -50%); }
}
.bh-btn--cta:active { transform: scale(.98); }

@media (prefers-reduced-motion: reduce) {
	.bh-btn--cta, .bh-btn--cta::before, .bh-btn--cta > :is(a, .wp-block-button__link), .bh-btn--cta > :is(a, .wp-block-button__link)::after { transition: none; }
	.bh-btn--cta::before { transform: none; opacity: 0; }
	.bh-btn--cta:hover::before, .bh-btn--cta:has(> a:focus-visible)::before { transform: none; opacity: 1; }
	.bh-btn--cta:hover > :is(a, .wp-block-button__link), .bh-btn--cta:has(> a:focus-visible) > a { transform: none; }
	.bh-btn--cta > :is(a, .wp-block-button__link)::after,
	.bh-btn--cta:hover > :is(a, .wp-block-button__link)::after,
	.bh-btn--cta:has(> a:focus-visible) > a::after { transform: translate(0, -50%); }
	.bh-btn--cta:active { transform: none; }
}

/* Hero ------------------------------------------------------------------ */
.bh-hero h1 { max-width: 14ch; text-wrap: balance; }
.bh-lede { max-width: 60ch; }
.bh-hero .bh-lede { max-width: 46ch; }
.bh-hero .wp-block-image img { width: 100%; height: auto; }

/* Town index: the signature element ------------------------------------- */
.bh-towns { border-top: 1px solid var(--wp--preset--color--stone); }
.bh-towns > .bh-town {
	margin: 0;
	padding: 0.85rem 0 0.75rem;
	border-bottom: 1px solid var(--wp--preset--color--stone);
	gap: 1rem;
}
.bh-town p { margin: 0; }
.bh-town p:first-child a {
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--x-large);
	font-weight: 450;
	line-height: 1.2;
	color: var(--wp--preset--color--primary);
	text-decoration: none;
}
.bh-town p:first-child a:hover {
	color: var(--wp--preset--color--accent);
	text-decoration: underline;
	text-underline-offset: 0.18em;
	text-decoration-thickness: 1px;
}
.bh-town p:last-child {
	color: var(--wp--preset--color--slate);
	font-size: var(--wp--preset--font-size--small);
	white-space: nowrap;
	flex-shrink: 0;
}

/* Listing cards ---------------------------------------------------------- */
.bh-listing { height: 100%; }
.bh-listing .wp-block-image { margin: 0; }
.bh-listing .wp-block-image img { aspect-ratio: 4 / 3; object-fit: cover; width: 100%; border-radius: var(--wp--custom--radius) var(--wp--custom--radius) 0 0; }
.bh-listing .bh-price { font-variant-numeric: tabular-nums; }
.bh-status {
	display: inline-block;
	padding: 0.15rem 0.55rem;
	border-radius: 999px;
	background: var(--wp--preset--color--linen);
	color: var(--wp--preset--color--dark);
	font-weight: 600;
}

/* Facts row ------------------------------------------------------------- */
.bh-facts .wp-block-column { border-left: 2px solid var(--wp--preset--color--accent); padding-left: 1rem; }

/* Team ------------------------------------------------------------------ */
.bh-initials { width: 5.5rem; height: 5.5rem; }
.bh-initials p { margin: 0; }
.bh-agent .wp-block-image img { aspect-ratio: 1; object-fit: cover; width: 5.5rem; border-radius: 999px; }
.bh-agent p { margin: 0; }

/* Footer ---------------------------------------------------------------- */
.wp-site-blocks > footer { margin-block-start: 0; }
.wp-site-blocks > header + * { margin-block-start: 0; }
.bh-plain-list { list-style: none; }

/* Utilities ------------------------------------------------------------- */
.bh-nowrap { white-space: nowrap; }
.bh-tabular { font-variant-numeric: tabular-nums; }

/* Below 1024px the menu (bh/site-nav) is the burger and its full-screen menu,
   which holds the phone and "What's my home worth?": the CTA hides. */
@media (max-width: 1023px) {
	.bh-header .bh-header-cta, .bh-header .wp-block-buttons.bh-header-cta { display: none; }
}

/* WhatsApp button (inc/whatsapp.php) -------------------------------------
   Bottom right on every page; --bh-wa-lift (set by its script) keeps it above
   bars fixed at the bottom. Transform and opacity only. */
.bh-wa {
	--bh-wa-lift: 0px;
	position: fixed; z-index: var(--z-float);
	right: calc(20px + env(safe-area-inset-right));
	bottom: calc(20px + env(safe-area-inset-bottom));
	display: flex; align-items: center; gap: 10px;
	text-decoration: none;
	/* The lift is a transform: no layout shift when a bottom bar appears. */
	transform: translateY(calc(-1 * var(--bh-wa-lift)));
	transition: transform 220ms var(--wp--custom--ease, ease), opacity 220ms ease;
}
.bh-wa__circle {
	display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
	background: #25D366; color: #fff;
	box-shadow: 0 6px 18px rgba(15, 27, 45, .22), 0 2px 4px rgba(15, 27, 45, .12);
	transition: transform 220ms var(--wp--custom--ease, ease);
}
.bh-wa__label {
	padding: 9px 14px; border-radius: 20px;
	background: var(--wp--preset--color--white); color: var(--wp--preset--color--primary);
	box-shadow: 0 6px 18px rgba(15, 27, 45, .16);
	font: 600 0.8125rem/1 var(--wp--preset--font-family--body); white-space: nowrap;
	opacity: 0; transform: translateX(10px); pointer-events: none;
	transition: transform 220ms var(--wp--custom--ease, ease), opacity 220ms ease;
}
@media (hover: hover) and (pointer: fine) {
	.bh-wa:hover .bh-wa__label, .bh-wa:focus-visible .bh-wa__label { opacity: 1; transform: none; }
	.bh-wa:hover .bh-wa__circle { transform: scale(1.06); }
}
@media (hover: none) { .bh-wa__label { display: none; } }
.bh-wa:focus-visible { outline: none; }
.bh-wa:focus-visible .bh-wa__circle { box-shadow: 0 0 0 3px var(--wp--preset--color--light), 0 0 0 5px var(--wp--preset--color--accent); }
/* Above the phone bars of listings and agent profiles even before the script runs. */
@media (max-width: 899px) { body:has(.bh-listing-mobile-bar) .bh-wa { --bh-wa-lift: 76px; } }
@media (max-width: 1023px) { body:has(.bh-agent-bar) .bh-wa { --bh-wa-lift: 70px; } }
/* Map view on phones: hidden while the map is open. */
body.bh-mv-map-open .bh-wa { opacity: 0; transform: translateY(calc(12px - var(--bh-wa-lift))); pointer-events: none; visibility: hidden; }
@media (prefers-reduced-motion: reduce) { .bh-wa, .bh-wa__circle, .bh-wa__label { transition: none; } }
@media print { .bh-wa { display: none !important; } }

/* Back to top (inc/to-top.php) --------------------------------------------
   A 40px circle centred over the WhatsApp circle (56px, 20px from the edges,
   12px gap), lifted with it above bottom bars (--bh-wa-lift on <html>).
   Shown after 1.5 screens of scrolling; transform and opacity only. */
.bh-totop {
	position: fixed; z-index: var(--z-float);
	right: calc(28px + env(safe-area-inset-right));
	bottom: calc(20px + env(safe-area-inset-bottom));
	display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
	background: var(--wp--preset--color--white); color: var(--wp--preset--color--primary);
	box-shadow: 0 0 0 1px var(--wp--preset--color--line), 0 4px 14px rgba(15, 27, 45, .16);
	opacity: 0; visibility: hidden; pointer-events: none;
	transform: translateY(calc(10px - var(--bh-wa-lift, 0px)));
	transition: opacity 200ms ease, transform 200ms var(--wp--custom--ease, ease), visibility 0s linear 200ms, background-color 200ms ease, color 200ms ease;
}
.bh-totop--wa { bottom: calc(88px + env(safe-area-inset-bottom)); }
.bh-totop.is-shown {
	opacity: 1; visibility: visible; pointer-events: auto;
	transform: translateY(calc(-1 * var(--bh-wa-lift, 0px)));
	transition-delay: 0s;
}
.bh-totop:hover { background: var(--wp--preset--color--primary); color: var(--wp--preset--color--white); }
.bh-totop:focus-visible { outline: 2px solid var(--wp--preset--color--accent); outline-offset: 3px; }
/* The phone bars of listings and agent profiles, as for the WhatsApp button. */
@media (max-width: 899px) { body:has(.bh-listing-mobile-bar) .bh-totop { --bh-wa-lift: 76px; } }
@media (max-width: 1023px) { body:has(.bh-agent-bar) .bh-totop { --bh-wa-lift: 70px; } }
body.bh-mv-map-open .bh-totop { opacity: 0; visibility: hidden; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .bh-totop { transition: none; } }
@media print { .bh-totop { display: none !important; } }

/* Equal Housing Opportunity logo in the footer copyright line (inc/eho.php) */
.bh-eho { display: inline-block; margin: 0 4px 0 6px; vertical-align: -6px; }

/* Scrolling tables in content are focusable regions (inc/a11y.php). */
:is(.wp-block-table, .bh-table-wrap)[tabindex]:focus-visible { outline: 2px solid var(--wp--preset--color--accent); outline-offset: 2px; }
