/**
 * ESF formation pitch, jerseys, modal.
 * Pitch is landscape (goals left–right); coords: x% toward opponent, y% lateral.
 */

.esf-formation {
	--esf-pitch-shadow: inset 0 0 100px rgba(0, 0, 0, 0.18);
	margin: 0;
}

.esf-formation--hero {
	width: 100%;
	color: rgba(255, 255, 255, 0.95);
}

.esf-formation-hero__hint {
	font-size: 0.62rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	opacity: 0.72;
	margin: 0 0 6px;
	line-height: 1.35;
	text-align: center;
}

.esf-formation--hero .esf-formation__pitch-wrap {
	max-width: 100%;
	width: 100%;
	padding: clamp(6px, 1.4vw, 10px);
	border-radius: 14px;
	background: linear-gradient(155deg, #243d14 0%, #0f1a0a 42%, #1a2e0f 100%);
	box-shadow:
		0 1px 0 rgba(255, 255, 255, 0.07) inset,
		0 22px 48px rgba(0, 0, 0, 0.42),
		0 0 0 1px rgba(0, 0, 0, 0.35);
}

.esf-formation--hero .esf-formation__pitch {
	border-radius: 10px;
	box-shadow:
		var(--esf-pitch-shadow),
		0 0 0 1px rgba(255, 255, 255, 0.06) inset;
	/* Shorter, broadcast-style pitch; full width of the hero */
	aspect-ratio: 105 / 52;
	margin-inline: auto;
}

.esf-formation__toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem 1.5rem;
	align-items: flex-end;
	margin-bottom: 1rem;
}

.esf-formation__toolbar p {
	margin: 0;
}

.esf-formation__toolbar label {
	display: block;
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	opacity: 0.85;
	margin-bottom: 0.25rem;
}

.esf-formation__preset {
	min-width: 10rem;
	padding: 0.35rem 0.5rem;
	border-radius: 6px;
	border: 1px solid rgba(0, 0, 0, 0.15);
	background: #fff;
}

.esf-formation__kit {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem 1.25rem;
}

.esf-formation__kit input[type="color"] {
	width: 2.75rem;
	height: 2.25rem;
	padding: 0;
	border: 1px solid rgba(0, 0, 0, 0.2);
	border-radius: 6px;
	cursor: pointer;
}

.esf-formation__save {
	align-self: flex-end;
}

.esf-formation__message {
	font-size: 0.9rem;
	align-self: center;
	min-height: 1.25em;
}

.esf-formation__message.is-success {
	color: #0d7d4d;
}

.esf-formation__message.is-error {
	color: #b00020;
}

.esf-formation__slot-hint {
	margin-top: 0.75rem;
	font-size: 0.9rem;
	opacity: 0.9;
}

.esf-formation__slot-controls {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 0.75rem;
	margin-top: 1rem;
}

.esf-formation__slot-row {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.esf-formation__slot-row label {
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	opacity: 0.8;
}

.esf-formation__slot-row select {
	padding: 0.35rem 0.5rem;
	border-radius: 6px;
	border: 1px solid rgba(0, 0, 0, 0.15);
	background: #fff;
	font-size: 0.9rem;
}

.esf-formation__pitch-wrap {
	position: relative;
	width: 100%;
	max-width: 920px;
	margin: 0 auto;
	border-radius: 12px;
	padding: 12px;
	background: linear-gradient(145deg, #2d5016 0%, #1a3009 50%, #243d12 100%);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.esf-formation__pitch {
	position: relative;
	width: 100%;
	aspect-ratio: 105 / 68;
	border-radius: 8px;
	overflow: hidden;
	background-color: #3d8f2e;
	background-image: repeating-linear-gradient(
		90deg,
		#3f9230 0px,
		#3f9230 11px,
		#368228 11px,
		#368228 22px
	);
	box-shadow: var(--esf-pitch-shadow);
	touch-action: none;
}

.esf-formation__markings {
	position: absolute;
	inset: 0;
	pointer-events: none;
	z-index: 1;
	background-image: url("../images/esf-pitch-markings.svg");
	background-size: 100% 100%;
	background-repeat: no-repeat;
	opacity: 1;
	filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.35));
}

.esf-formation__player {
	position: absolute;
	z-index: 3;
	transform: translate(-50%, -50%);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
	cursor: pointer;
	border: none;
	background: transparent;
	padding: 0;
	font: inherit;
	color: inherit;
	touch-action: none;
}

.esf-formation__player:focus-visible {
	outline: 2px solid #1e6bb8;
	outline-offset: 2px;
	border-radius: 8px;
}

.esf-formation__jersey {
	position: relative;
	width: 38px;
	height: 46px;
	display: grid;
	place-items: center;
	border: none;
	background: transparent;
	box-shadow: none;
	padding: 0;
}

