/**
 * KCAI map layer controls + the sighting layer's own marks.
 *
 * TWO RULES THIS FILE IS BUILT AROUND
 *
 * 1. NOTHING DEPENDS ON COLOUR. Every layer is told apart by its glyph and, for
 *    sightings, by a DASHED stroke against every other layer's solid one. The
 *    colours below are a fourth, redundant signal.
 *
 * 2. 44px IS A FLOOR, NOT A TARGET. The whole row is the hit area, so a finger
 *    on a phone in the rain has the label, the glyph and the count to aim at
 *    rather than a 16px checkbox.
 *
 * Themed from the same custom properties the homepage sets on :root, with a
 * prefers-color-scheme fallback for the one visitor whose JavaScript did not
 * run. Written :not([data-theme]) so an explicit choice always wins.
 */

.kch-layers {
	position: relative;
	z-index: 650;
	width: 100%;
	margin-top: -76px;
	padding: 8px 12px 10px;
	pointer-events: none;
}

.kcl {
	--kcl-ink:    #14202B;
	--kcl-mute:   #5B6B7A;
	--kcl-line:   #DCE4EB;
	--kcl-card:   #FFFFFF;
	--kcl-sunk:   #F5F8FA;
	--kcl-accent: #0072B0;
	--kcl-focus:  #0072B0;
	--kcl-sight:  #6A45E8;

	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 58px;
	background: var(--kcl-card);
	background: color-mix(in srgb, var(--kcl-card) 94%, transparent);
	border: 1px solid var(--kcl-line);
	border-radius: 16px;
	padding: 7px 8px 7px 10px;
	box-shadow: 0 7px 24px rgba(7, 20, 31, .22);
	backdrop-filter: blur(12px) saturate(1.08);
	-webkit-backdrop-filter: blur(12px) saturate(1.08);
	color: var(--kcl-ink);
	font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	pointer-events: auto;
}

:root[data-theme="dark"] .kcl {
	--kcl-ink:    #EAF2F8;
	--kcl-mute:   #9FB3C4;
	--kcl-line:   #22303E;
	--kcl-card:   #101A23;
	--kcl-sunk:   #0E1720;
	--kcl-accent: #4FC3FF;
	--kcl-focus:  #7FD4FF;
	--kcl-sight:  #B49BFF;
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme]) .kcl {
		--kcl-ink:    #EAF2F8;
		--kcl-mute:   #9FB3C4;
		--kcl-line:   #22303E;
		--kcl-card:   #101A23;
		--kcl-sunk:   #0E1720;
		--kcl-accent: #4FC3FF;
		--kcl-focus:  #7FD4FF;
		--kcl-sight:  #B49BFF;
	}
}

.kcl__head {
	display: flex;
	flex: 0 0 auto;
	gap: 6px;
	align-items: center;
	margin: 0;
	padding-right: 9px;
	border-right: 1px solid var(--kcl-line);
}
.kcl__title { margin: 0 3px 0 0; font-size: .84rem; font-weight: 800; color: var(--kcl-ink); white-space: nowrap; }
.kcl__bulk  { display: flex; gap: 5px; }

/* 44px floor, and the label sits inside the button rather than beside it. */
.kcl__btn {
	min-height: 44px;
	min-width: 44px;
	padding: 0 10px;
	border: 1px solid var(--kcl-line);
	border-radius: 12px;
	background: var(--kcl-sunk);
	color: var(--kcl-ink);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}
.kcl__btn:hover { border-color: var(--kcl-accent); background: var(--kcl-card); }
.kcl__btn:focus-visible { outline: 3px solid var(--kcl-focus); outline-offset: 2px; }

.kcl__list {
	display: flex;
	flex: 1 1 auto;
	gap: 7px;
	min-width: 0;
	list-style: none;
	margin: 0;
	padding: 1px 2px 3px;
	overflow-x: auto;
	overflow-y: hidden;
	overscroll-behavior-x: contain;
	scroll-snap-type: x proximity;
	scrollbar-width: thin;
	scrollbar-color: var(--kcl-line) transparent;
}
.kcl__item { flex: 0 0 auto; scroll-snap-align: start; }

/*
 * THE WHOLE ROW IS THE CONTROL. `min-height: 44px` on the label, not on the
 * checkbox: a 44px checkbox with a 15px label beside it still leaves most of
 * the row dead, and the label is what a person actually aims at.
 */
.kcl__row {
	--kcl-layer: var(--kcl-accent);
	display: flex;
	align-items: center;
	gap: 7px;
	min-height: 46px;
	min-width: 118px;
	padding: 4px 8px 4px 6px;
	border: 1px solid var(--kcl-line);
	border-radius: 14px;
	background: var(--kcl-sunk);
	box-shadow: 0 1px 0 rgba(255,255,255,.45) inset;
	cursor: pointer;
	transition: border-color .14s ease, background .14s ease, transform .14s ease, box-shadow .14s ease;
}
.kcl__row:hover { border-color: var(--kcl-layer); transform: translateY(-1px); }
.kcl__row.is-active { border-color: var(--kcl-layer); background: var(--kcl-card); background: color-mix(in srgb, var(--kcl-layer) 12%, var(--kcl-card)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--kcl-layer) 34%, transparent), 0 3px 10px rgba(7,20,31,.12); }
.kcl__box {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}
/* The focus ring goes on the ROW, so keyboard focus is visible at the size the
 * row is, not at the size the checkbox is. */
