/**
 * CV Compatibility Centre: the finder.
 *
 * Values from the Figma (archive 8661:18043, focus 8754:17483, done
 * 8754:16988): field 548 wide with an 18px value, dropdown on a 24 radius
 * with an 8px shadow, answer column 480 wide. The grey block and the H1
 * around it are built in GenerateBlocks.
 */

/* ── the field ───────────────────────────────────────────── */
.cg-finder {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 48px;
	width: 100%;
}

.cg-finder__search {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	width: 548px;
	max-width: 100%;
}

.cg-finder__bar {
	position: relative;
	width: 100%;
	z-index: 30;
}

.cg-finder__bar > svg {
	position: absolute;
	left: 24px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--cg-gray-500);
	pointer-events: none;
}

/* Figma: 59 tall (15 + 27 + 15 + the 1px border), 24 of side padding,
   12 between the icons and the text */
.cg-finder__input,
.cg-finder__input[type="text"] {
	width: 100%;
	margin: 0;
	font: inherit;
	font-size: 18px;
	line-height: 1.5;
	letter-spacing: -.02em;
	color: var(--cg-gray-700);
	caret-color: var(--cg-brand);
	background: var(--cg-white);
	border: 1px solid var(--cg-gray-300);
	border-radius: 9999px;
	padding: 15px 24px 15px 56px;
	box-shadow: none;
	-webkit-appearance: none;
	appearance: none;
	transition: border-color 200ms var(--cg-ease), box-shadow 200ms var(--cg-ease);
}

.cg-finder__input::placeholder {
	color: var(--cg-gray-500);
}

/* focus: a 2px brand border drawn inside, so nothing moves */
.cg-finder__input:focus,
.cg-finder__input[type="text"]:focus {
	outline: none;
	border-color: var(--cg-brand);
	box-shadow: inset 0 0 0 1px var(--cg-brand);
}

/* with focus or a value, the icon darkens as the text does */
.cg-finder__bar:focus-within > svg,
.cg-finder__bar:has(.cg-finder__input:not(:placeholder-shown)) > svg {
	color: var(--cg-gray-700);
}

/* Figma cancel-01, only while typing */
.cg-finder__clear {
	display: none;
	position: absolute;
	right: 24px;
	top: 50%;
	transform: translateY(-50%);
	width: 20px;
	height: 20px;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: var(--cg-gray-700);
	cursor: pointer;
	place-items: center;
}

.cg-finder__clear:hover,
.cg-finder__clear:focus {
	background: none;
	color: var(--cg-gray-950);
}

.cg-finder__clear:focus-visible {
	outline: 2px solid var(--cg-brand);
	outline-offset: 2px;
	border-radius: 4px;
}

.cg-finder__bar:focus-within:has(.cg-finder__input:not(:placeholder-shown)) .cg-finder__clear {
	display: grid;
}

/* the text keeps clear of the X only while the X is there, so the
   placeholder gets the whole field */
.cg-finder__bar:focus-within:has(.cg-finder__input:not(:placeholder-shown)) .cg-finder__input {
	padding-right: 56px;
}

.cg-finder__hint {
	margin: 0;
	font-size: 14px;
	line-height: 1.4;
	color: var(--cg-gray-600); /* on grey: gray-500 falls short of AA */
	text-align: center;
}

/* ── the dropdown: kits by full name with a photo, never a scrollbar ── */
.cg-finder__sugg {
	display: none;
	position: absolute;
	left: 0;
	right: 0;
	top: calc(100% + 8px);
	z-index: 40;
	background: var(--cg-white);
	border: 1px solid var(--cg-gray-200);
	border-radius: 24px;
	padding: 8px;
	box-shadow: 0 8px 24px rgba(23, 20, 18, .08);
	text-align: left;
}

.cg-finder__sugg.is-open {
	display: block;
}

.cg-finder:not(.cg-finder--mini) .cg-label {
	color: var(--cg-gray-600); /* the hub's finder sits on grey */
}

.cg-finder__head {
	padding: 8px 16px 4px;
}

.cg-finder__row {
	display: flex;
	width: 100%;
	align-items: center;
	gap: 12px;
	margin: 0;
	background: none;
	border: 0;
	padding: 8px 16px;
	border-radius: 16px;
	font: inherit;
	text-align: left;
	color: inherit;
	cursor: pointer;
	transition: background 200ms var(--cg-ease);
}

.cg-finder__row:hover,
.cg-finder__row.is-cursor {
	background: var(--cg-gray-100);
}

.cg-finder__ic {
	width: 40px;
	height: 40px;
	flex: 0 0 40px;
	border-radius: 6px;
	background: var(--cg-gray-100);
	overflow: hidden;
	display: grid;
	place-items: center;
}

.cg-finder__ic img,
.cg-card__ph img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	mix-blend-mode: multiply;
}

.cg-finder__t {
	font-size: 16px;
	line-height: 1.5;
	font-weight: 400;
	color: var(--cg-gray-700);
}

.cg-finder__t b {
	font-weight: 600;
}

