:root {
	--ck-color-image-caption-background: #ccc;
}

.page-header {
	max-height: 3.5rem;
}

p + ol,
p + ul {
	margin: -1.5rem 0 1rem 2rem;
}

img.scale1p5 {
	transform: scale(1.5);
}

.post-content pre {
	margin-bottom: 1rem;
	font-size: 16px;
	overflow: auto;
	position: relative;
    white-space: pre;
}

@keyframes fadeInHoldFadeOut {
	0% {
		opacity: 0;
	}
	20% {
		opacity: 1;
	}
	80% {
		opacity: 1;
	}
	90% {
		opacity: 0;
	}
	100% {
		opacity: 0;
	}
}

@keyframes fadeOut {
	0% {
		opacity: 0.5;
	}
	80% {
		opacity: 0;
	}
	100% {
		opacity: 0;
	}
}

.post-content pre[data-language]::before {
	content: attr(data-language);
    position: absolute;
	display: block;
    background: #aaa;
    color: #000;
    top: -1px;
    right: 0px;
    padding: 5px 10px;
    font-size: 10px;
	animation: fadeOut .7s forwards;
}

.post-content pre[data-language]:hover::before {
	animation: fadeInHoldFadeOut 3s forwards;
}

.post-content h3 {
	font-size: 1.3rem;
	margin: 3rem 0 1rem;
}

.post-content video {
	max-width: 100%;
	min-width: 100%;
	display: block;
	height: auto;
	margin: 0 auto;
}


/* =========================================
   Table of Contents Navigation
   ========================================= */

