/* ========== POST VIEW ============================================ */
.post-outer {
	max-width: var(--post-max);
	margin: 0 auto;
	padding: calc(var(--space-lg) * 5) 0 var(--space-3xl);
}
.post-nav {
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: var(--text-label);
	font-family: var(--font-mono);
	color: var(--ink-faint);
	margin-bottom: var(--space-2xl);
}
.post-nav a {
	color: var(--ink-faint);
	text-decoration: none;
	letter-spacing: var(--tracking-data);
}
.post-nav a:hover {
	color: var(--accent);
	text-decoration: none;
}
.post-nav .breadcrumb {
	display: flex;
	align-items: center;
	gap: 0;
}

.post-meta {
	display: flex;
	align-items: center;
	gap: var(--space-md);
	font-size: var(--text-label);
	font-family: var(--font-mono);
	color: var(--ink-faint);
	letter-spacing: var(--tracking-label);
	margin-bottom: var(--space-lg);
}
.post-meta .read {
	margin-left: auto;
}

.post-title {
	font-family: var(--font-sans);
	font-size: var(--text-display);
	font-weight: 700;
	letter-spacing: var(--tracking-tight);
	line-height: var(--lh-tight);
	color: var(--ink);
	margin-bottom: var(--space-2xl);
}
.post-title-rule {
	height: 1px;
	background: var(--border);
	margin-bottom: var(--space-2xl);
}

.post-hero {
	display: block;
	height: 340px;
	border: var(--border-rule);
	background: var(--panel);
	position: relative;
	margin-bottom: var(--space-2xl);
	border-radius: var(--border-radius);
	text-decoration: none;
	color: inherit;
}
.post-hero img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: inherit;
}
.post-hero .hero-label {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	gap: var(--space-xs);
	font-family: var(--font-mono);
	font-size: var(--text-label);
	color: var(--ink-faint);
	letter-spacing: var(--tracking-kicker);
	text-transform: uppercase;
	pointer-events: none;
}
.post-hero .hero-label .sub {
	color: var(--ink-faint);
	font-size: var(--text-micro);
}

.post-layout {
	display: grid;
	grid-template-columns: minmax(0, var(--content-max)) var(--toc-width);
	gap: 0 var(--space-2xl);
	align-items: start;
}
.post-content {
	min-width: 0;
}

.floating-toc {
	position: sticky;
	top: calc(var(--header-height) + var(--tips-height, 0px) + 8px);
	padding: 0 0 var(--space-md);
	max-height: calc(100vh - var(--header-height) - var(--tips-height, 0px) - 24px);
	display: flex;
	flex-direction: column;
}
.ftoc-label {
	font-family: var(--font-mono);
	font-size: var(--text-label);
	text-transform: uppercase;
	color: var(--ink-faint);
	margin-bottom: var(--space-sm);
	padding-left: calc(2ch + 1px);
	letter-spacing: var(--tracking-kicker);
}
#TableOfContents {
	border-left: var(--space-3xs) solid var(--border);
	overflow-y: auto;
	overscroll-behavior: contain;
	flex: 1;
	min-height: 0;
	letter-spacing: var(--tracking-kicker);
	& a {
		display: block;
		padding-block: var(--space-xs);
		padding-right: 2ch;
		font-family: var(--font-mono);
		font-size: var(--text-label);
		line-height: var(--lh-base);
		color: var(--ink-faint);
		text-decoration: none;
		transition:
			color 0.15s,
			background 0.15s;

		&:hover {
			color: var(--ink-dim);
			background: var(--accent-dim);
			text-decoration: none;
		}
		&.active {
			color: var(--accent);
		}
	}
	& li {
		list-style: none;
	}
	& > ul { padding-left: 0; }
	& > ul > li > a { padding-left: 2ch; }
	& > ul > li > ul > li > a { padding-left: 4ch; }
	& > ul > li > ul > li > ul > li > a { padding-left: 6ch; }
	& > ul > li > ul > li > ul > li > ul > li > a  { padding-left: 8ch; }
	& > ul > li > ul > li > ul > li > ul > li > ul > li > a  { padding-left: 10ch; }

	& ul {
		--indent: 0ch;
		padding-left: 0;
	}

	& ul ul {
		--indent: calc(var(--indent) + 2ch);
	}

	& a {
		padding-left: var(--indent);
	}
}

