/*
 * Game interface. Mobile first (390 x 844 reference), desktop layout from 960px.
 * Loaded after base.css (colors, reset, site header).
 */

/* Layout: header, scrolling timeline, panel under the thumb. */

.app {
	display: flex;
	flex-direction: column;
	height: 100dvh;
	max-width: 520px;
	margin: 0 auto;
}

/* Game bar: lives, score and progress. */

.topbar {
	flex: none;
	padding: 10px 16px;
	background: var(--surface);
	border-bottom: 1px solid var(--line);
}

.topbar__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.lives {
	display: flex;
	gap: 5px;
}

.life {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: var(--ink);
	border: 2px solid var(--ink);
	transition: background-color 0.3s;
}

.life--lost {
	background: transparent;
}

.score {
	display: flex;
	align-items: baseline;
	gap: 6px;
}

.score__label {
	font-size: 12px;
	color: var(--ink-soft);
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

.score__value {
	font-size: 20px;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}

.pips {
	display: flex;
	gap: 6px;
	margin: 10px 0 0;
	padding: 0;
	list-style: none;
}

.pip {
	flex: 1;
	height: 8px;
	border-radius: 4px;
	background: var(--line);
	border: 2px solid transparent;
}

.pip--current {
	background: var(--ink);
}

.pip--correct {
	background: var(--correct);
}

.pip--wrong {
	background: transparent;
	border-color: var(--wrong);
}

/* Challenge: the score to beat, under the pips (claude/challenge-link.MD). */

.challenge {
	margin: 8px 0 0;
	font-size: 13px;
	font-weight: 700;
	color: var(--ink-soft);
}

/* League decks: the popin that announces the game (league, seasons covered, goal). It reuses
   the challenge popin. */

.intro .invite__body {
	text-align: center;
}

.intro__league {
	font-size: 26px;
}

.intro__span {
	display: inline-block;
	margin: 10px 0 12px;
	padding: 4px 12px;
	border-radius: 999px;
	background: var(--accent);
	font-size: 14px;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}

.intro .recap__actions .button {
	flex: 1;
}

/* Timeline. */

.board {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 8px 16px 16px;
	scroll-padding: 24px;
}

.board__edge {
	margin: 4px 0;
	font-size: 11px;
	font-weight: 700;
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: 0.08em;
	text-align: center;
}

.timeline {
	margin: 0;
	padding: 0;
	list-style: none;
}

.gap {
	height: var(--gap-height);
	display: flex;
	align-items: stretch;
}

.gap__button {
	flex: 1;
	margin: 4px 0;
	border: 2px dashed var(--line);
	border-radius: 8px;
	background: transparent;
	color: var(--ink-soft);
	font-size: 13px;
	font-weight: 700;
	cursor: pointer;
	transition: border-color 0.15s, background-color 0.15s, color 0.15s;
	animation: fade-in 0.3s both;
}

.gap__button:hover,
.gap__button:focus-visible {
	border-color: var(--ink);
	border-style: solid;
	background: var(--surface);
	color: var(--ink);
	outline: none;
}

.timeline.is-busy .gap__button,
.timeline.is-end .gap__button {
	pointer-events: none;
	animation: fade-out 0.2s both;
}

.timeline.is-end .gap {
	height: 8px;
}

.card {
	position: relative;
	display: flex;
	min-height: 64px;
	background: var(--surface);
	border: 2px solid transparent;
	border-radius: var(--radius);
	box-shadow: 0 1px 2px rgba(11, 31, 58, 0.08);
	overflow: hidden;
}

.card--anchor {
	border-color: var(--ink);
}

.stamp {
	flex: none;
	width: 72px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 8px 4px;
	background: var(--ink);
	color: #fff;
	text-align: center;
	line-height: 1.1;
	transition: background-color 0.2s;
}

.stamp__year {
	font-size: 20px;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}

.stamp__day,
.stamp__minute {
	font-size: 12px;
	font-weight: 600;
	opacity: 0.9;
}

/* League decks: a season, both years on two lines of the same size. */
.stamp--season .stamp__year {
	font-size: 17px;
}

.stamp--unknown {
	background: var(--muted);
}

.stamp--unknown .stamp__year {
	font-size: 26px;
}

.stamp--correct {
	background: var(--correct);
}

.stamp--wrong {
	background: var(--wrong);
}

.card__body {
	flex: 1;
	min-width: 0;
	padding: 10px 12px;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 4px;
}

.card__tag {
	align-self: flex-start;
	padding: 1px 6px;
	border-radius: 4px;
	background: var(--ink);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

.card__text {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.25;
}

.card__detail {
	margin: 0;
	font-size: 13px;
	color: var(--ink-soft);
	line-height: 1.3;
}

.card__mark {
	flex: none;
	align-self: center;
	width: 28px;
	height: 28px;
	margin-right: 10px;
	border-radius: 50%;
	display: grid;
	place-items: center;
	color: #fff;
	font-size: 15px;
	font-weight: 800;
}

.card__mark--correct {
	background: var(--correct);
}

.card__mark--wrong {
	background: var(--wrong);
}

.card.is-correct {
	animation: pulse 0.4s ease-out;
}

.card.is-wrong {
	animation: shake 0.4s ease-in-out;
}

.card.is-pending {
	box-shadow: 0 6px 20px rgba(11, 31, 58, 0.2);
	z-index: 1;
}

/* Panel. */

/* Mobile: a slim band that shows the event only; the timeline keeps the room. */
.panel {
	flex: none;
	display: flex;
	flex-direction: column;
	justify-content: center;
	min-height: calc(68px + env(safe-area-inset-bottom));
	padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
	background: var(--accent);
	border-radius: 16px 16px 0 0;
	box-shadow: 0 -4px 16px rgba(11, 31, 58, 0.12);
}

/* The site footer follows the panel (initFooter() in app/js/menu.js): on mobile it keeps the
   bottom safe area, the panel no longer needs it. */
@media (max-width: 959px) {
	.panel:has(+ .site-footer) {
		min-height: 68px;
		padding-bottom: 10px;
	}
}

.app > .site-footer {
	flex: none;
	margin-top: 0;
}

.panel__content {
	animation: rise 0.3s ease-out both;
}

.panel__meta {
	display: none;
	justify-content: space-between;
	gap: 8px;
	font-size: 13px;
	font-weight: 700;
}

.panel__card {
	margin: 0;
	font-size: 18px;
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: -0.01em;
}

.panel__hint {
	display: none;
	margin: 16px 0 0;
	font-size: 13px;
	color: var(--ink-soft);
}

/* Verdict, points and bonus on one line on mobile. */
.panel__verdict-row {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	column-gap: 12px;
}

.panel__verdict {
	margin: 0;
	font-size: 20px;
	font-weight: 800;
}

.panel__verdict--correct {
	color: var(--correct);
}

.panel__verdict--wrong {
	color: var(--wrong);
}

.panel__points {
	margin: 0;
	font-size: 16px;
	font-weight: 700;
}

.panel__title {
	margin: 0;
	font-size: 15px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

.panel__tier {
	margin: 6px 0 0;
	font-size: 40px;
	font-weight: 800;
	line-height: 1;
	letter-spacing: -0.02em;
}

.panel__score {
	margin: 6px 0 0;
	font-size: 18px;
	font-weight: 700;
}

.panel__best {
	margin: 4px 0 0;
	font-size: 13px;
	color: var(--ink-soft);
}

.panel__challenge {
	margin: 8px 0 0;
	font-size: 15px;
	font-weight: 800;
}

.pips--large {
	margin: 14px 0 0;
}

.pips--large .pip {
	height: 14px;
	border-radius: 7px;
}

.pips--large .pip:not(.pip--correct):not(.pip--wrong) {
	background: rgba(11, 31, 58, 0.15);
}

/* Two rows: Replay and Recap side by side, the challenge button on a row of its own. */
.panel__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 16px;
}

.button {
	flex: 1;
	min-height: 48px;
	border-radius: 10px;
	border: 2px solid var(--ink);
	font-size: 16px;
	font-weight: 800;
	cursor: pointer;
}

.button--primary {
	flex: 2;
	background: var(--ink);
	color: #fff;
}

.button--secondary {
	background: transparent;
}

.button--wide {
	flex-basis: 100%;
}

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

.panel__error {
	margin: 0;
	font-size: 16px;
	font-weight: 700;
}

/* Recap popin of a lost game: a self-contained card, made to be screenshot. */

.recap {
	width: min(380px, calc(100% - 32px));
	max-height: calc(100dvh - 32px);
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--ink);
	overflow: visible;
}

.recap[open] {
	animation: recap-in 0.25s ease-out both;
}

.recap::backdrop {
	background: rgba(11, 31, 58, 0.55);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
}

.recap__card {
	overflow: hidden;
	border-radius: 20px;
	background: var(--surface);
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}

.recap__brand {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 18px;
	background: var(--ink);
	color: #fff;
}

.recap__site {
	font-size: 18px;
	font-weight: 800;
	letter-spacing: -0.01em;
}

.recap__period-label {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px;
	margin: 0;
	padding: 8px 18px;
	background: var(--accent);
	font-size: 13px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.recap__period-label strong {
	font-size: 15px;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}

.recap__body {
	padding: 14px 18px 6px;
}

/* List of the placed cards: icon, year, text on one line, points. */
.recap__items {
	margin: 10px 0 0;
	padding: 0;
	list-style: none;
}

.recap__item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 5px 0;
	border-bottom: 1px solid var(--line);
	font-size: 13px;
}

.recap__item .icon {
	flex: none;
	width: 20px;
	height: 20px;
}

.recap__item-year {
	flex: none;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}

.recap__item-text {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	color: var(--ink-soft);
	white-space: nowrap;
	text-overflow: ellipsis;
}

.recap__item-points {
	flex: none;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}

.recap__item--wrong .recap__item-points {
	color: var(--muted);
}

.recap__item-bonus {
	margin-left: 4px;
	color: var(--correct);
}

.panel__bonus {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	color: #c2410c;
	font-size: 15px;
	font-weight: 800;
}

.panel__bonus .icon {
	width: 22px;
	height: 22px;
}

.recap__rows {
	margin: 10px 0 0;
}

.recap__row {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	padding: 4px 0;
	font-size: 14px;
}

.recap__row dt {
	color: var(--ink-soft);
	font-weight: 600;
}

.recap__row dd {
	margin: 0;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}

.recap__row--total {
	margin-top: 6px;
	padding-top: 10px;
	border-top: 2px solid var(--ink);
}

.recap__row--total dt {
	color: var(--ink);
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.recap__row--total dd {
	font-size: 28px;
	line-height: 1;
}

.recap__challenge {
	margin: 2px 0 6px;
	font-size: 15px;
	font-weight: 800;
}

.recap__challenge--won {
	color: var(--correct);
}

.recap__challenge--lost {
	color: var(--wrong);
}

.recap__best {
	margin: 2px 0 0;
	color: var(--ink-soft);
	font-size: 13px;
}

.recap__url {
	display: block;
	margin: 8px 0 0;
	padding: 10px 18px;
	border-top: 1px solid var(--line);
	color: var(--muted);
	font-size: 12px;
	font-weight: 700;
	text-align: center;
	text-decoration: none;
	letter-spacing: 0.02em;
}

.recap__url:hover {
	color: var(--ink);
}

/* Actions sit under the card, so that a screenshot of the card stays clean. */
.recap__actions {
	display: flex;
	gap: 10px;
	margin-top: 14px;
}

/* One row, whatever the height of the screen: Replay and the challenge share the width, the
   close button is a square. */
.recap__actions .button {
	flex: 1;
	padding: 4px 6px;
	line-height: 1.15;
}

.recap__actions .button--icon {
	flex: none;
	width: 48px;
	font-size: 18px;
}

.button--light {
	border-color: #fff;
	background: #fff;
	color: var(--ink);
}

/* Challenge button under the recap card: the accent color stands out on the dark backdrop. */
.button--accent {
	border-color: var(--accent);
	background: var(--accent);
	color: var(--ink);
}

.button--accent:focus-visible {
	outline-color: #fff;
}

/* After a challenge, sending it back comes before Replay. */
.recap--challenge .button--accent {
	order: -1;
}

.button--light:focus-visible {
	outline-color: #fff;
}

/* Challenge popin: the link to copy, over the recap popin. */

.invite__body {
	padding: 18px;
}

.invite__title {
	margin: 0;
	font-size: 20px;
	font-weight: 800;
}

.invite__text {
	margin: 6px 0 0;
	color: var(--ink-soft);
	font-size: 14px;
}

.invite__field {
	display: flex;
	gap: 8px;
	margin-top: 14px;
}

.invite__url {
	flex: 1;
	min-width: 0;
	min-height: 48px;
	padding: 0 12px;
	border: 2px solid var(--line);
	border-radius: 10px;
	background: var(--bg);
	color: var(--ink);
	font: inherit;
	font-size: 14px;
}

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

.invite__copy {
	flex: none;
	padding: 0 16px;
}

/* Toast. */

.toast {
	position: fixed;
	left: 50%;
	/* As wide as its text, up to the screen: a long message must not wrap at half the width. */
	width: max-content;
	max-width: calc(100% - 32px);
	text-align: center;
	bottom: calc(190px + env(safe-area-inset-bottom));
	transform: translateX(-50%);
	margin: 0;
	padding: 10px 16px;
	border-radius: 999px;
	background: var(--ink);
	color: #fff;
	font-size: 14px;
	font-weight: 700;
	animation: toast-in 0.2s ease-out both;
}

/* Desktop: timeline on the left, panel as a side column. */

@media (min-width: 960px) {
	.app {
		display: grid;
		grid-template-columns: minmax(0, 1fr) 380px;
		grid-template-rows: auto auto minmax(0, 1fr) auto;
		column-gap: 32px;
		max-width: 1120px;
		padding: 0 32px;
	}

	body {
		overflow-x: clip;
	}

	/* Full-bleed bands: they span the whole window, their content stays aligned with the grid. */
	.masthead,
	.topbar,
	.app > .site-footer {
		grid-column: 1 / -1;
		margin-inline: calc(50% - 50vw);
		padding-inline: calc(50vw - 50%);
	}

	.masthead {
		padding-block: 14px;
	}

	.topbar {
		padding-block: 14px;
	}

	.pips {
		max-width: 520px;
	}

	.board {
		padding: 16px 8px 32px 0;
	}

	.timeline {
		max-width: 680px;
		margin: 0 auto;
	}

	.card {
		min-height: 72px;
	}

	.stamp {
		width: 88px;
	}

	.stamp__year {
		font-size: 22px;
	}

	.card__text {
		font-size: 16px;
	}

	.panel {
		align-self: start;
		margin-top: 24px;
		padding: 24px;
		border-radius: 20px;
		box-shadow: 0 8px 24px rgba(11, 31, 58, 0.14);
		min-height: 0;
	}

	.panel__meta {
		display: flex;
		margin-bottom: 12px;
	}

	.panel__card {
		font-size: 26px;
		line-height: 1.2;
	}

	.panel__verdict-row {
		display: block;
	}

	.panel__verdict {
		margin-top: 8px;
		font-size: 28px;
	}

	.panel__points {
		margin-top: 4px;
		font-size: 20px;
	}

	.panel__bonus {
		margin-top: 6px;
		font-size: 16px;
	}

	.panel__hint {
		display: block;
	}

	.toast {
		bottom: 32px;
	}
}

/* Keyframes. */

@keyframes recap-in {
	from {
		opacity: 0;
		transform: translateY(16px) scale(0.98);
	}
}

@keyframes fade-in {
	from {
		opacity: 0;
	}
}

@keyframes fade-out {
	to {
		opacity: 0;
	}
}

@keyframes rise {
	from {
		opacity: 0;
		transform: translateY(16px);
	}
}

@keyframes toast-in {
	from {
		opacity: 0;
		transform: translate(-50%, 16px);
	}
}

@keyframes pulse {
	50% {
		box-shadow: 0 0 0 6px rgba(11, 107, 72, 0.35);
		transform: scale(1.02);
	}
}

@keyframes shake {
	20%,
	60% {
		transform: translateX(-6px);
	}

	40%,
	80% {
		transform: translateX(6px);
	}
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}
