/**
 * Changeloger Guided Tour
 *
 * Overlay, spotlight and popover for the onboarding tour.
 *
 * @since 1.12.0
 */

.cha-tour {
	--cha-tour-accent: #6366f1;
	--cha-tour-bg: #ffffff;
	--cha-tour-fg: #1f2937;
	--cha-tour-muted: #6b7280;
	--cha-tour-border: #e5e7eb;

	position: fixed;
	inset: 0;

	/* One above .cha-modal-overlay (100000) so in-modal steps stay reachable. */
	z-index: 100001;
	display: none;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

	/*
	 * The root spans the viewport, so it must stay click-through or it would
	 * swallow clicks on the very controls the tour asks the user to press.
	 * Only the popover (and the dimmed overlay on centred steps) opt back in.
	 */
	pointer-events: none;
}

.cha-tour.is-open {
	display: block;
}

/*
 * A modal the tour did not open is covering the page. Stay mounted so the step
 * resumes cleanly, but get out of the user's way while they deal with it.
 */
.cha-tour.is-blocked {
	visibility: hidden;
	pointer-events: none;
}

/* Inside a modal, its own backdrop supplies the dimming. */
.cha-tour.in-modal .cha-tour-spotlight {
	box-shadow: none;
}

.cha-tour.in-modal .cha-tour-overlay {
	display: none;
}

/* ------------------------------------------------------------------ *
 * Overlay + spotlight
 * ------------------------------------------------------------------ */

.cha-tour-overlay {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	animation: cha-tour-fade 0.2s ease-out;
}

/*
 * The spotlight is a transparent box with a huge outer shadow, which punches a
 * hole in the overlay without needing an SVG mask.
 */
.cha-tour-spotlight {
	position: fixed;
	border-radius: 8px;
	box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55);
	outline: 2px solid var(--cha-tour-accent);
	outline-offset: 2px;
	pointer-events: none;
	transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
}

/*
 * On anchored steps the spotlight's own ring shadow supplies the dimming, so
 * the flat overlay stands down to avoid double-darkening the page.
 */
.cha-tour:not(.is-centered) .cha-tour-overlay {
	background: transparent;
}

/* Centred steps have no spotlight, so the overlay dims and blocks the page. */
.cha-tour.is-centered .cha-tour-overlay {
	pointer-events: auto;
}

/* ------------------------------------------------------------------ *
 * Popover
 * ------------------------------------------------------------------ */

.cha-tour-pop {
	position: fixed;
	width: 340px;
	max-width: calc(100vw - 24px);
	box-sizing: border-box;
	padding: 20px;
	background: var(--cha-tour-bg);
	color: var(--cha-tour-fg);
	border-radius: 12px;
	box-shadow: 0 20px 45px rgba(15, 23, 42, 0.25);
	animation: cha-tour-pop-in 0.22s ease-out;
	pointer-events: auto;
}

.cha-tour.is-centered .cha-tour-pop {
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 440px;
	padding: 28px;
	text-align: center;
}

.cha-tour-pop-arrow {
	position: absolute;
	width: 12px;
	height: 12px;
	background: var(--cha-tour-bg);
	transform: rotate(45deg);
}

.cha-tour-pop[data-placement="bottom"] .cha-tour-pop-arrow {
	top: -6px;
	margin-left: -6px;
}

.cha-tour-pop[data-placement="top"] .cha-tour-pop-arrow {
	bottom: -6px;
	margin-left: -6px;
}

.cha-tour-pop[data-placement="right"] .cha-tour-pop-arrow {
	left: -6px;
	margin-top: -6px;
}

.cha-tour-pop[data-placement="left"] .cha-tour-pop-arrow {
	right: -6px;
	margin-top: -6px;
}

.cha-tour.is-centered .cha-tour-pop-arrow {
	display: none;
}

/* ------------------------------------------------------------------ *
 * Content
 * ------------------------------------------------------------------ */

.cha-tour-close {
	position: absolute;
	top: 10px;
	right: 10px;
	width: 26px;
	height: 26px;
	padding: 0;
	font-size: 20px;
	line-height: 1;
	color: var(--cha-tour-muted);
	background: none;
	border: 0;
	border-radius: 6px;
	cursor: pointer;
}

.cha-tour-close:hover {
	background: #f3f4f6;
	color: var(--cha-tour-fg);
}

.cha-tour-count {
	margin-bottom: 6px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--cha-tour-accent);
}

.cha-tour-title {
	margin: 0 0 8px;
	font-size: 17px;
	font-weight: 600;
	line-height: 1.35;
	color: var(--cha-tour-fg);
}

.cha-tour.is-centered .cha-tour-title {
	font-size: 22px;
}

.cha-tour-body {
	margin: 0 0 16px;
	font-size: 13.5px;
	line-height: 1.6;
	color: var(--cha-tour-muted);
}

.cha-tour-badge {
	display: inline-block;
	margin-bottom: 8px;
	padding: 2px 8px;
	font-size: 10.5px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #92400e;
	background: #fef3c7;
	border-radius: 999px;
}

.cha-tour-badge[hidden] {
	display: none !important;
}

