/**
 * SEARCH-CATEGORY-SEGMENTS-1A — shared search category segments.
 *
 * One component for the homepage hero search (radio mode, dark tone on the
 * navy strip) and /find/ (link mode, light tone). Markup:
 * aptv2_usearch_render_segments() in inc/apt-universal-search.php.
 *
 * Category identity comes from the /map/ Browse rail: each segment carries
 * the APT_Map_Marker_Registry colour variables inline (--apt-mk-base /
 * -light / -dark / -tint) and the same glyph, drawn as the same gradient
 * icon bubble (apt-map-markers.css .apt-mk-icon). No colour is defined here
 * per category.
 */

.apt-seg {
	--apt-seg-bg: #FFF;
	--apt-seg-line: #E5E7EB;
	--apt-seg-text: #374151;
	--apt-seg-hover-bg: var( --apt-mk-tint, #F3F6FB );
	--apt-seg-active-bg: var( --apt-mk-tint, #F3F6FB );
	--apt-seg-active-text: #1A1A1A;
	--apt-seg-focus: #2D6CDF;
	container-type: inline-size;
	container-name: aptseg;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

/* Dark tone: on the homepage's navy scope strip. */
.apt-seg--dark {
	--apt-seg-bg: rgba( 255, 255, 255, 0.06 );
	--apt-seg-line: rgba( 255, 255, 255, 0.18 );
	--apt-seg-text: #FFF;
	--apt-seg-hover-bg: rgba( 255, 255, 255, 0.13 );
	--apt-seg-active-bg: #FFF;
	--apt-seg-active-text: #092443;
	--apt-seg-focus: #FFF;
}

.apt-seg__title {
	margin: 0 0 8px;
	padding: 0;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #6B7280;
}

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

.apt-seg__list {
	display: flex;
	gap: 6px;
	max-width: 720px;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Doubled class: beats theme list-item margins (e.g. li + li spacing). */
.apt-seg .apt-seg__list > li {
	display: flex;
	flex: 1 1 auto;
	margin: 0;
	padding: 0;
}

.apt-seg__item {
	position: relative;
	display: flex;
	flex: 1 1 auto;
	min-width: 0;
	margin: 0;
	color: inherit;
	text-decoration: none;
	cursor: pointer;
}

.apt-seg .apt-seg__list > li > .apt-seg__item {
	width: 100%;
}

/* The radio covers the whole segment (click target) but is invisible; the
   face below shows its state. */
.apt-seg__input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}

.apt-seg__face {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	box-sizing: border-box;
	width: 100%;
	min-height: 60px;
	padding: 7px 10px;
	border: 1px solid var( --apt-seg-line );
	border-radius: 12px;
	background: var( --apt-seg-bg );
	color: var( --apt-seg-text );
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	transition: background-color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, color 0.14s ease;
}

/* Same gradient bubble as the map's category icon, smaller. */
.apt-seg__icon {
	display: inline-grid;
	place-items: center;
	flex-shrink: 0;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: linear-gradient( 145deg, var( --apt-mk-light, #8EA0B2 ), var( --apt-mk-base, #708399 ) 52%, var( --apt-mk-dark, #526477 ) );
	box-shadow: 0 3px 7px rgba( 18, 39, 70, 0.16 );
}

.apt-seg__icon svg {
	display: block;
	width: 54%;
	height: 54%;
	max-width: none;
	fill: #FFF;
}

.apt-seg__label {
	white-space: nowrap;
}

/* Hover: the category's own colour, like a map Browse row. */
.apt-seg__item:hover .apt-seg__face {
	border-color: var( --apt-mk-base, #708399 );
	background: var( --apt-seg-hover-bg );
}

/* Selected: filled face, category border, category bar along the bottom
   (the map's selected-row stripe) and the Browse rail's soft lift. */
.apt-seg__input:checked + .apt-seg__face,
.apt-seg__item[aria-current] .apt-seg__face {
	border-color: var( --apt-mk-base, #708399 );
	background: var( --apt-seg-active-bg );
	color: var( --apt-seg-active-text );
	font-weight: 700;
	box-shadow:
		inset 0 -4px 0 var( --apt-mk-base, #708399 ),
		0 4px 10px -6px rgba( 0, 0, 0, 0.22 );
}

/* Keyboard focus. */
.apt-seg__item:focus-visible {
	outline: 0;
}

.apt-seg__input:focus-visible + .apt-seg__face,
.apt-seg__item:focus-visible .apt-seg__face {
	outline: 2px solid var( --apt-seg-focus );
	outline-offset: 2px;
}

/* The search form marks pointer use (data-apt-pointer, apt-universal-search.js)
   so clicking a segment never leaves a focus ring behind. */
[data-apt-pointer] .apt-seg__input:focus-visible + .apt-seg__face {
	outline: 0;
}

/* Narrow (phone): three columns, two rows — every scope visible, no
   horizontal scroll; long labels wrap onto two lines. */
@container aptseg ( max-width: 520px ) {
	.apt-seg__list {
		display: grid;
		grid-template-columns: repeat( 3, minmax( 0, 1fr ) );
	}

	.apt-seg__face {
		min-height: 58px;
		padding: 7px 6px;
	}

	.apt-seg__label {
		white-space: normal;
		overflow-wrap: break-word;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.apt-seg__face {
		transition: none;
	}
}

@media ( forced-colors: active ) {
	.apt-seg__input:checked + .apt-seg__face,
	.apt-seg__item[aria-current] .apt-seg__face {
		border-width: 3px;
	}
}
