/* ---------- Grid ---------- */

.osw-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: clamp(0.9rem, 2vw, 1.5rem);
	list-style: none;
	margin: 0;
	padding: 0;
}
@media (min-width: 640px)  { .osw-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .osw-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1280px) { .osw-grid { grid-template-columns: repeat(4, 1fr); } }
.osw-grid { gap: clamp(1.75rem, 3vw, 3rem); }
@media (min-width: 1800px) { .osw-grid { grid-template-columns: repeat(5, 1fr); } }

.osw-card {
	position: relative;
	overflow: hidden;
}
.osw-card a {
	display: block;
	position: relative;
	text-decoration: none;
	color: var(--osw-ink);
}

/* The frame. Container queries let the number scale with the card itself,
   so it stays proportional at every column count without breakpoint maths. */
.osw-card__stage {
	position: relative;
	container-type: inline-size;
	aspect-ratio: 4 / 5;
	/* Let the number sit whole; the card (not the stage) clips overflow. */
	overflow: visible;
	background: transparent;
}

/* Oversized ghost number. The <svg> itself (see oswh_ghost_number_svg() in
   functions.php + osw/ghost-glyphs.php) is built from the real Tiller-Heavy
   glyph outlines, not live text -- placement and the single-vs-double-digit
   target size are computed once in PHP from the font's actual vector data
   and baked into the SVG's own coordinates. The digits are plain filled
   shapes (fill="currentColor" on their <g>, same pattern as every icon svg
   elsewhere in this theme) with opacity carrying the "ghost" watermark look,
   rather than a hollow stroked outline -- an earlier stroke + clip-path +
   non-scaling-stroke version simply didn't render, for a reason that wasn't
   possible to isolate without a real browser to inspect.
   .osw-card__ghost is a plain <span> wrapper around the SVG, not the SVG
   itself: CSS mask-image support on replaced elements (svg, img, video) is
   inconsistent across browsers -- some hide the element entirely rather than
   falling back gracefully when the mask doesn't apply the way they expect.
   A plain span is what the fade was proven to work on before, so it stays
   the masked element; the SVG inside just fills it. */
