/*
 * Theme Name:        SEO Insights
 * Theme URI:         https://seoinsights.org
 * Description:       Elite SaaS Micro-Tools Portal + Advanced SEO/GEO Publishing Blog. Zero-bloat, 100 PageSpeed, enterprise-grade security. Built for seoinsights.org.
 * Version:           1.0.0
 * Requires at least: 6.4
 * Tested up to:      6.7
 * Requires PHP:      8.2
 * Author:            SEO Insights Team
 * Author URI:        https://seoinsights.org
 * License:           GPL-2.0-or-later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       seoinsights
 * Tags:              full-site-editing, block-themes, custom-colors, dark-mode, performance, seo, saas
 */

/* ==========================================================================
   DESIGN TOKEN SYSTEM — GLOBAL CUSTOM PROPERTIES
   ========================================================================== */

:root {
	/* --- Brand Palette --- */
	--si-ink:          #0F172A;
	--si-indigo:       #6366F1;
	--si-indigo-light: #818CF8;
	--si-indigo-glow:  rgba(99, 102, 241, 0.15);
	--si-surface:      #FFFFFF;
	--si-surface-2:    #F8FAFC;
	--si-surface-3:    #F1F5F9;
	--si-border:       #E2E8F0;
	--si-border-soft:  rgba(226, 232, 240, 0.6);
	--si-text:         #0F172A;
	--si-text-muted:   #64748B;
	--si-text-subtle:  #94A3B8;

	/* --- Semantic Color Aliases (Customizer-overridable) --- */
	--color-primary:      var(--si-indigo);
	--color-primary-glow: var(--si-indigo-glow);
	--color-bg:           var(--si-surface);
	--color-bg-alt:       var(--si-surface-2);
	--color-bg-card:      var(--si-surface);
	--color-text:         var(--si-text);
	--color-text-muted:   var(--si-text-muted);
	--color-border:       var(--si-border);
	--color-heading:      var(--si-ink);

	/* --- Fluid Typography Scale (clamp-based) --- */
	--fs-xs:   clamp(0.694rem,  0.65rem  + 0.22vw, 0.8rem);
	--fs-sm:   clamp(0.833rem,  0.79rem  + 0.22vw, 0.95rem);
	--fs-base: clamp(1rem,      0.96rem  + 0.22vw, 1.125rem);
	--fs-md:   clamp(1.2rem,    1.1rem   + 0.5vw,  1.4rem);
	--fs-lg:   clamp(1.44rem,   1.3rem   + 0.7vw,  1.75rem);
	--fs-xl:   clamp(1.728rem,  1.5rem   + 1.1vw,  2.25rem);
	--fs-2xl:  clamp(2.074rem,  1.75rem  + 1.6vw,  2.986rem);
	--fs-3xl:  clamp(2.488rem,  2rem     + 2.4vw,  3.815rem);

	/* --- Font Families --- */
	--font-display: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
	--font-body:    'Inter', 'Segoe UI', system-ui, sans-serif;
	--font-mono:    'JetBrains Mono', 'Fira Code', monospace;

	/* --- Spacing Scale --- */
	--space-1:  0.25rem;
	--space-2:  0.5rem;
	--space-3:  0.75rem;
	--space-4:  1rem;
	--space-5:  1.25rem;
	--space-6:  1.5rem;
	--space-8:  2rem;
	--space-10: 2.5rem;
	--space-12: 3rem;
	--space-16: 4rem;
	--space-20: 5rem;
	--space-24: 6rem;

	/* --- Layout Dimensions --- */
	--container-sm:  640px;
	--container-md:  768px;
	--container-lg:  1024px;
	--container-xl:  1280px;
	--container-2xl: 1440px;
	--sidebar-w:     320px;
	--header-h:      72px;

	/* --- Radius --- */
	--radius-sm:   4px;
	--radius-md:   8px;
	--radius-lg:   12px;
	--radius-xl:   16px;
	--radius-2xl:  24px;
	--radius-full: 9999px;

	/* --- Elevation / Shadow --- */
	--shadow-xs:  0 1px 2px 0 rgba(15, 23, 42, 0.05);
	--shadow-sm:  0 1px 3px 0 rgba(15, 23, 42, 0.1), 0 1px 2px -1px rgba(15, 23, 42, 0.1);
	--shadow-md:  0 4px 6px -1px rgba(15, 23, 42, 0.1), 0 2px 4px -2px rgba(15, 23, 42, 0.1);
	--shadow-lg:  0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -4px rgba(15, 23, 42, 0.1);
	--shadow-xl:  0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.1);
	--shadow-glow:0 0 0 3px var(--color-primary-glow);

	/* --- Motion --- */
	--ease-out:   cubic-bezier(0.0, 0.0, 0.2, 1);
	--ease-in:    cubic-bezier(0.4, 0.0, 1, 1);
	--ease-inout: cubic-bezier(0.4, 0.0, 0.2, 1);
	--duration-fast:   150ms;
	--duration-base:   300ms;
	--duration-slow:   500ms;
}

