/*
 * ris-tour.css
 * ------------
 * First-visit guided tour (coach marks). Styles for:
 *   - the dimming overlay + clip-path spotlight cut-out
 *   - the amber spotlight ring with a single soft glow "breathe" pulse
 *   - the anchored coach-mark card (eyebrow chip, serif title, dots, buttons)
 *   - the centered welcome / finish dialog
 *
 * Reuses the existing design-system tokens (radius, shadows, fonts) and the
 * amber accent (#e8a44a — chart-4 / section-fiscal, same chip amber used on
 * the homepage "New" ribbon). No new palette.
 */

:root {
	--tour-amber: #e8a44a;
	--tour-amber-ink: #9a6a14; /* darkened amber, ≥4.5:1 on white */
	--tour-amber-soft: rgba(232, 164, 74, 0.35);
	--tour-dim: rgba(17, 24, 39, 0.62);
	--tour-card-radius: var(--radius);
	--tour-z: 100000;
}

/* ── Root container (present only while the tour is active) ───────────── */
.ris-tour-root {
	position: fixed;
	inset: 0;
	z-index: var(--tour-z);
	/* The root itself never blocks — its children (overlay/card) do. */
	pointer-events: none;
}

.ris-tour-root[hidden] {
	display: none;
}

/* ── Dimming overlay + spotlight hole ────────────────────────────────── */
/* The overlay is a full-viewport dim. A clip-path (fill-rule evenodd) punches
   a rounded-rect hole over the spotlit element. clip-path removes the hole
   region from hit-testing too, so real clicks fall THROUGH the hole to the
   live element (hybrid advancement) while every other click is blocked. */
.ris-tour-overlay {
	position: fixed;
	inset: 0;
	background: var(--tour-dim);
	pointer-events: auto;
	opacity: 0;
	transition: opacity 260ms cubic-bezier(0.4, 0, 0.2, 1);
	-webkit-tap-highlight-color: transparent;
}

.ris-tour-root.is-visible .ris-tour-overlay {
	opacity: 1;
}

