/* The table of contents at the top of a blog post (Elementor Pro "Table of Contents" widget, CSS class bj-toc;
   build/pro/blog-toc.php). Its title, which headings it lists, colours and fonts are widget settings (the Style tab
   uses the site's Global Colors and Fonts); this file adds the card look the sidebar cards share: a soft shadow,
   a gold hairline after the small-caps title, serif numbers, and the heading landing clear of the sticky header. */

/* fewer than two headings to list: no box. The widget builds its list in the browser (the spinner shows until then);
   no headings leave its body empty, one heading makes a list of one. Always shown in the Elementor editor. */
body:not(.elementor-editor-active) .bj-toc:not(:has(.elementor-toc__spinner-container)):not(:has(.elementor-toc__list-item ~ .elementor-toc__list-item)) { display: none; }

.bj-toc .elementor-widget-container, .bj-toc:not(:has(.elementor-widget-container)) { box-shadow: 0 12px 30px -24px rgba(26, 26, 26, .45); }

/* header: "IN THIS ARTICLE", then a thin gold rule up to the fold button */
.bj-toc .elementor-toc__header { position: relative; gap: 16px; padding: 20px 26px; }
.bj-toc .elementor-toc__header-title { display: flex; align-items: center; gap: 14px; margin: 0; letter-spacing: .2em; text-transform: uppercase; line-height: 1.4; }
.bj-toc .elementor-toc__header-title::after { content: ""; flex: 1 1 auto; min-width: 24px; height: 1px; background: linear-gradient(90deg, var(--bj-gold), rgba(203, 167, 103, .15)); }
.bj-toc .elementor-toc__toggle-button { display: inline-grid; place-items: center; width: 32px; height: 32px; margin: -6px -8px -6px 0; border-radius: 4px; }
.bj-toc .elementor-toc__toggle-button::after { content: ""; position: absolute; inset: 0; } /* the whole bar opens and closes it */
.bj-toc .elementor-toc__toggle-button svg { width: 16px; height: 16px; fill: none; transition: transform .3s var(--bj-ease); }
.bj-toc .elementor-toc__toggle-button svg * { stroke: var(--toggle-button-color, var(--bj-gold-text)); }
.bj-toc .elementor-toc__toggle-button--collapse svg { transform: rotate(180deg); }
.bj-toc .elementor-toc__toggle-button:focus-visible { outline: 2px solid var(--bj-gold); outline-offset: 2px; }
/* folded (phones): only the header shows, so no line under it */
.bj-toc.elementor-toc--collapsed .elementor-toc__header { border-bottom-color: transparent; }

/* the list: one heading per line, serif numbers in gold, a line that wraps hangs under its words */
.bj-toc .elementor-toc__body { padding: 20px 26px 12px; }
.bj-toc .elementor-toc__list-item { margin: 0 0 .7em; line-height: 1.45; }
.bj-toc .elementor-toc__list-item.elementor-item-active { font-weight: inherit; }
.bj-toc .elementor-toc__list-item-text-wrapper { align-items: baseline; }
.bj-toc ol.elementor-toc__list-wrapper .elementor-toc__list-item-text-wrapper::before { flex: none; min-width: 1.75em; margin-inline-end: 4px; font-family: var(--bj-serif); font-size: 1.12em; font-weight: 600; line-height: 1; }
.bj-toc .elementor-toc__list-item-text { text-decoration: none; transition-property: color; }
/* "you are here": the heading the reader has reached (inc/pro/blog-toc.php marks it bj-current), in the widget's
   Active colour. Elementor's own highlight (elementor-item-active) picks an item at random on load, so it is muted. */
.bj-toc .elementor-toc__body .elementor-toc__list-item-text.elementor-item-active:not(.bj-current) { color: var(--item-text-color); text-decoration: var(--item-text-decoration, none); }
.bj-toc .elementor-toc__body .elementor-toc__list-item-text.bj-current { color: var(--item-text-active-color, var(--bj-gold-text)); font-weight: 600; }
/* headings that carry their own number ("1. …"): the list leaves its numbers out (inc/pro/blog-toc.php) */
.bj-toc.bj-toc--own-numbers ol.elementor-toc__list-wrapper .elementor-toc__list-item-text-wrapper::before { content: none; }
.bj-toc .elementor-toc__list-item .elementor-toc__list-wrapper { margin-top: .6em; }

/* a heading picked in the list lands below the sticky header, with room to breathe (the list links to an empty
   anchor the widget puts before each heading; the browser scrolls to it itself) */
.bj-prose :is(h2, h3, h4) { scroll-margin-top: calc(var(--header-sticky-height, 72px) + 28px); }
.bj-prose :is(.elementor-menu-anchor, .elementor-toc__heading-anchor) { scroll-margin-top: var(--header-sticky-height, 72px); } /* the heading's own top margin adds the air */
.admin-bar .bj-prose :is(h2, h3, h4) { scroll-margin-top: calc(var(--header-sticky-height, 72px) + 32px + 28px); }
.admin-bar .bj-prose :is(.elementor-menu-anchor, .elementor-toc__heading-anchor) { scroll-margin-top: calc(var(--header-sticky-height, 72px) + 32px); }
@media (prefers-reduced-motion: no-preference) { html:has(.bj-toc) { scroll-behavior: smooth; } }

@media (max-width: 767px) {
	.bj-toc .elementor-toc__header { padding: 16px 20px; }
	.bj-toc .elementor-toc__body { padding: 16px 20px 8px; }
}
