/* ============================================================================
   EigenCode AI — Main Stylesheet
   3-Layer Architecture: theme.json tokens → variable scoping → selector overrides
   ============================================================================ */

/* == Layer 2: CSS Variable Scoping ========================================= */

:root {
	--ec-glass-bg: rgba(15, 23, 41, 0.7);
	--ec-glass-border: rgba(59, 130, 246, 0.12);
	--ec-glass-border-hover: rgba(59, 130, 246, 0.3);
	--ec-glass-blur: 12px;
	--ec-glow-blue: rgba(59, 130, 246, 0.15);
	--ec-glow-cyan: rgba(6, 214, 160, 0.1);
	--ec-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	--ec-shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
	--ec-shadow-glow: 0 0 20px var(--ec-glow-blue);
}

/* == Layer 3: Global Resets & Base ========================================== */

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

html { scroll-behavior: smooth; }

body {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

::selection {
	background: var(--wp--preset--color--secondary);
	color: #ffffff;
}

img { max-width: 100%; height: auto; }

/* == Double-Stack Navbar ==================================================== */

.ec-header {
	position: sticky;
	top: 0;
	z-index: 1000;
}

.ec-header__top-bar {
	transition: max-height var(--ec-transition), opacity var(--ec-transition), padding var(--ec-transition);
	max-height: 50px;
	overflow: hidden;
}

.ec-header--scrolled .ec-header__top-bar {
	max-height: 0;
	opacity: 0;
	padding-top: 0 !important;
	padding-bottom: 0 !important;
	border-bottom-width: 0 !important;
}

/*
 * Glass blur on scroll: applied via ::before pseudo-element so the main-bar
 * itself never gets backdrop-filter (which would create a containing block
 * and trap position:fixed descendants like the mobile overlay).
 */
.ec-header__main-bar {
	position: relative;
}

.ec-header__main-bar::before {
	content: '';
	position: absolute;
	inset: 0;
	z-index: -1;
	transition: backdrop-filter var(--ec-transition), background-color var(--ec-transition), opacity var(--ec-transition);
	backdrop-filter: blur(16px) saturate(180%);
	-webkit-backdrop-filter: blur(16px) saturate(180%);
	background-color: rgba(11, 17, 32, 0.92);
	opacity: 0;
	pointer-events: none;
}

.ec-header--scrolled .ec-header__main-bar::before {
	opacity: 1;
}

.ec-header__divider {
	opacity: 0.3;
	user-select: none;
}

.ec-header__site-title a {
	background: linear-gradient(135deg, var(--wp--preset--color--text) 0%, var(--wp--preset--color--secondary-light) 100%);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
}

.ec-header__cta .wp-block-button__link {
	transition: transform var(--ec-transition), box-shadow var(--ec-transition);
}

.ec-header__cta .wp-block-button__link:hover {
	transform: translateY(-1px);
	box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
}

.ec-nav-highlight a {
	color: var(--wp--preset--color--accent) !important;
	font-weight: 600 !important;
}

/*
 * When mobile overlay is open, neutralize all CSS properties on ancestors
 * that create containing blocks for position:fixed descendants.
 *
 * Primary: CSS :has() fires synchronously (same render frame as is-menu-open).
 * Fallback: .ec-menu-open class toggled by main.js MutationObserver.
 */
.ec-header:has(.is-menu-open),
.ec-header:has(.is-menu-open) .ec-header__top-bar,
.ec-header:has(.is-menu-open) .ec-header__main-bar,
.ec-header:has(.is-menu-open) .ec-header__main-layout,
.ec-header.ec-menu-open,
.ec-menu-open .ec-header__top-bar,
.ec-menu-open .ec-header__main-bar,
.ec-menu-open .ec-header__main-layout {
	position: static !important;
	transform: none !important;
	filter: none !important;
	backdrop-filter: none !important;
	-webkit-backdrop-filter: none !important;
	will-change: auto !important;
	perspective: none !important;
	contain: none !important;
	overflow: visible !important;
}

/* == Mobile Navigation =====================================================
 *
 * WordPress block navigation overlay DOM structure:
 *   .wp-block-navigation__responsive-container        (overlay root)
 *     └ .wp-block-navigation__responsive-close         (a11y focus-trap wrapper)
 *         └ .wp-block-navigation__responsive-dialog     (dialog container)
 *             ├ button.__responsive-container-close      (close X button)
 *             └ div.__responsive-container-content       (nav link list)
 *
 * WordPress adds inline styles when the menu opens, so !important is needed
 * on the overlay root. Child elements use normal specificity where possible.
 * ========================================================================== */

/* -- Mobile header layout ------------------------------------------------- */
@media (max-width: 768px) {
	.ec-header__phone,
	.ec-header__divider { display: none; }
	.ec-header__cta { display: none !important; }

	.ec-header__main-layout {
		display: flex !important;
		justify-content: space-between !important;
		width: 100%;
	}

	.ec-header__nav {
		order: 99;
		flex: 0 0 auto;
	}

	.wp-block-navigation__responsive-container-open {
		background: transparent !important;
		border: none !important;
		cursor: pointer;
	}
}

/* -- 1. Overlay root — dark background + symmetric padding ----------------
 *    .ec-menu-open on the header neutralizes containing-block properties
 *    (position, backdrop-filter, overflow) so position:fixed works.
 *    Scoped under .ec-header for specificity over WP core.
 * ------------------------------------------------------------------------- */
.ec-header .wp-block-navigation__responsive-container.is-menu-open {
	position: fixed !important;
	inset: 0 !important;
	width: 100% !important;
	height: 100% !important;
	display: flex !important;
	flex-direction: column !important;
	background: linear-gradient(180deg, #060A13 0%, #0B1120 100%) !important;
	padding: 2rem !important;
	z-index: 100000 !important;
	overflow: auto !important;
}

/* -- 2. Content — center nav items vertically and horizontally ------------ */
.ec-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
	align-items: center !important;
	justify-content: center !important;
	flex: 1;
	padding-top: calc(2rem + 24px);
}

/* -- 3. Close button — styled, WP core handles position:absolute ---------- */
.ec-header .wp-block-navigation__responsive-container-close svg {
	fill: var(--wp--preset--color--muted);
	stroke: var(--wp--preset--color--muted);
	width: 28px;
	height: 28px;
	transition: fill 0.2s ease, stroke 0.2s ease;
}

.ec-header .wp-block-navigation__responsive-container-close:hover svg {
	fill: var(--wp--preset--color--text);
	stroke: var(--wp--preset--color--text);
}

/* -- 4. Nav items — centered text + themed typography --------------------- */
.ec-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item {
	text-align: center;
}

.ec-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item a {
	color: var(--wp--preset--color--text);
	font-size: 1.6rem;
	font-weight: 500;
	letter-spacing: 0.02em;
	padding: 0.9rem 2rem;
	display: block;
	text-decoration: none;
	border-radius: 8px;
	transition: background 0.25s ease, color 0.25s ease;
}

.ec-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item a:hover {
	background: rgba(59, 130, 246, 0.1);
	color: var(--wp--preset--color--secondary);
}

.ec-header .wp-block-navigation__responsive-container.is-menu-open .ec-nav-highlight a {
	color: var(--wp--preset--color--accent);
	font-weight: 600;
}

/* == Glass-Morphism Cards =================================================== */

.is-style-ec-glass-card {
	background: var(--ec-glass-bg) !important;
	backdrop-filter: blur(var(--ec-glass-blur));
	-webkit-backdrop-filter: blur(var(--ec-glass-blur));
	border: 1px solid var(--ec-glass-border) !important;
	border-radius: 12px;
	transition: border-color var(--ec-transition), transform var(--ec-transition), box-shadow var(--ec-transition);
}

.is-style-ec-glass-card:hover {
	border-color: var(--ec-glass-border-hover) !important;
	transform: translateY(-4px);
	box-shadow: 0 8px 32px rgba(59, 130, 246, 0.15);
}

.is-style-ec-neon-glow {
	border: 1px solid var(--ec-glass-border);
	border-radius: 12px;
	box-shadow: var(--ec-shadow-glow);
}

.is-style-ec-data-card {
	background: var(--ec-glass-bg);
	border: 1px solid var(--ec-glass-border);
	border-radius: 12px;
	position: relative;
	overflow: hidden;
}

.is-style-ec-data-card::before {
	content: '';
	position: absolute;
	inset: 0;
	background-image: radial-gradient(circle at 1px 1px, rgba(59, 130, 246, 0.06) 1px, transparent 0);
	background-size: 24px 24px;
	pointer-events: none;
}

.is-style-ec-dark-section {
	background: var(--wp--preset--color--background) !important;
}

.is-style-ec-surface-card {
	background: var(--wp--preset--color--surface) !important;
	border: 1px solid var(--ec-glass-border);
	border-radius: 12px;
	box-shadow: var(--ec-shadow-card);
}

/* == Heading Styles ========================================================= */

.is-style-ec-accent-underline {
	position: relative;
	display: inline-block;
	padding-bottom: 12px;
}

.is-style-ec-accent-underline::after {
	content: '';
	position: absolute;
	bottom: 0;
	left: 0;
	width: 60px;
	height: 3px;
	background: linear-gradient(90deg, var(--wp--preset--color--secondary), var(--wp--preset--color--accent));
	border-radius: 2px;
}

.is-style-ec-centered-accent {
	text-align: center;
	position: relative;
	padding-bottom: 16px;
}

.is-style-ec-centered-accent::after {
	content: '';
	position: absolute;
	bottom: 0;
	left: 50%;
	transform: translateX(-50%);
	width: 60px;
	height: 3px;
	background: linear-gradient(90deg, var(--wp--preset--color--secondary), var(--wp--preset--color--accent));
	border-radius: 2px;
}

/* == Button Styles ========================================================== */

.is-style-ec-outline-neon .wp-block-button__link {
	background: transparent !important;
	border: 2px solid var(--wp--preset--color--secondary) !important;
	color: var(--wp--preset--color--secondary) !important;
	transition: all var(--ec-transition);
}

.is-style-ec-outline-neon .wp-block-button__link:hover {
	background: rgba(59, 130, 246, 0.1) !important;
	box-shadow: 0 0 20px rgba(59, 130, 246, 0.2);
}

.is-style-ec-accent-button .wp-block-button__link {
	background: var(--wp--preset--color--accent) !important;
	color: #0B1120 !important;
	font-weight: 700;
}

.is-style-ec-accent-button .wp-block-button__link:hover {
	background: var(--wp--preset--color--accent-light) !important;
	box-shadow: 0 0 20px var(--ec-glow-cyan);
}

.is-style-ec-dark-button .wp-block-button__link {
	background: var(--wp--preset--color--primary) !important;
	border: 1px solid var(--ec-glass-border) !important;
	color: var(--wp--preset--color--text) !important;
}

/* == Code Display =========================================================== */

.is-style-ec-code-display {
	background: var(--wp--preset--color--background) !important;
	border-left: 3px solid var(--wp--preset--color--secondary) !important;
	box-shadow: inset 0 0 30px rgba(6, 214, 160, 0.03);
	position: relative;
}

.is-style-ec-code-display::before {
	content: '>';
	position: absolute;
	top: 12px;
	left: 12px;
	color: var(--wp--preset--color--accent);
	font-family: var(--wp--preset--font-family--mono);
	font-size: 0.75rem;
	opacity: 0.5;
}

/* == Image & Separator Styles =============================================== */

.is-style-ec-glow-shadow img {
	box-shadow: 0 8px 40px rgba(59, 130, 246, 0.2);
	border-radius: 8px;
}

.is-style-ec-neon-separator {
	border: none !important;
	height: 2px !important;
	background: linear-gradient(90deg, transparent 0%, var(--wp--preset--color--secondary) 30%, var(--wp--preset--color--accent) 70%, transparent 100%) !important;
}

/* == Card Grid ============================================================== */

.is-style-ec-card-grid > .wp-block-column {
	display: flex;
	flex-direction: column;
}

.is-style-ec-card-grid > .wp-block-column > .wp-block-group {
	flex: 1;
}

/* == Animated Counters ====================================================== */

.ec-counter {
	text-align: center;
	padding: 1.5rem 1rem;
	border-top: 2px solid var(--wp--preset--color--secondary);
}

.ec-counter__value {
	display: block;
	font-family: var(--wp--preset--font-family--mono);
	font-size: clamp(1.75rem, 1.5rem + 1vw, 2.5rem);
	font-weight: 800;
	color: var(--wp--preset--color--text);
	line-height: 1.2;
}

.ec-counter__label {
	display: block;
	font-size: 0.8rem;
	color: var(--wp--preset--color--muted);
	margin-top: 0.5rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	font-weight: 500;
}

/* == Score Badge ============================================================ */

.ec-score-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 12px;
	border-radius: 20px;
	font-size: 0.8rem;
	font-weight: 700;
	font-family: var(--wp--preset--font-family--mono);
}

