/*
 * File: assets/css/mc-location-picker.css
 *
 * City/town location picker (pill button + panel) — lives in the global
 * header (.mc-header), reuses its design tokens (--mc-header-accent, etc.
 * from mappcanada-header.css). Dedicated file rather than growing
 * mappcanada-header.css further, mirroring mc-messaging.css / mc-passkeys.css.
 *
 * Sections:
 *  1. Pill button
 *  2. Panel shell (position: fixed — see note below)
 *  3. "Use my location" row
 *  4. Search input
 *  5. All of Canada / Recent / Results lists
 *  6. Narrow widths — compact inline pill + full-width bottom-sheet panel
 *
 * @package MappCanada
 */

/* =========================================================================
 * 1. PILL BUTTON
 *
 * A single instance (in the always-visible header search row — see
 * mappcanada-header.css, no separate mobile-drawer instance). It shares the
 * row with the search bar at every width and just gets more compact at
 * narrow widths (section 6) rather than stacking onto its own line.
 * ======================================================================= */

.mc-location-pill-wrap {
	display: flex;
	align-items: center;
	flex-shrink: 0;
}

/* Minimal header layout hides .mc-header__search-wrap (mappcanada-header.css,
 * section 20) but the search row itself can still render if search is
 * independently enabled — hide the pill too so row 2 doesn't show a lone
 * pill with nothing to search next to. */
.mc-header--minimal .mc-location-pill-wrap--desktop {
	display: none;
}

.mc-location-pill {
	display: flex;
	align-items: center;
	gap: 6px;
	/* Height interpolates 44px → 40px with the header's scroll-compact
	 * progress (--mc-scroll-progress is set on .mc-header, inherited here). */
	height: calc(44px - 4px * var(--mc-scroll-progress, 0));
	padding: 0 14px;
	background: var(--mc-header-input-bg);
	color: var(--mc-header-input-text);
	border: none;
	border-radius: var(--mc-header-radius);
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
	min-width: 0;      /* allow the label to ellipsise when the row is tight */
	max-width: 200px;
	flex-shrink: 0;
	transition: box-shadow var(--mc-header-transition), height .18s ease;
}

.mc-location-pill:hover,
.mc-location-pill:focus {
	outline: none;
	box-shadow: 0 0 0 2px var(--mc-header-accent);
}

.mc-location-pill[aria-expanded="true"] {
	box-shadow: 0 0 0 2px var(--mc-header-accent);
}

.mc-location-pill__icon {
	flex-shrink: 0;
	font-size: 1rem;
}

.mc-location-pill__label {
	flex: 1 1 auto;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	text-align: left;
}

.mc-location-pill__chevron {
	flex-shrink: 0;
	font-size: 0.7rem;
	opacity: .6;
}

/* =========================================================================
 * 2. PANEL SHELL
 *
 * position: fixed so the panel escapes .mc-header's overflow:hidden ancestor
 * (same reasoning as .mc-header__typeahead / .mc-header__mega-menu). top/
 * left/right are computed and injected by mc-location-picker.js each time
 * the panel opens and on resize.
 * ======================================================================= */

.mc-location-panel {
	position: fixed;
	z-index: calc(var(--mc-header-z) + 10);
	width: 380px;
	max-width: calc(100vw - 24px);
	max-height: calc(100vh - 100px);
	display: flex;
	flex-direction: column;
	background: #fff;
	color: #1a1a2e;
	border-radius: var(--mc-header-radius);
	box-shadow: 0 10px 32px rgba(0,0,0,.25);
	overflow: hidden;
}

.mc-location-panel[hidden] { display: none; }

.mc-location-panel__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	border-bottom: 1px solid #eee;
	flex-shrink: 0;
}

.mc-location-panel__title {
	margin: 0;
	font-size: 1rem;
	font-weight: 700;
}

.mc-location-panel__close {
	width: 30px;
	height: 30px;
	border: none;
	border-radius: 50%;
	background: #f2f2f2;
	color: #555;
	font-size: 1.1rem;
	line-height: 1;
	cursor: pointer;
}

.mc-location-panel__close:hover,
.mc-location-panel__close:focus {
	background: #e6e6e6;
	outline: none;
}

.mc-location-panel__body {
	padding: 14px 16px 16px;
	overflow-y: auto;
}

/* =========================================================================
 * 3. "USE MY LOCATION" ROW
 * ======================================================================= */

.mc-location-use-mine {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	height: 42px;
	margin-bottom: 12px;
	background: var(--mc-header-accent);
	color: #fff;
	border: none;
	border-radius: var(--mc-header-radius);
	font-size: 0.9rem;
	font-weight: 600;
	cursor: pointer;
	transition: background var(--mc-header-transition);
}

.mc-location-use-mine:hover,
.mc-location-use-mine:focus {
	background: #b02318;
	outline: none;
}

