/**
 * Topic Preview - Zeina
 *
 * Mirrors Zeina's cards and dropdowns: soft 12px corners, an 8px spacing
 * scale, subtle borders, and the style's configurable primary colour.
 */

:root {
	--tp-bg: #ffffff;
	--tp-border: #e5e7eb;
	--tp-divider: #f3f4f6;
	--tp-text: #334155;
	--tp-muted: #64748b;
	--tp-section-bg: rgba(var(--color-primary), 0.08);
	--tp-section-text: rgba(var(--color-text), 1);
	--tp-scrollbar-track: #f8fafc;
	--tp-scrollbar-thumb: #cbd5e1;
	--tp-scrollbar-hover: #94a3b8;
	--tp-avatar-bg: rgba(var(--color-primary), 0.14);
	--tp-avatar-icon: rgba(var(--color-primary), 0.7);
}

.topic_preview_container {
	box-sizing: border-box;
	font-family: inherit;
	font-size: 0.875rem;
	line-height: 1.5rem;
	font-style: normal;
	text-decoration: none;
	background-color: var(--tp-bg);
	border: 1px solid var(--tp-border);
	border-radius: 0.75rem;
	box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
	color: var(--tp-text);
	position: absolute;
	z-index: 20;
	display: none;
	min-width: 40px;
	margin-left: -40px;
	padding: 0.5rem;
}

.topic_preview_container * {
	max-width: 100%;
	height: auto;
	pointer-events: none;
}

.topic_preview_container.invert:before {
	/* Upper Triangle */
	background-color: var(--tp-bg);
	border: 0;
	border-top: 1px solid var(--tp-border);
	border-right: 1px solid var(--tp-border);
	position: absolute;
	display: block;
	width: 10px;
	height: 10px;
	margin-top: -14px;
	margin-left: 10px;
	content: "";
	transform: rotate(-45deg);
}

.topic_preview_container:after {
	/* Lower Triangle */
	background-color: var(--tp-bg);
	border: 0;
	border-bottom: 1px solid var(--tp-border);
	border-left: 1px solid var(--tp-border);
	position: absolute;
	top: 100%;
	display: block;
	width: 10px;
	height: 10px;
	margin-top: -5px;
	margin-left: 10px;
	content: "";
	transform: rotate(-45deg);
}

.topic_preview_container.invert:after {
	/* Hide lower triangle when inverted */
	display: none;
	content: "";
}

.rtl .topic_preview_container:after,
.rtl .topic_preview_container.invert:before,
[dir="rtl"] .topic_preview_container:after,
[dir="rtl"] .topic_preview_container.invert:before {
	margin-right: 10px;
	margin-left: auto;
}

/* Avatars and Text */
.topic_preview_avatar {
	position: relative;
	flex-shrink: 0;
	width: 3rem;
	height: 3rem;
	border-radius: 0.5rem;
	overflow: hidden;
	background-color: var(--tp-avatar-bg);
}

.topic_preview_avatar img {
	border: 0;
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	object-fit: cover;
}

.topic_preview_avatar .avatar-placeholder {
	height: 100%;
}

.topic_preview_post {
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
}

.topic_preview_post.rtl {
	flex-direction: row-reverse;
}

.topic_preview_first,
.topic_preview_last {
	word-wrap: break-word;
	overflow-wrap: anywhere;
	overflow: hidden;
	flex: 1;
	min-width: 0;
}

.topic_preview_first a,
.topic_preview_last a {
	color: var(--tp-section-text);
	text-decoration: underline;
	text-decoration-color: rgba(var(--color-primary), 0.35);
	text-underline-offset: 2px;
}

/* Restore post-content list indentation removed by phpBB's base reset. */
.topic_preview_first ul,
.topic_preview_first ol,
.topic_preview_last ul,
.topic_preview_last ol {
	margin: 0.8em 0 0.9em 3em;
}

.topic_preview_first li,
.topic_preview_last li {
	display: list-item;
	list-style-type: inherit;
}

.rtl .topic_preview_first ul,
.rtl .topic_preview_first ol,
.rtl .topic_preview_last ul,
.rtl .topic_preview_last ol {
	margin: 0.8em 3em 0.9em 0;
}

.topic_preview_scrollable {
	overflow-x: hidden;
	overflow-y: auto;
	max-height: 400px;
	padding: 0.25rem;
	padding-inline-end: 0.5rem;
	pointer-events: auto;
}

.topic_preview_scrollable::-webkit-scrollbar {
	width: 0.375rem;
}

.topic_preview_scrollable::-webkit-scrollbar-track {
	background: var(--tp-scrollbar-track);
	border-radius: 9999px;
}

.topic_preview_scrollable::-webkit-scrollbar-thumb {
	background: var(--tp-scrollbar-thumb);
	border-radius: 9999px;
}

.topic_preview_scrollable::-webkit-scrollbar-thumb:hover {
	background: var(--tp-scrollbar-hover);
}

.topic_preview_section:not(:first-child) {
	border-top: 1px solid var(--tp-divider);
	margin-top: 0.75rem;
	padding-top: 0.75rem;
}

.topic_preview_section:last-child {
	padding-bottom: 0.25rem;
}

.topic_preview_section_title {
	display: inline-flex;
	align-items: center;
	border-radius: 9999px;
	background-color: var(--tp-section-bg);
	color: var(--tp-section-text);
	margin-bottom: 0.5rem;
	padding: 0.125rem 0.5rem;
	font-size: 0.75rem;
	line-height: 1rem;
	font-weight: 600;
}

/* Pure CSS no-avatar */
.topic_preview_no_avatar {
	background: var(--tp-avatar-bg);
	position: relative;
	overflow: hidden;
	width: 100%;
	height: 100%;
}

/* Pure CSS no-avatar body */
.topic_preview_no_avatar:before {
	background: var(--tp-bg);
	border-radius: 100%;
	position: absolute;
	bottom: 0;
	left: 50%;
	width: 80%;
	height: 80%;
	margin: 0 0 -35% -40%;
	content: "";
}

/* Pure CSS no-avatar head */
.topic_preview_no_avatar:after {
	border-radius: 50%;
	background: var(--tp-bg);
	box-shadow: 0 0 0 3px var(--tp-avatar-icon);
	position: absolute;
	top: 10%;
	left: 50%;
	width: 50%;
	height: 50%;
	margin: 0 0 0 -25%;
	content: "";
}

/* responsive design */
@media only screen and (max-width: 550px), only screen and (max-device-width: 550px) {
	.topic_preview_container {
		max-width: 300px;
	}
}

@media only screen and (max-width: 360px), only screen and (max-device-width: 360px) {
	.topic_preview_container {
		max-width: 220px;
	}
}