.toc-navigation {
	position: sticky;
	top: 100px;
	max-height: calc(100vh - 140px);
	overflow-y: auto;
	padding: 1.5rem;
	background: var(--card-bg, #ffffff);
	border: 1px solid var(--border-color, #e5e7eb);
	border-radius: 12px;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
	scrollbar-width: thin;
	scrollbar-color: var(--primary-color, #7c3aed) transparent;
}

.toc-navigation::-webkit-scrollbar {
	width: 4px;
}

.toc-navigation::-webkit-scrollbar-track {
	background: transparent;
}

.toc-navigation::-webkit-scrollbar-thumb {
	background: var(--primary-color, #7c3aed);
	border-radius: 4px;
}

/* TOC Title */
.toc-title {
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	color: var(--text-muted, #6b7280);
	margin-bottom: 1rem;
	padding-bottom: 0.75rem;
	border-bottom: 1px solid var(--border-color, #e5e7eb);
}

/* TOC List */
.toc-list {
	list-style: none;
	padding: 0;
	margin: 0;
}

/* TOC Items */
.toc-item {
	position: relative;
	margin: 0;
	padding: 0;
}

/* TOC Links */
.toc-link {
	display: block;
	padding: 0.5rem 0.75rem 0.5rem 1rem;
	font-size: 0.875rem;
	line-height: 1.5;
	color: var(--text-secondary, #4b5563);
	text-decoration: none;
	border-radius: 0 6px 6px 0;
	transition: all 0.2s ease;
	word-break: break-word;
}

.toc-link:hover {
	color: var(--primary-color, #7c3aed);
	background: var(--hover-bg, #7c3aed14);
}

.toc-link.toc-active {
	color: var(--primary-color, #7c3aed);
	font-weight: 600;
	background: var(--active-bg, #7c3aed1f);
}

/* Indentation levels */
.toc-level-1 .toc-link {
	font-weight: 600;
	font-size: 0.9375rem;
	padding-left: 1rem;
}

.toc-level-2 .toc-link {
	padding-left: 1.5rem;
}

.toc-level-3 .toc-link {
	padding-left: 2rem;
	font-size: 0.8125rem;
}

.toc-level-4 .toc-link {
	padding-left: 2.5rem;
	font-size: 0.8125rem;
	color: var(--text-muted, #6b7280);
}

/* Empty state */
.toc-empty {
	font-size: 0.875rem;
	color: var(--text-muted, #6b7280);
	text-align: center;
	padding: 1rem;
}

/* Progress indicator (optional enhancement) */
.toc-navigation.with-progress::after {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	width: 3px;
	height: var(--scroll-progress, 0%);
	background: linear-gradient(to bottom, var(--primary-color, #7c3aed), var(--secondary-color, #a78bfa));
	border-radius: 3px;
	transition: height 0.1s linear;
}

.toc-sidebar {
	display: block;
	position: fixed;
	top: 120px;
	left: 0;
	gap: 2rem;
	max-width: 1400px;
	margin: 0 auto;
	padding: 2rem;
	background: var(--card-bg);
}

/* Large screens */
@media (min-width: 1200px) {
	.toc-sidebar {
		gap: 3rem;
	}
}

/* Medium screens - TOC moves to collapsible */
@media (max-width: 1024px) {
	/* Mobile TOC toggle button */
	.toc-mobile-toggle {
		display: flex;
		align-items: center;
		justify-content: space-between;
		position: fixed;
		bottom: 1.5rem;
		right: 1.5rem;
		z-index: 40;
		padding: 0.75rem 1.25rem;
		background: var(--primary-color, #7c3aed);
		color: white;
		border: none;
		border-radius: 50px;
		font-size: 0.875rem;
		font-weight: 600;
		cursor: pointer;
		box-shadow: 0 4px 15px #7c3aed66;
		transition: all 0.3s ease;
	}

	.toc-mobile-toggle:hover {
		transform: translateY(-2px);
		box-shadow: 0 6px 20px #7c3aed80;
	}

	.toc-mobile-toggle svg {
		width: 18px;
		height: 18px;
		margin-right: 0.5rem;
	}

	/* Mobile TOC panel */
	.toc-mobile-panel {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		z-index: 41;
		max-height: 60vh;
		background: var(--card-bg, #ffffff);
		border-radius: 20px 20px 0 0;
		box-shadow: 0 -4px 30px #00000026;
		transform: translateY(100%);
		transition: transform 0.3s ease;
		overflow: hidden;
	}

	.toc-mobile-panel.is-open {
		transform: translateY(0);
	}

	.toc-mobile-panel .toc-navigation {
		position: relative;
		top: 0;
		max-height: calc(60vh - 60px);
		border: none;
		border-radius: 0;
		box-shadow: none;
	}

	.toc-mobile-header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 1rem 1.5rem;
		border-bottom: 1px solid var(--border-color, #e5e7eb);
	}

	.toc-mobile-header h3 {
		margin: 0;
		font-size: 1rem;
		font-weight: 700;
		text-transform: uppercase;
		letter-spacing: 0.1em;
		color: var(--text-muted, #6b7280);
	}

	.toc-mobile-close {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 32px;
		height: 32px;
		background: var(--hover-bg, #f3f4f6);
		border: none;
		border-radius: 50%;
		cursor: pointer;
		transition: background 0.2s ease;
	}

	.toc-mobile-close:hover {
		background: var(--border-color, #e5e7eb);
	}

	/* Backdrop */
	.toc-backdrop {
		position: fixed;
		inset: 0;
		z-index: 39;
		background: #00000080;
		opacity: 0;
		visibility: hidden;
		transition: all 0.3s ease;
	}

	.toc-backdrop.is-visible {
		opacity: 1;
		visibility: visible;
	}
}

/* Small screens */
@media (max-width: 640px) {
	.toc-mobile-toggle {
		bottom: 1rem;
		right: 1rem;
		padding: 0.625rem 1rem;
		font-size: 0.8125rem;
	}

	.toc-mobile-panel {
		max-height: 70vh;
	}

	.toc-mobile-panel .toc-navigation {
		padding: 1rem;
	}

	.toc-link {
		padding: 0.625rem 0.75rem 0.625rem 1rem;
		font-size: 0.9375rem;
	}

	.toc-level-2 .toc-link {
		padding-left: 1.25rem;
	}

	.toc-level-3 .toc-link,
	.toc-level-4 .toc-link {
		padding-left: 1.5rem;
		font-size: 0.875rem;
	}
}

/* =========================================
   Dark Mode Support
   ========================================= */

@media (prefers-color-scheme: dark) {
	.toc-navigation {
		--card-bg: #1f2937;
		--border-color: #374151;
		--text-secondary: #d1d5db;
		--text-muted: #9ca3af;
		--hover-bg: #7c3aed26;
		--active-bg: #7c3aed33;
	}

	.toc-mobile-panel {
		--card-bg: #1f2937;
		--border-color: #374151;
	}
}

/* Manual dark mode class */
.dark .toc-navigation,
[data-theme='dark'] .toc-navigation {
	--card-bg: #1f2937;
	--border-color: #374151;
	--text-secondary: #d1d5db;
	--text-muted: #9ca3af;
	--hover-bg: #7c3aed26;
	--active-bg: #7c3aed33;
}

/* Smooth scroll behavior for the whole page */
html {
	scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}

	.toc-link,
	.toc-item::before,
	.toc-mobile-panel,
	.toc-backdrop {
		transition: none;
	}
}

/* the following ToC code based on: https://gist.github.com/kjk/d9343c3f45d9f529b2b8156048254840 */
.toc-wrapper {
	position: fixed;
	top: calc(50% + 50px);
	left: 0.5rem;
	z-index: 40;
	max-height: calc(100vh - 2rem);
	overflow-y: auto;
	transform: translateY(-50%);
}

.toc-wrapper::-webkit-scrollbar {
	width: 6px;
}

.toc-wrapper::-webkit-scrollbar-thumb {
	background-color: #d3d3d3;
	border-radius: 8px;
}

.toc-wrapper::-webkit-scrollbar-track {
	background-color: #fafafa;
}

.toc-mini {
	display: flex;
	flex-direction: column;
	cursor: pointer;
}

.toc-item-mini {
	width: 1rem;
	height: 4px;
	margin: 4px 0;
	background: lightgrey;
}

.toc-item-mini.toc-active {
	width: 1.75rem;
	background: #97c9f4;
}

.toc-list {
	display: none;
	flex-direction: column;
	font-size: 10pt;
	padding: 12px 8px;
	background-color: #fff;
	box-shadow: #0f0f0f0a 0px 0px 0px 1px, #0f0f0f08 0px 3px 6px, #0f0f0f0f 0px 9px 24px;
	border: 1px solid #37352f42;
	border-radius: 8px;
}

.toc-trunc {
	max-width: 32ch;
	min-width: 12ch;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.toc-wrapper:hover > .toc-mini {
	display: none;
}

.toc-wrapper:hover > .toc-list {
	display: flex;
}

.toc-item {
	cursor: pointer;
}

.toc-item:hover {
	background-color: #f6f6f6;
}

.toc-bold {
	font-weight: bold;
	color: #0d82fd;
}

.toc-active {
	background: #05385a;
}

.toc-ind-1 {
	padding-left: 1rem;
}

.toc-ind-2 {
	padding-left: 2rem;
}

.toc-ind-3 {
	padding-left: 3rem;
}

.toc-ind-4 {
	padding-left: 4rem;
}

.toc-ind-5 {
	padding-left: 5rem;
}

.toc-ind-6 {
	padding-left: 6rem;
}

.toc-item-mini.ind-1 {
	margin-left: .5rem;
}

.toc-item-mini.ind-2 {
	margin-left: 1rem;
}

.toc-item-mini.ind-3 {
	margin-left: 1.5rem;
}

.toc-item-mini.ind-4 {
	margin-left: 2rem;
}

.toc-item-mini.ind-5 {
	margin-left: 2.5rem;
}

.toc-item-mini.ind-6 {
	margin-left: 3rem;
}

/* Large screens */
@media (min-width: 1200px) {
	.post-content pre {
		font-size: 16px;
	}
}

/* Medium screens - TOC moves to collapsible */
@media (max-width: 1024px) {
	.post-content pre {
		font-size: 14px;
	}

	.toc-wrapper > .toc-mini {
		display: flex;
		height: 20px;
		width: 20px;
		max-width: 20px;
		border: 10px solid transparent;
		border-left: 10px solid #0d82fd;
	}

	.toc-wrapper:hover > .toc-list {
		display: flex;
	}
}

/* Small screens */
@media (max-width: 640px) {
	.post-content pre {
		font-size: 14px;
	}

	.toc-wrapper > .toc-mini {
		display: none;
	}

	.toc-wrapper > .toc-list {
		display: none;
	}
}