/**
 * Autolight AI Bulb Finder – frontend.
 * All colours are CSS variables (overridable from admin → Frontend).
 */

.albf {
	--albf-bg: #0b0f14;
	--albf-card: #171e28;
	--albf-border: #263243;
	--albf-text: #ffffff;
	--albf-muted: #a9b4c4;
	--albf-blue: #5aa9ff;
	--albf-accent: #f2c230;
	--albf-accent-text: #0b0f14;
	--albf-radius: 16px;
	--albf-radius-sm: 10px;
	--albf-input-bg: rgba(255, 255, 255, 0.04);
	--albf-row-alt: rgba(255, 255, 255, 0.025);
	--albf-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
	--albf-ease: cubic-bezier(0.2, 0.7, 0.2, 1);

	container-type: inline-size;
	box-sizing: border-box;
	width: 100%;
	margin: 0 auto;
	padding: clamp(12px, 3vw, 32px);
	background: var(--albf-bg);
	border-radius: var(--albf-radius);
	color: var(--albf-text);
	font-family: inherit;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

.albf *,
.albf *::before,
.albf *::after {
	box-sizing: border-box;
}

.albf__card {
	position: relative;
	background:
		radial-gradient(120% 80% at 100% 0%, rgba(90, 169, 255, 0.07), transparent 60%),
		var(--albf-card);
	border: 1px solid var(--albf-border);
	border-radius: var(--albf-radius);
	padding: clamp(20px, 4vw, 40px);
	box-shadow: var(--albf-shadow);
	overflow: hidden;
}

.albf__card::before {
	content: "";
	position: absolute;
	inset: 0 0 auto 0;
	height: 3px;
	background: linear-gradient(90deg, transparent, var(--albf-accent), transparent);
	opacity: 0.85;
}

/* Header ---------------------------------------------------------------- */

.albf__header {
	margin: 0 0 clamp(18px, 3vw, 28px);
}

.albf .albf__title {
	margin: 0 0 6px;
	padding: 0;
	color: var(--albf-text);
	font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.25rem);
	font-weight: 800;
	letter-spacing: -0.02em;
	line-height: 1.15;
	text-transform: none;
	border: 0;
}

.albf .albf__subtitle {
	margin: 0;
	color: var(--albf-blue);
	font-size: 1rem;
	opacity: 0.9;
}

/* Form ------------------------------------------------------------------ */

.albf__form {
	margin: 0;
}

.albf__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 14px 16px;
}

.albf__grid--four {
	grid-template-columns: repeat(4, minmax(0, 1fr));
}

.albf__field {
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	gap: 6px;
	min-width: 0;
}

.albf .albf__label {
	display: block;
	margin: 0;
	color: var(--albf-muted);
	font-size: 0.8rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.albf__optional {
	color: var(--albf-blue);
	font-weight: 500;
	letter-spacing: 0;
	text-transform: none;
	opacity: 0.8;
}

.albf .albf__input {
	-webkit-appearance: none;
	appearance: none;
	display: block;
	width: 100%;
	height: 52px;
	margin: 0;
	padding: 0 16px;
	background: var(--albf-input-bg);
	border: 1px solid var(--albf-border);
	border-radius: var(--albf-radius-sm);
	box-shadow: none;
	color: var(--albf-text);
	font: inherit;
	font-size: 1rem;
	line-height: 52px;
	transition: border-color 0.2s var(--albf-ease), background-color 0.2s var(--albf-ease), box-shadow 0.2s var(--albf-ease);
}

.albf .albf__input::placeholder {
	color: var(--albf-muted);
	opacity: 0.55;
}

.albf .albf__input:hover {
	border-color: color-mix(in srgb, var(--albf-border) 50%, var(--albf-muted));
}

.albf .albf__input:focus,
.albf .albf__input:focus-visible {
	outline: none;
	border-color: var(--albf-accent);
	background: rgba(255, 255, 255, 0.06);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--albf-accent) 25%, transparent);
}

.albf .albf__input[aria-invalid="true"] {
	border-color: #ff6b6b;
}

.albf .albf__input--plate {
	text-transform: uppercase;
	letter-spacing: 0.08em;
}