.cg-finder__none {
	margin: 0;
	padding: 12px 16px;
	font-size: 14px;
	line-height: 1.5;
	color: var(--cg-gray-500);
}

/* ── the answer: the device, then its parts as cards ─────── */
.cg-finder__answer {
	width: 480px;
	max-width: 100%;
	display: flex;
	flex-direction: column;
	gap: 24px;
	text-align: left;
	container-type: inline-size;
}

.cg-finder__answer[hidden] {
	display: none;
}

.cg-finder__parts {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.cg-finder__list {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.cg-card {
	display: flex;
	align-items: center;
	gap: 12px;
	background: var(--cg-white);
	border: 1px solid var(--cg-gray-300);
	border-radius: 20px;
	padding: 12px 24px 12px 12px;
	text-decoration: none;
	transition: border-color 200ms var(--cg-ease), opacity 200ms var(--cg-ease);
}

/* a part card reacts as every card on the site: the border darkens to
   gray-500 (first time vaper quiz, hub guide cards); a tap dims it */
a.cg-card:is(:hover, :focus-visible) {
	border-color: var(--cg-gray-500);
}

a.cg-card:active {
	opacity: .92;
	transition-duration: 50ms;
}

.cg-card__ph {
	width: 64px;
	height: 64px;
	flex: 0 0 64px;
	border-radius: 8px;
	background: var(--cg-gray-100);
	overflow: hidden;
	display: grid;
	place-items: center;
}

.cg-card__tx {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.cg-card__k {
	font-size: 14px;
	line-height: 1.4;
	color: var(--cg-gray-500);
}

.cg-card__n {
	font-size: 16px;
	font-weight: 500;
	line-height: 1.5;
	color: var(--cg-gray-800);
}

.cg-card__pr {
	font-size: 16px;
	line-height: 1.5;
	color: var(--cg-gray-600);
	white-space: nowrap;
}

.cg-card .cg-chev {
	flex: 0 0 16px;
	color: var(--cg-gray-500);
}

.cg-finder__change {
	margin: 0;
	padding: 0;
	font: inherit;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.4;
	color: var(--cg-gray-500);
	background: none;
	border: 0;
	cursor: pointer;
	text-decoration: underline;
	white-space: nowrap;
}

.cg-finder__change:hover {
	color: var(--cg-gray-950);
	background: none;
}

/* ── mini: the guide rail ────────────────────────────────── */
.cg-finder--mini {
	gap: 0;
}

.cg-finder--mini .cg-finder__bar > svg {
	left: 20px;
}

/* Figma: 45 tall, 20 of side padding, a 16 icon, 12 to the text */
.cg-finder--mini .cg-finder__input,
.cg-finder--mini .cg-finder__input[type="text"] {
	font-size: 14px;
	padding: 11px 20px 11px 48px;
}

.cg-finder--mini .cg-finder__bar:focus-within:has(.cg-finder__input:not(:placeholder-shown)) .cg-finder__input {
	padding-right: 48px;
}

.cg-finder--mini .cg-finder__clear {
	right: 20px;
	width: 16px;
	height: 16px;
}

.cg-finder--mini .cg-finder__sugg {
	right: auto;
	width: 280px;
	top: calc(100% + 4px);
	border-radius: 16px;
	z-index: 60;
}

.cg-finder--mini .cg-finder__row {
	padding: 8px 12px;
	border-radius: 12px;
}

.cg-finder--mini .cg-finder__t {
	font-size: 14px;
}

/* ── breakpoints: the site's own, 1024 (tablet) and 767 (phone) ── */
@media (max-width: 1024px) {
	.cg-finder {
		gap: 32px;
	}
}

@media (max-width: 767px) {
	/* on a phone the guide's own "Open the finder" does this job */
	.cg-finder--mini {
		display: none;
	}

	.cg-finder__input,
	.cg-finder__input[type="text"] {
		font-size: 16px;
		padding: 12px 16px 12px 48px;
	}

	.cg-finder__bar:focus-within:has(.cg-finder__input:not(:placeholder-shown)) .cg-finder__input {
		padding-right: 48px;
	}

	.cg-finder__bar > svg {
		left: 16px;
	}

	.cg-finder__clear {
		right: 16px;
	}

	.cg-finder__answer {
		gap: 16px;
	}
}

/* a narrow answer (phones): compact cards, as the kit block's. Name and
   price step down to 14, the photo to 48, 8 between cards, no arrow */
@container (max-width: 360px) {
	.cg-finder__list {
		gap: 8px;
	}

	.cg-card {
		padding: 8px 16px 8px 8px;
		border-radius: 16px;
	}

	.cg-card__ph {
		width: 48px;
		height: 48px;
		flex-basis: 48px;
		border-radius: 6px;
	}

	.cg-card__n,
	.cg-card__pr {
		font-size: 14px;
		line-height: 1.4;
	}

	.cg-card__k {
		font-size: 12px;
	}

	/* the whole card is the link; the arrow's width goes to the name */
	.cg-card .cg-chev {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cg-finder *,
	.cg-card {
		transition: none;
	}
}
