/**
 * Sticky TOC for Elementor — frontend styles.
 *
 * Notes:
 * - All rules are scoped to .stoc and its named children — no universal `.stoc *` selector.
 * - Baseline rules use :where() to keep specificity at 0, so theme/user styles trivially win.
 *   Elementor's per-instance selectors (which prefix with .elementor-element-xxx) still beat
 *   our baseline because they have higher specificity.
 * - Box-sizing is set ONLY on stoc-prefixed elements so it can't leak to nested user HTML.
 */

/* Reset only on stoc elements themselves */
:where(
	.stoc,
	.stoc__trigger,
	.stoc__trigger-label,
	.stoc__trigger-icon,
	.stoc__panel,
	.stoc__scroll,
	.stoc__list,
	.stoc__list-item,
	.stoc__item,
	.stoc__item-label,
	.stoc__arrow,
	.stoc__arrow-left,
	.stoc__cta,
	.stoc__cta-icon,
	.stoc__cta-label
) {
	box-sizing: border-box;
}

:where(.stoc) {
	--stoc-sticky-offset: 0px;
	--stoc-z: 99;
	--stoc-separator-color: currentColor;
	--stoc-separator-char: "/";
	--stoc-fade-color: transparent;
	--stoc-active-weight: 600;

	display: flex;
	align-items: center;
	gap: 16px;
	width: 100%;
	position: relative;
}

:where(.stoc--sticky) {
	position: sticky;
	top: var(--stoc-sticky-offset);
	z-index: var(--stoc-z);
}

/* ---------- Mobile trigger ---------- */

:where(.stoc__trigger) {
	display: none;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	width: 100%;
	padding: 10px 16px;
	background: transparent;
	border: 0;
	border-radius: inherit;
	color: inherit;
	font: inherit;
	cursor: pointer;
	text-align: left;
}

.stoc__trigger:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

:where(.stoc__trigger-icon) {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.2s ease;
}

:where(.stoc__trigger-icon i, .stoc__trigger-icon svg) {
	width: 1em;
	height: 1em;
	display: inline-block;
	line-height: 1;
}

.stoc__trigger[aria-expanded="true"] .stoc__trigger-icon {
	transform: rotate(180deg);
}

/* ---------- Panel (scrolling area on desktop, dropdown body on mobile) ---------- */

:where(.stoc__panel) {
	position: relative;
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	align-items: center;
}

:where(.stoc__scroll) {
	flex: 1 1 auto;
	min-width: 0;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-behavior: smooth;
	overflow-anchor: none; /* prevent browser anchor-scroll on layout shift */
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	mask-image: linear-gradient(to right, transparent 0, #000 36px, #000 calc(100% - 36px), transparent 100%);
	-webkit-mask-image: linear-gradient(to right, transparent 0, #000 36px, #000 calc(100% - 36px), transparent 100%);
}

.stoc__scroll::-webkit-scrollbar {
	display: none;
}

.stoc__scroll.is-start {
	mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 36px), transparent 100%);
	-webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 36px), transparent 100%);
}

.stoc__scroll.is-end {
	mask-image: linear-gradient(to right, transparent 0, #000 36px, #000 100%);
	-webkit-mask-image: linear-gradient(to right, transparent 0, #000 36px, #000 100%);
}

.stoc__scroll.is-start.is-end {
	mask-image: none;
	-webkit-mask-image: none;
}

:where(.stoc__list) {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	gap: 24px;
	margin: 0;
	padding: 0;
	list-style: none;
	white-space: nowrap;
}

:where(.stoc__list-item) {
	display: inline-flex;
	align-items: center;
	margin: 0;
	padding: 0;
}

.stoc--with-separator .stoc__list-item:not(:last-child)::after {
	content: var(--stoc-separator-char);
	color: var(--stoc-separator-color);
	margin-left: 24px;
	opacity: 0.7;
	pointer-events: none;
	user-select: none;
}

:where(.stoc__item) {
	display: inline-flex;
	align-items: center;
	padding: 4px 0;
	color: inherit;
	text-decoration: none;
	transition: color 0.2s ease, opacity 0.2s ease;
	border-radius: 2px;
}

.stoc__item:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 4px;
}

/* Layout-shift prevention: reserve the bold-active width up front via a hidden ghost.
   The label has data-label="<text>" and an ::after at the active weight (height 0). */
:where(.stoc__item-label) {
	position: relative;
	display: inline-block;
}

.stoc__item-label::after {
	content: attr(data-label);
	display: block;
	height: 0;
	overflow: hidden;
	visibility: hidden;
	font-weight: var(--stoc-active-weight);
	letter-spacing: inherit;
	pointer-events: none;
	user-select: none;
}

/* ---------- Side scroll arrows ---------- */

:where(.stoc__arrow, .stoc__arrow-left) {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 1.8em;
	height: 1.8em;
	padding: 0;
	background: transparent;
	border: 0;
	color: inherit;
	cursor: pointer;
	font: inherit;
	z-index: 1;
	transition: opacity 0.2s ease, transform 0.15s ease;
}

:where(.stoc__arrow) {
	margin-left: -36px;
}

:where(.stoc__arrow-left) {
	margin-right: -36px;
	order: -1; /* sit before scroll */
}

.stoc__arrow:hover {
	transform: translateX(2px);
}

.stoc__arrow-left:hover {
	transform: translateX(-2px);
}

.stoc__arrow:focus-visible,
.stoc__arrow-left:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
	border-radius: 2px;
}

