/* Webbler Table of Contents – colors and sizes come from CSS variables set
 * by the widget's style controls; every var() has a fallback. */

.wtoc {
	--wtoc-bg-d: #f0f8f6;
	--wtoc-text-d: #1e3530;
	--wtoc-title-d: #1e3530;
	--wtoc-num-d: #2f8f86;
	--wtoc-hover-d: #2f8f86;
	--wtoc-line-d: rgba(30, 53, 48, 0.45);
	--wtoc-active-bg-d: transparent;
	--wtoc-border-d: rgba(30, 53, 48, 0.12);
	box-sizing: border-box;
}

/* Floating: frosted dark glass */
.wtoc--float {
	--wtoc-bg-d: rgba(30, 53, 48, 0.78);
	--wtoc-text-d: #ffffff;
	--wtoc-title-d: #ffffff;
	--wtoc-num-d: #6bcbc2;
	--wtoc-hover-d: #6bcbc2;
	--wtoc-line-d: rgba(255, 255, 255, 0.6);
	--wtoc-border-d: rgba(255, 255, 255, 0.14);
}

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

/* No headings: the whole widget (and its spacing) goes away */
.elementor-widget.wtoc-hidden {
	display: none;
}

/* Nothing shows until the headings are found (or when there are too few) */
.wtoc.is-pending,
.wtoc.is-empty {
	display: none;
}

.wtoc__box {
	width: 100%;
	border: var(--wtoc-border-w, 1px) solid var(--wtoc-border, var(--wtoc-border-d));
	border-radius: var(--wtoc-radius, 24px);
	background: var(--wtoc-bg, var(--wtoc-bg-d));
	color: var(--wtoc-text, var(--wtoc-text-d));
	font-size: 17px;
	line-height: 1.4;
	-webkit-backdrop-filter: blur(var(--wtoc-blur, 16px));
	backdrop-filter: blur(var(--wtoc-blur, 16px));
}

