/*
   On the board: lit beds and the darts themselves; on the cards, what
   each visit was and the legs' dots.
   Loaded in order with the others (see index.html): a later rule wins. */

/* BOARD MARKERS AND LIGHTS (inside the board SVG, in board units: radius 100) */

.dartboard .shading,
.dartboard .outlines,
.dartboard .numbers,
.dartboard .lit,
.dartboard .marks {
	pointer-events: none;
}

/* Where this turn's darts landed: the segment glows. */
.light {
	fill-rule: evenodd; /* rings (the outer bull, the number ring) light as rings */
	stroke-linejoin: round;
}

.light.hit {
	fill: color-mix(in srgb, var(--board-hit) 35%, transparent);
	stroke: var(--board-hit);
	stroke-width: 0.9;
	filter: drop-shadow(0 0 1.5px var(--board-hit));
	animation: fade-in var(--medium) var(--ease-out);
}

/* A past turn being looked back at. */
.light.review {
	fill: color-mix(in srgb, var(--board-hit) 45%, transparent);
	stroke: var(--board-hit);
	stroke-width: 1;
	filter: drop-shadow(0 0 1.5px var(--board-hit));
}

/* Under the mouse pointer; and a dart in the number ring (a miss), lit the same. */
.light.hover,
.light.miss {
	fill: color-mix(in srgb, white 14%, transparent); /* a mix, like the lit colours: see light-from-hover */
	stroke: rgba(255, 255, 255, 0.45);
	stroke-width: 0.4;
}

.light.miss {
	animation: fade-in var(--medium) var(--ease-out);
}

/* Lit where the pointer was: from the pointer's light to its own (for the
   number ring, the same look, so no flicker). */
.light.from-hover {
	animation: light-from-hover var(--medium) var(--ease-out);
}

@keyframes light-from-hover {
	from {
		/* A mix like the lit colours: between a mix and a plain rgba() the
		   browser blends through red or black. */
		fill: color-mix(in srgb, white 14%, transparent);
		stroke: rgba(255, 255, 255, 0.45);
		stroke-width: 0.4;
		filter: none;
	}
}

/* The bed of a dart picked up to move: flashes in the moving yellow, in time
   with its slot (whatever the highlight colour). */
.light.editing {
	fill: color-mix(in srgb, var(--dart-edit) 40%, transparent);
	stroke: var(--dart-edit);
	stroke-width: 0.9;
	filter: drop-shadow(0 0 1.5px var(--dart-edit));
	animation: editing-light 0.9s ease-in-out infinite alternate;
}

@keyframes editing-light {
	from { opacity: 0.35; }
}

/* A dart in the board, in perspective (dart3d.js). Its barrel and shaft are
   shaded in dartboard.js. */

/* Its shadow on the board: one shape, faded along its length (a gradient from dartboard.js). */
.dart-shadow {
	opacity: 0.4;
}

/* Darts show in full, unless see-through: picked up to move (--see, 0 to 1,
   from dartboard.js). */
.dart-body {
	opacity: calc(1 - 0.15 * var(--see, 0));
}

.dart-point {
	fill: black;
}

/* Soft edges, a darker tone of each part rather than a hard line. */
.dart-steel,
.dart-face {
	stroke: rgba(0, 0, 0, 0.35);
	stroke-width: 0.12;
	stroke-linejoin: round;
}

/* Grip rings round the barrel. */
.dart-grip {
	stroke: #000000;
	stroke-dasharray: 0.7 1.1;
	opacity: 0.4;
}

.dart-shaft {
	stroke: rgba(0, 0, 0, 0.4);
	stroke-width: 0.1;
	opacity: calc(1 - 0.4 * var(--see, 0));
}

.dart:not(.seeing) .dart-shaft {
	mask: none;
}

.dart-flight {
	opacity: calc(1 - 0.62 * var(--see, 0));
}

.dart-flight polygon {
	stroke: color-mix(in srgb, var(--dart-flight) 55%, black);
	stroke-width: 0.25;
	stroke-opacity: 0.5;
	stroke-linejoin: round;
}

/* Lit beds on their way out. */
.dartboard .leaving {
	animation: fade-out var(--medium) var(--ease-out) forwards;
}

/* A dart picked up to move: its slot pulses, and its bed
   flashes. The slot's edge is the moving yellow, its glow red, and the card
   grows downward to say another tap removes it. */
