@use "../tokens" as *;

// Settings-app shell (appendix B §4, §7.1, §8).

// Top bar ------------------------------------------------------------------------------------------
.ssw-topbar {
	position: sticky;
	top: 32px;
	z-index: 25;
	display: flex;
	align-items: center;
	gap: 12px;
	height: 60px;
	padding: 0 max(20px, calc((100% - 1260px) / 2));
	border-bottom: 1px solid $line-card;
	background: #fff;
	box-shadow: none;
	transition: box-shadow 200ms ease;

	&.is-stuck {
		box-shadow: 0 4px 12px -4px rgba(16, 17, 20, 0.12);
	}
}

.ssw-topbar__logo {
	height: 24px;
	width: auto;
	display: block;
	flex: 0 0 auto;
}

.ssw-topbar__version {
	flex: 0 0 auto;
	font-size: 12px;
	font-weight: 500;
	color: $muted-2;
	font-variant-numeric: tabular-nums;
}

.ssw-tabs {
	display: flex;
	gap: 2px;
	margin-left: 24px;
	align-self: stretch;
	min-width: 0;
	overflow-x: auto;
	scrollbar-width: none;
}

.ssw-tabs__sep {
	align-self: center;
	flex: 0 0 1px;
	width: 1px;
	height: 20px;
	margin: 0 6px;
	background: #dcdcde;
}

.ssw-tabs__tab {
	position: relative;
	display: flex;
	align-items: center;
	border: 0;
	background: transparent;
	font-size: 15px;
	font-weight: 500;
	color: $text-2;
	padding: 0 14px;
	cursor: pointer;
	white-space: nowrap;
	transition: color 160ms ease;

	@include focus-visible;

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

.ssw-tabs__bar {
	position: absolute;
	left: 10px;
	right: 10px;
	bottom: 0;
	height: 2px;
	background: $blue;
	border-radius: 2px 2px 0 0;
	transform: scaleX(0);
	transform-origin: center;
	transition: transform 200ms $ease;

	.is-on > & {
		transform: scaleX(1);
	}
}

// Phone widths (WordPress's 782px admin breakpoint) --------------------------------------------------
// The tabs take a row of their own and scroll sideways, faded at the edge that hides more (classes
// set by TopBar). The bar stops sticking: the admin bar above it grows to 46px, then scrolls away
// at 600px, and two sticky rows would eat a phone's screen.
@media screen and (max-width: 782px) {

	.ssw-topbar {
		position: relative;
		top: auto;
		flex-wrap: wrap;
		height: auto;
		row-gap: 0;
		padding: 0 16px;
	}

	.ssw-topbar__logo {
		margin: 14px 0;
	}

	.ssw-tabs {
		order: 1;
		flex: 0 0 calc(100% + 32px);
		height: 44px;
		margin: 0 -16px;
		padding: 0 6px;
		border-top: 1px solid $line-card;

		&.has-more-end {
			mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
		}

		&.has-more-start {
			mask-image: linear-gradient(to left, #000 calc(100% - 48px), transparent);
		}

		&.has-more-start.has-more-end {
			mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent);
		}
	}

	.ssw-tabs__tab {
		font-size: 14px;
		padding: 0 10px;
	}

	.ssw-tabs__bar {
		left: 6px;
		right: 6px;
	}
}

// Get Help -----------------------------------------------------------------------------------------
.ssw-help {
	position: relative;
	margin-left: auto;
	flex: 0 0 auto;
}

.ssw-help__button {
	width: 36px;
	height: 36px;
	border: 0;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
	outline: none;
	background: transparent;
	color: $text-2;
	transition: background 140ms ease, color 140ms ease;

	@include focus-visible;

	&:hover,
	&.is-open {
		background: $tint;
		color: $blue;
	}
}

.ssw-help__menu {
	position: absolute;
	top: calc(100% + 4px);
	right: 0;
	z-index: 60;
	width: 240px;
	background: #fff;
	border-radius: $radius-menu;
	box-shadow: $shadow-menu;
	padding: 4px;
	display: flex;
	flex-direction: column;
	gap: 3px;
	transform-origin: top right;
	transition: opacity 160ms ease, transform 160ms $ease;
	opacity: 0;
	transform: translateY(-4px) scaleY(0.97);
	pointer-events: none;

	&.is-open {
		opacity: 1;
		transform: none;
		pointer-events: auto;
	}
}

.ssw-admin .ssw-help__item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 7px 10px;
	border-radius: $radius-control;
	font-size: 14px;
	font-weight: 400;
	color: $text;
	text-decoration: none;
	transition: background 120ms ease, color 120ms ease;

	&:hover,
	&:focus-visible {
		background: $tint;
		color: $blue;
		outline: none;
	}
}

