/**
 * The homes map's own chrome — the canvas, the pins, the popup card and the two lines of text.
 *
 * Leaflet's stylesheet does the positioning (tiles, panes, popups) and is served beside this one,
 * first. What lives here is only what makes the map read as part of this site: theme.json's tokens
 * for every colour, size and space, the shape of a pin, and a popup that is a small listing card.
 *
 * The status badge inside the popup is NewPad Core's .newpad-badge from inventory.css — one rule
 * owns that badge everywhere it appears — which is why Core lists this block among the ones that
 * stylesheet is enqueued for. The "Photo similar" badge is the same arrangement.
 */

/* --- the canvas ------------------------------------------------------------ */

/*
 * ⚠ box-sizing IS SAID HERE because a border sits next to a height — CLAUDE.md's rule, learned from
 * .newpad-banner. The canvas takes its WIDTH from the section (auto, never 100%), so it cannot
 * measure wider than its container whatever padding anyone adds to it later.
 *
 * `isolation: isolate` because Leaflet's panes carry z-indexes up to 1000 and its popups 700.
 * Contained here, they stack against each other and never against the header's menu overlay or
 * anything else on the page.
 */
.newpad-map__canvas {
	box-sizing: border-box;
	height: clamp(300px, 55vh, 480px);
	overflow: hidden;
	border: 1px solid var(--wp--preset--color--sage);
	/* The card radius — ticket 31 — so the map panel and the cards above it are one family. The
	   pins, the fan-out and the tiles inside are unchanged; only the frame is. */
	border-radius: var(--wp--custom--radius--card);
	box-shadow: var(--wp--preset--shadow--card);
	background-color: var(--wp--preset--color--smoke);
	isolation: isolate;
}

/* Leaflet sets Helvetica at 12px on its container. The attribution and the popup are this site's. */
.newpad-map__canvas.leaflet-container {
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--small);
}

.newpad-map__canvas .leaflet-control-attribution a {
	color: var(--wp--preset--color--navy);
}

/* With JavaScript off, the box says so. The module hides this the moment it mounts. */
.newpad-map__fallback {
	margin: 0;
	padding: var(--wp--preset--spacing--30);
	color: var(--wp--preset--color--muted);
}

.newpad-map__count {
	margin: 0 0 var(--wp--preset--spacing--20);
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
}

/* Shown by the module on a phone only, and hidden again while the map is unlocked — see view.js. */
.newpad-map__hint {
	margin: var(--wp--preset--spacing--10) 0 0;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
}

/* --- tap to move: the outline and the Done control ------------------------- */

/*
 * The canvas while one finger moves it — `newpad-map--moving` on the section, set by view.js on a
 * tap of the background and cleared by Done or a tap outside (ticket 35). An OUTLINE, not a
 * border: a border is inside the box, so it would take 3px off the tiles and make Leaflet
 * re-measure; an outline paints outside, follows the card radius, and changes no size. No
 * transition, on purpose — the module honours prefers-reduced-motion for every animation it
 * owns, and a state change nothing animates needs no exception.
 *
 * ⚠ !important, AND IT IS THE ONLY WAY THIS RULE CAN WIN. Leaflet's DomUtil.preventOutline() runs
 * on every mousedown on the map — a tap sends one — and writes `outline-style: none` INLINE on the
 * container to hide the browser's focus ring after a click, restoring it on the next keydown. An
 * inline declaration beats any class rule, so without this the outline computed `none 3px green`
 * and nothing showed; measured in the browser pane on 2026-10-08, after the first draft read
 * correct. The shorthand is width, style and colour; the offset is a separate property Leaflet
 * never writes inline.
 */
.newpad-map--moving .newpad-map__canvas {
	outline: 3px solid var(--wp--preset--color--brand-green) !important;
	outline-offset: 2px;
}

/*
 * Done: a real <button> inside a Leaflet control, top right. 44px — the floor every tap target on
 * this site keeps — on the count pill's pair, paper on ink (.newpad-gallery__count in
 * inventory.css), and NEVER paper on green, which is 2.4:1 and below every floor there is. The
 * display face at the one weight it ships in, stated. box-sizing is stated because padding sits
 * beside a size — CLAUDE.md's rule — though the padding here is horizontal only, so the 44px is
 * the min-height either way, as .newpad-gallery__count notes of the same shape. Leaflet's own
 * 10px control margin is kept, so Done sits exactly where
 * the zoom buttons sit on the other side. Two classes deep so it beats Leaflet's `.leaflet-control`
 * rules on specificity, not on print order.
 */
.newpad-map__canvas .newpad-map__done {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0 var(--wp--preset--spacing--20);
	border: 0;
	border-radius: var(--wp--custom--radius--button);
	background-color: var(--wp--preset--color--ink);
	color: var(--wp--preset--color--paper);
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
}

.newpad-map__canvas .newpad-map__done:hover,
.newpad-map__canvas .newpad-map__done:focus-visible {
	background-color: var(--wp--preset--color--navy);
	color: var(--wp--preset--color--paper);
}

/* Inside the pill, as the count pill draws it: an outline outside would sit over the tiles. */
.newpad-map__canvas .newpad-map__done:focus-visible {
	outline: 2px solid var(--wp--preset--color--paper);
	outline-offset: -5px;
}

/* --- the pins -------------------------------------------------------------- */

/*
 * A DivIcon 44px square — the tap floor every control on this site is measured against — with the
 * pin drawn inside it and its tip at the bottom centre, where view.js anchors it. Leaflet's own
 * `.leaflet-div-icon` white box does not apply: passing a className replaces it.
 */
.newpad-pin {
	border: 0;
	background: none;
}