.darts span.editing {
	--slot-veil: inset 0 0 0 0 transparent; /* the hover veil, if any: both frames list it, so the glow fades */
	border-color: var(--dart-edit);
	animation: editing 0.9s ease-in-out infinite alternate;
}

@keyframes editing {
	from { box-shadow: var(--slot-veil), 0 0 0 transparent; }
	to { box-shadow: var(--slot-veil), 0 0 calc(2.6 * var(--u)) calc(0.3 * var(--u)) var(--bust); }
}

/* History turns entered on the board can be tapped to show their darts. */
.history span.has-hits {
	cursor: pointer;
}

.history span.has-hits b {
	text-decoration: underline dotted var(--text-muted);
	text-underline-offset: 0.3vmin;
}

/* The turn whose darts are on the board, in white, whatever the board's highlight colour. */
.history span.reviewing b {
	color: black;
	background: white;
	border-radius: 0.5vmin;
	box-shadow: 0 0 0 0.35vmin white;
	text-decoration: none;
	text-shadow: none;
}

/* What each visit was (see historyMarks in feedback.js), in the history and in
   the toast of a past visit on show (.toast-score). */
.history span.zero b,
.history span.bust b,
.toast-score:is(.zero, .bust) b {
	color: var(--history-muted);
	font-weight: normal;
}

:is(.history span, .toast-score).bust b {
	text-decoration: line-through color-mix(in srgb, var(--bust) 70%, transparent);
}

:is(.history span, .toast-score).ton b {
	font-weight: 700;
}

:is(.history span, .toast-score).ton-forty b {
	color: var(--ton-forty);
	font-weight: 700;
}

:is(.history span, .toast-score).max b {
	color: var(--max);
	font-weight: 800;
	text-shadow: 0 0 0.8vmin color-mix(in srgb, var(--max) 70%, transparent);
}

:is(.history span, .toast-score).finish b {
	color: var(--checkout);
	font-weight: 700;
}

/* A finished leg, a dot at the start of the line: filled green if this player
   won it, grey if not. Each is drawn inside a wider tap area. */
.leg-dot {
	flex: none;
	align-self: stretch;
	display: flex;
	align-items: center;
	padding: 0 calc(0.6vmin * var(--s)); /* the tap area wider than the dot, easier on a phone */
}

.leg-dot::before {
	content: '';
	box-sizing: border-box;
	width: calc(1.8vmin * var(--s));
	height: calc(1.8vmin * var(--s));
	border-radius: 50%;
	transition: box-shadow var(--medium) var(--ease-out);
}

.leg-dot.won::before {
	background: var(--checkout);
}

.leg-dot.lost::before {
	background: var(--history-muted);
}

/* Picked: a white ring round it while its visits are on the line. */
.leg-dot.open::before {
	box-shadow: 0 0 0 calc(0.3vmin * var(--s)) white;
}

/* In a match, the leg being played: an empty white ring, as the legs to come
   but bright; green while it's this player's throw and they have a checkout on. */
.leg-dot.now::before {
	border: calc(0.25vmin * var(--s)) solid white;
	transition: border-color var(--medium) var(--ease-out);
}

.leg-dot.now.chance::before {
	border-color: var(--checkout-now);
}

/* A leg still to come: an empty ring. */
.leg-dot.future::before {
	border: calc(0.25vmin * var(--s)) solid var(--history-muted);
}

/* The leg just won: green fills it in from its ring. */
.leg-dot.filled::before {
	animation: leg-fill var(--slow) var(--ease-out);
}

/* The player's best visit of the leg: a small star on its corner like a badge,
   taking no room and leaving its colour alone. Of the game: a green one. */
:is(.history span, .toast-score):is(.best, .best-game) b {
	position: relative;
}

:is(.history span, .toast-score):is(.best, .best-game) b::before {
	content: '\2605';
	position: absolute;
	top: -0.22em;
	right: -0.35em;
	font-size: 0.55em;
	font-weight: normal;
	line-height: 1;
	color: var(--text-soft);
	text-shadow: none;
}

:is(.history span, .toast-score).best-game b::before {
	color: var(--star-game);
}

/* In the history, a little more room after a starred visit, so its star never meets the next one. */
.history span:is(.best, .best-game) {
	padding-right: 0.6em;
}

/* In a toast the score ends the text, which is cut at its edge: room there for the star. */
.toast-score:is(.best, .best-game) {
	padding-right: 0.35em;
}