.mc-location-use-mine[disabled] {
	opacity: .6;
	cursor: default;
}

.mc-location-use-mine--loading .mc-location-use-mine__icon {
	animation: mc-location-pulse 1s ease-in-out infinite;
}

@keyframes mc-location-pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: .4; }
}

.mc-location-use-mine__status {
	margin: -6px 0 12px;
	font-size: 0.8rem;
	line-height: 1.4;
	color: #666;
}

.mc-location-use-mine__status[hidden] { display: none; }

.mc-location-use-mine__status--error { color: #b02318; }
.mc-location-use-mine__status--success { color: #1a7a3c; }

/* =========================================================================
 * 4. SEARCH INPUT
 * ======================================================================= */

.mc-location-search-wrap {
	margin-bottom: 10px;
}

.mc-location-search-input {
	width: 100%;
	height: 40px;
	padding: 0 12px;
	box-sizing: border-box;
	border: 1px solid #ddd;
	border-radius: var(--mc-header-radius);
	font-size: 0.9rem;
	outline: none;
}

.mc-location-search-input:focus {
	border-color: var(--mc-header-accent);
	box-shadow: 0 0 0 2px rgba(213,43,30,.15);
}

/* =========================================================================
 * 5. ALL OF CANADA / RECENT / RESULTS
 * ======================================================================= */

.mc-location-all-canada {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	padding: 9px 10px;
	margin-bottom: 8px;
	background: #f7f7f7;
	border: 1px solid transparent;
	border-radius: var(--mc-header-radius);
	font-size: 0.88rem;
	font-weight: 600;
	color: #1a1a2e;
	cursor: pointer;
	text-align: left;
}

.mc-location-all-canada:hover,
.mc-location-all-canada:focus {
	border-color: var(--mc-header-accent);
	outline: none;
}

.mc-location-all-canada--active {
	background: #fff5f4;
	border-color: var(--mc-header-accent);
	color: var(--mc-header-accent);
}

.mc-location-section-label {
	margin: 4px 0 6px;
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .06em;
	color: #999;
}

.mc-location-recent[hidden] { display: none; }

.mc-location-recent-list,
.mc-location-results-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.mc-location-recent-list { margin-bottom: 10px; }

.mc-location-result,
.mc-location-recent-item {
	display: flex;
	align-items: baseline;
	gap: 6px;
	width: 100%;
	padding: 8px 10px;
	background: none;
	border: none;
	border-radius: var(--mc-header-radius);
	font-size: 0.88rem;
	color: #1a1a2e;
	cursor: pointer;
	text-align: left;
}

.mc-location-result:hover,
.mc-location-result:focus,
.mc-location-result--focused,
.mc-location-recent-item:hover,
.mc-location-recent-item:focus {
	background: #f0f4ff;
	outline: none;
}

.mc-location-result__name,
.mc-location-recent-item__name {
	font-weight: 600;
}

.mc-location-result__province,
.mc-location-recent-item__province {
	color: #888;
	font-size: 0.8rem;
}

.mc-location-result__distance {
	margin-left: auto;
	flex-shrink: 0;
	font-size: 0.76rem;
	color: #999;
}

.mc-location-results-message {
	margin: 10px 4px;
	font-size: 0.85rem;
	color: #888;
	text-align: center;
}

.mc-location-results-message[hidden] { display: none; }

/* =========================================================================
 * 6. NARROW WIDTHS — COMPACT PILL (stays inline) + FULL-WIDTH BOTTOM-SHEET PANEL
 *
 * The header keeps the pill and the search bar on ONE line at every width
 * (mappcanada-header.css) — so below 640px the pill just gets more compact
 * (tighter padding, capped width, no chevron, label ellipsised) rather than
 * going full-width on its own line. The 🔍 search button stays visible.
 * The panel it opens still becomes a full-width bottom sheet.
 * ======================================================================= */

@media (max-width: 640px) {
	.mc-location-pill {
		max-width: 42vw;   /* never let the pill crowd out the search bar */
		padding: 0 10px;
		gap: 4px;
		font-size: 0.82rem;
	}

	.mc-location-pill__chevron {
		display: none;
	}

	.mc-location-panel {
		left: 0 !important;
		right: 0 !important;
		width: 100%;
		max-width: 100%;
		bottom: 0;
		top: auto !important;
		max-height: 85vh;
		border-radius: 16px 16px 0 0;
	}

	.mc-location-panel__body {
		padding-bottom: max(16px, env(safe-area-inset-bottom));
	}
}

/* Extra squeeze on very small phones (≤ 360px) so the search input keeps a
 * usable width. Label still shown (ellipsised) — the pin icon alone would
 * drop the current city/"All of Canada" text. */
@media (max-width: 22.5em) {
	.mc-location-pill {
		max-width: 38vw;
		padding: 0 8px;
	}

	.mc-location-pill__icon {
		font-size: 0.95rem;
	}
}
