/*
 * Tabelloni a gironi (round robin) dei Promises: inc/draw-round-robin.php.
 * Colori del tabellone a eliminazione diretta (assets/css/draw.scss):
 * primary #17253f, secondary #29a5dc, grey #838282.
 */

#mainDraw.rrDraw {
	overflow: visible;
}

.rrDraw__body {
	display: flex;
	flex-direction: column;
	gap: 32px;
	padding: 8px 0 24px;
	font-family: 'Titillium Web', sans-serif;
	color: #17253f;
}

.rrDraw__groups {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
	gap: 20px;
	align-items: start;
}

.rrDraw__group,
.rrDraw__section,
.rrDraw__bracket {
	background: #fff;
	border: 1px solid rgba(23, 37, 63, 0.12);
	border-radius: 8px;
	padding: 16px;
}

/*
 * Fase finale come il tabellone a eliminazione diretta: una colonna per turno,
 * il match n centrato fra i match 2n e 2n+1 che lo alimentano (ogni colonna ha
 * la stessa altezza e i match si dividono lo spazio), linee di collegamento fra
 * le colonne. Se non entra scorre in orizzontale.
 */

.rrDraw__bracket {
	--rr-gap: 48px;
	--rr-line: rgba(23, 37, 63, 0.25);
	overflow-x: auto;
	scrollbar-width: thin;
}

.rrDraw__rounds {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: minmax(280px, 360px);
	column-gap: var(--rr-gap);
	width: max-content;
	min-width: 100%;
}

.rrDraw__round {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.rrDraw__slots {
	flex: 1;
	display: flex;
	flex-direction: column;
}

.rrDraw__slot {
	position: relative;
	flex: 1;
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding: 8px 0;
}

/* Uscita verso il turno dopo: tratto orizzontale e mezza linea verticale che si unisce con il match accanto. */
.rrDraw__round:not(:last-child) .rrDraw__slot::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 100%;
	width: calc(var(--rr-gap) / 2);
	border-top: 2px solid var(--rr-line);
}

.rrDraw__round:not(:last-child) .rrDraw__slot::before {
	content: '';
	position: absolute;
	left: calc(100% + var(--rr-gap) / 2 - 2px);
	height: 50%;
	border-left: 2px solid var(--rr-line);
}

.rrDraw__round:not(:last-child) .rrDraw__slot:nth-child(odd)::before {
	top: 50%;
}

.rrDraw__round:not(:last-child) .rrDraw__slot:nth-child(even)::before {
	top: 0;
}

/* Entrata dal turno prima. */
.rrDraw__round:not(:first-child) .rrDraw__slot > .rrDraw__matches {
	position: relative;
}

.rrDraw__round:not(:first-child) .rrDraw__slot > .rrDraw__matches::before {
	content: '';
	position: absolute;
	top: 50%;
	right: 100%;
	width: calc(var(--rr-gap) / 2);
	border-top: 2px solid var(--rr-line);
}

/* La finale: scheda in evidenza. */
.rrDraw__round--final .rrDraw__match {
	border: 2px solid #29a5dc;
	background: #fff;
}

.rrDraw__round--final .rrDraw__row {
	padding: 10px 12px;
	font-size: 15px;
}

.rrDraw__round--final .rrDraw__set {
	font-size: 18px;
}

.rrDraw__round--final .rrDraw__title {
	color: #29a5dc;
}

.rrDraw__title {
	margin: 0 0 12px;
	padding-bottom: 6px;
	border-bottom: 2px solid #29a5dc;
	font-family: 'Oswald', sans-serif;
	font-size: 18px;
	font-weight: 500;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #17253f;
}

/* Coppie del girone */

.rrDraw__teams {
	list-style: none;
	margin: 0 0 16px;
	padding: 0;
}

.rrDraw__teamsItem {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 6px 0;
	border-bottom: 1px solid rgba(23, 37, 63, 0.08);
	font-size: 14px;
}

.rrDraw__teamsItem:last-child {
	border-bottom: 0;
}

/* Scheda punteggio: una riga per coppia */

.rrDraw__matches {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.rrDraw__match {
	border-radius: 6px;
	background: rgba(23, 37, 63, 0.04);
	overflow: hidden;
}

.rrDraw__row {
	display: grid;
	grid-template-columns: 1fr auto 16px;
	align-items: center;
	gap: 10px;
	padding: 7px 10px;
	font-size: 13px;
}

.rrDraw__row + .rrDraw__row {
	border-top: 1px solid rgba(23, 37, 63, 0.08);
}

.rrDraw__row--winner {
	background: rgba(41, 165, 220, 0.12);
	font-weight: 700;
}

.rrDraw__pair {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.rrDraw__player {
	display: flex;
	align-items: center;
	gap: 6px;
	min-width: 0;
	color: #4a5568;
	overflow-wrap: anywhere;
}

.rrDraw__row--winner .rrDraw__player {
	color: #17253f;
}

.rrDraw__player--tbd {
	color: #838282;
	font-style: italic;
}

.rrDraw__flag {
	flex: none;
	width: 20px;
	height: auto;
	border-radius: 2px;
}

.rrDraw__seed {
	color: #838282;
	font-size: 12px;
	font-weight: 400;
}

.rrDraw__sets {
	display: flex;
	gap: 4px;
}

.rrDraw__set {
	min-width: 22px;
	text-align: center;
	font-size: 15px;
	font-variant-numeric: tabular-nums;
}

.rrDraw__set sup {
	font-size: 10px;
	margin-left: 1px;
}

.rrDraw__check {
	color: #29a5dc;
	font-weight: 700;
}

.rrDraw__note {
	padding: 4px 10px 6px;
	font-size: 12px;
	font-weight: 600;
	color: #838282;
	text-align: right;
}

@media (max-width: 767px) {
	.rrDraw__groups {
		grid-template-columns: 1fr;
	}

	.rrDraw__bracket {
		--rr-gap: 32px;
	}

	.rrDraw__rounds {
		grid-auto-columns: minmax(240px, 280px);
	}
}
