/*
 * OIT Translate Sync – Sprachauswahl „Decrypt“
 * Sprachwechsel als Entschlüsselung: Vorschau der echten Überschrift,
 * Scanlinie über die Seite, Text setzt sich in der neuen Sprache zusammen.
 *
 * Farben im Theme anpassen:
 *   .oit-decrypt { --od-accent: #…; }
 */

.oit-decrypt {
	--od-ink: #000;
	--od-paper: #fff;
	--od-accent: #e40fd9;
	--od-muted: rgba(255, 255, 255, .55);
	--od-line: rgba(255, 255, 255, .14);
	--od-ease: cubic-bezier(.3, .7, .2, 1);

	position: relative;
	display: inline-flex;
	vertical-align: middle;
	z-index: 99990;
	font-family: inherit;
}

.oit-decrypt[data-position="float"] {
	position: fixed;
	right: 20px;
	bottom: calc(var(--od-bottom, 20px) + env(safe-area-inset-bottom, 0px));
}

.oit-decrypt[data-position="float"][data-corner="bl"] {
	right: auto;
	left: 20px;
}

/* Automatisch platziert: bis das Script die Stelle gefunden hat, unsichtbar */
.oit-decrypt.is-unplaced {
	display: none !important;
}

.oit-decrypt[data-position="auto"] {
	flex: none;
	width: auto;
	margin: 0;
}

/* Desktop: als letzter Eintrag in der Menüliste */
.oit-decrypt-item {
	display: flex;
	align-items: center;
	margin: 0;
	padding: 0 0 0 8px;
	list-style: none;
}

.oit-decrypt-item::before,
.oit-decrypt-item::after {
	display: none !important;
}

/* Handy: absolut neben dem Hamburger, ohne den Header umzubauen */
.oit-decrypt[data-position="auto"].is-beside-toggle {
	position: absolute;
	z-index: 20;
}

/* ---------- Auslöser ---------- */

.oit-decrypt .oit-decrypt__trigger {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 36px;
	min-height: 0;
	margin: 0;
	padding: 0 12px 0 8px;
	border: 0;
	border-radius: 999px;
	background: var(--od-ink);
	color: var(--od-paper);
	font: inherit;
	font-size: 14px;
	font-weight: 500;
	line-height: 1;
	letter-spacing: 0;
	text-transform: none;
	box-shadow: none;
	cursor: pointer;
	transition: box-shadow .2s ease;
	-webkit-tap-highlight-color: transparent;
}

.oit-decrypt[data-position="float"] .oit-decrypt__trigger {
	height: 44px;
	padding: 0 16px 0 10px;
	font-size: 15px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
}

.oit-decrypt .oit-decrypt__trigger:hover,
.oit-decrypt.is-open .oit-decrypt__trigger {
	background: var(--od-ink);
	color: var(--od-paper);
	box-shadow: 0 0 0 3px rgba(228, 15, 217, .3);
}

.oit-decrypt .oit-decrypt__trigger:focus-visible {
	outline: 2px solid var(--od-accent);
	outline-offset: 3px;
}

/* Kompakt: nur Flagge, fügt sich wie ein Menüpunkt ein */
.oit-decrypt[data-size="compact"] .oit-decrypt__trigger {
	gap: 5px;
	height: 40px;
	padding: 0 8px;
	background: transparent;
	color: var(--od-trigger-color, currentColor);
}

.oit-decrypt[data-size="compact"] .oit-decrypt__trigger:hover,
.oit-decrypt[data-size="compact"].is-open .oit-decrypt__trigger {
	background: rgba(128, 128, 128, .2);
	color: var(--od-trigger-color, currentColor);
	box-shadow: none;
}

.oit-decrypt[data-size="compact"] .oit-decrypt__label {
	display: none;
}

.oit-decrypt[data-size="compact"] .oit-decrypt__trigger .oit-decrypt__flag {
	width: 24px;
	height: 24px;
	box-shadow: 0 0 0 1px rgba(128, 128, 128, .35);
}

/* Flaggen rund, mit feinem Rand gegen helle Flaggen auf Schwarz */
.oit-decrypt .oit-decrypt__flag {
	display: block;
	flex: none;
	width: 20px;
	height: 20px;
	margin: 0;
	border-radius: 50%;
	object-fit: cover;
	box-shadow: 0 0 0 1px rgba(255, 255, 255, .22);
}

.oit-decrypt[data-position="float"] .oit-decrypt__trigger .oit-decrypt__flag {
	width: 24px;
	height: 24px;
}

.oit-decrypt__label {
	display: inline-block;
	white-space: nowrap;
}

.oit-decrypt__caret {
	transition: transform .3s var(--od-ease);
}

.oit-decrypt.is-open .oit-decrypt__caret {
	transform: rotate(180deg);
}

.oit-decrypt[data-position="float"] .oit-decrypt__caret {
	transform: rotate(180deg);
}

.oit-decrypt[data-position="float"].is-open .oit-decrypt__caret {
	transform: rotate(0deg);
}

/* ---------- Panel ---------- */

.oit-decrypt .oit-decrypt__panel {
	position: fixed;
	top: var(--od-top, 0px);
	left: var(--od-left, 0px);
	z-index: 99991;
	box-sizing: border-box;
	width: min(320px, calc(100vw - 24px));
	padding: 20px 8px 8px;
	border-radius: 16px;
	background: var(--od-ink);
	color: var(--od-paper);
	box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
	visibility: hidden;
	clip-path: inset(0 0 100% 0 round 16px);
	transition: clip-path .34s var(--od-ease), visibility 0s linear .34s;
}