.post-body img,
.post-body figure,
.post-body iframe,
.post-body video {
	max-width: 100%;
	height: auto;
}
.post-body iframe {
	background: var(--bg);
}

.post-body {
	font-size: var(--text-prose);
	line-height: var(--lh-loose);
	overflow-wrap: break-word;
	text-align: justify;
}
.post-body pre {
	overflow-wrap: normal;
}
.post-body p {
	margin: 0 0 1.4em;
}
.post-body em {
	color: var(--ink);
	font-style: italic;
}
.post-body > h1,
.post-body > h2,
.post-body > h3,
.post-body > h4,
.post-body > h5 {
	font-family: var(--font-mono);
	font-size: var(--text-heading);
	font-weight: 500;
	letter-spacing: var(--tracking-kicker);
	/* text-transform: uppercase; */
	color: var(--accent);
	margin: var(--space-2xl) 0;
	left: 50px;
	display: flex;
	align-items: center;
	gap: 1ch;

	--line-style: 1px dashed var(--border);
}
.post-body > h1::before,
.post-body > h2::before,
.post-body > h3::before,
.post-body > h4::before,
.post-body > h5::before {
	flex-shrink: 0;
	font-family: var(--font-mono);
	font-size: inherit;
	font-weight: inherit;
	color: var(--ink-ghost);
	/* letter-spacing: var(--tracking-kicker); */
}
.post-body > h1::before { content: "#"; }
.post-body > h2::before { content: "##"; }
.post-body > h3::before { content: "###"; }
.post-body > h4::before { content: "####"; }
.post-body > h5::before { content: "#####"; }

.post-body > h1::after,
.post-body > h2::after,
.post-body > h3::after,
.post-body > h4::after,
.post-body > h5::after {
	content: "";
	flex: 1;
	height: 0;
	border-top: var(--line-style);
}
.post-body blockquote {
	margin: 1.8em 0;
	padding: 0 0 0 var(--space-xl);
	border-left: var(--space-2xs) solid var(--border-hi);
	color: var(--ink);
	font-size: var(--text-prose);
	font-style: italic;
	line-height: var(--lh-base);
}
.post-body code {
	font-size: var(--text-label);
}
.post-body pre {
	overflow-x: auto;
}
.post-body pre code {
	background: none;
	border: none;
	padding: 0;
	font-size: inherit;
	color: inherit;
}


.post-body > .highlight {
	border: var(--border-rule);
	border-left: var(--space-2xs) solid var(--accent);
	border-radius: var(--border-radius);
	margin: var(--space-lg) 0;
	overflow: hidden;
}

.post-body > .highlight > .chroma > pre {
	background: var(--pre-bg);
	border: none;
	padding: var(--space-lg) var(--space-md);
	margin: 0;
	font-family: var(--font-mono);
	font-size: var(--text-label);
	line-height: var(--lh-base);
	color: var(--ink);
	overflow-x: auto;
	transition: background 0.2s;
}

.callout {
	--callout-color: var(--warn);
	background: var(--pre-bg);
	border: var(--border-rule);
	border-left: var(--space-2xs) solid var(--callout-color);
	border-radius: var(--border-radius);
	padding: var(--space-md) var(--space-lg);
	margin: var(--space-lg) 0;
	color: var(--ink-dim);
}
.callout--note {
	--callout-color: var(--accent);
}
.callout--info {
	--callout-color: var(--accent);
}
.callout--tip,
.callout--ok,
.callout--success {
	--callout-color: var(--ok);
}
.callout--error,
.callout--danger {
	--callout-color: var(--err);
}
.callout .callout-label {
	display: block;
	font-family: var(--font-mono);
	font-size: 10px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--callout-color);
	margin-bottom: var(--space-2xs);
}
.callout .callout-body > :first-child {
	margin-top: 0;
}
.callout .callout-body > :last-child {
	margin-bottom: 0;
}