.albf__hp {
	position: absolute !important;
	left: -10000px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.albf__turnstile {
	margin-top: 16px;
}

.albf__actions {
	margin-top: 20px;
}

.albf .albf__button {
	-webkit-appearance: none;
	appearance: none;
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	min-width: 220px;
	height: 54px;
	margin: 0;
	padding: 0 28px;
	background: var(--albf-accent);
	border: 0;
	border-radius: 999px;
	box-shadow: 0 8px 24px color-mix(in srgb, var(--albf-accent) 25%, transparent);
	color: var(--albf-accent-text);
	cursor: pointer;
	font: inherit;
	font-size: 1rem;
	font-weight: 800;
	letter-spacing: 0.02em;
	line-height: 1;
	text-transform: none;
	transition: transform 0.2s var(--albf-ease), box-shadow 0.2s var(--albf-ease), filter 0.2s var(--albf-ease);
}

.albf .albf__button:hover {
	transform: translateY(-2px);
	box-shadow: 0 12px 32px color-mix(in srgb, var(--albf-accent) 40%, transparent);
	filter: brightness(1.05);
}

.albf .albf__button:active {
	transform: translateY(0);
}

.albf .albf__button:focus-visible {
	outline: 3px solid var(--albf-text);
	outline-offset: 3px;
}

.albf .albf__button[disabled] {
	cursor: progress;
	transform: none;
	filter: saturate(0.8);
	opacity: 0.9;
}

.albf__spinner {
	display: none;
	width: 18px;
	height: 18px;
	border: 2px solid color-mix(in srgb, var(--albf-accent-text) 30%, transparent);
	border-top-color: var(--albf-accent-text);
	border-radius: 50%;
	animation: albf-spin 0.7s linear infinite;
}

.albf.is-loading .albf__spinner {
	display: inline-block;
}

@keyframes albf-spin {
	to {
		transform: rotate(360deg);
	}
}

.albf .albf__form-error {
	margin: 14px 0 0;
	color: #ff8a8a;
	font-size: 0.95rem;
}

/* Results --------------------------------------------------------------- */

.albf__results:focus {
	outline: none;
}

.albf__results:empty {
	display: none;
}

.albf__results {
	margin-top: clamp(24px, 4vw, 36px);
}

.albf-result {
	transition: opacity 0.35s var(--albf-ease), transform 0.35s var(--albf-ease);
}

.albf-result.is-entering {
	opacity: 0;
	transform: translateY(8px);
}

.albf .albf-result__title {
	margin: 0 0 16px;
	padding: 0;
	color: var(--albf-text);
	font-size: clamp(1.15rem, 1rem + 0.6vw, 1.45rem);
	font-weight: 700;
	letter-spacing: -0.01em;
	border: 0;
}

.albf .albf-result__note {
	margin: 16px 0 0;
	color: var(--albf-muted);
	font-size: 0.85rem;
}

/* Desktop table */
.albf .albf-table {
	width: 100%;
	margin: 0;
	border: 1px solid var(--albf-border);
	border-collapse: separate;
	border-spacing: 0;
	border-radius: var(--albf-radius-sm);
	overflow: hidden;
	background: transparent;
	font-size: 0.97rem;
}

.albf .albf-table th,
.albf .albf-table td {
	padding: 14px 18px;
	border: 0;
	border-bottom: 1px solid var(--albf-border);
	background: transparent;
	color: var(--albf-text);
	text-align: left;
	vertical-align: middle;
}

.albf .albf-table thead th {
	background: rgba(255, 255, 255, 0.03);
	color: var(--albf-blue);
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.albf .albf-table tbody tr:nth-child(even) td {
	background: var(--albf-row-alt);
}

.albf .albf-table tbody tr:last-child td {
	border-bottom: 0;
}

.albf .albf-table tbody tr:hover td {
	background: rgba(255, 255, 255, 0.05);
}

.albf .albf-table__position {
	font-weight: 600;
}

.albf .albf-table__variant {
	color: var(--albf-muted);
}

/* 2.0: fitment period next to the position, e.g. "Nærlys 2015–2020". */
.albf .albf-years {
	color: var(--albf-muted);
	font-weight: 500;
	white-space: nowrap;
}

.albf .albf-table__action {
	width: 1%;
	text-align: right;
	white-space: nowrap;
}

.albf-bulb {
	color: var(--albf-text);
	font-weight: 800;
	letter-spacing: 0.02em;
}

.albf-spec {
	margin-left: 8px;
	color: var(--albf-muted);
	font-size: 0.9em;
}

.albf-flag {
	display: inline-block;
	margin-left: 8px;
	padding: 2px 8px;
	border: 1px solid color-mix(in srgb, var(--albf-blue) 50%, transparent);
	border-radius: 999px;
	color: var(--albf-blue);
	font-size: 0.75rem;
	font-weight: 600;
	white-space: nowrap;
}

.albf-led {
	color: var(--albf-blue);
	font-size: 0.85rem;
	font-weight: 600;
	white-space: nowrap;
}

.albf-none {
	color: var(--albf-muted);
}

.albf .albf-shop,
.albf .albf-shop:visited {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 8px 16px;
	background: var(--albf-accent);
	border: 0;
	border-radius: 999px;
	color: var(--albf-accent-text);
	font-size: 0.8rem;
	font-weight: 800;
	letter-spacing: 0.04em;
	line-height: 1.2;
	text-decoration: none;
	text-transform: uppercase;
	white-space: nowrap;
	transition: transform 0.2s var(--albf-ease), box-shadow 0.2s var(--albf-ease), filter 0.2s var(--albf-ease);
}

.albf .albf-shop:hover {
	color: var(--albf-accent-text);
	transform: translateY(-1px);
	box-shadow: 0 6px 18px color-mix(in srgb, var(--albf-accent) 35%, transparent);
	filter: brightness(1.05);
}

.albf .albf-shop:focus-visible {
	outline: 2px solid var(--albf-text);
	outline-offset: 2px;
}

/* Mobile cards (hidden on wide containers) */
.albf .albf-cards {
	display: none;
	margin: 0;
	padding: 0;
	list-style: none;
}

.albf .albf-cardrow {
	margin: 0 0 12px;
	padding: 16px 18px;
	background: rgba(255, 255, 255, 0.03);
	border: 1px solid var(--albf-border);
	border-radius: var(--albf-radius-sm);
	list-style: none;
}

.albf-cardrow__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 4px 12px;
	margin-bottom: 10px;
}

.albf-cardrow__position {
	color: var(--albf-text);
	font-weight: 700;
}

.albf-cardrow__variant {
	color: var(--albf-blue);
	font-size: 0.85rem;
	font-weight: 600;
}

.albf-cardrow__bulb {
	color: var(--albf-text);
	font-size: 1.6rem;
	font-weight: 800;
	letter-spacing: 0.01em;
	line-height: 1.15;
}

.albf-cardrow__bulb--led {
	font-size: 1.1rem;
	font-weight: 700;
}

.albf-cardrow__spec {
	margin-top: 2px;
	color: var(--albf-muted);
	font-size: 0.92rem;
}

.albf-cardrow .albf-flag {
	margin: 10px 0 0;
}

.albf-cardrow .albf-led {
	display: block;
	margin-top: 12px;
}

.albf .albf-shop--block {
	display: flex;
	width: 100%;
	margin-top: 14px;
	padding: 12px 16px;
	font-size: 0.85rem;
}

/* Messages */
.albf-message {
	padding: 20px 22px;
	background: rgba(255, 255, 255, 0.03);
	border: 1px solid var(--albf-border);
	border-left: 3px solid var(--albf-accent);
	border-radius: var(--albf-radius-sm);
}

.albf .albf-message__title {
	margin: 0 0 4px;
	color: var(--albf-text);
	font-size: 1.05rem;
	font-weight: 700;
}

.albf .albf-message__text {
	margin: 0;
	color: var(--albf-muted);
}

.albf .albf-message a {
	color: var(--albf-accent);
	text-decoration: underline;
}

/* Responsive (container based – works in narrow columns too) ------------- */

@container (max-width: 860px) {
	.albf__grid--four {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@container (max-width: 640px) {
	.albf__grid,
	.albf__grid--four {
		grid-template-columns: 1fr;
	}

	.albf .albf__button {
		width: 100%;
		min-width: 0;
	}

	.albf .albf-table {
		display: none;
	}

	.albf .albf-cards {
		display: block;
	}
}

/* Fallback for browsers without container queries */
@supports not (container-type: inline-size) {
	@media (max-width: 640px) {
		.albf__grid,
		.albf__grid--four {
			grid-template-columns: 1fr;
		}

		.albf .albf__button {
			width: 100%;
			min-width: 0;
		}

		.albf .albf-table {
			display: none;
		}

		.albf .albf-cards {
			display: block;
		}
	}
}

.albf .albf-hint {
	margin: 12px 0 0;
	color: var(--albf-muted);
	font-size: 0.9rem;
	text-align: center;
}

@media (prefers-reduced-motion: reduce) {
	.albf *,
	.albf *::before,
	.albf *::after,
	.albf-ac-layer * {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}

/* ------------------------------------------------------------------
 * Autocomplete (2.1.0) – same dark theme, yellow active state.
 * ------------------------------------------------------------------ */
.albf--ac-open .albf__card {
	overflow: visible; /* Let the suggestion list extend past the card while open. */
}

.albf__field--ac {
	position: relative;
}

/* 2.1.7: the list is rendered in a fixed layer on <body> (positioned by JS under –
 * or, without room, above – the field), so cards/sections after the finder can
 * never cover or clip it, whatever their stacking context or overflow. */
.albf-ac-layer {
	--albf-card: #171e28;
	--albf-border: #263243;
	--albf-text: #ffffff;
	--albf-muted: #a9b4c4;
	--albf-accent: #f2c230;
	--albf-accent-text: #0b0f14;
	--albf-ease: cubic-bezier(0.2, 0.7, 0.2, 1);

	position: fixed;
	top: 0;
	left: 0;
	z-index: 2147483000;
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

.albf-ac-layer[hidden] {
	display: none;
}

.albf-ac-layer *,
.albf-ac-layer *::before,
.albf-ac-layer *::after {
	box-sizing: border-box;
}

.albf .albf-ac,
.albf-ac-layer .albf-ac {
	position: relative;
	z-index: 1;
	width: 100%;
	max-height: min(288px, 46vh);
	margin: 0;
	padding: 6px;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	list-style: none;
	background: color-mix(in srgb, var(--albf-card) 92%, #ffffff);
	border: 1px solid var(--albf-border);
	border-radius: 12px;
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
	color: var(--albf-text);
	text-align: left;
	/* Dark scrollbar instead of the browser's white default. */
	scrollbar-width: thin;
	scrollbar-color: var(--albf-border) transparent;
	animation: albf-ac-in 0.14s var(--albf-ease);
}

.albf-ac-layer .albf-ac::-webkit-scrollbar {
	width: 8px;
}

.albf-ac-layer .albf-ac::-webkit-scrollbar-track {
	background: transparent;
}

.albf-ac-layer .albf-ac::-webkit-scrollbar-thumb {
	background: var(--albf-border);
	border-radius: 8px;
}

.albf-ac-layer--up .albf-ac {
	box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.5);
}

.albf .albf-ac[hidden],
.albf-ac-layer .albf-ac[hidden] {
	display: none;
}

.albf .albf-ac__option,
.albf-ac-layer .albf-ac__option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	min-height: 44px;
	margin: 0;
	padding: 10px 12px;
	border-radius: 8px;
	color: var(--albf-text);
	font-size: 0.95rem;
	line-height: 1.3;
	cursor: pointer;
	overflow-wrap: anywhere;
	-webkit-tap-highlight-color: transparent;
	transition: background-color 0.12s var(--albf-ease), color 0.12s var(--albf-ease);
}

.albf .albf-ac__option strong,
.albf-ac-layer .albf-ac__option strong {
	color: var(--albf-accent);
	font-weight: 700;
}

.albf .albf-ac__option:hover,
.albf .albf-ac__option.is-active,
.albf-ac-layer .albf-ac__option:hover,
.albf-ac-layer .albf-ac__option.is-active {
	background: var(--albf-accent);
	color: var(--albf-accent-text);
}

.albf .albf-ac__option:hover strong,
.albf .albf-ac__option.is-active strong,
.albf-ac-layer .albf-ac__option:hover strong,
.albf-ac-layer .albf-ac__option.is-active strong {
	color: inherit;
}

.albf .albf-ac__tag,
.albf-ac-layer .albf-ac__tag {
	flex: none;
	color: var(--albf-muted);
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.albf .albf-ac__option:hover .albf-ac__tag,
.albf .albf-ac__option.is-active .albf-ac__tag,
.albf-ac-layer .albf-ac__option:hover .albf-ac__tag,
.albf-ac-layer .albf-ac__option.is-active .albf-ac__tag {
	color: inherit;
	opacity: 0.75;
}

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

@keyframes albf-ac-in {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}
