/* ATELIER UDIT – minimal prose + layout */
:root {
	/* Layout scale */
	--max: clamp(66ch, 2.5vw + 78ch, 104ch); /* Harmonic readable measure for prose (wider) */

	--background: hsla(213, 100%, 18%, 0.9999); /* #00295E */
	--foreground: hsla(60, 60%, 49%, 0.9999); /* #C9C932 */

	/* Text colors tuned for WCAG AA on white background */
	--text-primary: #0f172a; /* slate-900 – ~13.6:1 on #fff */
	--text-secondary: #334155; /* slate-700 – ~7.3:1 on #fff */
	--muted: #64748b; /* slate-500 – subtle, still readable for metadata */

	/* Brand/action colors with strong contrast on white */
	--primary: #1d4ed8; /* blue-700 – links/buttons, ~6.5:1 on #fff */
	--primary-hover: #1e40af; /* blue-800 – hover/focus, ~8.6:1 on #fff */
	--accent: #0f172a; /* neutral accent for headings/logos */

	/* Surfaces and borders */
	--bg: #ffffff; /* base page background */
	--bg-light: #f8fafc; /* slate-50 – cards/alternating sections */
	--border-light: #e2e8f0; /* slate-200 – separators with clear edges */

	/* Code-specific surfaces (used by code styles below) */
	--code-inline-bg: #eef2ff; /* indigo-50 – subtle inline highlight */
	--code-inline-border: #c7d2fe; /* indigo-200 – defines inline code */
	--code-block-bg: #0a0f1f; /* deep navy – high-contrast code blocks */
	--code-block-border: #1f2937; /* slate-800 – clear block outline */
	--code-block-fg: #e5e7eb; /* light text for dark code blocks */

	/* Links and focus */
	--link: #9373dd;
	--link-visited: #7a4dea; /* indigo-700 – distinct visited state */
	--focus-outline: #93c5fd; /* indigo-300 – visible focus */
	--link-inverse: #e2b127; /* inverse of --link for accents */
	--link-visited-inverse: rgb(81, 63, 15); /* inverse of --link-visited for accents */
	--link-on-dark: #93c5fd; /* light link color on dark code blocks */

	/* Contrasting foregrounds for colored surfaces */
	--on-primary: #ffffff; /* text/icon color on primary surfaces */
	--hero-fg: #ffffff; /* hero text */

	/* UI accents */
	--border-hover: #cbd5e0; /* slate-300 – hover emphasis */
	--shadow-color: rgba(17, 24, 39, 0.15); /* slate-900 @15% for soft elevation */
	--scroll-thumb: #334155; /* slate-700 */
	--scroll-track: var(--code-block-bg);

	/* ===== RESPONSIVE TYPOGRAPHY ===== */
	--text-2xs: clamp(0.25rem, 0.3vw + 0.15em, 0.5rem);
	--text-xs: clamp(0.375rem, 0.4vw + 0.2em, 0.625rem);
	--text-sm: clamp(0.5rem, 0.5vw + 0.25em, 0.75rem);
	--text-base: clamp(0.625rem, 0.6vw + 0.3em, 0.875rem);
	--text-lg: clamp(0.75rem, 0.8vw + 0.4em, 1rem);
	--text-xl: clamp(0.875rem, 1vw + 0.5em, 1.2rem);
	--text-2xl: clamp(1rem, 1.5vw + 0.8em, 1.5rem);
	--text-3xl: clamp(1.125rem, 2vw + 1em, 2rem);

	/* ===== LINE HEIGHTS ===== */
	--line-height-2xs: clamp(0.5rem, 0.3vw + 0.5em, 0.625rem);
	--line-height-xs: clamp(0.625rem, 0.4vw + 0.6em, 0.75rem);
	--line-height-sm: clamp(0.75rem, 0.5vw + 0.75em, 0.875rem);
	--line-height-base: clamp(0.875rem, 0.6vw + 0.85em, 1rem);
	--line-height-lg: clamp(1rem, 0.8vw + 1em, 1.2rem);
	--line-height-xl: clamp(1.1rem, 1vw + 1.1em, 1.3rem);
	--line-height-2xl: clamp(1.2rem, 1.2vw + 1.3em, 1.5rem);
	--line-height-3xl: clamp(1.3rem, 1.5vw + 1.4em, 1.7rem);

	/* ===== SEMANTIC TYPE TOKENS ===== */
	--font-body-size: var(--text-base);
	--font-body-line: var(--line-height-base);

	--font-h1-size: var(--text-3xl);
	--font-h1-line: var(--line-height-3xl);
	--font-h2-size: var(--text-2xl);
	--font-h2-line: var(--line-height-2xl);
	--font-h3-size: var(--text-xl);
	--font-h3-line: var(--line-height-xl);
	--font-h4-size: var(--text-lg);
	--font-h4-line: var(--line-height-lg);

	--font-lead-size: var(--text-xl);
	--font-lead-line: var(--line-height-xl);

	--font-code-block-size: var(--text-base);
	--font-code-block-line: var(--line-height-base);

	--font-hero-title-size: clamp(2.5rem, 5vw, 4rem);
	--font-hero-title-line: 1.2;
	--font-hero-subtitle-size: clamp(1.1rem, 2.5vw, 1.5rem);
	--font-hero-subtitle-line: 1.3;
	--font-hero-tagline-size: clamp(1rem, 2vw, 1.25rem);
	--font-hero-tagline-line: 1.3;

	--font-section-title-size: var(--text-3xl);
	--font-section-title-line: var(--line-height-3xl);
	--font-card-title-size: 1.5rem;
	--font-card-title-line: 1.3;
	--font-resource-title-size: 1.25rem;
	--font-resource-title-line: 1.3;

	--font-flag-size: 2rem;
	--font-method-icon-size: 3rem;
	--font-resource-icon-size: 2.5rem;
}

