/* Shared Critical CSS - Above-Fold Only */
/* Manually curated for optimal performance (~7-8KB) */

/* Fonts - Inter 400 & 600 only */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/inter/inter-400.woff2') format('woff2');
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/fonts/inter/inter-600.woff2') format('woff2');
}

/* Brandon Grotesque for Headings */
@font-face {
    font-family: 'Brandon Grotesque';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/Brandon-Grotesque-Web-Regular.woff2') format('woff2');
}

/* CSS Variables - Essential for preventing FOUC */
:root {
    --color-primary: #1B5E20;
    --color-primary-light: #2E7D32;
    --color-primary-dark: #0D3D10;
    --color-secondary: #2E7D32;
    --color-text: #212121;
    --color-text-light: #666666;
    --color-text-lighter: #999999;
    --color-bg: #FFFFFF;
    --color-bg-light: #F8F9FA;
    --color-bg-section: #F5F5F5;
    --color-border: #E0E0E0;
    --color-border-light: #F0F0F0;
    --color-success: #4CAF50;
    --color-warning: #FF9800;
    --color-error: #F44336;
    --color-info: #2196F3;
    --font-family-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-family-headings: 'Brandon Grotesque', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-base: 1rem;
    --font-size-sm: 0.875rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.8;
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-base: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    --spacing-3xl: 4rem;
    --max-width: 1200px;
    --max-width-content: 800px;
    --container-padding: 1rem;
    --border-radius-sm: 4px;
    --border-radius-base: 8px;
    --border-radius-lg: 12px;
    --border-radius-xl: 16px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-base: 0 4px 6px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 20px rgba(46, 125, 50, 0.08), 0 2px 8px rgba(46, 125, 50, 0.06);
    --shadow-lg: 0 15px 25px rgba(46, 125, 50, 0.1), 0 5px 10px rgba(0, 0, 0, 0.05);
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
}

/* Dark Mode Variables */
html[data-theme="dark"] {
    /* Background Colors */
    --color-bg: #121212;
    --color-bg-light: #1E1E1E;
    --color-bg-section: #1A1A1A;

    /* Text Colors */
    --color-text: #E0E0E0;
    --color-text-light: #B0B0B0;
    --color-text-lighter: #808080;

    /* Primary Colors - Slightly lighter for dark mode */
    --color-primary: #4CAF50;
    --color-primary-light: #66BB6A;
    --color-primary-dark: #388E3C;

    /* Border Colors */
    --color-border: #333333;
    --color-border-light: #2A2A2A;
}

/* Box Model Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    line-height: var(--line-height-normal);
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family-base);
    font-size: var(--font-size-base);
    color: var(--color-text);
    background-color: var(--color-bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
    padding: var(--spacing-xl) 0;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-family-headings);
    font-weight: 600;
    line-height: var(--line-height-tight);
    color: var(--color-text);
    margin-bottom: var(--spacing-base);
}

h1 { font-size: var(--font-size-4xl); font-weight: 700; }
h2 { font-size: var(--font-size-3xl); }
p { margin-bottom: var(--spacing-base); }
a { color: var(--color-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-secondary); }

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

/* Header - Complete above-fold styling */
body > header {
    position: relative;
    background: linear-gradient(to right, #0f1410, #1a1d1f);
    height: 70px;
}

body > header::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.4' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.28;
    pointer-events: none;
}

body > header .logo,
body > header .logo:hover,
body > header .nav-menu a,
body > header .nav-menu a:hover,
body > header .nav-menu a.active,
body > header .search-link,
body > header .search-link:hover,
body > header .mobile-menu-toggle,
body > header .mobile-menu-toggle:hover,
body > header .theme-toggle,
body > header .theme-toggle:hover {
    color: #ffffff !important;
}

body > header .logo:hover,
body > header .nav-menu a:hover,
body > header .nav-menu a.active,
body > header .search-link:hover,
body > header .mobile-menu-toggle:hover,
body > header .theme-toggle:hover {
    color: #66BB6A !important;
}

.nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--container-padding);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
    position: relative;
    z-index: 1;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-family: var(--font-family-headings);
    font-size: var(--font-size-xl);
    font-weight: 700;
    text-decoration: none;
}

.logo-image {
    height: 32px;
    width: auto;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: var(--spacing-lg);
    align-items: center;
    margin: 0;
    padding: 0;
}

.nav-menu-desktop {
    display: flex;
}

.nav-menu li {
    margin: 0;
}

.nav-menu a {
    font-family: var(--font-family-headings);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-decoration: none;
    padding: var(--spacing-sm) var(--spacing-base);
}

.search-link {
    padding: var(--spacing-sm);
    display: inline-flex;
    align-items: center;
}