.ec-score-badge--success {
	background: rgba(74, 222, 128, 0.15);
	color: var(--wp--preset--color--success);
	border: 1px solid rgba(74, 222, 128, 0.3);
}

.ec-score-badge--warning {
	background: rgba(251, 191, 36, 0.15);
	color: #FBBF24;
	border: 1px solid rgba(251, 191, 36, 0.3);
}

.ec-score-badge--danger {
	background: rgba(248, 113, 113, 0.15);
	color: var(--wp--preset--color--danger);
	border: 1px solid rgba(248, 113, 113, 0.3);
}

.ec-score-badge__label {
	font-family: var(--wp--preset--font-family--body);
	font-weight: 500;
	text-transform: uppercase;
	font-size: 0.65rem;
	letter-spacing: 0.04em;
}

/* == Breadcrumbs ============================================================ */

.ec-breadcrumbs {
	padding: 0.75rem 0;
	font-size: 0.8rem;
}

.ec-breadcrumbs__list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	list-style: none;
	padding: 0;
	margin: 0;
}

.ec-breadcrumbs__item + .ec-breadcrumbs__item::before {
	content: '/';
	margin-right: 0.5rem;
	color: var(--wp--preset--color--muted);
	opacity: 0.5;
}

.ec-breadcrumbs__item a {
	color: var(--wp--preset--color--muted);
	text-decoration: none;
}

