/**
 * Tabs — Common base CSS (loads for every style).
 *
 * Shared mechanics only: nav layout, tab button reset, panel show/hide + fade,
 * icon positioning and the moving indicator base. The indicator is positioned
 * by JS (left/top/width/height of the active tab) and each style decides how it
 * looks — a bottom underline for Style 1, a sliding pill for Style 5, hidden
 * elsewhere.
 *
 * @package captain-widgets-kit
 * @since   1.3.0
 */

.captwiki-tabs {
	--captwiki-tab-accent: #6366f1;
	display: block;
	box-sizing: border-box;
}

.captwiki-tabs *,
.captwiki-tabs *::before,
.captwiki-tabs *::after {
	box-sizing: border-box;
}

/* ── Nav ───────────────────────────────────────────────── */
.captwiki-tabs__nav {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.captwiki-tabs__tab {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin: 0;
	padding: 12px 20px;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.3;
	color: #4b5563;
	background: transparent;
	border: none;
	cursor: pointer;
	transition: color 0.25s ease, background-color 0.25s ease, border-color 0.25s ease;
	-webkit-appearance: none;
	appearance: none;
}

.captwiki-tabs__tab:focus-visible {
	outline: 2px solid var( --captwiki-tab-accent );
	outline-offset: 2px;
}

/* Justified alignment makes the tabs share the row equally. */
.captwiki-tabs__nav[style*="justify-content: stretch"] .captwiki-tabs__tab,
.captwiki-tabs__nav[style*="justify-content:stretch"] .captwiki-tabs__tab {
	flex: 1 1 0;
}

/* ── Icon position ─────────────────────────────────────── */
.captwiki-tabs--icon-above .captwiki-tabs__tab {
	flex-direction: column;
}

.captwiki-tabs__tab-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	line-height: 1;
}

.captwiki-tabs__tab-icon svg {
	width: 1em;
	height: 1em;
	fill: currentColor;
}

.captwiki-tabs__tab-icon i {
	font-size: inherit;
	font-style: normal;
}

/* ── Indicator (positioned by JS, styled per-style) ────── */
.captwiki-tabs__indicator {
	position: absolute;
	left: 0;
	top: 0;
	width: 0;
	height: 0;
	display: none;
	pointer-events: none;
	border: 0 solid var( --captwiki-tab-accent );
	transition: left 0.32s cubic-bezier( 0.22, 0.61, 0.36, 1 ),
		top 0.32s cubic-bezier( 0.22, 0.61, 0.36, 1 ),
		width 0.32s cubic-bezier( 0.22, 0.61, 0.36, 1 ),
		height 0.32s cubic-bezier( 0.22, 0.61, 0.36, 1 );
}

/* ── Panels ────────────────────────────────────────────── */
.captwiki-tabs__panels {
	position: relative;
}

.captwiki-tabs__panel {
	color: #374151;
	font-size: 15px;
	line-height: 1.7;
}

.captwiki-tabs__panel[hidden] {
	display: none;
}

.captwiki-tabs__panel-inner > :first-child {
	margin-top: 0;
}

.captwiki-tabs__panel-inner > :last-child {
	margin-bottom: 0;
}

/* ── Content fade animation ────────────────────────────── */
.captwiki-tabs--animate .captwiki-tabs__panel.is-active {
	animation: captwiki-tabs-fade 0.35s ease;
}

@keyframes captwiki-tabs-fade {
	from {
		opacity: 0;
		transform: translateY( 6px );
	}
	to {
		opacity: 1;
		transform: none;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.captwiki-tabs__indicator,
	.captwiki-tabs--animate .captwiki-tabs__panel.is-active {
		transition: none;
		animation: none;
	}
}
