/**
 * GSL Salinity Graph — front end.
 * All colours come from inline custom properties set by the shortcode.
 */

.gsl-card {
	--gsl-card-bg: #0f3a4a;
	--gsl-bar: #dde9ee;
	--gsl-accent: #f5e400;
	--gsl-ink: #ffffff;
	--gsl-chart-h: 78px;
	--gsl-gap: 5px;

	position: relative;
	box-sizing: border-box;
	max-width: 722px;
	margin: 0 0 1.5rem;
	padding: 0;
	overflow: hidden;
	background: var(--gsl-card-bg);
	border-radius: 14px;
	color: var(--gsl-ink);
	font-family: inherit;
	-webkit-font-smoothing: antialiased;
}

.gsl-card *,
.gsl-card *::before,
.gsl-card *::after {
	box-sizing: border-box;
}

/* ---------- Hero image ---------- */

.gsl-card__media {
	position: relative;
	aspect-ratio: 722 / 213;
	overflow: hidden;
	background: #16323d;
}

.gsl-card__image {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	object-fit: cover;
}

.gsl-card__badge {
	position: absolute;
	bottom: 16px;
	left: 16px;
	padding: 6px 13px;
	background: #ffffff;
	border-radius: 999px;
	color: #1b2c34;
	font-size: 12.5px;
	font-weight: 500;
	line-height: 1.2;
	letter-spacing: 0.005em;
}

/* ---------- Readout ---------- */

.gsl-card__body {
	padding: 22px 24px 24px;
}

.gsl-card__badgeline {
	margin: 0 0 14px;
}

.gsl-card__badge--inline {
	position: static;
	display: inline-block;
}

.gsl-card__label {
	margin: 0 0 10px;
	color: rgba(255, 255, 255, 0.92);
	font-size: 12.5px;
	font-weight: 600;
	letter-spacing: 0.09em;
	line-height: 1.2;
	text-transform: uppercase;
}

.gsl-card__readout {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 4px 10px;
	margin: 0;
	line-height: 1;
}

.gsl-card__value {
	font-size: 34px;
	font-weight: 700;
	letter-spacing: -0.015em;
	line-height: 1;
}

.gsl-card__unit {
	color: rgba(255, 255, 255, 0.82);
	font-size: 15px;
	font-weight: 500;
}

.gsl-card__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 2px 8px;
	margin: 9px 0 0;
	color: rgba(255, 255, 255, 0.62);
	font-size: 12.5px;
	line-height: 1.35;
}

.gsl-card__site {
	color: rgba(255, 255, 255, 0.48);
	font-size: 12px;
}

/* Separators are drawn between siblings, so hiding the site or the percentage
   never leaves an orphaned dot behind. */
.gsl-card__meta > * + *::before {
	content: "·";
	margin-right: 8px;
	color: rgba(255, 255, 255, 0.32);
}

/* ---------- Readout ---------- */

/* Secondary to the g/L figure by design: the measured number stays the headline. */
.gsl-card__readout .gsl-card__derived {
	padding: 4px 9px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.11);
	color: rgba(255, 255, 255, 0.9);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.005em;
	white-space: nowrap;
}

.gsl-card__meta .gsl-card__derived {
	color: rgba(255, 255, 255, 0.82);
}

/* ---------- Bars and line ---------- */

.gsl-chart {
	margin-top: 18px;
}

.gsl-chart__bars {
	display: flex;
	align-items: flex-end;
	gap: var(--gsl-gap);
	height: var(--gsl-chart-h);
	margin: 0;
	padding: 0;
	list-style: none;
}

.gsl-chart__item {
	display: flex;
	position: relative;
	flex: 1 1 0;
	align-items: flex-end;
	min-width: 0;
	height: 100%;
	margin: 0;
	padding: 0;
	list-style: none;
}

.gsl-chart__bar {
	display: block;
	width: 100%;
	height: var(--gsl-h, 50%);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 5px;
	background: var(--gsl-bar);
	box-shadow: none;
	cursor: pointer;
	transition: background-color 140ms ease, transform 140ms ease;
	appearance: none;
}

.gsl-chart__bar.is-latest {
	background: var(--gsl-accent);
}

.gsl-chart__bar:hover,
.gsl-chart__bar:focus-visible {
	background: #ffffff;
	outline: none;
	transform: scaleX(1.08);
}

.gsl-chart__bar.is-latest:hover,
.gsl-chart__bar.is-latest:focus-visible {
	background: var(--gsl-accent);
	filter: brightness(1.12);
}

.gsl-chart__bar:focus-visible {
	box-shadow: 0 0 0 2px var(--gsl-card-bg), 0 0 0 4px rgba(255, 255, 255, 0.85);
}

/* ---------- Tooltip ---------- */