.esf-formation__jersey-shape {
	grid-area: 1 / 1;
	width: 100%;
	height: 100%;
	display: block;
	filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4)) drop-shadow(0 1px 0 rgba(0, 0, 0, 0.25));
}

.esf-formation__jersey-shape path:first-of-type {
	stroke: rgba(0, 0, 0, 0.2);
	stroke-width: 0.6;
}

.esf-formation__jersey-num {
	grid-area: 1 / 1;
	position: relative;
	z-index: 1;
	font-weight: 800;
	font-size: 0.82rem;
	line-height: 1;
	letter-spacing: -0.03em;
	margin-top: -2px;
	text-shadow:
		0 1px 0 rgba(0, 0, 0, 0.5),
		0 0 8px rgba(0, 0, 0, 0.35);
	pointer-events: none;
}

.esf-formation--hero .esf-formation__jersey {
	width: 34px;
	height: 41px;
}

.esf-formation--hero .esf-formation__jersey-num {
	font-size: 0.7rem;
}

.esf-formation--hero .esf-formation__player-name {
	max-width: 76px;
	font-size: 0.5rem;
	padding: 2px 4px;
	line-height: 1.1;
}

.esf-formation__player-name {
	max-width: 100px;
	font-size: 0.58rem;
	font-weight: 700;
	text-align: center;
	line-height: 1.15;
	padding: 3px 6px;
	background: linear-gradient(180deg, rgba(12, 12, 14, 0.88), rgba(6, 6, 8, 0.92));
	color: #fff;
	border-radius: 4px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	border: 1px solid rgba(255, 255, 255, 0.08);
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

.esf-formation__player.is-empty .esf-formation__jersey-shape {
	opacity: 0.5;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}

.esf-formation__player.is-empty .esf-formation__jersey-shape path {
	stroke: rgba(255, 255, 255, 0.35);
	stroke-width: 0.75;
	stroke-dasharray: 2 2;
}

.esf-formation__player.is-empty .esf-formation__jersey-num {
	font-size: 0.75rem;
	opacity: 0.8;
}

.esf-formation__player.is-dragging {
	z-index: 10;
	opacity: 0.95;
}

.esf-formation--editor .esf-formation__player {
	cursor: grab;
}

.esf-formation--editor .esf-formation__player.is-dragging {
	cursor: grabbing;
}

.esf-formation__modal-overlay {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 100050;
	background: rgba(0, 0, 0, 0.45);
	align-items: center;
	justify-content: center;
	padding: 1rem;
}

.esf-formation__modal-overlay.is-open {
	display: flex;
}

.esf-formation__modal {
	background: #fff;
	border-radius: 14px;
	max-width: 420px;
	width: 100%;
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
	overflow: hidden;
	animation: esfFormModalIn 0.2s ease-out;
}

@keyframes esfFormModalIn {
	from {
		opacity: 0;
		transform: scale(0.96) translateY(8px);
	}
	to {
		opacity: 1;
		transform: scale(1) translateY(0);
	}
}

.esf-formation__modal-head {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 1rem;
	padding: 1.25rem 1.25rem 0.5rem;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.esf-formation__modal-head h4 {
	margin: 0;
	font-size: 1.15rem;
}

.esf-formation__modal-role {
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	opacity: 0.65;
	margin: 0.25rem 0 0;
}

.esf-formation__modal-close {
	border: none;
	background: rgba(0, 0, 0, 0.06);
	width: 2rem;
	height: 2rem;
	border-radius: 8px;
	cursor: pointer;
	font-size: 1.25rem;
	line-height: 1;
	flex-shrink: 0;
}

.esf-formation__modal-close:hover {
	background: rgba(0, 0, 0, 0.12);
}

.esf-formation__modal-body {
	padding: 1rem 1.25rem 1.25rem;
}

.esf-formation__modal-stats {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.65rem;
	margin: 0 0 1rem;
}

.esf-formation__modal-stats span {
	display: block;
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	opacity: 0.7;
}

.esf-formation__modal-stats strong {
	font-size: 1.1rem;
}

.esf-formation__modal-link {
	display: inline-block;
	font-weight: 600;
	text-decoration: none;
}

.esf-formation__modal-link:hover {
	text-decoration: underline;
}

@media (max-width: 600px) {
	.esf-formation__jersey {
		width: 36px;
		height: 44px;
	}

	.esf-formation__jersey-num {
		font-size: 0.92rem;
	}

	.esf-formation__toolbar {
		flex-direction: column;
		align-items: stretch;
	}

	.esf-formation__player-name {
		max-width: 88px;
		font-size: 0.54rem;
	}

	.esf-formation--hero .esf-formation__pitch {
		aspect-ratio: 105 / 46;
	}
}