/* Demo-content button: the shortest path from empty form to published. */
.cha-tour-action {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	margin: 0 0 14px;
	padding: 10px 16px;
	font-size: 13px;
	font-weight: 600;
	color: #fff;
	background: linear-gradient(135deg, #6366f1, #8b5cf6);
	border: 0;
	border-radius: 8px;
	cursor: pointer;
	transition: filter 0.15s ease;
}

.cha-tour-action::before {
	content: "\2728";
	font-size: 14px;
}

.cha-tour-action:hover:not(:disabled) {
	filter: brightness(1.08);
}

.cha-tour-action.is-done {
	color: #166534;
	background: #dcfce7;
	cursor: default;
}

.cha-tour-action.is-done::before {
	content: "\2713";
}

.cha-tour-action[hidden] {
	display: none !important;
}

.cha-tour-hint {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 16px;
	padding: 9px 12px;
	font-size: 12.5px;
	font-weight: 500;
	color: #3730a3;
	background: #eef2ff;
	border-radius: 8px;
}

.cha-tour-hint::before {
	content: "";
	flex: 0 0 8px;
	width: 8px;
	height: 8px;
	background: var(--cha-tour-accent);
	border-radius: 50%;
	animation: cha-tour-pulse 1.4s ease-in-out infinite;
}

/* ------------------------------------------------------------------ *
 * Progress + actions
 * ------------------------------------------------------------------ */

.cha-tour-progress {
	height: 3px;
	margin-bottom: 16px;
	background: var(--cha-tour-border);
	border-radius: 999px;
	overflow: hidden;
}

.cha-tour-progress-bar {
	display: block;
	height: 100%;
	background: var(--cha-tour-accent);
	border-radius: 999px;
	transition: width 0.3s ease;
}

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

.cha-tour-actions-right {
	display: flex;
	align-items: center;
	gap: 8px;
}

.cha-tour-actions button {
	padding: 8px 16px;
	font-size: 13px;
	font-weight: 500;
	border-radius: 7px;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.cha-tour-skip {
	padding-left: 0 !important;
	color: var(--cha-tour-muted);
	background: none;
	border: 0;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.cha-tour-skip:hover {
	color: var(--cha-tour-fg);
}

.cha-tour-back {
	color: var(--cha-tour-fg);
	background: #fff;
	border: 1px solid var(--cha-tour-border);
}

.cha-tour-back:hover {
	background: #f9fafb;
}

.cha-tour-next {
	color: #fff;
	background: var(--cha-tour-accent);
	border: 1px solid var(--cha-tour-accent);
}

.cha-tour-next:hover {
	background: #4f46e5;
	border-color: #4f46e5;
}

.cha-tour-back[hidden],
.cha-tour-next[hidden],
.cha-tour-hint[hidden] {
	display: none !important;
}

/* ------------------------------------------------------------------ *
 * Skip confirmation
 * ------------------------------------------------------------------ */

.cha-tour-confirm {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	padding: 20px;
	text-align: center;
	background: var(--cha-tour-bg);
	border-radius: 12px;
}

.cha-tour-confirm-title {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	color: var(--cha-tour-fg);
}

.cha-tour-confirm-body {
	margin: 0 0 14px;
	font-size: 12.5px;
	line-height: 1.5;
	color: var(--cha-tour-muted);
}

.cha-tour-confirm-actions {
	display: flex;
	gap: 8px;
}

.cha-tour-confirm-actions button {
	padding: 8px 16px;
	font-size: 13px;
	font-weight: 500;
	border-radius: 7px;
	cursor: pointer;
}

.cha-tour-confirm-no {
	color: #fff;
	background: var(--cha-tour-accent);
	border: 1px solid var(--cha-tour-accent);
}

.cha-tour-confirm-yes {
	color: var(--cha-tour-muted);
	background: #fff;
	border: 1px solid var(--cha-tour-border);
}

/* ------------------------------------------------------------------ *
 * Celebration
 * ------------------------------------------------------------------ */

.cha-tour-confetti {
	position: fixed;
	inset: 0;
	overflow: hidden;
	pointer-events: none;
}

.cha-tour-confetti i {
	position: absolute;
	top: -12px;
	width: 8px;
	height: 14px;
	border-radius: 1px;
	animation-name: cha-tour-fall;
	animation-timing-function: cubic-bezier(0.2, 0.6, 0.5, 1);
	animation-fill-mode: forwards;
}

@keyframes cha-tour-fall {
	0% {
		opacity: 1;
		transform: translateY(0) rotate(0deg);
	}

	100% {
		opacity: 0;
		transform: translateY(102vh) rotate(680deg);
	}
}

/* ------------------------------------------------------------------ *
 * Motion
 * ------------------------------------------------------------------ */

@keyframes cha-tour-fade {
	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

@keyframes cha-tour-pop-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.cha-tour.is-centered .cha-tour-pop {
	animation: none;
}

@keyframes cha-tour-pulse {
	0%,
	100% {
		opacity: 1;
		transform: scale(1);
	}

	50% {
		opacity: 0.4;
		transform: scale(0.75);
	}
}

@media (prefers-reduced-motion: reduce) {
	.cha-tour-overlay,
	.cha-tour-pop,
	.cha-tour-spotlight,
	.cha-tour-progress-bar,
	.cha-tour-hint::before {
		animation: none !important;
		transition: none !important;
	}
}

/* ------------------------------------------------------------------ *
 * Small screens
 * ------------------------------------------------------------------ */

@media screen and (max-width: 782px) {
	.cha-tour-pop,
	.cha-tour.is-centered .cha-tour-pop {
		top: auto !important;
		bottom: 16px;
		left: 16px !important;
		right: 16px;
		width: auto;
		max-width: none;
		transform: none;
	}

	.cha-tour-pop-arrow {
		display: none;
	}
}