/* ==========================================================================
   DARK MODE TOKEN OVERRIDES
   ========================================================================== */

[data-theme="dark"],
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--color-bg:       #0B0F1A;
		--color-bg-alt:   #111827;
		--color-bg-card:  #131C2E;
		--color-text:     #E2E8F0;
		--color-text-muted: #94A3B8;
		--color-heading:  #F1F5F9;
		--color-border:   rgba(255, 255, 255, 0.08);
		--shadow-sm:  0 1px 3px 0 rgba(0, 0, 0, 0.4);
		--shadow-md:  0 4px 6px -1px rgba(0, 0, 0, 0.4);
		--shadow-lg:  0 10px 15px -3px rgba(0, 0, 0, 0.4);
	}
}

[data-theme="dark"] {
	--color-bg:       #0B0F1A;
	--color-bg-alt:   #111827;
	--color-bg-card:  #131C2E;
	--color-text:     #E2E8F0;
	--color-text-muted: #94A3B8;
	--color-heading:  #F1F5F9;
	--color-border:   rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   RESET & BASE
   ========================================================================== */

*, *::before, *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

html {
	scroll-behavior: smooth;
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	tab-size: 4;
}

body {
	font-family: var(--font-body);
	font-size: var(--fs-base);
	line-height: 1.7;
	color: var(--color-text);
	background-color: var(--color-bg);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	transition: background-color var(--duration-base) var(--ease-out),
	            color var(--duration-base) var(--ease-out);
}

/* Remove default list styles */
ul, ol { list-style: none; }

/* Remove default anchor styles */
a {
	color: var(--color-primary);
	text-decoration: none;
	transition: color var(--duration-fast) var(--ease-out);
}
a:hover { color: var(--si-indigo-light); }

/* Typography baseline */
h1, h2, h3, h4, h5, h6 {
	font-family: var(--font-display);
	font-weight: 700;
	color: var(--color-heading);
	line-height: 1.2;
	letter-spacing: -0.02em;
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
h5 { font-size: var(--fs-md); }
h6 { font-size: var(--fs-base); }

p { margin-bottom: var(--space-4); }

img, video, svg {
	max-width: 100%;
	height: auto;
	display: block;
}

img { object-fit: cover; }

/* ==========================================================================
   LAYOUT PRIMITIVES
   ========================================================================== */

.si-container {
	width: 100%;
	max-width: var(--container-xl);
	margin-inline: auto;
	padding-inline: clamp(1rem, 4vw, 2rem);
}

.si-container--narrow { max-width: var(--container-md); }
.si-container--wide   { max-width: var(--container-2xl); }

.si-grid {
	display: grid;
	gap: var(--space-6);
}

.si-flex {
	display: flex;
	gap: var(--space-4);
}

/* Site wrapper for sticky footer */
#page {
	display: grid;
	grid-template-rows: auto 1fr auto;
	min-height: 100dvh;
}

/* ==========================================================================
   SITE HEADER
   ========================================================================== */

.site-header {
	position: sticky;
	top: 0;
	z-index: 100;
	height: var(--header-h);
	background-color: var(--color-bg);
	border-bottom: 1px solid var(--color-border);
	backdrop-filter: blur(12px) saturate(180%);
	-webkit-backdrop-filter: blur(12px) saturate(180%);
	background-color: rgba(var(--color-bg-raw, 255, 255, 255), 0.85);
	transition: box-shadow var(--duration-base) var(--ease-out);
}

.site-header.is-scrolled {
	box-shadow: var(--shadow-md);
}

.header-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	height: 100%;
	gap: var(--space-8);
}

/* Site Branding */
.site-branding {
	display: flex;
	align-items: center;
	gap: var(--space-3);
	flex-shrink: 0;
}

.site-logo img {
	height: 36px;
	width: auto;
}

.site-name {
	font-family: var(--font-display);
	font-size: var(--fs-md);
	font-weight: 800;
	color: var(--color-heading);
	letter-spacing: -0.03em;
	background: linear-gradient(135deg, var(--si-ink) 0%, var(--si-indigo) 100%);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
}

