/* Cards, stats strip, navy timeline panel — see design-system.md */

.card-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 1px;
	background: var(--color-line);
}

.card {
	display: block;
	background: var(--color-white);
	border-top: 2px solid var(--color-navy);
	padding: var(--sp-3) var(--sp-2);
	text-decoration: none;
	color: inherit;
	transition: background-color 0.18s ease;
}

a.card:hover {
	background: var(--color-paper);
}

/* The 2px grid gap and neighbouring cards would clip an outside ring */
a.card:focus-visible {
	outline-offset: -4px;
}

.card__tag {
	margin-bottom: var(--sp-1);
}

.card__title {
	font-family: var(--font-heading);
	font-weight: 600;
	font-size: 19px;
	text-transform: var(--heading-transform);
	letter-spacing: var(--heading-letter-spacing);
	color: var(--color-ink);
	margin: 0 0 var(--sp-1);
}

.card__description {
	font-size: 15px;
	color: var(--color-steel);
	margin: 0;
}

/* The hairline background shows through empty cells, so a short
   last row stretches its final card to the end of the row. */
@media (min-width: 761px) {
	.card-grid > :last-child:nth-child(3n + 1) {
		grid-column: span 3;
	}

	.card-grid > :last-child:nth-child(3n + 2) {
		grid-column: span 2;
	}

	/* Exactly four cards: 2 × 2 instead of 3 + one full-width card */
	.card-grid:has(> :nth-child(4):last-child) {
		grid-template-columns: repeat(2, 1fr);
	}

	.card-grid:has(> :nth-child(4):last-child) > :last-child {
		grid-column: auto;
	}

	/* Exactly two cards: two equal halves */
	.card-grid:has(> :nth-child(2):last-child) {
		grid-template-columns: repeat(2, 1fr);
	}

	.card-grid:has(> :nth-child(2):last-child) > :last-child {
		grid-column: auto;
	}
}

@media (max-width: 760px) {
	.card-grid {
		grid-template-columns: 1fr;
	}
}

/* Stats strip */
.stats-strip {
	background: var(--color-paper);
	border-top: 1px solid var(--color-line);
	border-bottom: 1px solid var(--color-line);
}

.stats-strip__grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
}

/* Three stats: three equal columns, no empty fourth. */
@media (min-width: 761px) {
	.stats-strip__grid:has(> .stat:nth-child(3):last-child) {
		grid-template-columns: repeat(3, 1fr);
	}
}

.stat {
	text-align: center;
	padding: var(--sp-4) var(--sp-2);
	border-left: 1px solid var(--color-line);
}

.stat:first-child {
	border-left: none;
}

/* Five or six stats: 3 x 2 instead of leaving orphans on a second row. */
@media (min-width: 761px) {
	.stats-strip__grid:has(> .stat:nth-child(5)) {
		grid-template-columns: repeat(3, 1fr);
	}

	.stats-strip__grid:has(> .stat:nth-child(5)) > .stat:nth-child(3n + 1) {
		border-left: none;
	}

	.stats-strip__grid:has(> .stat:nth-child(5)) > .stat:nth-child(-n + 3) {
		border-bottom: 1px solid var(--color-line);
	}
}

.stat__number {
	display: block;
	font-family: var(--font-display);
	font-weight: 700;
	font-size: 38px;
	color: var(--color-red);
	font-variant-numeric: tabular-nums;
}

.stat__label {
	display: block;
	font-size: 13.5px;
	color: var(--color-steel);
	margin-top: var(--sp-1);
}

@media (max-width: 760px) {
	.stats-strip__grid {
		grid-template-columns: repeat(2, 1fr);
	}

	.stat:nth-child(2n + 1) {
		border-left: none;
	}

	.stat:not(:nth-last-child(-n + 2)) {
		border-bottom: 1px solid var(--color-line);
	}
}

/* Navy timeline / legacy panel */
.timeline-panel {
	background: var(--color-navy-deep);
	background-image: repeating-linear-gradient(
			0deg,
			var(--grid-rule-line) 0,
			var(--grid-rule-line) 1px,
			transparent 1px,
			transparent var(--grid-rule-size)
		),
		repeating-linear-gradient(
			90deg,
			var(--grid-rule-line) 0,
			var(--grid-rule-line) 1px,
			transparent 1px,
			transparent var(--grid-rule-size)
		);
	padding-block: var(--sp-6);
}

.timeline-panel__row {
	display: flex;
	align-items: baseline;
	gap: var(--sp-3);
	padding-block: var(--sp-2);
	border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.timeline-panel__row:last-child {
	border-bottom: none;
}

.timeline-panel__year {
	flex: 0 0 auto;
	width: 88px;
	font-family: var(--font-heading);
	font-size: 28px;
	line-height: 1;
	font-weight: 700;
	color: var(--color-red);
	font-variant-numeric: tabular-nums;
}

.timeline-panel__label {
	color: var(--color-white);
}

@media (max-width: 760px) {
	.timeline-panel__row {
		flex-direction: column;
		gap: var(--sp-1);
	}
}
