/*
 * UTS Sites Table of Contents — front-end styles.
 *
 * Intentionally NO font-family, font-size or link color/hover-color
 * rules here. Every text element uses `inherit`, and every <a> tag
 * is left untouched so the theme's own body font and link/hover
 * colors apply automatically. Only layout, spacing, and subtle
 * depth/structure are controlled by the plugin.
 */

.uts-toc-container {
	--uts-toc-border: var(--uts-toc-border-custom, rgba(0, 0, 0, 0.10));
	--uts-toc-bg: var(--uts-toc-bg-custom, #fafafa);
	--uts-toc-marker: var(--uts-toc-marker-custom, rgba(0, 0, 0, 0.28));
	--uts-toc-text: #1f1f1f;
	--uts-toc-link: var(--uts-toc-link-custom, #1f1f1f);

	font-family: inherit;
	font-size: inherit;
	line-height: 1.65;
	box-sizing: border-box;
	margin: 1.75em 0;
	padding: 1.25em 1.5em 1.4em;
	border: 1px solid var(--uts-toc-border);
	border-radius: 10px;
	background: var(--uts-toc-bg);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
	max-width: 100%;
}

.uts-toc-container * {
	box-sizing: border-box;
}

.uts-toc-title {
	font-weight: 700;
	font-size: 1.05em;
	letter-spacing: 0.01em;
	margin: 0 0 0.75em;
	padding-bottom: 0.6em;
	border-bottom: 1px solid var(--uts-toc-border);
	display: flex;
	align-items: center;
	gap: 0.5em;
}

.uts-toc-title::before {
	content: "";
	display: inline-block;
	width: 4px;
	height: 1em;
	border-radius: 2px;
	background: var(--uts-toc-marker);
	flex-shrink: 0;
}

.uts-toc-toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	background: none;
	border: none;
	padding: 0;
	margin: 0 0 0.75em;
	cursor: pointer;
	font: inherit;
	color: inherit;
	text-align: left;
	padding-bottom: 0.6em;
	border-bottom: 1px solid var(--uts-toc-border);
}

/* No hover/focus/active visual change of any kind — many themes style
   ALL <button> elements with a hover gradient/shadow/border. Force the
   toggle to stay exactly as its resting state, always.

   Specificity is intentionally stacked very high (repeated class +
   ancestor chain) because some themes style buttons with selectors
   specific enough to beat a plain ".uts-toc-toggle:hover" even with
   !important — !important only wins ties by specificity, not by
   itself. This is deliberately harder to out-specify than any normal
   theme button rule. */
html body .uts-toc-container .uts-toc-toggle.uts-toc-toggle.uts-toc-toggle,
html body .uts-toc-container .uts-toc-toggle.uts-toc-toggle.uts-toc-toggle:hover,
html body .uts-toc-container .uts-toc-toggle.uts-toc-toggle.uts-toc-toggle:focus,
html body .uts-toc-container .uts-toc-toggle.uts-toc-toggle.uts-toc-toggle:focus-visible,
html body .uts-toc-container .uts-toc-toggle.uts-toc-toggle.uts-toc-toggle:active,
html body .uts-toc-container .uts-toc-toggle.uts-toc-toggle.uts-toc-toggle:hover:active,
html body .uts-toc-container .uts-toc-toggle.uts-toc-toggle.uts-toc-toggle:focus:active {
	background: none !important;
	background-color: transparent !important;
	background-image: none !important;
	box-shadow: none !important;
	border: none !important;
	border-bottom: 1px solid var(--uts-toc-border) !important;
	color: inherit !important;
	text-shadow: none !important;
	outline: none !important;
	transform: none !important;
	transition: none !important;
	-webkit-tap-highlight-color: transparent !important;
}

/* Kill any theme "ripple" / touch-feedback overlay rendered via a
   ::before or ::after pseudo-element on the button. This is a
   completely separate visual layer from the button's own
   background/color — a theme's material-style tap effect commonly
   animates a pseudo-element's own background on top of the button,
   which none of the background/color overrides above can reach
   since they only affect the real element, not its pseudo-elements. */
.uts-toc-toggle::before,
.uts-toc-toggle::after {
	display: none !important;
	content: none !important;
	background: none !important;
	background-image: none !important;
	opacity: 0 !important;
	box-shadow: none !important;
	transform: none !important;
}

.uts-toc-toggle .uts-toc-title {
	margin: 0;
	border-bottom: none;
	padding-bottom: 0;
	flex: 1;
}

.uts-toc-arrow-wrap {
	width: 24px;
	height: 24px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	margin-left: 12px;
	background: var(--uts-toc-arrow-bg, rgba(0, 0, 0, 0.05));
	transition: background 0.2s ease, transform 0.2s ease;
}

.uts-toc-toggle:hover .uts-toc-arrow-wrap {
	background: var(--uts-toc-arrow-bg-hover, rgba(0, 0, 0, 0.09));
}

.uts-toc-collapsed .uts-toc-arrow-wrap {
	transform: rotate(180deg);
}

.uts-toc-arrow {
	width: 8px;
	height: 8px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
	opacity: 0.6;
}

.uts-toc-body {
	overflow: hidden;
	max-height: 2000px;
	transition: max-height 0.28s ease, opacity 0.2s ease;
	opacity: 1;
}

.uts-toc-collapsed .uts-toc-body {
	max-height: 0;
	opacity: 0;
}

.uts-toc-list {
	margin: 0 !important;
	padding-left: 0 !important;
	list-style: none !important;
	list-style-type: none !important;
}

/* Belt-and-suspenders: some themes inject bullets via ::marker or a
   li:before pseudo-element instead of the list-style property, which
   list-style:none alone does not remove. Kill both explicitly so ONLY
   the plugin's own .uts-toc-marker-dot / .uts-toc-marker-num show,
   regardless of theme. */
.uts-toc-container li {
	list-style: none !important;
}

.uts-toc-container li::marker {
	content: none !important;
}

.uts-toc-container li::before {
	content: none !important;
}

.uts-toc-sublist {
	margin: 0.3em 0 0 0.05em;
	padding-left: 1.1em;
	border-left: 2px solid var(--uts-toc-border);
}

.uts-toc-item {
	margin: 0 !important;
	padding: 0.25em 0 !important;
	line-height: 1.4 !important;
}

/* Marker (bullet dot or number) + text are both real elements laid
   out with flex, not a hanging-indent trick. This guarantees wrapped
   second lines align perfectly under the first line's text — in
   both bullet and numbered mode, identically — since the text is
   its own flex item with its own left edge, independent of the
   marker's width or type. */
.uts-toc-item > a {
	display: flex !important;
	align-items: flex-start !important;
	gap: var(--uts-toc-marker-gap, 0.6em) !important;
}

.uts-toc-text {
	flex: 1;
	min-width: 0;
}

.uts-toc-marker {
	flex-shrink: 0;
	margin-top: calc((1.65em - 6px) / 2);
}

.uts-toc-marker-dot {
	display: inline-block;
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background: var(--uts-toc-marker);
	margin-right: 0.2em;
}

.uts-toc-marker-num {
	font-size: inherit;
	font-weight: 600;
	opacity: 0.65;
}

/* Sub-items get a visibly lighter treatment so the hierarchy is
   obvious at a glance, not just via indent. */
.uts-toc-sublist .uts-toc-item {
	opacity: 0.82;
}

.uts-toc-sublist .uts-toc-marker-dot {
	width: 4px;
	height: 4px;
}

.uts-toc-sublist .uts-toc-sublist .uts-toc-item {
	opacity: 0.7;
}

/* Font size per actual heading level — customizable in
   Settings → UTS TOC → Typography. Defaults match the plugin's
   original sizing; --uts-toc-fs-hN is only output inline when it
   differs from the default. */
.uts-toc-item-h2 { font-size: var(--uts-toc-fs-h2, 100%); }
.uts-toc-item-h3 { font-size: var(--uts-toc-fs-h3, 93%); }
.uts-toc-item-h4 { font-size: var(--uts-toc-fs-h4, 90%); }
.uts-toc-item-h5 { font-size: var(--uts-toc-fs-h5, 88%); }
.uts-toc-item-h6 { font-size: var(--uts-toc-fs-h6, 85%); }

.uts-toc-list[class*="uts-toc-level-"] > .uts-toc-item {
	padding-left: 0 !important;
}

.uts-toc-sublist > .uts-toc-item {
	padding-left: 1.15em !important;
}

/* Font stays inherited from the theme (no font-family override here).
   Color defaults to a neutral, readable value (var(--uts-toc-link))
   chosen to stay legible on both light and dark backgrounds; this can
   be overridden in Settings → UTS TOC → Colors. */
.uts-toc-container a {
	font: inherit;
	font-weight: normal !important;
	line-height: inherit !important;
	text-decoration: none !important;
	text-decoration-line: none !important;
	border-bottom: none !important;
	box-shadow: none !important;
	background-image: none !important;
	outline: none !important;
	margin: 0 !important;
	padding: 0 !important;
	color: var(--uts-toc-link, inherit);
}

/* Some themes draw their link underline as a separate bar via a
   ::before/::after pseudo-element (common in animated-underline
   hover effects) rather than via text-decoration — a technique
   text-decoration:none can never touch. Kill that layer too. */
.uts-toc-container a::before,
.uts-toc-container a::after {
	display: none !important;
	content: none !important;
	background: none !important;
	background-image: none !important;
	border: none !important;
	box-shadow: none !important;
}

.uts-toc-container a:hover {
	border-bottom: none !important;
	box-shadow: none !important;
}

.uts-toc-container a:hover .uts-toc-text {
	text-decoration: underline !important;
}

/* Toggle in Settings → UTS TOC → Behaviour & Style: makes ONLY the
   white background transparent. Border, shadow, radius, and every
   other style stay exactly as-is. */
.uts-toc-container.uts-toc-transparent {
	background: transparent !important;
}

.uts-toc-credit {
	margin-top: 0.9em;
	padding-top: 0.6em;
	border-top: 1px solid var(--uts-toc-border);
	font-size: 0.78em;
	opacity: 0.6;
	text-align: right;
}

@media (max-width: 480px) {
	.uts-toc-container {
		padding: 1em 1.1em 1.2em;
		border-radius: 8px;
	}
}

/* ============================================================
   Day / Night mode support (automatic)

   JS (uts-toc.js) checks the ACTUAL rendered background color of
   the page — not a guessed theme class name — and stamps
   data-uts-toc-mode="dark" / "light" on each TOC box. This works
   with any theme's toggle, whatever class/attribute it uses
   internally, and updates live the instant the user flips it.

   prefers-color-scheme below is only a same-paint-frame fallback
   for the brief moment before JS runs; the data-attribute (set
   right after) always takes over and wins.
   ============================================================ */

/* ============================================================
   Day / Night mode support (automatic)

   Base .uts-toc-container above already defaults --uts-toc-text
   to a readable dark color — so even if JS hasn't run yet (or
   never runs, e.g. JS blocked), text is ALWAYS readable. Dark
   mode below only overrides the variable; it never depends on
   JS having tagged the box first.

   JS (uts-toc.js) additionally checks the ACTUAL rendered
   background color and stamps data-uts-toc-mode="dark"/"light"
   for accuracy with any theme's toggle, live.
   ============================================================ */

/* NOTE: the OS-level (prefers-color-scheme) fallback that used to
   live here was removed. It guessed dark/light purely from the
   PHONE's OS setting, not the site's actual background — so on a
   light-themed site viewed with the phone in dark mode, the TOC
   would flash dark for a moment on every load/refresh before JS
   corrected it. The JS below (uts-toc.js) checks the page's real
   rendered background and applies data-uts-toc-mode immediately on
   DOMContentLoaded, so light is now the only default appearance and
   dark is only ever applied once genuinely confirmed. */

.uts-toc-container[data-uts-toc-mode="dark"] {
	--uts-toc-border: var(--uts-toc-border-dark-custom, var(--uts-toc-border-custom, rgba(255, 255, 255, 0.14)));
	--uts-toc-bg: var(--uts-toc-bg-dark-custom, var(--uts-toc-bg-custom, #1e1e1e));
	--uts-toc-marker: var(--uts-toc-marker-dark-custom, var(--uts-toc-marker-custom, rgba(255, 255, 255, 0.35)));
	--uts-toc-text: #e8e8e8;
	--uts-toc-link: var(--uts-toc-link-dark-custom, var(--uts-toc-link-custom, #5eead4));
	--uts-toc-arrow-bg: rgba(255, 255, 255, 0.12);
	--uts-toc-arrow-bg-hover: rgba(255, 255, 255, 0.2);
}

.uts-toc-container[data-uts-toc-mode="light"] {
	--uts-toc-border: var(--uts-toc-border-custom, rgba(0, 0, 0, 0.10));
	--uts-toc-bg: var(--uts-toc-bg-custom, #fafafa);
	--uts-toc-marker: var(--uts-toc-marker-custom, rgba(0, 0, 0, 0.28));
	--uts-toc-text: #1f1f1f;
	--uts-toc-link: var(--uts-toc-link-custom, #1f1f1f);
	--uts-toc-arrow-bg: rgba(0, 0, 0, 0.05);
	--uts-toc-arrow-bg-hover: rgba(0, 0, 0, 0.09);
}

/* Unconditional — always active, doesn't wait on any attribute. */
.uts-toc-title,
.uts-toc-toggle {
	color: var(--uts-toc-text) !important;
}

.uts-toc-item,
.uts-toc-container a {
	color: var(--uts-toc-link) !important;
}

/* ============================================================
   Force full visibility, always.
   Many themes/page-builders (Elementor motion effects, AOS,
   scroll-reveal, etc.) apply a fade/slide "entrance animation"
   to content wrappers — the TOC box can get caught mid-fade if
   a screenshot/page-load happens before that animation finishes.
   This overrides any such opacity/transform on the box and its
   text so it's always instantly, fully visible — while leaving
   the plugin's own collapse/arrow animations untouched.
   ============================================================ */
.uts-toc-container {
	opacity: 1 !important;
	visibility: visible !important;
	transform: none !important;
}

.uts-toc-title,
.uts-toc-item,
.uts-toc-toggle,
.uts-toc-container a {
	opacity: 1 !important;
	visibility: visible !important;
}

.uts-toc-sublist .uts-toc-item {
	opacity: 0.82 !important;
}

.uts-toc-sublist .uts-toc-sublist .uts-toc-item {
	opacity: 0.7 !important;
}

.uts-toc-collapsed .uts-toc-body {
	opacity: 0 !important;
}
