/* LEGO Filter
 * Farger og tekster styres fra Innstillinger → LEGO Filter.
 * Overstyring fra Elementor (Egendefinert CSS) fungerer også:
 * .lf-wrap { --lf-accent: #e3000b; --lf-radius: 4px; }
 */

.lf-wrap {
	--lf-accent: #111;
	--lf-on-accent: #fff;
	--lf-bg: #fff;
	--lf-border: rgba(0, 0, 0, 0.14);
	--lf-muted: rgba(0, 0, 0, 0.55);
	--lf-radius: 8px;
	--lf-gap: 12px;
	/* Knapper: fylt som standard. Innstillingen «Kontur» bytter til .lf--outline under. */
	--lf-btn-border-w: 1px;
	--lf-btn-border: var(--lf-accent);
	--lf-btn-bg: var(--lf-accent);
	--lf-btn-fg: var(--lf-on-accent);
	--lf-btn-hover-bg: transparent;
	--lf-btn-hover-fg: var(--lf-accent);
	font-size: 15px;
	line-height: 1.4;
}
.lf-wrap.lf--outline {
	--lf-btn-bg: transparent;
	--lf-btn-fg: var(--lf-accent);
	--lf-btn-hover-bg: var(--lf-accent);
	--lf-btn-hover-fg: var(--lf-on-accent);
}

.lf-wrap [hidden] { display: none !important; }

/* Nøytraliser temaets og Elementors globale knappestil på pluginens egne knapper.
   Elementor skriver «.elementor-kit-N button { … }», som ellers vinner over enkle klasser. */
.lf-wrap button,
.lf-wrap button:hover,
.lf-wrap button:focus,
.lf-wrap button:active {
	background: none;
	border: 0;
	border-radius: 0;
	padding: 0;
	margin: 0;
	box-shadow: none;
	text-shadow: none;
	text-transform: none;
	letter-spacing: normal;
	font: inherit;
	line-height: inherit;
	color: inherit;
	min-height: 0;
	min-width: 0;
	width: auto;
	transform: none;
}
.lf-wrap summary { font: inherit; color: inherit; }

/* Knappen som åpner skuffen – finnes bare i mobil-modus */
.lf-wrap .lf-toggle { display: none !important; }
.lf-wrap.is-mobile .lf-toggle,
.lf-wrap.is-mobile .lf-toggle:hover {
	display: inline-flex !important;
	align-items: center;
	gap: 8px;
	padding: 10px 14px;
	border: var(--lf-btn-border-w) solid var(--lf-border);
	border-radius: var(--lf-radius);
	background: var(--lf-bg);
	color: inherit;
	cursor: pointer;
}
.lf-toggle__count {
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 11px;
	background: var(--lf-accent);
	color: var(--lf-on-accent);
	font-size: 12px;
	font-weight: 500;
}

.lf-wrap .lf-backdrop { display: none !important; }
.lf-wrap.is-mobile .lf-backdrop {
	display: block !important;
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	z-index: 9998;
}
.lf-wrap.is-mobile .lf-backdrop[hidden] { display: none !important; }

/* Skjemaet – sidebar på desktop */
.lf {
	display: flex;
	flex-direction: column;
	margin: 0;
	background: var(--lf-bg);
}

.lf__head {
	display: flex;
	align-items: center;
	gap: var(--lf-gap);
	padding-bottom: var(--lf-gap);
	border-bottom: 1px solid var(--lf-border);
}
.lf__heading { font-weight: 500; font-size: 17px; }
.lf-wrap .lf__reset {
	margin-left: auto;
	font-size: 14px;
	color: var(--lf-muted);
	text-decoration: underline;
	text-underline-offset: 2px;
}
.lf-wrap .lf__reset:hover { color: inherit; }
.lf-wrap .lf__close { display: none !important; }
.lf-wrap.is-mobile .lf .lf__close,
.lf-wrap.is-mobile .lf .lf__close:hover {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--lf-border);
	color: inherit;
	cursor: pointer;
	line-height: 0;
}
.lf-wrap.is-mobile .lf .lf__close svg { display: block; }

.lf__body { padding: var(--lf-gap) 0; }

.lf__label {
	display: block;
	margin: 0 0 6px;
	padding: 0;
	font-size: 13px;
	color: var(--lf-muted);
}
.lf__section { margin-top: 18px; }

/* Segmentknapp Alle / Ny / Brukt */
.lf__seg {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 4px;
	margin: 0;
	padding: 0;
	border: 0;
	min-width: 0;
}
.lf__seg legend { grid-column: 1 / -1; }
.lf__seg-item { position: relative; display: block; }
.lf__seg-item input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	margin: 0;
}
.lf-wrap .lf__seg-item span {
	display: block;
	padding: 8px 4px;
	text-align: center;
	border: var(--lf-btn-border-w) solid var(--lf-border);
	border-radius: var(--lf-radius);
	background: transparent;
	color: inherit;
	cursor: pointer;
	user-select: none;
}
.lf-wrap .lf__seg-item input:checked + span {
	background: var(--lf-btn-bg);
	border-color: var(--lf-btn-border);
	color: var(--lf-btn-fg);
	font-weight: 500;
}
.lf__seg-item input:focus-visible + span {
	outline: 2px solid var(--lf-accent);
	outline-offset: 2px;
}

