/* ==========================================================================
   MetroMesh enhancement layer
   Sits on top of index.css. Holds browser-surface theming, responsive fixes,
   and the live network map on the home page.
   ========================================================================== */

/* ---------- Browser surfaces ---------- */

html {
	-webkit-text-size-adjust: 100%;
	-webkit-tap-highlight-color: transparent;
	scrollbar-color: color-mix(in srgb, var(--white), transparent 75%) var(--black);
	accent-color: #50EBE5;
}

::selection {
	background: #50EBE5;
	color: var(--black);
}

input,
textarea {
	caret-color: #50EBE5;
}

:focus-visible {
	outline: 2px solid var(--thm-acnt, #50EBE5);
	outline-offset: 3px;
}

/* ---------- Hero: recede as the page scrolls away ---------- */

.home-hero {
	overflow: clip;
}

@supports (animation-timeline: view()) {
	@media (prefers-reduced-motion: no-preference) {
		.home-hero-video {
			animation: mm-hero-recede linear both;
			animation-timeline: view();
			animation-range: exit 0% exit 100%;
		}
	}
}

@keyframes mm-hero-recede {
	to {
		opacity: .3;
		scale: 1.08;
	}
}

/* ---------- Responsive fixes ---------- */

@media (max-width: 63.98rem) {

	/* keep step copy legible over the photos on touch screens */
	.convictions-item::after {
		position: absolute;
		inset: 0;
		z-index: -1;
		background: linear-gradient(to top, var(--thm-bg) 20%, color-mix(in srgb, var(--thm-bg), transparent 35%) 65%, color-mix(in srgb, var(--thm-bg), transparent 70%));
		content: "";
		pointer-events: none;
	}

	.convictions-item {
		aspect-ratio: auto;
		min-height: 26rem;
	}
}

@media (max-width: 47.98rem) {
	.home-hero-toast {
		width: 100%;
		max-width: none;
	}

	.footer-title {
		text-wrap: balance;
	}
}

/* ---------- Live network map ---------- */

.live-map {
	--mm-outdoor: #50eb97;
	--mm-indoor: #facc15;
	--mm-selected: var(--orange);
	--mm-ease: cubic-bezier(.16, 1, .3, 1);
	margin-top: 2.5rem;
}

.live-map-stage {
	position: relative;
	isolation: isolate;
	aspect-ratio: 2 / 1;
	min-height: 28rem;
	overflow: clip;
	background: #14161b;
	border-block: 1px solid var(--thm-bdr);
}

.live-map-canvas,
.live-map-fallback {
	display: block;
	width: 100%;
	height: 100%;
	position: absolute;
	inset: 0;
}

.live-map-canvas {
	touch-action: pan-y;
	cursor: crosshair;
}

.live-map-canvas[data-hover] {
	cursor: pointer;
}

.live-map-fallback {
	object-fit: cover;
}

.live-map.is-ready .live-map-fallback {
	display: none;
}

.live-map:not(.is-ready) .live-map-hud,
.live-map:not(.is-ready) .live-map-controls,
.live-map:not(.is-ready) .live-map-hint {
	display: none;
}

/* HUD */

.live-map-hud {
	display: flex;
	position: absolute;
	inset: 0 0 auto;
	z-index: 1;
	padding: 1.25rem var(--container-gutter) 3rem;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: start;
	gap: 1rem 2.5rem;
	background: linear-gradient(to bottom, #14161b 10%, color-mix(in srgb, #14161b, transparent 100%));
	pointer-events: none;
}

.live-map-status {
	display: flex;
	align-items: center;
	gap: .625rem;
	font-family: var(--ff-secondary);
	font-size: .8125rem;
	line-height: 1.15;
	text-transform: uppercase;
	color: var(--thm-acnt-2);
}

.live-map-dot {
	width: .5rem;
	aspect-ratio: 1;
	border-radius: 50%;
	background: var(--mm-outdoor);
	box-shadow: 0 0 0 0 color-mix(in srgb, var(--mm-outdoor), transparent 40%);
}

@media (prefers-reduced-motion: no-preference) {
	.live-map-dot {
		animation: mm-beacon 2s var(--mm-ease) infinite;
	}
}

@keyframes mm-beacon {
	70%,
	100% {
		box-shadow: 0 0 0 .5rem color-mix(in srgb, var(--mm-outdoor), transparent 100%);
	}
}

.live-map-stats {
	display: flex;
	flex-wrap: wrap;
	gap: .75rem 2rem;
}

.live-map-stat dt {
	font-family: var(--ff-secondary);
	font-size: .6875rem;
	line-height: 1.2;
	text-transform: uppercase;
	color: color-mix(in srgb, var(--white), transparent 45%);
}

.live-map-stat dd {
	margin-top: .25rem;
	font-family: var(--ff-secondary);
	font-size: 1.125rem;
	line-height: 1.1;
	font-variant-numeric: tabular-nums;
	color: var(--white);
}

.live-map-stat dt::before {
	display: inline-block;
	width: .375rem;
	aspect-ratio: 1;
	margin-right: .4rem;
	border-radius: 50%;
	vertical-align: .1em;
	background: currentColor;
	content: "";
}

.live-map-stat:has([data-stat=outdoor]) dt::before {
	background: var(--mm-outdoor);
}

.live-map-stat:has([data-stat=indoor]) dt::before {
	background: var(--mm-indoor);
}

.live-map-stat:has([data-stat=units]) dt::before,
.live-map-stat:has([data-stat=impressions]) dt::before {
	display: none;
}

/* Unit card */

.live-map-card {
	width: max-content;
	max-width: min(17rem, calc(100% - 2 * var(--container-gutter)));
	position: absolute;
	top: 0;
	left: 0;
	z-index: 2;
	padding: 1rem 3rem 1rem 1.25rem;
	border: 1px solid var(--thm-bdr);
	border-radius: .25rem;
	background: var(--black);
	box-shadow: 0 .75rem 2rem rgba(0, 0, 0, .45);
	transition: opacity .25s var(--mm-ease), filter .25s var(--mm-ease), translate .25s var(--mm-ease);
}

.live-map-card[hidden] {
	display: block;
	opacity: 0;
	filter: blur(4px);
	translate: 0 .375rem;
	pointer-events: none;
	visibility: hidden;
	transition: opacity .15s ease, filter .15s ease, translate .15s ease, visibility 0s .15s;
}

.live-map-card-title {
	font-size: .875rem;
	line-height: 1.15;
	text-transform: uppercase;
}

.live-map-card-title::before {
	display: inline-block;
	width: .5rem;
	aspect-ratio: 1;
	margin-right: .5rem;
	border-radius: 50%;
	vertical-align: .05em;
	background: var(--mm-selected);
	content: "";
}

.live-map-card-text {
	margin-top: .5rem;
	font-family: var(--ff-secondary);
	font-size: .75rem;
	line-height: 1.35;
	color: color-mix(in srgb, var(--white), transparent 36%);
}

.live-map-card-close {
	display: flex;
	width: 2.75rem;
	height: 2.75rem;
	position: absolute;
	top: 0;
	right: 0;
	justify-content: center;
	align-items: center;
	color: color-mix(in srgb, var(--white), transparent 40%);
	transition: color .2s ease;
}

.live-map-card-close .icon {
	width: 1rem;
	height: 1rem;
}

.live-map-card-close:hover {
	color: var(--white);
}

.live-map-hint {
	position: absolute;
	right: var(--container-gutter);
	bottom: 1rem;
	z-index: 1;
	font-family: var(--ff-secondary);
	font-size: .6875rem;
	text-transform: uppercase;
	color: color-mix(in srgb, var(--white), transparent 50%);
	pointer-events: none;
	transition: opacity .4s ease;
}

.live-map[data-touched] .live-map-hint {
	opacity: 0;
}

/* Controls */

.live-map-controls {
	display: flex;
	padding: 1.25rem var(--container-gutter) 0;
	flex-wrap: wrap;
	align-items: center;
	gap: .75rem 1.5rem;
}

.live-map-modes,
.live-map-hoods {
	display: flex;
	flex-wrap: wrap;
	gap: .5rem;
}

.live-map-modes {
	padding: .25rem;
	border: 1px solid var(--thm-bdr);
	border-radius: .25rem;
	gap: .25rem;
}

.live-map-mode,
.live-map-hood {
	min-height: 2.75rem;
	padding: .5rem 1rem;
	border-radius: .1875rem;
	font-family: var(--ff-secondary);
	font-size: .8125rem;
	line-height: 1.15;
	text-transform: uppercase;
	color: color-mix(in srgb, var(--white), transparent 30%);
	transition: background-color .25s var(--mm-ease), color .25s var(--mm-ease), border-color .25s var(--mm-ease);
}

.live-map-mode:hover,
.live-map-hood:hover {
	color: var(--white);
}

.live-map-mode[aria-pressed=true] {
	background: #50EBE5;
	color: var(--black);
}

.live-map-hood {
	min-height: 2.5rem;
	padding: .5rem .875rem;
	border: 1px solid var(--thm-bdr);
	font-size: .75rem;
}

.live-map-hood[aria-pressed=true] {
	border-color: var(--mm-outdoor);
	color: var(--mm-outdoor);
}

.live-map-hoods:not([hidden]) {
	animation: mm-rise .4s var(--mm-ease) both;
}

@keyframes mm-rise {
	from {
		opacity: 0;
		translate: 0 .5rem;
	}
}

@media (max-width: 63.98rem) {
	.live-map-stage {
		aspect-ratio: 4 / 3;
	}
}

@media (max-width: 47.98rem) {
	.live-map-stage {
		aspect-ratio: 4 / 5;
		min-height: 0;
	}

	.live-map-hud {
		flex-direction: column;
		padding-bottom: 2rem;
		background: linear-gradient(to bottom, #14161b 72%, color-mix(in srgb, #14161b, transparent 100%));
	}

	.live-map-mode {
		font-size: .75rem;
	}

	.live-map-stats {
		display: grid;
		width: 100%;
		grid-template-columns: repeat(3, auto);
		gap: .75rem 1rem;
	}

	.live-map-stat--wide {
		grid-column: 1 / -1;
	}

	.live-map-modes {
		width: 100%;
	}

	.live-map-mode {
		flex: 1;
		padding-inline: .5rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.live-map-card,
	.live-map-card[hidden] {
		transition: none;
	}

	.live-map-hoods:not([hidden]) {
		animation: none;
	}
}

/* ---------- Reduced motion: show revealed text immediately ---------- */

@media (prefers-reduced-motion: reduce) {
	[data-reveal] .word,
	[data-reveal=opacity] {
		opacity: 1 !important;
		transition: none !important;
	}
}