[data-theme="dark"] .site-name {
	background: linear-gradient(135deg, #F1F5F9 0%, var(--si-indigo-light) 100%);
	-webkit-background-clip: text;
	background-clip: text;
}

/* Primary Navigation */
.primary-navigation {
	flex: 1;
}

.primary-navigation ul {
	display: flex;
	align-items: center;
	gap: var(--space-1);
}

.primary-navigation a {
	display: inline-flex;
	align-items: center;
	padding: var(--space-2) var(--space-3);
	font-size: var(--fs-sm);
	font-weight: 500;
	color: var(--color-text-muted);
	border-radius: var(--radius-md);
	transition: color var(--duration-fast) var(--ease-out),
	            background-color var(--duration-fast) var(--ease-out);
}

.primary-navigation a:hover,
.primary-navigation .current-menu-item > a {
	color: var(--color-primary);
	background-color: var(--color-primary-glow);
}

/* Header Actions */
.header-actions {
	display: flex;
	align-items: center;
	gap: var(--space-3);
	flex-shrink: 0;
}

/* Dark Mode Toggle */
.dark-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: 1px solid var(--color-border);
	border-radius: var(--radius-md);
	background: transparent;
	color: var(--color-text-muted);
	cursor: pointer;
	transition: border-color var(--duration-fast), color var(--duration-fast),
	            background-color var(--duration-fast);
	appearance: none;
	-webkit-appearance: none;
}

.dark-toggle:hover {
	border-color: var(--color-primary);
	color: var(--color-primary);
	background-color: var(--color-primary-glow);
}

.dark-toggle:focus-visible {
	outline: 2px solid var(--color-primary);
	outline-offset: 2px;
}

.dark-toggle .icon-sun  { display: none; }
.dark-toggle .icon-moon { display: block; }
[data-theme="dark"] .dark-toggle .icon-sun  { display: block; }
[data-theme="dark"] .dark-toggle .icon-moon { display: none; }

/* Mobile Nav Toggle */
.nav-toggle {
	display: none;
	flex-direction: column;
	justify-content: center;
	gap: 5px;
	width: 40px;
	height: 40px;
	padding: var(--space-2);
	background: transparent;
	border: 1px solid var(--color-border);
	border-radius: var(--radius-md);
	cursor: pointer;
}

.nav-toggle span {
	display: block;
	width: 100%;
	height: 2px;
	background-color: var(--color-text);
	border-radius: var(--radius-full);
	transition: transform var(--duration-base) var(--ease-inout),
	            opacity var(--duration-base) var(--ease-inout);
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

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

	.primary-navigation {
		position: fixed;
		inset: var(--header-h) 0 0 0;
		background: var(--color-bg);
		border-top: 1px solid var(--color-border);
		padding: var(--space-6);
		transform: translateX(100%);
		transition: transform var(--duration-base) var(--ease-out);
		overflow-y: auto;
		z-index: 99;
	}

	.primary-navigation.is-open {
		transform: translateX(0);
	}

	.primary-navigation ul {
		flex-direction: column;
		align-items: stretch;
	}

	.primary-navigation a {
		font-size: var(--fs-md);
		padding: var(--space-3) var(--space-4);
	}
}

/* ==========================================================================
   HERO SECTION
   ========================================================================== */

.site-hero {
	position: relative;
	padding-block: var(--space-24) var(--space-20);
	overflow: hidden;
}

/* Decorative background mesh */
.site-hero::before {
	content: '';
	position: absolute;
	inset: 0;
	background:
		radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.12) 0%, transparent 70%),
		radial-gradient(ellipse 60% 40% at 80% 80%, rgba(99, 102, 241, 0.06) 0%, transparent 60%);
	pointer-events: none;
}

.hero-content {
	position: relative;
	text-align: center;
	max-width: 800px;
	margin-inline: auto;
}

.hero-eyebrow {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	padding: var(--space-1) var(--space-3) var(--space-1) var(--space-2);
	margin-bottom: var(--space-6);
	background: var(--color-primary-glow);
	border: 1px solid rgba(99, 102, 241, 0.3);
	border-radius: var(--radius-full);
	font-size: var(--fs-xs);
	font-weight: 600;
	color: var(--color-primary);
	letter-spacing: 0.05em;
	text-transform: uppercase;
}

.hero-eyebrow .dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--color-primary);
	animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
	0%, 100% { opacity: 1; transform: scale(1); }
	50%       { opacity: 0.5; transform: scale(0.8); }
}

.hero-title {
	font-size: var(--fs-3xl);
	font-weight: 800;
	letter-spacing: -0.04em;
	margin-bottom: var(--space-6);
}

