/* 
 * Convergence.ninja - Modern UI Styles
 * A modernized, clean design with smooth animations
 */

/* ===== CSS Variables ===== */
:root {
    /* Colors - Deep dark theme with red accents */
    --bg-primary: #0a0a0a;
    --bg-secondary: #121212;
    --bg-card: #1a1a1a;
    --bg-card-hover: #222222;
    --bg-elevated: #1f1f1f;
    
    --text-primary: #ffffff;
    --text-secondary: #b8b8b8;
    --text-muted: #6a6a6a;
    
    --accent-primary: #dc2626;
    --accent-secondary: #ef4444;
    --accent-glow: rgba(220, 38, 38, 0.3);
    --accent-gradient: linear-gradient(135deg, #991b1b 0%, #dc2626 100%);
    
    /* Ninja red accent */
    --ninja-red: #dc2626;
    --ninja-red-dark: #991b1b;
    
    /* Spacing & Sizing */
    --container-max: 1100px;
    --header-height: 70px;
    
    /* Effects */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px var(--accent-glow);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.65;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Subtle gradient background */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(220, 38, 38, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(220, 38, 38, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: clamp(1.4rem, 3vw, 2rem);
    margin-top: 1.5rem;
}

p {
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

a {
    color: var(--accent-secondary);
    text-decoration: none;
    transition: color var(--transition-base);
}

a:hover {
    color: var(--accent-primary);
}

code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--bg-elevated);
    padding: 0.2em 0.5em;
    border-radius: var(--radius-sm);
    color: var(--accent-secondary);
}

pre {
    background: var(--bg-elevated);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 1.5rem 0;
    border: 1px solid rgba(220, 38, 38, 0.2);
}

pre code {
    background: transparent;
    padding: 0;
}

blockquote {
    border-left: 3px solid var(--accent-primary);
    padding-left: 1.25rem;
    margin: 1.5rem 0;
    color: var(--text-secondary);
    font-style: italic;
    background: linear-gradient(90deg, rgba(220, 38, 38, 0.1) 0%, transparent 100%);
    padding: 1rem 1.25rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ===== Layout ===== */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

main {
    flex: 1;
    padding-top: calc(var(--header-height) + 2rem);
}

/* ===== Header ===== */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid rgba(220, 38, 38, 0.1);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: var(--container-max);
    padding: 0 1.5rem;
}

.logo-container a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: transform var(--transition-base);
}

.logo-container a:hover {
    transform: scale(1.02);
}

.logo {
    height: 42px;
    width: 42px;
    border-radius: var(--radius-sm);
    transition: transform var(--transition-base);
}

.site-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 0 0 20px rgba(220, 38, 38, 0.3);
}

nav ul {
    display: flex;
    list-style: none;
    gap: 0.5rem;
}

nav a {
    display: inline-block;
    padding: 0.6rem 1.1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    position: relative;
}

nav a:hover,
nav a.active {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

nav a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--accent-gradient);
    transition: all var(--transition-base);
    transform: translateX(-50%);
}

nav a:hover::after,
nav a.active::after {
    width: 70%;
    background: var(--accent-gradient);
}

/* ===== Home Page ===== */
.home-container {
    animation: fadeInUp 0.6s ease-out;
}

.home-container h1 {
    text-align: center;
    margin-bottom: 1.5rem;
}

/* Sort Options */
.sort-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.sort-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0 0.5rem;
}

.sort-option {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-base);
}

.sort-option:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.sort-option.active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-md);
}

/* Post Grid */
.post-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.post-card {
    background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-card-hover) 100%);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-base);
    position: relative;
}

.post-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(220, 38, 38, 0.3);
}

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

.post-link {
    display: block;
    padding: 1.5rem;
    color: inherit;
}

.post-title {
    font-size: 1.15rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    transition: color var(--transition-base);
}

.post-link:hover .post-title {
    color: var(--accent-secondary);
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.post-date, .post-views {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.post-views {
    background: rgba(220, 38, 38, 0.1);
    padding: 0.25rem 0.6rem;
    border-radius: 99px;
    color: var(--accent-secondary);
}

.no-posts {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
}

/* ===== Post Page ===== */
.blog-post {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: clamp(1.5rem, 4vw, 2.5rem);
    border: 1px solid rgba(255, 255, 255, 0.05);
    animation: fadeInUp 0.5s ease-out;
}

.post-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.post-content {
    color: var(--text-secondary);
}

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: 1.5rem 0;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.post-content a {
    color: var(--accent-secondary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.post-content a:hover {
    color: var(--accent-primary);
}

/* ===== About Page ===== */
.about-container {
    animation: fadeInUp 0.6s ease-out;
}

.about-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* ===== Footer ===== */
footer {
    background: var(--bg-secondary);
    padding: 2rem 1.5rem;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: auto;
}

footer p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--accent-gradient);
    color: white;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(220, 38, 38, 0.4);
}

/* ===== Error Page ===== */
.error-message {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.error-message h2 {
    font-size: 3rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Animations ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Loading animation */
.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .header-content {
        padding: 0 1rem;
    }
    
    .site-title {
        font-size: 1.1rem;
    }
    
    .logo {
        height: 36px;
        width: 36px;
    }
    
    nav ul {
        gap: 0.25rem;
    }
    
    nav a {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .container {
        padding: 1.5rem 1rem;
    }
    
    .post-list {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .sort-container {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .post-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    nav ul {
        gap: 0.1rem;
    }
    
    nav a {
        padding: 0.4rem 0.5rem;
        font-size: 0.8rem;
    }
}

/* ===== Utility Classes ===== */
.text-gradient {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glow {
    box-shadow: var(--shadow-glow);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* ===== Post Page - Sticky Header Support ===== */
/* Ensure the header stays visible while scrolling through blog posts */
.post-container {
    /* Add padding to account for fixed header */
    padding-top: calc(var(--header-height) + 2rem);
    padding-bottom: 2rem;
}

.blog-post {
    /* Post content scrolls independently under fixed header */
    max-width: 100%;
}

/* Ensure blog post content area is properly positioned */
.post-content {
    margin-top: 1rem;
}