/* Dark mode CSS variables */
html.dark,
.dark {
	/* Dark mode text colors */
	--text-primary: #f5f5f5;
	--text-secondary: #d4d4d4;
	--muted: #a3a3a3;

	/* Dark mode surfaces */
	--bg: #0a0a0a;
	--bg-light: #171717;
	--border-light: #262626;

	/* Dark mode code surfaces */
	--code-inline-bg: #262626;
	--code-inline-border: #404040;

	/* Dark mode borders */
	--border-hover: #404040;
	--shadow-color: rgba(0, 0, 0, 0.5);
}

* {
	box-sizing: border-box;
}
html {
	-webkit-text-size-adjust: 100%;
}
body {
	margin: 0;
	font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica Neue, Arial,
		'Apple Color Emoji', 'Segoe UI Emoji';
	font-size: var(--font-body-size);
	line-height: var(--font-body-line);
	color: var(--text-primary);
	background: var(--background);
	text-rendering: optimizeLegibility;
	-webkit-font-smoothing: antialiased;
	font-variant-numeric: oldstyle-nums proportional-nums;
}

h1 {
	text-box-trim: both;
	text-box-align: center;
}

/* Footer logo fits container */
img.footer-logo {
	display: block;
	max-width: 100%;
	height: auto;
	margin: 0;
	padding-bottom: 15px;
}

.container {
	background: var(--bg-light);
	max-width: var(--max);
	margin: 0 auto;
	padding: 2rem 1rem;
}
.site-header,
.site-footer {
	background: var(--background);
	padding: 0.75rem 1rem;
	border-bottom: 1px solid var(--border-light);
}
.site-footer {
	border-top: 1px solid var(--border-light);
	border-bottom: 0;
	color: var(--muted);
}

.brand {
	text-decoration: none;
	font-weight: 700;
	color: var(--accent);
	margin-right: 1rem;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.brand-logo {
	width: 2rem;
	height: 2rem;
	flex-shrink: 0;
	display: block;
}

.site-header nav a {
	margin-right: 0.75rem;
	color: var(--link);
	text-decoration: none;
}
.site-header nav a:hover {
	text-decoration: underline;
}
.site-header nav a:focus-visible {
	outline: 3px solid var(--focus-outline);
	outline-offset: 2px;
}

.prose h1 {
	font-size: var(--font-h1-size);
	line-height: var(--font-h1-line);
	margin: 1.5rem 0 0.75rem;
}
.prose h2 {
	font-size: var(--font-h2-size);
	line-height: var(--font-h2-line);
	margin: 1.25rem 0 0.5rem;
}
.prose h3 {
	font-size: var(--font-h3-size);
	line-height: var(--font-h3-line);
	margin: 1.25rem 0 0.5rem;
}
.prose h4 {
	font-size: var(--font-h4-size);
	line-height: var(--font-h4-line);
	margin: 1.25rem 0 0.5rem;
}
.prose h5 {
	font-size: var(--font-h5-size);
	line-height: var(--font-h5-line);
	margin: 1.25rem 0 0.5rem;
}
.prose h6 {
	font-size: var(--font-h6-size);
	line-height: var(--font-h6-line);
	margin: 1.25rem 0 0.5rem;
}
.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
	padding-block: 0.35rem;
}

/* ========================================
   Heading shades (scan-friendly hierarchy)
   ======================================== */
/* Subtle “shaded” bands to make sections easier to follow.
   - H2 strongest (section)
   - H3 medium (subsection)
   - H4 light (detail)
*/

:root {
	--heading-shade-h2: color-mix(in oklab, var(--primary), white 88%);
	--heading-shade-h3: color-mix(in oklab, var(--primary), white 93%);
	--heading-shade-h4: color-mix(in oklab, var(--primary), white 96%);
}

html.dark,
.dark {
	--heading-shade-h2: color-mix(in oklab, var(--primary), black 78%);
	--heading-shade-h3: color-mix(in oklab, var(--primary), black 84%);
	--heading-shade-h4: color-mix(in oklab, var(--primary), black 88%);
}

.prose :where(h2, h3, h4) {
	border-radius: 0.5rem;
	padding-inline: 0.75rem;
}

.prose h2 {
	background: linear-gradient(90deg, var(--heading-shade-h2) 0%, transparent 70%);
	border-left: 6px solid color-mix(in oklab, var(--primary), white 25%);
}

.prose h3 {
	background: linear-gradient(90deg, var(--heading-shade-h3) 0%, transparent 72%);
	border-left: 4px solid color-mix(in oklab, var(--primary), white 40%);
}

.prose h4 {
	background: linear-gradient(90deg, var(--heading-shade-h4) 0%, transparent 75%);
	border-left: 3px solid color-mix(in oklab, var(--primary), white 55%);
}

@media print {
	.prose h2,
	.prose h3,
	.prose h4 {
		background: none !important;
		border-left: 0 !important;
		padding-inline: 0 !important;
	}
}
.prose p {
	margin: 0.75rem 0;
}
.prose a {
	text-decoration: underline;
	text-decoration-color: currentColor;
	text-underline-offset: 2px;
	color: var(--link) !important;
}
.prose a:hover {
	color: var(--primary-hover);
	text-decoration-thickness: 2px;
}
.prose a:visited {
	color: var(--link-visited-inverse);
}
.prose a:focus-visible {
	outline: 3px solid var(--focus-outline);
	outline-offset: 2px;
}
.prose code {
	padding: none !important;
	border-radius: 0.25rem;
	border: 1px solid var(--code-inline-border);
}
.prose pre {
	position: relative;
	background: var(--code-block-bg);
	color: var(--code-block-fg);
	padding: 1rem;
	border-radius: 0.5rem;
	border: 1px solid var(--code-block-border);
	overflow: auto;
}