.hero-title .accent {
	background: linear-gradient(135deg, var(--si-indigo) 0%, #A78BFA 100%);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
}

.hero-description {
	font-size: var(--fs-md);
	color: var(--color-text-muted);
	line-height: 1.8;
	margin-bottom: var(--space-10);
}

/* Hero Search Bar */
.hero-search {
	position: relative;
	max-width: 600px;
	margin-inline: auto;
}

.hero-search__input {
	width: 100%;
	height: 56px;
	padding: 0 120px 0 var(--space-5);
	font-size: var(--fs-base);
	font-family: var(--font-body);
	color: var(--color-text);
	background: var(--color-bg-card);
	border: 1.5px solid var(--color-border);
	border-radius: var(--radius-xl);
	box-shadow: var(--shadow-sm);
	transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
	outline: none;
}

.hero-search__input:focus {
	border-color: var(--color-primary);
	box-shadow: var(--shadow-glow), var(--shadow-sm);
}

.hero-search__input::placeholder {
	color: var(--color-text-subtle);
}

.hero-search__btn {
	position: absolute;
	right: var(--space-2);
	top: 50%;
	transform: translateY(-50%);
	height: 40px;
	padding: 0 var(--space-5);
	font-size: var(--fs-sm);
	font-weight: 600;
	font-family: var(--font-body);
	color: #fff;
	background: var(--color-primary);
	border: none;
	border-radius: var(--radius-lg);
	cursor: pointer;
	transition: background-color var(--duration-fast), transform var(--duration-fast);
	white-space: nowrap;
}

.hero-search__btn:hover {
	background: var(--si-indigo-light);
	transform: translateY(-50%) scale(1.02);
}

/* Search results dropdown */
.hero-search__results {
	position: absolute;
	top: calc(100% + var(--space-2));
	left: 0;
	right: 0;
	background: var(--color-bg-card);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-xl);
	z-index: 50;
	overflow: hidden;
	display: none;
}

.hero-search__results.is-open { display: block; }

.search-result-item {
	display: flex;
	align-items: center;
	gap: var(--space-3);
	padding: var(--space-3) var(--space-4);
	border-bottom: 1px solid var(--color-border);
	transition: background-color var(--duration-fast);
	cursor: pointer;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background-color: var(--color-bg-alt); }

.search-result-type {
	font-size: var(--fs-xs);
	font-weight: 600;
	padding: 2px var(--space-2);
	border-radius: var(--radius-sm);
	background: var(--color-primary-glow);
	color: var(--color-primary);
	flex-shrink: 0;
}

.search-result-title {
	font-size: var(--fs-sm);
	font-weight: 500;
	color: var(--color-text);
}

/* ==========================================================================
   SECTION HEADINGS
   ========================================================================== */

.section-header {
	margin-bottom: var(--space-10);
}

.section-eyebrow {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	font-size: var(--fs-xs);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--color-primary);
	margin-bottom: var(--space-3);
}

.section-eyebrow::before {
	content: '';
	display: block;
	width: 24px;
	height: 2px;
	background: var(--color-primary);
	border-radius: var(--radius-full);
}

.section-title {
	font-size: var(--fs-2xl);
	font-weight: 800;
	letter-spacing: -0.03em;
	color: var(--color-heading);
	margin-bottom: var(--space-4);
}

.section-description {
	font-size: var(--fs-md);
	color: var(--color-text-muted);
	max-width: 60ch;
	line-height: 1.75;
}

/* ==========================================================================
   SAAS TOOL HUB GRID
   ========================================================================== */

.tools-hub {
	padding-block: var(--space-20);
	background: var(--color-bg-alt);
}

.tools-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	gap: var(--space-6);
}

.tool-card {
	position: relative;
	display: flex;
	flex-direction: column;
	padding: var(--space-6);
	background: var(--color-bg-card);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-xl);
	box-shadow: var(--shadow-sm);
	transition: border-color var(--duration-base) var(--ease-out),
	            box-shadow var(--duration-base) var(--ease-out),
	            transform var(--duration-base) var(--ease-out);
	overflow: hidden;
	text-decoration: none;
}

.tool-card::before {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(135deg, var(--color-primary-glow) 0%, transparent 60%);
	opacity: 0;
	transition: opacity var(--duration-base) var(--ease-out);
}

.tool-card:hover {
	border-color: var(--color-primary);
	box-shadow: var(--shadow-lg), 0 0 0 1px var(--color-primary);
	transform: translateY(-2px);
}

.tool-card:hover::before { opacity: 1; }

.tool-card__icon {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	border-radius: var(--radius-lg);
	background: var(--color-primary-glow);
	color: var(--color-primary);
	margin-bottom: var(--space-4);
	font-size: 1.5rem;
}

.tool-card__badge {
	position: absolute;
	top: var(--space-4);
	right: var(--space-4);
	font-size: var(--fs-xs);
	font-weight: 700;
	padding: 2px var(--space-2);
	border-radius: var(--radius-full);
	background: var(--color-primary);
	color: #fff;
}

.tool-card__title {
	font-size: var(--fs-md);
	font-weight: 700;
	color: var(--color-heading);
	margin-bottom: var(--space-2);
}

.tool-card__desc {
	font-size: var(--fs-sm);
	color: var(--color-text-muted);
	line-height: 1.6;
	flex: 1;
	margin-bottom: var(--space-5);
}

