/* ==========================================================================
   Resekartan Popup
   Own stacking context. z-index 50 sits under the sticky section nav (95).
   Not a native HTML popover — that layer ignores z-index.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Trigger
   -------------------------------------------------------------------------- */

.rk-src {
	display: inline-block;
	line-height: 0;
	vertical-align: middle;
	transform: translateY(-0.14em);
}

.rk-popup-block {
	display: inline;
}

.rk-src__btn {
	-webkit-appearance: none;
	appearance: none;
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: calc(1em + var(--rk-src-bump, 0px));
	height: calc(1em + var(--rk-src-bump, 0px));
	margin: 0 0 0 0.15em;
	padding: 0;
	vertical-align: middle;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	opacity: 0.55;
	cursor: pointer;
	transition: opacity 0.15s ease, background-color 0.15s ease, transform 0.12s ease;
}

/* Keeps the visual dot small while giving it a ~28px touch target. */
.rk-src__btn::after {
	content: "";
	position: absolute;
	inset: -8px;
}

.rk-src__btn:hover,
.rk-src__btn:focus-visible {
	opacity: 1;
	background: color-mix(in srgb, currentColor 15%, transparent);
}

.rk-src__btn:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.rk-src__btn:active {
	transform: scale(0.9);
}

.rk-src__icon {
	display: block;
	width: 100%;
	height: 100%;
}

/* --------------------------------------------------------------------------
   2. Card
   Reset inherited type from gold labels / dark sections.
   z-index 50: under .rk-navbar (95). Fixed so it is not trapped in a card.
   ========================================================================== */

.rk-src__pop {
	--rk-pop-bg: #fefcf8;
	--rk-pop-ink: #1b1d1b;
	--rk-pop-muted: #6b655d;
	--rk-pop-accent: var(--gold, #c08c2c);
	--rk-pop-line: rgba(27, 29, 27, 0.14);

	box-sizing: border-box;
	display: none;
	position: fixed;
	z-index: 50;
	inset: auto;
	top: 50%;
	left: 50%;
	translate: -50% -50%;
	margin: 0;
	width: min(340px, calc(100vw - 2rem));
	height: fit-content;
	max-height: min(38.7vh, 290px, calc(100dvh - 1.5rem));
	overflow: hidden;
	overscroll-behavior: contain;

	padding: 0.85rem 0.95rem 0.9rem;
	border: 1px solid var(--rk-pop-line);
	border-radius: 14px;
	background: var(--rk-pop-bg);
	color: var(--rk-pop-ink);
	box-shadow: 0 18px 44px rgba(21, 35, 31, 0.22), 0 2px 6px rgba(21, 35, 31, 0.1);

	font-family: inherit;
	font-size: 0.82rem;
	font-style: normal;
	font-weight: 400;
	line-height: 1.55;
	letter-spacing: normal;
	text-align: left;
	text-indent: 0;
	text-transform: none;
	white-space: normal;
	word-break: normal;
}

.rk-src__pop.is-open {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.rk-src__head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	flex: 0 0 auto;
	gap: 0.6rem;
	background: var(--rk-pop-bg);
}

.rk-src__kicker {
	color: var(--rk-pop-accent);
	font-size: 0.62rem;
	font-weight: 800;
	letter-spacing: 0.12em;
	line-height: 1.5;
	text-transform: uppercase;
}

.rk-src__close {
	-webkit-appearance: none;
	appearance: none;
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	margin: -4px -4px 0 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--rk-pop-muted);
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.rk-src__close:hover,
.rk-src__close:focus-visible {
	background: color-mix(in srgb, currentColor 14%, transparent);
	color: var(--rk-pop-ink);
}

.rk-src__close:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 1px;
}

.rk-src__body {
	display: block;
	flex: 1 1 auto;
	min-height: 0;
	/* Reserve a real track so classic + overlay scrollbars never cover the text. */
	padding-right: 1rem;
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-gutter: stable;
	scrollbar-width: thin;
}

.rk-src__body::-webkit-scrollbar {
	width: 10px;
}

.rk-src__body::-webkit-scrollbar-thumb {
	background: color-mix(in srgb, var(--rk-pop-muted) 45%, transparent);
	border-radius: 999px;
	border: 2px solid transparent;
	background-clip: padding-box;
}

