/*
 * Place map -- the design's Places view.
 *
 * Source of every value here: docs/design/README.md section 5 ("Places (map)"). Where a value is
 * a palette colour it is written as a --nfv-* token and NOT as a hex, because inc/chrome.php's
 * :root block is the only place this project states a colour (NFV-071). Two literals survive on
 * purpose and are marked below: a drop shadow and a tile filter, neither of which is a palette
 * entry.
 *
 * WHAT THIS FILE IS *NOT*
 * -----------------------
 * The design's section 5 is a standalone Places route with its own eyebrow and H2 ("Where the
 * Nelsons lived"). This shortcode is not that route -- it renders inside a family-group page,
 * between that page's intro paragraph and its own first <h2> (measured on pages 13487 and 13584,
 * 2026-08-19). So the header, the eyebrow and the "Places / Migration over time" toggle are
 * deliberately absent: printing "Where the Nelsons lived" above a map embedded on "The Nelson
 * Family of Owen Township" page would assert a heading that is not that page's subject.
 *
 * The migration slider that section 5 also describes is NOT built. It needs a year and a caption
 * sentence per stop, and no such field exists on a Place record -- see docs/DECISIONS.md NFV-076.
 * That is why --nfv-pill-faded still has no consumer; it is the migration pill's colour and it is
 * waiting for data, not for code.
 *
 * LOADING
 * -------
 * Enqueued from the shortcode (inc/place-map.php), so it only reaches the two pages that carry a
 * map. It depends on the 'leaflet' style handle because every .leaflet-* rule below is an
 * override and must come after Leaflet's own sheet. It does NOT travel to webtrees: the chrome
 * export renders only the header and footer template parts, so this shortcode never runs there
 * and this handle is never in that queue (verified anonymously on /tree/ after release).
 */

/*
 * The wrapper exists ONLY to be a query container. The layout below has to respond to the width
 * of the COLUMN this shortcode was dropped into, not to the width of the window -- measured on
 * staging 2026-08-19, a 1440px window gives this block a 645px column, because Twenty
 * Twenty-Five's default content width is narrow and the map sits in the normal content flow. A
 * viewport media query cannot tell those two apart, so it would have shipped a 413px map inside a
 * 1440px window. An element cannot query itself, hence the extra div.
 */
.nfv-place-map-wrap {
	container-type: inline-size;
}

.nfv-place-map-frame {
	display: flex;
	align-items: stretch;
	height: 620px;
	border: 1px solid var(--nfv-line);
	border-radius: 4px;
	overflow: hidden;
	background: var(--nfv-surface);
	font-family: var(--nfv-font-ui);
}

/* --- the place list ------------------------------------------------------------------------- */

.nfv-place-map-list {
	flex: 0 0 230px;
	width: 230px;
	background: var(--nfv-surface);
	border-right: 1px solid var(--nfv-line);
	padding: 22px 20px;
	overflow-y: auto;
}

.nfv-place-map-list ol {
	list-style: none;
	margin: 0;
	padding: 0;
}

.nfv-place-map-list li + li {
	margin-top: 2px;
}

/*
 * A real <a> to the Place record, upgraded by place-map.js into a fly-to control. With scripting
 * off the link still works, which is why this is an anchor and not a <button>: the fallback has
 * to go somewhere, and the Place page is where the prose lives.
 */
.nfv-place-map-row {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	padding: 7px 8px;
	border-radius: 3px;
	text-decoration: none;
	color: var(--nfv-ink);
}

.nfv-place-map-row:hover,
.nfv-place-map-row:focus-visible {
	background: var(--nfv-line-softest);
	color: var(--nfv-ink);
	text-decoration: none;
}

.nfv-place-map-row:focus-visible {
	outline: 2px solid var(--nfv-accent);
	outline-offset: 1px;
}

.nfv-place-map-row[aria-current="true"] {
	background: var(--nfv-accent-tint);
	color: var(--nfv-accent);
}

.nfv-place-map-badge {
	flex: 0 0 19px;
	width: 19px;
	height: 19px;
	border-radius: 50%;
	background: var(--nfv-accent);
	color: var(--nfv-surface);
	font-family: var(--nfv-font-ui);
	font-size: 10.5px;
	line-height: 19px;
	text-align: center;
	font-weight: 500;
}

.nfv-place-map-name {
	font-family: var(--nfv-font-display);
	font-size: 15px;
	line-height: 1.3;
}

/* --- the map itself ------------------------------------------------------------------------- */

.nfv-place-map {
	flex: 1 1 auto;
	min-width: 0;
	height: 100%;
	background: var(--nfv-map-bg);
}