.tool-card__cta {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	font-size: var(--fs-sm);
	font-weight: 600;
	color: var(--color-primary);
	transition: gap var(--duration-fast);
}

.tool-card:hover .tool-card__cta { gap: var(--space-3); }

/* ==========================================================================
   INSIGHTS BLOG GRID
   ========================================================================== */

.insights-section {
	padding-block: var(--space-20);
}

.posts-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
	gap: var(--space-6);
}

.post-card {
	display: flex;
	flex-direction: column;
	background: var(--color-bg-card);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-xl);
	overflow: hidden;
	transition: box-shadow var(--duration-base) var(--ease-out),
	            transform var(--duration-base) var(--ease-out);
}

.post-card:hover {
	box-shadow: var(--shadow-lg);
	transform: translateY(-2px);
}

.post-card__thumb {
	position: relative;
	aspect-ratio: 16/9;
	overflow: hidden;
	background: var(--color-bg-alt);
}

.post-card__thumb picture,
.post-card__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform var(--duration-slow) var(--ease-out);
}

.post-card:hover .post-card__thumb img { transform: scale(1.03); }

.post-card__cat {
	position: absolute;
	bottom: var(--space-3);
	left: var(--space-3);
	padding: var(--space-1) var(--space-3);
	font-size: var(--fs-xs);
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: #fff;
	background: var(--color-primary);
	border-radius: var(--radius-full);
}

.post-card__body {
	flex: 1;
	display: flex;
	flex-direction: column;
	padding: var(--space-5);
}

.post-card__meta {
	display: flex;
	align-items: center;
	gap: var(--space-3);
	font-size: var(--fs-xs);
	color: var(--color-text-subtle);
	margin-bottom: var(--space-3);
}

.post-card__title {
	font-size: var(--fs-md);
	font-weight: 700;
	color: var(--color-heading);
	line-height: 1.35;
	margin-bottom: var(--space-3);
	transition: color var(--duration-fast);
}

.post-card__title a { color: inherit; }
.post-card__title a:hover { color: var(--color-primary); }

.post-card__excerpt {
	font-size: var(--fs-sm);
	color: var(--color-text-muted);
	line-height: 1.65;
	margin-bottom: var(--space-5);
	flex: 1;
	/* Clamp to 3 lines */
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.post-card__footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding-top: var(--space-4);
	border-top: 1px solid var(--color-border);
}

.post-author {
	display: flex;
	align-items: center;
	gap: var(--space-2);
}

.post-author__avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	object-fit: cover;
}

.post-author__name {
	font-size: var(--fs-xs);
	font-weight: 600;
	color: var(--color-text-muted);
}

.post-read-more {
	font-size: var(--fs-xs);
	font-weight: 600;
	color: var(--color-primary);
	display: flex;
	align-items: center;
	gap: var(--space-1);
}

/* ==========================================================================
   SINGLE POST LAYOUT (With TOC)
   ========================================================================== */

.single-layout {
	display: grid;
	grid-template-columns: 1fr var(--sidebar-w);
	gap: var(--space-12);
	align-items: start;
	padding-block: var(--space-12);
}

@media (max-width: 1023px) {
	.single-layout {
		grid-template-columns: 1fr;
	}
}

.single-content {
	min-width: 0; /* Prevent grid blowout */
}

/* Article Typography */
.entry-content {
	font-size: var(--fs-base);
	line-height: 1.85;
	color: var(--color-text);
}

.entry-content h2,
.entry-content h3,
.entry-content h4 {
	margin-top: var(--space-10);
	margin-bottom: var(--space-4);
	scroll-margin-top: calc(var(--header-h) + var(--space-6));
}

.entry-content p { margin-bottom: var(--space-5); }

.entry-content ul,
.entry-content ol {
	list-style: revert;
	padding-left: var(--space-6);
	margin-bottom: var(--space-5);
}

.entry-content li { margin-bottom: var(--space-2); }

.entry-content blockquote {
	position: relative;
	margin: var(--space-8) 0;
	padding: var(--space-6);
	background: var(--color-bg-alt);
	border-left: 4px solid var(--color-primary);
	border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
	font-size: var(--fs-md);
	font-style: italic;
	color: var(--color-text-muted);
}

.entry-content code {
	font-family: var(--font-mono);
	font-size: 0.875em;
	padding: 2px 6px;
	background: var(--color-bg-alt);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-sm);
	color: var(--si-indigo);
}

[data-theme="dark"] .entry-content code { color: var(--si-indigo-light); }

.entry-content pre {
	margin-bottom: var(--space-6);
	padding: var(--space-5);
	background: var(--si-ink);
	border-radius: var(--radius-lg);
	overflow-x: auto;
}

.entry-content pre code {
	background: none;
	border: none;
	color: #E2E8F0;
	padding: 0;
}