/* ---------- Head ---------- */
.wtoc .wtoc__head {
	margin: 0;
	padding: 0;
	color: var(--wtoc-title, var(--wtoc-title-d));
	font-size: 18px;
	font-weight: 500;
	line-height: 1.3;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.wtoc:not(.wtoc--fold) .wtoc__head {
	padding: var(--wtoc-pad, 28px) var(--wtoc-pad, 28px) 0;
}

.wtoc .wtoc__toggle,
.wtoc .wtoc__toggle:hover,
.wtoc .wtoc__toggle:focus {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	width: 100%;
	margin: 0;
	padding: calc(var(--wtoc-pad, 28px) * 0.8) var(--wtoc-pad, 28px);
	border: 0;
	border-radius: var(--wtoc-radius, 24px);
	background: none;
	box-shadow: none;
	color: inherit;
	font: inherit;
	letter-spacing: inherit;
	text-align: left;
	text-transform: inherit;
	cursor: pointer;
}

.wtoc .wtoc__toggle:focus-visible {
	outline: 2px solid var(--wtoc-hover, var(--wtoc-hover-d));
	outline-offset: -4px;
}

.wtoc__title {
	min-width: 0;
}

.wtoc__chev {
	flex-shrink: 0;
	width: 18px;
	height: 18px;
	transition: transform 250ms ease;
}

.wtoc.is-closed .wtoc__chev {
	transform: rotate(180deg);
}

/* ---------- Open / close (glides to its real height) ---------- */
.wtoc__panel {
	display: grid;
	grid-template-rows: 1fr;
	transition: grid-template-rows 300ms ease, visibility 0s linear 0s;
}

.wtoc__clip {
	min-height: 0;
	overflow: hidden;
}

.wtoc.is-closed .wtoc__panel {
	grid-template-rows: 0fr;
	visibility: hidden;
	transition: grid-template-rows 300ms ease, visibility 0s linear 300ms;
}

/* ---------- List ---------- */
.wtoc .wtoc__list {
	display: flex;
	flex-direction: column;
	gap: var(--wtoc-gap, 14px);
	max-height: var(--wtoc-max-h, 50vh);
	margin: 0;
	padding: 6px var(--wtoc-pad, 28px) var(--wtoc-pad, 28px);
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	list-style: none;
	scrollbar-width: thin;
}

.wtoc:not(.wtoc--fold) .wtoc__list {
	padding-top: calc(var(--wtoc-pad, 28px) * 0.6);
}

.wtoc .wtoc__list > li {
	margin: 0;
	padding: 0;
	list-style: none;
}

.wtoc .wtoc__list > li::before,
.wtoc .wtoc__list > li::marker {
	content: none;
}

/* Each heading: the outline of the section being read sits around it */
.wtoc .wtoc__link,
.wtoc .wtoc__link:link,
.wtoc .wtoc__link:visited {
	display: flex;
	align-items: baseline;
	gap: 0.5em;
	margin: 0 -14px;
	padding: 8px 14px;
	border: 1px solid transparent;
	border-radius: 16px;
	background: transparent;
	color: var(--wtoc-text, var(--wtoc-text-d));
	font: inherit;
	text-decoration: none;
	transition: color 200ms ease, border-color 200ms ease, background-color 200ms ease;
}

/* Hover only with a mouse (no "stuck" color after tapping on phones) */
@media (hover: hover) and (pointer: fine) {
	.wtoc .wtoc__link:hover {
		color: var(--wtoc-hover, var(--wtoc-hover-d));
		text-decoration: none;
	}
}

.wtoc .wtoc__link:focus-visible {
	color: var(--wtoc-hover, var(--wtoc-hover-d));
	text-decoration: none;
}

.wtoc .wtoc__link:focus-visible {
	outline: 2px solid var(--wtoc-hover, var(--wtoc-hover-d));
	outline-offset: 0;
}

.wtoc .wtoc__item.is-active .wtoc__link {
	border-color: var(--wtoc-active-line, var(--wtoc-line-d));
	background: var(--wtoc-active-bg, var(--wtoc-active-bg-d));
	color: var(--wtoc-active, var(--wtoc-text, var(--wtoc-text-d)));
}

.wtoc__num {
	display: none;
	flex-shrink: 0;
	min-width: 1.4em;
	color: var(--wtoc-num, var(--wtoc-num-d));
	font-variant-numeric: tabular-nums;
}

.wtoc--numbered .wtoc__num {
	display: inline;
}

.wtoc__text {
	min-width: 0;
	overflow-wrap: anywhere;
}

/* ---------- Floating box ---------- */
.wtoc--float {
	position: fixed;
	z-index: 990;
	bottom: var(--wtoc-edge, 24px);
	width: min(var(--wtoc-float-w, 384px), calc(100vw - 2 * var(--wtoc-edge, 24px)));
	transition: opacity 300ms ease, transform 300ms ease, visibility 0s linear 0s;
}

.wtoc--float.wtoc--side-right {
	right: var(--wtoc-edge, 24px);
}

.wtoc--float.wtoc--side-left {
	left: var(--wtoc-edge, 24px);
}

.wtoc--float.wtoc--side-center {
	left: 50%;
	transform: translateX(-50%);
}

.wtoc--float .wtoc__box {
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

/* Hidden before the first heading / while the footer is in view */
.wtoc--float.is-away {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateY(16px);
	transition: opacity 300ms ease, transform 300ms ease, visibility 0s linear 300ms;
}

.wtoc--float.wtoc--side-center.is-away {
	transform: translate(-50%, 16px);
}

/* In the Elementor editor the floating box stays where you can click it */
.elementor-editor-active .wtoc--float {
	position: relative;
	right: auto;
	bottom: auto;
	left: auto;
	transform: none;
	margin-left: auto;
}

.elementor-editor-active .wtoc--float.wtoc--side-left {
	margin-left: 0;
}

.elementor-editor-active .wtoc--float.wtoc--side-center {
	margin-right: auto;
}

/* ---------- Sticky box (sidebar) ---------- */
@media (min-width: 768px) {
	.elementor-widget-webbler-toc:has(> .elementor-widget-container > .wtoc--sticky),
	.elementor-widget-webbler-toc:has(> .wtoc--sticky) {
		position: sticky;
		top: var(--wtoc-top, 24px);
		align-self: flex-start;
	}
}

/* ---------- Mobile ---------- */
@media (max-width: 767px) {
	.wtoc--float {
		width: calc(100vw - 2 * min(var(--wtoc-edge, 24px), 16px));
		bottom: min(var(--wtoc-edge, 24px), 16px);
	}

	.wtoc--float.wtoc--side-right,
	.wtoc--float.wtoc--side-left,
	.wtoc--float.wtoc--side-center {
		right: auto;
		left: min(var(--wtoc-edge, 24px), 16px);
		transform: none;
	}

	.wtoc--float.wtoc--side-center.is-away,
	.wtoc--float.is-away {
		transform: translateY(16px);
	}

	.wtoc .wtoc__toggle,
	.wtoc .wtoc__toggle:hover,
	.wtoc .wtoc__toggle:focus {
		padding: 16px 20px;
	}

	.wtoc .wtoc__list {
		padding: 4px 20px 20px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wtoc *,
	.wtoc,
	.wtoc__panel {
		transition: none !important;
	}
}
