/* ==========================================================================
   JeffXL Terminal — single posts, pages, code blocks, TOC and comments.
   Loaded on singular views only.
   ========================================================================== */

/* Entry header ------------------------------------------------------------ */
.entry-header,
.entry-footer,
.post-navigation,
.comments-area {
	max-width: var(--measure);
	margin-inline: auto;
}

.entry-header {
	margin-bottom: 2rem;
}

.entry-crumbs {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	margin: 0 0 1rem;
	color: var(--muted);
	font: 500 0.82rem/1.4 var(--font-mono);
}

.entry-crumbs a {
	color: var(--muted);
	text-decoration: none;
}

.entry-crumbs a:hover {
	color: var(--accent);
}

.entry-title {
	margin-bottom: 1rem;
	font-size: clamp(1.85rem, 1.2rem + 3vw, 2.75rem);
	font-weight: 750;
	line-height: 1.15;
	letter-spacing: -0.025em;
	overflow-wrap: anywhere;
}

.entry-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 1rem;
	color: var(--muted);
	font: 500 0.82rem/1.4 var(--font-mono);
}

.entry-meta .avatar {
	width: 22px;
	height: 22px;
	border-radius: 50%;
}

.entry-author {
	color: var(--text);
}

/* Same block as the header, so the image's left edge lines up with the title. */
.entry-thumb {
	max-width: var(--measure);
	margin: 0 auto 2.5rem;
}

.entry-thumb img {
	display: block;
	width: 100%;
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

/* Layout with optional sticky TOC ----------------------------------------- */
.entry-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 1.5rem;
	max-width: var(--measure);
	margin-inline: auto;
}

@media (min-width: 1200px) {
	/* Keep header, footer, navigation and comments on the same left edge as the text column. */
	.single-container:has(.toc:not([hidden])) :is(.entry-header, .entry-footer, .post-navigation, .comments-area) {
		max-width: calc(var(--measure) + 230px + 3rem);
		padding-right: calc(230px + 3rem);
	}

	/* The image spans the text and TOC columns: left edge on the text, right edge on the TOC. */
	.single-container:has(.toc:not([hidden])) .entry-thumb {
		max-width: calc(var(--measure) + 230px + 3rem);
	}

	.entry-layout:has(> .toc:not([hidden])) {
		grid-template-columns: minmax(0, var(--measure)) 230px;
		column-gap: 3rem;
		max-width: calc(var(--measure) + 230px + 3rem);
	}

	.entry-layout > .toc {
		position: sticky;
		top: calc(var(--header-h) + 24px);
		grid-row: 1;
		grid-column: 2;
		align-self: start;
		max-height: calc(100vh - var(--header-h) - 48px);
		overflow-y: auto;
	}
}

.toc details {
	padding: 0.8rem 1rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg-elev);
}

.toc summary {
	color: var(--muted);
	font: 600 0.75rem/1.4 var(--font-mono);
	letter-spacing: 0.08em;
	text-transform: uppercase;
	list-style: none;
	cursor: pointer;
}

.toc summary::-webkit-details-marker {
	display: none;
}

.toc summary::before {
	content: "▸ ";
	color: var(--accent);
}

.toc details[open] summary::before {
	content: "▾ ";
}

.toc ol {
	margin: 0.75rem 0 0;
	padding: 0;
	list-style: none;
	font-size: 0.875rem;
}

.toc li {
	margin: 0.15rem 0;
}

.toc .toc-h3 {
	padding-left: 0.85rem;
}

.toc a {
	display: block;
	padding: 0.2rem 0 0.2rem 0.65rem;
	border-left: 2px solid var(--border);
	color: var(--muted);
	line-height: 1.4;
	text-decoration: none;
}

.toc a:hover {
	color: var(--text-strong);
}

.toc a.is-active {
	border-left-color: var(--accent);
	color: var(--accent);
}

@media (min-width: 1200px) {
	.toc details {
		padding: 0;
		border: 0;
		background: none;
	}
}

/* Prose ------------------------------------------------------------------- */
.prose {
	min-width: 0;
	color: var(--text);
	font-size: 1.0625rem;
	line-height: 1.78;
	overflow-wrap: break-word;
}

.prose > * {
	margin-block: 0;
}

.prose > * + * {
	margin-top: 1.25em;
}

.prose h2 {
	margin-top: 2.4em;
	font-size: 1.55rem;
}

.prose h3 {
	margin-top: 2em;
	font-size: 1.25rem;
}

