/* ==========================================================================
   S8 location picker — DESIGN_SYSTEM.md "Location picker" (D316).
   One stylesheet for the shared From / To component on the homepage and
   on Deal Discovery. EXISTING TOKENS ONLY: no new colour, font or visual
   direction. The closed field keeps each page's approved field box
   (Gate 5 homepage panel, Gate 6 V2 Discovery bar); only the control inside
   it becomes a button. The open picker reuses the Travel Months panel's
   visual language (white surface, ink text, pink highlight, 44px targets).
   ========================================================================== */

/* --- Closed field: shared ------------------------------------------------- */

.fr-location-trigger[hidden],
.fr-location-field [data-location-fallback][hidden],
.fr-location-code[hidden] {
	display: none !important;
}

.fr-location-trigger {
	font-family: var(--fr-font-body);
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.fr-location-trigger__place {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	min-width: 0;
}

/* The IATA code badge: never truncated (R-21, L-2). */
.fr-location-code {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	min-width: 2.7em;
	padding: 1px 6px;
	border: 1px solid var(--fr-g5-field-border);
	border-radius: var(--fr-radius-sm);
	background: var(--fr-surface);
	font-family: var(--fr-font-body);
	font-size: 0.72rem;
	font-weight: 700;
	line-height: 1.35;
	letter-spacing: 0.04em;
	color: var(--fr-g5-ink);
	white-space: nowrap;
}

/* H-1: an unrecognised code from an old link — bare code, warning badge
   and border, explained by the line under the Discovery bar. */
.fr-location-code--warning {
	border-color: var(--fr-warning);
	background: var(--fr-warning-bg);
	color: var(--fr-warning);
	min-width: 1.6em;
}

.fr-location-field--unknown {
	border-color: var(--fr-warning) !important;
}

/* --- Closed field: homepage (Gate 5 panel) ---------------------------------
   The button is the approved .fr-month-trigger pattern laid over the whole
   64px field box; the code badge sits on the label line, top right, so the
   value line keeps its full width for the place (L-2). */

.fr-location-trigger--home {
	display: block;
}

.fr-location-trigger--home .fr-location-trigger__place {
	display: block;
}

.fr-location-trigger--home .fr-location-code {
	position: absolute;
	top: var(--fr-space-2);
	right: var(--fr-space-3);
}

.fr-location-field.fr-search-field:has(.fr-location-trigger--home .fr-location-code:not([hidden])) > .fr-search-field__label {
	padding-right: 3.6em;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

@media (max-width: 767px) {
	.fr-location-trigger--home .fr-location-code {
		right: var(--fr-space-2);
	}
}

/* --- Closed field: Deal Discovery (Gate 6 V2 bar) --------------------------
   The borderless value of the approved bar, with one theme chevron instead
   of the browser's native arrow (V-4). Below 1200px the badge sits on the
   label line; in the single-row bar it follows the place (L-2). */

.fr-discovery-filters__field.fr-location-field {
	position: relative;
}

.fr-location-trigger--discovery {
	grid-area: control;
	display: flex;
	align-items: center;
	gap: var(--fr-space-2);
	width: 100%;
	min-width: 0;
	min-height: 44px;
	padding: 0 4px 0 0;
	border: 0;
	border-radius: var(--fr-radius-sm);
	background: transparent;
	font-size: 0.88rem;
	font-weight: 600;
	color: var(--fr-g5-ink);
	text-align: left;
}

/* V-4: one theme chevron, drawn like the bar's other dropdown arrows. */
.fr-location-trigger__chevron {
	display: none;
}

.fr-location-trigger--discovery .fr-location-trigger__chevron {
	display: block;
	flex: none;
	width: 7px;
	height: 7px;
	margin: -4px 4px 0 auto;
	border: solid currentColor;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.fr-location-trigger--discovery .fr-location-code {
	position: absolute;
	top: 4px;
	right: var(--fr-space-2);
}

.fr-location-field:has(.fr-location-trigger--discovery .fr-location-code:not([hidden])) > .fr-label {
	padding-right: 3.6em;
}

/* L-3: below 375px From and To take a full row each, as the approved
   homepage already does below 360px, so values and labels stay readable. */
@media (max-width: 374px) {
	.fr-discovery-filters__primary > .fr-location-field {
		grid-column: 1 / -1;
	}
}

@media (min-width: 1200px) {
	.fr-location-trigger--discovery {
		font-size: 1rem;
	}

	.fr-location-trigger--discovery {
		gap: var(--fr-space-1);
	}

	.fr-location-trigger--discovery .fr-location-code {
		position: static;
		min-width: 0;
		padding: 1px 4px;
	}

	.fr-location-trigger--discovery .fr-location-trigger__chevron {
		margin-left: auto;
		margin-right: 2px;
	}

	.fr-location-field:has(.fr-location-trigger--discovery .fr-location-code:not([hidden])) > .fr-label {
		padding-right: 0;
	}
}

/* H-1 warning line and the "not searched yet" status under the bar (on navy). */
.fr-location-warning,
.fr-discovery-filters__hints .fr-location-warning {
	display: inline-block;
	margin: var(--fr-space-1) 0 0;
	padding: var(--fr-space-1) var(--fr-space-2);
	border-radius: var(--fr-radius-sm);
	background: var(--fr-warning-bg);
	color: var(--fr-warning);
	font-size: 0.78rem;
	font-weight: 600;
	line-height: 1.35;
}

.fr-location-warning[hidden] {
	display: none;
}

.fr-discovery-filters__pending {
	margin: var(--fr-space-2) 0 0;
	font-size: 0.8rem;
	font-weight: 600;
	line-height: 1.35;
	color: var(--fr-g5-text);
}

.fr-discovery-filters__pending:empty {
	display: none;
}

/* --- The picker: anchored panel (from 768px) ------------------------------ */

.fr-location-picker {
	position: absolute;
	z-index: 1002;
	display: flex;
	flex-direction: column;
	width: 420px;
	max-width: calc(100vw - 16px);
	overflow: hidden;
	background: var(--fr-surface);
	color: var(--fr-g5-ink);
	border-radius: var(--fr-radius-g5-card);
	box-shadow: 0 0 0 1px var(--fr-g5-field-border), var(--fr-shadow-md);
	font-family: var(--fr-font-body);
	text-align: left;
}

.fr-location-picker[hidden] {
	display: none;
}

.fr-location-picker--panel {
	padding-top: var(--fr-space-3);
}

.fr-location-picker--panel .fr-location-picker__head {
	display: none;
}

/* --- The picker: full-screen sheet (below 768px) -------------------------- */

.fr-location-picker--sheet {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	width: auto;
	max-width: none;
	height: 100vh;
	height: 100dvh;
	border-radius: 0;
	box-shadow: none;
	padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

.fr-location-picker__head {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: space-between;
	gap: var(--fr-space-3);
	padding: var(--fr-space-2) var(--fr-space-2) var(--fr-space-2) var(--fr-space-4);
}

.fr-location-picker__title {
	margin: 0;
	font-family: var(--fr-font-g5-display);
	font-size: 1.25rem;
	font-weight: 800;
	color: var(--fr-g5-ink);
}

.fr-location-picker__close,
.fr-location-picker__clear {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: var(--fr-radius-md);
	background: transparent;
	color: var(--fr-g5-ink);
	cursor: pointer;
}

.fr-location-picker__clear {
	color: var(--fr-g5-ink-muted);
}

.fr-location-picker__close[hidden],
.fr-location-picker__clear[hidden] {
	display: none;
}

.fr-location-picker__close .fr-icon,
.fr-location-picker__clear .fr-icon,
.fr-location-picker__search > .fr-icon {
	width: 20px;
	height: 20px;
}

.fr-location-picker__search {
	display: flex;
	flex: none;
	align-items: center;
	gap: var(--fr-space-2);
	min-height: 48px;
	margin: 0 var(--fr-space-4) var(--fr-space-2);
	padding: 0 0 0 var(--fr-space-3);
	border: 1.5px solid var(--fr-g5-field-border);
	border-radius: var(--fr-radius-md);
	background: var(--fr-surface);
	color: var(--fr-g5-ink-muted);
}

.fr-location-picker__search:focus-within {
	outline: 2px solid var(--fr-focus-ring);
	outline-offset: 2px;
}

/* 16px, so iPhone Safari does not zoom the page on focus (R-34). */
.fr-location-picker__input {
	flex: 1 1 auto;
	min-width: 0;
	min-height: 44px;
	padding: 0;
	border: 0;
	background: transparent;
	font-family: var(--fr-font-body);
	font-size: 1rem;
	color: var(--fr-g5-ink);
}

.fr-location-picker__input::placeholder {
	color: var(--fr-g5-ink-muted);
	opacity: 1;
}

.fr-location-picker__input:focus {
	outline: none; /* The search box's own ring (:focus-within) shows focus. */
}

.fr-location-picker__message,
.fr-location-picker__note {
	flex: none;
	margin: 0 var(--fr-space-4) var(--fr-space-2);
	font-size: 0.85rem;
	line-height: 1.4;
	color: var(--fr-g5-ink-muted);
}

.fr-location-picker__message[hidden],
.fr-location-picker__note[hidden] {
	display: none;
}

.fr-location-picker__message.is-error {
	color: var(--fr-danger);
	font-weight: 600;
}

/* H-1: informational, never an option. */
.fr-location-picker__note {
	padding: var(--fr-space-2) var(--fr-space-3);
	border-left: 3px solid var(--fr-warning);
	border-radius: var(--fr-radius-sm);
	background: var(--fr-warning-bg);
	color: var(--fr-warning);
	font-weight: 600;
}

.fr-location-picker__list {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding: 0 0 var(--fr-space-3);
}

.fr-location-picker__group-label {
	padding: var(--fr-space-3) var(--fr-space-4) var(--fr-space-1);
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--fr-g5-ink-muted);
}

.fr-location-picker__option {
	display: flex;
	align-items: center;
	gap: var(--fr-space-3);
	min-height: 48px;
	padding: var(--fr-space-2) var(--fr-space-4);
	cursor: pointer;
	color: var(--fr-g5-ink);
}

.fr-location-picker__option:hover,
.fr-location-picker__option.is-active {
	background: var(--fr-bg);
	box-shadow: inset 3px 0 0 var(--fr-g5-pink);
}

.fr-location-picker__option-text {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.fr-location-picker__option-main {
	font-size: 0.95rem;
	font-weight: 600;
	overflow-wrap: anywhere;
}

.fr-location-picker__option-detail {
	font-size: 0.8rem;
	color: var(--fr-g5-ink-muted);
	overflow-wrap: anywhere;
}

/* The committed value is marked (aria-selected) with a check. */
.fr-location-picker__option[aria-selected="true"]::after {
	content: "";
	flex: none;
	width: 6px;
	height: 12px;
	margin-right: 4px;
	border: solid var(--fr-success);
	border-width: 0 2.5px 2.5px 0;
	transform: rotate(45deg);
}

/* R-32: a code that could not be checked is never styled as an airport. */
.fr-location-picker__option--unchecked .fr-location-picker__option-detail {
	color: var(--fr-warning);
	font-weight: 600;
}

.fr-location-picker :focus-visible {
	outline: 2px solid var(--fr-focus-ring);
	outline-offset: 2px;
}

/* The search box carries the ring for its input (:focus-within above). */
.fr-location-picker .fr-location-picker__input:focus,
.fr-location-picker .fr-location-picker__input:focus-visible {
	outline: none;
}

/* --- D317: several airports, countries and nearby airports ---------------
   Same surface, ink, pink highlight, code badge and 44px targets as the rest
   of the picker; no new colour. */

/* The closed field with 2–3 airports shows their codes ("LHR, VIE, HKG"). */
.fr-location-trigger.is-multiple .fr-location-trigger__place {
	letter-spacing: 0.02em;
}

/* "All" — a country-wide scope, not an airport code. */
.fr-location-code--scope {
	text-transform: uppercase;
}

.fr-location-picker__selection {
	flex: none;
	max-height: 60vh;
	overflow-y: auto;
	overscroll-behavior: contain;
	margin: 0 var(--fr-space-4) var(--fr-space-2);
	padding: var(--fr-space-2) 0 var(--fr-space-3);
	border-bottom: 1px solid var(--fr-g5-field-border);
}

.fr-location-picker__selection[hidden],
.fr-location-picker__nearby[hidden],
.fr-location-picker__nearby-panel[hidden],
.fr-location-picker__add[hidden] {
	display: none;
}

.fr-location-picker__selection-head {
	margin: 0 0 var(--fr-space-2);
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--fr-g5-ink-muted);
}

.fr-location-picker__chips {
	display: flex;
	flex-wrap: wrap;
	gap: var(--fr-space-2);
	margin: 0;
	padding: 0;
	list-style: none;
}

.fr-location-picker__chip-item {
	min-width: 0;
	max-width: 100%;
}

/* A removable airport chip: the whole chip is the remove button (44px tall). */
.fr-location-picker__chip {
	display: inline-flex;
	align-items: center;
	gap: var(--fr-space-2);
	max-width: 100%;
	min-height: 44px;
	padding: 0 var(--fr-space-2) 0 var(--fr-space-3);
	border: 1.5px solid var(--fr-g5-field-border);
	border-radius: var(--fr-radius-md);
	background: var(--fr-bg);
	font-family: var(--fr-font-body);
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--fr-g5-ink);
	cursor: pointer;
}

.fr-location-picker__chip:hover {
	border-color: var(--fr-g5-pink);
}

.fr-location-picker__chip-place {
	min-width: 0;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.fr-location-picker__chip .fr-icon {
	flex: none;
	width: 16px;
	height: 16px;
	color: var(--fr-g5-ink-muted);
}

.fr-location-picker__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--fr-space-2);
	margin-top: var(--fr-space-2);
}

.fr-location-picker__add {
	display: inline-flex;
	align-items: center;
	gap: var(--fr-space-1);
	min-height: 44px;
	padding: 0 var(--fr-space-2);
	border: 0;
	border-radius: var(--fr-radius-md);
	background: transparent;
	font-family: var(--fr-font-body);
	font-size: 0.95rem;
	font-weight: 700;
	color: var(--fr-g5-ink);
	cursor: pointer;
}

.fr-location-picker__add .fr-icon {
	width: 18px;
	height: 18px;
	color: var(--fr-g5-pink-action);
}

.fr-location-picker__add:hover {
	box-shadow: inset 0 -2px 0 var(--fr-g5-pink);
}

.fr-location-picker__done {
	margin-left: auto;
}

/* Nearby airports: a collapsed disclosure; checkboxes only when verified. */
.fr-location-picker__nearby {
	margin-top: var(--fr-space-2);
	border-top: 1px solid var(--fr-g5-field-border);
}

.fr-location-picker__nearby-toggle {
	display: flex;
	align-items: center;
	gap: var(--fr-space-3);
	width: 100%;
	min-height: 48px;
	padding: var(--fr-space-2) 0;
	border: 0;
	background: transparent;
	font-family: var(--fr-font-body);
	text-align: left;
	color: var(--fr-g5-ink);
	cursor: pointer;
}

.fr-location-picker__nearby-text {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.fr-location-picker__nearby-title {
	font-size: 0.95rem;
	font-weight: 700;
}

.fr-location-picker__nearby-intro {
	font-size: 0.8rem;
	color: var(--fr-g5-ink-muted);
}

.fr-location-picker__nearby-chevron {
	flex: none;
	width: 7px;
	height: 7px;
	margin: -4px 6px 0 0;
	border: solid currentColor;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.fr-location-picker__nearby-toggle[aria-expanded="true"] .fr-location-picker__nearby-chevron {
	margin-top: 4px;
	transform: rotate(-135deg);
}

.fr-location-picker__nearby-note {
	margin: 0 0 var(--fr-space-2);
	font-size: 0.85rem;
	line-height: 1.4;
	color: var(--fr-g5-ink-muted);
}

.fr-location-picker__nearby-set {
	min-width: 0;
	margin: 0 0 var(--fr-space-2);
	padding: 0;
	border: 0;
}

.fr-location-picker__nearby-legend {
	padding: 0;
	margin-bottom: var(--fr-space-1);
	font-size: 0.8rem;
	font-weight: 700;
	color: var(--fr-g5-ink-muted);
}

.fr-location-picker__nearby-option {
	display: flex;
	align-items: center;
	gap: var(--fr-space-3);
	min-height: 44px;
	cursor: pointer;
}

.fr-location-picker__nearby-option input {
	flex: none;
	width: 20px;
	height: 20px;
	margin: 0;
	accent-color: var(--fr-g5-pink-action);
}

.fr-location-picker__nearby-option:has(input:disabled) {
	cursor: not-allowed;
	opacity: 0.55;
}

.fr-location-picker__select-all {
	min-height: 44px;
	padding: 0 var(--fr-space-2);
	border: 0;
	background: transparent;
	font-family: var(--fr-font-body);
	font-size: 0.9rem;
	font-weight: 700;
	color: var(--fr-g5-ink);
	text-decoration: underline;
	cursor: pointer;
}

/* At the limit, other airports cannot be added (the message says why). */
.fr-location-picker__option.is-disabled {
	cursor: not-allowed;
	opacity: 0.5;
}

.fr-location-picker__option.is-disabled:hover {
	background: transparent;
	box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
	.fr-location-picker,
	.fr-location-picker * {
		transition: none !important;
		animation: none !important;
	}
}