.prose pre a {
	color: var(--link-on-dark);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.prose pre code {
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
	font-size: var(--font-code-block-size);
	line-height: var(--font-code-block-line) !important;
	border: 0;
}
.prose pre::-webkit-scrollbar {
	height: 10px;
}
.prose pre::-webkit-scrollbar-thumb {
	background: var(--scroll-thumb);
	border-radius: 8px;
}
.prose pre::-webkit-scrollbar-track {
	background: var(--scroll-track);
}

/* Copy code button */
.copy-code-btn {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	padding: 0.5rem;
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 0.25rem;
	color: var(--code-block-fg);
	cursor: pointer;
	opacity: 0;
	transition: opacity 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.prose pre:hover .copy-code-btn,
.prose pre:focus-within .copy-code-btn,
.copy-code-btn.copied {
	opacity: 1;
}

.copy-code-btn:hover {
	background: rgba(255, 255, 255, 0.2);
	border-color: rgba(255, 255, 255, 0.3);
}

.copy-code-btn:active {
	background: rgba(255, 255, 255, 0.15);
}

.copy-code-btn:focus-visible {
	outline: 2px solid var(--code-block-fg);
	outline-offset: 2px;
}

.copy-code-btn svg {
	display: block;
}

.prose ul,
.prose ol {
	padding-left: 1.25rem;
}
.prose table {
	display: block; /* intrinsic: allow horizontal scrolling if needed */
	inline-size: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border: 1px solid var(--border-light);
	border-radius: 8px;
	background: var(--bg);
	margin: 1rem 0;
}
.prose table thead th {
	position: sticky;
	top: 0;
	background: var(--bg-light);
	color: var(--text-primary);
}
.prose table th,
.prose table td {
	padding: 0.5rem 0.75rem;
	text-align: left;
	vertical-align: top;
	border-bottom: 1px solid var(--border-light);
	word-break: break-word;
}
.prose table th {
	font-weight: 700;
}
.prose table tbody tr:nth-child(even) {
	background: var(--bg-light);
}
.muted {
	color: var(--muted);
}
.showroom {
	list-style: none;
	padding: 0;
	margin: 1rem 0;
	display: grid;
	gap: 0.75rem;
}
.showroom .card {
	padding: 0.75rem 1rem;
	border: 1px solid #e5e7eb;
	border-radius: 0.5rem;
}

/* ========================================
   HOMEPAGE SPECIFIC STYLES
   ======================================== */

/* Hero Section */
.hero-section {
	background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
	color: var(--hero-fg);
	padding: 4rem 2rem;
	text-align: center;
	margin-bottom: 3rem;
}

@media (max-width: 768px) {
	.hero-section {
		padding: 3rem 1.5rem;
	}
}

@media (min-width: 769px) {
	.hero-section {
		padding: 5rem 3rem;
	}
}

@media (min-width: 1024px) {
	.hero-section {
		padding: 6rem 4rem;
	}
}

.hero-title {
	font-size: var(--font-hero-title-size);
	font-weight: 700;
	margin-bottom: 1rem;
	line-height: var(--font-hero-title-line);
}

.hero-title .brand {
	display: block;
	font-weight: 800;
	color: inherit;
}

.hero-title .institution {
	font-size: var(--text-sm);
	opacity: 0.9;
}

.hero-subtitle {
	font-size: var(--font-hero-subtitle-size);
	margin-bottom: 0.5rem;
	opacity: 0.95;
	line-height: var(--font-hero-subtitle-line);
}

.hero-tagline {
	font-size: var(--font-hero-tagline-size);
	opacity: 0.9;
	margin-bottom: 2rem;
	line-height: var(--font-hero-tagline-line);
}

.lead {
	font-size: var(--font-lead-size);
	line-height: var(--font-lead-line);
	max-width: 800px;
	margin: 0 auto;
	opacity: 0.95;
}

/* Main Content Layout */
.content-main {
	max-width: 1200px;
	margin: 0 auto;
	padding: 0 1rem;
}

.section-title {
	font-size: var(--font-section-title-size);
	line-height: var(--font-section-title-line);
	font-weight: 600;
	margin-bottom: 2rem;
	text-align: center;
	color: var(--text-primary);
}

/* Lessons Section */
.lessons-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	gap: 2rem;
	margin-bottom: 4rem;
}

.lesson-card,
.method-item {
	background: var(--bg-light);
	border: 2px solid var(--border-light);
	border-radius: 12px;
	padding: 2rem;
	text-align: center;
	transition: all 0.3s ease;
}

.lesson-card:hover,
.method-item:hover {
	border-color: var(--primary);
	transform: translateY(-4px);
	box-shadow: 0 10px 25px var(--shadow-color);
}

.flag {
	font-size: var(--font-flag-size);
	margin-right: 0.5rem;
}

.card-title {
	font-size: var(--font-card-title-size);
	font-weight: 600;
	margin-bottom: 1rem;
	color: var(--text-primary);
}

.card-description {
	color: var(--text-secondary);
	margin-bottom: 1.5rem;
	line-height: var(--font-body-line);
}

/* Button Styles */
.btn {
	display: inline-block;
	padding: 0.75rem 1.5rem;
	border-radius: 8px;
	text-decoration: none;
	font-weight: 600;
	transition: all 0.2s ease;
}

.btn-primary {
	color: var(--text-primary);
	background: var(--primary);
	color: white;
}

.btn-primary:hover {
	background: var(--primary-hover);
	transform: translateY(-2px);
}

/* Methodology Section */
.methodology-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
	gap: 2rem;
	margin-bottom: 4rem;
}