.ec-breadcrumbs__item a:hover {
	color: var(--wp--preset--color--secondary);
}

.ec-breadcrumbs__item:last-child span {
	color: var(--wp--preset--color--text);
}

/* == Footer ================================================================= */

.ec-footer-list {
	list-style: none !important;
}

.ec-footer-list li a {
	color: var(--wp--preset--color--muted);
	text-decoration: none;
	transition: color var(--ec-transition);
}

.ec-footer-list li a:hover {
	color: var(--wp--preset--color--secondary);
}

/* == Scroll Reveal Animation ================================================ */

.ec-reveal {
	opacity: 0;
	transform: translateY(20px);
	transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.ec-reveal.ec-visible {
	opacity: 1;
	transform: translateY(0);
}

/* == Utility Classes ======================================================== */

.ec-text-gradient {
	background: linear-gradient(135deg, var(--wp--preset--color--secondary) 0%, var(--wp--preset--color--accent) 100%);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
}

.ec-badge {
	display: inline-block;
	padding: 2px 10px;
	border-radius: 4px;
	font-size: 0.7rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

.ec-badge--blue {
	background: rgba(59, 130, 246, 0.15);
	color: var(--wp--preset--color--secondary);
	border: 1px solid rgba(59, 130, 246, 0.25);
}

.ec-badge--cyan {
	background: rgba(6, 214, 160, 0.15);
	color: var(--wp--preset--color--accent);
	border: 1px solid rgba(6, 214, 160, 0.25);
}

.ec-badge--red {
	background: rgba(248, 113, 113, 0.15);
	color: var(--wp--preset--color--danger);
	border: 1px solid rgba(248, 113, 113, 0.25);
}

/* == Responsive ============================================================= */

@media (max-width: 1024px) {
	.ec-header__top-bar .wp-block-group {
		flex-wrap: wrap;
		gap: 0.5rem;
	}
}

@media (max-width: 768px) {
	.ec-header__top-bar {
		display: none !important;
	}

	.ec-header__main-bar {
		backdrop-filter: blur(16px);
		-webkit-backdrop-filter: blur(16px);
		background-color: rgba(11, 17, 32, 0.95) !important;
	}
}

@media (max-width: 480px) {
	.ec-counter__value {
		font-size: 1.5rem;
	}
}
