/*
   A card's history line: its turns (a board turn tapped to show its darts) and
   the finished legs' dots at its end.
   Loaded in order with the others (see index.html): a later rule wins. */

/* The history line: the turns, the finished legs' dots at its end. Its taps
   are its own (a board turn, a leg dot): it doesn't open the player's menu. */
.history-line {
	grid-area: history;
	display: flex;
	align-items: center;
	min-width: 0;
	box-sizing: border-box;
	background: var(--row);
	border-top: var(--border-muted);
	border-bottom: var(--border);
	cursor: auto;
	transition: background-color var(--slow) var(--ease-out);
}

/* The panel's border is the last card's bottom line, and over a phone's keypad the framed card's. */
.card:last-child .history-line,
.scores-section.framed .card.active .history-line {
	border-bottom: none;
}

.card.active .history-line {
	background: var(--active-line);
}

.card.menu-open .history-line {
	background: var(--menu-line);
}

/* With darts on the board, the thrower's past turns can't be tapped to show:
   their bar steps back. */
.score-cards.darts-down .card.active:not(.menu-open) .history-line {
	background: color-mix(in srgb, var(--active-line) 45%, black);
}

.score-cards.darts-down .card.active:not(.menu-open) .history {
	filter: var(--dim);
}

.score-cards.darts-down .card.active:not(.menu-open) .history span {
	pointer-events: none;
}

@property --fade-left {
	syntax: "<length>";
	inherits: false;
	initial-value: 0px;
}

@property --fade-right {
	syntax: "<length>";
	inherits: false;
	initial-value: 0px;
}

.history {
	flex: 1 1 auto;
	align-self: stretch;
	display: flex;
	align-items: center;
	min-width: 0;
	padding-left: calc(var(--card-inset) + var(--name-gap));
	/* Older turns fade out at the left edge when they scroll past it. */
	mask-image: linear-gradient(to right, transparent, black var(--fade-left), black calc(100% - var(--fade-right)), transparent);
	transition: --fade-left var(--medium), --fade-right var(--medium), filter var(--medium) var(--ease-out);
}

/* The finished legs' dots, after the turns and still as they scroll; the
   latest in view if there are more than fit. */
.leg-dots {
	flex: none;
	align-self: stretch;
	display: flex;
	max-width: 40%;
	padding-right: calc(var(--card-end) - 0.6vmin * var(--s)); /* a dot's edge where the score ends */
	overflow-x: auto;
	scrollbar-width: none;
}

.leg-dots::-webkit-scrollbar {
	display: none;
}

.leg-dots:empty {
	display: none;
}

.history.fade-left {
	--fade-left: calc(6vmin * var(--s));
}

.history.fade-right {
	--fade-right: calc(3vmin * var(--s));
}

/* Before the leg dots, always a fade, the turns ending clear of it. */
.history:has(+ .leg-dots:not(:empty)) {
	--fade-right: calc(4vmin * var(--s));
	padding-right: calc(4vmin * var(--s));
}

.history span {
	flex: none;
	color: var(--text-soft);
	font-size: calc(2.25vmin * var(--s));
	font-weight: normal;
	padding-right: 0.4em; /* the same in every layout (vw made it tight upright) */
	line-height: 1.35;
}

.history span b {
	color: var(--value);
	transition: color var(--medium) var(--ease-out), background-color var(--medium) var(--ease-out), box-shadow var(--medium) var(--ease-out);
}
