/**
 * Top List Manager – enhanced frontend dropdown.
 *
 * The native <select class="toplist-frontend-dropdown"> is kept in the DOM as
 * the value holder for the live-refresh script, but visually replaced by the
 * .toplist-dd custom control. Colors/sizing are exposed as custom properties
 * so individual pages can re-theme via their own custom CSS.
 */

.toplist-frontend-dropdown-wrapper.toplist-dd-enhanced > select.toplist-frontend-dropdown {
	display: none !important;
}

.toplist-dd {
	--tdd-accent: #2f6fed;
	--tdd-accent-soft: #e9f1ff;
	--tdd-border: #2f6fed;
	--tdd-surface: #ffffff;
	--tdd-text: #172033;
	--tdd-muted: #64708299;
	--tdd-separator: #eef2f9;
	--tdd-radius: 12px;
	--tdd-menu-radius: 16px;
	--tdd-font-size: 18px;
	--tdd-icon-size: 28px;
	--tdd-shadow: 0 22px 55px rgba(15, 32, 68, 0.22), 0 4px 14px rgba(15, 32, 68, 0.1);

	position: relative;
	width: 100%;
	box-sizing: border-box;
	text-align: left;
	font-family: inherit;
}

.toplist-dd *,
.toplist-dd *::before,
.toplist-dd *::after {
	box-sizing: border-box;
}

/* ---------------------------------------------------------------- toggle */

.toplist-dd__toggle {
	display: flex;
	align-items: center;
	gap: 13px;
	width: 100%;
	margin: 0;
	padding: 14px 18px;
	background: var(--tdd-surface);
	border: 2px solid var(--tdd-border);
	border-radius: var(--tdd-radius);
	cursor: pointer;
	font: inherit;
	font-size: var(--tdd-font-size);
	line-height: 1.3;
	color: var(--tdd-muted);
	text-align: left;
	transition: box-shadow 0.22s ease, border-color 0.22s ease;
	-webkit-appearance: none;
	appearance: none;
}

.toplist-dd__toggle:hover {
	box-shadow: 0 8px 22px rgba(47, 111, 237, 0.16);
}

.toplist-dd__toggle:focus {
	outline: none;
}

.toplist-dd__toggle:focus-visible {
	outline: 3px solid rgba(47, 111, 237, 0.35);
	outline-offset: 2px;
}

.toplist-dd.is-open .toplist-dd__toggle {
	box-shadow: 0 10px 26px rgba(47, 111, 237, 0.2);
}

.toplist-dd__badge {
	flex: 0 0 auto;
	width: 30px;
	height: 24px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--tdd-accent);
}

.toplist-dd__badge svg {
	width: 100%;
	height: auto;
	display: block;
}

.toplist-dd__badge img {
	width: 26px;
	height: 24px;
	object-fit: contain;
	display: block;
}

.toplist-dd__label {
	flex: 1 1 auto;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-weight: 500;
}

.toplist-dd.has-value .toplist-dd__label {
	color: var(--tdd-text);
	font-weight: 700;
}

.toplist-dd__chevron {
	flex: 0 0 auto;
	width: 22px;
	height: 22px;
	color: #3c4658;
	transition: transform 0.22s ease;
}

.toplist-dd__chevron svg {
	width: 100%;
	height: 100%;
	display: block;
}

.toplist-dd.is-open .toplist-dd__chevron {
	transform: rotate(180deg);
}

/* ------------------------------------------------------------------ menu */

.toplist-dd__menu {
	position: absolute;
	top: calc(100% + 10px);
	left: 0;
	right: 0;
	z-index: 99999;
	margin: 0;
	padding: 8px;
	list-style: none;
	background: var(--tdd-surface);
	border-radius: var(--tdd-menu-radius);
	box-shadow: var(--tdd-shadow);
	max-height: min(430px, 62vh);
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	scrollbar-color: #c7d2e4 transparent;
	animation: toplist-dd-in 0.16s ease;
}