/* ==========================================================================
   TABLE OF CONTENTS
   ========================================================================== */

.toc-sidebar {
	position: sticky;
	top: calc(var(--header-h) + var(--space-6));
	max-height: calc(100vh - var(--header-h) - var(--space-12));
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: var(--color-border) transparent;
}

.toc-widget {
	background: var(--color-bg-card);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-xl);
	padding: var(--space-5);
}

.toc-widget__header {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	font-size: var(--fs-xs);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--color-text-muted);
	margin-bottom: var(--space-4);
	padding-bottom: var(--space-4);
	border-bottom: 1px solid var(--color-border);
}

.toc-nav { padding: 0; }

.toc-nav__item { margin-bottom: var(--space-1); }

.toc-nav__link {
	display: block;
	padding: var(--space-2) var(--space-3);
	font-size: var(--fs-xs);
	font-weight: 500;
	color: var(--color-text-muted);
	border-left: 2px solid transparent;
	border-radius: 0 var(--radius-md) var(--radius-md) 0;
	transition: color var(--duration-fast),
	            border-color var(--duration-fast),
	            background-color var(--duration-fast);
	line-height: 1.5;
}

.toc-nav__link:hover {
	color: var(--color-primary);
	background: var(--color-primary-glow);
	border-color: var(--si-indigo-light);
}

.toc-nav__link.is-active {
	color: var(--color-primary);
	border-color: var(--color-primary);
	background: var(--color-primary-glow);
	font-weight: 600;
}

/* h3 indentation */
.toc-nav__item--h3 .toc-nav__link {
	padding-left: var(--space-6);
	font-size: calc(var(--fs-xs) * 0.95);
}

/* ==========================================================================
   RELATED POSTS
   ========================================================================== */

.related-posts {
	margin-top: var(--space-16);
	padding-top: var(--space-10);
	border-top: 1px solid var(--color-border);
}

.related-posts__header {
	margin-bottom: var(--space-6);
}

.related-posts__grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: var(--space-5);
}

@media (max-width: 767px) {
	.related-posts__grid {
		grid-template-columns: 1fr;
	}
}

.related-card {
	display: flex;
	flex-direction: column;
	background: var(--color-bg-card);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-xl);
	overflow: hidden;
	transition: box-shadow var(--duration-base), transform var(--duration-base);
}

.related-card:hover {
	box-shadow: var(--shadow-md);
	transform: translateY(-2px);
}

.related-card__thumb {
	aspect-ratio: 16/9;
	overflow: hidden;
	background: var(--color-bg-alt);
}

.related-card__thumb picture,
.related-card__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform var(--duration-slow);
}

.related-card:hover .related-card__thumb img { transform: scale(1.04); }

.related-card__body {
	padding: var(--space-4);
	display: flex;
	flex-direction: column;
	flex: 1;
}

.related-card__cat {
	font-size: var(--fs-xs);
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--color-primary);
	margin-bottom: var(--space-2);
}

.related-card__title {
	font-size: var(--fs-sm);
	font-weight: 700;
	color: var(--color-heading);
	line-height: 1.4;
	margin-bottom: var(--space-2);
}

.related-card__title a { color: inherit; }
.related-card__title a:hover { color: var(--color-primary); }

.related-card__meta {
	font-size: var(--fs-xs);
	color: var(--color-text-subtle);
	margin-top: auto;
}

/* ==========================================================================
   CONTACT FORM
   ========================================================================== */

.contact-wrapper {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--space-12);
	align-items: start;
	padding-block: var(--space-16);
}

@media (max-width: 767px) {
	.contact-wrapper { grid-template-columns: 1fr; }
}

.contact-form-panel {
	background: var(--color-bg-card);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-2xl);
	padding: var(--space-8);
	position: relative;
	overflow: hidden;
}

.si-form-group {
	margin-bottom: var(--space-5);
}

.si-form-label {
	display: block;
	font-size: var(--fs-sm);
	font-weight: 600;
	color: var(--color-text);
	margin-bottom: var(--space-2);
}

.si-form-label .required {
	color: #EF4444;
	margin-left: 2px;
}

.si-form-input,
.si-form-textarea {
	width: 100%;
	padding: 12px var(--space-4);
	font-size: var(--fs-base);
	font-family: var(--font-body);
	color: var(--color-text);
	background: var(--color-bg);
	border: 1.5px solid var(--color-border);
	border-radius: var(--radius-lg);
	transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
	outline: none;
	appearance: none;
}

.si-form-input:focus,
.si-form-textarea:focus {
	border-color: var(--color-primary);
	box-shadow: var(--shadow-glow);
}