.prose h4 {
	margin-top: 1.75em;
	font-size: 1.05rem;
}

.prose h2 + *,
.prose h3 + *,
.prose h4 + * {
	margin-top: 0.75em;
}

.prose h2::before,
.prose h3::before {
	color: var(--accent);
	font-family: var(--font-mono);
	font-weight: 500;
}

.prose h2::before {
	content: "## ";
	content: "## " / "";
}

.prose h3::before {
	content: "### ";
	content: "### " / "";
}

.prose a {
	color: var(--accent);
	text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.prose a:hover {
	text-decoration-color: currentColor;
}

.prose strong {
	color: var(--text-strong);
}

.prose ul,
.prose ol {
	padding-left: 1.4em;
}

.prose li + li {
	margin-top: 0.35em;
}

.prose ul li::marker {
	color: var(--accent);
}

.prose ol li::marker {
	color: var(--muted);
	font-family: var(--font-mono);
	font-size: 0.9em;
}

.prose blockquote {
	margin-inline: 0;
	padding: 0.9rem 1.2rem;
	border-left: 3px solid var(--accent);
	border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
	background: var(--bg-elev);
}

.prose blockquote p:last-child {
	margin-bottom: 0;
}

.prose blockquote cite {
	color: var(--muted);
	font-size: 0.85rem;
	font-style: normal;
}

.prose hr {
	margin-block: 2.5em;
	border: 0;
	border-top: 1px dashed var(--border-strong);
}

.prose img {
	border-radius: var(--radius-sm);
}

.prose figure {
	margin-inline: 0;
}

.prose figcaption,
.prose .wp-element-caption {
	margin-top: 0.6rem;
	color: var(--muted);
	font-size: 0.85rem;
	text-align: center;
}

.prose :not(pre) > code {
	padding: 0.12em 0.4em;
	border: 1px solid var(--border);
	border-radius: 5px;
	background: var(--bg-soft);
	color: var(--text-strong);
	font: 0.86em var(--font-mono);
	overflow-wrap: anywhere;
}

.prose table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.95rem;
}

.prose > table,
.prose .wp-block-table {
	display: block;
	overflow-x: auto;
}

.prose .wp-block-table table {
	min-width: 100%;
}

.prose th,
.prose td {
	padding: 0.6rem 0.75rem;
	border: 0;
	border-bottom: 1px solid var(--border);
	text-align: left;
	vertical-align: top;
}

.prose th {
	color: var(--muted);
	font: 600 0.78rem/1.4 var(--font-mono);
	letter-spacing: 0.05em;
	text-transform: uppercase;
}

.prose iframe,
.prose embed,
.prose object {
	max-width: 100%;
}

.prose .alignleft {
	float: left;
	max-width: 50%;
	margin: 0.3em 1.5em 1em 0;
}

.prose .alignright {
	float: right;
	max-width: 50%;
	margin: 0.3em 0 1em 1.5em;
}

.prose .aligncenter {
	display: block;
	margin-inline: auto;
}

.prose .alignwide,
.prose .alignfull {
	width: 100%;
}

.prose::after {
	content: "";
	display: table;
	clear: both;
}

.prose h1 {
	margin-top: 1.5em;
	font-size: clamp(1.5rem, 1.15rem + 1.6vw, 2rem);
	line-height: 1.2;
}

/* Phones: reading mode — larger text, shorter headings, readable metadata. */
@media (max-width: 719px) {
	.prose {
		font-size: 1.125rem;
		line-height: 1.72;
	}

	.prose > * + *,
	.prose p + p {
		margin-top: 1.1em;
	}

	.prose h1 {
		font-size: 1.5rem;
	}

	.prose h2 {
		margin-top: 2em;
		font-size: 1.35rem;
		line-height: 1.3;
	}

	.prose h3 {
		font-size: 1.18rem;
		line-height: 1.35;
	}

	.prose ul,
	.prose ol {
		padding-left: 1.2em;
	}

	.prose li + li {
		margin-top: 0.5em;
	}

	.prose figcaption,
	.prose .wp-element-caption,
	.prose blockquote cite {
		font-size: 0.9rem;
	}

	.prose pre {
		font-size: 0.875rem;
	}

	.entry-title {
		font-size: clamp(1.75rem, 1.3rem + 2.4vw, 2.1rem);
		line-height: 1.2;
	}

	.entry-meta,
	.entry-crumbs {
		font-size: 0.875rem;
	}

	.author-bio,
	.comment-meta {
		font-size: 0.95rem;
	}
}