.method-item {
	text-align: center;
	padding: 1.5rem;
}

.method-icon {
	font-size: var(--font-method-icon-size);
	display: block;
	margin-bottom: 1rem;
}

.method-title {
	font-size: var(--font-resource-title-size);
	font-weight: 600;
	margin-bottom: 1rem;
	color: var(--text-primary);
}

.method-description {
	color: var(--text-secondary);
	line-height: var(--font-body-line);
}

/* Resources Section */
.resources-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 2rem;
	margin-bottom: 4rem;
}

.resource-card {
	background: var(--bg);
	border: 1px solid var(--border-light);
	border-radius: 8px;
	padding: 2rem;
	transition: all 0.3s ease;
}

.resource-card:hover {
	border-color: var(--border-hover);
	box-shadow: 0 4px 12px var(--shadow-color);
}

.resource-icon {
	font-size: var(--font-resource-icon-size);
	display: block;
	margin-bottom: 1rem;
}

.resource-title {
	font-size: var(--font-resource-title-size);
	font-weight: 600;
	margin-bottom: 1rem;
	color: var(--text-primary);
}

.resource-description {
	color: var(--text-secondary);
	margin-bottom: 1.5rem;
	line-height: var(--font-body-line);
}

.resource-link {
	color: var(--primary);
	text-decoration: none;
	font-weight: 600;
}

.resource-link:hover {
	text-decoration: underline;
}

.external-link-icon {
	margin-left: 0.25rem;
	opacity: 0.7;
}

/* Sidebar Info */
.sidebar-info {
	max-width: 1200px;
	margin: 4rem auto 0;
	padding: 0 1rem;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	gap: 2rem;
}

.info-card {
	background: var(--bg-light);
	border: 1px solid var(--border-light);
	border-radius: 8px;
	padding: 2rem;
}

.info-title {
	font-size: var(--font-resource-title-size);
	font-weight: 600;
	margin-bottom: 1rem;
	color: var(--text-primary);
}

.author-links {
	margin-top: 1rem;
}

.author-link {
	display: inline-block;
	margin-right: 1rem;
	color: var(--primary);
	text-decoration: none;
}

.author-link:hover {
	text-decoration: underline;
}

.license-link {
	color: var(--primary);
	text-decoration: none;
}

.license-link:hover {
	text-decoration: underline;
}

/* Accessibility */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
	.hero-section {
		padding: 2rem 1rem;
	}

	.lessons-grid,
	.methodology-grid,
	.resources-grid {
		grid-template-columns: 1fr;
	}

	.sidebar-info {
		grid-template-columns: 1fr;
	}
}

/* Improve overall readability and color depth for headings */
.prose h1,
.prose h2,
.prose h3,
.prose h4 {
	color: var(--text-primary);
}

/* Blockquotes contrast */
.prose blockquote {
	border-left: 4px solid var(--primary);
	background: var(--bg-light);
	padding: 0.5rem 1rem;
	color: var(--text-secondary);
	position: relative;
	overflow: visible;
	/* Define quote characters: double quotes, single quotes */
	quotes: '\201C''\201D''\2018''\2019';
	font-family: Georgia, 'Times New Roman', Times, serif;
}

/* Oversized decorative quotes for blockquotes */
/* Override Tailwind's default quotes on p:first-of-type and p:last-of-type */
.prose :where(blockquote p:first-of-type):not(:where([class~='not-prose'], [class~='not-prose'] *))::before,
.prose :where(blockquote p:last-of-type):not(:where([class~='not-prose'], [class~='not-prose'] *))::after {
	font-size: 5rem;
	line-height: 0.5em;
	font-family: Georgia, 'Times New Roman', Times, serif;
	color: var(--primary);
	opacity: 0.2;
	position: absolute;
	pointer-events: none;
	z-index: 0;
	font-weight: 400;
}

/* Opening quote - positioned at top-left, above text */
.prose :where(blockquote p:first-of-type):not(:where([class~='not-prose'], [class~='not-prose'] *))::before {
	content: open-quote !important;
	left: 0;
	top: 0;
	line-height: 0.5em;
}

/* Add padding to first paragraph to prevent text collision with opening quote */
.prose :where(blockquote p:first-of-type):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
	padding-left: 2rem;
	padding-top: 1.5rem;
}

/* Closing quote - positioned at bottom-right with upper padding */
.prose :where(blockquote p:last-of-type):not(:where([class~='not-prose'], [class~='not-prose'] *))::after {
	content: close-quote !important;
	right: 0.5rem;
	bottom: -1.5rem;
	line-height: 0em;
	padding-top: 0.5rem;
}

/* Ensure blockquote content is above the quotes */
.prose blockquote > * {
	position: relative;
	z-index: 1;
}

/* Figure quote styling - for attributed quotes */
.prose figure.quote {
	margin: 1.5rem 0;
}

.prose figure.quote blockquote {
	margin: 0; /* Remove default margin since figure handles spacing */
}

.prose figure.quote figcaption {
	margin-top: 0.75rem;
	text-align: right;
	font-size: 0.875em;
	color: var(--text-secondary);
	font-style: italic;
}

.prose figure.quote figcaption cite {
	font-style: normal;
}

/* =============================
   Readings page enhancements
   ============================= */