.toplist-dd__menu[hidden] {
	display: none;
}

/* the active row is the focus indicator; no ring on the list itself */
.toplist-dd__menu:focus,
.toplist-dd__menu:focus-visible {
	outline: none;
	box-shadow: var(--tdd-shadow);
}

.toplist-dd__menu::-webkit-scrollbar {
	width: 8px;
}

.toplist-dd__menu::-webkit-scrollbar-thumb {
	background: #c7d2e4;
	border-radius: 99px;
}

@keyframes toplist-dd-in {
	from {
		opacity: 0;
		transform: translateY(-6px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@media (prefers-reduced-motion: reduce) {
	.toplist-dd__menu {
		animation: none;
	}
	.toplist-dd__chevron {
		transition: none;
	}
}

/* --------------------------------------------------------------- options */

.toplist-dd__option {
	display: flex;
	align-items: center;
	gap: 14px;
	margin: 0;
	padding: 13px 14px;
	border-radius: 10px;
	cursor: pointer;
	color: var(--tdd-text);
	font-size: calc(var(--tdd-font-size) - 1px);
	font-weight: 600;
	line-height: 1.3;
	position: relative;
}

/* subtle separators between rows, mockup-style */
.toplist-dd__option + .toplist-dd__option::before {
	content: "";
	position: absolute;
	top: 0;
	left: 14px;
	right: 14px;
	height: 1px;
	background: var(--tdd-separator);
}

.toplist-dd__option.is-active,
.toplist-dd__option:hover {
	background: var(--tdd-accent-soft);
}

.toplist-dd__option.is-active::before,
.toplist-dd__option:hover::before,
.toplist-dd__option.is-active + .toplist-dd__option::before,
.toplist-dd__option:hover + .toplist-dd__option::before {
	opacity: 0;
}

.toplist-dd__option.is-selected {
	color: var(--tdd-accent);
}

.toplist-dd__icon {
	flex: 0 0 auto;
	width: var(--tdd-icon-size);
	height: var(--tdd-icon-size);
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--tdd-accent);
}

.toplist-dd__icon img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	display: block;
}

.toplist-dd__icon svg {
	width: 80%;
	height: 80%;
	display: block;
}

.toplist-dd__icon--placeholder {
	color: #b6c1d4;
}

.toplist-dd__text {
	flex: 1 1 auto;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.toplist-dd__arrow {
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
	color: #b9c2d0;
}

.toplist-dd__arrow svg {
	width: 100%;
	height: 100%;
	display: block;
}

.toplist-dd__option.is-active .toplist-dd__arrow,
.toplist-dd__option:hover .toplist-dd__arrow {
	color: var(--tdd-accent);
}

/* ------------------------------------------------------- swapped content */

/* No stray bullets in toplist results (post-template list or list markup
   coming from post meta HTML) — seen after live list swaps. */
.toplist-query-content ul {
	list-style: none;
}

.toplist-query-content li::marker {
	content: "";
}

/* ----------------------------------------------------------------- note */

.toplist-dd__note {
	position: absolute;
	top: calc(100% + 7px);
	left: 3px;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--tdd-accent);
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
	white-space: nowrap;
	pointer-events: none;
}

.toplist-dd__note-icon {
	flex: 0 0 auto;
	width: 15px;
	height: 15px;
	display: inline-flex;
}

.toplist-dd__note-icon svg {
	width: 100%;
	height: 100%;
	display: block;
}

/* --------------------------------------------------------------- mobile */

@media (max-width: 600px) {
	.toplist-dd {
		--tdd-font-size: 16px;
		--tdd-icon-size: 24px;
		--tdd-radius: 10px;
		--tdd-menu-radius: 14px;
	}

	.toplist-dd__toggle {
		padding: 12px 14px;
		gap: 10px;
	}

	.toplist-dd__note {
		font-size: 12px;
	}

	.toplist-dd__option {
		padding: 11px 10px;
		gap: 10px;
	}
}