.ssw-help__label {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.ssw-help__ext {
	opacity: 0;
	transform: translate(-3px, 3px);
	transition: opacity 140ms ease, transform 160ms $ease;

	&.is-on {
		opacity: 1;
		transform: translate(0, 0);
	}
}

// Buttons used across the app ------------------------------------------------------------------
.ssw-btn {
	height: 36px;
	padding: 0 14px;
	border: 0;
	border-radius: $radius-control;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	white-space: nowrap;

	@include focus-visible;

	&.is-40 {
		height: 40px;
		padding: 0 16px;
	}

	&.is-secondary {
		background: #fff;
		box-shadow: inset 0 0 0 1px $line-ring;
		color: $text;
		transition: box-shadow 140ms ease;

		&:hover {
			box-shadow: inset 0 0 0 1px $faint;
		}
	}

	&.is-primary {
		background: $blue;
		color: #fff;
		transition: background 140ms ease;

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

	&.is-danger {
		background: $danger;
		color: #fff;
		transition: background 140ms ease;

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

// Save button --------------------------------------------------------------------------------------
.ssw-save {
	height: 36px;
	padding: 0 18px;
	border: 1px solid $off;
	background: $off;
	color: #fff;
	border-radius: $radius-control;
	font-size: 14px;
	font-weight: 600;
	cursor: default;
	transition: background 160ms ease, border-color 160ms ease;

	@include focus-visible;

	&.is-dirty,
	&.is-saving {
		background: $blue;
		border-color: $blue;
	}

	&.is-dirty {
		cursor: pointer;
	}

	&.is-saved {
		background: $success-ink;
		border-color: $success-ink;
	}
}

// Vertical sub-tabs --------------------------------------------------------------------------------
.ssw-vtabs {
	display: flex;
	flex-direction: column;
	gap: 2px;
	position: sticky;
	top: 120px;
	background: #fff;
	border: 1px solid $line-card;
	border-radius: $radius-card;
	padding: 6px;
}

.ssw-vtabs__tab {
	border: 0;
	font-size: 14px;
	font-weight: 400;
	height: 40px;
	padding: 0 12px;
	display: flex;
	align-items: center;
	gap: 10px;
	text-align: left;
	cursor: pointer;
	border-radius: $radius-menu;
	background: transparent;
	color: $text;
	box-shadow: none;
	transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;

	@include focus-visible;

	svg {
		opacity: 0.7;
	}

	&:hover {
		color: $ink;
	}

	&.is-on {
		background: $tint;
		color: $blue;

		svg {
			opacity: 1;
		}
	}
}

// Phone widths: the sub-tabs become a row above the panel (.ssw-adv stacks).
@media screen and (max-width: 782px) {

	.ssw-vtabs {
		position: static;
		flex-direction: row;
		flex-wrap: wrap;
	}
}

// Settings-tab rows ("Advanced Controls"): label column up to 420px, control right after it.
.ssw-settings-row {
	display: flex;
	gap: 16px;
	align-items: flex-start;
	padding: 13px 0;
}

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

	small {
		display: block;
		font-size: 12.5px;
		font-weight: 400;
		color: $muted-2;
		margin-top: 2px;
		line-height: 1.5;
		text-wrap: pretty;
	}
}

// Collapsible block (grid-rows animation) ----------------------------------------------------------
.ssw-collapse {
	display: grid;
	grid-template-rows: 0fr;
	opacity: 0;
	transition: grid-template-rows 280ms $ease-std, opacity 200ms ease;

	> div {
		min-height: 0;
		overflow: hidden;
	}

	&.is-open {
		grid-template-rows: 1fr;
		opacity: 1;
	}

	&.is-panel {
		transition: grid-template-rows 280ms $ease-std, opacity 220ms ease;
	}

	&.is-rest {
		margin-top: -6px;
		transition: grid-template-rows 320ms $ease-std, opacity 260ms ease, margin-top 320ms $ease-std;

		&.is-open {
			margin-top: 0;
		}

		// Open and settled: the rows' tooltips may leave the box.
		&.is-settled > div {
			overflow: visible;
		}
	}
}

// Alert dialog ---------------------------------------------------------------------------------------
.ssw-alert-scrim {
	position: fixed;
	inset: 0;
	z-index: 300;
	background: rgba(16, 17, 20, 0.4);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	animation: ssw-fade-in 200ms ease;
}

.ssw-alert-scrim__hit {
	position: absolute;
	inset: 0;
}

.ssw-alert {
	position: relative;
	width: 100%;
	max-width: 440px;
	background: #fff;
	border-radius: $radius-card;
	box-shadow: $shadow-alert;
	padding: 24px;
	display: flex;
	flex-direction: column;
	gap: 16px;

	.ssw-alert-scrim > & {
		animation: ssw-alert-in 260ms $ease;
	}
}

.ssw-alert__head {
	display: flex;
	gap: 14px;
	align-items: flex-start;
}

.ssw-alert__icon {
	flex: 0 0 36px;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: $danger-tint;
	color: $danger;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ssw-alert__text {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.ssw-alert__title {
	margin: 0;
	font-size: 16px;
	font-weight: 600;
	color: $ink;
	line-height: 1.5;
}

.ssw-alert__body {
	margin: 0;
	font-size: 14px;
	line-height: 1.55;
	color: $text-2;
	text-wrap: pretty;
}

.ssw-alert__actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
}

@keyframes ssw-fade-in {

	from {
		opacity: 0;
	}
}

@keyframes ssw-alert-in {

	from {
		transform: translateY(8px) scale(0.97);
	}
}

// Get Started checklist ------------------------------------------------------------------------------
.ssw-checklist {
	background: #fff;
	border: 1px solid $line-card;
	border-radius: $radius-card;
	padding: 20px 20px 16px;
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.ssw-checklist__head {
	display: flex;
	align-items: flex-start;
	gap: 16px;
}

.ssw-checklist__heading {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.ssw-checklist__title {
	font-size: 16px;
	font-weight: 600;
	color: $ink;
}

.ssw-checklist__subtitle {
	font-size: 13px;
	color: $muted;
	text-wrap: pretty;
}

.ssw-checklist__count {
	font-size: 13px;
	color: $muted;
	white-space: nowrap;
	padding-top: 2px;
}

.ssw-checklist__dismiss {
	flex: 0 0 28px;
	width: 28px;
	height: 28px;
	margin: -4px -6px 0 0;
	border: 0;
	border-radius: $radius-control;
	background: transparent;
	color: $faint;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 140ms ease, color 140ms ease;

	@include focus-visible;

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

.ssw-checklist__bar {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 4px;
}

.ssw-checklist__segment {
	position: relative;
	height: 6px;
	border-radius: 3px;
	background: $line-list;
	overflow: hidden;
}

.ssw-checklist__fill {
	position: absolute;
	inset: 0;
	border-radius: 3px;
	background: linear-gradient(90deg, #00a32a, #00ba37);
	transform-origin: left center;
	transform: scaleX(0);
	transition: transform 700ms cubic-bezier(0.65, 0, 0.35, 1);

	&.is-on {
		transform: scaleX(1);
	}
}

.ssw-checklist__steps {
	display: flex;
	flex-direction: column;
}

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

.ssw-checklist__circle {
	flex: 0 0 24px;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: #fff;
	box-shadow: inset 0 0 0 1.5px $line-ring-strong;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: 600;
	color: $text-2;

	.is-done > & {
		background: $success;
		box-shadow: none;
	}
}

.ssw-checklist__step-text {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
	font-size: 14px;
	font-weight: 500;
	color: $ink;

	// The design's #8c8f94 is 3.4:1 on white; #74757a (4.6:1) meets WCAG AA (as the wizard's meta note).
	.is-done > & {
		color: $muted-2;
	}
}

.ssw-checklist__action {
	flex: 0 0 76px;
	width: 76px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: $radius-control;
	background: #fff;
	box-shadow: inset 0 0 0 1px $blue;
	color: $blue;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	transition: background 140ms ease;

	@include focus-visible;

	&:hover {
		background: $tint;
	}
}

.ssw-checklist__done {
	flex: 0 0 76px;
	width: 76px;
	text-align: center;
	font-size: 13px;
	color: $success-2;
	font-weight: 500;
}

.ssw-checklist__resume {
	display: flex;
	align-items: center;
	gap: 12px;
	padding-top: 2px;
}

.ssw-checklist__resume-icon {
	flex: 0 0 32px;
	width: 32px;
	height: 32px;
	border-radius: $radius-menu;
	background: $tint;
	color: $blue;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ssw-checklist__resume-text {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 1px;

	> span:first-child {
		font-size: 13px;
		font-weight: 500;
		color: $ink;
	}

	> span:last-child {
		font-size: 12.5px;
		color: $muted;
	}
}

.ssw-checklist__resume-button {
	flex: 0 0 auto;
	border: 0;
	background: transparent;
	padding: 0;
	font-size: 13px;
	font-weight: 500;
	color: $blue;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 4px;

	@include focus-visible;

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

// Attribute Priority ---------------------------------------------------------------------------------
.ssw-prio {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.ssw-prio__rest {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 1px;
}

.ssw-prio__row {
	display: flex;
	align-items: center;
	gap: 10px;
	height: 44px;
	padding: 0 12px 0 6px;
	border-radius: $radius-menu;
	background: #fff;
	box-shadow: inset 0 0 0 1px $line-row;
	transition: box-shadow 140ms ease, opacity 140ms ease;

	&.is-dragging {
		box-shadow: inset 0 0 0 1px $blue;
		opacity: 0.55;
	}
}

.ssw-prio__grip {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 28px;
	color: $faint-3;
	cursor: grab;

	@include focus-visible;
}

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

	@include focus-visible;

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

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

		svg {
			opacity: 1;
		}
	}
}

.ssw-prio__box.is-disabled {
	cursor: not-allowed;
	background: $surface-2;
	box-shadow: inset 0 0 0 1px #dcdcde;
}

// The name keeps its width; a long meta text shortens with an ellipsis (design of 2026-10-26).
.ssw-prio__name {
	flex: 1 0 auto;
	font-size: 14px;
	font-weight: 400;
	color: $text;
	white-space: nowrap;
	cursor: pointer;

	&.is-disabled {
		color: $faint;
		cursor: not-allowed;
	}
}

.ssw-prio__meta {
	flex: 0 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	font-size: 12px;
	color: $muted-2;
	white-space: nowrap;

	&.is-warn {
		color: $warning;
	}
}

// "Type not set": the meta text explains itself in the info tooltip (controls' .ssw-info__body).
.ssw-prio__tip {
	position: relative;
	display: inline-flex;
	flex: 0 1 auto;
	min-width: 0;
	cursor: help;
	outline: none;

	&:hover .ssw-info__body,
	&:focus .ssw-info__body {
		opacity: 1;
		transform: translate(-50%, 0);
	}

	&:focus-visible .ssw-prio__meta {
		text-decoration: underline;
	}
}

.ssw-prio__more {
	align-self: flex-start;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	height: 32px;
	padding: 0 10px;
	margin-left: -10px;
	border: 0;
	border-radius: $radius-control;
	background: transparent;
	color: $blue;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: background 140ms ease;

	@include focus-visible;

	&:hover {
		background: $tint;
	}

	svg {
		transition: transform 180ms ease;

		&.is-up {
			transform: rotate(180deg);
		}
	}
}
