/* ==========================================================================
   Wayfinder – förhandsvisning / spelare (helskärm, touch)
   Liggande: lista till vänster. Stående: lista nedtill.
   ========================================================================== */

:root {
	--wf-pv-list: 340px;
	--wf-pv-logo: 96px;
	--wf-pv-bg: #ffffff;
	--wf-pv-fg: #1d1b19;
	--wf-pv-muted: #7a716a;
	--wf-pv-accent: #e8590c;
	--wf-pv-radius: 14px;
	--wf-pv-shadow: 0 4px 18px rgba(0, 0, 0, .14);
	--wf-ctrl-size: 56px;
}

* { box-sizing: border-box; }

html, body {
	height: 100%;
	margin: 0;
	overflow: hidden;
	background: #f4f1ee;
	color: var(--wf-pv-fg);
	font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	-webkit-user-select: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
	touch-action: none;
}

.wf-pv {
	position: fixed;
	inset: 0;
}

.wf-pv-map {
	position: absolute;
	inset: 0;
}

/* Lista ------------------------------------------------------------------ */

/* Menyn har egna färger (Inställningar → Färger). Standardvärdena är de som
   gällde innan inställningen fanns, så en karta utan egna val ser likadan ut. */
.wf-pv-list {
	position: absolute;
	z-index: 3;
	top: 16px;
	left: 16px;
	bottom: 16px;
	width: var(--wf-pv-list);
	display: flex;
	flex-direction: column;
	color: var(--wf-menu-text, var(--wf-pv-fg));
	background: var(--wf-menu, var(--wf-pv-bg));
	border-radius: var(--wf-pv-radius);
	box-shadow: var(--wf-pv-shadow);
	overflow: hidden;
}

/* Logotyp ovanför listan (Inställningar → Logotyp) */
.wf-pv-logo {
	position: absolute;
	z-index: 3;
	top: 16px;
	left: 16px;
	width: var(--wf-pv-list);
	height: var(--wf-pv-logo);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 10px 20px;
	background: var(--wf-pv-bg);
	border-radius: var(--wf-pv-radius);
	box-shadow: var(--wf-pv-shadow);
}

.wf-pv-logo img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}

/* Listan (och snabbvalen) flyttar ner respektive åt sidan för logotypen */
.wf-pv.has-logo .wf-pv-list {
	top: calc(32px + var(--wf-pv-logo));
}

.wf-pv.has-logo .wf-quick {
	left: calc(var(--wf-pv-list) + 32px);
}

/* Genomskinliga toner i stället för fasta ljusa färger: menyn kan vara mörk,
   och då ska sökrutan, snabbknapparna och planmärkena följa med. */
.wf-pv-search {
	margin: 16px 16px 10px;
	padding: 12px 14px;
	border: 1px solid rgba(128, 128, 128, .32);
	border-radius: 10px;
	font: inherit;
	color: inherit;
	background: rgba(128, 128, 128, .12);
	-webkit-user-select: text;
	user-select: text;
}

.wf-pv-scroll {
	flex: 1;
	overflow-y: auto;
	touch-action: pan-y;
	-webkit-overflow-scrolling: touch;
}

.wf-pv-items {
	margin: 0;
	padding: 0 8px 12px;
	list-style: none;
}

/* Kategorier */

.wf-pv-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 0 16px 10px;
}

.wf-pv-chip {
	min-height: 36px;
	padding: 6px 14px;
	border: 1px solid rgba(128, 128, 128, .32);
	border-radius: 18px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 14px;
	cursor: pointer;
}

