/*
   The toast, a past turn on show, and hover for a mouse.
   Loaded in order with the others (see index.html): a later rule wins. */

/* TOAST */

.toast {
	position: absolute;
	top: calc(env(safe-area-inset-top) + var(--top-drop) + var(--side-pad) + var(--ctrl-size) / 2); /* level with the middle of undo, redo and Settings */
	left: 61%;
	z-index: 50;
	width: max-content; /* as wide as its text, up to its max, wherever it's centred */
	max-width: 40vw;
	padding: 1vmin 2.5vmin;
	box-sizing: border-box;
	font-family: var(--font-condensed);
	font-size: 3.5vmin;
	line-height: 1.2;
	white-space: nowrap;
	color: var(--text);
	text-shadow: 0 0 1vmin black;
	background: var(--panel);
	border: var(--border);
	border-radius: var(--radius);
	box-shadow: 0 1vmin 3vmin rgba(0, 0, 0, 0.6);
	pointer-events: none;
	transform: translate(-50%, -50%);
	animation: toast-in var(--medium) var(--ease-back);
}

.toast.leaving {
	animation: toast-out var(--medium) var(--ease-out) forwards;
}

.toast-text {
	display: block;
	overflow: hidden;
	text-overflow: ellipsis;
	/* Room above the text inside what's cut, for a score's star (Safari has no overflow-clip-margin), not moving it. */
	padding-top: 0.3em;
	margin-top: -0.3em;
}

.toast-title {
	font-weight: 600;
}

.toast-detail {
	color: var(--text-soft);
}

.toast.bust {
	border-color: var(--bust);
}

.toast.bust .toast-title {
	color: var(--bust);
}

.toast.win {
	border-color: var(--checkout);
	box-shadow: 0 1vmin 3vmin rgba(0, 0, 0, 0.6), 0 0 2vmin rgba(0, 200, 0, 0.35);
}

.toast.win .toast-title {
	color: var(--checkout);
}

/* A past turn's toast: a small ✕ after the score, in the toast itself, to
   show that it can be closed. Any tap closes a past turn (the pointerdown
   listener in app.js), this one included. */
.toast.review {
	display: flex;
	align-items: center;
	gap: 1.4vmin;
	padding-right: 1.6vmin;
}

.toast.review .toast-text {
	min-width: 0;
}

.toast-close {
	display: none;
	flex: none;
	align-items: center;
	justify-content: center;
	padding: 0.4vmin;
	margin: -0.4vmin 0;
	font: inherit;
	color: var(--text-soft);
	background: none;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	pointer-events: auto;
	transition: box-shadow var(--hover-speed);
}

.toast.review .toast-close {
	display: flex;
}

.toast-close .icon {
	flex: none;
	width: 2.2vmin;
	height: 2.2vmin;
}

/* The thrower's checkout: a toast that stays, taking taps (the next route),
   out of sight while another toast shows. */
.checkout-toast {
	z-index: 49; /* under any other toast */
	pointer-events: auto;
	transition: opacity var(--medium) var(--ease-out) var(--fast);
}

/* Gone at once while another toast shows (and as it goes), back once it's gone. */
.toast:not([hidden]) ~ .checkout-toast {
	visibility: hidden;
	opacity: 0;
	pointer-events: none;
	transition: none;
}

/* A past turn on show: outlined in white, whatever the board's highlight colour. */
.toast.review {
	border-color: white;
	box-shadow: 0 1vmin 3vmin rgba(0, 0, 0, 0.6), 0 0 2vmin rgba(255, 255, 255, 0.32);
}

@keyframes toast-in {
	from { opacity: 0; transform: translate(-50%, calc(-50% - 2vmin)) scale(0.9); }
}

@keyframes toast-out {
	to { opacity: 0; transform: translate(-50%, calc(-50% - 1.5vmin)) scale(0.95); }
}

/* HOVER: with a mouse, whatever can be pressed lights up a little under the
   pointer (the board has its own: .light.hover), fading in and out (see
   MOTION). Only with a pointer that hovers, and not since the last touch
   (app.js sets .touching on the root: a touch screen laptop has both), so a
   tap leaves nothing lit. */

:root {
	--hover-veil: inset 0 0 0 100vmax rgba(255, 255, 255, 0.15); /* over a button's own fill */
	--hover-tint: rgba(255, 255, 255, 0.1); /* buttons with no fill of their own */
	--hover-speed: 150ms; /* the hover lights fade a little quicker than other changes (--medium) */
}

@media (hover: hover) {
	:root:not(.touching) :is(
		.settings-btn-action:not(:disabled),
		.stepper-btn:not(:disabled),
		.game-tile,
		.segmented button,
		.players-add,
		.calc-tbl td:not(.disabled),
		.ctrl-btn:not(.disabled),
		.side-btn:not(.disabled),
		.darts span:not(.empty)
	):hover {
		box-shadow: var(--hover-veil);
	}

	/* A dart being moved keeps its veil under the pulsing glow. */
	:root:not(.touching) .darts span.editing:hover {
		--slot-veil: var(--hover-veil);
	}

	:root:not(.touching) :is(.field-btn, .player-menu button, .darts-clear):not(:disabled):hover {
		background: var(--hover-tint);
	}

	:root:not(.touching) .toast-close:hover {
		box-shadow: var(--hover-veil);
	}

	/* The player menu's name row lights as one; its pencil not on its own. */
	:root:not(.touching) .player-menu:not(.renaming) .player-menu-head:hover {
		background: var(--hover-tint);
	}

	:root:not(.touching) .player-menu:not(.renaming) .player-menu-rename:hover {
		background: none;
	}

	:root:not(.touching) .swatch:not([aria-pressed="true"]):hover {
		transform: scale(1.08);
	}

	:root:not(.touching) .settings-check:has(input:not(:disabled)):hover {
		color: white;
	}

	:root:not(.touching) .checkout:not(.hint):hover {
		color: white;
	}

	:root:not(.touching) .checkout:not(.hint):hover .checkout-count {
		max-width: 3.2em;
		margin-left: 0.35em;
		opacity: 1;
	}

	:root:not(.touching) .history span.has-hits:not(.reviewing):hover b {
		background: var(--hover-tint);
		border-radius: 0.5vmin;
		box-shadow: 0 0 0 0.35vmin var(--hover-tint);
	}

	:root:not(.touching) .leg-dot[role="button"]:not(.open, .now):hover::before {
		box-shadow: 0 0 0 calc(0.3vmin * var(--s)) color-mix(in srgb, var(--text-soft) 30%, transparent);
	}

	/* A player's card, all of it, under the pointer anywhere but its history line (which has taps of its own). */
	:root:not(.touching) .card:hover:not(:has(.history-line:hover))::before,
	:root:not(.touching) .card:hover:not(:has(.history-line:hover)) .history-line {
		box-shadow: inset 0 0 0 100vmax rgba(255, 255, 255, 0.07);
	}
}
