/**
 * 3-column layout for single game pages.
 *
 * Desktop ≥1024px: random sidebar + main + hot sidebar (sticky, scrollable).
 * Below 1024px: collapses to 1 column with both sidebars pushed under main,
 * and the inner card lists switch from a vertical stack to a 2-col grid so
 * cards stay readable without filling the whole page.
 *
 * Loaded via TGG_Template_Loader on `is_singular('game')`. Depends on
 * `tgg-frontend` (so .tgg-single-wrap defaults are already in scope).
 */

/* ===== 3-col grid container ===== */
.tgg-single-wrap.tgg-single-layout {
	max-width: 1400px;
	display: grid;
	grid-template-columns: minmax(220px, 1fr) minmax(0, 4fr) minmax(220px, 1fr);
	gap: 24px;
	padding: 20px;
	align-items: start;
}

/* Center column — min-width:0 so iframes/long words can shrink instead of
   forcing the grid track wider than 4fr. */
.tgg-single-main {
	min-width: 0;
}

.tgg-single-main > .tgg-single,
.tgg-single-main > article {
	margin: 0;
}

/* ===== Sidebar shell ===== */
.tgg-sidebar {
	position: sticky;
	top: 80px;
	max-height: calc(100vh - 100px);
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: #ccc transparent;
}

.tgg-sidebar::-webkit-scrollbar {
	width: 6px;
}
.tgg-sidebar::-webkit-scrollbar-track {
	background: transparent;
}
.tgg-sidebar::-webkit-scrollbar-thumb {
	background: rgba(0, 0, 0, 0.2);
	border-radius: 3px;
}

.tgg-sidebar-section {
	background: #fff;
	border-radius: 12px;
	padding: 16px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
	margin-bottom: 16px;
}

.tgg-sidebar-title {
	font-size: 16px;
	font-weight: 700;
	margin: 0 0 12px;
	padding-bottom: 8px;
	border-bottom: 2px solid #f0f0f0;
}

.tgg-sidebar-list {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/* ===== Card ===== */
.tgg-sidebar-card {
	display: flex;
	gap: 10px;
	align-items: center;
	text-decoration: none;
	color: inherit;
	border-radius: 8px;
	padding: 6px;
	transition: background 0.15s ease;
}

.tgg-sidebar-card:hover,
.tgg-sidebar-card:focus-visible {
	background: #f5f5f5;
	text-decoration: none;
	color: inherit;
	outline: none;
}

.tgg-sidebar-card-thumb {
	position: relative;
	flex-shrink: 0;
	width: 60px;
	height: 60px;
	border-radius: 8px;
	overflow: hidden;
	background: #eee;
}

.tgg-sidebar-card-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.tgg-sidebar-card-info {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.tgg-sidebar-card-title {
	font-size: 13px;
	font-weight: 500;
	line-height: 1.3;
	color: #222;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.tgg-sidebar-card-meta {
	font-size: 11px;
	color: #888;
}

.tgg-sidebar-rank {
	position: absolute;
	top: 4px;
	left: 4px;
	background: rgba(255, 87, 34, 0.95);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	padding: 1px 5px;
	border-radius: 4px;
	line-height: 1;
}

.tgg-sidebar-card-thumb .tgg-badge-mini {
	position: absolute;
	bottom: 4px;
	right: 4px;
	top: auto;
	left: auto;
	font-size: 8px;
	padding: 1px 4px;
	border-radius: 4px;
	line-height: 1;
}

/* ===== Responsive ===== */

/* Below desktop: collapse to single column, sidebars pushed under main. */
@media (max-width: 1024px) {
	.tgg-single-wrap.tgg-single-layout {
		grid-template-columns: 1fr;
		gap: 16px;
		padding: 12px;
	}
	.tgg-sidebar {
		position: static;
		max-height: none;
		overflow: visible;
	}
	.tgg-single-main      { order: 1; }
	.tgg-sidebar-left     { order: 2; }
	.tgg-sidebar-right    { order: 3; }

	.tgg-sidebar-list {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		gap: 8px;
	}
}

@media (max-width: 600px) {
	.tgg-sidebar-card-thumb {
		width: 50px;
		height: 50px;
	}
	.tgg-sidebar-card-title {
		font-size: 12px;
	}
}

@media (max-width: 380px) {
	.tgg-sidebar-list {
		grid-template-columns: 1fr;
	}
}

/* When iOS pseudo-fullscreen is active anywhere on the page, hide sidebars
   so they don't peek above the overlay or steal scroll focus. */
body:has(.tgg-pseudo-fullscreen) .tgg-sidebar {
	display: none;
}

@media (prefers-reduced-motion: reduce) {
	.tgg-sidebar-card {
		transition: none;
	}
}
