/* Table of contents list: used by the inline block and by the drawer behind the Contents button. */
.dwp-rx-toc {
	font-size: var(--dwp-rx-toc-font-size, 0.9375rem);
	line-height: 1.4;
	color: var(--dwp-rx-toc-text, inherit);
	background: var(--dwp-rx-toc-bg, transparent);
}
.dwp-rx-toc[hidden] { display: none !important; }
.dwp-rx-toc__summary { cursor: pointer; font-weight: 600; padding: 0.25rem 0; }

/*
 * The !important below is deliberate: in the block editor this runs alongside WordPress' own
 * default editor styles for lists (meant for the core List block), and their load order relative
 * to our own stylesheet cannot be predicted or influenced. Without it that default style
 * sometimes won, so the table of contents looked like unformatted plain text instead of a list.
 */
.dwp-rx-toc .dwp-rx-toc__list {
	position: relative;
	list-style: none !important;
	margin: 0.5rem 0 0;
	padding: 0;
	max-height: 70vh;
	overflow: auto;
	border-inline-start: 1px solid var(--c-border, rgba(128, 128, 128, 0.4));
}
/*
 * Themes such as Genesis put list-style-type on the <li> (".entry-content ol > li") and margins and
 * padding on ".entry-content ol". The selectors here start with .dwp-rx-toc so they outrank those.
 */
.dwp-rx-toc .dwp-rx-toc__item,
.dwp-rx-toc .dwp-rx-toc__group { list-style: none !important; }
.dwp-rx-toc .dwp-rx-toc__item a,
.dwp-rx-toc .dwp-rx-toc__item .dwp-rx-toc__link {
	display: block !important;
	margin-inline-start: -1px;
	padding: 0.3rem 0.75rem;
	border-inline-start: 2px solid transparent;
	/*
	 * Deliberately "inherit" and no colour of its own: an explicit value on this descendant would
	 * otherwise block the text colour someone picks in the block settings (background/text) on the
	 * block itself, because "color" normally inherits until a child sets something else.
	 */
	color: inherit;
	/* Themes often bold every link in the content (".entry-content a"). */
	font-weight: inherit;
	text-decoration: none;
}
.dwp-rx-toc .dwp-rx-toc__item--l3 a { padding-inline-start: 1.5rem; }
.dwp-rx-toc .dwp-rx-toc__item--l4 a { padding-inline-start: 2.25rem; }
/*
 * Hover must not lower the contrast of the text. The text gets a touch heavier instead, drawn with
 * a text-shadow in the current colour so the width does not change (a real font-weight would
 * re-wrap long headings), plus a faint tint. It follows the text colour, so it works in any theme.
 */
.dwp-rx-toc .dwp-rx-toc__item a:hover {
	text-shadow: 0 0 0.6px currentColor, 0 0 0.6px currentColor;
	background: color-mix( in srgb, currentColor 8%, transparent );
}
.dwp-rx-toc .dwp-rx-toc__item a[aria-current] {
	border-inline-start-color: var(--c-accent, currentColor);
	font-weight: 600;
}

/*
 * Grouped/collapsible variant: the top-level heading is itself a <summary>, with a small plus or
 * minus box in front of the title. Themes like to give <details> and <summary> a border, padding
 * and a marker of their own, so those are reset here.
 */
.dwp-rx-toc .dwp-rx-toc__group-toggle {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	box-shadow: none;
}
.dwp-rx-toc .dwp-rx-toc__group-toggle > summary {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	font-weight: inherit;
	list-style: none !important;
	cursor: pointer;
}
.dwp-rx-toc .dwp-rx-toc__group-toggle > summary::marker { content: ''; }
.dwp-rx-toc .dwp-rx-toc__group-toggle > summary::-webkit-details-marker { display: none; }
.dwp-rx-toc .dwp-rx-toc__group-toggle > summary > a { flex: 1 1 auto; min-width: 0; }
/* Same size and colours as the level badge in the panel, so titles line up with the rows without a group. */
.dwp-rx-toc .dwp-rx-toc__toggle {
	flex: none;
	box-sizing: border-box;
	min-width: 2.75em;
	padding: 0.1em 0.4em;
	font-size: 0.75em;
	font-weight: 600;
	line-height: 1.4;
	text-align: center;
	color: var( --dwp-rx-badge-text, #1e1e1e );
	background: var( --dwp-rx-badge-bg, #ddd );
	border-radius: 4px;
}
.dwp-rx-toc .dwp-rx-toc__toggle::before { content: '+'; }
.dwp-rx-toc .dwp-rx-toc__group-toggle[open] > summary .dwp-rx-toc__toggle::before { content: '\2212'; }
.dwp-rx-toc .dwp-rx-toc__sublist { list-style: none !important; margin: 0; padding: 0; }

/* Compact style: lighter and smaller, fits a narrow sidebar better. */
.dwp-rx-toc--compact { font-size: var(--dwp-rx-toc-font-size, 0.8125rem); }
.dwp-rx-toc--compact .dwp-rx-toc__summary { font-weight: 500; }
.dwp-rx-toc--compact .dwp-rx-toc__list { border-inline-start-width: 1px; opacity: 0.95; }
.dwp-rx-toc--compact .dwp-rx-toc__item a { padding-block: 0.2rem; }
.dwp-rx-toc--compact .dwp-rx-toc__item a[aria-current] { font-weight: 500; }

/* Anchor jumps do not end up under a fixed header. Adjust the variable for your theme. */
.wp-block-post-content :is(h2, h3, h4)[id],
.entry-content :is(h2, h3, h4)[id],
[data-dwp-rx-heading] {
	scroll-margin-top: var(--dwp-rx-anchor-offset, 5rem);
}