.search-link svg {
    width: 24px;
    height: 24px;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--spacing-sm);
    width: 44px;
    height: 44px;
}

.hamburger-icon {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 18px;
    height: 22px;
    gap: 5px;
}

.hamburger-line {
    width: 100%;
    height: 2px;
    background-color: currentColor;
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

.hamburger-line:nth-child(1),
.hamburger-line:nth-child(3) {
    width: 90%;
}

.nav-actions {
    display: none;
}

.search-link-mobile {
    display: none;
}

/* Mobile Menu Overlay - Glassmorphism Backdrop */
.mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Mobile Menu Drawer - Slide-in from Right */
.mobile-menu-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 85vw);
    background: linear-gradient(165deg,
            rgba(255, 255, 255, 0.98) 0%,
            rgba(248, 249, 250, 0.98) 50%,
            rgba(245, 247, 248, 0.98) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 3px solid var(--color-primary);
    box-shadow:
        -8px 0 32px rgba(0, 0, 0, 0.15),
        -4px 0 16px rgba(46, 125, 50, 0.08);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Noise texture overlay for premium feel */
.mobile-menu-drawer::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 0, 0, 0.015) 2px, rgba(0, 0, 0, 0.015) 4px);
    pointer-events: none;
    z-index: 1;
}

.mobile-menu-drawer.active {
    transform: translateX(0);
}

/* Mobile Menu Close Button */
.mobile-menu-close {
    position: absolute;
    top: var(--spacing-base);
    right: var(--spacing-base);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 2px solid rgba(76, 175, 80, 0.3);
    border-radius: var(--border-radius-sm);
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    opacity: 0;
    transform: scale(0.8) rotate(-90deg);
}

.mobile-menu-drawer.active .mobile-menu-close {
    animation: closeButtonAppear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s forwards;
}

