/*
 * KPC Optimering – consent banner, the settings link under the footer and the cookie table.
 * The banner is fixed to the bottom of the viewport, so showing it never moves the page (no layout shift).
 * Colours are set here rather than inherited: white surface, near-black text (16:1) and the site's dark green
 * for the buttons (8.5:1 against white), independent of the section the page happens to end with.
 */

.kpco-consent {
	--kpco-c-text: #1d1d1b;
	--kpco-c-muted: #4a4a48;
	--kpco-c-accent: var(--fs-color-primary, #265359);
	--kpco-c-line: rgba(0, 0, 0, 0.16);
	position: fixed;
	z-index: 100000; /* Above the sticky header, the mobile buy bar and lightboxes: the question comes first. */
	bottom: 16px;
	left: 16px;
	box-sizing: border-box;
	width: calc(100% - 32px);
	max-width: 600px;
	max-height: calc(100vh - 32px);
	max-height: calc(100dvh - 32px);
	padding: 20px 20px 0; /* The bottom padding belongs to the button row, which stays in view when the content scrolls. */
	overflow-y: auto;
	overscroll-behavior: contain;
	border: 1px solid var(--kpco-c-line);
	border-radius: 12px;
	background: #fff;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
	color: var(--kpco-c-text);
	font-size: 0.9375rem;
	line-height: 1.5;
	text-align: left;
}

/* The hidden attribute must win over the display values below and over theme rules. */
.kpco-consent[hidden],
.kpco-consent [hidden] {
	display: none !important;
}

.kpco-consent .kpco-consent__title {
	margin: 0 0 6px;
	color: inherit;
	font-family: var(--bold-font-family, inherit);
	font-size: 1.0625rem;
	font-synthesis: none; /* The site's bold is a separate font file; do not thicken it artificially. */
	font-weight: 700;
	line-height: 1.3;
}

.kpco-consent .kpco-consent__text,
.kpco-consent .kpco-consent__more {
	margin: 0;
	color: inherit;
}

.kpco-consent a {
	color: var(--kpco-c-accent);
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* A link on a line of its own gets a full-size tap target (44 px). */
.kpco-consent .kpco-consent__more a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
}

/* Second layer ---------------------------------------------------------------------------------------------------- */

.kpco-consent__prefs {
	margin-top: 14px;
	border-top: 1px solid var(--kpco-c-line);
}

.kpco-consent__cat {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: center;
	column-gap: 12px;
	padding: 8px 0 10px;
	border-bottom: 1px solid var(--kpco-c-line);
}

.kpco-consent .kpco-consent__label {
	display: flex;
	align-items: center;
	min-height: 44px;
	margin: 0;
	color: inherit;
	font-family: var(--bold-font-family, inherit);
	font-size: inherit;
	font-synthesis: none;
	font-weight: 700;
	letter-spacing: 0;
	text-transform: none;
}

.kpco-consent label.kpco-consent__label {
	cursor: pointer;
}

.kpco-consent__always,
.kpco-consent .kpco-consent__desc {
	color: var(--kpco-c-muted);
	font-size: 0.8125rem;
}

.kpco-consent .kpco-consent__desc {
	grid-column: 1 / -1;
	margin: 0;
}

/* A checkbox drawn as a switch. The state is shown by the position of the knob, not by colour alone. */
.kpco-consent .kpco-consent__switch {
	position: relative;
	display: block;
	flex: none;
	width: 52px;
	height: 30px;
	margin: 0;
	padding: 0;
	border: 2px solid #5c5c5a;
	border-radius: 99px;
	background: #fff;
	box-shadow: none;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.kpco-consent .kpco-consent__switch::before {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: #5c5c5a;
}

/* Invisible margin that brings the tap target up to 44 px. */
.kpco-consent .kpco-consent__switch::after {
	content: "";
	position: absolute;
	inset: -9px -4px;
}

.kpco-consent .kpco-consent__switch:checked {
	border-color: var(--kpco-c-accent);
	background: var(--kpco-c-accent);
}

.kpco-consent .kpco-consent__switch:checked::before {
	background: #fff;
	transform: translateX(22px);
}

/* Buttons: one style for all, so that no choice is easier to find than another -------------------------------------- */

.kpco-consent__actions {
	position: sticky;
	bottom: 0;
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 8px;
	padding: 16px 0 20px;
	background: #fff;
}

.kpco-consent .kpco-consent__btn {
	display: block;
	width: 100%;
	min-height: 48px;
	margin: 0;
	padding: 10px 14px;
	border: 2px solid var(--kpco-c-accent);
	border-radius: 99px;
	background: var(--kpco-c-accent);
	box-shadow: none;
	color: #fff;
	cursor: pointer;
	font-family: var(--bold-font-family, inherit);
	font-size: 0.875rem;
	font-synthesis: none;
	font-weight: 700;
	letter-spacing: 0;
	line-height: 1.25;
	text-align: center;
	text-shadow: none;
	text-transform: none;
	white-space: normal;
}

.kpco-consent .kpco-consent__btn:hover {
	border-color: var(--kpco-c-text);
	background: var(--kpco-c-text);
	box-shadow: none;
	color: #fff;
}

/*
 * Focus: a dark ring on the white surface, set off from the control by a white gap. The banner itself only receives
 * focus from the script, as the starting point for Tab and screen readers; it is not a control and gets no ring.
 */
.kpco-consent:focus {
	outline: none;
}

.kpco-consent a:focus-visible,
.kpco-consent .kpco-consent__btn:focus-visible,
.kpco-consent .kpco-consent__switch:focus-visible {
	outline: 3px solid var(--kpco-c-text);
	outline-offset: 2px;
	box-shadow: 0 0 0 2px #fff;
}

@media (min-width: 550px) {
	.kpco-consent__actions {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

/* Phones: a bottom sheet that leaves the upper part of the page visible and usable. */
@media (max-width: 549px) {
	.kpco-consent {
		bottom: 0;
		left: 0;
		width: 100%;
		max-width: none;
		max-height: 80vh;
		max-height: 80dvh;
		padding: 16px 16px 0;
		border-width: 1px 0 0;
		border-radius: 16px 16px 0 0;
	}

	.kpco-consent__actions {
		padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
	}

	/* Second layer: the two ready-made answers side by side, "Spara val" below, so the switches keep their room. */
	.kpco-consent--prefs .kpco-consent__actions {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.kpco-consent--prefs .kpco-consent__btn[data-kpco-consent="save"] {
		grid-column: 1 / -1;
	}
}

/* Little room (phones, low landscape windows): the second layer drops the introduction the visitor has just read. */
@media (max-width: 549px), (max-height: 599px) {
	.kpco-consent--prefs .kpco-consent__text {
		display: none;
	}
}

/*
 * Hardly any room (a narrow window at 400 % zoom, a small phone on its side): the stacked buttons would cover the
 * whole sheet and hide the question. They scroll with the text instead.
 */
@media (max-width: 549px) and (max-height: 479px) {
	.kpco-consent__actions {
		position: static;
	}
}

/*
 * Forced colours (contrast themes) replace every background, which would make the knob disappear and both states
 * look alike. Borders are kept, so the knob is drawn as one.
 */
@media (forced-colors: active) {
	.kpco-consent .kpco-consent__switch::before {
		box-sizing: border-box;
		border: 10px solid ButtonText;
	}

	.kpco-consent .kpco-consent__switch:checked::before {
		border-color: Highlight;
	}
}

/* The question belongs to the screen, not to a printed page. */
@media print {
	.kpco-consent,
	.kpco-consent-footer {
		display: none !important;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.kpco-consent {
		animation: kpco-consent-in 0.25s ease-out;
	}

	.kpco-consent .kpco-consent__switch,
	.kpco-consent .kpco-consent__switch::before {
		transition: background-color 0.15s, border-color 0.15s, transform 0.15s;
	}
}

/* Opacity and transform only: neither moves the page. */
@keyframes kpco-consent-in {
	from {
		opacity: 0;
		transform: translateY(12px);
	}
}

/* Settings link under the footer (same strip as the legal line of the company facts) -------------------------------- */

.kpco-consent-footer {
	padding: 0 15px;
	background-color: var(--brand-color-2, #2b2b2b);
	color: rgba(255, 255, 255, 0.88);
	font-size: 0.8rem;
	line-height: 1.5;
	text-align: center;
}

.kpco-consent-footer a {
	display: inline-block;
	padding: 13px 2px;
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.kpco-consent-footer a:hover {
	color: #fff;
}

.kpco-consent-footer a:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

/* Cookie table ------------------------------------------------------------------------------------------------------ */

.kpco-cookie-table {
	margin: 0 0 1.5em;
	overflow-x: auto;
}

.kpco-cookie-table:focus-visible {
	outline: 2px solid var(--fs-color-primary, #265359);
	outline-offset: 2px;
}

.kpco-cookie-table table {
	width: 100%;
	min-width: 640px;
	margin: 0;
	border-collapse: collapse;
	font-size: 0.9rem;
}

.kpco-cookie-table th,
.kpco-cookie-table td {
	padding: 10px 12px 10px 0;
	border-bottom: 1px solid rgba(0, 0, 0, 0.14);
	letter-spacing: 0;
	line-height: 1.45;
	text-align: left;
	text-transform: none;
	vertical-align: top;
}

.kpco-cookie-table tbody th {
	max-width: 15em;
	font-weight: inherit;
	overflow-wrap: anywhere;
}