/* ── Lists ────────────────────────────────────────────────── */
.post-body ul,
.post-body ol {
	margin: var(--space-md) 0;
	padding-left: 1.5em;
}

.post-body ul {
	list-style: disc;
}
.post-body ul ul { list-style: circle; }
.post-body ul ul ul { list-style: square; }

.post-body ol {
	list-style: decimal;
}

.post-body li {
	margin-bottom: var(--space-xs);
}

.post-body li > ul,
.post-body li > ol {
	margin-top: var(--space-2xs);
}

/* ── Definition lists ────────────────────────────────────── */
.post-body dl {
	margin: var(--space-md) 0;
}
.post-body dt {
	font-family: var(--font-mono);
	font-size: var(--text-label);
	font-weight: 500;
	color: var(--accent);
	margin-top: var(--space-sm);
}
.post-body dt:first-child {
	margin-top: 0;
}
.post-body dd {
	margin: var(--space-3xs) 0 var(--space-3xs) 1.5em;
	color: var(--ink-dim);
}

/* ── Task list checkboxes ────────────────────────────────── */
.post-body ul:has(input[type="checkbox"]) {
	list-style: none;
	padding-left: 0;
}

.post-body ul:has(input[type="checkbox"]) li {
	display: flex;
	align-items: baseline;
	gap: var(--space-xs);
}

.post-body ul:has(input[type="checkbox"]) input[type="checkbox"] {
	margin: 0;
	flex-shrink: 0;
	accent-color: var(--accent);
	appearance: none;
	-webkit-appearance: none;
	width: 14px;
	height: 14px;
	border: 1px solid var(--ink-dim);
	border-radius: 3px;
	background: transparent;
	vertical-align: middle;
	cursor: default;
	position: relative;
	top: -1px;
}

.post-body ul:has(input[type="checkbox"]) input[type="checkbox"]:checked {
	background: var(--accent);
	border-color: var(--accent);
}

/* ── Horizontal rules ────────────────────────────────────── */
.post-body hr {
	border: none;
	border-top: 1px solid var(--border);
	margin: var(--space-2xl) 0;
}

/* ── Tables (Markdown) ──────────────────────────────────────── */
.post-body > table {
	width: 100%;
	border-collapse: collapse;
	font-family: var(--font-mono);
	font-size: var(--text-label);
	line-height: var(--lh-base);
	margin: var(--space-lg) 0;
	max-width: 100%;
}

.post-body > table thead {
	background: var(--panel);
	border-bottom: 2px solid var(--border);
}
.post-body > table th,
.post-body > table td {
	padding: var(--space-xs) var(--space-sm);
	border: 1px solid var(--border);
	text-align: left;
	vertical-align: top;
	white-space: nowrap;
}
.post-body > table th {
	color: var(--ink);
	font-weight: 600;
}
.post-body > table td {
	color: var(--ink-dim);
}
.post-body > table tbody tr:nth-child(even) {
	background: var(--bg-alt);
}
.post-body > table.table-fit {
	width: auto;
}
.post-body > table.table-center {
	margin-left: auto;
	margin-right: auto;
}
.post-body > table.table-right {
	margin-left: auto;
	margin-right: 0;
}
.post-body > table th[style*="center"],
.post-body > table td[style*="center"] {
	text-align: center;
}
.post-body > table th[style*="right"],
.post-body > table td[style*="right"] {
	text-align: right;
}

/* ── Figures ──────────────────────────────────────────────── */
.post-body figure {
	border-top: none;
	border-radius: 0 0 var(--border-radius) var(--border-radius);
	padding: 0;
	margin: var(--space-lg) 0;
}
.post-body figure img {
	display: block;
	margin: 0;
	max-width: 100%;
	height: auto;
}
.post-body a[href^="#al-frame-"] img {
	cursor: zoom-in;
}
.post-body figcaption {
	background: var(--panel);
	border: var(--border-rule);
	border-top: none;
	font-size: var(--text-label);
	line-height: var(--lh-base);
	color: var(--ink-dim);
	padding: var(--space-xs) var(--space-sm);
	padding-top: 0;
	text-align: center;
}

