/*
 * Buttons. Values follow the handoff's CSS implementation guide, which is more
 * specific than the component table where the two disagree - see the notes at
 * the foot of this file.
 */

.btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-8);
	height: 52px;
	padding: var(--space-12) var(--space-24);
	border: none;
	border-radius: var(--radius-lg);
	font-family: var(--font-body);
	font-size: var(--text-body);
	font-weight: 600;
	line-height: 1.5;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition: background var(--duration-state) ease,
		box-shadow var(--duration-state) ease,
		opacity var(--duration-state) ease;
}

.btn:focus-visible {
	outline: 2px solid var(--color-primary);
	outline-offset: 2px;
}

.btn[disabled],
.btn[aria-disabled="true"] {
	opacity: 0.4;
	cursor: not-allowed;
	pointer-events: none;
}

.btn-sm {
	height: 46px;
}

.btn-nav {
	height: 50px;
}

.btn-full {
	width: 100%;
}

/* Trailing arrow slides on hover. */
.btn__arrow {
	transition: transform var(--duration-hover) var(--ease-out-quart);
}

.btn:hover .btn__arrow {
	transform: translateX(3px);
}

/* --- Primary --- */

.btn-primary {
	background: var(--color-primary);
	color: var(--color-text-inverse);
}

.btn-primary:hover {
	background: var(--color-primary-hover);
}

.btn-primary:active {
	background: var(--color-primary-active);
	box-shadow: inset 0 2px 4px rgb(0 0 0 / 20%);
}

/* --- Secondary and ghost --- */

.btn-secondary,
.btn-ghost {
	padding: var(--space-12) var(--space-42);
	border: 1.5px solid var(--color-border-default);
	color: var(--color-text-primary);
}

.btn-secondary {
	background: var(--color-bg-default);
}

.btn-ghost {
	background: transparent;
}

.btn-secondary:hover,
.btn-ghost:hover {
	background: var(--color-surface-light);
}

.btn-secondary:active,
.btn-ghost:active {
	background: var(--color-surface-gray);
	box-shadow: inset 0 2px 4px rgb(0 0 0 / 10%);
}

/* --- Dark, used for the nav CTA --- */

.btn-dark {
	height: 50px;
	padding: var(--space-8) var(--space-20);
	background: var(--color-surface-dark);
	color: var(--color-text-inverse);
}

.btn-dark:hover {
	background: var(--color-surface-dark-hover);
}

.btn-dark:active {
	background: #000;
	box-shadow: inset 0 2px 4px rgb(0 0 0 / 30%);
}

/* --- Loading --- */

.btn.is-loading {
	pointer-events: none;
	opacity: 0.7;
}

.btn.is-loading .btn__label {
	visibility: hidden;
}

.btn.is-loading::after {
	content: "";
	position: absolute;
	width: 16px;
	height: 16px;
	border: 2px solid currentcolor;
	border-top-color: transparent;
	border-radius: 50%;
	animation: btn-spin 600ms linear infinite;
}

@keyframes btn-spin {
	to {
		transform: rotate(360deg);
	}
}

/* --- Mobile --- */

@media (max-width: 767px) {
	.btn {
		width: 100%;
		border-radius: var(--radius-md);
	}

	/* A distinct variant rather than a width override: on mobile the design
	   fills the CTA with warm white instead of purple. */
	.btn-mobile-cta {
		padding: var(--space-14) var(--space-24);
		background: var(--color-bg-warm);
		color: var(--color-text-primary);
	}

	.btn-mobile-cta:hover {
		background: var(--color-surface-muted);
	}

	.btn-mobile-cta:active {
		background: var(--color-surface-gray);
	}

	/* The nav CTA stays compact next to the hamburger. */
	.site-header .btn {
		width: auto;
	}
}

@media (prefers-reduced-motion: reduce) {
	.btn,
	.btn__arrow {
		transition: none;
	}

	.btn.is-loading::after {
		animation-duration: 2s;
	}
}

/*
 * Conflicts resolved in favour of the CSS implementation guide:
 *   padding      12px 24px  (component table says 8px 24px)
 *   border       1.5px      (component table says 1px)
 *   disabled     opacity .4 (interaction section says .5)
 *   pressed      inset shadow + darker fill (interaction section says scale .98)
 * Worth confirming with the designer; each is a one-line change here.
 */
