/*
 * NCase Teams - shared card-design gallery (js/nct-design-gallery.js).
 * Client decision 2026-10-26: each team in a league picks its own design.
 * Used by the league wizard rows, My League and the team page coach tools,
 * so every colour/size reads from nct-tokens.css with a plain fallback for
 * pages where the wizard stylesheets aren't loaded (My Account).
 */

.nct-dg {
	--dg-line: var(--nct-line, #e3e8ef);
	--dg-line-strong: var(--nct-line-strong, #c9d2de);
	--dg-text: var(--nct-text, #1b1f24);
	--dg-faint: var(--nct-text-faint, #6b7482);
	--dg-primary: var(--nct-primary, #2a8ad4);
	--dg-select: var(--nct-select-solid, #6b4ff2);
	--dg-tint: var(--nct-tint, #f3f7fc);
	--dg-error: var(--nct-error, #c0392b);
	--dg-font: var(--nct-font-body, 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif);
	font-family: var(--dg-font);
	color: var(--dg-text);
}

/* Mode choice ----------------------------------------------------------- */
.nct-dg-modes {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin: 0 0 12px;
}

.nct-dg-mode {
	position: relative;
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 10px 12px;
	border: 1px solid var(--dg-line-strong);
	border-radius: 10px;
	background: #fff;
	cursor: pointer;
}

.nct-dg-mode:has(input:checked) {
	border-color: var(--dg-select);
	background: var(--dg-tint);
}

.nct-dg-mode input,
.nct-dg-card input,
.nct-dg-sw input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	pointer-events: none;
}

.nct-dg-dot {
	flex: 0 0 16px;
	width: 16px;
	height: 16px;
	margin-top: 2px;
	border-radius: 50%;
	border: 2px solid var(--dg-line-strong);
	background: #fff;
}

.nct-dg-mode:has(input:checked) .nct-dg-dot {
	border-color: var(--dg-select);
	box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 8px var(--dg-select);
}

.nct-dg-mode-text {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.nct-dg-mode-title {
	font: 600 14px/20px var(--dg-font);
}

.nct-dg-mode-sub {
	font: 400 12.5px/18px var(--dg-font);
	color: var(--dg-faint);
}

/* Gallery --------------------------------------------------------------- */
.nct-dg-gallery {
	background: #fff;
	border: 1px solid var(--dg-line);
	border-radius: 12px;
	padding: 14px;
}

.nct-dg-gallery[hidden] {
	display: none;
}

.nct-dg-label {
	font: 600 14px/20px var(--dg-font);
	margin: 0 0 12px;
}

.nct-dg-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
	gap: 12px;
}

.nct-dg-card {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	border: 2px solid var(--dg-line-strong);
	background: #fff;
	border-radius: 10px;
	padding: 8px 6px 6px;
	cursor: pointer;
}

.nct-dg-card:hover {
	border-color: var(--dg-primary);
}

.nct-dg-card:has(input:focus-visible) {
	outline: 2px solid var(--dg-primary);
	outline-offset: 2px;
}

.nct-dg-card:has(input:checked) {
	border-color: var(--dg-select);
	background: var(--dg-tint);
}

.nct-dg-card:has(input:checked)::after {
	content: '\2713';
	position: absolute;
	top: 6px;
	right: 6px;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: var(--dg-select);
	color: #fff;
	font-size: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.nct-dg-card-img {
	width: 100%;
	max-width: 90px;
	height: auto;
	object-fit: contain;
}

.nct-dg-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 110px;
	background: var(--dg-line);
	color: var(--dg-faint);
	font-size: 12.5px;
	text-align: center;
	padding: 16px;
}

.nct-dg-card-name {
	font: 500 13px/18px var(--dg-font);
	text-align: center;
}

.nct-dg-card-colors {
	margin-top: -2px;
	font-size: 11px;
	color: var(--dg-faint);
	text-align: center;
}

/* Colour swatches: a full-width grid item placed after the picked card's row. */
.nct-dg-colors {
	grid-column: 1 / -1;
	background: var(--dg-tint);
	border: 1px solid var(--dg-line);
	border-radius: 10px;
	padding: 14px 16px;
}

.nct-dg-colors[hidden] {
	display: none;
}

.nct-dg-colors-label {
	font: 600 13px/18px var(--dg-font);
	margin: 0 0 10px;
}

.nct-dg-color-row {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.nct-dg-sw {
	position: relative;
	display: inline-flex;
	cursor: pointer;
	border-radius: 50%;
	padding: 4px;
}

.nct-dg-sw-dot {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	border: 1px solid rgba(0, 0, 0, .15);
}

.nct-dg-sw:has(input:checked) .nct-dg-sw-dot {
	box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--dg-select);
}

.nct-dg-color-hint,
.nct-dg-error {
	font-size: 12.5px;
	color: var(--dg-error);
	margin: 10px 0 0;
}

.nct-dg-color-hint[hidden],
.nct-dg-error[hidden] {
	display: none;
}

/* Buttons (match .nct-ct-btn without depending on nct-team-flow.css) ----- */
.nct-dg-btn {
	border-radius: 30px;
	padding: 12px 22px;
	font: 600 15px/22px var(--dg-font, 'Inter', system-ui, sans-serif);
	text-transform: none;
	letter-spacing: normal;
	cursor: pointer;
	border: 1px solid transparent;
}

.nct-dg-btn-primary {
	background: #1b1f24;
	color: #fff;
	border-color: #1b1f24;
}

.nct-dg-btn-primary:hover {
	background: #2a8ad4;
	border-color: #2a8ad4;
	color: #fff;
}

.nct-dg-btn-primary:disabled {
	opacity: .6;
	cursor: default;
}

.nct-dg-btn-secondary {
	background: #fff;
	color: #1b1f24;
	border-color: #c9d2de;
}

/* Hover-to-enlarge preview (same behaviour as the wizard's step-8 zoom) --- */
.nct-dg-zoom {
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	z-index: 10010;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	max-width: min(420px, calc(100vw - 48px));
	max-height: calc(100vh - 48px);
	padding: 20px 20px 16px;
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 30px 70px rgba(0, 0, 0, .4);
	font-family: 'Inter', system-ui, sans-serif;
}

.nct-dg-zoom[hidden] {
	display: none;
}

.nct-dg-zoom-img {
	display: block;
	max-width: 100%;
	max-height: calc(100vh - 200px);
	width: auto;
	height: auto;
	border-radius: 12px;
	object-fit: contain;
}

.nct-dg-zoom-name {
	margin: 0;
	font: 600 15px/20px inherit;
	text-align: center;
}

.nct-dg-zoom-close {
	position: absolute;
	top: 10px;
	right: 10px;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: 0;
	background: rgba(0, 0, 0, .06);
	font: 400 20px/1 inherit;
	cursor: pointer;
}

.nct-dg-zoom-close:hover {
	background: rgba(0, 0, 0, .12);
}

.nct-dg-zoom-select {
	flex: 0 0 auto;
	width: 100%;
	margin-top: 2px;
}

.nct-dg-zoom-select-active {
	background: #1a7f37;
	border-color: #1a7f37;
	cursor: default;
}

/* Modal ------------------------------------------------------------------ */
.nct-dg-modal-backdrop {
	position: fixed;
	inset: 0;
	z-index: 10000;
	background: rgba(10, 14, 20, .55);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.nct-dg-modal {
	position: relative;
	width: min(760px, 100%);
	max-height: calc(100vh - 48px);
	display: flex;
	flex-direction: column;
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 30px 70px rgba(0, 0, 0, .4);
	font-family: 'Inter', system-ui, sans-serif;
	color: #1b1f24;
}

.nct-dg-modal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 20px 24px 12px;
}

.nct-dg-modal-title {
	margin: 0;
	font: 700 20px/26px inherit;
	text-transform: none;
	letter-spacing: normal;
}

.nct-dg-modal-close {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: 0;
	background: rgba(0, 0, 0, .06);
	font: 400 20px/1 inherit;
	cursor: pointer;
}

.nct-dg-modal-intro {
	margin: 0;
	padding: 0 24px 12px;
	font-size: 13.5px;
	color: #6b7482;
}

.nct-dg-modal-body {
	padding: 0 24px;
	overflow: auto;
	flex: 1 1 auto;
}

.nct-dg-modal-foot {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	padding: 16px 24px 20px;
	border-top: 1px solid #e3e8ef;
}

/* Extra fields a modal may render above the gallery ("Add a team"). */
.nct-dg-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin: 0 0 12px;
	font: 600 13px/18px inherit;
}

.nct-dg-field input {
	font: 400 15px/22px inherit;
	padding: 10px 12px;
	border: 1px solid #c9d2de;
	border-radius: 10px;
}

.nct-dg-fields-row {
	display: grid;
	grid-template-columns: 1fr 140px;
	gap: 12px;
}

body.nct-dg-modal-open {
	overflow: hidden;
}

@media (max-width: 640px) {
	.nct-dg-fields-row {
		grid-template-columns: 1fr;
	}
	.nct-dg-modal-backdrop {
		padding: 12px;
	}
}