/* ── Floats ────────────────────────────────────────────────── */
.post-body {
	& .float-left {
		float: left;
		margin-left: 0;
		margin-right: var(--space-lg);
		margin-bottom: var(--space-sm);
		max-width: 33%;
		margin-top: var(--space-sm);

	}
	& .float-right {
		float: right;
		margin-right: 0;
		margin-left: var(--space-lg);
		margin-bottom: var(--space-sm);
		max-width: 33%;
		margin-top: var(--space-sm);
	}
	& blockquote.float-left,
	& blockquote.float-right {
		margin-top: var(--space-3xs);
	}
}

.post-body .float-clear {
	clear: both;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1040px) {
	.post-layout {
		grid-template-columns: 1fr;
	}
	.floating-toc {
		display: none;
	}
}

/* dyslexia */
.dyslexia-toggle {
	padding: 0 0 var(--space-sm) 0;
	border-bottom: 1px solid var(--border);
	margin-bottom: var(--space-sm);
}
.dt-label {
	display: flex;
	align-items: center;
	gap: var(--space-xs);
	cursor: pointer;
	user-select: none;
}
.dt-checkbox {
	appearance: none;
	-webkit-appearance: none;
	width: 28px;
	height: 14px;
	border-radius: 7px;
	background: var(--panel-hi);
	border: 1px solid var(--border);
	cursor: pointer;
	position: relative;
	flex-shrink: 0;
	transition: background 0.15s, border-color 0.15s;
}
.dt-checkbox::after {
	content: "";
	position: absolute;
	inset: 1px auto 1px 1px;
	width: 10px;
	border-radius: 5px;
	background: var(--ink-faint);
	transition: left 0.15s, background 0.15s;
}
.dt-checkbox:checked {
	background: var(--accent-dim);
	border-color: var(--accent);
}
.dt-checkbox:checked::after {
	left: calc(100% - 11px);
	background: var(--accent);
}
.dt-text {
	font-family: var(--font-mono);
	/* font-size: var(--text-micro); */
	letter-spacing: var(--tracking-kicker);
	text-transform: uppercase;
	color: var(--ink-faint);
}

/* ── Article lightbox (ports projects lightbox) ──────────────── */
.article-lightbox {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 200;
}
.article-lightbox:target,
.article-lightbox:has(.gallery-frame:target) {
	display: block;
}
.lightbox-bg {
	position: absolute;
	inset: 0;
	z-index: 0;
	background: color-mix(in oklab, var(--bg) 85%, transparent);
	cursor: zoom-out;
}
.lightbox-strip {
	position: relative;
	z-index: 1;
	display: flex;
	overflow-x: auto;
	scroll-behavior: smooth;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	height: 100%;
	align-items: center;
	gap: 10vw;
	pointer-events: none;
}
.lightbox-strip a,
.lightbox-strip button {
	pointer-events: auto;
}
.lightbox-strip::-webkit-scrollbar {
	display: none;
}
.lightbox-strip .strip-pad {
	flex-shrink: 0;
	width: 50vw;
	height: 1px;
}
.gallery-frame {
	flex-shrink: 0;
	width: 75vw;
	height: 90vh;
	display: flex;
	align-items: center;
	justify-content: center;
	scroll-snap-align: center;
	position: relative;
	overflow: hidden;
	touch-action: pinch-zoom;
}
.gallery-frame img {
	max-height: 90vh;
	max-width: 100%;
	object-fit: contain;
	pointer-events: auto;
	touch-action: pinch-zoom;
}

