@use "../kit-deps" as *;
@use "typography" as *;

.tabs {
	display: grid;
	gap: $space-4;
	width: 100%;
	max-width: 900px;
}

.tabs-list {
	display: flex;
	align-items: stretch;
	gap: 0;
	max-width: 100%;
	overflow-x: auto;
	border: $border-width-base solid $border-color-muted;
	border-left-width: $border-width-accent;
	background: $surface-panel-muted;
	scrollbar-width: thin;
}

.tab {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: $space-2;
	min-height: $control-height-md;
	padding: $space-3 $space-4;
	border: 0;
	border-right: $border-width-base solid rgba($color-text-light, 0.08);
	border-radius: 0;
	color: $color-text-medium;
	background: transparent;
	font-family: $font-family-base;
	font-size: $font-size-sm;
	font-weight: $font-weight-bold;
	line-height: $line-height-base;
	text-transform: uppercase;
	white-space: nowrap;
	cursor: pointer;
	transition-duration: $motion-base;
	transition-timing-function: $motion-ease;
	transition-property: color, background, opacity;

	.ph,
	.ph-bold {
		font-size: $icon-size-sm;
	}

	&:focus-visible {
		@include focus_ring;
		z-index: 1;
	}

	@include hover_touch {
		color: $color-black;
		background: $color-secondary;
	}

	&:disabled,
	&[aria-disabled="true"] {
		color: $color-text-dark;
		cursor: not-allowed;
		opacity: 0.62;

		@include hover_touch {
			color: $color-text-dark;
			background: transparent;
		}
	}
}

.tab-active,
.tab[aria-selected="true"] {
	color: $color-black;
	background: $color-primary;
}

.tabs-panels {
	border: $border-width-base solid $border-color-muted;
	border-left-width: $border-width-accent;
	background: $surface-panel-muted;
}

.tab-panel {
	display: none;
	padding: $space-4;
	color: $color-text-medium;
	font-size: $font-size-sm;
	line-height: $line-height-relaxed;

	p {
		margin-top: 0;
	}

	p:last-child {
		margin-bottom: 0;
	}
}

.tab-panel-active {
	display: block;
}

.tabs-compact {
	max-width: 620px;

	.tabs-list {
		border-left-width: $border-width-base;
	}

	.tab {
		min-height: $control-height-sm;
		padding: $space-2 $space-3;
	}

	.tabs-panels {
		border-left-width: $border-width-base;
	}

	.tab-panel {
		padding: $space-3;
	}
}

.tabs-vertical {
	grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
	align-items: start;

	.tabs-list {
		flex-direction: column;
		overflow-x: visible;
	}

	.tab {
		justify-content: flex-start;
		border-right: 0;
		border-bottom: $border-width-base solid rgba($color-text-light, 0.08);
		text-align: left;
	}
}

@include media_down("md") {
	.tabs-vertical {
		grid-template-columns: 1fr;

		.tabs-list {
			flex-direction: row;
			overflow-x: auto;
		}

		.tab {
			justify-content: center;
			border-right: $border-width-base solid rgba($color-text-light, 0.08);
			border-bottom: 0;
			text-align: center;
		}
	}
}