@media (max-width: 559px) {
	.prose .alignleft,
	.prose .alignright {
		float: none;
		max-width: 100%;
		margin: 0 0 1em;
	}
}

.page-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	margin-top: 2rem;
	font-family: var(--font-mono);
}

/* Code blocks (always dark, like a terminal) ------------------------------- */
.prose pre {
	margin-block: 1.6em;
	padding: 1rem 1.1rem;
	overflow-x: auto;
	border: 1px solid var(--code-border);
	border-radius: var(--radius);
	background: var(--code-bg);
	color: var(--code-text);
	font: 0.86rem/1.65 var(--font-mono);
	tab-size: 2;
	-webkit-overflow-scrolling: touch;
}

.prose pre code,
.prose .wp-block-code code {
	display: block;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	white-space: pre;
	overflow-wrap: normal;
}

.code-block {
	margin-block: 1.6em;
	overflow: hidden;
	border: 1px solid var(--code-border);
	border-radius: var(--radius);
	background: var(--code-bg);
}

.prose > .code-block + * {
	margin-top: 1.6em;
}

.code-block pre,
.prose .code-block pre {
	margin: 0;
	border: 0;
	border-radius: 0;
}

.code-bar {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.45rem 0.6rem 0.45rem 0.85rem;
	border-bottom: 1px solid var(--code-border);
	background: var(--code-bar);
}

.code-bar .dots i {
	width: 10px;
	height: 10px;
}

.code-lang {
	margin-right: auto;
	color: #8b949e;
	font: 500 0.72rem/1 var(--font-mono);
	text-transform: lowercase;
}

.code-copy {
	padding: 0.4rem 0.65rem;
	border: 1px solid #30363d;
	border-radius: 5px;
	background: transparent;
	color: #c9d1d9;
	font: 500 0.72rem/1 var(--font-mono);
	cursor: pointer;
}

.code-copy:hover {
	border-color: #4ade80;
	color: #4ade80;
}

.hljs {
	background: transparent;
	color: var(--code-text);
}

.hljs-comment,
.hljs-quote {
	color: #7d8590;
	font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-doctag,
.hljs-meta .hljs-keyword {
	color: #c792ea;
}

.hljs-string,
.hljs-regexp,
.hljs-meta .hljs-string {
	color: #a5e075;
}

.hljs-number,
.hljs-literal,
.hljs-symbol,
.hljs-bullet {
	color: #f78c6c;
}

.hljs-title,
.hljs-title.function_,
.hljs-section {
	color: #82aaff;
}

.hljs-built_in,
.hljs-type,
.hljs-title.class_ {
	color: #ffcb6b;
}

.hljs-attr,
.hljs-attribute,
.hljs-property,
.hljs-selector-class,
.hljs-selector-id {
	color: #89ddff;
}

.hljs-variable,
.hljs-template-variable,
.hljs-params {
	color: #f2c48d;
}

.hljs-tag,
.hljs-name,
.hljs-meta {
	color: #ff757f;
}

.hljs-addition {
	background: rgb(46 160 67 / 0.18);
	color: #7ee787;
}

.hljs-deletion {
	background: rgb(248 81 73 / 0.18);
	color: #ffa198;
}

.hljs-emphasis {
	font-style: italic;
}

.hljs-strong {
	font-weight: 700;
}

/* Entry footer ------------------------------------------------------------ */
.entry-footer {
	margin-top: 3rem;
	padding-top: 1.5rem;
	border-top: 1px dashed var(--border);
}

.author-box {
	display: flex;
	align-items: flex-start;
	gap: 1rem;
	padding: 1.1rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg-elev);
}

.author-box .avatar {
	flex-shrink: 0;
	width: 56px;
	height: 56px;
	border-radius: 50%;
}

.author-name {
	margin: 0 0 0.25rem;
	font: 700 0.95rem/1.4 var(--font-mono);
}

.author-name a {
	color: var(--text-strong);
	text-decoration: none;
}

.author-bio {
	margin: 0;
	color: var(--muted);
	font-size: 0.92rem;
}

.post-navigation {
	margin-top: 2.5rem;
}

.post-navigation .nav-links {
	display: grid;
	gap: 1rem;
	justify-content: stretch;
}

@media (min-width: 640px) {
	.post-navigation .nav-links {
		grid-template-columns: 1fr 1fr;
	}

	.post-navigation .nav-next {
		grid-column: 2;
		text-align: right;
	}
}

