/**
 * Welcome Voice - front-end styles.
 * Colors are set from the settings page via CSS custom properties.
 */

.welcome-voice {
	--wv-bg: #2563eb;
	--wv-fg: #ffffff;
	--wv-offset: 20px;

	position: fixed;
	z-index: 99990;
	display: flex;
	flex-direction: column;
	gap: 8px;
	box-sizing: border-box;
	width: max-content;
	max-width: calc(100vw - (var(--wv-offset) * 2));
	margin: 0;
	padding: 0;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.3;
	pointer-events: none; /* Only the button and caption capture clicks. */
}

.welcome-voice[hidden] {
	display: none !important;
}

/* ---- Position: vertical ---- */
.welcome-voice--bottom-right,
.welcome-voice--bottom-left,
.welcome-voice--bottom-center {
	bottom: calc(var(--wv-offset) + env(safe-area-inset-bottom, 0px));
}

.welcome-voice--top-right,
.welcome-voice--top-left,
.welcome-voice--top-center {
	top: calc(var(--wv-offset) + env(safe-area-inset-top, 0px));
	flex-direction: column-reverse; /* Caption sits below the button. */
}

body.admin-bar .welcome-voice--top-right,
body.admin-bar .welcome-voice--top-left,
body.admin-bar .welcome-voice--top-center {
	top: calc(var(--wv-offset) + 32px);
}

/* ---- Position: horizontal ---- */
.welcome-voice--bottom-right,
.welcome-voice--top-right {
	right: calc(var(--wv-offset) + env(safe-area-inset-right, 0px));
	align-items: flex-end;
}

.welcome-voice--bottom-left,
.welcome-voice--top-left {
	left: calc(var(--wv-offset) + env(safe-area-inset-left, 0px));
	align-items: flex-start;
}

.welcome-voice--bottom-center,
.welcome-voice--top-center {
	left: 50%;
	transform: translateX(-50%);
	align-items: center;
}

/* ---- Caption ---- */
.welcome-voice .welcome-voice__caption {
	box-sizing: border-box;
	max-width: 260px;
	margin: 0;
	padding: 8px 12px;
	border-radius: 12px;
	background: rgba(17, 24, 39, 0.92);
	color: #ffffff;
	font-size: 13px;
	font-weight: 400;
	line-height: 1.4;
	text-align: left;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
	pointer-events: auto;
}

.welcome-voice--bottom-center .welcome-voice__caption,
.welcome-voice--top-center .welcome-voice__caption {
	text-align: center;
}

/* ---- Button row ---- */
.welcome-voice .welcome-voice__row {
	display: flex;
	align-items: center;
	gap: 6px;
}

.welcome-voice .welcome-voice__button {
	-webkit-appearance: none;
	appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-height: 44px;
	margin: 0;
	padding: 10px 18px;
	border: 0;
	border-radius: 999px;
	background: var(--wv-bg);
	color: var(--wv-fg);
	font: inherit;
	font-weight: 600;
	letter-spacing: 0;
	line-height: 1.2;
	text-transform: none;
	text-decoration: none;
	white-space: normal;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22), 0 1px 3px rgba(0, 0, 0, 0.18);
	transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
	pointer-events: auto;
	-webkit-tap-highlight-color: transparent;
}

.welcome-voice .welcome-voice__button:hover {
	transform: translateY(-1px);
	box-shadow: 0 10px 24px rgba(0, 0, 0, 0.26), 0 1px 3px rgba(0, 0, 0, 0.18);
}

.welcome-voice .welcome-voice__button:active {
	transform: scale(0.98);
}

.welcome-voice .welcome-voice__button:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px #ffffff, 0 0 0 6px var(--wv-bg), 0 6px 20px rgba(0, 0, 0, 0.22);
}

.welcome-voice .welcome-voice__button:disabled {
	opacity: 0.7;
	cursor: progress;
	transform: none;
}

/* ---- Dismiss ---- */
.welcome-voice .welcome-voice__dismiss {
	-webkit-appearance: none;
	appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 32px;
	height: 32px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(17, 24, 39, 0.75);
	color: #ffffff;
	font: inherit;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	pointer-events: auto;
	-webkit-tap-highlight-color: transparent;
}

.welcome-voice .welcome-voice__dismiss:hover {
	background: rgba(17, 24, 39, 0.95);
}

.welcome-voice .welcome-voice__dismiss:focus-visible {
	outline: 2px solid #ffffff;
	outline-offset: 2px;
	box-shadow: 0 0 0 4px rgba(17, 24, 39, 0.9);
}

/* ---- Entrance ---- */
@keyframes welcome-voice-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

.welcome-voice:not([hidden]) .welcome-voice__caption,
.welcome-voice:not([hidden]) .welcome-voice__row {
	animation: welcome-voice-in 0.3s ease-out both;
}

/* ---- Small screens ---- */
@media (max-width: 782px) {
	body.admin-bar .welcome-voice--top-right,
	body.admin-bar .welcome-voice--top-left,
	body.admin-bar .welcome-voice--top-center {
		top: calc(var(--wv-offset) + 46px);
	}
}

@media (max-width: 600px) {
	.welcome-voice {
		--wv-offset: 14px;

		font-size: 14px;
	}

	.welcome-voice .welcome-voice__caption {
		max-width: 220px;
	}

	.welcome-voice .welcome-voice__button {
		padding: 10px 16px;
	}
}

/* ---- Accessibility & print ---- */
@media (prefers-reduced-motion: reduce) {
	.welcome-voice:not([hidden]) .welcome-voice__caption,
	.welcome-voice:not([hidden]) .welcome-voice__row {
		animation: none;
	}

	.welcome-voice .welcome-voice__button {
		transition: none;
	}
}

@media print {
	.welcome-voice {
		display: none !important;
	}
}