.oit-decrypt .oit-decrypt__panel[data-dir="up"] {
	clip-path: inset(100% 0 0 0 round 16px);
}

.oit-decrypt.is-open .oit-decrypt__panel {
	visibility: visible;
	clip-path: inset(0 0 0 0 round 16px);
	transition: clip-path .34s var(--od-ease), visibility 0s linear 0s;
}

/* Scanlinie an der Öffnungskante */
.oit-decrypt .oit-decrypt__panel::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	height: 2px;
	background: var(--od-accent);
	box-shadow: 0 0 14px 1px var(--od-accent);
	opacity: 0;
	pointer-events: none;
}

.oit-decrypt.is-open .oit-decrypt__panel::after {
	animation: od-panel-scan-down .34s var(--od-ease) forwards;
}

.oit-decrypt.is-open .oit-decrypt__panel[data-dir="up"]::after {
	animation-name: od-panel-scan-up;
}

@keyframes od-panel-scan-down {
	0%   { top: 0; opacity: 1; }
	85%  { opacity: 1; }
	100% { top: calc(100% - 2px); opacity: 0; }
}

@keyframes od-panel-scan-up {
	0%   { top: calc(100% - 2px); opacity: 1; }
	85%  { opacity: 1; }
	100% { top: 0; opacity: 0; }
}

/* Vorschau: echte Überschrift der Seite in der gewählten Sprache */
.oit-decrypt .oit-decrypt__preview {
	display: -webkit-box;
	min-height: 2.5em;
	margin: 0 12px 14px;
	padding: 0;
	overflow: hidden;
	color: var(--od-paper);
	font-size: 20px;
	font-weight: 600;
	line-height: 1.25;
	letter-spacing: -.01em;
	overflow-wrap: anywhere;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

/* ---------- Sprachliste ---------- */

.oit-decrypt .oit-decrypt__list {
	max-height: min(50vh, 360px);
	margin: 0;
	padding: 6px 0 0;
	overflow-y: auto;
	border-top: 1px solid var(--od-line);
	list-style: none;
	overscroll-behavior: contain;
}

.oit-decrypt .oit-decrypt__list li {
	margin: 0;
	padding: 0;
	list-style: none;
}

.oit-decrypt .oit-decrypt__lang {
	position: relative;
	isolation: isolate;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 12px;
	overflow: hidden;
	border-radius: 10px;
	color: var(--od-paper);
	font-size: 15px;
	font-weight: 500;
	line-height: 1.2;
	text-decoration: none;
}

/* Magenta-Balken schiebt sich unter die Zeile */
.oit-decrypt .oit-decrypt__lang::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	border-radius: inherit;
	background: var(--od-accent);
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform .24s var(--od-ease);
}

.oit-decrypt .oit-decrypt__lang:hover,
.oit-decrypt .oit-decrypt__lang:focus-visible {
	color: var(--od-paper);
	outline: none;
}

.oit-decrypt .oit-decrypt__lang:hover::before,
.oit-decrypt .oit-decrypt__lang:focus-visible::before {
	transform: scaleX(1);
}

.oit-decrypt .oit-decrypt__lang:focus-visible {
	box-shadow: inset 0 0 0 2px var(--od-paper);
}

.oit-decrypt__name {
	flex: 1;
}

/* Aktuelle Sprache: Punkt am rechten Rand */
.oit-decrypt .oit-decrypt__lang.is-current::after {
	content: "";
	flex: none;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--od-accent);
}

.oit-decrypt .oit-decrypt__lang.is-current:hover::after,
.oit-decrypt .oit-decrypt__lang.is-current:focus-visible::after {
	background: var(--od-paper);
}

/* ---------- Scanlinie über die ganze Seite ---------- */

.oit-decrypt-scan {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 2147483000;
	height: 2px;
	background: #e40fd9;
	background: var(--od-scan, #e40fd9);
	box-shadow: 0 0 18px 2px var(--od-scan, #e40fd9), 0 0 70px 10px rgba(228, 15, 217, .3);
	pointer-events: none;
	transform: translateY(-10px);
	will-change: transform;
	transition: opacity .35s ease;
}

.oit-decrypt-scan::before {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: 2px;
	height: 90px;
	background: linear-gradient(to bottom, rgba(228, 15, 217, 0), rgba(228, 15, 217, .07));
}

.oit-decrypt-scan.is-done {
	opacity: 0;
}

/* ---------- Mobil: Panel als Blatt am unteren Rand ---------- */

@media (max-width: 599px) {
	.oit-decrypt .oit-decrypt__panel {
		left: 12px;
		right: 12px;
		width: auto;
	}

	.oit-decrypt .oit-decrypt__panel[data-dir="up"] {
		top: auto;
		bottom: calc(12px + env(safe-area-inset-bottom, 0px));
	}
}

/* ---------- Ohne JavaScript ---------- */

.oit-decrypt:not(.is-ready):focus-within .oit-decrypt__panel {
	position: absolute;
	top: calc(100% + 10px);
	right: 0;
	left: auto;
	visibility: visible;
	clip-path: none;
}

.oit-decrypt:not(.is-ready) .oit-decrypt__preview {
	display: none;
}

/* ---------- Weniger Bewegung ---------- */

@media (prefers-reduced-motion: reduce) {
	.oit-decrypt *,
	.oit-decrypt *::before,
	.oit-decrypt *::after {
		animation: none !important;
		transition-duration: .01ms !important;
		transition-delay: 0s !important;
	}
}