.gsl-chart__tip {
	display: block;
	position: absolute;
	bottom: calc(100% + 10px);
	left: 50%;
	z-index: 5;
	min-width: 118px;
	padding: 9px 11px;
	transform: translateX(calc(-50% + var(--gsl-tip-shift, 0px))) translateY(4px);
	transition: opacity 130ms ease, transform 130ms ease;
	border-radius: 8px;
	opacity: 0;
	background: #ffffff;
	box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28);
	color: #12333f;
	font-size: 12px;
	line-height: 1.35;
	text-align: left;
	white-space: nowrap;
	pointer-events: none;
}

.gsl-chart__bar:hover .gsl-chart__tip,
.gsl-chart__bar:focus .gsl-chart__tip,
.gsl-chart__bar:focus-visible .gsl-chart__tip {
	transform: translateX(calc(-50% + var(--gsl-tip-shift, 0px))) translateY(0);
	opacity: 1;
}

.gsl-chart__tip::after {
	content: "";
	position: absolute;
	top: 100%;
	left: calc(50% - 5px - var(--gsl-tip-shift, 0px));
	width: 0;
	height: 0;
	border-top: 5px solid #ffffff;
	border-right: 5px solid transparent;
	border-left: 5px solid transparent;
}

.gsl-chart__tip-period {
	display: block;
	color: #5b7683;
	font-size: 11px;
	font-weight: 500;
	letter-spacing: 0.03em;
	text-transform: uppercase;
}

.gsl-chart__tip-value {
	display: block;
	margin-top: 2px;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: -0.01em;
}

.gsl-chart__tip-pct {
	display: block;
	margin-top: 3px;
	padding-top: 3px;
	border-top: 1px solid rgba(18, 51, 63, 0.12);
	color: #12333f;
	font-size: 12px;
	font-weight: 600;
}

.gsl-chart__tip-site {
	display: block;
	margin-top: 3px;
	max-width: 190px;
	color: #5b7683;
	font-size: 11px;
	white-space: normal;
}

/* ---------- Axis and caption ---------- */

.gsl-chart__axis {
	display: flex;
	justify-content: space-between;
	margin-top: 13px;
	color: rgba(255, 255, 255, 0.7);
	font-size: 12.5px;
}

.gsl-card__source {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 4px 12px;
	margin: 0;
	padding: 0 24px 20px;
	color: rgba(255, 255, 255, 0.42);
	font-size: 11.5px;
	line-height: 1.5;
	text-align: left;
}

/*
 * Themes commonly style links via .entry-content a or similar, which outranks a
 * single class and can render these in a dark link colour on a dark card. These
 * selectors are deliberately specific, and forced, so the caption stays legible
 * whatever the theme does.
 */
.gsl-card figcaption.gsl-card__source a,
.gsl-card figcaption.gsl-card__source a:link,
.gsl-card figcaption.gsl-card__source a:visited,
.gsl-card .gsl-card__source .gsl-card__source-link {
	color: #ffffff !important;
	opacity: 0.82;
	text-decoration: underline;
	text-decoration-color: rgba(255, 255, 255, 0.45);
	text-underline-offset: 2px;
	box-shadow: none;
}

.gsl-card figcaption.gsl-card__source a:hover,
.gsl-card figcaption.gsl-card__source a:focus,
.gsl-card figcaption.gsl-card__source a:active {
	color: #ffffff !important;
	opacity: 1;
	text-decoration-color: #ffffff;
}

.gsl-card figcaption.gsl-card__source a:focus-visible {
	outline: 2px solid rgba(255, 255, 255, 0.8);
	outline-offset: 2px;
}

.gsl-card__axisnote {
	color: rgba(255, 255, 255, 0.38);
}

/* ---------- States ---------- */

.gsl-card--empty {
	padding: 22px 24px;
	color: rgba(255, 255, 255, 0.75);
	font-size: 13px;
}

.gsl-card--empty p {
	margin: 0;
}

.gsl-sr-only {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	border: 0;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ---------- Responsive ---------- */

@media (max-width: 600px) {
	.gsl-card {
		--gsl-chart-h: 62px;
		--gsl-gap: 3px;
		border-radius: 12px;
	}

	.gsl-card__body {
		padding: 18px 16px 20px;
	}

	.gsl-card__source {
		padding: 0 16px 16px;
	}

	.gsl-card__value {
		font-size: 28px;
	}

	.gsl-card__readout .gsl-card__derived {
		padding: 3px 8px;
		font-size: 12px;
	}

	.gsl-card__meta {
		gap: 1px 6px;
	}

	.gsl-card__meta > * + *::before {
		margin-right: 6px;
	}

	.gsl-chart__bar {
		border-radius: 3px;
	}

	.gsl-chart__tip {
		min-width: 100px;
		padding: 7px 9px;
	}

	.gsl-card__source {
		gap: 2px 10px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.gsl-chart__bar,
	.gsl-chart__tip {
		transition: none;
	}

	.gsl-chart__bar:hover,
	.gsl-chart__bar:focus-visible {
		transform: none;
	}
}