.si-form-input.is-invalid,
.si-form-textarea.is-invalid {
	border-color: #EF4444;
	box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.si-form-textarea {
	min-height: 160px;
	resize: vertical;
}

.si-form-error {
	display: none;
	font-size: var(--fs-xs);
	color: #EF4444;
	margin-top: var(--space-1);
}

.si-form-error.is-visible { display: block; }

.char-counter {
	display: block;
	font-size: var(--fs-xs);
	color: var(--color-text-subtle);
	text-align: right;
	margin-top: var(--space-1);
}

.char-counter.is-near   { color: #F59E0B; }
.char-counter.is-limit  { color: #EF4444; }

/* Submit Button */
.btn-submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-2);
	width: 100%;
	height: 52px;
	font-size: var(--fs-base);
	font-weight: 700;
	font-family: var(--font-body);
	color: #fff;
	background: var(--color-primary);
	border: none;
	border-radius: var(--radius-lg);
	cursor: pointer;
	transition: background-color var(--duration-fast), transform var(--duration-fast);
	position: relative;
	overflow: hidden;
}

.btn-submit:hover:not(:disabled) {
	background: var(--si-indigo-light);
	transform: translateY(-1px);
}

.btn-submit:disabled { opacity: 0.7; cursor: not-allowed; }

/* ==========================================================================
   SKELETON SHIMMER LOADER
   ========================================================================== */

@keyframes shimmer {
	0%   { background-position: -1000px 0; }
	100% { background-position:  1000px 0; }
}

.skeleton-overlay {
	position: absolute;
	inset: 0;
	background: var(--color-bg-card);
	z-index: 10;
	display: none;
	flex-direction: column;
	gap: var(--space-4);
	padding: var(--space-8);
	border-radius: var(--radius-2xl);
}

.skeleton-overlay.is-active { display: flex; }

.skeleton-line {
	height: 16px;
	border-radius: var(--radius-sm);
	background: linear-gradient(
		90deg,
		var(--color-bg-alt) 25%,
		var(--color-border) 50%,
		var(--color-bg-alt) 75%
	);
	background-size: 1000px 100%;
	animation: shimmer 1.8s ease-in-out infinite;
}

.skeleton-line--title  { height: 24px; width: 60%; }
.skeleton-line--short  { width: 40%; }
.skeleton-line--medium { width: 75%; }
.skeleton-line--full   { width: 100%; }
.skeleton-block {
	height: 52px;
	border-radius: var(--radius-lg);
	background: linear-gradient(
		90deg,
		var(--color-bg-alt) 25%,
		var(--color-border) 50%,
		var(--color-bg-alt) 75%
	);
	background-size: 1000px 100%;
	animation: shimmer 1.8s ease-in-out infinite;
}

/* ==========================================================================
   STICKY SIDEBAR MONETIZATION
   ========================================================================== */

.sidebar-sticky-zone {
	position: sticky;
	top: calc(var(--header-h) + var(--space-6));
	display: flex;
	flex-direction: column;
	gap: var(--space-5);
}

.ad-widget,
.affiliate-widget {
	background: var(--color-bg-card);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-xl);
	overflow: hidden;
	transition: box-shadow var(--duration-base);
}

.ad-widget:hover,
.affiliate-widget:hover {
	box-shadow: var(--shadow-md);
}

.ad-widget__label {
	display: block;
	text-align: center;
	font-size: var(--fs-xs);
	color: var(--color-text-subtle);
	padding: var(--space-2);
	border-bottom: 1px solid var(--color-border);
	letter-spacing: 0.05em;
	text-transform: uppercase;
}

.ad-widget__slot {
	padding: var(--space-4);
	min-height: 250px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--color-bg-alt);
}

.affiliate-widget__body {
	padding: var(--space-5);
}

.affiliate-widget__badge {
	display: inline-flex;
	align-items: center;
	gap: var(--space-1);
	font-size: var(--fs-xs);
	font-weight: 700;
	color: #D97706;
	background: rgba(217, 119, 6, 0.1);
	border-radius: var(--radius-full);
	padding: 2px var(--space-2);
	margin-bottom: var(--space-3);
}

.affiliate-widget__title {
	font-size: var(--fs-sm);
	font-weight: 700;
	color: var(--color-heading);
	margin-bottom: var(--space-2);
}

.affiliate-widget__desc {
	font-size: var(--fs-xs);
	color: var(--color-text-muted);
	line-height: 1.6;
	margin-bottom: var(--space-4);
}

