/**
 * Critical CSS - Essential styles for initial page load
 * Contains: Above-the-fold styles, core layout, variables, header
 * Inlined in HTML for fastest possible rendering
 */

@import url('/css/fonts.css');

/* CSS Variables for theme switching */
:root {
    /* Light mode colors */
    --bg-gradient: linear-gradient(135deg, #d4af37 0%, #ffd700 25%, #ff6b35 75%, #dc143c 100%);
    --text-primary: #2c1810;
    --text-secondary: #444;
    --text-accent: #dc143c;
    --header-bg: linear-gradient(90deg, #dc143c 0%, #8b0000 100%);
    --header-text: #ffd700;
    --footer-bg: linear-gradient(90deg, #8b0000 0%, #dc143c 100%);
    --card-bg: rgba(255, 255, 255, 0.95);
    --card-shadow: rgba(0, 0, 0, 0.1);
    --border-color: #ffd700;
    --loading-bg: rgba(255, 255, 255, 0.8);
    --text-accent-rgb: 220, 20, 60;
    --title-shadow: 2px 2px 0px #ffd700;
}

/* Dark mode - Soviet Space Era theme */
[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 25%, #16213e 75%, #0f0f0f 100%);
    --text-primary: #e0e0e0;
    --text-secondary: #c0c0c0;
    --text-accent: #ff6b6b;
    --header-bg: linear-gradient(90deg, #0d0d0d 0%, #2a2a4e 50%, #0d0d0d 100%);
    --header-text: #ffd700;
    --footer-bg: linear-gradient(90deg, #0d0d0d 0%, #2a2a4e 100%);
    --card-bg: rgba(26, 26, 46, 0.95);
    --card-shadow: rgba(255, 215, 0, 0.1);
    --border-color: #ffd700;
    --loading-bg: rgba(26, 26, 46, 0.9);
    --text-accent-rgb: 255, 107, 107;
    --title-shadow: 2px 2px 0px #1a1a2e;
}

/* Base styles - Critical for LCP */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto Condensed', 'Arial Narrow', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-gradient);
    background-attachment: fixed;
    min-height: 100vh;
    transition: all 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Typography - Critical for LCP */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Bebas Neue', sans-serif;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

a {
    color: var(--text-accent);
    text-decoration: none;
    transition: all 0.3s ease;
}

a:hover {
    color: var(--header-text);
}

/* Header - Critical for above-the-fold */
header {
    background: var(--header-bg);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    position: sticky;
    top: 0;
    z-index: 1000;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 20px;
}

header h1 {
    font-size: 2.5rem;
    margin: 0;
    transform: skew(-5deg);
    transition: all 0.3s ease;
}

header h1 a {
    color: var(--header-text);
    text-decoration: none;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
    letter-spacing: 3px;
}

header h1:hover {
    transform: skew(-5deg) scale(1.05);
}

/* Navigation - Critical */
nav {
    display: flex;
    align-items: center;
    gap: 2rem;
}

nav a {
    color: var(--header-text);
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.5rem 1rem;
    border: 2px solid transparent;
    transform: skew(-3deg);
    transition: all 0.3s ease;
}

nav a:hover {
    color: var(--text-primary);
    background: var(--header-text);
    border-color: var(--header-text);
    transform: skew(-3deg) scale(1.1);
}

/* Dark mode toggle - Critical */
.dark-mode-toggle {
    background: none;
    border: 2px solid var(--header-text);
    color: var(--header-text);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    transform: skew(-5deg);
}

.dark-mode-toggle::before {
    content: '☀';
    font-size: 1.2rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

[data-theme="dark"] .dark-mode-toggle::before {
    content: '🌙';
}

.dark-mode-toggle:hover {
    background: var(--header-text);
    color: var(--text-primary);
    transform: skew(-5deg) scale(1.1);
}

/* Main content container - Critical */
main {
    padding: 0;
}

/* Footer - Critical - Optimized for CLS */
footer {
    background: var(--footer-bg);
    color: var(--header-text);
    padding: 2rem 0;
    margin-top: 4rem;
    min-height: 120px; /* Prevent layout shift by reserving space */
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    min-height: 60px; /* Additional stability */
}

.footer-content p {
    margin: 0; /* Prevent margin collapse */
    min-height: 1.5em; /* Consistent text height */
}

.footer-nav {
    display: flex;
    gap: 2rem;
}

.footer-nav a {
    color: var(--header-text);
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    display: inline-block; /* Stable layout */
    min-height: 1.5em; /* Prevent height changes */
}

.footer-nav a:hover {
    color: var(--text-accent);
    transform: translateY(-2px);
}

/* Search Component - Critical for above fold */
.header-search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 400px;
    margin: 0 2rem;
}

.search-input {
    width: 100%;
    padding: 0.75rem 3rem 0.75rem 1.5rem;
    background: var(--card-bg);
    border: 3px solid var(--text-accent);
    border-radius: 0;
    color: var(--text-primary);
    font-family: 'Roboto Condensed', sans-serif;
    font-size: 1rem;
    transform: skew(-2deg);
    transition: all 0.3s ease;
    outline: none;
}

.search-input:focus {
    border-color: var(--header-text);
    transform: skew(-2deg) scale(1.02);
}

.search-input::placeholder {
    color: var(--text-secondary);
    font-style: italic;
}

.search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-accent);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    transition: all 0.3s ease;
    z-index: 10;
}

.search-clear:hover {
    color: var(--header-text);
    transform: translateY(-50%) scale(1.2);
}

/* Loading state - Critical */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    flex-direction: column;
    gap: 1rem;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--card-bg);
    border-top: 4px solid var(--text-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Blog grid - Critical for LCP */
#blog-posts.blog-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)) !important;
    gap: 2rem !important;
    margin-top: 2rem;
    width: 100%;
    opacity: 1;
    transform: translateY(0);
    transition: all 0.6s ease;
}

/* Blog cards - Critical for LCP */
.blog-card {
    background: var(--card-bg);
    color: var(--text-primary);
    font-family: 'Roboto Condensed', sans-serif;
    border: 3px solid var(--text-accent);
    box-shadow: 8px 8px 0px var(--text-accent);
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    transform: skew(-1deg);
}

.blog-card:hover {
    transform: skew(-1deg) translateY(-5px);
    box-shadow: 12px 12px 0px var(--text-accent);
    border-color: var(--border-color);
}

.blog-card-content {
    padding: 1.5rem;
    transform: skew(1deg);
}

.blog-card-content h2 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.8rem;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* About Page - Critical sections */
.about-hero {
    background: linear-gradient(45deg, #dc143c 0%, #b91c1c 30%, #dc143c 70%, #b91c1c 100%);
    padding: 3rem 2rem;
    text-align: center;
    color: var(--header-text);
    margin: 2rem 0 2rem 0;
    box-shadow: 10px 10px 0px #8b0000;
    border: 4px solid var(--border-color);
    position: relative;
    transform: skew(-2deg);
}

.about-hero h1 {
    font-size: 3rem;
    margin: 0 0 1rem 0;
    font-family: 'Bebas Neue', sans-serif;
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 2px 2px 0px #8b0000;
    color: var(--header-text);
}

.hero-subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    font-family: 'Roboto Condensed', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--header-text);
    margin: 0;
}

.about-content {
    margin: 0 auto;
    padding: 0 2rem;
}

.about-intro {
    text-align: center;
    margin-bottom: 3rem;
}

.about-intro h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-family: 'Bebas Neue', sans-serif;
}