/*
 * Tiles are tinted to the palette. Values are the design's, verbatim. This is a filter, not a
 * colour, so it is not a token. It is scoped to the tile pane on purpose: the attribution and the
 * zoom control live in other panes and must stay untinted and legible.
 */
.nfv-place-map .leaflet-tile-pane {
	filter: sepia(.32) saturate(.72) brightness(1.03);
}

.nfv-place-map.leaflet-container {
	font-family: var(--nfv-font-ui);
}

/*
 * Numbered marker. The shadow is the design's literal value -- a shadow is not a palette entry,
 * and expressing it as a token would state a colour this project's :root block does not hold.
 */
.nfv-place-map-pin {
	display: block;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: var(--nfv-accent);
	color: var(--nfv-surface);
	font-family: var(--nfv-font-ui);
	font-size: 11.5px;
	font-weight: 500;
	line-height: 24px;
	text-align: center;
	box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}

.nfv-place-map .leaflet-popup-content-wrapper,
.nfv-place-map .leaflet-popup-tip {
	background: var(--nfv-surface);
	color: var(--nfv-ink);
	border-radius: 3px;
	box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}

.nfv-place-map .leaflet-popup-content {
	margin: 10px 14px;
	font-family: var(--nfv-font-display);
	font-size: 15px;
	line-height: 1.3;
}

.nfv-place-map .leaflet-popup-content a {
	color: var(--nfv-accent);
}

/*
 * OpenStreetMap attribution. It is a LICENCE REQUIREMENT and must stay readable -- do not hide
 * it, do not shrink it away, do not move it behind the tile filter. These rules only bring its
 * colours onto the palette.
 */
.nfv-place-map .leaflet-control-attribution {
	background: var(--nfv-surface);
	color: var(--nfv-muted);
	font-family: var(--nfv-font-ui);
	font-size: 10.5px;
}

.nfv-place-map .leaflet-control-attribution a {
	color: var(--nfv-accent);
}

.nfv-place-map .leaflet-bar a {
	background: var(--nfv-surface);
	color: var(--nfv-ink);
	border-bottom-color: var(--nfv-line);
}

.nfv-place-map .leaflet-bar a:hover {
	background: var(--nfv-line-softest);
	color: var(--nfv-ink);
}

/*
 * Leaflet did not initialise (blocked CDN, or a bad marker payload). place-map.js sets this so a
 * dead 620px rectangle never ships; the list stands on its own, which is what it is for.
 */
.nfv-place-map-frame.is-listonly {
	height: auto;
}

.nfv-place-map-frame.is-listonly .nfv-place-map {
	display: none;
}

.nfv-place-map-frame.is-listonly .nfv-place-map-list {
	flex: 1 1 auto;
	width: auto;
	border-right: 0;
}

/* --- narrow containers and narrow screens ---------------------------------------------------- */

/*
 * THE STACKED LAYOUT. List on top, map beneath, both full width.
 *
 * 700px is derived, not picked: the sidebar is 230px, and below a map of about 460px the sidebar
 * costs more width than the map has to spare. 230 + 460 + the 1px rule rounds to 700.
 *
 * On this site every page that carries a map has a 645px content column, so THIS is the layout
 * that actually renders today; the side-by-side one above is what a wider column -- or the
 * design's own full-width Places route, if it is ever built -- would get. Do not delete it as
 * dead code.
 *
 * The list stays first in the DOM and first on screen. It is the accessible representation of the
 * map (an <ol> of real links), so reading order and visual order agreeing is worth more here than
 * putting the picture first.
 */
@container (max-width: 700px) {
	.nfv-place-map-frame {
		display: block;
		height: auto;
	}

	.nfv-place-map {
		height: 420px;
	}

	.nfv-place-map-list {
		width: auto;
		border-right: 0;
		border-bottom: 1px solid var(--nfv-line);
		overflow-y: visible;
	}
}

/*
 * Same layout again, keyed to the viewport, for two reasons: a browser without container queries
 * would otherwise get the side-by-side layout at 375px, and a phone wants a shorter map than a
 * narrow column on a desktop does. 781px is WordPress' own mobile breakpoint. Rows keep their
 * 44px minimum, which is the tap-target floor this project measures.
 */
@media (max-width: 781px) {
	.nfv-place-map-frame {
		display: block;
		height: auto;
	}

	.nfv-place-map {
		height: 360px;
	}

	.nfv-place-map-list {
		width: auto;
		border-right: 0;
		border-bottom: 1px solid var(--nfv-line);
		padding: 14px 12px;
		overflow-y: visible;
	}
}