:where(.stoc__arrow i, .stoc__arrow svg, .stoc__arrow-left i, .stoc__arrow-left svg) {
	width: 1em;
	height: 1em;
	display: inline-block;
	line-height: 1;
}

.stoc__arrow.is-hidden,
.stoc__arrow-left.is-hidden {
	opacity: 0;
	pointer-events: none;
}

/* ---------- CTA ---------- */

:where(.stoc__cta) {
	display: inline-flex;
	align-items: center;
	flex: 0 0 auto;
	color: inherit;
	text-decoration: none;
	transition: color 0.2s ease, background-color 0.2s ease;
	border-radius: 2px;
}

.stoc__panel .stoc__cta {
	margin-left: 16px;
}

.stoc__cta:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

:where(.stoc__cta-icon) {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
}

:where(.stoc__cta-icon i, .stoc__cta-icon svg) {
	width: 1em;
	height: 1em;
	display: inline-block;
}

/* ---------- Empty state ---------- */

.stoc--empty {
	padding: 16px;
	border: 1px dashed #ccc;
	color: #777;
	font-style: italic;
	text-align: center;
}

.stoc__list-item--hint {
	color: inherit;
	opacity: 0.7;
	font-style: italic;
	pointer-events: none;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
	.stoc__trigger-icon,
	.stoc__item,
	.stoc__cta,
	.stoc__arrow,
	.stoc__arrow-left {
		transition: none;
	}
	.stoc__scroll {
		scroll-behavior: auto;
	}
}

/* ==========================================================================
 * DROPDOWN STATE — applied via JS based on responsive mode + viewport.
 * Class .stoc--dropdown toggles all the mobile/dropdown styling.
 * Also kept under the default 768px media query as a no-JS fallback.
 * ========================================================================== */


.stoc.stoc--dropdown {
	flex-wrap: wrap;
	row-gap: 0;
}

.stoc.stoc--dropdown .stoc__trigger {
	display: inline-flex;
	flex: 1 1 auto;
}

.stoc.stoc--dropdown .stoc__panel {
	display: none;
	flex-basis: 100%;
	order: 99;
	padding-top: 12px;
}

.stoc.stoc--dropdown.is-open .stoc__panel,
.stoc.stoc--dropdown:has(.stoc__trigger[aria-expanded="true"]) .stoc__panel {
	display: block;
}

.stoc.stoc--dropdown .stoc__scroll {
	overflow: visible;
	mask-image: none;
	-webkit-mask-image: none;
}

.stoc.stoc--dropdown .stoc__list {
	flex-direction: column;
	align-items: stretch;
	gap: 0;
	white-space: normal;
}

.stoc.stoc--dropdown .stoc__list-item {
	display: block;
}

.stoc.stoc--dropdown.stoc--with-separator .stoc__list-item:not(:last-child)::after {
	display: none;
}

.stoc.stoc--dropdown .stoc__item {
	display: block;
	padding: 12px 16px;
	border-radius: 4px;
}

.stoc.stoc--dropdown .stoc__arrow,
.stoc.stoc--dropdown .stoc__arrow-left {
	display: none;
}

.stoc.stoc--dropdown .stoc__panel .stoc__cta {
	display: flex;
	width: 100%;
	justify-content: center;
	margin-left: 0;
	margin-top: 8px;
}

/* No-JS fallback: still go to dropdown on phones when JS hasn't run yet
   AND mode isn't explicitly something else. */
@media (max-width: 767px) {
	.stoc:not(.stoc--js-ready):not(.stoc--rmode-never):not(.stoc--rmode-always) {
		flex-wrap: wrap;
		row-gap: 0;
	}
	.stoc:not(.stoc--js-ready):not(.stoc--rmode-never):not(.stoc--rmode-always) .stoc__trigger {
		display: inline-flex;
		flex: 1 1 auto;
	}
	.stoc:not(.stoc--js-ready):not(.stoc--rmode-never):not(.stoc--rmode-always) .stoc__panel {
		display: none;
		flex-basis: 100%;
		order: 99;
		padding-top: 12px;
	}
}