.theme .grid {
	display: grid;
	grid-template-columns: 300px 1fr;
	gap: 1.5rem;
	max-width: 1200px;
	margin: 0 auto;
	padding: 1rem;
}

.theme .toc {
	position: sticky;
	top: 1rem;
	align-self: start;
	background: var(--bg-light);
	border: 1px solid var(--border-light);
	border-radius: 8px;
	padding: 1rem;
}

.theme .toc h6 {
	margin: 0 0 0.5rem;
	color: var(--text-primary);
}

.theme .toc a {
	color: var(--primary);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.theme .toc a:focus-visible {
	outline: 3px solid #93c5fd;
	outline-offset: 2px;
}

.theme .parallax {
	position: relative;
	background: var(--bg);
}

.theme .slide__bg {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: linear-gradient(180deg, var(--bg) 0%, var(--bg-light) 100%);
	opacity: 0.6;
	pointer-events: none;
}

.theme .slides {
	position: relative;
	z-index: 1;
}

.theme .grid-container {
	margin-bottom: 2rem;
	padding: 1rem;
	border: 1px solid var(--border-light);
	border-radius: 8px;
	background: var(--bg);
}

.theme .collection-title h2 {
	margin: 0 0 1rem;
	color: var(--text-primary);
}

.theme .fluid-columns {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 1.25rem;
}

.theme .sidebar-toggle-btn {
	position: sticky;
	top: 0.5rem;
	margin: 0.5rem;
	padding: 0.5rem 0.75rem;
	background: var(--primary);
	color: #fff;
	border-radius: 6px;
	text-decoration: none;
	cursor: pointer;
}

.theme .sidebar-toggle-btn:focus-visible {
	outline: 3px solid #93c5fd;
	outline-offset: 2px;
}

@media (max-width: 960px) {
	.theme .grid {
		grid-template-columns: 1fr;
	}
	.theme .toc {
		position: static;
	}
}

/* ========================================
   Modern Lesson Layout - Awwwards Level
   ======================================== */

/* Lesson Wrapper - Grid Layout */
.lesson-wrapper {
	display: grid;
	grid-template-columns: 280px 1fr;
	gap: 0;
	min-height: calc(100vh - 80px);
	max-width: 100%;
	margin: 0;
	padding: 0;
	/* Ensure no extra spacing */
	box-sizing: border-box;
}

/* When page has no TOC, single column so main content uses full width */
.lesson-wrapper--no-toc {
	grid-template-columns: 1fr;
}

@media (max-width: 1024px) {
	.lesson-wrapper {
		grid-template-columns: 1fr;
		min-height: 0; /* Remove min-height on mobile */
		display: block;
		/* Remove any spacing that TOC might have created */
		margin: 0;
		padding: 0;
		width: 100%;
	}

	/* TOC doesn't take space in grid on mobile - completely removed from flow */
	/* But allow it to show when expanded - this rule only applies when NOT expanded */
	.lesson-wrapper > .lesson-toc:not([aria-expanded='true']) {
		display: none !important;
		position: fixed !important; /* Override any other positioning */
	}

	/* When expanded, ensure TOC is visible and positioned correctly */
	.lesson-wrapper > .lesson-toc[aria-expanded='true'] {
		display: block !important;
		position: fixed !important;
	}
}

/* ========================================
   TOC Sidebar (Aside)
   ======================================== */

.lesson-toc {
	position: sticky;
	top: 0;
	height: 100vh;
	overflow: hidden;
	background: var(--bg);
	border-right: 1px solid var(--border-light);
	z-index: 10;
}

@media (max-width: 1024px) {
	.lesson-toc {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		max-width: 320px;
		height: 100vh;
		z-index: 100;
		transform: translateX(-100%);
		transition: transform 0.3s ease;
		box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
		border-right: none;
		/* Remove from document flow on mobile */
		display: none;
	}

	.lesson-toc[aria-expanded='true'] {
		display: block;
		transform: translateX(0);
	}
}

.toc-container {
	display: flex;
	flex-direction: column;
	height: 100%;
}

.toc-header {
	padding: 1.5rem 1.25rem 1rem;
	border-bottom: 1px solid var(--border-light);
	background: var(--bg);
	flex-shrink: 0;
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 1rem;
}

.toc-title {
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--text-secondary);
	margin: 0;
	line-height: 1.2;
	flex: 1;
}

.toc-close {
	display: none;
	background: none;
	border: none;
	color: var(--text-secondary);
	cursor: pointer;
	padding: 0.25rem;
	border-radius: 4px;
	transition: all 0.2s ease;
	width: 24px;
	height: 24px;
	align-items: center;
	justify-content: center;
}

.toc-close:hover {
	background: var(--bg-light);
	color: var(--text-primary);
}

@media (max-width: 1024px) {
	.toc-close {
		display: flex;
	}
}

.toc-toggle {
	display: none;
	position: fixed;
	bottom: 2rem;
	right: 2rem;
	z-index: 101;
	background: var(--primary);
	color: white;
	border: none;
	border-radius: 50px;
	padding: 0.75rem 1.25rem;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	transition: all 0.3s ease;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.875rem;
	font-weight: 500;
}

.toc-toggle:hover {
	background: var(--primary-hover);
	transform: translateY(-2px);
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.toc-toggle svg {
	flex-shrink: 0;
}

.toc-backdrop {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.5);
	z-index: 99; /* Below TOC (100) */
	opacity: 0;
	transition: opacity 0.3s ease;
	backdrop-filter: blur(4px);
	pointer-events: none;
}

.toc-backdrop[aria-hidden='false'] {
	display: block;
	opacity: 1;
	pointer-events: all;
}

