/**
 * Sidebar (inc/sidebar.php): categories, newest posts as dark tiles,
 * help box; and the columns it sits in. Loaded where the theme sidebar
 * shows (archives, single posts: body.bst-has-sidebar).
 * See "Sidebar" in docs/design-system.md (blog-archive-01.jpg,
 * blog-archive-02.jpg).
 */

/*
 * Columns, shared by the archives and single posts: one section on ivory
 * with --section-y padding inside the page container (#page, aligned
 * with .bst-container in base.css). Below 1024px one column, the sidebar
 * below the main column; from 1024px the main column takes 8 of 12
 * columns and the sidebar the other 4. Widths from here, not from the
 * GeneratePress options (content 70% / sidebar 30%).
 */
.bst-has-sidebar .site-content {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--gap);
	padding-top: var(--section-y);
	padding-bottom: var(--section-y);
}

.bst-has-sidebar .site-content .content-area,
.bst-has-sidebar .site-content .is-right-sidebar {
	width: auto;
}

/* GeneratePress separate-containers margins around main and the sidebar. */
.bst-has-sidebar .site-main,
.bst-has-sidebar .inside-right-sidebar {
	margin: 0;
}

@media (min-width: 1024px) {

	.bst-has-sidebar .site-content {
		grid-template-columns: repeat(12, minmax(0, 1fr));
	}

	.bst-has-sidebar .site-content .content-area {
		grid-column: 1 / 9;
	}

	.bst-has-sidebar .site-content .is-right-sidebar {
		grid-column: 9 / 13;
	}
}

/* Three blocks, separated by twice --gap. */
.bst-sidebar {
	display: flex;
	flex-direction: column;
	gap: calc(var(--gap) * 2);
}

/* Block titles: h2, heading font, uppercase, --text-h3, hairline below. */
.bst-sidebar__title {
	margin: 0 0 0.75em;
	padding-bottom: 0.5em;
	border-bottom: 1px solid var(--color-border);
	font-size: var(--text-h3);
}

/* Lists */
.bst-sidebar__cats,
.bst-sidebar__subcats,
.bst-sidebar__tiles {
	margin: 0;
	padding: 0;
	list-style: none;
}

/*
 * Category rows: name in the menu type style (--color-text, forest on
 * hover and focus), count in the date style at the right end; hairlines
 * between rows, at least 44px tall.
 */
.bst-sidebar__cat + .bst-sidebar__cat,
.bst-sidebar__subcat {
	border-top: 1px solid var(--color-border);
}

.bst-sidebar__cat-link {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1em;
	min-height: 44px;
	padding: 0.5em 0;
	color: var(--color-text);
	text-decoration: none;
}

.bst-sidebar__cat-link:hover,
.bst-sidebar__cat-link:focus {
	color: var(--color-forest);
}

.bst-sidebar__cat-name {
	font-family: var(--font-body);
	font-size: var(--text-menu);
	font-weight: 500;
	line-height: 1.5;
	letter-spacing: 0.15em;
	text-transform: uppercase;
}

.bst-sidebar__count {
	flex-shrink: 0;
	color: var(--color-accent);
	font-family: var(--font-heading);
	font-size: var(--text-body);
	font-style: italic;
	line-height: 1.4;
}

/* Current top-level branch (accent exception) and the current category. */
.bst-sidebar__cat.is-current-branch > .bst-sidebar__cat-link,
.bst-sidebar__cat-link[aria-current="page"] {
	color: var(--color-accent);
}

/* Child categories of the current branch: indented, heading font italic. */
.bst-sidebar__subcats {
	padding-left: 1.25em;
}

.bst-sidebar__subcat .bst-sidebar__cat-name {
	font-family: var(--font-heading);
	font-size: var(--text-link);
	font-style: italic;
	font-weight: 400;
	letter-spacing: 0;
	text-transform: none;
}

/*
 * Post tiles: 16:9 featured image under --color-overlay (plain forest
 * without one); the title, white heading font italic, at the bottom left.
 * The whole tile is one link.
 */
.bst-sidebar__tiles {
	display: grid;
	gap: calc(var(--gap) / 2);
}

.bst-sidebar__tile-item {
	margin: 0;
}

.bst-tile {
	position: relative;
	display: flex;
	align-items: flex-end;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background-color: var(--color-forest);
	color: var(--color-white);
	text-decoration: none;
}

.bst-tile::after {
	position: absolute;
	inset: 0;
	background-color: var(--color-overlay);
	content: "";
}

.bst-tile__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.bst-tile__title {
	position: relative;
	z-index: 1;
	padding: 1em 1.25em;
	font-family: var(--font-heading);
	font-size: var(--text-link);
	font-style: italic;
	line-height: 1.35;
	text-decoration: underline;
	text-decoration-color: transparent;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
	transition: text-decoration-color var(--motion-fast) ease;
}

.bst-tile:hover,
.bst-tile:focus {
	color: var(--color-white);
}

.bst-tile:hover .bst-tile__title,
.bst-tile:focus .bst-tile__title {
	text-decoration-color: var(--color-accent);
}

/* Help box: dark surface on forest. */
.bst-sidebar__help {
	--focus-color: var(--color-white);
	--surface-color: var(--color-forest);

	padding: var(--gap);
	background-color: var(--color-forest);
	color: var(--color-white);
}

.bst-sidebar__help-title {
	margin: 0 0 0.5em;
	color: var(--color-white);
	font-size: var(--text-h3);
}

.bst-sidebar__help-text {
	margin: 0 0 1.5em;
}
