/**
 * MoSeven + · Show Chat
 *
 * Messenger-Verlauf in einem CSS-Smartphone. Die Bühne bleibt über die Scrollstrecke
 * fixiert (sticky), das Skript blendet pro Schritt die nächste Nachricht ein.
 */

.msp-sc {
	/* Maße (über Elementor-Controls überschreibbar) */
	--msp-sc-w: 360px;
	--msp-sc-top: 0px;
	--msp-sc-step: 320px;
	--msp-sc-hold: 0px;
	--msp-sc-count: 1;
	--msp-sc-bezel: 11px;
	--msp-sc-radius: 50px;
	--msp-sc-frame: #1b1b1d;
	--msp-sc-edge: #3a3a3e;
	--msp-sc-stage-h: calc(100vh - var(--msp-sc-top));

	/* Farbschema Hell */
	--msp-sc-bg: #efeae2;
	--msp-sc-bar: #ffffff;
	--msp-sc-bar-text: #111b21;
	--msp-sc-a-bg: #d9fdd3;
	--msp-sc-a-text: #111b21;
	--msp-sc-b-bg: #ffffff;
	--msp-sc-b-text: #111b21;
	--msp-sc-meta: #667781;
	--msp-sc-read: #53bdeb;
	--msp-sc-accent: #25d366;
	--msp-sc-field: #ffffff;
	--msp-sc-line: rgba(11, 20, 26, 0.08);
	--msp-sc-home: rgba(17, 27, 33, 0.85);

	position: relative;
	height: calc(var(--msp-sc-stage-h) + (var(--msp-sc-count) - 1) * var(--msp-sc-step) + var(--msp-sc-hold));
}

@supports (height: 100svh) {
	.msp-sc {
		/* Kleinste Fensterhöhe: Das Smartphone passt auch bei eingeblendeter Adressleiste. */
		--msp-sc-stage-h: calc(100svh - var(--msp-sc-top));
	}
}

.msp-sc--dark {
	--msp-sc-bg: #0b141a;
	--msp-sc-bar: #1f2c34;
	--msp-sc-bar-text: #e9edef;
	--msp-sc-a-bg: #005c4b;
	--msp-sc-a-text: #e9edef;
	--msp-sc-b-bg: #202c33;
	--msp-sc-b-text: #e9edef;
	--msp-sc-meta: #8696a0;
	--msp-sc-read: #53bdeb;
	--msp-sc-accent: #00a884;
	--msp-sc-field: #2a3942;
	--msp-sc-line: rgba(255, 255, 255, 0.06);
	--msp-sc-home: rgba(233, 237, 239, 0.8);
}

/* ------------------------------------------------------------------- Bühne */

.msp-sc__stage {
	position: sticky;
	top: var(--msp-sc-top);
	height: var(--msp-sc-stage-h);
	display: grid;
	align-items: center;
	justify-items: center;
	box-sizing: border-box;
	padding: 24px 0;
}

/* Ersatz, falls ein übergeordnetes Element position: sticky verhindert. */
.msp-sc.is-pin-fallback .msp-sc__stage {
	position: relative;
	top: 0;
	will-change: transform;
}

/* --------------------------------------------------------------- Smartphone */

.msp-sc__phone {
	position: relative;
	box-sizing: border-box;
	/* Breite wie eingestellt, aber nie höher als der sichtbare Bereich. */
	width: min(var(--msp-sc-w), calc((var(--msp-sc-stage-h) - 48px) / 2.05), 100%);
	aspect-ratio: 1 / 2.05;
	padding: var(--msp-sc-bezel);
	border-radius: var(--msp-sc-radius);
	background: var(--msp-sc-frame);
	box-shadow:
		0 0 0 1.5px var(--msp-sc-edge),
		inset 0 0 0 1px rgba(255, 255, 255, 0.07);
	container-type: inline-size;
}

.msp-sc.has-shadow .msp-sc__phone {
	box-shadow:
		0 0 0 1.5px var(--msp-sc-edge),
		inset 0 0 0 1px rgba(255, 255, 255, 0.07),
		0 40px 70px -30px rgba(0, 0, 0, 0.45),
		0 18px 36px -18px rgba(0, 0, 0, 0.3);
}