@media (max-width: 1024px) {
	.toc-toggle {
		display: flex;
	}

	/* TOC is completely removed from document flow on mobile */
	.lesson-toc {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		max-width: 320px;
		height: 100vh;
		z-index: 100;
		transform: translateX(-100%);
		transition: transform 0.3s ease;
		box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
		display: none; /* Hidden by default, removed from flow */
		background: var(--bg); /* Ensure background is visible */
	}

	.lesson-toc[aria-expanded='true'] {
		display: block !important; /* Override any other display rules */
		transform: translateX(0) !important;
		visibility: visible !important;
		opacity: 1 !important;
		z-index: 100 !important; /* Ensure it's above backdrop */
	}

	/* Hide toggle when TOC is open - using body class set by JS */
	body.toc-open .toc-toggle {
		opacity: 0;
		pointer-events: none;
	}

	.toc-backdrop {
		display: block;
	}
}

.toc-nav {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 1rem 0;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
}

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

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

.toc-nav::-webkit-scrollbar-thumb {
	background: var(--border-light);
	border-radius: 3px;
}

.toc-nav::-webkit-scrollbar-thumb:hover {
	background: var(--muted);
}

.toc-content {
	padding: 0 1.25rem;
}

/* TOC List Styling */
#toc-sidebar-placeholder ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

#toc-sidebar-placeholder > ul {
	margin: 0;
}

#toc-sidebar-placeholder li {
	margin: 0;
	position: relative;
}

#toc-sidebar-placeholder > ul > li {
	margin-bottom: 0.5rem;
}

/* TOC Links */
#toc-sidebar-placeholder a {
	display: block;
	padding: 0.5rem 0.75rem;
	margin: 0 -0.75rem;
	text-decoration: none;
	color: var(--text-secondary);
	font-size: 0.875rem;
	line-height: 1.5;
	border-radius: 6px;
	transition: all 0.2s ease;
	position: relative;
}

#toc-sidebar-placeholder a:hover {
	color: var(--text-primary);
	background: var(--bg-light);
}

#toc-sidebar-placeholder a.toc-active {
	color: var(--primary);
	background: var(--bg-light);
	font-weight: 500;
}

#toc-sidebar-placeholder a.toc-active::before {
	content: '';
	position: absolute;
	left: 0;
	top: 50%;
	transform: translateY(-50%);
	width: 3px;
	height: 60%;
	background: var(--primary);
	border-radius: 0 2px 2px 0;
}

/* Nested TOC Items (H3, H4) */
#toc-sidebar-placeholder ul ul {
	margin-left: 0.75rem;
	margin-top: 0.25rem;
	padding-left: 0.75rem;
	border-left: 1px solid var(--border-light);
}

#toc-sidebar-placeholder ul ul ul {
	margin-left: 0.5rem;
	padding-left: 0.5rem;
}

#toc-sidebar-placeholder ul ul a {
	font-size: 0.8125rem;
	padding: 0.375rem 0.625rem;
	color: var(--muted);
}

#toc-sidebar-placeholder ul ul a:hover,
#toc-sidebar-placeholder ul ul a.toc-active {
	color: var(--text-primary);
}

/* Active TOC Item */
.toc-item-active > a {
	color: var(--primary);
	font-weight: 500;
}

/* ========================================
   Main Content Area
   ======================================== */

.lesson-main {
	overflow-y: auto;
	height: 100vh;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	position: relative;
	margin: 0;
	padding: 0;
}

@media (max-width: 1024px) {
	.lesson-main {
		height: auto;
		overflow-y: visible;
		min-height: calc(100vh - 80px);
		margin: 0;
		padding: 0;
		/* Start immediately, no extra spacing */
	}
}

.lesson-main::-webkit-scrollbar {
	width: 8px;
}

.lesson-main::-webkit-scrollbar-track {
	background: transparent;
}

.lesson-main::-webkit-scrollbar-thumb {
	background: var(--border-light);
	border-radius: 4px;
}

.lesson-main::-webkit-scrollbar-thumb:hover {
	background: var(--muted);
}

.lesson-content {
	max-width: 900px;
	margin: 0 auto;
	padding: 2rem 3rem;
}

@media (max-width: 1024px) {
	.lesson-content {
		padding: 1.5rem 1.25rem;
		max-width: 100%;
		margin-top: 0; /* Remove any top margin */
	}
}

@media (max-width: 768px) {
	.lesson-content {
		padding: 1.25rem 1rem;
	}
}

/* ========================================
   Breadcrumb Navigation
   ======================================== */

.breadcrumb {
	margin-bottom: 2rem;
	padding-bottom: 1rem;
	border-bottom: 1px solid var(--border-light);
	margin-top: 0; /* Ensure no top margin */
}

@media (max-width: 1024px) {
	.breadcrumb {
		margin-top: 0;
		padding-top: 0;
	}
}

.breadcrumb-list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	list-style: none;
	margin: 0;
	padding: 0;
	gap: 0.5rem;
	font-size: 0.875rem;
}

