/* =====================================================================
   Modern Post View — Stil von WoltLab Suite 6.3 fuer WBB 6.2
   ---------------------------------------------------------------------
   Nachbau der neuen Beitragsliste aus 6.3 (messageListView) auf dem
   UNVERAENDERTEN 6.2-Markup. Geladen per {modernPostAssets} nur auf der
   Themen-Seite, wenn „Beitrags-Ansicht: Stil von WoltLab Suite 6.3“
   gewaehlt ist. Ergaenzt durch js/Amp/ModernThreadList/PostView.js
   (Kacheln, Federsymbol, Trennlinie „Neue Beiträge“, Aktionsmenue).

   Anpassbar im individuellen CSS des Stils, z. B.:
       .wbbThreadPostList { --mtl-best: #2e7d32; --mtl-sidebar: 240px; }
   ===================================================================== */

.wbbThreadPostList,
#messageQuickReply {
	--mtl-pad: 20px;
	--mtl-radius: 8px;
	--mtl-sidebar: 220px;
	--mtl-avatar: 96px;
	--mtl-sticky-top: 70px;
	--mtl-border: var(--wcfContentBorderInner);
	--mtl-sidebar-bg: var(--wcfContentBackground);
	--mtl-main-bg: var(--wcfContentContainerBackground, var(--wcfContentBackground));
	--mtl-starter: var(--wcfButtonPrimaryBackground);
	--mtl-starter-text: var(--wcfButtonPrimaryText);
	--mtl-online: rgba(0, 153, 0, 1);
	--mtl-best: var(--wcfStatusSuccessBorder, #4caf50);
	--mtl-official: var(--wcfStatusInfoBorder, #2779bd);
	--mtl-tint: color-mix(in srgb, var(--wcfContentText) 5%, transparent);
	--mtl-tint-strong: color-mix(in srgb, var(--wcfContentText) 9%, transparent);
	--mtl-note-scheduled: #6f42c1;
	--mtl-note-disabled: #a1a1aa;
	--mtl-note-deleted: rgba(204, 0, 0, 1);
	--mtl-note-edited: color-mix(in srgb, var(--wcfContentText) 35%, transparent);
}

html[data-color-scheme="dark"] .wbbThreadPostList {
	--mtl-note-scheduled: #673ab7;
	--mtl-note-disabled: #52525b;
	--mtl-note-deleted: #c1183d;
}

/* ---- Liste: Karten mit Abstand statt Trennlinien ---- */
.wbbThreadPostList.messageList:not(.messageReducedList) {
	border-top-width: 0;
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.wbbThreadPostList.messageList:not(.messageReducedList) > li {
	border-bottom-width: 0;
	padding: 0;
}

.wbbThreadPostList.messageList > li.messageListPagination {
	margin: 0;
	padding: 0;
	border-top-width: 0;
}

/* ---- Karte ---- */
.wbbThreadPostList > li > .message:not(.messageReduced),
#messageQuickReply > .message {
	background-color: var(--mtl-main-bg);
	border: 1px solid var(--mtl-border);
	border-radius: var(--mtl-radius);
}

/* Inline-Editor, Ladeoverlay: Ecken mitnehmen */
.wbbThreadPostList > li > .message .messageContent.loading > .messageContentLoadingOverlay {
	border-radius: var(--mtl-radius);
}

.wbbThreadPostList .messageContent,
#messageQuickReply .messageContent {
	min-width: 0;
	padding: var(--mtl-pad);
}

/* ---- Autoren-Sidebar: Teil der Karte, dezente Trennlinie ---- */
.wbbThreadPostList .messageSidebar,
#messageQuickReply .messageSidebar {
	background-color: transparent;
	border: 0;
	border-radius: 0;
	color: var(--wcfContentText);
}

.wbbThreadPostList .messageSidebar a,
#messageQuickReply .messageSidebar a {
	color: var(--wcfContentLink);
}

.wbbThreadPostList .messageSidebar a:hover,
#messageQuickReply .messageSidebar a:hover {
	color: var(--wcfContentLinkActive);
}

.wbbThreadPostList .messageSidebar .userAvatar img,
#messageQuickReply .messageSidebar .userAvatar img {
	border-radius: 50%;
	display: block;
	height: var(--mtl-avatar);
	width: var(--mtl-avatar);
}

/* Online: gruener Punkt am Avatar statt Badge */
.wbbThreadPostList .messageSidebar .badgeOnline {
	background-color: var(--mtl-online);
	border: 3px solid var(--mtl-sidebar-bg);
	border-radius: 50%;
	bottom: 4px;
	color: transparent;
	font-size: 0;
	height: 18px;
	left: auto;
	line-height: 0;
	overflow: hidden;
	padding: 0;
	right: 4px;
	top: auto;
	width: 18px;
}