/* ── Spotlight ring (visual only; hole is cut by the overlay) ─────────── */
.ris-tour-spotlight {
	position: fixed;
	pointer-events: none;
	border-radius: 12px;
	border: 2px solid var(--tour-amber);
	box-shadow:
		0 0 0 3px rgba(232, 164, 74, 0.28),
		0 0 22px 4px var(--tour-amber-soft);
	transition:
		top 320ms cubic-bezier(0.4, 0, 0.2, 1),
		left 320ms cubic-bezier(0.4, 0, 0.2, 1),
		width 320ms cubic-bezier(0.4, 0, 0.2, 1),
		height 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Single soft glow "breathe" pulse when a step appears — the signature moment. */
.ris-tour-spotlight.is-pulsing {
	animation: ris-tour-breathe 1200ms cubic-bezier(0.4, 0, 0.2, 1) 1;
}

@keyframes ris-tour-breathe {
	0% {
		box-shadow:
			0 0 0 3px rgba(232, 164, 74, 0.28),
			0 0 0 0 rgba(232, 164, 74, 0.5);
	}
	45% {
		box-shadow:
			0 0 0 5px rgba(232, 164, 74, 0.36),
			0 0 34px 12px rgba(232, 164, 74, 0.45);
	}
	100% {
		box-shadow:
			0 0 0 3px rgba(232, 164, 74, 0.28),
			0 0 22px 4px var(--tour-amber-soft);
	}
}

/* ── Coach-mark card ─────────────────────────────────────────────────── */
.ris-tour-card {
	position: fixed;
	z-index: calc(var(--tour-z) + 2);
	pointer-events: auto;
	width: min(360px, calc(100vw - 32px));
	box-sizing: border-box;
	background: var(--card, #fff);
	color: var(--card-foreground, #1d2939);
	border: 1px solid var(--border, #e5e9f2);
	border-radius: var(--tour-card-radius);
	box-shadow:
		0 10px 15px -3px rgba(0, 0, 0, 0.12),
		0 4px 6px -4px rgba(0, 0, 0, 0.1),
		0 24px 48px -12px rgba(29, 41, 57, 0.28);
	padding: 20px 20px 18px;
	opacity: 0;
	transform: translateY(6px) scale(0.985);
	transition:
		opacity 240ms cubic-bezier(0.4, 0, 0.2, 1),
		transform 240ms cubic-bezier(0.4, 0, 0.2, 1),
		top 300ms cubic-bezier(0.4, 0, 0.2, 1),
		left 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.ris-tour-root.is-visible .ris-tour-card {
	opacity: 1;
	transform: translateY(0) scale(1);
}

/* Centered dialog variant (steps 1 & 6): no cut-out, card is the focus. */
.ris-tour-card.is-centered {
	top: 50%;
	left: 50%;
	transform: translate(-50%, calc(-50% + 8px)) scale(0.985);
	width: min(440px, calc(100vw - 32px));
	padding: 26px 26px 22px;
}

.ris-tour-root.is-visible .ris-tour-card.is-centered {
	transform: translate(-50%, -50%) scale(1);
}

/* Optional little arrow pointing toward the spotlight. */
.ris-tour-card__arrow {
	position: absolute;
	width: 14px;
	height: 14px;
	background: var(--card, #fff);
	border: 1px solid var(--border, #e5e9f2);
	transform: rotate(45deg);
}
.ris-tour-card--below .ris-tour-card__arrow {
	top: -8px;
	border-right: none;
	border-bottom: none;
}
.ris-tour-card--above .ris-tour-card__arrow {
	bottom: -8px;
	border-left: none;
	border-top: none;
}
.ris-tour-card.is-centered .ris-tour-card__arrow {
	display: none;
}

/* ── Eyebrow chip (amber TOUR badge, matches homepage badge style) ────── */
.ris-tour-card__eyebrow {
	display: inline-block;
	width: fit-content;
	font-family: var(--font-sans);
	font-size: 0.6875rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 1px;
	color: #fff;
	background: var(--tour-amber);
	padding: 0.25rem 0.75rem;
	border-radius: 9999px;
	margin-bottom: 12px;
}

/* ── Title + body ────────────────────────────────────────────────────── */
.ris-tour-card__title {
	font-family: var(--font-display, "Bitter", Georgia, serif);
	font-size: 1.25rem;
	font-weight: 700;
	line-height: 1.25;
	color: var(--foreground, #1d2939);
	margin: 0 0 8px;
}

.ris-tour-card.is-centered .ris-tour-card__title {
	font-size: 1.5rem;
}

.ris-tour-card__body {
	font-family: var(--font-sans);
	font-size: 0.9375rem;
	line-height: 1.55;
	color: #4a525d;
	margin: 0;
}

/* ── Footer: dots + buttons ──────────────────────────────────────────── */
.ris-tour-card__footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-top: 18px;
}

.ris-tour-card__dots {
	display: flex;
	align-items: center;
	gap: 6px;
}

.ris-tour-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #d7dce6;
	transition:
		background-color var(--transition-fast, 150ms ease),
		transform var(--transition-fast, 150ms ease);
}

.ris-tour-dot.is-active {
	background: var(--tour-amber);
	transform: scale(1.25);
}

.ris-tour-card__actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

/* Buttons */
.ris-tour-btn {
	font-family: var(--font-sans);
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1;
	border-radius: 8px;
	padding: 9px 16px;
	cursor: pointer;
	border: 1px solid transparent;
	transition:
		background-color var(--transition-fast, 150ms ease),
		border-color var(--transition-fast, 150ms ease),
		color var(--transition-fast, 150ms ease),
		box-shadow var(--transition-fast, 150ms ease);
}

.ris-tour-btn:focus-visible {
	outline: 2px solid var(--tour-amber);
	outline-offset: 2px;
}

/* Primary — amber */
.ris-tour-btn--primary {
	background: var(--tour-amber);
	color: #2a1c05;
	box-shadow: var(--shadow-xs, 0 1px 2px rgba(0, 0, 0, 0.05));
}
.ris-tour-btn--primary:hover {
	background: #dd9736;
}

/* Quiet — Back */
.ris-tour-btn--quiet {
	background: transparent;
	color: var(--text-muted, #74819a);
	border-color: transparent;
	padding-inline: 10px;
}
.ris-tour-btn--quiet:hover {
	color: var(--foreground, #1d2939);
	background: var(--muted, #f3f5fa);
}

/* Welcome dialog buttons row */
.ris-tour-card__welcome-actions {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 10px;
	margin-top: 22px;
}

/* Sub-row holding the quiet "Skip tour" link under the footer. */
.ris-tour-card__subrow {
	display: flex;
	justify-content: flex-start;
	margin-top: 10px;
	padding-top: 10px;
	border-top: 1px solid var(--border, #eef1f7);
}

/* Skip link (quiet text) */
.ris-tour-skip {
	font-family: var(--font-sans);
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--text-muted, #74819a);
	background: none;
	border: none;
	padding: 4px 2px;
	cursor: pointer;
	text-decoration: none;
}
.ris-tour-skip:hover {
	color: var(--foreground, #1d2939);
	text-decoration: underline;
}
.ris-tour-skip:focus-visible {
	outline: 2px solid var(--tour-amber);
	outline-offset: 2px;
	border-radius: 4px;
}

/* The dialog container receives initial focus (tabindex="-1") — it must
   never show its own ring; controls keep :focus-visible rings when tabbed. */
.ris-tour-card:focus {
	outline: none;
}

/* Close (✕) on the welcome dialog */
.ris-tour-card__close {
	position: absolute;
	top: 12px;
	right: 12px;
	width: 30px;
	height: 30px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: none;
	background: transparent;
	color: var(--text-muted, #74819a);
	border-radius: 8px;
	cursor: pointer;
	font-size: 0.95rem;
	line-height: 1;
	transition: background-color var(--transition-fast, 150ms ease), color var(--transition-fast, 150ms ease);
}
.ris-tour-card__close:hover {
	background: var(--muted, #f3f5fa);
	color: var(--foreground, #1d2939);
}
.ris-tour-card__close:focus-visible {
	outline: 2px solid var(--tour-amber);
	outline-offset: 2px;
}

/* Header row for the welcome card (title beside nothing; close is absolute) */
.ris-tour-card__footer--welcome {
	margin-top: 0;
}

/* ── Small screens ───────────────────────────────────────────────────── */
@media (max-width: 520px) {
	.ris-tour-card {
		width: calc(100vw - 24px);
	}
	/* On phones, anchored cards can be cramped near the target — the engine
	   pins them to the bottom via .is-docked. */
	.ris-tour-card.is-docked {
		left: 12px !important;
		right: 12px;
		top: auto !important;
		bottom: 16px;
		width: auto;
	}
	.ris-tour-card.is-docked .ris-tour-card__arrow {
		display: none;
	}
}

/* ── Reduced motion: snap positions, no pulse, no entrance drift ─────── */
@media (prefers-reduced-motion: reduce) {
	.ris-tour-overlay,
	.ris-tour-spotlight,
	.ris-tour-card {
		transition: none !important;
	}
	.ris-tour-spotlight.is-pulsing {
		animation: none !important;
	}
	.ris-tour-card,
	.ris-tour-root.is-visible .ris-tour-card {
		transform: none !important;
	}
	.ris-tour-card.is-centered,
	.ris-tour-root.is-visible .ris-tour-card.is-centered {
		transform: translate(-50%, -50%) !important;
	}
}
