/* Kinskofer Glossar-Tooltips
 * Farben und Schrift kommen als CSS-Variablen aus Divi (siehe includes/frontend.php).
 */

/* ---------- Markierter Begriff ---------- */
.khgt .khgt__trigger {
	cursor: pointer;
	color: inherit;
	font-style: italic;
	text-decoration-line: underline;
	text-decoration-style: solid;
	text-decoration-color: currentColor; /* Farbe des umgebenden Textes */
	text-decoration-thickness: 2px;
	text-underline-offset: 0.2em;
	text-decoration-skip-ink: auto;
	border-radius: 2px;
	-webkit-tap-highlight-color: transparent;
}

.khgt .khgt__trigger:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.khgt .khgt__trigger[aria-expanded="true"] {
	text-decoration-thickness: 3px;
}

/* Nur für angemeldete Redakteure: Eintrag fehlt oder ist nicht veröffentlicht */
.khgt-missing {
	text-decoration: underline dashed #d63638 2px;
	text-underline-offset: 0.2em;
}

/* ---------- Tooltip ---------- */
.khgt .khgt__pop {
	/* Popover-Standardwerte des Browsers zurücksetzen */
	position: fixed;
	inset: auto;
	top: 0;
	left: 0;
	margin: 0;
	overflow: visible;

	display: none;
	box-sizing: border-box;
	width: max-content;
	max-width: min(800px, calc(100vw - 16px));
	padding: 12px 16px;
	z-index: 100000; /* nur relevant ohne Popover-Unterstützung */

	background: var(--khgt-bg);
	color: var(--khgt-text);
	border: 1px solid rgba(0, 0, 0, 0.12);
	border-radius: 4px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);

	font-family: var(--khgt-font);
	font-size: var(--khgt-size);
	line-height: var(--khgt-lh);
	font-weight: 400;
	font-style: normal;
	letter-spacing: normal;
	text-transform: none;
	text-align: left;
	text-decoration: none;
	text-shadow: none;
	white-space: normal;
	overflow-wrap: break-word;
	hyphens: auto;
	cursor: auto;
}

.khgt .khgt__pop.is-open {
	display: block;
	animation: khgt-in 0.12s ease-out;
}

.khgt .khgt__pop.is-pinned {
	padding-right: 40px;
}

/* Pfeil */
.khgt .khgt__pop::before {
	content: "";
	position: absolute;
	left: calc(var(--khgt-arrow-x, 50%) - 6px);
	width: 12px;
	height: 12px;
	background: var(--khgt-bg);
	border: 1px solid rgba(0, 0, 0, 0.12);
	transform: rotate(45deg);
}

.khgt .khgt__pop[data-placement="top"]::before {
	bottom: -7px;
	border-top: 0;
	border-left: 0;
}

.khgt .khgt__pop[data-placement="bottom"]::before {
	top: -7px;
	border-right: 0;
	border-bottom: 0;
}

.khgt .khgt__body {
	display: block;
	position: relative; /* über dem Pfeil */
}

.khgt .khgt__body a {
	color: var(--khgt-accent);
	text-decoration: underline;
}

.khgt .khgt__body strong,
.khgt .khgt__body b {
	font-weight: 700;
}

/* Schließen-Button: sichtbar nach Klick/Tap/Tastatur, nicht beim reinen Hover */
.khgt .khgt__close {
	display: none;
	position: absolute;
	top: 4px;
	right: 4px;
	width: 32px;
	height: 32px;
	min-width: 0;
	margin: 0;
	padding: 0;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: 0;
	border-radius: 4px;
	box-shadow: none;
	color: var(--khgt-text);
	font: inherit;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}

.khgt .khgt__pop.is-pinned .khgt__close {
	display: flex;
}

.khgt .khgt__close:hover {
	background: rgba(0, 0, 0, 0.06);
}

.khgt .khgt__close:focus-visible {
	outline: 2px solid var(--khgt-accent);
	outline-offset: 0;
}

/* Mobil (Divi-Breakpoint): höchstens 85 % der Bildschirmbreite */
@media (max-width: 767px) {
	.khgt .khgt__pop {
		max-width: 85vw;
	}
}

@keyframes khgt-in {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.khgt .khgt__pop.is-open {
		animation: none;
	}
}

@media (forced-colors: active) {
	.khgt .khgt__pop {
		border: 1px solid CanvasText;
	}
}