.affiliate-widget__btn {
	display: block;
	text-align: center;
	padding: var(--space-3) var(--space-4);
	font-size: var(--fs-sm);
	font-weight: 700;
	color: #fff;
	background: linear-gradient(135deg, #D97706, #F59E0B);
	border-radius: var(--radius-lg);
	transition: opacity var(--duration-fast);
}

.affiliate-widget__btn:hover { color: #fff; opacity: 0.9; }

/* ==========================================================================
   BUTTON SYSTEM
   ========================================================================== */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-2);
	padding: var(--space-3) var(--space-6);
	font-size: var(--fs-sm);
	font-weight: 700;
	font-family: var(--font-body);
	border-radius: var(--radius-lg);
	border: 2px solid transparent;
	cursor: pointer;
	transition: all var(--duration-fast) var(--ease-out);
	text-decoration: none;
	white-space: nowrap;
}

.btn:focus-visible {
	outline: 2px solid var(--color-primary);
	outline-offset: 2px;
}

.btn-primary {
	color: #fff;
	background: var(--color-primary);
	border-color: var(--color-primary);
}

.btn-primary:hover {
	color: #fff;
	background: var(--si-indigo-light);
	border-color: var(--si-indigo-light);
	transform: translateY(-1px);
	box-shadow: var(--shadow-md);
}

.btn-outline {
	color: var(--color-primary);
	background: transparent;
	border-color: var(--color-primary);
}

.btn-outline:hover {
	color: #fff;
	background: var(--color-primary);
}

.btn-ghost {
	color: var(--color-text-muted);
	background: transparent;
	border-color: transparent;
}

.btn-ghost:hover {
	color: var(--color-primary);
	background: var(--color-primary-glow);
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

.site-footer {
	background: var(--si-ink);
	color: #94A3B8;
	padding-block: var(--space-16) var(--space-8);
}

[data-theme="dark"] .site-footer {
	background: #040810;
}

.footer-grid {
	display: grid;
	grid-template-columns: 2fr repeat(3, 1fr);
	gap: var(--space-10);
	margin-bottom: var(--space-10);
}

@media (max-width: 767px) {
	.footer-grid {
		grid-template-columns: 1fr;
	}
}

.footer-brand .site-name {
	background: linear-gradient(135deg, #F1F5F9, var(--si-indigo-light));
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	margin-bottom: var(--space-3);
}

.footer-brand p {
	font-size: var(--fs-sm);
	line-height: 1.7;
	color: #64748B;
	margin-bottom: var(--space-5);
}

.footer-col__title {
	font-family: var(--font-display);
	font-size: var(--fs-xs);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #CBD5E1;
	margin-bottom: var(--space-4);
}

.footer-links li { margin-bottom: var(--space-2); }

.footer-links a {
	font-size: var(--fs-sm);
	color: #64748B;
	transition: color var(--duration-fast);
}

.footer-links a:hover { color: var(--si-indigo-light); }

.footer-bottom {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding-top: var(--space-8);
	border-top: 1px solid rgba(255, 255, 255, 0.06);
	font-size: var(--fs-xs);
	color: #475569;
	flex-wrap: wrap;
	gap: var(--space-4);
}

/* ==========================================================================
   THANKS PAGE
   ========================================================================== */

.thanks-page {
	min-height: 70vh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding-block: var(--space-16);
}

.thanks-card {
	text-align: center;
	max-width: 520px;
	padding: var(--space-12);
	background: var(--color-bg-card);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-2xl);
	box-shadow: var(--shadow-xl);
}

.thanks-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 80px;
	height: 80px;
	border-radius: 50%;
	background: rgba(99, 102, 241, 0.1);
	color: var(--color-primary);
	font-size: 2.5rem;
	margin-bottom: var(--space-6);
	margin-inline: auto;
	animation: pop-in 0.5s var(--ease-out) both;
}

@keyframes pop-in {
	from { transform: scale(0.5); opacity: 0; }
	to   { transform: scale(1);   opacity: 1; }
}

.thanks-card h1 {
	font-size: var(--fs-2xl);
	margin-bottom: var(--space-4);
}

.thanks-card p {
	color: var(--color-text-muted);
	margin-bottom: var(--space-6);
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

.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;
}

.text-center { text-align: center; }
.text-muted   { color: var(--color-text-muted); }

.mt-0  { margin-top: 0 !important; }
.mb-0  { margin-bottom: 0 !important; }

.honeypot-field { display: none !important; visibility: hidden !important; }

/* ==========================================================================
   PAGINATION
   ========================================================================== */

.pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-2);
	margin-top: var(--space-12);
}

.page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: var(--radius-md);
	font-size: var(--fs-sm);
	font-weight: 600;
	color: var(--color-text-muted);
	border: 1px solid var(--color-border);
	transition: all var(--duration-fast);
}

.page-numbers:hover,
.page-numbers.current {
	color: #fff;
	background: var(--color-primary);
	border-color: var(--color-primary);
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
	.site-header,
	.toc-sidebar,
	.sidebar-sticky-zone,
	.related-posts,
	.site-footer { display: none !important; }

	.single-layout {
		grid-template-columns: 1fr;
	}
}
