/* Modern Theme Overrides & Enhancements */

:root {
    --glass-bg: rgba(26, 29, 35, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --hero-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

/* Global Overflow Fix */
html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
    margin: 0;
    padding: 0;
}

/* Glassmorphism Cards */
.skills-category, 
.project-card, 
.timeline-content, 
.contact-method, 
.contact-form-container,
.about-text .personal-qualities li,
.fact,
.blog-sidebar,
.blog-post {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
}

/* Fix for overflowing text in skills cards */
.skills-category .category-header h3 {
    word-break: break-word;
    hyphens: auto;
    min-width: 0; /* Allow flex item to shrink */
}

/* Enhanced Hero Section */
#hero, #blog-hero {
    background: var(--hero-gradient);
    position: relative;
}

#hero::before, #blog-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 20%, rgba(255, 107, 53, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(0, 184, 148, 0.1) 0%, transparent 40%);
    z-index: 1;
    animation: pulse-bg 10s ease-in-out infinite alternate;
}

@keyframes pulse-bg {
    0% { opacity: 0.5; transform: scale(1); }
    100% { opacity: 0.8; transform: scale(1.1); }
}

/* Typography Enhancements */
h1, h2, h3 {
    letter-spacing: -0.02em;
}

p {
    line-height: 1.8;
    letter-spacing: 0.01em;
}

/* Button Glow Effects */
.btn-primary {
    position: relative;
    z-index: 1;
    overflow: visible;
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: var(--gradient-primary);
    z-index: -1;
    border-radius: inherit;
    filter: blur(10px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-primary:hover::after {
    opacity: 0.6;
}

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

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

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

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

/* Mobile Menu Enhanced */
@media (max-width: 1024px) {
    .nav-menu {
        background: rgba(26, 29, 35, 0.98);
        backdrop-filter: blur(20px);
    }
}

/* Light Mode Support (Variables) */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e2e8f0;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.05);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
    
    --hero-gradient: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

[data-theme="light"] .hero-text h1 {
    background: linear-gradient(135deg, #0f172a 0%, #FF6B35 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

/* Fix for Light Mode text contrast in Hero section */
[data-theme="light"] .hero-description {
    color: var(--text-secondary);
}

[data-theme="light"] .stat-label {
    color: var(--text-muted);
}

[data-theme="light"] .scroll-arrow {
    color: var(--text-muted);
}

[data-theme="light"] .nav-menu a {
    color: var(--text-secondary);
}

[data-theme="light"] .nav-menu a:hover,
[data-theme="light"] .nav-menu a.active {
    color: var(--accent-color);
}

[data-theme="light"] header,
[data-theme="light"] header.scrolled {
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: var(--shadow-sm);
}

/* Blog Light Mode Fixes */
[data-theme="light"] #blog-hero h1 {
    background: linear-gradient(135deg, #0f172a 0%, #FF6B35 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

[data-theme="light"] .blog-subtitle {
    color: var(--text-secondary);
}

/* Theme Toggle Button */
.theme-toggle {
    background: transparent;
    border: 2px solid var(--bg-tertiary);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 20px;
}

.theme-toggle:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    transform: rotate(15deg);
}

/* Modern Logo Styles */
.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.logo-symbol {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    width: 45px;
    height: 45px;
    border-radius: 12px;
    color: white;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 14px;
    box-shadow: var(--shadow-glow);
    position: relative;
    overflow: hidden;
}

.logo-symbol::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 40%, rgba(255, 255, 255, 0.2) 50%, transparent 60%);
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.logo-container:hover .logo-symbol::after {
    transform: translateX(100%);
}

.logo-bracket {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

.logo-initial {
    margin: 0 2px;
    letter-spacing: -1px;
}

.logo-text-group {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.logo-main {
    font-family: var(--font-primary);
    font-weight: 800;
    font-size: 18px;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.logo-sub {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent-color);
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* Logo Hover Effects */
.logo-container:hover .logo-symbol {
    transform: scale(1.05);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.logo-container:hover .logo-main {
    color: var(--accent-color);
    transition: color 0.3s ease;
}

/* Light Mode Logo Adjustments */
[data-theme="light"] .logo-main {
    color: var(--text-dark);
}

[data-theme="light"] .logo-container:hover .logo-main {
    color: var(--accent-color);
}

/* --- Responsive Overrides --- */

/* Main content spacing */
main {
    padding-top: 100px;
}

@media (max-width: 768px) {
    main {
        padding-top: 80px;
    }
}

/* Tablet & Smaller Desktop (1024px and down) */
@media (max-width: 1024px) {
    .projects-grid, 
    .skills-container {
        /* Relax the min-width for grids to prevent overflow */
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1.5rem;
    }
    
    .contact-content {
        grid-template-columns: 1fr;
    }
    
    /* Improve mobile menu backdrop */
    .nav-menu {
        background: rgba(26, 29, 35, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        padding-top: 100px; /* Ensure menu content doesn't overlap with close button */
    }
    
    /* Light mode mobile menu */
    [data-theme="light"] .nav-menu {
        background: rgba(255, 255, 255, 0.98);
    }
    
    /* Fix blog layout on tablets */
    .blog-layout {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

/* Mobile Devices (768px and down) */
@media (max-width: 768px) {
    /* IMPORTANT: Override any potential fixed widths from style.css */
    .container {
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden;
    }
    
    /* Force Blog Layout to stack comfortably */
    .blog-layout {
        display: flex !important;
        flex-direction: column !important;
        gap: 1.5rem !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .blog-sidebar {
        width: 100% !important;
        margin-top: 1rem !important;
    }
    
    .blog-main {
        width: 100% !important;
    }
    
    /* Ensure Blog Posts stay within container */
    .blog-post {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 0 2.5rem 0 !important; /* Added bottom margin for better separation */
        box-sizing: border-box !important;
    }
    
    /* Prevent code blocks from stretching layout */
    pre, code {
        white-space: pre-wrap;
        word-break: break-word;
        max-width: 100%;
        overflow-x: auto;
    }

    /* Hero Section Adjustments */
    .hero-text h1 {
        font-size: 2.5rem; /* Smaller heading */
    }
    
    .hero-stats {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 1.5rem;
    }
    
    /* Grid adjustments for smaller screens */
    .projects-grid, 
    .skills-container {
        grid-template-columns: 1fr; /* Single column */
    }
    
    /* Timeline adjustments */
    .timeline::before {
        left: 20px;
    }
    .timeline-item {
        padding-left: 50px;
    }
    .timeline-item::before {
        left: 11px;
    }
    
    /* Logo sizing on mobile */
    .logo-symbol {
        width: 35px;
        height: 35px;
        font-size: 12px;
    }
    .logo-main {
        font-size: 16px;
    }
    .logo-sub {
        font-size: 10px;
    }
    
    /* Profile Image */
    .profile-container {
        width: 200px;
        height: 200px;
    }
    
    /* Allow blog buttons to wrap */
    .post-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* Small Mobile Devices (480px and down) */
@media (max-width: 480px) {
    /* Tighter padding for very small screens */
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .hero-text h1 {
        font-size: 2rem;
    }
    
    .hero-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .project-links {
        flex-direction: column;
    }
    
    .nav-menu {
        width: 100%;
    }
    
    /* Ensure chat widget doesn't block content on small screens */
    .ai-chat-widget {
        bottom: 20px;
        right: 20px;
    }
    .ai-chat-toggle {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    .ai-chat-window {
        width: calc(100vw - 40px);
        right: 0;
        bottom: 70px;
        height: 60vh;
    }
}
