/* iURBAN Map block (front and editor). The map is drawn by Route's render bundle
   (decision 018); this file only sizes the frame and shows the paper box and spinner.
   Shapes: plans/map-embed.md A3 (16:9, 4:3, 1:1, 4:5): the column's full width and the chosen ratio,
   no height cap (owner 2026-11-13). The homepage cards size their own frames. */
.iurban-map {
	margin-block: 1.5rem;
	margin-inline: 0;
	container-type: inline-size; /* the phone shape below reads the frame's own width, the same 600 px view.js uses for the camera */
}

.iurban-map__frame {
	position: relative;
	width: 100%;
	height: 320px;
	background: var(--wp--preset--color--ivory, #f8f5ee);
	overflow: hidden;
	isolation: isolate; /* Pins and controls (z-index up to 100000) stay inside the map, under the contents bar (24-25). */
}

/* The frame's shape, the post's choice (plans/map-embed.md A3): the width is the column, the height follows.
   Before the fullscreen rules below, which must win. */
.iurban-map--ar-16-9 .iurban-map__frame {
	height: auto;
	aspect-ratio: 16 / 9;
}

.iurban-map--ar-4-3 .iurban-map__frame {
	height: auto;
	aspect-ratio: 4 / 3;
}

.iurban-map--ar-1-1 .iurban-map__frame {
	height: auto;
	aspect-ratio: 1 / 1;
}

.iurban-map--ar-4-5 .iurban-map__frame {
	height: auto;
	aspect-ratio: 4 / 5;
}

/* The phone shape (owner 2026-12-06): a frame under 600 px wide (view.js's phone width, not the viewport) takes
   `aspectPhone` when the post set it; none set = the desktop shape above. Before the fullscreen rules. */
@container (max-width: 599px) {
	.iurban-map--arp-16-9 .iurban-map__frame {
		height: auto;
		aspect-ratio: 16 / 9;
	}

	.iurban-map--arp-4-3 .iurban-map__frame {
		height: auto;
		aspect-ratio: 4 / 3;
	}

	.iurban-map--arp-1-1 .iurban-map__frame {
		height: auto;
		aspect-ratio: 1 / 1;
	}

	.iurban-map--arp-4-5 .iurban-map__frame {
		height: auto;
		aspect-ratio: 4 / 5;
	}
}

.iurban-map__caption {
	margin-block-start: 0.5rem;
	font-size: 0.875rem;
	line-height: 1.5;
	opacity: 0.72;
}

/* Full screen corner (owner 2026-11-15, docs/ui-rules.md › Map buttons): one spacing set. The colour logo
   sits top right at the edge; the buttons are a right-aligned column under it, the gap apart; the credit (i)
   sits left of the logo, centred on it, the whole time (it never moves while the buttons fade).
   Never on the map inside the article. One element, CSS only. */
.iurban-map__frame {
	--irm-edge: 12px;
	--irm-gap: 8px;
	--irm-logo-w: 87px;
	--irm-logo-h: 22px;
}

@media (max-width: 599px) {
	.iurban-map__frame {
		--irm-edge: 10px;
		--irm-logo-w: 71px;
		--irm-logo-h: 18px;
	}
}

.iurban-map__logo {
	display: none;
	position: absolute;
	z-index: 100000; /* above Route pins (from 1000), like the control corners */
	width: var(--irm-logo-w);
	height: var(--irm-logo-h);
	background: url("../../assets/img/logo-colour.svg") right center / contain no-repeat;
	pointer-events: none;
}

.iurban-map__frame:fullscreen .iurban-map__logo,
.iurban-map__frame.irm-full .iurban-map__logo {
	display: block;
	top: calc(env(safe-area-inset-top, 0px) + var(--irm-edge));
	right: calc(env(safe-area-inset-right, 0px) + var(--irm-edge));
}

.iurban-map__frame:fullscreen .maplibregl-ctrl-top-right,
.iurban-map__frame.irm-full .maplibregl-ctrl-top-right {
	top: calc(env(safe-area-inset-top, 0px) + var(--irm-edge) + var(--irm-logo-h) + var(--irm-gap));
	right: calc(env(safe-area-inset-right, 0px) + var(--irm-edge));
	gap: var(--irm-gap);
}

.iurban-map__frame:fullscreen .maplibregl-ctrl-top-right .maplibregl-ctrl,
.iurban-map__frame.irm-full .maplibregl-ctrl-top-right .maplibregl-ctrl {
	margin: 0;
}


/* Fullscreen (MapLibre's own button): the frame fills the screen. */
.iurban-map__frame:fullscreen {
	height: 100%;
}

.iurban-map__frame:-webkit-full-screen {
	height: 100%;
}

/* The inline data is for the script, never shown. */
.iurban-map__data {
	display: none;
}

/* Spinner: until the first full frame. */
.iurban-map__spin {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 24px;
	height: 24px;
	margin: -12px 0 0 -12px;
	border: 2px solid rgba(34, 34, 34, 0.18);
	border-top-color: rgba(34, 34, 34, 0.6);
	border-radius: 50%;
	animation: iurban-map-spin 0.8s linear infinite;
	pointer-events: none;
}

.iurban-map__frame.is-live .iurban-map__spin,
.iurban-map__frame.is-failed .iurban-map__spin {
	display: none;
}

@keyframes iurban-map-spin {
	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	.iurban-map__spin {
		animation: none;
	}
}

/* Could not load: the box stays, one grey line (A4). */
.iurban-map__fail {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	color: var(--wp--preset--color--ink-soft, #6b7076);
	font-size: 14px;
}

.iurban-map__frame .maplibregl-ctrl-attrib {
	font-size: 10px;
}

/* Credit button (i): small and faint, but never gone. The corner sits above Route's pins
   (their z-index starts at 1000) so a pin cannot cover it. Open, the credit is full size. */
.iurban-map__frame .maplibregl-ctrl-bottom-right,
.iurban-map__frame .maplibregl-ctrl-top-right,
.iurban-map__frame .maplibregl-ctrl-top-left {
	z-index: 100000;
}

.iurban-map__frame .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show) {
	width: 18px;
	height: 18px;
	min-height: 0;
	margin: 6px;
	padding: 0;
	background-color: rgba(255, 255, 255, 0.55);
	opacity: 0.7;
}

.iurban-map__frame .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show) .maplibregl-ctrl-attrib-button {
	width: 18px;
	height: 18px;
	background-size: 18px 18px;
}