.wbbThreadPostList .messageSidebar .badgeOnline::before {
	display: none;
}

/* Themenersteller: farbiger Ring + Federsymbol */
.wbbThreadPostList > li.messageGroupStarter .messageSidebar .userAvatar img {
	box-shadow:
		0 0 0 3px var(--mtl-sidebar-bg),
		0 0 0 6px var(--mtl-starter);
}

.wbbThreadPostList .mtlStarterIcon {
	align-items: center;
	background-color: var(--mtl-starter);
	border: 3px solid var(--mtl-sidebar-bg);
	border-radius: 50%;
	bottom: 0;
	color: var(--mtl-starter-text);
	display: flex;
	height: 32px;
	justify-content: center;
	left: 0;
	position: absolute;
	width: 32px;
}

.wbbThreadPostList .mtlStarterInline {
	color: var(--mtl-starter);
	display: none;
	margin-left: 4px;
}

/* Rang-Text als Badge bleibt, Rangbild/Trophaeen kompakt */
.wbbThreadPostList .messageSidebar .userTitle {
	margin-top: 4px;
}

.wbbThreadPostList .messageSidebar .userRank img {
	max-width: 100%;
}

.wbbThreadPostList .messageSidebar .specialTrophyContainer ul {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	justify-content: center;
}

/* Kennzahlen als Kacheln in zwei Spalten, Profilfelder untereinander */
.wbbThreadPostList .messageSidebar .userCredits {
	margin-top: 16px;
}

.wbbThreadPostList .messageSidebar dl.mtlCredits {
	display: grid;
	gap: 4px;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	text-align: center;
}

/* dl.dataList hat ein Clearfix (::before/::after mit content) - im Grid waeren
   das eigene Zellen, ::before belegte die erste Kachel-Position. */
.wbbThreadPostList .messageSidebar dl.mtlCredits::before,
.wbbThreadPostList .messageSidebar dl.mtlCredits::after {
	content: none;
	display: none;
}

.wbbThreadPostList dl.mtlCredits > .mtlStat {
	background-color: var(--mtl-tint);
	border-radius: var(--wcfBorderRadius);
	display: flex;
	flex-direction: column;
	gap: 3px;
	line-height: 1;
	padding: 6px 4px 5px;
}

.wbbThreadPostList dl.mtlCredits > .mtlStat:hover {
	background-color: var(--mtl-tint-strong);
}

.wbbThreadPostList dl.mtlCredits > .mtlStat--wide,
.wbbThreadPostList dl.mtlCredits > .mtlUserOption {
	grid-column: 1 / -1;
}

.wbbThreadPostList dl.mtlCredits dt,
.wbbThreadPostList dl.mtlCredits dd {
	float: none;
	margin: 0;
	overflow: hidden;
	padding: 0;
	text-align: inherit;
	text-overflow: ellipsis;
	white-space: nowrap;
	width: auto;
}

.wbbThreadPostList dl.mtlCredits > .mtlStat > dt,
.wbbThreadPostList dl.mtlCredits > .mtlStat > dt a {
	color: var(--wcfContentDimmedText);
	font-size: var(--wcfFontSizeSmall);
}

/* Wert ueber dem Schluessel; das Markup behaelt den Schluessel vorne (Screenreader) */
.wbbThreadPostList dl.mtlCredits > .mtlStat > dd {
	color: var(--wcfContentText);
	font-variant-numeric: tabular-nums;
	font-weight: 600;
	order: -1;
}

.wbbThreadPostList dl.mtlCredits > .mtlUserOption {
	display: flex;
	flex-direction: column;
	margin-top: 6px;
	overflow-wrap: anywhere;
	text-align: left;
}

.wbbThreadPostList dl.mtlCredits > .mtlUserOption > dt {
	color: var(--wcfContentDimmedText);
}

.wbbThreadPostList dl.mtlCredits > .mtlUserOption > dd {
	white-space: normal;
}

/* ---- Kopf, Text, Fuss ---- */
.wbbThreadPostList .messageHeader + .messageBody {
	margin-top: 16px;
}

.wbbThreadPostList .messageText {
	line-height: 1.6;
}

/* Abstand gleichmaessig, Buttons einzeln statt Button-Gruppe */
.wbbThreadPostList .messageFooterGroup {
	align-items: center;
	gap: 4px;
}

