@use "@teydeastudio/components/src/teydea-admin" as *;

/**
 * The policy
 */
.password-requirements-policy {
	display: flex;
	flex-direction: column;
	gap: $tsc-space-4;

	&__header {
		align-items: center;
		display: flex;
		gap: $tsc-space-2;

		// The label sets itself at the top of a row, which would leave it 2 px above the title's middle.
		.tsc-status-label {
			align-self: center;
		}
	}

	&__breadcrumb {
		display: flex;
	}

	&__header-separator {
		color: $tsc-ink-muted;
		flex: none;
	}

	&__title {
		color: $tsc-ink;
		font-size: 16px;
		font-weight: 600;
		line-height: 24px;
		margin: 0;
	}

	&__meta {
		color: $tsc-ink-muted;
	}

	// A borderless icon button: its dots, 9 px inside it, line up with the edge of the card below.
	&__actions {
		margin-left: auto;
		margin-right: -9px;
	}

	&__body {
		align-items: flex-start;
		display: flex;
		gap: $tsc-space-6;
	}

	/**
	 * The section menu stays in view at the top of the frame's content while the cards scroll
	 */
	&__section-menu {
		box-sizing: border-box;
		display: flex;
		flex: none;
		flex-direction: column;
		gap: 2px;
		position: sticky;
		top: 0;
		width: 200px;
	}

	&__section-link {
		background: transparent;
		border: 0;
		border-radius: $tsc-radius-md;
		color: $tsc-ink;
		cursor: pointer;
		font: inherit;
		font-size: 13px;
		line-height: 20px;
		padding: 7px $tsc-space-3;
		text-align: left;

		&:hover {
			background: $tsc-surface-hover;
		}

		&:focus-visible {
			box-shadow: 0 0 0 2px $tsc-accent;
			outline: 2px solid transparent;
		}

		&[aria-current="true"] {
			background: $tsc-hairline;
			font-weight: 600;
		}
	}

	&__cards {
		flex: 1;
		min-width: 0;
	}

	&__cards,
	&__section {
		display: flex;
		flex-direction: column;
		gap: $tsc-space-3;
	}

	&__section {
		scroll-margin-top: $tsc-space-6;

		&:focus {
			outline: none;
		}
	}

	@media (max-width: $tsc-narrow-breakpoint) {
		// "All policies" takes a line of its own, so the policy's name has the width of the screen.
		&__header {
			flex-wrap: wrap;
			row-gap: 0;
		}

		&__breadcrumb {
			flex-basis: 100%;
		}

		&__header-separator {
			display: none;
		}

		&__meta {
			white-space: nowrap;
		}

		&__body {
			align-items: stretch;
			flex-direction: column;
		}

		&__section {
			scroll-margin-top: calc(var(--wp-admin--admin-bar--height, 46px) + #{$tsc-space-4});
		}

		&__section-menu {
			flex-direction: row;
			flex-wrap: wrap;
			position: static;
			width: auto;
		}
	}

	&__text {
		color: $tsc-ink-muted;
		margin: 0;
		max-width: 640px;
	}
}

/**
 * The "Try the policy" card
 */
.password-requirements-try-password {
	display: flex;
	flex-direction: column;
	gap: $tsc-space-3;

	&__note {
		color: $tsc-ink-muted;
		margin: 0;
	}

	&__note {
		align-items: flex-start;
		display: flex;
		gap: $tsc-space-1;

		svg {
			fill: currentColor;
			flex: none;
		}
	}

	&__requirements {
		display: flex;
		flex-direction: column;
		gap: $tsc-space-1;
		margin: 0;
		transition: opacity 0.15s ease-out;

		&.is-checking {
			opacity: 0.45;
		}

		@media (prefers-reduced-motion: reduce) {
			transition: none;
		}
	}

	// The line is as tall as the icon, so that on a requirement that wraps the icon sits on its first line.
	&__requirement {
		align-items: flex-start;
		color: $tsc-ink;
		display: flex;
		gap: $tsc-space-1;
		line-height: 20px;
		margin: 0;

		svg {
			fill: $tsc-ink-muted;
			flex: none;
		}

		&--met svg {
			fill: $tsc-success;
		}

		&--not-met svg {
			fill: $tsc-error;
		}
	}

	&__requirement-state {
		color: $tsc-ink-muted;
		margin-left: auto;
		white-space: nowrap;
	}

	&__on-save {
		border-top: 1px solid $tsc-hairline;
		padding-top: $tsc-space-3;

		ul {
			list-style: disc;
			margin: $tsc-space-1 0 0;
			padding-left: $tsc-space-5;
		}
	}

	&__on-save-title {
		color: $tsc-ink;
		font-weight: 600;
		margin: 0;
	}
}