.iurban-map__frame .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show):hover,
.iurban-map__frame .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show):focus-within {
	opacity: 1;
}

/* The credit (i) is the last of the top-right buttons on every map (map-core adds it there; owner 2026-11-11, one code for the post and homepage maps): a column, right aligned, the (i) last and centred under the 32 px buttons. */
.iurban-map__frame .maplibregl-ctrl-top-right {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
}

.iurban-map__frame .maplibregl-ctrl-top-right .maplibregl-ctrl-attrib {
	order: 9;
}

/* Outside full screen the (i) sits left of the first button (full screen), 8 px apart, centred on it (owner 2026-11-15, 0.38.9);
   the 5 s credit text opens leftward from there, along the top edge. */
.iurban-map__frame .maplibregl-ctrl-top-right .maplibregl-ctrl-attrib.maplibregl-compact,
.iurban-map__frame .maplibregl-ctrl-top-right .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show) {
	position: absolute;
	top: 14px; /* 6 px corner margin + (34 px button - 18 px (i)) / 2 */
	right: 48px; /* 6 px corner margin + 34 px button + 8 px gap */
	margin: 0;
}

/* Placed absolutely, the open credit would shrink to a narrow box and wrap: keep it on one line. Open, it sits 4 px higher than the folded (i) (owner 2026-11-15). */
.iurban-map__frame .maplibregl-ctrl-top-right .maplibregl-ctrl-attrib.maplibregl-compact-show {
	white-space: nowrap;
	top: 10px;
}

/* Map buttons (full screen, + / -): one quiet family (docs/ui-rules.md, Map buttons). MapLibre's own
   controls, restyled here; the icons are our own thin outlines (1.5 px, round caps) as masks, so the
   colour follows the button state. The box is 32 px; the touch area is 44 px (the ::after). */
.iurban-map__frame .maplibregl-ctrl-top-left .maplibregl-ctrl,
.iurban-map__frame .maplibregl-ctrl-top-right .maplibregl-ctrl {
	margin: 6px 6px 0 6px;
}

.iurban-map__frame .maplibregl-ctrl-group {
	overflow: visible;
	border: 1px solid rgba(28, 35, 48, 0.1);
	border-radius: 8px;
	background: #fff;
	box-shadow: 0 1px 2px rgba(20, 28, 45, 0.06);
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
	.iurban-map__frame .maplibregl-ctrl-group {
		background: rgba(255, 255, 255, 0.8);
		-webkit-backdrop-filter: blur(6px);
		backdrop-filter: blur(6px);
	}
}

.iurban-map__frame .maplibregl-ctrl-group button {
	position: relative;
	width: 32px;
	height: 32px;
	background: transparent;
}

.iurban-map__frame .maplibregl-ctrl-group button::after {
	content: "";
	position: absolute;
	inset: -6px;
}

