/* === Sticky Header Support === */

/* Fixed header and nav positioning */
body.with-sticky #header,
body.with-sticky #topnav {
	position: fixed;
	width: 100%;
	top: 0;
	left: 0;
	transform: translateY(0);
	transition: transform 0.5s ease;
	z-index: 200;
}

/* === Mobile Behavior === */
body.with-sticky.mobile #header {
	height: 40px;
	top: 0;
}
body.with-sticky.mobile #topnav {
	top: 40px;
	z-index: 199;
}
body.with-sticky.mobile.hide-header #header {
	transform: translateY(-44px);
}
body.with-sticky.mobile.hide-header #topnav {
	transform: translateY(-110%); /* header + nav height combined */
}

/* === Desktop Behavior === */
body.with-sticky.desktop #header {
	height: 42px;
	top: 0;
}
body.with-sticky.desktop #topnav {
	top: 42px;
	z-index: 199;
}
body.with-sticky.desktop.hide-header #header {
	transform: translateY(-42px);
}
body.with-sticky.desktop.hide-header #topnav {
	transform: translateY(-43px);
}

/* === Anchor Compensation === */
body.with-sticky [id^="L"] {
	/* Using max() ensures at least 1px, respects iOS safe areas */
	scroll-margin-top: 1px !important;
}

/* === Anchor offset to push content below fixed headers === */
body.with-sticky.desktop .anchor-offset {
	height: 66px; /* 42px header + 24px nav */
}

body.with-sticky.mobile .anchor-offset {
	height: 44px; /* 40px header + 4px buffer */
}

/* === Mobile Header Left/Right Offset Patch === */
body.with-sticky #header {
	left: 0 !important;
	right: 0 !important;
	margin: 0 auto !important;
}

/* === Mobile Redundancy Override for Safety === */
body.with-sticky.mobile #header {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	width: 100%;
	height: 40px;
	transform: translateY(0);
	transition: transform 0.5s ease;
	z-index: 200;
}
body.with-sticky.mobile.hide-header #header {
	transform: translateY(-44px);
}

/* === Desktop Scroll Padding Fix === */
body.with-sticky.desktop #content {
	padding-top: 0; /* Minimal, avoids double padding if layout already has spacing */
}

/* === Optional Fallbacks for Legacy Table Layouts === */
body.with-sticky.desktop table:first-of-type {
	margin-top: 1px;
}

/* === Ensure first visible post isn't pushed below anchor offset */
body.with-sticky #content > .post:first-child {
	margin-top: 1px !important;
}

/* === Optional: Standardize .post layout if used later === */
.post {
	margin: 0;
	padding: 0;
}

/* Mobile: 40px header + 24px nav = 64px */
body.with-sticky.mobile [id^="L"] {
	scroll-margin-top: 64px !important;
}

/* Desktop: 42px header + 24px nav = 66px */
body.with-sticky.desktop [id^="L"] {
	scroll-margin-top: 66px !important;
}

body.mobile.with-sticky div#topnav {
	margin: 0 5px;
}