/* Seitentasten */
.msp-sc__key {
	position: absolute;
	width: 3px;
	border-radius: 2px;
	background: var(--msp-sc-edge);
}

.msp-sc__key--a,
.msp-sc__key--b {
	left: -4px;
	border-radius: 2px 0 0 2px;
}

.msp-sc__key--a {
	top: 19%;
	height: 7%;
}

.msp-sc__key--b {
	top: 28%;
	height: 7%;
}

.msp-sc__key--c {
	right: -4px;
	top: 23%;
	height: 11%;
	border-radius: 0 2px 2px 0;
}

/* Bildschirm: alle Maße in em, die Grundgröße wächst mit der Breite des Smartphones. */
.msp-sc__screen {
	position: relative;
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
	border-radius: max(0px, calc(var(--msp-sc-radius) - var(--msp-sc-bezel)));
	background: var(--msp-sc-bg);
	color: var(--msp-sc-b-text);
	font-size: 15px;
	font-size: 4.45cqw;
	line-height: 1.35;
	text-align: left;
	-webkit-font-smoothing: antialiased;
}

.msp-sc__icon {
	display: block;
	flex: none;
	width: 1.4em;
	height: 1.4em;
}

/* Statusleiste */
.msp-sc__statusbar {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex: none;
	height: 2.75em;
	padding: 0.35em 1.7em 0;
	box-sizing: border-box;
	background: var(--msp-sc-bar);
	color: var(--msp-sc-bar-text);
	font-size: 0.8em;
	font-weight: 600;
	letter-spacing: 0.01em;
}

.msp-sc__camera {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 0.95em;
	height: 0.95em;
	margin: -0.3em 0 0 -0.475em;
	border-radius: 50%;
	background: #050506;
	box-shadow: inset 0 0 0 0.18em #17171a;
}

.msp-sc__sys {
	display: flex;
	align-items: center;
	gap: 0.35em;
}

.msp-sc__sys .msp-sc__icon {
	height: 0.85em;
	width: auto;
}

.msp-sc__sys .msp-sc__icon--signal {
	width: 1.3em;
}

.msp-sc__sys .msp-sc__icon--wifi {
	width: 1.15em;
}

.msp-sc__sys .msp-sc__icon--battery {
	width: 1.85em;
}

/* Chat-Kopf */
.msp-sc__header {
	display: flex;
	align-items: center;
	gap: 0.55em;
	flex: none;
	padding: 0.3em 0.75em 0.6em 0.4em;
	background: var(--msp-sc-bar);
	color: var(--msp-sc-bar-text);
	border-bottom: 1px solid var(--msp-sc-line);
}

.msp-sc__back .msp-sc__icon {
	width: 1.5em;
	height: 1.5em;
}

.msp-sc__avatar {
	flex: none;
	width: 2.4em;
	height: 2.4em;
	margin: 0 0 0 -0.35em;
	border-radius: 50%;
	object-fit: cover;
}

.msp-sc__avatar--initial {
	display: grid;
	place-items: center;
	background: color-mix(in srgb, var(--msp-sc-meta) 25%, var(--msp-sc-bar));
	color: var(--msp-sc-bar-text);
	font-weight: 600;
	font-size: 1em;
}

.msp-sc__who {
	display: flex;
	flex: 1;
	flex-direction: column;
	min-width: 0;
}