/* In a stack the touch areas must not overlap: the 44 px grows outward from the outer ends. */
.iurban-map__frame .maplibregl-ctrl-group button:first-child:not(:only-child)::after {
	inset: -12px -6px 0;
}

.iurban-map__frame .maplibregl-ctrl-group button:last-child:not(:only-child)::after {
	inset: 0 -6px -12px;
}

.iurban-map__frame .maplibregl-ctrl-group button:first-child {
	border-radius: 7px 7px 0 0;
}

.iurban-map__frame .maplibregl-ctrl-group button:last-child {
	border-radius: 0 0 7px 7px;
}

.iurban-map__frame .maplibregl-ctrl-group button:only-child {
	border-radius: 7px;
}

.iurban-map__frame .maplibregl-ctrl-group button + button {
	border-top: 1px solid rgba(28, 35, 48, 0.1);
}

.iurban-map__frame .maplibregl-ctrl-group button .maplibregl-ctrl-icon {
	width: 16px;
	height: 16px;
	margin: 7px;
	background-color: rgba(28, 35, 48, 0.75);
	background-image: none;
	-webkit-mask: var(--iurban-map-icon) center / 16px 16px no-repeat;
	mask: var(--iurban-map-icon) center / 16px 16px no-repeat;
}

.iurban-map__frame .maplibregl-ctrl-group button:hover,
.iurban-map__frame .maplibregl-ctrl-group button:focus-visible {
	background-color: #fff;
}

.iurban-map__frame .maplibregl-ctrl-group button:hover .maplibregl-ctrl-icon,
.iurban-map__frame .maplibregl-ctrl-group button:focus-visible .maplibregl-ctrl-icon {
	background-color: #1c2330;
}

.iurban-map__frame .maplibregl-ctrl-group button:focus-visible {
	outline: 2px solid #1c2330;
	outline-offset: 1px;
}

.iurban-map__frame .maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon {
	--iurban-map-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 6V2h4M10 2h4v4M14 10v4h-4M6 14H2v-4'/%3E%3C/svg%3E");
}

.iurban-map__frame .maplibregl-ctrl-shrink .maplibregl-ctrl-icon {
	--iurban-map-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 2v4H2M14 6h-4V2M10 14v-4h4M2 10h4v4'/%3E%3C/svg%3E");
}

.iurban-map__frame .maplibregl-ctrl-fly .maplibregl-ctrl-icon {
	--iurban-map-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 2.5v9.5M0.8 7.2 8 6.2l7.2 1M5.2 13.8 8 12l2.8 1.8'/%3E%3C/svg%3E");
}

/* Fly button (Route's renderer, only on a map with Orbit): pressed while flying = full ink, like hover. */
.iurban-map__frame .maplibregl-ctrl-group button.maplibregl-ctrl-fly[aria-pressed="true"] .maplibregl-ctrl-icon {
	background-color: #1c2330;
}

/* Full screen with no touch, mouse move or key for 3 s: the renderer puts .irm-idle on the map box and the top-right buttons fade; the credit (i) stays. */
/* The buttons sit above the pins and their name tags (z-index 100000, set with the corners above: pins stack from 1000 up). */
.iurban-map__frame .maplibregl-ctrl-top-right .maplibregl-ctrl {
	transition: opacity 0.4s ease;
}

/* (MapLibre gives each control pointer-events: auto, so the hidden buttons are switched off one by one; the (i) sits in this corner and is skipped) */
.iurban-map__frame.irm-idle .maplibregl-ctrl-top-right .maplibregl-ctrl:not(.maplibregl-ctrl-attrib) {
	opacity: 0;
	pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
	.iurban-map__frame .maplibregl-ctrl-top-right .maplibregl-ctrl {
		transition: none;
	}
}

.iurban-map__frame .maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon {
	--iurban-map-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M3 8h10M8 3v10'/%3E%3C/svg%3E");
}

.iurban-map__frame .maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon {
	--iurban-map-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M3 8h10'/%3E%3C/svg%3E");
}

/* Full screen: the credit (i) left of the logo (after the (i) margins above, so it wins). */
.iurban-map__frame:fullscreen .maplibregl-ctrl-top-right .maplibregl-ctrl-attrib.maplibregl-compact,
.iurban-map__frame:fullscreen .maplibregl-ctrl-top-right .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show),
.iurban-map__frame.irm-full .maplibregl-ctrl-top-right .maplibregl-ctrl-attrib.maplibregl-compact,
.iurban-map__frame.irm-full .maplibregl-ctrl-top-right .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show) {
	position: absolute;
	top: calc((var(--irm-logo-h) - 18px) / 2 - var(--irm-logo-h) - var(--irm-gap)); /* centred on the logo (owner 2026-11-15) */
	right: calc(var(--irm-logo-w) + var(--irm-gap));
	margin: 0;
}