.post-navigation a {
	display: block;
	height: 100%;
	padding: 1rem 1.1rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg-elev);
	text-decoration: none;
}

.post-navigation a:hover {
	border-color: var(--accent);
}

.nav-label {
	display: block;
	margin-bottom: 0.35rem;
	color: var(--muted);
	font: 500 0.75rem/1 var(--font-mono);
}

.nav-title {
	color: var(--text-strong);
	font-weight: 600;
	overflow-wrap: anywhere;
}

/* Comments ---------------------------------------------------------------- */
.comments-area {
	margin-top: 3rem;
}

.comments-title,
.comment-reply-title {
	font: 700 1.05rem/1.3 var(--font-mono);
	letter-spacing: 0;
}

.comment-list,
.comment-list .children {
	margin: 0;
	padding: 0;
	list-style: none;
}

.comment-list .children {
	margin-left: 0.5rem;
	padding-left: 1rem;
	border-left: 1px dashed var(--border);
}

@media (min-width: 720px) {
	.comment-list .children {
		padding-left: 1.5rem;
	}
}

.comment-body {
	padding: 1rem 0;
	border-bottom: 1px solid var(--border);
}

.comment-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25rem 0.75rem;
	font-size: 0.88rem;
}

.comment-author .avatar {
	margin-right: 0.5rem;
	border-radius: 50%;
	vertical-align: middle;
}

.comment-author .fn {
	color: var(--text-strong);
	font-style: normal;
	font-weight: 600;
}

.comment-author .says {
	display: none;
}

.comment-metadata a {
	color: var(--muted);
	font: 500 0.75rem/1.4 var(--font-mono);
	text-decoration: none;
}

.comment-content {
	margin-top: 0.5rem;
	overflow-wrap: break-word;
}

.reply a {
	font: 600 0.75rem/1 var(--font-mono);
	text-decoration: none;
}

.comment-respond {
	margin-top: 2rem;
	padding: 1.25rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg-elev);
}

.comment-form p {
	margin: 0 0 1rem;
}

.comment-form label {
	display: block;
	margin-bottom: 0.35rem;
	color: var(--muted);
	font: 500 0.8rem/1.4 var(--font-mono);
}

.comment-form .comment-form-cookies-consent {
	display: flex;
	align-items: flex-start;
	gap: 0.5rem;
}

.comment-form .comment-form-cookies-consent label {
	margin: 0;
}

.comment-notes,
.logged-in-as {
	color: var(--muted);
	font-size: 0.85rem;
}

/* Terminal sessions (```console blocks): "$" prompt, dimmed output ----------- */
.prose pre.is-console .ps1 {
	color: #4ade80;
	user-select: none;
}

.prose pre.is-console .term-cmd {
	color: var(--code-text);
}

.prose pre.is-console .term-out {
	color: #8b949e;
}

/* Details block (FAQ accordions) --------------------------------------------- */
.prose .wp-block-details {
	margin-block: 0.75rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg-elev);
	transition: border-color 0.15s;
}

