/*
 * History page: the history of football as one vertical timeline of dated cards
 * (app/js/history.js). Mobile first, designed at 390 px wide. The document itself scrolls: no
 * ancestor of the filter band or of the rail may set overflow, or position: sticky stops working.
 */

.history-page {
	display: flex;
	flex-direction: column;
	min-height: 100dvh;
}

/* Head: eyebrow and title on navy. */

.history__head {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 24px max(16px, calc((100% - 720px) / 2 + 16px)) 20px;
	background: var(--ink);
	color: #fff;
}

.history__eyebrow {
	margin: 0;
	color: var(--accent);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.history__title {
	margin: 0;
	font-size: 28px;
	font-weight: 800;
	line-height: 1.1;
	text-wrap: balance;
}

/* Box leading to the game, under the title. */

.history__game {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 10px;
	padding: 10px 10px 10px 14px;
	border: 2px solid var(--accent);
	border-radius: var(--radius);
	color: #fff;
	text-decoration: none;
}

.history__game-text {
	flex: 1;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.35;
}

.history__game-button {
	flex: none;
	padding: 8px 16px;
	border-radius: 999px;
	background: var(--accent);
	color: var(--ink);
	font-size: 14px;
	font-weight: 800;
}

.history__game:hover .history__game-button {
	background: #fff;
}

.history__game:focus-visible {
	outline: 3px solid var(--accent);
	outline-offset: 2px;
}

/* Filter band: stays at the top of the screen. Its height is written by app/js/history.js in
   --history-band, for the cards and the rail that stop under it. */

.history__filters {
	position: sticky;
	top: 0;
	z-index: 5;
	display: grid;
	grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.2fr) minmax(0, 1fr);
	gap: 6px;
	padding: 8px max(12px, calc((100% - 720px) / 2 + 12px));
	background: var(--accent);
}

/* A filter is a white card: its name at the top, the chosen value under it, and the arrow in a
   round badge. The native list stays on top of everything, so a tap anywhere opens it; the name
   and the badge let the taps through. Once a value is chosen (is-active, set by history.js), the
   card turns navy, with its name and its badge in yellow. */
