/* ==========================================================================
   CAForum Topic Tiles 1.1 — styles apply only to the topic list in viewforum.

   Theming: override any of the --tt-* variables from your style, e.g.
     body.section-viewforum { --tt-accent: #c0392b; --tt-surface: #1e2329; }
   ========================================================================== */

body.section-viewforum {
	--tt-surface: #fff;
	--tt-text: #1f2933;
	--tt-muted: #66717d;
	--tt-border: rgba(15, 23, 42, .09);
	--tt-accent: #105289;            /* prosilver link blue */
	--tt-radius: 14px;
	--tt-gap: 20px;
	--tt-min-width: 300px;
	--tt-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 2px 8px rgba(15, 23, 42, .05);
	--tt-shadow-hover: 0 4px 10px rgba(15, 23, 42, .08), 0 14px 32px rgba(15, 23, 42, .12);
	--tt-sticky: #d97706;
	--tt-announce: #2563eb;
	--tt-global: #dc2626;
	--tt-new: #16a34a;
}

/* ---- Grid ---------------------------------------------------------------- */

body.section-viewforum .topiclist.topics {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--tt-min-width)), 1fr));
	gap: var(--tt-gap);
	margin: 18px 0 28px;
	padding: 0;
	background: transparent;
	border: 0;
}

body.section-viewforum .topiclist.topics > li.row {
	display: block;
	min-width: 0;
	margin: 0;
	padding: 0;
	background: transparent;
	border: 0;
}

body.section-viewforum .topiclist.topics > li.row > *:not(.topic-tile) {
	display: none !important;
}

/* ---- Card ---------------------------------------------------------------- */

.topic-tile,
.topic-tile *,
.topic-tile *::before,
.topic-tile *::after {
	box-sizing: border-box;
}

.topic-tile {
	position: relative;
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
	color: var(--tt-text);
	background: var(--tt-surface);
	border: 1px solid var(--tt-border);
	border-radius: var(--tt-radius);
	box-shadow: var(--tt-shadow);
	transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.topic-tile:hover {
	transform: translateY(-3px);
	box-shadow: var(--tt-shadow-hover);
}

.topic-tile:focus-within {
	border-color: var(--tt-accent);
}

/* Type accents: a thin coloured line at the top of the card. */
.topic-tile--sticky::before,
.topic-tile--announce::before {
	content: "";
	position: absolute;
	z-index: 3;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	background: var(--tt-sticky);
	pointer-events: none;
}
.topic-tile--announce::before { background: var(--tt-announce); }

/* ---- Media --------------------------------------------------------------- */

.topic-tile__media {
	--tt-hue: 210;
	position: relative;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: hsl(var(--tt-hue) 25% 90%);
}

.topic-tile__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform .45s cubic-bezier(.2, .7, .2, 1);
}

.topic-tile:hover .topic-tile__image { transform: scale(1.05); }

/* Soft shade so the badges stay readable on bright pictures. */
.topic-tile__media::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(to bottom, rgba(0, 0, 0, .28), transparent 38%);
	pointer-events: none;
}

.topic-tile__media--empty {
	display: flex;
	align-items: center;
	justify-content: center;
	background:
		radial-gradient(circle at 18% 22%, hsl(calc(var(--tt-hue) + 30) 85% 72% / .55), transparent 55%),
		radial-gradient(circle at 85% 90%, hsl(calc(var(--tt-hue) - 25) 75% 35% / .6), transparent 60%),
		linear-gradient(135deg, hsl(var(--tt-hue) 58% 56%), hsl(calc(var(--tt-hue) + 35) 52% 40%));
}

.topic-tile__placeholder {
	color: rgba(255, 255, 255, .92);
	font-family: Georgia, "Times New Roman", serif;
	font-size: 64px;
	font-weight: 700;
	line-height: 1;
	text-shadow: 0 2px 12px rgba(0, 0, 0, .18);
	transition: transform .45s cubic-bezier(.2, .7, .2, 1);
}

.topic-tile:hover .topic-tile__placeholder { transform: scale(1.08); }

/* ---- Badges -------------------------------------------------------------- */

.topic-tile__badges {
	position: absolute;
	z-index: 2;
	top: 10px;
	left: 10px;
	right: 90px;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	pointer-events: none;
}

.topic-tile__badge {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 4px 9px 4px 7px;
	color: #fff;
	background: rgba(17, 24, 39, .72);
	border-radius: 999px;
	font-size: 10.5px;
	font-weight: 700;
	letter-spacing: .04em;
	line-height: 1.4;
	text-transform: uppercase;
	white-space: nowrap;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
}

.topic-tile__badge .icon { font-size: 11px; }
.topic-tile__badge--sticky   { background: var(--tt-sticky); }
.topic-tile__badge--announce { background: var(--tt-announce); }
.topic-tile__badge--global   { background: var(--tt-global); }
.topic-tile__badge--locked   { padding: 4px 6px; }

.topic-tile__new {
	position: absolute;
	z-index: 2;
	top: 10px;
	right: 10px;
	padding: 4px 10px;
	color: #fff !important;
	background: var(--tt-new);
	border-radius: 999px;
	font-size: 10.5px;
	font-weight: 700;
	letter-spacing: .04em;
	line-height: 1.4;
	text-decoration: none !important;
	text-transform: uppercase;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}

.topic-tile__new:hover { filter: brightness(1.1); }

/* ---- Body ---------------------------------------------------------------- */

.topic-tile__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	padding: 14px 16px 12px;
}

