/* ==================== THEME SYSTEM ==================== */

/* Dark Theme (Default) */
:root[data-theme="dark"] {
    --bg-dark: #0f0f11;
    --bg-card: #161618;
    --bg-elevated: #1e1e20;
    --text-main: #ffffff;
    --text-muted: #888888;
    --text-dim: #666666;
    --accent: #f5a623;
    --accent-dim: rgba(245, 166, 35, 0.08);
    --accent-hover: #ffa500;
    --border-light: rgba(255, 255, 255, 0.08);
    --border-medium: rgba(255, 255, 255, 0.12);
    --code-bg: #1a1a1d;
    --shadow: rgba(0, 0, 0, 0.5);
    --shadow-lg: rgba(0, 0, 0, 0.7);
}

/* Light Theme */
:root[data-theme="light"] {
    --bg-dark: #ffffff;
    --bg-card: #f8f9fa;
    --bg-elevated: #ffffff;
    --text-main: #1a1a1a;
    --text-muted: #666666;
    --text-dim: #999999;
    --accent: #f5a623;
    --accent-dim: rgba(245, 166, 35, 0.08);
    --accent-hover: #e69500;
    --border-light: rgba(0, 0, 0, 0.08);
    --border-medium: rgba(0, 0, 0, 0.12);
    --code-bg: #f5f5f5;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
}

/* Common variables (both themes) */
:root {
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-serif: 'Georgia', serif;
    --transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-fast: all 0.15s ease;
}

/* Smooth theme transition */
* {
    transition: background-color 0.3s ease, 
                border-color 0.3s ease, 
                color 0.3s ease,
                box-shadow 0.3s ease;
}

/* Prevent transition on page load */
.preload * {
    transition: none !important;
}

/* ==================== THEME TOGGLE BUTTON ==================== */

.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    margin-left: 1rem;
}

.theme-toggle:hover {
    border-color: var(--accent);
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--accent-dim);
}

.theme-icon {
    position: absolute;
    font-size: 1.2rem;
    transition: var(--transition);
}

/* Show/hide icons based on theme */
[data-theme="dark"] .sun-icon {
    opacity: 0;
    transform: rotate(180deg) scale(0);
}

[data-theme="dark"] .moon-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

[data-theme="light"] .sun-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

[data-theme="light"] .moon-icon {
    opacity: 0;
    transform: rotate(-180deg) scale(0);
}

/* ==================== BASE STYLES ==================== */

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    padding-bottom: 4rem;
}

a { 
    text-decoration: none; 
    color: inherit; 
}

/* ==================== NAVIGATION ==================== */

nav {
    padding: 2rem 0;
    max-width: 1000px;
    margin: 0 auto 4rem auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-inline: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.logo {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.5px;
    color: var(--text-main);
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.nav-links a:hover {
    color: var(--accent);
    transition: var(--transition);
}

/* ==================== HEADER SECTION ==================== */

.page-header {
    max-width: 1000px;
    margin: 0 auto 3rem auto;
    padding-inline: 1.5rem;
}

.page-header h1 {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.page-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 600px;
}

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

.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    max-width: 1000px;
    margin: 0 auto;
    padding-inline: 1.5rem;
}

/* ==================== CARD DESIGN ==================== */

.blog-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    padding: 2rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 320px;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.blog-card:hover {
    transform: translateY(-5px);
    border-color: rgba(245, 166, 35, 0.4);
    box-shadow: 0 10px 30px -10px var(--shadow-lg);
}

/* Hover Glow Effect */
.blog-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(800px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(245, 166, 35, 0.08), transparent 40%);
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
}

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

/* Card Content */
.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: monospace;
}