.wbbThreadPostList .messageFooterButtons,
.wbbThreadPostList .messageFooterButtonsExtra {
	gap: 4px;
}

.wbbThreadPostList .messageFooterButtons > li > .button,
.wbbThreadPostList .messageFooterButtonsExtra > li > .button {
	border-radius: var(--wcfBorderRadius) !important;
}

.wbbThreadPostList .messageFooterGroup > .messageFooterButtonsExtra + .messageFooterButtons > li:first-child {
	margin-left: 0;
}

/* gruppierte Aktionen: Originale bleiben im DOM (Mobilmenue liest sie) */
@media (min-width: 769px) {
	.wbbThreadPostList .mtlActionsGrouped .mtlProxiedAction {
		display: none !important;
	}

	.wbbThreadPostList .mtlActionsGrouped > .messageFooterButtonsExtra {
		display: none;
	}

	.wbbThreadPostList .mtlActionsGrouped > .messageFooterButtons {
		flex: 1 1 auto;
	}
}

@media (max-width: 768px) {
	.wbbThreadPostList .mtlActionsToggleItem {
		display: none !important;
	}
}

.mtlActionsMenu > li > a {
	align-items: center;
	display: flex;
	gap: 8px;
}

.mtlActionsMenu > li.active > a {
	font-weight: 600;
}

/* ---- Hinweise als farbige Boxen ---- */
.wbbThreadPostList .messageFooterNotes:empty {
	display: none;
}

.wbbThreadPostList .messageFooterNote,
.wbbThreadPostList .mtlTopNotes > .messageFooterNote {
	background-color: var(--mtl-tint);
	border-left: 5px solid var(--mtl-note, var(--mtl-note-edited));
	border-radius: var(--wcfBorderRadius);
	color: var(--wcfContentDimmedText);
	margin-top: 6px;
	overflow-wrap: anywhere;
	padding: 8px 12px;
}

.wbbThreadPostList .messageFooterNotes > .messageFooterNote:first-child {
	margin-top: 16px;
}

.wbbThreadPostList .messageFooterNote a {
	color: inherit;
	font-weight: 600;
}

.wbbThreadPostList .messageFooterNote a:hover {
	text-decoration: underline;
}

.wbbThreadPostList .messageFooterNote.wbbPostDeleteNote {
	--mtl-note: var(--mtl-note-deleted);
}

.wbbThreadPostList .messageFooterNote.wbbPostDisabledNote,
.wbbThreadPostList .messageFooterNote.wbbPostDelayedNote {
	color: var(--wcfContentText);
}

.wbbThreadPostList .messageFooterNote.wbbPostDisabledNote {
	--mtl-note: var(--mtl-note-disabled);
}

.wbbThreadPostList .messageFooterNote.wbbPostDelayedNote {
	--mtl-note: var(--mtl-note-scheduled);
}

.wbbThreadPostList .mtlTopNotes {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-bottom: 16px;
}

.wbbThreadPostList .mtlTopNotes > .messageFooterNote:first-child {
	margin-top: 0;
}

/* ---- Badges: „Neu“ wird durch die Trennlinie ersetzt (nur mit JS) ---- */
.wbbThreadPostList.mtlPostView .messageStatus .newMessageBadge {
	display: none;
}

.wbbThreadPostList > li.mtlNewPostsSeparator {
	align-items: center;
	color: var(--wcfContentLink);
	display: flex;
	gap: 10px;
}

.wbbThreadPostList > li.mtlNewPostsSeparator::before,
.wbbThreadPostList > li.mtlNewPostsSeparator::after {
	border-top: 1px solid currentColor;
	content: "";
	flex: 1 1 auto;
}