/* Alt text box: clamped to 1 line, expands on click */
.gallery-alt-box {
	position: absolute;
	bottom: calc(var(--space-3xl) * 2 + var(--space-xl));
	left: 50%;
	transform: translateX(-50%);
	z-index: 90;
	width: 66%;
	max-width: 500px;
	background: rgba(0, 0, 0, 0.65);
	color: #e0e0e0;
	padding: var(--space-sm) var(--space-lg);
	border-radius: var(--space-sm);
	font-family: var(--font-sans);
	font-size: var(--text-label);
	line-height: 1.6;
	cursor: pointer;
	pointer-events: auto;
	user-select: none;
	transition: background 0.15s;
	display: flex;
	align-items: center;
	gap: 6px;
}
.gallery-alt-box::after {
	content: "\f106";
	font-family: var(--font-nerd);
	margin-left: auto;
	font-size: 1.8rem;
	line-height: 1;
	opacity: 0.6;
	transition: transform 0.2s;
	flex-shrink: 0;
	pointer-events: none;
}
.alt-toggle:checked ~ .gallery-alt-box::after {
	transform: rotate(180deg);
	align-self: flex-start;
	margin-top: var(--space-2xs);
}
.gallery-alt-text {
	display: -webkit-box;
	-webkit-line-clamp: 1;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.alt-toggle:checked ~ .gallery-alt-box .gallery-alt-text {
	-webkit-line-clamp: unset;
	overflow: visible;
}
.alt-toggle:checked ~ .gallery-alt-box {
	background: rgba(0, 0, 0, 0.8);
}

/* Prev/next zones */
.gallery-nav {
	position: fixed;
	top: 50%;
	transform: translateY(-50%);
	width: 10vw;
	min-width: 64px;
	height: 10vw;
	min-height: 64px;
	display: none;
	align-items: center;
	justify-content: center;
	font-size: 3rem;
	color: var(--ink-dim);
	background: none;
	border: none;
	text-decoration: none;
	z-index: 101;
	cursor: pointer;
	transition: color 0.15s, background 0.15s;
}
.gallery-frame:target .gallery-nav,
.article-lightbox:target .gallery-frame:first-of-type .gallery-nav,
.gallery-frame.js-current .gallery-nav {
	display: flex;
}
.gallery-nav.prev { left: 0; }
.gallery-nav.next { right: 0; }
.gallery-nav:hover {
	color: var(--ink);
	background: color-mix(in oklab, var(--bg) 94%, transparent);
}

/* Bottom thumbnail nav strip */
html.lb-open { overflow: hidden; }

.lightbox-nav {
	position: fixed;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 110;
	display: flex;
	gap: 8px;
	padding: 8px 12px;
	background: rgba(0, 0, 0, 0.5);
	border-radius: 10px;
	pointer-events: auto;
	max-width: 90vw;
	overflow-x: auto;
	scrollbar-width: none;
}
.lightbox-nav::-webkit-scrollbar {
	display: none;
}
.lightbox-nav a {
	display: block;
	width: clamp(56px, 10vw, 100px);
	height: clamp(38px, 6.5vw, 65px);
	border-radius: 4px;
	overflow: hidden;
	border: 2px solid transparent;
	opacity: 0.5;
	transition: border-color 0.15s, opacity 0.15s;
}
.lightbox-nav a:hover {
	opacity: 1;
}
.lightbox-nav a.active {
	border-color: var(--accent);
	opacity: 1;
}
.lightbox-nav img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* ── Alt text badge ──────────────────────────────────────────── */
.img-alt-wrap {
	display: inline-block;
	position: relative;
	max-width: 100%;
	line-height: 0;
	vertical-align: top;
}
.img-alt-wrap > img {
	display: block;
}
.img-alt-badge {
	position: absolute;
	inset: auto 4px 4px auto;
	background: color-mix(in oklab, black 65%, transparent);
	color: var(--color-text-light);
	font-family: var(--font-mono);
	font-size: 10px;
	line-height: 1;
	padding: 2px 5px;
	border-radius: 2px;
	pointer-events: none;
	user-select: none;
	transition: opacity 0.15s;
}
.img-alt-text {
	position: absolute;
	top: calc(100% + var(--space-xs));
	right: 0;
	background: color-mix(in oklab, black 65%, transparent);
	color: var(--color-text-light);
	font-family: var(--font-sans);
	font-size: var(--text-label);
	line-height: var(--lh-base);
	padding: var(--space-xs) var(--space-sm);
	border-radius: var(--border-radius);
	max-width: 100%;
	white-space: normal;
	pointer-events: none;
	user-select: none;
	opacity: 0;
	transition: opacity 0.15s;
	z-index: 5;
	text-align: left;
}
.img-alt-wrap:hover .img-alt-text,
.post-hero:hover .img-alt-text {
	opacity: 1;
}