.about-intro p {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 1rem;
}

.about-intro .highlight {
    color: var(--text-accent);
    font-weight: bold;
}

.about-section {
    margin-bottom: 3rem;
    padding: 2rem;
    background: var(--card-bg);
    border: 2px solid var(--text-accent);
    transform: skew(-1deg);
    box-shadow: 5px 5px 0px var(--text-accent);
}

.about-section h3 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.8rem;
    color: var(--text-accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 1.5rem;
    transform: skew(1deg);
}

.about-section p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1rem;
    font-size: 1rem;
}

/* Responsive - Critical */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    header .container {
        padding: 1rem 15px;
        flex-direction: column;
        gap: 1rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    nav {
        gap: 1rem;
    }
    
    #blog-posts.blog-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
    
    .blog-card {
        transform: skew(0deg);
    }
    
    .blog-card:hover {
        transform: skew(0deg) translateY(-3px);
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
        transform: skew(0deg);
    }
    
    nav a {
        transform: skew(0deg);
        font-size: 1rem;
        padding: 0.5rem;
    }
    
    .dark-mode-toggle {
        transform: skew(0deg);
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
    
    .header-search {
        margin: 0;
        max-width: 100%;
        order: 2;
        width: 100%;
    }
    
    .search-input {
        transform: skew(0deg);
        font-size: 0.9rem;
    }
    
    .search-input:focus {
        transform: skew(0deg);
    }
    
    .about-content {
        padding: 0 1rem;
    }
    
    .about-section {
        padding: 1.5rem;
        margin-bottom: 2rem;
        transform: skew(0deg);
    }
    
    .about-section h3 {
        transform: skew(0deg);
    }
    
    .about-hero {
        padding: 2rem 1rem;
        transform: skew(0deg);
    }
    
    .about-hero h1 {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .about-intro h2 {
        font-size: 1.5rem;
    }
    
    .about-section {
        padding: 1rem;
    }
    
    .about-section h3 {
        font-size: 1.5rem;
    }
    
    .about-hero {
        padding: 1.5rem 0.75rem;
    }
    
    .about-hero h1 {
        font-size: 1.5rem;
        letter-spacing: 1px;
    }
    
    .hero-subtitle {
        font-size: 0.9rem;
    }
}