.history__filter {
	position: relative;
	min-width: 0;
	border-radius: 14px;
	background: var(--surface);
	box-shadow: 0 1px 2px rgba(11, 31, 58, 0.12), 0 4px 12px rgba(11, 31, 58, 0.1);
	transition: background-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.history__filter-label {
	position: absolute;
	top: 8px;
	right: 8px;
	left: 10px;
	overflow: hidden;
	color: var(--ink-soft);
	font-size: 10px;
	font-weight: 800;
	letter-spacing: 0.08em;
	line-height: 1;
	text-overflow: ellipsis;
	text-transform: uppercase;
	white-space: nowrap;
	pointer-events: none;
	transition: color 0.15s;
}

/* Round badge, then the arrow drawn over it. */
.history__filter::before,
.history__filter::after {
	content: "";
	position: absolute;
	top: 22px;
	right: 6px;
	width: 20px;
	height: 20px;
	pointer-events: none;
}

.history__filter::before {
	border-radius: 50%;
	background: var(--bg);
	transition: background-color 0.15s, transform 0.15s;
}

.history__filter::after {
	background: var(--ink);
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Cpath d='M7 9.5l4 4 4-4' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Cpath d='M7 9.5l4 4 4-4' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* 16px: iOS zooms on smaller fields. */
.history__select {
	display: block;
	width: 100%;
	min-width: 0;
	min-height: 52px;
	padding: 20px 30px 6px 10px;
	border: 0;
	border-radius: inherit;
	background: transparent;
	color: var(--ink);
	font: inherit;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.2;
	text-overflow: ellipsis;
	white-space: nowrap;
	cursor: pointer;
	appearance: none;
}

.history__select:disabled {
	cursor: default;
}

.history__select option {
	background: var(--surface);
	color: var(--ink);
	font-weight: 600;
}

@media (hover: hover) {
	.history__filter:hover {
		box-shadow: 0 2px 4px rgba(11, 31, 58, 0.14), 0 8px 18px rgba(11, 31, 58, 0.16);
		transform: translateY(-1px);
	}

	.history__filter:hover::before {
		transform: scale(1.1);
	}
}

.history__filter.is-active {
	background: var(--ink);
	box-shadow: 0 4px 14px rgba(11, 31, 58, 0.3);
}

.history__filter.is-active .history__filter-label {
	color: var(--accent);
}

.history__filter.is-active .history__select {
	color: #fff;
}

.history__filter.is-active::before {
	background: var(--accent);
}

/* The focus ring goes round the whole card. */
.history__filters .history__select:focus-visible {
	outline: none;
}

.history__filter:has(.history__select:focus-visible) {
	outline: 3px solid var(--ink);
	outline-offset: 2px;
}

/* Timeline grid: the list, and the year rail on the right. */

.history {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 44px;
	gap: 6px;
	width: 100%;
	max-width: 720px;
	margin: 0 auto;
	padding: 16px 4px 40px 16px;
}

.history__list {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-width: 0;
}

/* The axis, behind the centre of the stamps (88 px wide), visible between the cards. */
.history__list::before {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	left: 43px;
	width: 2px;
	background: var(--ink);
}

.history__list > * {
	position: relative;
}

.history__error {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	margin: 0;
	padding: 8px 12px;
	border-radius: var(--radius);
	background: var(--line);
	color: var(--ink);
	font-size: 13px;
	font-weight: 700;
	text-align: center;
}

.history__decade {
	align-self: flex-start;
	margin: 0;
	padding: 7px 12px;
	border-radius: 999px;
	background: var(--accent);
	color: var(--ink);
	font-size: 12px;
	font-weight: 800;
	letter-spacing: 0.04em;
	scroll-margin-top: calc(var(--history-band, 70px) + 16px);
}

/* Card: navy stamp (date, type, scope), then the text. */

.event {
	display: flex;
	border-radius: var(--radius);
	background: var(--surface);
	overflow: hidden;
	scroll-margin-top: calc(var(--history-band, 70px) + 16px);
	content-visibility: auto;
	contain-intrinsic-size: auto 200px;
}

.event__stamp {
	flex: none;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 88px;
	padding: 12px 4px;
	background: var(--ink);
	color: #fff;
	text-align: center;
}

.event__when,
.event__zone {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 3px;
}

.event__year {
	font-size: 22px;
	font-weight: 800;
	line-height: 1;
	font-variant-numeric: tabular-nums;
}

.event__day {
	font-size: 12px;
	font-weight: 600;
	line-height: 1.2;
}

.event__type {
	font-size: 12px;
	font-weight: 700;
	line-height: 1.2;
}

/* Scope icon: an SVG used as a mask in the text colour, like the competition logos. */
.event__zone-icon {
	display: block;
	width: 30px;
	height: 30px;
	background-color: currentColor;
	-webkit-mask: var(--zone) center / contain no-repeat;
	mask: var(--zone) center / contain no-repeat;
}

.event__zone-label {
	font-size: 11px;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: 0.03em;
}

/* Importance: yellow year for the essentials, light stamp for the dates for insiders. */
.event--importance-1 .event__year {
	color: var(--accent);
}

.event--importance-3 .event__stamp {
	border-right: 2px solid var(--line);
	background: var(--surface);
	color: var(--ink);
}

.event__body {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 5px;
	min-width: 0;
	padding: 12px;
}

.event__title {
	margin: 0;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.25;
	text-wrap: balance;
}

.event__text {
	margin: 0;
	color: var(--ink-soft);
	font-size: 14px;
	line-height: 1.45;
}

/* Pinte 2 Foot articles about the event (partner site). */
.event__articles {
	margin-top: 2px;
	padding: 8px 10px;
	border-left: 3px solid var(--accent);
	border-radius: 4px;
	background: var(--bg);
	font-size: 13px;
}

.event__articles-label {
	margin: 0 0 2px;
	color: var(--ink-soft);
	font-weight: 700;
}

.event__articles ul {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.event__articles a {
	display: inline-block;
	padding: 4px 0;
	color: var(--ink);
	font-weight: 700;
	line-height: 1.3;
	text-decoration-color: var(--accent);
	text-decoration-thickness: 2px;
	text-underline-offset: 3px;
	overflow-wrap: anywhere;
}

.event__articles a::after {
	content: " ↗";
	color: var(--ink-soft);
}

.event__sources {
	font-size: 13px;
}

.event__sources summary {
	width: max-content;
	padding: 6px 0;
	font-weight: 700;
	cursor: pointer;
}

.event__sources ul {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.event__sources a {
	display: inline-block;
	padding: 5px 0;
	color: var(--ink);
	overflow-wrap: anywhere;
}

/* Year rail. */

.history__rail {
	position: sticky;
	top: calc(var(--history-band, 70px) + 16px);
	align-self: start;
	display: flex;
	flex-direction: column;
}

.history__rail[hidden] {
	display: none;
}

.history__mark {
	width: 44px;
	height: 40px;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--ink-soft);
	font-size: 12px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	cursor: pointer;
}

.history__mark span {
	padding: 4px 5px;
	border-radius: 6px;
}

.history__mark[aria-current="true"] span {
	background: var(--ink);
	color: #fff;
}

.history-page :focus-visible {
	outline: 3px solid var(--ink);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
	html {
		scroll-behavior: smooth;
	}
}

@media (min-width: 600px) {
	.history__title {
		font-size: 34px;
	}

	.history {
		padding-right: 8px;
	}
}

@media (min-width: 960px) {
	/* Same alignment as the other pages (1120px column, 32px gutters). */
	.masthead {
		padding: 14px max(32px, calc((100% - 1120px) / 2 + 32px));
	}
}
