@use "../teydea-admin" as *;

/**
 * Sub-menu
 */
.tsc-sub-nav {
	display: flex;
	gap: $tsc-space-6;

	&__menu {
		border-right: 1px solid $tsc-hairline;
		box-sizing: border-box;
		display: flex;
		flex: none;
		flex-direction: column;
		gap: 2px;
		padding-right: $tsc-space-3;
		width: $tsc-subnav-width;
	}

	&__item {
		align-items: flex-start;
		background: transparent;
		border: 0;
		border-radius: $tsc-radius-md;
		color: $tsc-ink;
		cursor: pointer;
		display: flex;
		font: inherit;
		gap: $tsc-space-2;
		padding: 10px $tsc-space-3;
		text-align: left;
		width: 100%;

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

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

		&.is-selected {
			background: $tsc-hairline;
		}

		&.is-selected .tsc-sub-nav__title {
			font-weight: 600;
		}
	}

	&__text {
		display: flex;
		flex: 1;
		flex-direction: column;
		gap: 2px;
		min-width: 0;
	}

	&__title {
		font-size: 13px;
		font-weight: 500;
	}

	&__description {
		color: $tsc-ink-muted;
		font-size: 12px;
	}

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

	// Each section is set apart by a divider, so it is clear where one check ends and the next begins.
	&__section {
		display: flex;
		flex-direction: column;
		gap: $tsc-space-4;
		scroll-margin-top: $tsc-space-6;

		& + & {
			border-top: 1px solid $tsc-hairline;
			margin-top: $tsc-space-8;
			padding-top: $tsc-space-8;
		}

		&:focus {
			outline: none;
		}

		// Everything in a section keeps the form's width, so the sections line up; the dividers run across.
		> * {
			box-sizing: border-box;
			max-width: $tsc-form-width;
		}

		> .components-external-link {
			align-self: flex-start;
		}
	}

	&__page-header {
		display: flex;
		flex-direction: column;
		gap: $tsc-space-1;

		.components-notice {
			margin: 0 0 $tsc-space-3;
		}
	}

	&__page-title-row {
		align-items: center;
		display: flex;
		flex-wrap: wrap;
		gap: $tsc-space-1 10px;

		.tsc-status-label {
			align-self: center;
		}
	}

	&__page-title {
		font-size: 18px;
		font-weight: 600;
		line-height: 24px;
		margin: 0;
	}

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

	&__page-meta {
		color: $tsc-ink-muted;
		font-size: 12px;
		line-height: 18px;
		margin: -2px 0 0;

		a {
			text-decoration: none;

			&:hover,
			&:focus {
				text-decoration: underline;
			}
		}

		// The check that fills it can have nothing to say yet.
		&:empty {
			display: none;
		}
	}

	/**
	 * In the settings frame's content, which scrolls inside the panel above the narrow layout,
	 * the menu runs from the tabs to the bottom of the panel, so its divider is full height.
	 * The menu keeps its items' text on the panel's 24 px line, and the page its own padding.
	 */
	@media (min-width: #{$tsc-narrow-breakpoint + 1}) {
		margin: (-$tsc-space-6) 0 (-$tsc-space-6) (-$tsc-space-6);
		min-height: calc(100cqh + #{2 * $tsc-space-6});

		// The menu stays at the top of the panel, as tall as the panel, while the sections scroll.
		&__menu {
			align-self: flex-start;
			height: calc(100cqh + #{2 * $tsc-space-6});
			overflow-y: auto;
			padding: $tsc-space-6 $tsc-space-3;
			position: sticky;
			top: -$tsc-space-6;
		}

		&__page {
			padding: $tsc-space-6 0 $tsc-space-8;
		}
	}

	@media (max-width: $tsc-narrow-breakpoint) {
		flex-direction: column;

		&__menu {
			border-bottom: 1px solid $tsc-hairline;
			border-right: 0;
			padding: 0 0 $tsc-space-3;
			width: 100%;
		}

		&__item {
			min-height: $tsc-touch-target;
		}

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