/**
 * Zap Competitions - Leaderboard
 *
 * Deliberately light-touch: layout and spacing only, with colours inherited
 * from the theme so the board sits inside the site's own styling. Themes can
 * override any of these, or replace the templates entirely.
 */

.zapc-leaderboard {
	max-width: 740px;
	margin: 0 auto 2rem;
}

/*
 * Period switcher.
 *
 * Mirrors the Draw Results tab bar so the two read as one component when the
 * leaderboard is shown there. Colours are expressed as custom properties, and
 * default to the theme's own Bootstrap variables where one matches exactly, so
 * a dark mode that redefines those follows automatically. Override any of them
 * to retune without restyling the whole bar.
 */
.zapc-leaderboard__tabs {
	--zapc-lb-tabs-bg: var(--bs-body-bg, #fff);
	--zapc-lb-tabs-border: #e9e8e8;
	--zapc-lb-tab-color: #a9acac;
	--zapc-lb-tab-active-bg: var(--bs-dark, #121212);
	--zapc-lb-tab-active-color: var(--bs-white, #fff);

	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 12px;

	/* Shrink to the tabs it holds and centre, as the Draw Results bar does. */
	width: fit-content;
	max-width: 100%;
	margin: 0 auto 30px;
	padding: 6px;
	background: var(--zapc-lb-tabs-bg);
	border: 1px solid var(--zapc-lb-tabs-border);
	border-radius: 6px;
}

.zapc-leaderboard__tab {
	display: block;
	padding: 8px 16px;
	border: 1px solid transparent;
	border-radius: 5px;
	color: var(--zapc-lb-tab-color);
	font-size: 12px;
	font-weight: 600;
	line-height: 18px;
	text-decoration: none;
}

.zapc-leaderboard__tab:hover,
.zapc-leaderboard__tab:focus {
	color: var(--zapc-lb-tab-active-bg);
	text-decoration: none;
}

.zapc-leaderboard__tab.is-active {
	background: var(--zapc-lb-tab-active-bg);
	border-color: var(--zapc-lb-tab-active-bg);
	color: var(--zapc-lb-tab-active-color);
}

/*
 * The Zap theme switches to dark via a body class rather than by redefining its
 * Bootstrap variables, and swaps the selected tab from black to the accent
 * colour. Only the custom properties are restated so the rules above still
 * apply, and any other theme can do the same from its own stylesheet.
 */
body.theme-dark .zapc-leaderboard__tabs {
	--zapc-lb-tabs-bg: #1c1c1c;
	--zapc-lb-tabs-border: #404140;
	--zapc-lb-tab-active-bg: var(--bs-primary, #da5467);
	--zapc-lb-tab-active-color: #fff;
}

.zapc-leaderboard__header {
	margin: 0 0 1rem;
}

.zapc-leaderboard__title {
	margin: 0 0 0.25rem;
	text-align: center;
}

/*
 * Close countdown.
 *
 * Server-rendered as an absolute time and upgraded to a live countdown by
 * zap-competitions-leaderboard-countdown.js, so it must read sensibly either
 * way. Deliberately quiet: it sits under the title and should not compete
 * with the prize places below it.
 */
.zapc-leaderboard__countdown {
	/* Laid out as a row because each unit is its own block-level element —
	   without this the hours, minutes and seconds would stack vertically. */
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: center;
	gap: 0.35em;

	margin: 0 0 1rem;
	font-size: 0.875em;
	opacity: 0.75;
	text-align: center;
}

.zapc-leaderboard__countdown-units {
	display: flex;
	align-items: baseline;
	gap: 0.4em;
}

/*
 * One box per unit. Left deliberately plain — the hooks are here so a theme
 * can make these into tiles without having to rebuild the markup:
 * .zapc-leaderboard__countdown-unit--days / --hours / --minutes / --seconds,
 * each holding a -value and a -suffix.
 */
.zapc-leaderboard__countdown-unit {
	display: inline-flex;
	align-items: baseline;
}

.zapc-leaderboard__countdown-value {
	font-variant-numeric: tabular-nums;
	font-weight: 600;
}

.zapc-leaderboard__countdown-suffix {
	opacity: 0.8;
}

.zapc-leaderboard__countdown.is-closed {
	opacity: 1;
	font-weight: 600;
}

/* ---------------------------------------------------------------------------
 * Prize places
 *
 * The places come from an editable list in the settings, so this must read
 * sensibly at any length. The top three carry medal colours; a fourth place
 * and beyond falls back to the neutral border and inherited text, which is why
 * the medal rules are additive rather than a hard-coded set of three.
 * ------------------------------------------------------------------------- */

.zapc-leaderboard__prizes {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.5rem;
	margin: 0 0 1rem;
	padding: 0;
	list-style: none;
}

.zapc-leaderboard__prize {
	display: inline-flex;
	align-items: baseline;
	gap: 0.4em;
	padding: 0.35em 0.85em;
	border-radius: 999px;
	background: var(--bs-dark, #121212);
	color: #ffffff;
	font-size: 0.8125rem;
	line-height: 1.5;
	white-space: nowrap;
}

.zapc-leaderboard__prize-place {
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.zapc-leaderboard__prize-amount {
	font-weight: 600;
}

/*
 * Medal fills.
 *
 * The stops are sampled from the medal emoji themselves, so the pills match the
 * medals shown against the top three rows of the board. The inset highlight is
 * what reads as a struck edge rather than a flat swatch.
 *
 * Text colour is chosen per medal to clear WCAG AA (4.5:1) against every stop
 * in its own gradient, not just the midpoint: gold and silver take dark text,
 * bronze takes white. Bronze's lightest stop is a little deeper than the emoji
 * so that white stays legible across the whole sweep - at the emoji's own
 * highlight it drops to 3.6:1.
 */
.zapc-leaderboard__prize--1,
.zapc-leaderboard__prize--2,
.zapc-leaderboard__prize--3 {
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}

.zapc-leaderboard__prize--1 {
	background: linear-gradient(135deg, #fde98f 0%, #f4b609 45%, #dd9f00 100%);
	color: #3d2900; /* 5.96:1 at the darkest stop */
}

.zapc-leaderboard__prize--2 {
	background: linear-gradient(135deg, #e8e8e8 0%, #c4c4c4 45%, #adadad 100%);
	color: #2f2f33; /* 5.94:1 at the darkest stop */
}

.zapc-leaderboard__prize--3 {
	background: linear-gradient(135deg, #b45c15 0%, #9a450f 45%, #8c3504 100%);
	color: #ffffff; /* 4.69:1 at the lightest stop */
}

.zapc-leaderboard__summary {
	margin: 0 0 1rem;
	text-align: center;
}

.zapc-leaderboard__summary p {
	margin: 0 0 0.25rem;
}

.zapc-leaderboard__table {
	width: 100%;
	border-collapse: collapse;
}

.zapc-leaderboard__table th,
.zapc-leaderboard__table td {
	padding: 0.65rem 0.75rem;
	text-align: left;
	vertical-align: middle;
}

.zapc-leaderboard__table thead th {
	border-bottom: 2px solid rgba(0, 0, 0, 0.12);
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	opacity: 0.6;
}

/* Between rows only: the header already carries its own dividing rule. */
.zapc-leaderboard__table tbody tr + tr {
	border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/*
 * Column rules are scoped to the table so they outrank the shared
 * `.zapc-leaderboard__table td` alignment above. Bare class selectors lose to
 * it on specificity, which is what left the Awards and Points values aligned
 * left while their headers aligned right.
 */
.zapc-leaderboard__table .zapc-leaderboard__col-place {
	width: 4.5rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.zapc-leaderboard__table .zapc-leaderboard__col-points {
	width: 6rem;
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.zapc-leaderboard__row.is-you {
	font-weight: 700;
	background: rgba(0, 0, 0, 0.04);
}

.zapc-leaderboard__you {
	display: inline-block;
	margin-left: 0.5rem;
	padding: 0.1rem 0.45rem;
	border-radius: 999px;
	font-size: 0.6875rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	background: rgba(0, 0, 0, 0.08);
}

/* Medals against the top three rows of the board. */
.zapc-leaderboard__row--1 .zapc-leaderboard__col-place::before {
	content: "\1F947\00a0";
}

.zapc-leaderboard__row--2 .zapc-leaderboard__col-place::before {
	content: "\1F948\00a0";
}

.zapc-leaderboard__row--3 .zapc-leaderboard__col-place::before {
	content: "\1F949\00a0";
}

.zapc-leaderboard__footer,
.zapc-leaderboard__updated,
.zapc-leaderboard__full-link {
	margin: 1rem 0 0;
	font-size: 0.875rem;
	opacity: 0.75;
}

.zapc-leaderboard__meta {
	margin: 0;
}

.zapc-leaderboard__empty {
	margin: 0;
	padding: 1.25rem;
	border: 1px dashed rgba(0, 0, 0, 0.2);
	border-radius: 0.25rem;
	text-align: center;
}

@media (max-width: 600px) {

	.zapc-leaderboard__table th,
	.zapc-leaderboard__table td {
		padding: 0.5rem 0.4rem;
	}
}

/* ---------------------------------------------------------------------------
 * Prize points badge
 *
 * Shown against each Instant Win prize that awards leaderboard points. Colours
 * are inherited so the badge sits inside the theme's own styling.
 * ------------------------------------------------------------------------- */

.zapc-prize-points {
	display: inline-block;
	margin-left: 0.4em;
	padding: 0.1em 0.5em;
	border: 1px solid currentColor;
	border-radius: 999px;
	font-size: 0.75em;
	font-weight: 700;
	line-height: 1.5;
	white-space: nowrap;
	vertical-align: middle;
	opacity: 0.75;
}

/* A prize that is only points has no other value to show, so lead with it. */
.zapc-prize-points--primary {
	opacity: 1;
	border-width: 2px;
}

/* ---------------------------------------------------------------------------
 * Product page points
 *
 * Sits under the add to cart button and tracks the ticket slider. Kept to a
 * single quiet line rather than the panel treatment used in the basket: at this
 * point the customer is choosing a quantity, and the button is what should hold
 * their attention.
 * ------------------------------------------------------------------------- */

.zapc-product-points {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.45em;
	margin: 0.75rem 0 0;
	font-size: 0.875rem;
	line-height: 1.4;
	text-align: center;
	opacity: 0.85;
}

.zapc-product-points i {
	flex-shrink: 0;
	color: #8c6508;
}

.zapc-product-points strong {
	font-weight: 700;
}

/* ---------------------------------------------------------------------------
 * Past boards
 *
 * Three optional links, so the row has to look deliberate with one, two or
 * three in it: earlier on the left, later on the right, current in the middle
 * whichever of its neighbours exist.
 * ------------------------------------------------------------------------- */

.zapc-leaderboard__history {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin: 1.5rem 0 0;
}

/* Keeps "Current board" centred when it is the only other link present. */
.zapc-leaderboard__history-link--current {
	margin-inline: auto;
}

.zapc-leaderboard__history-link {
	font-size: 0.9375em;
	text-decoration: none;
}

.zapc-leaderboard__history-link:hover,
.zapc-leaderboard__history-link:focus {
	text-decoration: underline;
}

/* ---------------------------------------------------------------------------
 * How far off the next place is (My Account only)
 * ------------------------------------------------------------------------- */

.zapc-leaderboard__summary-gap {
	margin: 0.25rem 0 0;
}

.zapc-leaderboard__summary-gap-prize::before {
	content: "\00b7";
	margin: 0 0.5em;
	opacity: 0.5;
}