/*
 * The head is a 26px square with three corners rounded, turned so the sharp one points down: the
 * tip lands 2px above the icon's bottom edge, the top of the head 5px below its top edge, and the
 * 44px box around it is what a thumb has to hit. Paper edge so it reads over any tile; the colour
 * is the status, and the name beside it says the status in words for anyone colour cannot reach.
 */
.newpad-pin__head {
	position: absolute;
	top: 10px;
	left: 9px;
	box-sizing: border-box;
	width: 26px;
	height: 26px;
	border: 2px solid var(--wp--preset--color--paper);
	border-radius: 50% 50% 50% 0;
	background-color: var(--wp--preset--color--brand-green);
	box-shadow: 0 1px 3px rgba(15, 28, 3, 0.35);
	transform: rotate(-45deg);
}

/*
 * The three tones, exactly the badge's three — and the badge changed in ticket 31, so these did
 * too: Coming Soon is paper with an ink edge, Under Contract and Sold are sage with an ink edge,
 * as the mockup's legend draws them. The paper edge the green pin keeps would vanish on a paper
 * pin and wash out on a sage one over pale tiles, so those two take ink. Nothing about the pin's
 * shape, its 44px box, its fan-out or the tiles changed; only the colours, which is what "the
 * badge's three" has meant since ticket 12.
 */
.newpad-pin--upcoming .newpad-pin__head {
	background-color: var(--wp--preset--color--paper);
	border-color: var(--wp--preset--color--ink);
}

.newpad-pin--taken .newpad-pin__head {
	background-color: var(--wp--preset--color--sage);
	border-color: var(--wp--preset--color--ink);
}

.newpad-pin:focus-visible {
	outline: 2px solid var(--wp--preset--color--navy);
	outline-offset: -3px;
	border-radius: 50%;
}

/* The pin's name: read, never seen. */
.newpad-pin__name {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* The line from a fanned-out pin back to the point it stands for. Leaflet writes the stroke as an
   SVG attribute; this rule outranks it. */
.newpad-pin__leg {
	stroke: var(--wp--preset--color--muted);
	stroke-dasharray: 3 3;
}

/* --- the popup: a small listing card ---------------------------------------- */

.newpad-map__popup .leaflet-popup-content-wrapper {
	padding: 0;
	overflow: hidden;
	border-radius: var(--wp--custom--radius--control);
	background-color: var(--wp--preset--color--paper);
	color: var(--wp--preset--color--ink);
	box-shadow: 0 3px 14px rgba(15, 28, 3, 0.3);
}

.newpad-map__popup .leaflet-popup-content {
	margin: 0;
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.4;
}

.newpad-map__popup .leaflet-popup-tip {
	background-color: var(--wp--preset--color--paper);
}

/*
 * Leaflet's close button is 24px square. Up to the 44px floor, on a paper disc so it reads over any
 * photograph. z-index 2: the badge over the photograph carries 1, and the title's stretched link
 * below carries none — both would otherwise paint over it. Three selectors deep so it outranks
 * Leaflet's own `.leaflet-container a.leaflet-popup-close-button` on specificity, not on print order.
 */
.newpad-map__canvas .newpad-map__popup a.leaflet-popup-close-button {
	top: 4px;
	right: 4px;
	z-index: 2;
	width: 44px;
	height: 44px;
	padding: 0;
	border-radius: 50%;
	background-color: rgba(254, 255, 251, 0.85);
	color: var(--wp--preset--color--ink);
	font: 22px/44px var(--wp--preset--font-family--body);
	text-align: center;
}

.newpad-map__card {
	position: relative;
}

/*
 * ⚠ LEAFLET STYLES EVERY <p> IN A POPUP — `.leaflet-popup-content p { margin: 1.08333em 0 }`, one
 * class and one element — and that outranks a single class saying `margin: 0`. Measured before
 * this rule: a 395px popup with 45px of air between the town and the price. The card's lines are
 * spaced by the body's gap and nothing else.
 */
.newpad-map__popup .newpad-map__card p {
	margin: 0;
}

.newpad-map__media {
	position: relative;
	aspect-ratio: 16 / 10;
	overflow: hidden;
	background-color: var(--wp--preset--color--smoke);
}

.newpad-map__media--empty {
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--wp--preset--color--muted);
}

.newpad-map__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* The two badges sit where they sit on every card: status top left, disclosure bottom right. */
.newpad-map__media .newpad-badge {
	position: absolute;
	z-index: 1;
	top: var(--wp--preset--spacing--10);
	left: var(--wp--preset--spacing--10);
}

.newpad-map__media .newpad-photo-badge {
	position: absolute;
	z-index: 1;
	right: var(--wp--preset--spacing--10);
	bottom: var(--wp--preset--spacing--10);
}

.newpad-map__body {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	padding: var(--wp--preset--spacing--20);
}

/* `lead` and an explicit 700, as every card title on the site — see inventory.css. */
.newpad-map__title {
	margin: 0;
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--lead);
	font-weight: 700;
	line-height: 1.2;
}

/* Two classes deep so it beats Leaflet's `.leaflet-container a` blue. */
.newpad-map__canvas .newpad-map__title a {
	color: var(--wp--preset--color--ink);
	text-decoration: none;
}

/* One link, a whole clickable card — the same overlay .newpad-card__title a::after uses. */
.newpad-map__title a::after {
	content: "";
	position: absolute;
	inset: 0;
}

.newpad-map__title a:focus-visible::after {
	outline: 2px solid var(--wp--preset--color--navy);
	outline-offset: -2px;
}

.newpad-map__price {
	margin: 0;
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 700;
}

.newpad-map__location,
.newpad-map__summary {
	margin: 0;
	color: var(--wp--preset--color--muted);
}
