/*
 * 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: rgba(0, 0, 0, 0.10);
	--uts-toc-bg: #fafafa;
	--uts-toc-marker: rgba(0, 0, 0, 0.28);
	--uts-toc-text: #1f1f1f;
	--uts-toc-link: #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);
}

.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;
	list-style: none;
}

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

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

.uts-toc-item::before {
	content: "";
	display: inline-block;
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background: var(--uts-toc-marker);
	margin-right: 0.6em;
	vertical-align: 0.12em;
}

/* Sub-items (h3, h4...) get a visibly smaller, lighter treatment so
   the h2 -> h3 hierarchy is obvious at a glance, not just via indent. */
.uts-toc-sublist .uts-toc-item {
	font-size: 0.93em;
	opacity: 0.82;
}

.uts-toc-sublist .uts-toc-item::before {
	width: 4px;
	height: 4px;
}

.uts-toc-sublist .uts-toc-sublist .uts-toc-item {
	font-size: 0.9em;
	opacity: 0.7;
}

/* Numbered mode swaps the dot markers for native counters. */
.uts-toc-container ol.uts-toc-list {
	counter-reset: uts-toc-counter;
}

.uts-toc-container ol.uts-toc-list > .uts-toc-item {
	counter-increment: uts-toc-counter;
	padding-left: 1.6em !important;
}

.uts-toc-container ol.uts-toc-list > .uts-toc-item::before {
	content: counter(uts-toc-counter) ".";
	display: inline-block;
	background: none;
	width: auto;
	height: auto;
	margin-right: 0.5em;
	vertical-align: baseline;
	font-size: 0.9em;
	font-weight: 600;
	opacity: 0.6;
}

.uts-toc-container ol.uts-toc-sublist {
	counter-reset: uts-toc-counter;
}

/* Links deliberately unstyled for color — theme's own `a` / `a:hover`
   rules apply here exactly as they do anywhere else on the page. */
.uts-toc-container a {
	font: inherit;
	line-height: inherit !important;
	text-decoration: none;
	margin: 0 !important;
	padding: 0 !important;
	color: var(--uts-toc-link, inherit);
}

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

/* 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.
   ============================================================ */

@media (prefers-color-scheme: dark) {
	.uts-toc-container:not([data-uts-toc-mode="light"]) {
		--uts-toc-border: rgba(255, 255, 255, 0.14);
		--uts-toc-bg: #1e1e1e;
		--uts-toc-marker: rgba(255, 255, 255, 0.35);
		--uts-toc-text: #e8e8e8;
		--uts-toc-link: #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="dark"] {
	--uts-toc-border: rgba(255, 255, 255, 0.14);
	--uts-toc-bg: #1e1e1e;
	--uts-toc-marker: rgba(255, 255, 255, 0.35);
	--uts-toc-text: #e8e8e8;
	--uts-toc-link: #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: rgba(0, 0, 0, 0.10);
	--uts-toc-bg: #fafafa;
	--uts-toc-marker: rgba(0, 0, 0, 0.28);
	--uts-toc-text: #1f1f1f;
	--uts-toc-link: #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;
}