.mtlNewPostsSeparator__label {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

/* ---- Hilfreichste Antwort / offizieller Beitrag: kraeftiger Rahmen ---- */
.wbbThreadPostList > li.wbbPostOfficial > .message {
	border-color: var(--mtl-official);
	box-shadow: 0 0 0 1px var(--mtl-official);
}

.wbbThreadPostList > li.wbbPostBestAnswer > .message {
	border-color: var(--mtl-best);
	box-shadow: 0 0 0 1px var(--mtl-best);
}

/* beim Anspringen (#postID) kurz hervorheben */
@keyframes mtlPostHighlight {
	0%,
	30% {
		box-shadow: 0 0 0 4px var(--mtl-highlight, var(--wcfButtonPrimaryBackground));
	}
	100% {
		box-shadow: 0 0 0 1px var(--mtl-highlight, transparent);
	}
}

.wbbThreadPostList > li:target > .message {
	animation: mtlPostHighlight 2s ease-out 0.2s both;
}

.wbbThreadPostList > li.wbbPostBestAnswer:target > .message {
	--mtl-highlight: var(--mtl-best);
}

.wbbThreadPostList > li.wbbPostOfficial:target > .message {
	--mtl-highlight: var(--mtl-official);
}

@media (prefers-reduced-motion: reduce) {
	.wbbThreadPostList > li:target > .message {
		animation: none;
	}
}

/* ---- Geloeschte Beitraege: eine kompakte Zeile ---- */
.wbbThreadPostList > li > .message.messageCollapsed {
	background-color: var(--mtl-main-bg);
	border-top: 1px solid var(--mtl-border);
	color: var(--wcfContentDimmedText);
	margin: 0;
}

.wbbThreadPostList > li > .message.messageCollapsed .messageContent {
	padding: 10px var(--mtl-pad);
}

/* ---- Moderationsprotokoll: Icon + Satz, am Beitragstext ausgerichtet ---- */
/* !important: WBB setzt hier 0,5,0-Selektoren (wbb.scss „modification log in threads“) */
.wbbThreadPostList.messageList:not(.messageReducedList) > li.modificationLogEntry {
	border-top-width: 0 !important;
	margin-left: 0 !important;
	margin-right: 0 !important;
	padding: 0 !important;
}

/* aufeinanderfolgende Eintraege enger zusammen */
.wbbThreadPostList.messageList > li.modificationLogEntry + li.modificationLogEntry {
	margin-top: -10px;
}
.wbbThreadPostList > li.modificationLogEntry > .message.messageReduced {
	background-color: transparent;
	border: 0;
}

.wbbThreadPostList > li.modificationLogEntry .messageContent {
	padding: 0 calc(1px + var(--mtl-pad));
}

.wbbThreadPostList > li.modificationLogEntry .messageHeader {
	align-items: center;
	background-color: transparent;
	color: var(--wcfContentDimmedText);
	margin: 0;
	padding: 0;
}

.wbbThreadPostList > li.modificationLogEntry .messageHeaderWrapper {
	align-items: center;
	display: flex;
	gap: 10px;
}

.wbbThreadPostList > li.modificationLogEntry .messageHeaderWrapper > :first-child,
.wbbThreadPostList > li.modificationLogEntry .messageHeaderWrapper > a:first-child img {
	border-radius: 50%;
	flex: 0 0 auto;
	height: 32px;
	width: 32px;
}

.wbbThreadPostList > li.modificationLogEntry .messageHeaderBox {
	align-items: baseline;
	column-gap: 10px;
	display: flex;
	flex-wrap: wrap;
	margin-left: 0;
	min-width: 0;
}

.wbbThreadPostList > li.modificationLogEntry .messageHeaderBox > div {
	color: var(--wcfContentText);
	order: 1;
	overflow-wrap: anywhere;
}

.wbbThreadPostList > li.modificationLogEntry .messageHeaderBox > .messageTitle {
	color: var(--wcfContentDimmedText);
	flex: 0 0 auto;
	font-size: var(--wcfFontSizeSmall);
	font-weight: 400;
	order: 2;
}

.wbbThreadPostList > li.modificationLogEntry .messageTitle a {
	color: inherit;
}

.wbbThreadPostList > li.modificationLogEntry .modificationLogEntryHide button {
	color: var(--wcfContentDimmedText);
}

/* =====================================================================
   Ab Tablet: Sidebar links in der Karte, Autor bleibt sticky
   Die Trennlinie wird als Hintergrund der Karte gezeichnet, damit die
   Sidebar selbst sticky sein kann (sie ist nur so hoch wie ihr Inhalt).
   ===================================================================== */
@media (min-width: 769px) {
	.wbbThreadPostList > li > .message:not(.messageReduced):not(.messageCollapsed),
	#messageQuickReply > .message {
		background-image: linear-gradient(
			to right,
			var(--mtl-sidebar-bg) 0,
			var(--mtl-sidebar-bg) var(--mtl-sidebar),
			var(--mtl-border) var(--mtl-sidebar),
			var(--mtl-border) calc(var(--mtl-sidebar) + 1px),
			transparent calc(var(--mtl-sidebar) + 1px)
		);
	}

	.wbbThreadPostList > li > .message.messageSidebarOrientationRight:not(.messageReduced):not(.messageCollapsed),
	#messageQuickReply > .message.messageSidebarOrientationRight {
		background-image: linear-gradient(
			to left,
			var(--mtl-sidebar-bg) 0,
			var(--mtl-sidebar-bg) var(--mtl-sidebar),
			var(--mtl-border) var(--mtl-sidebar),
			var(--mtl-border) calc(var(--mtl-sidebar) + 1px),
			transparent calc(var(--mtl-sidebar) + 1px)
		);
	}

	.wbbThreadPostList .messageSidebar,
	#messageQuickReply .messageSidebar {
		align-self: flex-start;
		box-sizing: border-box;
		flex: 0 0 calc(var(--mtl-sidebar) + 1px);
		padding: var(--mtl-pad);
		position: sticky;
		top: var(--mtl-sticky-top);
	}

	.wbbThreadPostList .messageSidebar + .messageContent,
	#messageQuickReply .messageSidebar + .messageContent,
	.wbbThreadPostList .messageSidebarOrientationRight .messageSidebar + .messageContent {
		flex-basis: auto;
		margin-left: 0;
		margin-right: 0;
		max-width: calc(100% - var(--mtl-sidebar) - 1px);
	}

	.wbbThreadPostList .messageSidebar .userAvatar {
		margin-bottom: 10px;
	}

	.wbbThreadPostList .messageSidebar .username {
		font-size: var(--wcfFontSizeDefault);
		font-weight: 600;
	}

	/* Moderationsprotokoll beginnt auf Hoehe des Beitragstexts */
	.wbbThreadPostList > li.modificationLogEntry .messageContent {
		padding-left: calc(1px + var(--mtl-sidebar) + var(--mtl-pad));
	}
}