.rk-src__body::-webkit-scrollbar-track {
	background: transparent;
}

.rk-src__title {
	display: block;
	font-weight: 600;
}

.rk-src__publisher {
	display: block;
	color: var(--rk-pop-muted);
	font-size: 0.78rem;
}

.rk-src__note {
	display: block;
	margin-top: 0.35rem;
	color: var(--rk-pop-muted);
}

.rk-src__meta {
	display: block;
	flex: 0 0 auto;
	padding-top: 0.5rem;
	border-top: 1px solid var(--rk-pop-line);
	color: var(--rk-pop-muted);
	font-size: 0.72rem;
}

.rk-src__pop a {
	color: var(--rk-pop-accent);
	text-decoration: underline;
	text-underline-offset: 2px;
	overflow-wrap: anywhere;
}

.rk-src__pop a:hover {
	text-decoration-thickness: 2px;
}

/* --------------------------------------------------------------------------
   4. Phones: bottom sheet. Same z-index 50 — the nav stays on top.
   -------------------------------------------------------------------------- */

@media (max-width: 640px) {
	.rk-src__pop {
		position: fixed;
		inset: auto 0 0 0;
		top: auto;
		left: auto;
		translate: none;
		margin: 0;
		width: 100%;
		max-width: none;
		max-height: min(46vh, calc(100dvh - 1.5rem));
		padding-bottom: calc(0.9rem + env(safe-area-inset-bottom, 0px));
		border-width: 1px 0 0 0;
		border-radius: 16px 16px 0 0;
		font-size: 0.88rem;
	}

	.rk-src__close {
		width: 30px;
		height: 30px;
	}
}

/* --------------------------------------------------------------------------
   6. Fact box — same 3-column cards as the original Gutenberg layout
   -------------------------------------------------------------------------- */

.wp-block-rk-faktaruta.rk-facts {
	display: block;
	column-count: 3;
	column-gap: 14px;
	margin-block: 0;
	margin-inline: auto;
	max-width: 1180px;
	width: 100%;
	box-sizing: border-box;
}

.rk-facts {
	display: block;
	column-count: 3;
	column-gap: 14px;
	margin: 0 auto;
	padding: 0;
	max-width: 1180px;
	width: 100%;
	box-sizing: border-box;
}

.rk-facts__item {
	display: flex;
	flex-direction: column;
	gap: 3px;
	box-sizing: border-box;
	margin: 0 0 14px;
	padding: 12px 14px;
	break-inside: avoid;
	border: 1px solid #ffffff24;
	border-radius: 11px;
	background: #ffffff0d;
}

.rk-facts__label,
.rk-facts__value {
	display: block;
	float: none;
	width: auto;
	margin: 0;
	margin-inline-start: 0;
	padding: 0;
}

.rk-facts__label {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	color: #c08c2c;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.12em;
	line-height: 1.2;
	text-transform: uppercase;
}

.rk-facts__value {
	color: #f4efea;
	font-size: 0.9rem;
	font-weight: 400;
	letter-spacing: normal;
	line-height: 1.4;
	text-transform: none;
}

.rk-facts__value time {
	border: 0;
	text-decoration: none;
	color: inherit;
}

/* Blockklassen och .rk-facts matchar båda, så brytpunkterna måste upprepa
   den dubbla klassen. Annars vinner column-count:3 ovan på specificitet. */
@media (max-width: 1024px) {
	.wp-block-rk-faktaruta.rk-facts,
	.rk-facts {
		column-count: 2;
	}
}

@media (max-width: 781px) {
	.wp-block-rk-faktaruta.rk-facts,
	.rk-facts {
		column-count: 1;
	}
}

@media (max-width: 600px) {
	.rk-facts {
		column-count: 1;
	}
}

/* Sources should survive a print-out, where nothing is clickable. */
@media print {
	.rk-src__btn,
	.rk-src__close {
		display: none;
	}

	.rk-src__pop,
	.rk-src__pop[hidden] {
		display: block !important;
		position: static;
		width: auto;
		height: auto;
		max-height: none;
		overflow: visible;
		margin: 0.25rem 0 0;
		padding: 0;
		border: 0;
		box-shadow: none;
		opacity: 1;
		font-size: 0.7rem;
	}

	.rk-src__body {
		overflow: visible;
	}
}