.breadcrumb-item {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.breadcrumb-separator {
	color: var(--muted);
	user-select: none;
}

.breadcrumb-link {
	color: var(--text-secondary);
	text-decoration: none;
	transition: color 0.2s ease;
}

.breadcrumb-link:hover {
	color: var(--primary);
	text-decoration: underline;
}

.breadcrumb-text {
	color: var(--text-primary);
}

.breadcrumb-current .breadcrumb-text {
	color: var(--text-primary);
	font-weight: 500;
}

/* ========================================
   Lesson Header
   ======================================== */

.lesson-header {
	margin-bottom: 3rem;
	padding-bottom: 2rem;
	border-bottom: 1px solid var(--border-light);
	margin-top: 0; /* Ensure no top margin */
}

@media (max-width: 1024px) {
	.lesson-header {
		margin-top: 0;
		padding-top: 0;
	}
}

.lesson-meta {
	margin-bottom: 1rem;
}

.lesson-tagline {
	font-size: 0.875rem;
	color: var(--muted);
	margin: 0 0 1.5rem 0;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.lesson-title {
	font-size: clamp(2rem, 4vw, 3rem);
	font-weight: 700;
	line-height: 1.2;
	color: var(--text-primary);
	margin: 0;
	letter-spacing: -0.02em;
}

.lesson-status {
	display: inline-flex;
	align-items: center;
	padding: 0.375rem 0.75rem;
	border-radius: 0.5rem;
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	white-space: nowrap;
}

/* Estados finalizados (verde) */
.lesson-status.status-finished,
.lesson-status.status-terminado,
.lesson-status[class*='status-finished'],
.lesson-status[class*='status-terminado'] {
	background: #dcfce7;
	color: #166534;
}

.dark .lesson-status.status-finished,
.dark .lesson-status.status-terminado,
.dark .lesson-status[class*='status-finished'],
.dark .lesson-status[class*='status-terminado'] {
	background: #14532d;
	color: #86efac;
}

/* Estados en progreso/borrador (amarillo) */
.lesson-status.status-draft,
.lesson-status.status-borrador,
.lesson-status.status-en-proceso,
.lesson-status[class*='in-progress'],
.lesson-status.status-in-progress,
.lesson-status[class*='in progress'],
.lesson-status[class*='status-draft'],
.lesson-status[class*='status-borrador'],
.lesson-status[class*='status-en-proceso'] {
	background: #fef3c7;
	color: #92400e;
}

.dark .lesson-status.status-draft,
.dark .lesson-status.status-borrador,
.dark .lesson-status.status-en-proceso,
.dark .lesson-status[class*='in-progress'],
.dark .lesson-status.status-in-progress,
.dark .lesson-status[class*='in progress'],
.dark .lesson-status[class*='status-draft'],
.dark .lesson-status[class*='status-borrador'],
.dark .lesson-status[class*='status-en-proceso'] {
	background: #78350f;
	color: #fde047;
}

@media (max-width: 768px) {
	.lesson-header .flex {
		flex-direction: column;
		align-items: flex-start;
		gap: 1rem;
	}

	.lesson-status {
		align-self: flex-start;
	}
}

.lesson-author-date {
	display: flex;
	gap: 1rem;
	font-size: 0.875rem;
	color: var(--text-secondary);
	margin-bottom: 1rem;
}

.lesson-author,
.lesson-date {
	margin: 0;
}

.lesson-url {
	margin: 0;
	font-size: 0.8125rem;
}

.lesson-permalink {
	color: var(--primary);
	text-decoration: none;
	word-break: break-all;
	transition: color 0.2s ease;
}

.lesson-permalink:hover {
	color: var(--primary-hover);
	text-decoration: underline;
}

/* ========================================
   Lesson Body (Prose Content)
   ======================================== */

.lesson-body {
	margin-top: 2rem;
}

.lesson-body :where(h2, h3, h4) {
	scroll-margin-top: 120px;
}

.lesson-body :where(h2, h3, h4)[id] {
	position: relative;
}

.lesson-body :where(h2, h3, h4)[id]:hover::before {
	content: '#';
	position: absolute;
	left: -1.5rem;
	color: var(--muted);
	font-weight: 400;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.lesson-body :where(h2, h3, h4)[id]:hover::before {
	opacity: 1;
}

/* ========================================
   Accessibility & Readability Enhancements
   ======================================== */

/* Better scroll targets for in-page anchors (TOC, footnotes) */
:where(.prose) h1,
:where(.prose) h2,
:where(.prose) h3,
:where(.prose) h4 {
	scroll-margin-top: 5rem;
}

/* Improve paragraph readability and prevent overflow in narrow viewports */
:where(.prose) p {
	max-width: 75ch;
	hyphens: auto;
	overflow-wrap: anywhere;
}

/* Tighter vertical rhythm for lists */
:where(.prose) ul,
:where(.prose) ol {
	margin-block: 0.75rem 1rem;
}
:where(.prose) li {
	margin-block: 0.25rem;
}

/* Footnotes (kramdown) clarity and touch targets */
:where(.prose) .footnotes {
	font-size: clamp(0.875rem, 0.35vw + 0.75rem, 0.95rem);
	border-top: 1px solid var(--border-light);
	margin-top: 2rem;
	padding-top: 1rem;
	color: var(--text-secondary);
}
:where(.prose) .footnotes ol {
	padding-left: 1.25rem;
}
:where(.prose) .footnotes li {
	margin: 0.5rem 0;
}
:where(.prose) sup a {
	text-decoration: none;
	border-bottom: 1px dotted var(--border-light);
	padding: 0 0.1em;
	color: var(--link);
}
:where(.prose) a.reversefootnote {
	text-decoration: none;
	color: var(--muted);
	margin-left: 0.4em;
	border: 0;
}
:where(.prose) a.reversefootnote:hover {
	color: var(--primary-hover);
}

/* Optional heading anchors (GitHub-like) – requires anchor links in HTML if used */
:where(.prose) h2[id],
:where(.prose) h3[id] {
	position: relative;
}
:where(.prose) h2[id]:hover a.anchor,
:where(.prose) h2[id]:focus-within a.anchor,
:where(.prose) h3[id]:hover a.anchor,
:where(.prose) h3[id]:focus-within a.anchor {
	opacity: 1;
}
:where(.prose) a.anchor {
	position: absolute;
	left: -1.25em;
	top: 0.15em;
	opacity: 0;
	text-decoration: none;
	color: var(--muted);
	transition: opacity 0.2s ease;
}
:where(.prose) a.anchor::before {
	content: '#';
}

/* Code refinements */
:where(.prose) pre {
	overscroll-behavior: contain;
}
:where(.prose) pre code .hl {
	background: rgba(255, 255, 255, 0.06);
	display: block;
	margin: 0 -1rem;
	padding: 0 1rem;
}

/* Tables: header contrast and captions */
:where(.prose) table thead th {
	font-weight: 700;
	letter-spacing: 0.01em;
	border-bottom: 1px solid var(--border-light);
}
:where(.prose) table caption {
	caption-side: bottom;
	padding: 0.5rem 0;
	color: var(--muted);
}

/* Links, focus, and selection */
:where(.prose) a {
	text-decoration-thickness: 2px;
	text-underline-offset: 2px;
	text-decoration-skip-ink: auto;
}
:where(a, button, input, select, textarea):focus-visible {
	outline: 3px solid var(--focus-outline);
	outline-offset: 2px;
	border-radius: 4px;
}
::selection {
	background: color-mix(in oklab, var(--primary), white 75%);
	color: var(--text-primary);
}

/* Skip link (add <a href="#main" class="skip-link">Saltar al contenido</a> in layout if desired) */
.skip-link {
	position: absolute;
	left: -9999px;
	top: auto;
	width: 1px;
	height: 1px;
	overflow: hidden;
}
.skip-link:focus {
	position: fixed;
	left: 1rem;
	top: 1rem;
	width: auto;
	height: auto;
	padding: 0.5rem 0.75rem;
	background: var(--primary);
	color: var(--on-primary);
	border-radius: 6px;
	z-index: 1000;
}

/* ========================================
   Responsive Adjustments for Lesson Layout
   ======================================== */

@media (max-width: 768px) {
	.lesson-content {
		padding: 1.25rem 1.25rem;
	}

	.lesson-title {
		font-size: 1.75rem;
	}

	.breadcrumb-list {
		font-size: 0.8125rem;
	}

	.toc-header {
		padding: 1rem 1rem 0.75rem;
	}

	.toc-content {
		padding: 0 1rem;
	}

	#toc-sidebar-placeholder a {
		font-size: 0.8125rem;
		padding: 0.4375rem 0.625rem;
	}
}

/* Ensure main content area doesn't conflict with default layout */
main#main {
	max-width: 100%;
	padding: 0;
	margin: 0;
}

main#main .lesson-wrapper {
	width: 100%;
	margin: 0;
	padding: 0;
}

