/*
 * ToolsBased — Reading layout for single blog posts.
 * Left: auto TOC. Center: readable article. Right: suggestions rail.
 * Inherits the hand-drawn tokens from handdrawn.css.
 */

/* ---------- 3-column grid ---------- */
.tb-single-post .tb-container {
	max-width: 1200px;
}

/* Keep title card + breadcrumb comfortably narrow */
.tb-single-post .tb-breadcrumb,
.tb-single-post .tb-post > header.tb-card {
	max-width: 880px;
	margin-left: auto;
	margin-right: auto;
}

.tb-reading-layout {
	display: grid;
	grid-template-columns: 240px minmax(0, 1fr) 300px;
	gap: 2.5rem;
	align-items: start;
	margin-top: 2rem;
}

.tb-toc-col,
.tb-rail-col {
	min-width: 0;
	align-self: stretch;
}

/* No headings = no TOC track: article takes the freed space. */
@media (min-width: 1101px) {
	.tb-reading-layout.tb-no-toc {
		grid-template-columns: minmax(0, 1fr) 300px;
	}

	.tb-reading-layout.tb-no-toc .tb-article-col {
		max-width: 78ch;
	}
}

/* Sticky side rails on desktop */
@media (min-width: 1101px) {
	.tb-toc-col nav#tb-toc,
	.tb-rail-col .tb-rail-sticky {
		position: sticky;
		top: 1.5rem;
	}
}

/* ---------- Center article: readable measure ---------- */
.tb-article-col {
	min-width: 0;
	max-width: 68ch;
	font-size: 1.125rem;
	line-height: 1.75;
}

.tb-article-col h2 {
	margin-top: 2.25em;
	line-height: 1.3;
	scroll-margin-top: 1.5rem;
}

.tb-article-col h3 {
	margin-top: 1.75em;
	line-height: 1.35;
	scroll-margin-top: 1.5rem;
}

.tb-article-col .tb-post-content {
	font-size: 1.25rem;
}

.tb-article-col p,
.tb-article-col ul,
.tb-article-col ol {
	margin-bottom: 1.25em;
}

.tb-article-col table {
	width: 100%;
	display: block;
	overflow-x: auto;
	border-collapse: collapse;
}

.tb-article-col img {
	max-width: 100%;
	height: auto;
}

/* ---------- Left: table of contents ---------- */
#tb-toc {
	font-size: 0.95rem;
	line-height: 1.5;
	border: 3px solid var(--tb-ink);
	border-radius: var(--tb-wobble-md);
	background: var(--tb-card);
	box-shadow: var(--tb-shadow-card);
	padding: 1rem 1.1rem;
	max-height: calc(100vh - 3rem);
	overflow-y: auto;
}

.tb-toc-title {
	font-family: var(--tb-font-head);
	font-size: 1.05rem;
	margin: 0 0 0.6rem;
}

.tb-toc-list,
.tb-toc-list ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.tb-toc-list ul {
	padding-left: 1rem;
	border-left: 2px dashed var(--tb-erased);
	margin: 0.15rem 0 0.15rem 0.25rem;
}

.tb-toc-list li {
	margin: 0.3rem 0;
}

.tb-toc-list a {
	color: var(--tb-ink);
	text-decoration: none;
}

.tb-toc-list a:hover {
	color: var(--tb-accent2);
	text-decoration: underline;
}

.tb-toc-list a[aria-current="true"] {
	color: var(--tb-accent);
	font-weight: 700;
}

/* Mobile collapsible copy (injected by JS, desktop-hidden) */
.tb-toc-mobile {
	display: none;
	margin-bottom: 1.5rem;
	border: 3px solid var(--tb-ink);
	border-radius: var(--tb-wobble-md);
	background: var(--tb-card);
	box-shadow: var(--tb-shadow-card);
	padding: 0.7rem 1rem;
}

.tb-toc-mobile summary {
	cursor: pointer;
	font-family: var(--tb-font-head);
	font-size: 1.05rem;
	min-height: 44px;
}

/* ---------- Right: suggestion rail ---------- */
.tb-rail-card {
	border: 3px solid var(--tb-ink);
	border-radius: var(--tb-wobble);
	background: var(--tb-card);
	box-shadow: var(--tb-shadow-card);
	padding: 1.1rem 1.2rem;
	margin-bottom: 1.5rem;
}

.tb-rail-card h3 {
	font-size: 1.15rem;
	margin: 0 0 0.7rem;
}

.tb-rail-card ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.tb-rail-card li {
	margin: 0.55rem 0;
	line-height: 1.45;
}

.tb-rail-card li a {
	color: var(--tb-ink);
	text-decoration: none;
}

.tb-rail-card li a:hover {
	color: var(--tb-accent2);
	text-decoration: underline;
}

.tb-rail-tool {
	background: var(--tb-postit);
}

.tb-rail-tool .tb-btn {
	width: 100%;
	margin-top: 0.6rem;
	font-size: 1rem;
	min-height: 44px;
}

/* ---------- Byline ---------- */
.tb-byline {
	gap: 1rem;
	align-items: center;
	margin-bottom: 1rem;
	font-size: 0.95rem;
}

/* ---------- Mobile: stack everything ---------- */
@media (max-width: 1100px) {
	.tb-reading-layout {
		grid-template-columns: minmax(0, 1fr);
		gap: 0;
	}

	.tb-toc-col {
		display: none;
	}

	.tb-toc-mobile {
		display: block;
	}

	.tb-article-col {
		max-width: 100%;
		font-size: 1.0625rem;
	}

	.tb-rail-col {
		margin-top: 2.5rem;
	}
}

/* Small phones: tighter spacing, no horizontal scroll */
@media (max-width: 600px) {
	.tb-reading-layout {
		margin-top: 1.25rem;
	}

	.tb-article-col {
		font-size: 1.0625rem;
	}

	.tb-article-col .tb-post-content {
		font-size: 1.125rem;
	}

	.tb-rail-card {
		padding: 1rem;
	}
}