.kcl__row:focus-within  { outline: 3px solid var(--kcl-focus); outline-offset: 2px; }

.kcl__glyph {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px; height: 30px;
	border-radius: 50%;
	background: var(--kcl-card);
	color: var(--kcl-accent);
	box-shadow: 0 1px 4px rgba(7,20,31,.12);
}
.kcl__glyph--sightings { color: var(--kcl-sight); }
.kcl__row--lost_pets{--kcl-layer:#f05b2a}.kcl__row--found_pets{--kcl-layer:#1688c9}.kcl__row--sightings{--kcl-layer:#6a45e8}.kcl__row--shelters{--kcl-layer:#1769aa}.kcl__row--veterinarians{--kcl-layer:#d62828}.kcl__row--pet_stores{--kcl-layer:#0f766e}.kcl__row--volunteer_scanners{--kcl-layer:#ef233c}.kcl__row--dog_parks{--kcl-layer:#2e7d32}.kcl__row--upcoming_events{--kcl-layer:#c2185b}.kcl__row--animal_control{--kcl-layer:#d4a017}
.kcl__glyph--lost_pets{color:#f05b2a}.kcl__glyph--found_pets{color:#1688c9}.kcl__glyph--shelters{color:#1769aa}.kcl__glyph--veterinarians{color:#d62828}.kcl__glyph--pet_stores{color:#0f766e}.kcl__glyph--volunteer_scanners{color:#ef233c}.kcl__glyph--dog_parks{color:#2e7d32}.kcl__glyph--upcoming_events{color:#c2185b}.kcl__glyph--animal_control{color:#d4a017}
/* The legend swatch repeats the map's dashed stroke, so the control shows the
 * same distinction the map draws. */
.kcl__glyph--sightings { border: 2px dashed currentColor; background: transparent; }

.kcl__text  { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.kcl__name  { font-size: .84rem; font-weight: 750; white-space: nowrap; }
.kcl__desc  { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.kcl__count {
	flex: 0 0 auto;
	display: grid;
	place-items: center;
	min-width: 22px;
	height: 22px;
	padding: 0 5px;
	border-radius: 999px;
	background: var(--kcl-card);
	text-align: center;
	font-variant-numeric: tabular-nums;
	font-size: .72rem;
	font-weight: 800;
	color: var(--kcl-mute);
}
.kcl__row.is-active .kcl__count { background: var(--kcl-layer); color: #fff; }

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

/* Announcements are for screen readers; they must not move the layout. */
.kcl__live {
	position: absolute;
	width: 1px; height: 1px;
	margin: -1px; padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 620px) {
	.kch-layers { margin-top: -70px; padding: 6px 7px 8px; }
	.kcl { gap: 7px; min-height: 56px; padding-left: 7px; border-radius: 14px; }
	.kcl__title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
	.kcl__head { padding-right: 7px; }
	.kcl__btn { padding: 0 8px; font-size: .78rem; }
	.kcl__row { min-width: 110px; }
}

/* ------------------------------------------------------------------ *
 * The sighting marks on the map itself
 * ------------------------------------------------------------------ */

.kcs-glyph-wrap { background: none; border: 0; }
.kcs-glyph {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 30px; height: 30px;
	border-radius: 50%;
	background: #FFFFFF;
	color: #4B2FBF;
	border: 2px solid #6A45E8;
	box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
:root[data-theme="dark"] .kcs-glyph { background: #101A23; color: #C9B6FF; border-color: #B49BFF; }

.kcs-glyph-wrap:focus-visible .kcs-glyph,
.kcs-glyph-wrap:focus .kcs-glyph { outline: 3px solid #0072B0; outline-offset: 2px; }

/* The dashed area stroke. This is the accessibility mechanism, not decoration:
 * every pet privacy ring on this map is solid. */
.kcs-area { stroke-dasharray: 6 5; }

.kcs-card { max-width: 260px; }
.kcs-card__status {
	margin: 0 0 6px;
	font-weight: 700;
	font-size: .8rem;
	text-transform: uppercase;
	letter-spacing: .03em;
	color: #4B2FBF;
}
:root[data-theme="dark"] .kcs-card__status { color: #C9B6FF; }
.kcs-card__img { width: 100%; height: auto; border-radius: 8px; display: block; margin: 0 0 6px; }
.kcs-card__h   { margin: 4px 0 2px; font-size: 1rem; }
.kcs-card__when, .kcs-card__where { margin: 0; font-size: .85rem; }
.kcs-card__note, .kcs-card__precision { margin: 4px 0 0; font-size: .72rem; opacity: .8; }
.kcs-card__note-mod { margin: 6px 0 0; font-size: .85rem; }
.kcs-card__go { margin: 8px 0 0; }

@media (prefers-reduced-motion: reduce) {
	.kcl *, .kcs-glyph { transition: none !important; animation: none !important; }
}