/* When lesson-wrapper is present, make main#main a simple container */
main#main:has(.lesson-wrapper) {
	display: contents;
	min-height: 0; /* Remove min-height that might cause spacing */
	padding: 0;
	margin: 0;
}

@media (max-width: 1024px) {
	main#main:has(.lesson-wrapper) {
		min-height: 0;
		padding: 0;
		margin: 0;
	}

	/* Ensure lesson-wrapper starts immediately after header */
	.lesson-wrapper {
		margin-top: 0 !important;
		padding-top: 0 !important;
	}
}

/* ========================================
   Back to Top Button
   ======================================== */

.back-to-top {
	position: fixed;
	bottom: 2rem;
	right: 2rem;
	width: 3rem;
	height: 3rem;
	background: var(--primary);
	color: var(--on-primary);
	border: none;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	opacity: 0;
	visibility: hidden;
	transform: translateY(1rem);
	transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, background-color 0.2s ease;
	z-index: 90;
}

.back-to-top:hover {
	background: var(--primary-hover);
	transform: translateY(0);
}

.back-to-top:focus {
	outline: 2px solid var(--focus-outline);
	outline-offset: 2px;
}

.back-to-top.visible {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.back-to-top svg {
	width: 1.25rem;
	height: 1.25rem;
}

/* Dark mode support */
.dark .back-to-top {
	background: #3b82f6;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.dark .back-to-top:hover {
	background: #2563eb;
}

/* Mobile adjustments */
@media (max-width: 768px) {
	.back-to-top {
		bottom: 1rem;
		right: 1rem;
		width: 2.5rem;
		height: 2.5rem;
	}

	.back-to-top svg {
		width: 1rem;
		height: 1rem;
	}
}

/* Hide in print */
@media print {
	.back-to-top {
		display: none !important;
	}
}

/* ========================================
   Print-only Elements
   ======================================== */

.print-only {
	display: none !important;
}

@media print {
	.print-only {
		display: block !important;
	}
}

/* ========================================
   Reduced motion and print styles
   ======================================== */
@media (prefers-reduced-motion: reduce) {
	* {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}

	.lesson-main,
	.toc-nav {
		scroll-behavior: auto;
	}
}
@media print {
	body {
		background: #fff;
		color: #111;
	}
	.site-header,
	.site-footer,
	nav,
	.hero-section,
	.lesson-toc,
	.breadcrumb {
		display: none !important;
	}
	.lesson-wrapper {
		grid-template-columns: 1fr !important;
		display: block !important;
	}
	.lesson-main {
		height: auto !important;
		overflow: visible !important;
	}
	.lesson-content {
		max-width: 100% !important;
		padding: 0 !important;
	}
	.container {
		max-width: none;
		padding: 0;
	}
	a {
		color: #000;
		text-decoration: underline;
	}
	pre {
		white-space: pre-wrap;
		border: 1px solid #ddd;
	}
}
