/*
 * Vivid Project Map: marker buttons, focus rings, sr-only utility, reduced
 * motion, and the map's own fallback states. Etch owns layout of the panel,
 * grid, and filters; nothing here positions those.
 */

[data-vivid-map] {
	min-height: 420px;
	position: relative;
}

/*
 * Single-project mode ([data-vivid-single]) and the empty state
 * ([data-vivid-map-state="empty"], set when the fetch for the project's
 * geometry fails or returns nothing) reuse the same container fallback
 * above and the .vivid-marker / .vivid-map-unavailable rules below; neither
 * attribute needs its own layout. Etch owns the section layout around them.
 */

.vivid-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

[data-vivid-map] a.vivid-sr-only:focus {
	position: absolute;
	top: 0;
	left: 0;
	z-index: 10;
	width: auto;
	height: auto;
	margin: 0;
	padding: 0.5em 1em;
	overflow: visible;
	clip: auto;
	white-space: normal;
	background: #ffffff;
	color: #0D2E5A;
	border-radius: 0 0 4px 0;
}

.vivid-marker {
	width: 32px;
	height: 32px;
	padding: 0;
	border: 2px solid #ffffff;
	border-radius: 50%;
	background-color: var(--vivid-marker-color, #6B7280);
	color: #ffffff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

/* The hidden attribute must win over display:flex above. */
.vivid-marker[hidden],
.maplibregl-marker.vivid-marker-wrap--hidden {
	display: none !important;
}

.vivid-marker[aria-current='true'] {
	box-shadow: 0 0 0 3px #ffffff, 0 0 0 5px var(--vivid-marker-color, #6B7280);
}

.vivid-marker:focus-visible,
[data-vivid-filter]:focus-visible,
[data-vivid-locate]:focus-visible,
[data-vivid-panel-close]:focus-visible {
	outline: 3px solid #F05A28;
	outline-offset: 2px;
}

[data-vivid-panel-close] {
	min-width: 44px;
	min-height: 44px;
}

.vivid-map-unavailable {
	margin: 0;
	padding: 1em;
	text-align: center;
}

/*
 * Office location maps ([data-vivid-location]), independent of
 * [data-vivid-map]. Static (card) mode is decorative: the container and
 * everything in it must never intercept pointer or keyboard interaction, so
 * clicks and hovers reach the card underneath. Interactive mode (the single
 * location template) is a full map and gets none of this.
 */
[data-vivid-location] {
	min-height: 160px;
	position: relative;
}

[data-vivid-location][data-vivid-location-mode='static'],
[data-vivid-location]:not([data-vivid-location-mode]) {
	pointer-events: none;
}

.vivid-location-attrib {
	position: absolute;
	right: 4px;
	bottom: 2px;
	z-index: 1;
	padding: 1px 4px;
	background: rgba(255, 255, 255, 0.7);
	color: #333;
	font-size: 10px;
	line-height: 1.4;
	pointer-events: none;
}

/*
 * Bottom sheet mode (mobile). Structural only: position, size, stacking and
 * motion. Colors, padding, radius, and typography belong to Etch.
 *
 * vivid-map-sheet.js sets data-sheet-mode on the panel only below the
 * breakpoint (data-vivid-sheet-breakpoint on the panel, default 767), so the
 * attribute is what keys these rules; the media query is a safety net only.
 * The !important flags are deliberate: Etch's .vivid-project-map__drawer sets
 * position: sticky, top, height: 36.25rem and z-index for the desktop side
 * panel and those must lose here even if the mobile media query keeps them.
 * The detent is expressed as a translateY so only the compositor moves the
 * sheet (no height animation, no will-change, no full-viewport layer).
 */
@media (max-width: 767px) {
	[data-vivid-panel][data-sheet-mode] {
		position: fixed !important;
		inset: auto 0 0 0 !important;
		top: auto !important;
		width: 100% !important;
		max-width: none !important;
		height: var(--vivid-sheet-full-height, 90vh) !important;
		max-height: none !important;
		margin: 0 !important;
		display: flex !important;
		flex-direction: column !important;
		transform: translateY(var(--vivid-sheet-offset, 0px));
		transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
		z-index: 10020 !important;
		box-sizing: border-box;
		overscroll-behavior: contain;
	}

	[data-vivid-panel][data-sheet-mode][hidden] {
		display: none !important;
	}

	[data-vivid-panel][data-sheet-mode][data-sheet-dragging] {
		transition: none;
	}

	/* Header stacks above the content (Etch's desktop rule is position:absolute). */
	[data-vivid-panel][data-sheet-mode] [data-vivid-panel-header] {
		position: relative !important;
		inset: auto !important;
		width: auto !important;
		flex: 0 0 auto;
		min-height: 44px;
		user-select: none;
		-webkit-user-select: none;
		touch-action: none;
		cursor: grab;
	}

	[data-vivid-panel][data-sheet-mode] [data-vivid-panel-content] {
		flex: 1 1 auto;
		min-height: 0;
		overflow-y: hidden;
		overscroll-behavior: contain;
		-webkit-overflow-scrolling: touch;
		touch-action: none;
	}

	[data-vivid-panel][data-sheet-mode][data-sheet='full'] [data-vivid-panel-content] {
		overflow-y: auto;
		touch-action: pan-y;
	}

	/*
	 * Peek and half show the title first: hide the card image. Etch can
	 * override with the same selector. The :has() rule also collapses a
	 * wrapper whose only child is the image (Etch's .vivid-project-card__media
	 * has an aspect-ratio and would otherwise keep its box).
	 */
	[data-vivid-panel][data-sheet-mode][data-sheet='peek'] [data-vivid-panel-content] img,
	[data-vivid-panel][data-sheet-mode][data-sheet='peek'] [data-vivid-panel-content] figure,
	[data-vivid-panel][data-sheet-mode][data-sheet='peek'] [data-vivid-panel-content] picture,
	[data-vivid-panel][data-sheet-mode][data-sheet='half'] [data-vivid-panel-content] img,
	[data-vivid-panel][data-sheet-mode][data-sheet='half'] [data-vivid-panel-content] figure,
	[data-vivid-panel][data-sheet-mode][data-sheet='half'] [data-vivid-panel-content] picture {
		display: none;
	}

	[data-vivid-panel][data-sheet-mode][data-sheet='peek'] [data-vivid-panel-content] :is(div, figure, picture):has(> img:only-child),
	[data-vivid-panel][data-sheet-mode][data-sheet='half'] [data-vivid-panel-content] :is(div, figure, picture):has(> img:only-child) {
		display: none;
	}

	/* Scrim over the page at the full detent only; the map stays interactive at half and peek. */
	.vivid-sheet-backdrop {
		position: fixed;
		inset: 0;
		z-index: 10010;
		background: rgba(0, 0, 0, 0.35);
		opacity: 0;
		pointer-events: none;
		transition: opacity 200ms;
	}

	.vivid-sheet-backdrop[data-visible] {
		opacity: 1;
		pointer-events: auto;
	}
}

html[data-vivid-sheet-open] {
	overscroll-behavior: none;
}

@media (prefers-reduced-motion: reduce) {
	[data-vivid-map],
	[data-vivid-map] *,
	[data-vivid-panel],
	[data-vivid-panel] * {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}
