/*
 * Tabs (Figma component "Tools" on Looms & Tools): 464 px of tab names, a 112 px gap, then the
 * 560 × 400 photo with its text. Phones: one panel at a time (328 × 200 photo, heading, text) with
 * a progress bar and previous/next buttons. Before section.js runs (or without it) the panels
 * simply stack.
 */

.tabs {
	display: grid;
	gap: 32px;
}

.tabs__panels {
	display: grid;
	gap: 60px;
}

.tabs__panel {
	display: grid;
	align-content: start;
	gap: 32px;
}

.tabs__panel:focus-visible {
	outline-offset: 8px;
}

.tabs__media img {
	width: 100%;
	aspect-ratio: 328 / 200;
	object-fit: cover;
}

.tabs__body {
	display: grid;
	gap: 16px;
}

.tabs__text {
	color: var(--c-text-2);
}

.tabs__text > * + * {
	margin-top: var(--lh-body);
}

/* Tab names: large serif, the selected one darker and underlined. */
.tabs__list {
	display: grid;
	justify-items: start;
	align-content: start;
	gap: 32px;
}

.tabs__tab {
	padding: 0;
	border: 0;
	background: none;
	color: var(--c-text-2);
	font-family: var(--f-display);
	font-size: var(--t-title);
	line-height: var(--lh-title);
	font-weight: 500;
	text-align: left;
	text-decoration: underline;
	text-decoration-color: transparent;
	text-decoration-thickness: 1px;
	text-underline-offset: 6px;
	transition: color 0.2s, text-decoration-color 0.2s;
}

.tabs__tab:hover,
.tabs__tab[aria-selected="true"] {
	color: var(--c-text);
}

.tabs__tab[aria-selected="true"] {
	text-decoration-color: currentColor;
}

/* Phone controls: progress bar and previous/next buttons. */
.tabs__controls {
	display: grid;
	gap: 16px;
}

.tabs__progress {
	position: relative;
	height: 2px;
	background: var(--c-line-2);
}

.tabs__progress span {
	position: absolute;
	inset-block: 0;
	left: calc(var(--pos, 0) * (1 - var(--size, 1)) * 100%);
	width: calc(var(--size, 1) * 100%);
	background: var(--c-muted);
	transition: left 0.3s;
}

.tabs__nav {
	display: flex;
	gap: 8px;
}

.tabs__button {
	display: grid;
	place-items: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 1px solid var(--c-line);
	border-radius: 50%;
	background: none;
	color: var(--c-muted);
	transition: color 0.2s, border-color 0.2s;
}

.tabs__button .icon {
	width: 21px;
	height: 21px;
}

.tabs__button:not(:disabled):hover {
	border-color: currentColor;
	color: var(--c-text);
}

.tabs__button:disabled {
	opacity: 0.5;
	cursor: default;
}

@media (max-width: 767px) {
	.tabs__list {
		display: none;
	}
}

@media (min-width: 768px) {
	/* Without the script: two panels per row. */
	.tabs:not(.is-tabs) .tabs__panels {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 60px 16px;
	}

	.tabs__media img {
		aspect-ratio: 560 / 400;
	}

	.tabs.is-tabs {
		grid-template-columns: minmax(0, 464fr) minmax(0, 560fr);
		column-gap: clamp(32px, 8.75vw, 112px);
		align-items: start;
	}

	.tabs__heading {
		grid-column: 1 / -1;
	}

	.is-tabs .tabs__panel {
		gap: 24px;
	}

	.is-tabs .tabs__body {
		gap: 24px;
	}

	/* The selected tab name already heads the panel. */
	.is-tabs .tabs__title {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}

	.tabs__controls {
		display: none;
	}
}
