/**
 * Kartta.
 *
 * Korkeus tulee CSS-muuttujista, jotta sama merkintä toimii sekä työpöydällä
 * että mobiilissa ilman erillistä media queryä itse komponentissa.
 */

.kp-map {
	position: relative;
	width: 100%;
	max-width: 100%;
	border-radius: var(--kp-map-radius, 14px);
	overflow: hidden;
	background: #eef1f3;
	isolation: isolate;
}

/* ---------------- Latauspainike ---------------- */

.kp-map__trigger {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	width: 100%;
	height: var(--kp-map-h, 320px);
	margin: 0;
	padding: 20px;
	border: 0;
	border-radius: 0;
	color: #1d2327;
	text-align: center;
	cursor: pointer;
	/* Kevyt karttamainen ruudukko, ei kuvatiedostoa. */
	background-color: #eef1f3;
	background-image:
		linear-gradient(rgba(23, 187, 33, .10) 1px, transparent 1px),
		linear-gradient(90deg, rgba(23, 187, 33, .10) 1px, transparent 1px),
		radial-gradient(circle at 50% 45%, rgba(255, 211, 79, .28), transparent 55%);
	background-size: 34px 34px, 34px 34px, 100% 100%;
	transition: background-color .2s ease;
}

.kp-map__trigger:hover,
.kp-map__trigger:focus {
	background-color: #e7ecef;
	color: #1d2327;
}

.kp-map__trigger:focus-visible {
	outline: 3px solid #17BB21;
	outline-offset: -3px;
}

.kp-map__pin {
	color: #17BB21;
	line-height: 0;
	transition: transform .2s ease;
}

.kp-map__trigger:hover .kp-map__pin {
	transform: translateY(-2px);
}

.kp-map__label {
	font-size: 16px;
	font-weight: 600;
	letter-spacing: .01em;
}

.kp-map__addr {
	display: block;
	margin: 0;
	font-size: 14px;
	color: #3c434a;
}

.kp-map__hint {
	display: block;
	max-width: 34ch;
	font-size: 12px;
	line-height: 1.45;
	color: #646970;
}

/* ---------------- Iframe ---------------- */

.kp-map__iframe {
	display: block;
	width: 100%;
	height: var(--kp-map-h, 320px);
	border: 0;
	background: #eef1f3;
}

/* ---------------- Kehys ja kosketuslinkki ---------------- */

.kp-map__canvas {
	position: relative;
	display: block;
	width: 100%;
}

.kp-map__hit {
	position: absolute;
	inset: 0;
	z-index: 3;
	display: none;
	align-items: flex-end;
	justify-content: flex-end;
	padding: 12px;
	text-decoration: none;
	-webkit-tap-highlight-color: transparent;
}

.kp-map__hit-badge {
	padding: 8px 14px;
	border-radius: 999px;
	background: #ffd34f;
	color: #1d2327;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
	box-shadow: 0 2px 6px rgba(0, 0, 0, .22);
}

/*
 * Kosketusnäytöllä napautus ei mene karttaupotukselle vaan avaa paikan
 * karttasovelluksessa. Vieritys toimii normaalisti, koska linkki aktivoituu
 * vasta napautuksesta.
 *
 * Kaksi ehtoa:
 *  1) media query — tavallinen kännykkäselain,
 *  2) .kp-map--touch — JS lisää luokan, koska "työpöytäversio" -tilassa
 *     kännykkä ilmoittaa hover:hover ja pointer:fine, jolloin media query ei
 *     osu ja iframe jäisi vastaanottamaan napautukset.
 */
@media (hover: none), (pointer: coarse) {
	.kp-map__hit {
		display: flex;
	}

	.kp-map__canvas > .kp-map__iframe {
		pointer-events: none;
	}

	/* Erillinen nappi on turha, koska koko kartta on linkki. */
	.kp-map > .kp-map__open {
		display: none;
	}
}

.kp-map--touch .kp-map__hit {
	display: flex;
}

.kp-map--touch .kp-map__canvas > .kp-map__iframe {
	pointer-events: none;
}