.osw-card__ghost {
	display: block;
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	z-index: 1;
	color: var(--osw-ghost);
	opacity: var(--osw-ghost-op);
	pointer-events: none;

	/* Fade the bottom of the number out, matching the photo's own gradient so
	   it dissolves into the card roughly where the headshot does. */
	-webkit-mask-image: linear-gradient(180deg, #000 70%, transparent 94%);
	        mask-image: linear-gradient(180deg, #000 70%, transparent 94%);
}
.osw-card__ghost svg {
	display: block;
	width: 100%;
	height: 100%;
}

/* Headshot fills the card width edge-to-edge. object-fit contain never crops,
   so the full photo (shoulders included) shows; the left-aligned ghost number
   reads behind it. */
.osw-card__photo {
	position: absolute;
	left: 0;
	top: 0;
	transform: none;
	z-index: 2;
	width: 100%;
	height: 100%;
	object-fit: contain;
	object-position: bottom center;
	/* Fade out the bottom of the photo so it dissolves into the card above
	   the name. */
	-webkit-mask-image: linear-gradient(180deg, #000 80%, transparent 100%);
	        mask-image: linear-gradient(180deg, #000 80%, transparent 100%);
	transition: transform 0.35s ease;
}
.osw-card:hover .osw-card__photo { transform: scale(1.03); }

.osw-card__photo--empty {
	display: grid;
	place-items: center;
	background: var(--osw-panel);
	color: var(--osw-line);
	font-family: var(--osw-brand);
	font-size: 18cqw;
}

.osw-card__badge {
	position: absolute;
	right: 0.6rem;
	/* Sits low in the photo's fade zone, just above where the name begins. */
	bottom: 0.4rem;
	z-index: 5;
	width: 4rem;
	height: 4rem;
	display: grid;
	place-items: center;
	border: 4px solid var(--osw-red);
	border-radius: 999px;
	background: var(--osw-badge-bg);
	font-family: var(--osw-display);
	font-weight: 700;
	font-size: var(--osw-step-3);
	line-height: 1;
	color: var(--osw-badge-ink);
}

.osw-card__cap {
	position: absolute;
	top: 0.6rem;
	right: 0.75rem;
	z-index: 5;
	font-family: var(--osw-display);
	font-weight: 700;
	font-size: var(--osw-step-2);
	color: var(--osw-gold);
}

/* Committed-school logo, mirroring .osw-card__badge on the opposite corner.
   A plain white ring regardless of theme -- it sits on the photo's own fade
   zone, not the page ground, and a school's own colours vary too much to
   pick one accent that always reads. */
.osw-card__committed {
	position: absolute;
	left: 0.6rem;
	bottom: 0.4rem;
	z-index: 5;
	width: 4rem;
	height: 4rem;
	display: grid;
	place-items: center;
	border: 3px solid rgba(255,255,255,0.92);
	border-radius: 999px;
	background: #fff;
	overflow: hidden;
	box-shadow: 0 4px 10px rgba(0,0,0,0.35);
}
.osw-card__committed img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	padding: 0.35rem;
}

/* Name block sits just beneath the photo's fade, in its own space, free to
   grow to two lines without crowding anything. */
.osw-card__body {
	padding: 0.2rem 0.2rem 0;
}
.osw-card__first {
	font-family: var(--osw-display);
	font-weight: 600;
	font-size: var(--osw-step-3);
	letter-spacing: 0.01em;
	color: var(--osw-ink-mute);
	line-height: 1;
}
.osw-card__last {
	font-family: var(--osw-display);
	font-weight: 700;
	text-transform: uppercase;
	font-size: clamp(1.75rem, 11cqw, 2.7rem);
	letter-spacing: 0.005em;
	line-height: 0.95;
	margin-top: 0.12rem;
	text-wrap: balance;
}
/* Double-barrelled and long surnames step down rather than overflow. */
.osw-card__last--long { font-size: clamp(1.25rem, 7.6cqw, 1.9rem); }
.osw-card__last--xlong { font-size: clamp(1.1rem, 6.2cqw, 1.55rem); }
.osw-card__meta {
	font-family: var(--osw-display);
	text-transform: uppercase;
	letter-spacing: 0.02em;
	font-size: var(--osw-step-0);
	font-weight: 600;
	color: var(--osw-ink-mute);
	margin-top: 0.4rem;
	/* Wraps to a second line if the stats do not fit, rather than clipping. */
	line-height: 1.35;
}
.osw-card__meta i {
	color: var(--osw-red);
	font-style: normal;
	padding: 0 0.4rem;
}

/* ---------- List view ----------
   A row per player: circled number, thumbnail, name and details, chevron.
   This is also the default on phones, where a single-column grid of tall
   cards would be a lot of scrolling for a 20-player roster. */

.osw-grid--list { display: block; }

.osw-grid--list .osw-card + .osw-card { border-top: 1px solid var(--osw-line); }

.osw-grid--list .osw-card a {
	display: grid;
	grid-template-columns: 2.9rem 4.4rem 1fr;
	align-items: center;
	gap: 0.9rem;
	padding: 0.85rem 0.15rem;
}

/* Circled number */
.osw-grid--list .osw-card__listnum {
	display: grid;
	place-items: center;
	width: 2.9rem;
	height: 2.9rem;
	border: 2px solid var(--osw-red);
	border-radius: 999px;
	font-family: var(--osw-display);
	font-weight: 700;
	font-size: var(--osw-step-2);
	line-height: 1;
	color: var(--osw-ink);
}

/* Thumbnail. No panel background behind it any more -- object-fit: cover
   (overriding the grid view's `contain`) means the photo fills this box
   completely instead of letterboxing inside it, so there's no gap left for
   a background colour to show through as a "box" around a smaller photo. */
.osw-grid--list .osw-card__stage {
	aspect-ratio: 4 / 5;
	width: 100%;
	border-radius: 4px;
	overflow: hidden;
}
.osw-grid--list .osw-card__stage::after,
.osw-grid--list .osw-card__ghost,
.osw-grid--list .osw-card__badge,
.osw-grid--list .osw-card__cap,
.osw-grid--list .osw-card__committed { display: none; }

.osw-grid--list .osw-card__photo {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: top center;
}
.osw-grid--list .osw-card:hover .osw-card__photo { transform: none; }

/* Detail block */
.osw-grid--list .osw-card__body {
	position: static;
	padding: 0;
	min-width: 0;
}
.osw-grid--list .osw-card__first,
.osw-grid--list .osw-card__last {
	display: inline;
	font-size: var(--osw-step-2);
	line-height: 1.25;
	letter-spacing: 0;
}
.osw-grid--list .osw-card__first {
	font-weight: 400;
	text-transform: none;
	color: var(--osw-ink);
}
.osw-grid--list .osw-card__last {
	font-weight: 700;
	text-transform: uppercase;
}
.osw-grid--list .osw-card__meta {
	margin-top: 0.25rem;
	white-space: normal;
}
.osw-grid--list .osw-card__extra { display: block; }

.osw-grid--list .osw-card__chev { display: none; }

/* Grid view hides the pieces that only list and print need. */
.osw-card__listnum { display: none; }
.osw-card__extra { display: none; }
.osw-card__extra span {
	display: block;
	font-family: var(--osw-body);
	font-size: var(--osw-step-0);
	line-height: 1.4;
	color: var(--osw-ink-mute);
}
.osw-card__chev { display: none; }

/* Phones: list layout is the default, and the toggle still works. */
@media (max-width: 639px) {
	/* Mobile grid card: number centred and as large as fits, headshot centred
	   and padded so a ring of the number shows around it, shoulders uncropped. */
	.osw-grid:not(.osw-grid--list) { grid-template-columns: 1fr; gap: 1.5rem; }

	.osw-grid:not(.osw-grid--list) .osw-card__stage {
		aspect-ratio: 4 / 5;
		display: block;
		position: relative;
	}

	/* No mobile override needed for .osw-card__ghost any more -- it's an SVG
	   sized to 100%/100% of the stage with the placement baked into its own
	   coordinates server-side, so it scales correctly at any card size on its
	   own. */

	/* Headshot fills the card width. */
	.osw-grid:not(.osw-grid--list) .osw-card__photo {
		position: absolute;
		left: 0;
		top: 0;
		transform: none;
		width: 100%;
		height: 100%;
		margin: 0;
		object-fit: contain;
		object-position: bottom center;
	}

	/* Badge in the corner of the photo. */
	.osw-grid:not(.osw-grid--list) .osw-card__badge {
		right: 0.6rem;
		bottom: 0.6rem;
	}
	.osw-grid:not(.osw-grid--list) .osw-card__committed {
		left: 0.6rem;
		bottom: 0.6rem;
	}

	.osw-filters {
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
	}
	.osw-filters::-webkit-scrollbar { display: none; }

	.osw-grid--list .osw-card a {
		grid-template-columns: 2.6rem 3.9rem 1fr;
		gap: 0.75rem;
	}
	.osw-grid--list .osw-card__listnum {
		width: 2.6rem;
		height: 2.6rem;
		font-size: var(--osw-step-1);
	}
	.osw-grid--list .osw-card__first,
	.osw-grid--list .osw-card__last { font-size: var(--osw-step-1); }
	.osw-card__extra span { font-size: var(--osw-step-min); }
}

/* ---------- Empty ---------- */

.osw-empty {
	font-family: var(--osw-display);
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--osw-ink-mute);
	padding: 3rem 0;
}

/* ---------- Print ----------
   A coach-friendly team sheet: masthead with team, season, site and contact,
   then a compact row per player with a small headshot. */

@media print {
	.osw-header,
	.osw-footer,
	.osw-toolbar,
	.osw-switch,
	.osw-card__chev { display: none !important; }

	body {
		background: #fff !important;
		background-image: none !important;
		color: #000;
	}

	.osw-print-head {
		display: block !important;
		margin-bottom: 1rem;
		padding-bottom: 0.75rem;
		border-bottom: 2px solid #000;
	}
	.osw-print-head__team {
		font-family: var(--osw-display);
		font-size: 20pt;
		font-weight: 700;
		text-transform: uppercase;
		line-height: 1.1;
	}
	.osw-print-head__meta {
		font-family: var(--osw-body);
		font-size: 9pt;
		color: #444;
		margin-top: 0.35rem;
		line-height: 1.5;
	}

	.osw-roster__head { display: none; }

	.osw-grid { display: block !important; }

	.osw-grid .osw-card {
		break-inside: avoid;
		page-break-inside: avoid;
		border-top: none;
	}
	.osw-grid .osw-card + .osw-card { border-top: 1px solid #ccc; }

	.osw-grid .osw-card a {
		display: grid !important;
		grid-template-columns: 2.2rem 2.6rem 1fr;
		gap: 0.6rem;
		align-items: center;
		padding: 0.3rem 0 !important;
		color: #000;
	}

	/* Keep a small headshot -- coaches use these to put names to faces. */
	.osw-card__stage {
		display: block !important;
		position: relative;
		aspect-ratio: 4 / 5;
		width: 100%;
		overflow: hidden;
		border-radius: 2px;
		background: #eee;
	}
	.osw-card__stage::after,
	.osw-card__ghost,
	.osw-card__badge,
	.osw-card__cap,
	.osw-card__committed { display: none !important; }
	.osw-card__photo {
		position: absolute !important;
		inset: 0;
		width: 100% !important;
		height: 100% !important;
		object-fit: cover;
		object-position: top center;
		transform: none !important;
	}

	.osw-card__listnum {
		display: grid !important;
		place-items: center;
		width: auto; height: auto;
		border: 0 !important;
		font-family: var(--osw-display);
		font-weight: 700;
		font-size: 12pt;
		color: #000 !important;
	}

	.osw-card__body {
		position: static !important;
		padding: 0 !important;
		display: block;
	}
	.osw-card__first,
	.osw-card__last {
		display: inline !important;
		font-size: 11pt;
		color: #000 !important;
	}
	.osw-card__first { font-weight: 400; text-transform: none; }
	.osw-card__last  { font-weight: 700; text-transform: uppercase; }
	.osw-card__meta {
		display: block;
		font-size: 8.5pt;
		color: #333 !important;
		margin-top: 0.1rem;
	}
	.osw-card__meta i { color: #999; }
	.osw-card__extra { display: block !important; }
	.osw-card__extra span { font-size: 8pt; color: #555 !important; }

	@page { margin: 1.2cm; }
}

/* ---------- Staff ----------
   Coaches, managers and trainers, shown beneath the players. A calmer card
   than a player's: circular photo, name, role and an optional email. No
   jersey number, no stat line. */

.osw-staff {
	margin-top: clamp(2.5rem, 6vw, 4.5rem);
}
.osw-staff__title {
	font-family: var(--osw-condensed);
	text-transform: uppercase;
	letter-spacing: 0.04em;
	font-size: var(--osw-step-3);
	color: var(--osw-ink);
	margin: 0 0 clamp(1.25rem, 3vw, 2rem);
	padding-bottom: 0.6rem;
	border-bottom: 2px solid var(--osw-red);
	display: inline-block;
}
.osw-staff__grid {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: clamp(1.25rem, 3vw, 2rem);
	grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 640px)  { .osw-staff__grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .osw-staff__grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1280px) { .osw-staff__grid { grid-template-columns: repeat(5, 1fr); } }

.osw-staff__card {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 0.85rem;
}

.osw-staff__photo {
	width: clamp(96px, 26cqw, 150px);
	aspect-ratio: 1;
	border-radius: 999px;
	overflow: hidden;
	background: var(--osw-panel);
	border: 3px solid var(--osw-line);
}
.osw-staff__photo img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: top center;
}
.osw-staff__photo--empty {
	display: grid;
	place-items: center;
}
.osw-staff__photo--empty span {
	font-family: var(--osw-brand);
	font-weight: 800;
	font-size: 2.5rem;
	color: var(--osw-ink-mute);
}

.osw-staff__name {
	font-family: var(--osw-condensed);
	text-transform: uppercase;
	font-weight: 700;
	font-size: var(--osw-step-2);
	line-height: 1.05;
	color: var(--osw-ink);
}
.osw-staff__role {
	font-family: var(--osw-condensed);
	text-transform: uppercase;
	letter-spacing: 0.05em;
	font-size: var(--osw-step-0);
	font-weight: 600;
	color: var(--osw-red);
	margin-top: 0.15rem;
}
.osw-staff__email {
	font-family: var(--osw-body);
	font-size: var(--osw-step-min);
	color: var(--osw-ink-mute);
	text-decoration: none;
	word-break: break-word;
	margin-top: 0.1rem;
}
.osw-staff__email:hover { color: var(--osw-red); }

/* Staff show on the printed sheet too, compact. */
@media print {
	.osw-staff__photo { border-color: #ccc; }
	.osw-staff__role  { color: #000; }
}