/* =====================================================================
   Mobil: Autor als Zeile oben in der Karte, nur Avatar/Name/Rang
   ===================================================================== */
@media (max-width: 768px) {
	.wbbThreadPostList,
	#messageQuickReply {
		--mtl-pad: 10px;
		--mtl-avatar: 32px;
	}

	.wbbThreadPostList.messageList:not(.messageReducedList) > li:not(:last-child) {
		padding-bottom: 0;
	}

	.wbbThreadPostList .messageSidebar,
	#messageQuickReply .messageSidebar {
		border-bottom: 1px solid var(--mtl-border);
		border-radius: calc(var(--mtl-radius) - 1px) calc(var(--mtl-radius) - 1px) 0 0;
		margin: 0;
		padding: var(--mtl-pad);
		background-color: var(--mtl-sidebar-bg);
	}

	.wbbThreadPostList.messageList > li:first-child .messageSidebar {
		border-top-width: 0;
		border-radius: calc(var(--mtl-radius) - 1px) calc(var(--mtl-radius) - 1px) 0 0;
	}

	.wbbThreadPostList .messageSidebar + .messageContent {
		margin-top: 0;
	}

	.wbbThreadPostList .messageSidebar .messageAuthor {
		min-height: 32px;
	}

	.wbbThreadPostList .messageSidebar .messageAuthor .userAvatar .userAvatarImage,
	.wbbThreadPostList .messageSidebar .messageAuthor .userAvatar img {
		height: 32px;
		max-height: 32px;
		max-width: 32px;
		width: 32px;
	}

	.wbbThreadPostList .messageSidebar .messageAuthor .messageAuthorContainer,
	.wbbThreadPostList .messageSidebar .messageAuthor .userTitle,
	.wbbThreadPostList .messageSidebar .messageAuthor .userRank {
		margin-left: 42px;
	}

	.wbbThreadPostList .messageSidebar .badgeOnline {
		border-width: 2px;
		bottom: -2px;
		height: 12px;
		right: -2px;
		top: auto;
		width: 12px;
	}

	.wbbThreadPostList > li.messageGroupStarter .messageSidebar .userAvatar img {
		box-shadow:
			0 0 0 2px var(--mtl-sidebar-bg),
			0 0 0 4px var(--mtl-starter);
	}

	.wbbThreadPostList .mtlStarterIcon {
		display: none;
	}

	.wbbThreadPostList .mtlStarterInline {
		display: inline-flex;
	}

	/* die Zeile ueber dem Beitrag identifiziert nur den Autor */
	.wbbThreadPostList .messageSidebar .userCredits,
	.wbbThreadPostList .messageSidebar .userRank,
	.wbbThreadPostList .messageSidebar .specialTrophyContainer {
		display: none;
	}

	.wbbThreadPostList .messageText {
		font-size: 1rem;
		line-height: 1.65;
		overflow-wrap: anywhere;
	}

	.wbbThreadPostList > li > .message.messageCollapsed {
		border-top-width: 1px;
		padding: 0;
	}
}
