/* WP SailingFlow — responsive, self-contained frontend styles.
   Designed to behave inside constrained theme/page-builder columns (e.g. Divi):
   tables never overflow their container — they scroll horizontally instead — and
   typography scales with the available space. */

.wpsf,
.wpsf * {
	box-sizing: border-box;
}

.wpsf {
	margin: 0 0 1.5rem;
	max-width: 100%;
	color: inherit;
	font-size: clamp( 13px, 0.95rem, 16px );
	line-height: 1.45;
	overflow-wrap: anywhere;
}

.wpsf-title {
	text-align: center;
	margin: 0 0 0.75rem;
	font-size: clamp( 1.1rem, 1.1rem + 0.6vw, 1.6rem );
	line-height: 1.2;
}

.wpsf-subtitle {
	text-align: center;
	margin: -0.4rem 0 1rem;
	color: #6b7280;
	font-size: 0.95em;
}

.wpsf-division {
	margin: 1.25rem 0 0.4rem;
	font-size: clamp( 1rem, 1rem + 0.3vw, 1.2rem );
	font-weight: 700;
}

/* Horizontal-scroll wrapper: keeps any table inside its column. */
.wpsf-scroll {
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	margin: 0 0 1rem;
}

.wpsf-table {
	width: 100%;
	border-collapse: collapse;
	margin: 0;
	background: #fff;
}

.wpsf-table th,
.wpsf-table td {
	padding: 0.5rem 0.7rem;
	text-align: left;
	border-bottom: 1px solid #eceef0;
	white-space: nowrap;
}

.wpsf-table thead th {
	background: #f1f3f5;
	font-weight: 700;
	color: #374151;
	position: sticky;
	top: 0;
}

.wpsf-table tbody tr:nth-child( even ) {
	background: #f7f8f9;
}

.wpsf-table tbody tr:hover {
	background: #eef4fb;
}

.wpsf-table tbody tr:last-child td {
	border-bottom: 0;
}

/* Key/value (race detail) table: let values wrap. */
.wpsf-keyvalue th {
	width: 34%;
	white-space: nowrap;
}

.wpsf-keyvalue td {
	white-space: normal;
}

.wpsf-muted {
	color: #9099a3;
	font-size: 0.9em;
}

.wpsf-cancelled {
	color: #9099a3;
	text-decoration: line-through;
}

.wpsf-tag {
	display: inline-block;
	padding: 0.05em 0.5em;
	border-radius: 999px;
	background: #e5e7eb;
	color: #4b5563;
	font-size: 0.72em;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	vertical-align: middle;
}

.wpsf-thrown {
	color: #9099a3;
}

.wpsf-total {
	font-weight: 700;
}

.wpsf-note {
	font-size: 0.88em;
	color: #6b7280;
	margin: 0 0 0.75rem;
}

/* Header + action buttons on the race-results view. */
.wpsf-results-head {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1rem;
	align-items: center;
	justify-content: space-between;
}

.wpsf-results-head .wpsf-title {
	text-align: left;
	margin: 0;
}

.wpsf-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.wpsf-button {
	display: inline-block;
	background-color: #c47e27;
	color: #fff !important;
	font-weight: 600;
	text-decoration: none;
	border-radius: 6px;
	padding: 0.45em 0.9em;
	font-size: 0.92em;
	line-height: 1.3;
	transition: background-color 0.15s ease;
}

.wpsf-button:hover {
	background-color: #a9690f;
	color: #fff !important;
}

.wpsf-button-alt {
	background-color: #4b5b8c;
}

.wpsf-button-alt:hover {
	background-color: #3a4870;
}

/* Series-title breadcrumb. */
.wpsf-series-title {
	font-size: clamp( 1.2rem, 1.1rem + 0.8vw, 1.8rem );
	line-height: 1.25;
}

.wpsf-series-sep {
	color: #b6bcc4;
	margin: 0 0.3em;
}

/* --- Wide standings grids: sticky Rank + Boat columns while cups/races scroll. */
.wpsf-standings-grid {
	--wpsf-rank-w: 3rem;
}

.wpsf-standings-grid th:first-child,
.wpsf-standings-grid td:first-child {
	position: sticky;
	left: 0;
	min-width: var( --wpsf-rank-w );
	z-index: 1;
}

.wpsf-standings-grid th:nth-child( 2 ),
.wpsf-standings-grid td:nth-child( 2 ) {
	position: sticky;
	left: var( --wpsf-rank-w );
	z-index: 1;
	box-shadow: 2px 0 0 rgba( 0, 0, 0, 0.05 );
}

/* Opaque backgrounds so the frozen columns hide content scrolling beneath. */
.wpsf-standings-grid thead th {
	z-index: 2;
}

.wpsf-standings-grid tbody td:first-child,
.wpsf-standings-grid tbody td:nth-child( 2 ) {
	background: #fff;
}

.wpsf-standings-grid tbody tr:nth-child( even ) td:first-child,
.wpsf-standings-grid tbody tr:nth-child( even ) td:nth-child( 2 ) {
	background: #f7f8f9;
}

.wpsf-standings-grid tbody tr:hover td:first-child,
.wpsf-standings-grid tbody tr:hover td:nth-child( 2 ) {
	background: #eef4fb;
}

/*
 * Small screens: collapse plain data tables (schedule, scratch sheet, single
 * race results) into stacked cards. Standings grids keep their tabular layout
 * and scroll horizontally instead.
 */
@media screen and ( max-width: 600px ) {
	.wpsf-scroll {
		border: 0;
		border-radius: 0;
		overflow-x: visible;
	}

	.wpsf-table:not( .wpsf-standings-grid ):not( .wpsf-keyvalue ) {
		background: transparent;
	}

	.wpsf-table:not( .wpsf-standings-grid ):not( .wpsf-keyvalue ) thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect( 0 0 0 0 );
	}

	.wpsf-table:not( .wpsf-standings-grid ):not( .wpsf-keyvalue ) tr {
		display: block;
		margin: 0 0 0.75rem;
		border: 1px solid #e5e7eb;
		border-radius: 8px;
		overflow: hidden;
		background: #fff;
	}

	.wpsf-table:not( .wpsf-standings-grid ):not( .wpsf-keyvalue ) td {
		display: flex;
		justify-content: space-between;
		gap: 1rem;
		white-space: normal;
		border-bottom: 1px solid #f0f1f3;
	}

	.wpsf-table:not( .wpsf-standings-grid ):not( .wpsf-keyvalue ) td::before {
		content: attr( data-label );
		font-weight: 600;
		color: #6b7280;
	}

	/* Re-enable horizontal scroll specifically for the wide grids on mobile. */
	.wpsf-standings-grid {
		display: table;
	}

	.wpsf-cup-standings .wpsf-scroll,
	.wpsf-standings .wpsf-scroll {
		overflow-x: auto;
		border: 1px solid #e5e7eb;
		border-radius: 8px;
	}
}