/* Vald kategori får samma färg som vald butik – det är samma sorts val */
.wf-pv-chip.is-active {
	border-color: var(--wf-menu-active, var(--wf-pv-fg));
	background: var(--wf-menu-active, var(--wf-pv-fg));
	color: var(--wf-menu-active-text, #fff);
}

/* Hitta närmaste (platstyper) */

.wf-pv-nearest { padding: 0 16px 8px; }
.wf-pv-nearest[hidden] { display: none; }

.wf-pv-section {
	margin: 4px 0 8px;
	color: inherit;
	opacity: .65;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .05em;
	text-transform: uppercase;
}

.wf-pv-nearest-items {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
	gap: 8px;
}

.wf-pv-near {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	padding: 10px 6px;
	border: 1px solid rgba(128, 128, 128, .26);
	border-radius: 12px;
	background: rgba(128, 128, 128, .10);
	color: inherit;
	font: inherit;
	font-size: 13px;
	line-height: 1.2;
	text-align: center;
	cursor: pointer;
}

.wf-pv-near[hidden] { display: none; }

/* Platstypens namn ska rymmas i rutan. Svenska sammansättningar blir långa
 * ("Presentkortsmaskin"), så texten får flera rader, avstavas där språket
 * tillåter det och bryts mitt i ordet som sista utväg – annars rann den
 * utanför rutan. */
.wf-pv-near > span {
	display: block;
	width: 100%;
	min-width: 0;
	hyphens: auto;
	overflow-wrap: anywhere;
	word-break: normal;
}
.wf-pv-near:active { background: rgba(128, 128, 128, .22); }
.wf-pv-near .wf-place { width: 36px; height: 36px; }
.wf-pv-near .wf-place.is-logo { width: auto; height: 28px; }

.wf-pv-items li {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 52px;
	padding: 10px 12px;
	border-radius: 10px;
	cursor: pointer;
}

.wf-pv-items li[hidden] { display: none; }

.wf-pv-items li:active { background: rgba(128, 128, 128, .22); }

/* Vald butik – samma färg som lokalen får på kartan, om inget annat valts */
.wf-pv-items li.is-active,
.wf-pv-items li.is-active:active {
	background: var(--wf-menu-active, var(--wf-highlight, #f0b44c));
	color: var(--wf-menu-active-text, var(--wf-highlight-text, #fff));
}

.wf-pv-items li.is-active .wf-pv-item-level {
	background: rgba(255, 255, 255, .24);
	color: inherit;
	opacity: 1;
}

.wf-pv-item-name { flex: 1; }

.wf-pv-item-level {
	min-width: 32px;
	padding: 2px 8px;
	border-radius: 6px;
	background: rgba(128, 128, 128, .18);
	color: inherit;
	opacity: .8;
	font-size: 13px;
	font-weight: 600;
	text-align: center;
}

.wf-pv-item-level:empty { display: none; }

.wf-pv-empty {
	padding: 12px 20px;
	color: inherit;
	opacity: .7;
}

/* Ruttkort --------------------------------------------------------------- */

.wf-pv-card {
	position: absolute;
	z-index: 4;
	/* Snabbvalsraden sätter --wf-quick-h, så kortet hamnar under den */
	top: calc(16px + var(--wf-quick-h, 0px));
	right: 16px;
	width: min(420px, calc(100% - 32px));
	padding: 18px 20px;
	background: var(--wf-pv-bg);
	border-radius: var(--wf-pv-radius);
	box-shadow: var(--wf-pv-shadow);
}

.wf-pv-card[hidden] { display: none; }

.wf-pv-title {
	display: flex;
	align-items: center;
	gap: 10px;
	padding-right: 40px;
	font-size: 22px;
	font-weight: 700;
	line-height: 1.2;
}

.wf-pv-sub {
	margin-top: 2px;
	color: var(--wf-pv-muted);
}

/* Lokalens egen logotyp och beskrivning */
.wf-pv-card-logo {
	display: block;
	max-width: 160px;
	max-height: 64px;
	margin-top: 12px;
	object-fit: contain;
	object-position: left center;
}

.wf-pv-desc {
	margin-top: 10px;
	/* Långa texter ska inte trycka undan vägbeskrivningen */
	max-height: 11em;
	overflow-y: auto;
	line-height: 1.45;
}

.wf-pv-desc p { margin: 0 0 .6em; }
.wf-pv-desc p:last-child { margin-bottom: 0; }

.wf-pv-meta {
	margin-top: 10px;
	font-weight: 600;
	color: var(--wf-route, var(--wf-pv-accent));
}

.wf-pv-meta.is-error { color: #b42318; }

.wf-pv-close {
	position: absolute;
	top: 10px;
	right: 10px;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 50%;
	background: #f3efeb;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
}

.wf-pv-steps {
	margin: 12px 0 0;
	padding-left: 22px;
}

.wf-pv-steps li {
	padding: 6px 4px;
	color: var(--wf-pv-muted);
	cursor: pointer;
}

.wf-pv-steps li.is-active {
	color: var(--wf-pv-fg);
	font-weight: 600;
}

.wf-pv-toggle {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin-top: 12px;
	color: var(--wf-pv-muted);
	font-size: 14px;
}

.wf-pv-toggle input { width: 20px; height: 20px; }

.wf-pv-notice {
	position: absolute;
	z-index: 5;
	left: 50%;
	bottom: 24px;
	transform: translateX(-50%);
	max-width: calc(100% - 32px);
	padding: 12px 18px;
	border-radius: 10px;
	background: rgba(29, 27, 25, .88);
	color: #fff;
	font-size: 14px;
}

.wf-pv-notice[hidden] { display: none; }

/* Stående skärm: listan nedtill, kortet överst -------------------------------- */

@media (orientation: portrait) {

	.wf-pv-list {
		top: auto;
		right: 16px;
		width: auto;
		height: 36%;
	}

	.wf-pv.has-list .wf-controls { bottom: calc(36% + 32px); }

	.wf-pv-card {
		left: 16px;
		width: auto;
	}

}

/* Debug (?debug=1) -------------------------------------------------------- */

.wf-debug {
	position: absolute;
	z-index: 10;
	top: 8px;
	left: 50%;
	transform: translateX(-50%);
	max-width: min(720px, calc(100% - 16px));
	padding: 8px 10px;
	border-radius: 8px;
	background: rgba(0, 0, 0, .78);
	color: #d7ffd9;
	font: 12px/1.35 ui-monospace, Menlo, Consolas, monospace;
	pointer-events: auto;
}

.wf-debug table { border-collapse: collapse; }
.wf-debug th { padding: 1px 10px 1px 0; color: #9ad19d; font-weight: 400; text-align: left; white-space: nowrap; vertical-align: top; }
.wf-debug td { padding: 1px 0; word-break: break-word; }
.wf-debug.is-collapsed { padding: 4px 10px; }

.wf-debug-errors,
.wf-boot-errors {
	margin: 6px 0 0;
	white-space: pre-wrap;
	color: #ffb4a8;
	font: 12px/1.35 ui-monospace, Menlo, Consolas, monospace;
}

.wf-boot-errors {
	position: fixed;
	z-index: 20;
	left: 8px;
	right: 8px;
	bottom: 8px;
	max-height: 40%;
	overflow: auto;
	padding: 10px;
	border-radius: 8px;
	background: rgba(0, 0, 0, .85);
}

.wf-boot-errors[hidden] { display: none; }

/* Snabbval högst upp -------------------------------------------------------
   En knapp per utplacerad platstyp. De som inte får plats hamnar under
   "Visa mer". Raden ligger ovanpå kartan men släpper igenom klick vid sidan
   om knapparna (pointer-events). */

.wf-quick {
	position: absolute;
	z-index: 5;
	top: 16px;
	left: 16px;
	right: 16px;
	pointer-events: none;
}

.wf-pv.has-list .wf-quick {
	left: calc(var(--wf-pv-list) + 32px);
}

.wf-quick-row {
	display: flex;
	gap: 10px;
	overflow: hidden;
	white-space: nowrap;
}

.wf-quick-btn {
	display: inline-flex;
	align-items: center;
	gap: 12px;
	flex: 0 0 auto;
	padding: 12px 20px;
	border: 0;
	border-radius: 999px;
	background: var(--wf-pv-bg);
	color: var(--wf-pv-fg);
	box-shadow: var(--wf-pv-shadow);
	font: inherit;
	font-size: 19px;
	font-weight: 700;
	line-height: 1.1;
	white-space: nowrap;
	cursor: pointer;
	pointer-events: auto;
}

.wf-quick-btn[hidden] { display: none; }
.wf-quick-btn:active { transform: translateY(1px); }

/* Samma runda bricka som markörerna på kartan */
.wf-quick-btn .wf-place,
.wf-quick-item .wf-place {
	flex: 0 0 auto;
	width: 34px;
	height: 34px;
	box-shadow: none;
}

.wf-quick-btn .wf-place svg,
.wf-quick-item .wf-place svg {
	width: 20px;
	height: 20px;
}

/* En logotyp visas som den är: ingen bricka, filens egna proportioner och
   inget namn vid sidan – namnet står redan i bilden (se QuickPicks). */
.wf-quick-btn.is-logo,
.wf-quick-item.is-logo { padding: 8px 14px; }

.wf-quick-btn.is-logo .wf-place,
.wf-quick-item.is-logo .wf-place { width: auto; height: 26px; }

.wf-quick-btn.is-logo .wf-place svg,
.wf-quick-item.is-logo .wf-place svg { width: auto; height: 100%; }

/* "Visa mer" ------------------------------------------------------------- */

.wf-quick-more.is-open,
.wf-quick-more.has-active {
	background: #f7eef2;
}

.wf-quick-caret {
	width: 0;
	height: 0;
	border: 6px solid transparent;
	border-top-color: currentColor;
	margin-top: 4px;
	transition: transform .15s;
}

.wf-quick-more.is-open .wf-quick-caret {
	transform: rotate(180deg);
	margin-top: -4px;
}

.wf-quick-menu {
	position: absolute;
	z-index: 1;
	right: 0;
	top: calc(100% + 10px);
	min-width: 280px;
	max-height: min(60vh, 520px);
	overflow-y: auto;
	padding: 8px;
	border-radius: var(--wf-pv-radius);
	background: var(--wf-pv-bg);
	box-shadow: var(--wf-pv-shadow);
	pointer-events: auto;
}

.wf-quick-menu[hidden] { display: none; }

.wf-quick-item {
	display: flex;
	align-items: center;
	gap: 14px;
	width: 100%;
	padding: 14px 16px;
	border: 0;
	border-radius: 10px;
	background: transparent;
	color: var(--wf-pv-fg);
	font: inherit;
	font-size: 19px;
	font-weight: 700;
	text-align: left;
	cursor: pointer;
}

.wf-quick-item:active { background: #f3ece8; }

/* Stående skärm: listan ligger längst ner, så hela bredden är ledig –
   men finns en logotyp uppe till vänster ska raden börja efter den */
@media (orientation: portrait) {
	.wf-pv.has-list .wf-quick { left: 16px; }
	.wf-pv.has-logo .wf-quick { left: calc(var(--wf-pv-list) + 32px); }
}

/* Smal skärm: mindre knappar så att fler ryms */
@media (max-aspect-ratio: 3/4) {
	.wf-quick-btn, .wf-quick-item { font-size: 17px; padding: 8px 14px; }
	.wf-quick-btn .wf-place, .wf-quick-item .wf-place { width: 30px; height: 30px; }
}

/* Hovertext: vad är det man pekar på? ------------------------------------- */

.wf-pv-tip {
	position: absolute;
	z-index: 6;
	top: 0;
	left: 0;
	max-width: 280px;
	padding: 7px 11px;
	border-radius: 8px;
	background: rgba(29, 27, 25, .92);
	color: #fff;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.25;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	pointer-events: none;
}

.wf-pv-tip[hidden] { display: none; }

/* Mätruta för felsökning på mediaspelare (?stats=1) */
.wf-stats {
	position: absolute;
	left: 12px;
	bottom: 12px;
	z-index: 40;
	max-width: min(900px, 70vw);
	padding: 10px 14px;
	border-radius: 10px;
	background: rgba(18, 20, 24, .86);
	color: #eef1f5;
	font: 500 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	pointer-events: none;
}

.wf-stats-row {
	display: flex;
	gap: 10px;
}

.wf-stats-row span {
	flex: none;
	width: 108px;
	color: #9aa3b0;
}

.wf-stats-row b {
	min-width: 0;
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.wf-stats-row b.is-bad { color: #ff8585; }

.wf-stats-row b.is-soso { color: #ffd166; }

/* Profilerraderna (?profile=1) – egen avdelning under de fasta raderna */
.wf-stats-profile {
	margin-top: 6px;
	padding-top: 6px;
	border-top: 1px solid rgba(255, 255, 255, 0.25);
}

/* Etiketterna kommer tillbaka mjukt efter en kameraflytt */
.wf-pv .wf-markers { transition: opacity .18s ease-out; }

/* Under en dragning ska de bara bort, inte tona: en genomskinlighetsövergång
   över ett lager med sjuttio egna grafiklager är tung på en mediaspelare, och
   den skulle ligga precis där rörelsen ska börja. */
.wf-pv .wf-markers.is-direkt { transition: none; }