@keyframes closeButtonAppear {
    from {
        opacity: 0;
        transform: scale(0.8) rotate(-90deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

.mobile-menu-close:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
    transform: rotate(90deg) scale(1.1);
}

.mobile-menu-close:active {
    transform: rotate(90deg) scale(0.95);
}

/* Mobile Menu Content Layout */
.mobile-menu-content {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding: clamp(4rem, 15vh, 6rem) var(--spacing-xl) var(--spacing-xl);
    position: relative;
    z-index: 2;
}

/* Mobile Menu Navigation */
.mobile-menu-nav {
    flex: 1;
}

.mobile-menu-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.mobile-menu-links li {
    margin: 0;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Staggered animation delays */
.mobile-menu-drawer.active .mobile-menu-links li:nth-child(1) {
    animation: menuItemFadeIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s forwards;
}

.mobile-menu-drawer.active .mobile-menu-links li:nth-child(2) {
    animation: menuItemFadeIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s forwards;
}

.mobile-menu-drawer.active .mobile-menu-links li:nth-child(3) {
    animation: menuItemFadeIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s forwards;
}

.mobile-menu-drawer.active .mobile-menu-links li:nth-child(4) {
    animation: menuItemFadeIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.25s forwards;
}

@keyframes menuItemFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mobile-menu-link {
    display: flex;
    align-items: center;
    font-family: var(--font-family-headings);
    font-size: clamp(1.125rem, 3vw, 1.25rem);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text);
    text-decoration: none;
    padding: var(--spacing-base) var(--spacing-base);
    border-radius: var(--border-radius-sm);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

/* Hover effect with background highlight */
.mobile-menu-link::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--color-primary);
    opacity: 0;
    transform: scaleX(0);
    transform-origin: left;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: -1;
    border-radius: var(--border-radius-sm);
}

.mobile-menu-link:hover,
.mobile-menu-link:focus-visible {
    color: white;
    transform: translateX(8px);
    text-decoration: none;
}

.mobile-menu-link:hover::before,
.mobile-menu-link:focus-visible::before {
    opacity: 1;
    transform: scaleX(1);
}

.mobile-menu-link.active {
    color: var(--color-primary);
    background: rgba(76, 175, 80, 0.1);
}

/* Mobile Menu Divider */
.mobile-menu-divider {
    height: 1px;
    background: linear-gradient(90deg,
            var(--color-primary) 0%,
            var(--color-border) 20%,
            var(--color-border) 80%,
            transparent 100%);
    margin: var(--spacing-lg) 0;
    opacity: 0;
    transform: scaleX(0);
    transform-origin: left;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mobile-menu-drawer.active .mobile-menu-divider {
    animation: dividerExpand 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s forwards;
}

@keyframes dividerExpand {
    from {
        opacity: 0;
        transform: scaleX(0);
    }

    to {
        opacity: 1;
        transform: scaleX(1);
    }
}

/* Mobile Menu Footer - Theme Toggle */
.mobile-menu-footer {
    padding-top: var(--spacing-base);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mobile-menu-drawer.active .mobile-menu-footer {
    animation: menuItemFadeIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.35s forwards;
}

.theme-toggle-mobile {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    width: 100%;
    padding: var(--spacing-base);
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.2);
    border-radius: var(--border-radius-base);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle-mobile:hover {
    background: rgba(76, 175, 80, 0.15);
    border-color: rgba(76, 175, 80, 0.3);
    transform: translateY(-2px);
}

.theme-toggle-label {
    font-family: var(--font-family-headings);
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Prevent body scroll when menu is open */
body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Dark Mode Mobile Menu Overrides */
html[data-theme="dark"] .mobile-menu-drawer {
    background: linear-gradient(165deg,
        rgba(30, 30, 30, 0.98) 0%,
        rgba(24, 24, 24, 0.98) 50%,
        rgba(18, 18, 18, 0.98) 100%);
    border-left: 3px solid var(--color-primary-light);
    box-shadow:
        -8px 0 32px rgba(0, 0, 0, 0.5),
        -4px 0 16px rgba(76, 175, 80, 0.15);
}

html[data-theme="dark"] .mobile-menu-drawer::before {
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 255, 255, 0.02) 2px, rgba(255, 255, 255, 0.02) 4px);
}

html[data-theme="dark"] .mobile-menu-link {
    color: rgba(255, 255, 255, 0.95);
}

html[data-theme="dark"] .mobile-menu-link:hover,
html[data-theme="dark"] .mobile-menu-link:focus-visible {
    color: white;
}

html[data-theme="dark"] .mobile-menu-link.active {
    color: var(--color-primary-light);
    background: rgba(76, 175, 80, 0.15);
}

html[data-theme="dark"] .mobile-menu-divider {
    background: linear-gradient(90deg,
        var(--color-primary-light) 0%,
        rgba(255, 255, 255, 0.15) 20%,
        rgba(255, 255, 255, 0.15) 80%,
        transparent 100%);
}

html[data-theme="dark"] .theme-toggle-label {
    color: rgba(255, 255, 255, 0.95);
}

html[data-theme="dark"] .mobile-menu-close {
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(76, 175, 80, 0.4);
}

html[data-theme="dark"] .mobile-menu-close:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

/* Desktop: Hide mobile menu elements */
@media (min-width: 769px) {

    .mobile-menu-overlay,
    .mobile-menu-drawer {
        display: none;
    }
}

/* Mobile responsive header */
@media (max-width: 768px) {
    body > header {
        height: 50px;
    }

    .nav-container {
        height: 50px;
    }

    .nav-actions {
        display: flex;
        align-items: center;
        gap: var(--spacing-xs);
    }

    .search-link-mobile {
        display: inline-flex;
    }

    .nav-menu-desktop {
        display: none;
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: var(--spacing-xs);
        margin-right: -8px;
    }
}

/* Search Page Hero - Above Fold */
.search-page {
    padding: var(--spacing-2xl) 0;
}

.search-header {
    text-align: center;
    margin-bottom: var(--spacing-2xl);
}

.search-header h1 {
    font-size: clamp(1.875rem, 5vw, 2.5rem);
    font-weight: 700;
    margin-bottom: var(--spacing-base);
    color: var(--color-text);
}

.search-header p {
    font-size: clamp(1rem, 2vw, 1.125rem);
    color: var(--color-text-light);
    max-width: 600px;
    margin: 0 auto var(--spacing-xl);
    line-height: var(--line-height-relaxed);
}

/* Popular Tags Pills */
.popular-tags {
    text-align: center;
    margin-bottom: var(--spacing-2xl);
}

.popular-tags h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--spacing-lg);
    color: var(--color-text);
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    justify-content: center;
    max-width: 700px;
    margin: 0 auto;
}

.tag-link {
    display: inline-block;
    padding: var(--spacing-sm) var(--spacing-lg);
    background: var(--color-primary);
    color: white;
    text-decoration: none;
    border-radius: 50px;
    font-size: var(--font-size-base);
    font-weight: 500;
    transition: all var(--transition-fast);
    border: 2px solid transparent;
}

.tag-link:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

/* Pagefind Search Container */
#pagefind-search {
    max-width: 800px;
    margin: 0 auto var(--spacing-2xl);
}

/* Dark mode overrides for search page */
html[data-theme="dark"] .tag-link {
    background: var(--color-primary);
    color: white;
}

html[data-theme="dark"] .tag-link:hover {
    background: var(--color-primary-light);
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--spacing-sm);
    display: inline-flex;
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
}

.theme-icon {
    display: none;
}

html[data-theme="light"] .theme-icon-sun,
html:not([data-theme]) .theme-icon-sun {
    display: block;
}

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