/*
 * Post Sidebar layout (Gravitate, 2026-11-17).
 * Loaded only on single blog posts whose Post Sidebar has widgets (see gravitate/post-sidebar.php).
 * Desktop: article on the left, table of contents on the right, staying in view while scrolling
 * (32px from the top: the site header is not sticky). The widget title is sized down from the theme's 32px h2.
 * Below 1024px: one column, with the table of contents above the article.
 */
.emr-post-layout {
	align-items: start;
	display: grid;
	gap: 48px;
	grid-template-columns: minmax(0, 1fr) 300px;
}

/* The article column keeps the theme's own styles; this only stops long content from widening the grid. */
.emr-post-layout > .site-main {
	min-width: 0;
}

.emr-post-sidebar {
	max-height: calc(100vh - var(--emr-post-sidebar-top, 32px) - 24px);
	overflow-y: auto;
	position: sticky;
	top: var(--emr-post-sidebar-top, 32px);
}

.emr-post-sidebar .widget-title {
	font-size: 22px;
	line-height: 1.25;
	margin-bottom: 12px;
}

.emr-post-sidebar .widget {
	margin-bottom: 24px;
	padding: 0;
}

@media (max-width: 1023px) {
	.emr-post-layout {
		gap: 24px;
		grid-template-columns: minmax(0, 1fr);
	}

	/* On phones and tablets the table of contents comes first, above the article. */
	.emr-post-sidebar {
		max-height: none;
		order: -1;
		overflow: visible;
		position: static;
	}
}

/*
 * Table of contents link states (Easy TOC widget).
 * Brand red is #d83531 (the site's date and button red). For link TEXT we use a darker
 * #b52a26 so it keeps 4.5:1 contrast on white; the brighter red is used for the accent bar.
 */
.emr-post-sidebar .ez-toc-widget-container ul.ez-toc-list li a {
	transition: color 0.15s ease;
}

#post-sidebar .ez-toc-widget-container ul.ez-toc-list li a:hover,
#post-sidebar .ez-toc-widget-container ul.ez-toc-list li a:focus-visible {
	color: #b52a26;
	text-decoration: underline;
	text-underline-offset: 3px;
}

#post-sidebar .ez-toc-widget-container ul.ez-toc-list li a:focus-visible {
	outline: 2px solid #b52a26;
	outline-offset: 2px;
}

/*
 * Current section. Highlighting is done by our own script (class "emr-current", see
 * gravitate/post-sidebar.php) because the plugin's jQuery highlighter is blocked by a theme
 * script error. The plugin's own li.active styling is neutralised here so only one item is
 * ever highlighted. The #post-sidebar id outranks the plugin and theme link colours.
 */
#post-sidebar .ez-toc-widget-container ul.ez-toc-list li.active {
	background-color: transparent;
}

#post-sidebar .ez-toc-widget-container ul.ez-toc-list li.active > a {
	font-weight: inherit;
}

#post-sidebar .ez-toc-widget-container ul.ez-toc-list li.emr-current {
	background-color: #ededed;
	box-shadow: inset 3px 0 0 #d83531;
}

#post-sidebar .ez-toc-widget-container ul.ez-toc-list li.emr-current > a {
	color: #b52a26;
	font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
	.emr-post-sidebar .ez-toc-widget-container ul.ez-toc-list li a {
		transition: none;
	}
}