body.section-viewforum .topic-tile__title {
	display: -webkit-box;
	margin: 0 0 6px;
	padding: 0;
	overflow: hidden;
	border: 0;
	color: var(--tt-text);
	font-family: inherit;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.35;
	text-transform: none;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}

.topic-tile--unread .topic-tile__title::before {
	content: "";
	display: inline-block;
	width: 8px;
	height: 8px;
	margin: 0 7px 2px 0;
	vertical-align: middle;
	background: var(--tt-new);
	border-radius: 50%;
}

body.section-viewforum .topic-tile__link {
	color: inherit;
	text-decoration: none;
	transition: color .15s ease;
}

.topic-tile:hover .topic-tile__link { color: var(--tt-accent); }

/* Whole card is clickable: the title link stretches over it. */
.topic-tile__link::after {
	content: "";
	position: absolute;
	z-index: 1;
	inset: 0;
}

.topic-tile__link:focus-visible { outline: none; }
.topic-tile__link:focus-visible::after {
	border-radius: var(--tt-radius);
	box-shadow: inset 0 0 0 3px var(--tt-accent);
}

/* Secondary links sit above the stretched title link. */
.topic-tile__raise { position: relative; z-index: 2; }

.topic-tile__excerpt {
	display: -webkit-box;
	margin: 0 0 14px;
	overflow: hidden;
	color: var(--tt-muted);
	font-size: 13.5px;
	line-height: 1.55;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
}

.topic-tile__excerpt--empty { opacity: .7; font-style: italic; }

/* ---- Author -------------------------------------------------------------- */

.topic-tile__author {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: auto;
	min-width: 0;
}

.topic-tile__avatar {
	display: inline-flex;
	flex: 0 0 36px;
	width: 36px;
	height: 36px;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	background: var(--tt-border);
	border-radius: 50%;
	box-shadow: 0 0 0 2px var(--tt-surface), 0 0 0 3px var(--tt-border);
}

.topic-tile__avatar img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	border-radius: 50%;
}

.topic-tile__avatar-initial {
	display: flex;
	width: 100%;
	height: 100%;
	align-items: center;
	justify-content: center;
	color: #fff;
	background: linear-gradient(135deg, var(--tt-accent), color-mix(in srgb, var(--tt-accent) 60%, #000));
	font-size: 15px;
	font-weight: 700;
}

.topic-tile__author-details {
	display: flex;
	flex-direction: column;
	min-width: 0;
	line-height: 1.35;
}

.topic-tile__author-line {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 13px;
}

body.section-viewforum .topic-tile__author-name {
	color: var(--tt-text);
	font-weight: 700;
	text-decoration: none;
}

body.section-viewforum a.topic-tile__author-name:hover { text-decoration: underline; }

body.section-viewforum .topic-tile__time {
	align-self: flex-start;
	color: var(--tt-muted);
	font-size: 12px;
	text-decoration: none;
}

body.section-viewforum .topic-tile__time:hover { color: var(--tt-accent); }
.topic-tile__time .icon { margin-right: 2px; font-size: 11px; opacity: .8; }

/* ---- Stats footer -------------------------------------------------------- */

.topic-tile__stats {
	display: flex;
	align-items: center;
	gap: 14px;
	margin-top: 12px;
	padding-top: 10px;
	border-top: 1px solid var(--tt-border);
	color: var(--tt-muted);
	font-size: 12px;
	font-variant-numeric: tabular-nums;
}

.topic-tile__stat {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	white-space: nowrap;
}

.topic-tile__stat .icon { font-size: 13px; opacity: .85; }
.topic-tile__stat--mine { color: var(--tt-accent); }

body.section-viewforum .topic-tile__go {
	display: inline-flex;
	width: 28px;
	height: 28px;
	margin-left: auto;
	align-items: center;
	justify-content: center;
	color: var(--tt-muted);
	border: 1px solid var(--tt-border);
	border-radius: 50%;
	text-decoration: none;
	transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .15s ease;
}

body.section-viewforum .topic-tile:hover .topic-tile__go {
	color: #fff;
	background: var(--tt-accent);
	border-color: var(--tt-accent);
}

body.section-viewforum .topic-tile__go:hover { transform: translateX(2px); }

/* ---- Utilities ----------------------------------------------------------- */

.topic-tile .sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ---- Responsive ---------------------------------------------------------- */

@media (max-width: 600px) {
	body.section-viewforum { --tt-gap: 14px; }
	.topic-tile:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
	.topic-tile,
	.topic-tile__image,
	.topic-tile__placeholder,
	.topic-tile__go { transition: none; }
	.topic-tile:hover,
	.topic-tile:hover .topic-tile__image,
	.topic-tile:hover .topic-tile__placeholder { transform: none; }
}

/* ---- Remove the classic topic list frame and column header --------------- */

@supports selector(.forumbg:has(ul.topiclist.topics)) {
	body.section-viewforum .forumbg:has(> .inner > ul.topiclist.topics) {
		margin: 18px 0 28px !important;
		padding: 0 !important;
		background: transparent !important;
		border: 0 !important;
		box-shadow: none !important;
	}

	body.section-viewforum .forumbg:has(> .inner > ul.topiclist.topics) > .inner {
		padding: 0 !important;
		background: transparent !important;
		border: 0 !important;
	}

	body.section-viewforum .forumbg:has(> .inner > ul.topiclist.topics) > .inner > ul.topiclist:not(.topics) {
		display: none !important;
	}
}