/* Kategorigrupper (details/summary) */
.lf__group { border-top: 1px solid var(--lf-border); }
.lf__group:last-child { border-bottom: 1px solid var(--lf-border); }
.lf__group-name {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 0;
	cursor: pointer;
	list-style: none;
}
.lf__group-name::-webkit-details-marker { display: none; }
.lf__group-name::after {
	content: "";
	width: 8px;
	height: 8px;
	border-right: 1.5px solid currentColor;
	border-bottom: 1.5px solid currentColor;
	transform: rotate(45deg);
	margin-right: 4px;
	transition: transform 0.15s ease;
}
.lf__group[open] > .lf__group-name::after { transform: rotate(225deg); }
.lf__group > .lf__options { padding: 0 0 10px 8px; }

/* Avkryssingsbokser */
.lf__check {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 6px 0;
	cursor: pointer;
}
.lf-wrap .lf__check input {
	width: 18px;
	height: 18px;
	margin: 0;
	padding: 0;
	flex: none;
	accent-color: var(--lf-accent);
	cursor: pointer;
}

/* Lange lister: vis de første N, resten bak «Vis alle» */
.lf__options:not(.is-expanded) > .lf__more { display: none; }
.lf-wrap .lf .lf__show-all,
.lf-wrap .lf .lf__show-all:hover {
	display: inline-block;
	margin-top: 4px;
	padding: 6px 0;
	border: 0;
	background: none;
	color: var(--lf-muted);
	font-size: 14px;
	text-decoration: underline;
	text-underline-offset: 2px;
	cursor: pointer;
}
.lf__options:not(.is-expanded) .lf__show-all-less,
.lf__options.is-expanded .lf__show-all-more { display: none; }

.lf__foot { padding-top: var(--lf-gap); }
.lf-wrap .lf .lf__submit,
.lf-wrap .lf .lf__submit:focus {
	display: block;
	width: 100%;
	padding: 12px 16px;
	border: var(--lf-btn-border-w) solid var(--lf-btn-border);
	border-radius: var(--lf-radius);
	background: var(--lf-btn-bg);
	color: var(--lf-btn-fg);
	font-weight: 500;
	text-align: center;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}
.lf-wrap .lf .lf__submit:hover {
	background: var(--lf-btn-hover-bg);
	color: var(--lf-btn-hover-fg);
}

.lf-wrap .lf .lf__submit:focus-visible,
.lf-wrap .lf-toggle:focus-visible,
.lf-wrap .lf__close:focus-visible,
.lf-wrap .lf__reset:focus-visible,
.lf-wrap .lf__show-all:focus-visible {
	outline: 2px solid var(--lf-accent);
	outline-offset: 2px;
}

/* Rutenettet mens ny liste hentes */
.lf-loading {
	opacity: 0.5;
	pointer-events: none;
	transition: opacity 0.15s ease;
}

/* Desktop med auto-oppdatering: knappen er overflødig */
.lf-wrap.lf--auto:not(.is-mobile) .lf__foot { display: none; }

/* Mobil: skuff nedenfra. Klassen is-mobile settes ut fra innstillingen «Skuff på skjermer smalere enn». */
.lf-wrap.is-mobile .lf {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	max-height: 88vh;
	max-height: 88dvh;
	padding: 0 16px;
	border-radius: 16px 16px 0 0;
	z-index: 9999;
	transform: translateY(100%);
	transition: transform 0.25s ease;
	visibility: hidden;
}
.lf-wrap.is-mobile .lf.is-open {
	transform: none;
	visibility: visible;
}
.lf-wrap.is-mobile .lf__head {
	position: sticky;
	top: 0;
	padding-top: 14px;
	background: var(--lf-bg);
}
.lf-wrap.is-mobile .lf__head::before {
	content: "";
	position: absolute;
	top: 6px;
	left: 50%;
	width: 36px;
	height: 4px;
	margin-left: -18px;
	border-radius: 2px;
	background: var(--lf-border);
}
.lf-wrap.is-mobile .lf__body {
	flex: 1;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}
.lf-wrap.is-mobile .lf__foot {
	position: sticky;
	bottom: 0;
	padding-bottom: calc(14px + env(safe-area-inset-bottom));
	background: var(--lf-bg);
	border-top: 1px solid var(--lf-border);
}

body.lf-locked { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
	.lf-wrap.is-mobile .lf,
	.lf__group-name::after,
	.lf-loading { transition: none; }
}