.msp-sc__name {
	overflow: hidden;
	font-size: 1em;
	font-weight: 600;
	line-height: 1.25;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.msp-sc__status {
	overflow: hidden;
	color: var(--msp-sc-meta);
	font-size: 0.76em;
	line-height: 1.3;
	white-space: nowrap;
	text-overflow: ellipsis;
	transition: color 0.2s ease;
}

.msp-sc__status.is-typing {
	color: var(--msp-sc-accent);
}

.msp-sc__actions {
	display: flex;
	gap: 1.05em;
	margin-right: 0.35em;
}

.msp-sc__actions .msp-sc__icon,
.msp-sc__more .msp-sc__icon {
	width: 1.35em;
	height: 1.35em;
}

/* Verlauf */
.msp-sc__body {
	position: relative;
	flex: 1;
	min-height: 0;
	overflow: hidden;
	background-color: var(--msp-sc-bg);
	background-repeat: repeat;
	background-position: center top;
}

.msp-sc__list {
	display: flex;
	flex-direction: column;
	gap: 0.18em;
	margin: 0;
	padding: 0.75em 0.7em;
	list-style: none;
	transition: transform 0.45s cubic-bezier(0.22, 0.8, 0.3, 1);
	will-change: transform;
}

.msp-sc__msg {
	display: flex;
	margin: 0;
	padding: 0;
}

.msp-sc__msg::before,
.msp-sc__msg::marker {
	content: none;
}

.msp-sc__msg--a {
	justify-content: flex-end;
}

.msp-sc__msg.is-first:not(:first-child) {
	margin-top: 0.5em;
}

.msp-sc__bubble {
	position: relative;
	display: block;
	box-sizing: border-box;
	max-width: 82%;
	padding: 0.4em 0.55em 0.3em 0.6em;
	border-radius: 0.6em;
	background: var(--msp-sc-b-bg);
	color: var(--msp-sc-b-text);
	box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
	overflow-wrap: anywhere;
}

.msp-sc__msg--a .msp-sc__bubble {
	background: var(--msp-sc-a-bg);
	color: var(--msp-sc-a-text);
}

/* Sprechblasen-Zipfel an der ersten Nachricht einer Folge */
.msp-sc__msg.is-first .msp-sc__bubble::before {
	content: "";
	position: absolute;
	top: 0;
	width: 0.55em;
	height: 0.75em;
	background: inherit;
}

.msp-sc__msg--b.is-first .msp-sc__bubble {
	border-top-left-radius: 0;
}

.msp-sc__msg--b.is-first .msp-sc__bubble::before {
	left: -0.5em;
	clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.msp-sc__msg--a.is-first .msp-sc__bubble {
	border-top-right-radius: 0;
}

.msp-sc__msg--a.is-first .msp-sc__bubble::before {
	right: -0.5em;
	clip-path: polygon(0 0, 100% 0, 0 100%);
}

.msp-sc__text {
	font-size: 0.93em;
	line-height: 1.38;
}

/* Uhrzeit und Haken stehen rechts unten, der Text fließt daneben. */
.msp-sc__meta {
	position: relative;
	top: 0.35em;
	float: right;
	display: inline-flex;
	align-items: center;
	gap: 0.2em;
	margin: 0.15em 0 0 0.75em;
	color: var(--msp-sc-meta);
	font-size: 0.68em;
	line-height: 1.6;
	white-space: nowrap;
}

.msp-sc--dark .msp-sc__msg--a .msp-sc__meta {
	color: rgba(233, 237, 239, 0.6);
}

.msp-sc__ticks {
	display: inline-flex;
}

.msp-sc__ticks .msp-sc__icon {
	width: 1.45em;
	height: 1em;
}

.msp-sc__ticks--read {
	color: var(--msp-sc-read);
}

/* Tipp-Anzeige (drei Punkte) */
.msp-sc__typing {
	display: none;
	align-self: flex-start;
	gap: 0.28em;
	margin: 0.5em 0 0;
	padding: 0.75em 0.85em;
	border-radius: 0.6em;
	border-top-left-radius: 0;
	background: var(--msp-sc-b-bg);
	box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
	animation: msp-sc-in 0.3s cubic-bezier(0.22, 0.8, 0.3, 1) both;
	transform-origin: 0 100%;
}

.msp-sc__typing::marker {
	content: none;
}

.msp-sc__typing span {
	display: block;
	width: 0.48em;
	height: 0.48em;
	border-radius: 50%;
	background: var(--msp-sc-meta);
	animation: msp-sc-dot 1.2s ease-in-out infinite;
}

.msp-sc__typing span:nth-child(2) {
	animation-delay: 0.15s;
}

.msp-sc__typing span:nth-child(3) {
	animation-delay: 0.3s;
}

.msp-sc__list.is-typing .msp-sc__typing {
	display: flex;
}

.msp-sc__typing.is-a {
	align-self: flex-end;
	border-top-left-radius: 0.6em;
	border-top-right-radius: 0;
	background: var(--msp-sc-a-bg);
	transform-origin: 100% 100%;
}

/* Fußleiste */
.msp-sc__footer {
	display: flex;
	align-items: center;
	gap: 0.4em;
	flex: none;
	padding: 0.4em 0.5em 1.45em;
	background: var(--msp-sc-bg);
}

.msp-sc__field {
	display: flex;
	flex: 1;
	align-items: center;
	gap: 0.6em;
	min-width: 0;
	height: 2.65em;
	padding: 0 0.75em;
	border-radius: 1.4em;
	background: var(--msp-sc-field);
	color: var(--msp-sc-meta);
	box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.1);
}

.msp-sc__field .msp-sc__icon {
	width: 1.35em;
	height: 1.35em;
}

.msp-sc__placeholder {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	font-size: 0.93em;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.msp-sc__mic {
	display: grid;
	place-items: center;
	flex: none;
	width: 2.65em;
	height: 2.65em;
	border-radius: 50%;
	background: var(--msp-sc-accent);
	color: #fff;
}

.msp-sc__mic .msp-sc__icon {
	width: 1.3em;
	height: 1.3em;
}

.msp-sc__home {
	position: absolute;
	bottom: 0.45em;
	left: 50%;
	width: 36%;
	height: 0.3em;
	border-radius: 0.3em;
	background: var(--msp-sc-home);
	transform: translateX(-50%);
}

/* ------------------------------------------------------------ Einblenden */

/* Erst wenn das Skript läuft, werden Nachrichten ausgeblendet (ohne Skript bleibt der Verlauf lesbar). */
.msp-sc.is-ready .msp-sc__msg:not(.is-shown) {
	display: none;
}

.msp-sc.is-ready .msp-sc__msg.is-shown.is-new {
	animation: msp-sc-in 0.38s cubic-bezier(0.22, 0.8, 0.3, 1) both;
}

.msp-sc__msg--b {
	transform-origin: 0 100%;
}

.msp-sc__msg--a {
	transform-origin: 100% 100%;
}

@keyframes msp-sc-in {
	from {
		opacity: 0;
		transform: translateY(0.9em) scale(0.92);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes msp-sc-dot {
	0%,
	60%,
	100% {
		opacity: 0.45;
		transform: translateY(0);
	}

	30% {
		opacity: 1;
		transform: translateY(-0.28em);
	}
}

/* ------------------------------------- Ganzer Verlauf (Editor, weniger Bewegung) */

.msp-sc.is-preview-all,
.msp-sc.is-static {
	height: auto;
}

.msp-sc.is-preview-all .msp-sc__stage,
.msp-sc.is-static .msp-sc__stage {
	position: relative;
	top: 0;
	height: auto;
	transform: none !important;
}

.msp-sc.is-preview-all .msp-sc__phone,
.msp-sc.is-static .msp-sc__phone {
	width: min(var(--msp-sc-w), 100%);
	aspect-ratio: auto;
	min-height: calc(min(var(--msp-sc-w), 100%) * 2.05);
}

.msp-sc.is-preview-all .msp-sc__screen,
.msp-sc.is-static .msp-sc__screen {
	min-height: calc(min(var(--msp-sc-w), 100%) * 2.05 - 2 * var(--msp-sc-bezel));
}

.msp-sc.is-preview-all .msp-sc__list,
.msp-sc.is-static .msp-sc__list {
	transform: none !important;
}

@media (prefers-reduced-motion: reduce) {
	.msp-sc__list {
		transition: none;
	}

	.msp-sc__typing,
	.msp-sc__typing span,
	.msp-sc.is-ready .msp-sc__msg.is-shown.is-new {
		animation: none;
	}
}