.prose .wp-block-details[open],
.prose .wp-block-details:hover {
	border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.prose .wp-block-details > summary {
	padding: 0.85rem 1rem;
	color: var(--text-strong);
	font-weight: 600;
	list-style: none;
	cursor: pointer;
}

.prose .wp-block-details > summary::-webkit-details-marker {
	display: none;
}

.prose .wp-block-details > summary::before {
	content: "+ ";
	content: "+ " / "";
	color: var(--accent);
	font-family: var(--font-mono);
}

.prose .wp-block-details[open] > summary::before {
	content: "− ";
	content: "− " / "";
}

.prose .wp-block-details > :not(summary) {
	margin: 0;
	padding: 0 1rem 0.9rem 2.1rem;
	color: var(--text);
}

/* Read mode (phones) -------------------------------------------------------
   Book-like reading toggled by the "Read mode" button: serif text, paper or
   night colors, adjustable size, distractions hidden. main.js sets
   data-read / data-read-tone / data-read-size on <html>. */
.read-fab,
.read-mode {
	display: none;
}

@media (max-width: 719px) {
	.read-fab {
		position: fixed;
		right: var(--gutter);
		bottom: calc(var(--gutter) + env(safe-area-inset-bottom, 0px));
		z-index: 40;
		display: inline-flex;
		align-items: center;
		gap: 0.45rem;
		padding: 0.7rem 1rem;
		border: 1px solid var(--border-strong);
		border-radius: 999px;
		background: var(--bg-elev);
		color: var(--text-strong);
		font: 600 0.9rem/1 var(--font-sans);
		box-shadow: var(--shadow);
		cursor: pointer;
	}

	.read-fab .icon {
		color: var(--accent);
	}

	:root[data-read="on"] body.single {
		--read-bg: #f4ecd8;
		--read-text: #3b3024;
		--read-muted: #7c6b56;
		--read-accent: #8a4f1d;
		--read-border: #e0d3b8;
		--read-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, ui-serif, serif;
		background: var(--read-bg);
		color: var(--read-text);
		color-scheme: light;
	}

	:root[data-read="on"][data-read-tone="night"] body.single {
		--read-bg: #15130f;
		--read-text: #d8cebd;
		--read-muted: #978b78;
		--read-accent: #d9a066;
		--read-border: #2d2721;
		color-scheme: dark;
	}

	:root[data-read="on"] body.single :is(.site-banner, .site-header, .site-footer, .entry-crumbs, .tag-list, .toc, .entry-footer, .post-navigation, .comments-area, .read-fab) {
		display: none;
	}

	:root[data-read="on"] body.single .read-mode {
		display: block;
	}

	:root[data-read="on"] body.single .site-main {
		padding-top: 1.5rem;
		padding-bottom: 6rem;
	}

	:root[data-read="on"] body.single :is(.entry-title, .prose h1, .prose h2, .prose h3, .prose h4) {
		color: var(--read-text);
		font-family: var(--read-serif);
		letter-spacing: 0;
	}

	:root[data-read="on"] body.single .entry-meta {
		color: var(--read-muted);
	}

	:root[data-read="on"] body.single .entry-author {
		color: var(--read-text);
	}

	:root[data-read="on"] body.single .prose {
		color: var(--read-text);
		font-family: var(--read-serif);
		font-size: 1.1875rem;
		line-height: 1.75;
		text-wrap: pretty;
	}

	:root[data-read="on"][data-read-size="0"] body.single .prose {
		font-size: 1.0625rem;
	}

	:root[data-read="on"][data-read-size="2"] body.single .prose {
		font-size: 1.3125rem;
	}

	:root[data-read="on"][data-read-size="3"] body.single .prose {
		font-size: 1.4375rem;
	}

	:root[data-read="on"][data-read-size="4"] body.single .prose {
		font-size: 1.5625rem;
	}

	:root[data-read="on"] body.single .prose :is(h2, h3)::before {
		content: none;
	}

	:root[data-read="on"] body.single .prose :is(strong, a) {
		color: inherit;
	}

	:root[data-read="on"] body.single .prose a {
		text-decoration-color: var(--read-accent);
	}

	:root[data-read="on"] body.single .prose :is(ul li, ol li)::marker {
		color: var(--read-accent);
	}

	:root[data-read="on"] body.single .prose blockquote {
		border-left-color: var(--read-accent);
		background: transparent;
		font-style: italic;
	}

	:root[data-read="on"] body.single .prose :not(pre) > code {
		border-color: var(--read-border);
		background: color-mix(in srgb, var(--read-text) 7%, transparent);
		color: var(--read-text);
	}

	:root[data-read="on"] body.single .prose hr {
		border-top-color: var(--read-border);
	}

	.read-progress {
		position: fixed;
		inset: 0 0 auto;
		z-index: 41;
		height: 3px;
		background: var(--read-border);
	}

	.read-progress span {
		display: block;
		width: 0;
		height: 100%;
		background: var(--read-accent);
	}

	.read-bar {
		position: fixed;
		inset: auto 0 0;
		z-index: 41;
		display: flex;
		align-items: center;
		gap: 0.5rem;
		padding: 0.6rem var(--gutter) calc(0.6rem + env(safe-area-inset-bottom, 0px));
		border-top: 1px solid var(--read-border);
		background: var(--read-bg);
	}

	.read-btn {
		min-width: 44px;
		min-height: 44px;
		padding: 0 0.75rem;
		border: 1px solid var(--read-border);
		border-radius: var(--radius-sm);
		background: transparent;
		color: var(--read-text);
		font: 600 0.95rem/1 var(--read-serif);
		cursor: pointer;
	}

	.read-btn--big {
		font-size: 1.15rem;
	}

	.read-btn .icon {
		vertical-align: middle;
	}

	.read-percent {
		margin-left: auto;
		color: var(--read-muted);
		font: 500 0.85rem/1 var(--font-mono);
	}

	.read-exit {
		font-family: var(--font-sans);
	}
}