.kp-map--touch > .kp-map__open {
	display: none;
}

/* ---------------- Linkki karttasovellukseen ---------------- */

.kp-map__open,
.kp-map__link {
	display: inline-block;
	padding: 9px 16px;
	border-radius: 999px;
	background: #ffd34f;
	color: #1d2327 !important;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none !important;
	box-shadow: 0 2px 6px rgba(0, 0, 0, .16);
	transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.kp-map__open {
	position: absolute;
	right: 14px;
	bottom: 14px;
	z-index: 2;
}

.kp-map__open:hover,
.kp-map__open:focus,
.kp-map__link:hover,
.kp-map__link:focus {
	background: #ffe27a;
	color: #1d2327 !important;
	transform: translateY(-1px);
	box-shadow: 0 4px 10px rgba(0, 0, 0, .22);
}

.kp-map__open:focus-visible,
.kp-map__link:focus-visible {
	outline: 2px solid #1d2327;
	outline-offset: 2px;
}

/* ---------------- Kartta asettelusarakkeessa ---------------- */

/*
 * Kun kartta on elementtialueen sarakkeessa, se täyttää sarakkeen jäljellä
 * olevan korkeuden ja ulottuu reunasta reunaan. Theme käyttää taulukkoasettelua
 * (display: table / table-cell), jossa prosenttikorkeudet eivät periydy, joten
 * juuri tämän elementtialueen kohdalla siirrytään flex-asetteluun. Silloin
 * kartta kasvaa myös silloin, kun viereinen kysymys avataan.
 */
.edgtf-elements-holder:has(.kp-map) {
	display: flex;
	flex-wrap: wrap;
	align-items: stretch;
}

.edgtf-elements-holder:has(.kp-map) > .edgtf-eh-item {
	display: flex;
	flex-direction: column;
	height: auto;
	min-width: 0;
}

.edgtf-elements-holder:has(.kp-map) > .edgtf-eh-item > .edgtf-eh-item-inner {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0;
}

.edgtf-eh-item-content:has(> .kp-map) {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	height: auto;
	min-height: 0;
}

/* Reunaton lohko: ei pyöristyksiä eikä varjoa. */
.edgtf-eh-item-content > .kp-map {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: var(--kp-map-h, 320px);
	border-radius: 0;
	box-shadow: none;
}

.edgtf-eh-item-content > .kp-map > .kp-map__trigger,
.edgtf-eh-item-content > .kp-map > .kp-map__iframe,
.edgtf-eh-item-content > .kp-map > .kp-map__fallback {
	flex: 1 1 auto;
	height: auto;
	min-height: var(--kp-map-h, 320px);
}

.edgtf-eh-item-content > .kp-map > .kp-map__canvas {
	display: flex;
	flex: 1 1 auto;
	min-height: 0;
}

.edgtf-eh-item-content > .kp-map > .kp-map__canvas > .kp-map__iframe {
	flex: 1 1 auto;
	height: auto;
	min-height: var(--kp-map-h, 320px);
}

/* ---------------- Varakehys, jos osoite ei tuota karttaa ---------------- */

.kp-map__fallback {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	height: var(--kp-map-h, 320px);
	padding: 20px;
	text-align: center;
	background: #eef1f3;
}

/* ---------------- Mobiili ---------------- */

@media (max-width: 782px) {
	.kp-map__trigger,
	.kp-map__iframe,
	.kp-map__fallback {
		height: var(--kp-map-h-m, 220px);
	}

	.kp-map__label {
		font-size: 15px;
	}

	.kp-map__hint {
		display: none;
	}

	.kp-map__open {
		right: 10px;
		bottom: 10px;
		padding: 8px 14px;
		font-size: 13px;
	}
}

/* ---------------- Liikkeen vähentäminen ---------------- */

@media (prefers-reduced-motion: reduce) {
	.kp-map__trigger,
	.kp-map__pin,
	.kp-map__open,
	.kp-map__link {
		transition: none;
	}

	.kp-map__trigger:hover .kp-map__pin {
		transform: none;
	}
}