.category-tag {
    color: var(--accent);
    background: var(--accent-dim);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.card-title {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.card-excerpt {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 2rem;
    flex-grow: 1;
}

.read-more {
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
}

.read-more span {
    transition: transform 0.3s ease;
}

.blog-card:hover .read-more span {
    transform: translateX(5px);
    color: var(--accent);
}

/* ==================== BLOG POST STYLES ==================== */

.blog-nav {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
}

.back-link {
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: 0.3s;
}

.back-link:hover {
    color: var(--accent);
}

.blog-article {
    max-width: 800px;
    margin: 4rem auto;
    padding: 0 1.5rem;
}

.blog-article header {
    margin-bottom: 3rem;
}

.meta {
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: block;
}

.blog-article h1 {
    font-size: clamp(2.5rem, 6vw, 3.5rem);
    line-height: 1.1;
    margin-bottom: 1.5rem;
    letter-spacing: -1.5px;
    color: var(--text-main);
}

.lead {
    font-size: 1.25rem;
    color: var(--text-muted);
    font-style: italic;
}

.content {
    font-size: 1.15rem;
    color: var(--text-main);
}

.content p {
    margin-bottom: 2rem;
}

.content h2 {
    font-size: 1.8rem;
    margin: 3rem 0 1rem 0;
    color: var(--text-main);
}

.content blockquote {
    margin: 3rem 0;
    padding-left: 2rem;
    border-left: 3px solid var(--accent);
    font-family: var(--font-serif);
    font-size: 1.4rem;
    color: var(--text-main);
    line-height: 1.5;
}

.content pre {
    background: var(--code-bg);
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 2rem 0;
    border: 1px solid var(--border-light);
}

.content code {
    font-family: 'Fira Code', monospace;
    font-size: 0.95rem;
    color: var(--text-main);
}

.highlight-text {
    color: var(--accent);
    font-weight: 600;
}

.content ul {
    margin-bottom: 2rem;
    list-style: none;
}

.content li {
    margin-bottom: 0.8rem;
    position: relative;
    padding-left: 1.5rem;
}

.content li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--accent);
}

.featured-image {
    width: 100%;
    height: 400px;
    background: linear-gradient(45deg, var(--bg-card), var(--bg-elevated));
    border-radius: 12px;
    margin: 3rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}

.blog-article footer {
    margin: 6rem auto 4rem auto;
    padding-top: 2rem;
    border-top: 1px solid var(--border-light);
}

.author-box {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: var(--code-bg);
    padding: 2rem;
    border-radius: 12px;
}

.author-img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.author-box h4 {
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.author-box p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ==================== MEDIA CAROUSEL ==================== */

.media-carousel {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 3rem 0;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
}

.carousel-container {
    overflow: hidden;
    border-radius: 12px;
}

.carousel-track {
    display: flex;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.media-carousel-item {
    min-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    background: var(--bg-card);
}

.media-carousel-item img,
.media-carousel-item video {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.media-caption {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-style: italic;
    margin-top: 1rem;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    font-size: 2rem;
    padding: 1rem 1.5rem;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
    z-index: 10;
}

.carousel-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-50%) scale(1.1);
}

.carousel-prev {
    left: 1rem;
}

.carousel-next {
    right: 1rem;
}

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.carousel-dot.active {
    background: var(--accent);
    transform: scale(1.3);
}

.carousel-dot:hover {
    background: var(--accent);
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 768px) {
    .carousel-btn {
        padding: 0.75rem 1rem;
        font-size: 1.5rem;
    }
    
    .carousel-prev {
        left: 0.5rem;
    }
    
    .carousel-next {
        right: 0.5rem;
    }
}

@media (max-width: 600px) {
    .blog-grid {
        grid-template-columns: 1fr;
    }
    .page-header h1 {
        font-size: 2.2rem;
    }
    
    .nav-links {
        gap: 1rem;
    }
    
    .theme-toggle {
        width: 36px;
        height: 36px;
        margin-left: 0.5rem;
    }
}

/* ==================== LIGHT MODE SPECIFIC ADJUSTMENTS ==================== */

[data-theme="light"] .blog-card:hover::before {
    background: radial-gradient(800px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(245, 166, 35, 0.05), transparent 40%);
}

[data-theme="light"] code {
    background: var(--code-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

[data-theme="light"] .carousel-btn {
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-main);
}

[data-theme="light"] .carousel-btn:hover {
    background: rgba(255, 255, 255, 1);
}

[data-theme="light"] .carousel-dots {
    background: rgba(0, 0, 0, 0.05);
}