@use "../tokens" as *;

// Setup wizard pieces (components/wizard.js), values from the prototype (appendix C §7).

/* Card ------------------------------------------------------------------------------------------- */

.ssw-wz-card {
	background: #fff;
	border-radius: 8px;
	box-shadow: inset 0 0 0 1px $line-card;
}

.ssw-wz-card__body {
	padding: 40px 48px;
}

.ssw-wz-title {
	margin: 0;
	font-size: 22px;
	line-height: 1.3;
	font-weight: 600;
	color: $ink;
}

.ssw-wz-lead {
	margin: 8px 0 0;
	font-size: 14.5px;
	color: $text-2;
	text-wrap: pretty;
}

.ssw-wz-rows {
	margin-top: 20px;
	display: flex;
	flex-direction: column;
}

.ssw-wz-section-title {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.5;
	color: $ink;
}

/* Stepper ---------------------------------------------------------------------------------------- */

.ssw-stepper {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ssw-stepper__step {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
}

.ssw-stepper__line {
	width: 40px;
	height: 1px;
	background: #dcdcde;
	transition: background 240ms;

	.is-done > &,
	.is-current > & {
		background: $blue;
	}
}

.ssw-stepper__item {
	display: flex;
	align-items: center;
	gap: 8px;
	white-space: nowrap;
}

.ssw-stepper__dot {
	width: 24px;
	height: 24px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: 600;
	background: $blue;
	color: #fff;
	transition: background 240ms, color 240ms, box-shadow 240ms;

	.is-todo & {
		background: #fff;
		color: $muted-2;
		box-shadow: inset 0 0 0 1px $line-ring-strong;
	}
}

.ssw-stepper__label {
	font-size: 14px;
	font-weight: 400;
	color: $ink;

	.is-done & {
		color: $text;
	}

	.is-todo & {
		color: $muted-2;
	}
}

/* Rows ------------------------------------------------------------------------------------------- */

.ssw-wz-row {
	padding: 18px 0;
	box-shadow: inset 0 1px 0 $line-list;

	&.is-first {
		box-shadow: none;
	}

	&.is-last {
		padding-bottom: 0;
	}
}

.ssw-switchrow {
	display: flex;
	gap: 16px;
	align-items: center;
	cursor: pointer;

	@include focus-visible;
}

.ssw-switchrow__label {
	flex: 1;
	min-width: 0;
	font-size: 14px;
	font-weight: 500;
	color: $text;
}

.ssw-switchrow__track {
	width: 36px;
	height: 20px;
	border-radius: 999px;
	position: relative;
	flex: 0 0 36px;
	background: $off;
	transition: background 140ms $ease-std;

	&.is-on {
		background: $blue;
	}
}

.ssw-switchrow__knob {
	position: absolute;
	left: 3px;
	top: 4px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 2px 4px rgba(31, 41, 55, 0.12);
	transition: transform 240ms $ease-spring;

	.is-on > & {
		transform: translateX(18px);
	}
}

.ssw-wz-controlrow {
	display: flex;
	gap: 12px 24px;
	align-items: center;
	flex-wrap: wrap;
}

.ssw-wz-controlrow__label {
	flex: 1 1 260px;
	min-width: 0;
	font-size: 14px;
	font-weight: 500;
	color: $text;
}

.ssw-wz-controlrow__controls {
	display: flex;
	gap: 24px;
	flex-wrap: wrap;
	flex: 0 0 auto;
}

.ssw-wz-check {
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	font-size: 14px;
	color: $text;

	@include focus-visible;
}

.ssw-wz-check__box {
	width: 16px;
	height: 16px;
	flex: 0 0 16px;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #fff;
	box-shadow: inset 0 0 0 1px $faint;
	transition: background 140ms, box-shadow 140ms;

	svg {
		opacity: 0;
		transition: opacity 140ms;
	}

	.is-on > & {
		background: $blue;
		box-shadow: none;

		svg {
			opacity: 1;
		}
	}
}

/* Choice row ------------------------------------------------------------------------------------- */

.ssw-choice {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px 32px;
}

.ssw-choice__text {
	flex: 1 1 260px;
	min-width: 0;
}

.ssw-choice__head {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 4px 10px;
}

.ssw-choice__title {
	font-size: 14px;
	font-weight: 500;
	color: $ink;
}

.ssw-choice__meta {
	font-size: 13px;
	color: $muted-2; // prototype #8c8f94 fails WCAG AA (3.4:1); deliberate deviation, see tests/e2e/ui/samples.js
}

.ssw-choice__desc {
	margin-top: 4px;
	font-size: 13px;
	line-height: 1.5;
	color: $muted-2;
	text-wrap: pretty;
}

.ssw-choice__options {
	flex: 0 0 auto;
	display: flex;
	flex-wrap: wrap;
	gap: 4px 24px;
}

.ssw-radio {
	line-height: normal; // a plain <button> in the prototype
	display: flex;
	gap: 8px;
	align-items: center;
	text-align: left;
	padding: 2px 0;

	@include focus-visible;
}

.ssw-radio__dot {
	width: 16px;
	height: 16px;
	flex: 0 0 16px;
	border-radius: 50%;
	background: #fff;
	box-shadow: inset 0 0 0 1.5px $line-ring-strong;
	transition: box-shadow 140ms;

	.is-on > & {
		box-shadow: inset 0 0 0 5px $blue;
	}
}

.ssw-radio__label {
	font-size: 14px;
	font-weight: 400;
	color: $ink;
	white-space: nowrap;
}

/* Footer ----------------------------------------------------------------------------------------- */

.ssw-wz-foot {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 48px;
	box-shadow: inset 0 1px 0 $line-list;
}

.ssw-wz-back,
.ssw-wz-next {
	height: 40px;
	border-radius: 4px;
	font-size: 14px;
	font-weight: 500;
	display: flex;
	align-items: center;
	transition: background 140ms;

	@include focus-visible;
}

.ssw-wz-back {
	padding: 0 14px 0 10px;
	margin-left: -10px;
	background: transparent;
	color: $text;
	gap: 6px;

	&:hover {
		background: $line-list;
	}
}

.ssw-wz-back:disabled {
	opacity: 0.45;
	cursor: default;

	&:hover {
		background: transparent;
	}
}

// Next and the note beside it ("2 selected" on More Tools).
.ssw-wz-foot__end {
	margin-left: auto;
	display: flex;
	align-items: center;
	gap: 14px;
}

.ssw-wz-foot__note {
	font-size: 14px;
	color: $muted;
	white-space: nowrap;
}

// "Skip for now" before Next (More Tools): a plain text link.
.ssw-wz-foot__skip {
	padding: 6px 4px;
	border-radius: 4px;
	font-size: 14px;
	color: $muted;
	white-space: nowrap;
	transition: color 140ms ease;

	&:hover {
		color: $ink;
		text-decoration: underline;
	}

	@include focus-visible;
}

.ssw-wz-next {
	padding: 0 20px;
	background: $blue;
	color: #fff;
	gap: 8px;

	&:hover {
		background: $blue-2;
	}

	&:disabled {
		background: #a7aaad;
		cursor: default;
	}
}

/* Done ------------------------------------------------------------------------------------------- */

.ssw-done-hero {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	padding-top: 8px;
}

.ssw-done-hero__title {
	margin: 22px 0 0;
	font-size: 26px;
	line-height: 1.25;
	font-weight: 600;
	color: $ink;
}

.ssw-done-hero__text {
	margin: 8px 0 0;
	font-size: 15px;
	line-height: 1.6;
	color: $muted;
	max-width: 520px;
	text-wrap: pretty;
}

.ssw-done-art {
	display: flex;
	transition: transform 200ms $ease;

	@include focus-visible;

	&:hover {
		transform: scale(1.04);
	}

	&:active {
		transform: scale(0.97);
	}

	svg {
		overflow: visible;
		display: block;
	}
}

.ssw-done-art__halo,
.ssw-done-art__disc,
.ssw-done-art__orbit,
.ssw-done-art__dot {
	transform-box: view-box;
	transform-origin: 60px 60px;
}

.ssw-done-art__halo {
	transform: scale(0);
	animation: ssw-pop 520ms $ease 80ms 1 forwards, ssw-halo 3.2s ease-in-out 1.4s infinite;
}

.ssw-done-art__disc {
	transform: scale(0);
	animation: ssw-pop 480ms $ease 160ms 1 forwards;
}

.ssw-done-art__ring {
	animation: ssw-draw 620ms $ease 200ms 1 forwards;
}

.ssw-done-art__tick {
	animation: ssw-draw 380ms $ease 640ms 1 forwards;
}

.ssw-done-art__orbit {
	animation: ssw-spin 30s linear 1.4s infinite;
}

.ssw-done-art__dot {
	opacity: 0;
	animation: ssw-burst 700ms $ease 560ms 1 forwards;
}

@keyframes ssw-draw {

	to {
		stroke-dashoffset: 0;
	}
}

@keyframes ssw-pop {

	0% {
		transform: scale(0);
	}

	60% {
		transform: scale(1.08);
	}

	100% {
		transform: scale(1);
	}
}

@keyframes ssw-burst {

	0% {
		transform: translate(0, 0) scale(0);
		opacity: 0;
	}

	20% {
		opacity: 1;
	}

	70% {
		transform: translate(calc(var(--x) * 1.15), calc(var(--y) * 1.15)) scale(1.15);
	}

	100% {
		transform: translate(var(--x), var(--y)) scale(1);
		opacity: 1;
	}
}

@keyframes ssw-spin {

	to {
		transform: rotate(360deg);
	}
}

@keyframes ssw-halo {

	0%,
	100% {
		transform: scale(1);
		opacity: 0.55;
	}

	50% {
		transform: scale(1.08);
		opacity: 0.2;
	}
}

// Reduced motion: show the finished state instead of nothing (base.scss turns animations off).
@media (prefers-reduced-motion: reduce) {

	.ssw-done-art__halo,
	.ssw-done-art__disc {
		transform: none;
	}

	.ssw-done-art__ring,
	.ssw-done-art__tick {
		stroke-dashoffset: 0;
	}

	.ssw-done-art__dot {
		opacity: 1;
		transform: translate(var(--x), var(--y));
	}
}

/* Summary and next steps ------------------------------------------------------------------------- */

.ssw-wz-section {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.ssw-stats {
	border-radius: 8px;
	box-shadow: inset 0 0 0 1px $line-card;
	background: #fff;
	overflow: hidden;
}

.ssw-stats__grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.ssw-stat {
	padding: 18px 20px;
	box-shadow: -1px 0 0 $line-list;
}

.ssw-stat__value {
	font-size: 24px;
	line-height: 1.2;
	font-weight: 600;
	color: $ink;
	font-variant-numeric: tabular-nums;
}

.ssw-stat__label {
	margin-top: 4px;
	font-size: 13px;
	color: $muted;
}

.ssw-stats__notices {
	display: flex;
	flex-direction: column;
	padding: 4px 20px;
	box-shadow: inset 0 1px 0 $line-list;
}

.ssw-stats__notice {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 10px 0;

	svg {
		flex: 0 0 16px;
		margin-top: 2px;
	}

	> span {
		flex: 1;
		min-width: 0;
		font-size: 14px;
		color: $text;
		text-wrap: pretty;
	}

	a {
		color: $blue;
		text-decoration: underline;
		text-underline-offset: 2px;
	}
}

.ssw-next-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 12px;
}

.ssw-next-card {
	line-height: normal;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 10px;
	padding: 18px;
	border-radius: 8px;
	background: #fff;
	box-shadow: inset 0 0 0 1px $line-card;
	text-align: left;
	transition: box-shadow 140ms, transform 140ms;

	@include focus-visible;

	&:hover {
		box-shadow: inset 0 0 0 1px $blue, 0 4px 14px rgba(34, 113, 177, 0.08);
	}
}

.ssw-next-card__icon {
	width: 32px;
	height: 32px;
	border-radius: 8px;
	background: $tint;
	color: $blue;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ssw-next-card__body {
	display: block;
}

.ssw-next-card__title {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 14px;
	font-weight: 600;
	color: $ink;
}

.ssw-next-card__desc {
	display: block;
	margin-top: 3px;
	font-size: 13px;
	color: $muted;
	text-wrap: pretty;
}
