/*
 * MASS ToC Enhancements v1.0.5
 * Deactivating the plugin removes everything in this file.
 *
 * All sidebar rules target ONLY the element the JS has tagged with
 * .mass-toc-meta — the specific .post-meta group that contains the ToC
 * block. Any other .post-meta on the site (blog cards, related posts,
 * other templates) is never touched.
 */

/*
 * Native anchor jumps (deep links, keyboard navigation) land below the
 * sticky header instead of behind it. The exact value is re-measured at
 * runtime by toc-enhancements.js; this is the no-JS fallback.
 */
html {
	scroll-padding-top: 135px;
}

@media (min-width: 769px) {

	/*
	 * Long sidebars: the theme's sticky column gets an internal scroll so
	 * a long ToC never clips off the bottom of short screens. This is the
	 * only rule that applies to the stock (non-floating) state.
	 */
	.post-meta.mass-toc-meta {
		max-height: calc(100vh - 120px);
		overflow-y: auto;
		/* the theme's vertical flex group wraps by default, which would
		   push the ToC into a second column when height is constrained */
		flex-wrap: nowrap !important;
		/* no visible scrollbar: the list auto-scrolls to the active
		   section, and wheel / touch scrolling still works */
		scrollbar-width: none;
	}
	.post-meta.mass-toc-meta::-webkit-scrollbar {
		display: none;
	}

	/* breathing room between the active item's accent bar and its text */
	.post-meta.mass-toc-meta .toc-link.active {
		padding-left: 0.75rem;
	}

	/*
	 * Floating ToC card.
	 * Engaged only while the JS holds .mass-toc-float on <html> — i.e. only
	 * once the reader has scrolled past the stock ToC. Without that class
	 * (top of the page, JS delayed, or JS unavailable) the block renders
	 * exactly as the theme ships it, so the ToC is always visible.
	 */
	html.mass-toc-float .post-meta.mass-toc-meta {
		/* date / category / share scroll away with the page while the card
		   is detached */
		position: static !important;
		z-index: auto !important;
	}

	html.mass-toc-float .toc-container.wp-block-mass-analytics-table-of-contents {
		position: fixed;
		/* top / left / width are driven by toc-enhancements.js */
		max-height: calc(100vh - 150px);
		overflow-y: auto;
		z-index: 600; /* stays below the site header (z-index 999) */
		box-shadow: 0 14px 44px rgba(0, 0, 0, 0.38);
		transition: opacity 0.2s ease;
		scrollbar-width: none; /* auto-scrolls to the active section */
	}
	html.mass-toc-float .toc-container.wp-block-mass-analytics-table-of-contents::-webkit-scrollbar {
		display: none;
	}

	/* Compact style for long ToCs (added by JS when the list has 9+ items)
	   so more of the list fits inside the card before it needs to scroll. */
	html.mass-toc-float .toc-container.mass-toc-long .toc-link {
		padding-top: 0.3rem;
		padding-bottom: 0.3rem;
		font-size: 0.92em;
		line-height: 1.35;
	}
}