/* Full screen, folded: the (i) 2 px lower than the open credit's line (owner 2026-11-15). */
.iurban-map__frame:fullscreen .maplibregl-ctrl-top-right .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show),
.iurban-map__frame.irm-full .maplibregl-ctrl-top-right .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show) {
	top: calc((var(--irm-logo-h) - 18px) / 2 + 2px - var(--irm-logo-h) - var(--irm-gap));
}

/* Hero card (assets/js/pin-card.js, plans/pin-focus.md, decision 018): only the map's main pin opens
   one. From 600 px a small card inside the frame, bottom left (also in full screen); under 600 px the
   theme's bottom sheet (.iu-sheet--pin, sheet.css), as high as its content. */
.iurban-pin {
	--iurban-pin-pad: 16px;
	--iurban-pin-ink: var(--wp--preset--color--ink, #222);
	--iurban-pin-display: var(--wp--preset--font-family--display, inherit);
	position: relative;
	box-sizing: border-box;
	padding: var(--iurban-pin-pad);
	color: var(--iurban-pin-ink);
	font-family: var(--wp--preset--font-family--body, inherit);
	font-size: 15px;
	line-height: 1.45;
}

.iurban-pin [hidden],
.iurban-pin-card[hidden] {
	display: none !important;
}

.iurban-pin a {
	text-decoration: none;
}

.iurban-pin a:focus-visible,
button.iurban-pin__x:focus-visible {
	outline: 2px solid var(--iurban-pin-ink);
	outline-offset: 2px;
}

.iurban-pin .iurban-pin__name {
	margin: 0;
	padding-right: 40px; /* the × */
	font-family: var(--iurban-pin-display);
	font-size: 22px;
	font-weight: 500;
	line-height: 1.25;
	overflow-wrap: anywhere;
}

.iurban-pin .iurban-pin__acts {
	display: flex;
	gap: 8px;
	margin-top: 14px;
}

/* Shared button shape (docs/ui-rules.md); the card's one action is the CTA (plan A3): "เว็บไซต์โครงการ" ink fill, "นำทาง" outlined. */
.iurban-pin .iurban-pin__btn {
	display: inline-flex;
	flex: 1 1 0;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-height: var(--iu-btn-min, 44px);
	padding: 0 16px;
	border: var(--iu-btn2-border, 1px solid #222);
	border-radius: var(--iu-btn-radius, 4px);
	background: var(--iu-btn2-bg, transparent);
	color: var(--iu-btn2-color, #222) !important;
	font-size: 15px;
	font-weight: 400;
	white-space: nowrap;
}

.iurban-pin .iurban-pin__web {
	border-color: var(--wp--preset--color--ink, #222);
	background: var(--wp--preset--color--ink, #222);
	color: var(--wp--preset--color--paper, #fff) !important;
}

/* No project site: "นำทาง" alone, ink fill, full width. */
.iurban-pin .iurban-pin__acts.is-solo .iurban-pin__go {
	border-color: var(--wp--preset--color--ink, #222);
	background: var(--wp--preset--color--ink, #222);
	color: var(--wp--preset--color--paper, #fff) !important;
}

/* The × : a 32 px circle, top right. */
button.iurban-pin__x {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--wp--preset--color--plate, #f5f3f0);
	color: var(--wp--preset--color--ink, #222);
	cursor: pointer;
}

.iurban-pin__xicon {
	width: 16px;
	height: 16px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
}

/* From 600 px: a small card inside the frame, bottom left, above the pins like the corner controls. */
.iurban-pin-card {
	position: absolute;
	bottom: 12px;
	left: 12px;
	z-index: 100000;
	box-sizing: border-box;
	width: min(320px, calc(100% - 24px));
	border-radius: 12px;
	background: var(--wp--preset--color--paper, #fff);
	box-shadow: 0 6px 20px rgba(20, 28, 45, 0.25);
	outline: none;
}

/* The phone sheet: as high as its content. */
.iu-sheet--pin {
	--iu-sheet-radius: 20px;
	box-shadow: 0 -8px 32px rgba(20, 28, 45, 0.12);
	outline: none;
}

.iu-sheet--pin::backdrop {
	background: rgba(0, 0, 0, 0.12);
}

.iu-sheet--pin .iu-sheet__inner {
	position: relative; /* the × */
}

.iu-sheet--pin .iu-sheet__body {
	padding: 0 0 env(safe-area-inset-bottom);
}
