/* Sailing Flow — responsive, self-contained frontend styles.
 *
 * The output adapts to the width of its CONTAINER (e.g. a Divi column), not the
 * browser viewport, using CSS container queries. In a narrow column tables
 * collapse into stacked cards; the font size scales with the column via
 * container-query units (cqi). Older browsers fall back to fixed sizes plus a
 * horizontal scroll, so nothing ever overflows its column.
 */

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

.wpsf {
	/* Establish a query container so children can respond to this width. */
	container-type: inline-size;
	container-name: wpsf;
	margin: 0 0 1.5rem;
	max-width: 100%;
	color: inherit;
	line-height: 1.45;
	overflow-wrap: anywhere;
}

.wpsf-title {
	text-align: center;
	margin: 0 0 0.75rem;
	line-height: 1.2;
	font-size: 1.4rem;
	font-size: clamp( 1.05rem, 4.2cqi, 1.6rem );
}

.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-weight: 700;
	font-size: 1.1rem;
	font-size: clamp( 0.98rem, 3cqi, 1.2rem );
}

/* Table wrapper. Horizontal scroll only acts as a last-resort safety net for
   browsers without container-query support; with cards it is never triggered. */
.wpsf-scroll {
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	margin: 0 0 1rem;
}

/* A flat table never needs horizontal scrolling, so its wrapper can overflow
   visibly — letting a hover tooltip (e.g. a cancelled race's notes) escape the
   panel instead of being clipped by the scroll box's overflow. */
.wpsf-scroll-flat {
	overflow: visible;
}

.wpsf-table {
	width: 100%;
	border-collapse: collapse;
	margin: 0;
	background: #fff;
	font-size: 14px;
	font-size: clamp( 11.5px, 1.3cqi + 6px, 15px );
}

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

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

.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;
}

/* Boat name stands out so it is easy to find — most useful in the stacked
   mobile card view, but harmless in the wide table too. */
.wpsf-table td.wpsf-boat-cell {
	font-weight: 700;
}

.wpsf-keyvalue th {
	width: 34%;
	white-space: nowrap;
}

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

/* Flat tables (e.g. schedule, scratch sheet) stay one row per record at any
   width; cells wrap rather than forcing a card layout or horizontal scroll. */
.wpsf-flat th,
.wpsf-flat td {
	white-space: normal;
}

.wpsf-scratch-table td:last-child,
.wpsf-scratch-table th:last-child {
	width: 5rem;
	text-align: right;
}

/* Boat-detail tooltip on the scratch sheet. */
.wpsf-tip {
	position: relative;
	cursor: help;
	border-bottom: 1px dotted currentColor;
	outline: none;
}

.wpsf-tip-bubble {
	position: absolute;
	left: 0;
	top: calc( 100% + 6px );
	z-index: 30;
	display: none;
	min-width: 12rem;
	max-width: 16rem;
	padding: 0.5em 0.7em;
	background: #1f2937;
	color: #fff;
	border-radius: 6px;
	font-size: 0.85em;
	font-weight: 400;
	line-height: 1.45;
	white-space: normal;
	/* Keep the bubble legible even inside a struck-through .wpsf-cancelled row. */
	text-decoration: none;
	text-align: left;
	box-shadow: 0 6px 18px rgba( 0, 0, 0, 0.22 );
}

.wpsf-tip-bubble::before {
	content: "";
	position: absolute;
	left: 1rem;
	bottom: 100%;
	border: 6px solid transparent;
	border-bottom-color: #1f2937;
}

.wpsf-tip-row {
	display: block;
}

.wpsf-tip:hover .wpsf-tip-bubble,
.wpsf-tip:focus .wpsf-tip-bubble,
.wpsf-tip:focus-within .wpsf-tip-bubble {
	display: block;
}

.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;
}

.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;
}

.wpsf-series-title {
	line-height: 1.25;
	font-size: 1.5rem;
	font-size: clamp( 1.2rem, 5cqi, 1.8rem );
}

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

/* Breadcrumbs */
.wpsf-breadcrumbs {
	margin: 0 0 1rem;
	font-size: 0.9em;
	line-height: 1.5;
	color: #6b7280;
}

.wpsf-breadcrumbs a {
	color: #4b5b8c;
	text-decoration: none;
}

.wpsf-breadcrumbs a:hover {
	text-decoration: underline;
}

.wpsf-breadcrumbs .wpsf-current {
	color: #374151;
	font-weight: 600;
}

.wpsf-bc-sep {
	color: #b6bcc4;
	margin: 0 0.35em;
}

/* --- Standings grids stay tabular so totals can be scanned down a column.
       The Place and Boat columns are frozen on the left while score columns
       scroll horizontally (necessary for a season with many cups). --- */
.wpsf-standings-grid th:first-child,
.wpsf-standings-grid td:first-child {
	position: sticky;
	left: 0;
	z-index: 1;
	width: 3.25rem;
	min-width: 3.25rem;
	text-align: center;
}

.wpsf-standings-grid th:nth-child( 2 ),
.wpsf-standings-grid td:nth-child( 2 ) {
	position: sticky;
	left: 3.25rem;
	z-index: 1;
	min-width: 8rem;
	box-shadow: 2px 0 0 rgba( 0, 0, 0, 0.05 );
}

.wpsf-standings-grid thead th {
	z-index: 2;
}

.wpsf-standings-grid th:last-child,
.wpsf-standings-grid td:last-child {
	font-weight: 700;
}

.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;
}

/* === Card layout, driven by the CONTAINER width === */

/* Simple data tables collapse to cards; standings grids stay tables and scroll. */
@container wpsf ( max-width: 560px ) {
	/* Card-collapsing tables no longer need the scroll box. The standings grid
	   (.wpsf-scroll-grid) is excluded: it stays a table, so it keeps its bordered,
	   horizontally scrollable panel — otherwise the regatta columns get crammed
	   together and clipped on a phone. */
	.wpsf-scroll:not( .wpsf-scroll-grid ) {
		border: 0;
		border-radius: 0;
		overflow-x: visible;
	}

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

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

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

	/* Shade every other boat card so the boundary between boats is obvious when
	   the table is stacked vertically. */
	.wpsf-table:not( .wpsf-standings-grid ):not( .wpsf-keyvalue ):not( .wpsf-flat ) tbody tr:nth-child( even ) {
		background: #f3f4f6;
	}

	.wpsf-table:not( .wpsf-standings-grid ):not( .wpsf-keyvalue ):not( .wpsf-flat ) tbody 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 ):not( .wpsf-flat ) tbody td::before {
		content: attr( data-label );
		font-weight: 600;
		color: #6b7280;
	}
}
