/* Premium Portfolio Styles - Final Polish */

/* 1. Base Variables & Typography */
:root {
    /* Brand Colors */
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --primary-dark: #3730a3;

    --accent: #f59e0b;

    /* Neutral Scales */
    --bg-body: #f3f4f6;
    --bg-surface: #ffffff;

    --text-main: #111827;
    --text-muted: #6b7280;
    --text-subtle: #9ca3af;

    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-float: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;

    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    /* Use exact font stack from index.css for consistency */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* 2. Global Navigation (Sticky & Glass) */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    z-index: 1000;
    transition: var(--transition-smooth);
}

.nav-container {
    max-width: 1280px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: -0.025em;
}

.nav-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 2px var(--primary-light);
}

.nav-menu {
    display: flex;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9375rem;
    transition: var(--transition-smooth);
}

.nav-link:hover {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

.nav-link.active {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.1);
}

/* 3. Main Layout Grid */
.main-wrapper {
    padding-top: 110px;
    padding-bottom: 80px;
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 48px;
    padding-left: 32px;
    padding-right: 32px;
}

/* 4. Sidebar Styles */
.portfolio-sidebar {
    position: sticky;
    top: 110px;
    background: var(--bg-surface);
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    height: fit-content;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.portfolio-sidebar h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-subtle);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.sidebar-menu {
    list-style: none;
}

.sidebar-menu li {
    margin-bottom: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: var(--transition-smooth);
    font-size: 0.95rem;
    cursor: pointer;
}

.sidebar-link i {
    width: 20px;
    text-align: center;
    color: var(--text-subtle);
    transition: color 0.3s;
}

.sidebar-link:hover {
    background: var(--bg-body);
    color: var(--text-main);
}

.sidebar-link:hover i {
    color: var(--primary);
}

.sidebar-link.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.sidebar-link.active i {
    color: rgba(255, 255, 255, 0.9);
}

/* 5. Content Area */
.content-header {
    margin-bottom: 40px;
    animation: fadeIn 0.5s ease;
}

.content-title {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.025em;
    margin-bottom: 8px;
}

.content-subtitle {
    font-size: 1.125rem;
    color: var(--text-muted);
}

/* 6. Card Grid */
.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.article-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: var(--shadow-sm);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%;
}

.article-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(79, 70, 229, 0.2);
}

.article-image {
    width: 100%;
    aspect-ratio: 16/10;
    object-fit: cover;
    background: var(--bg-body);
}

.article-card-content {
    padding: 24px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.article-card h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
    line-height: 1.4;
}

.article-summary {
    font-size: 0.9375rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 16px;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.read-btn {
    align-self: flex-start;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
    background: rgba(79, 70, 229, 0.08);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition-smooth);
}

.article-card:hover .read-btn {
    background: var(--primary);
    color: white;
}

/* 7. Modal (Refined to be less jarring) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;

    display: none;
    justify-content: center;
    align-items: flex-start;
    padding-top: 5vh;
    padding-bottom: 5vh;
    padding-left: 20px;
    padding-right: 20px;
    overflow-y: auto;

    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-surface);
    width: 100%;
    max-width: 800px;
    min-height: 80vh;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-float);
    position: relative;
    /* Move up slightly animation */
    transform: translateY(40px) scale(0.98);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);

    display: flex;
    flex-direction: column;
    /* Make modal header blend better */
    overflow: hidden;
    margin-bottom: 40px;
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

/* Refined Modal Header - Blends in, cleaner */
.modal-header {
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.98);
    /* Less transparent for cleaner look */
    z-index: 10;
    padding: 12px 24px;
    /* Reduced padding */
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-body);
    /* Subtle bg */
}

.modal-close-btn:hover {
    background: var(--bg-body);
    color: var(--text-main);
    filter: brightness(0.95);
}

.modal-body {
    padding: 40px 60px;
}

.modal-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 24px;
    line-height: 1.2;
    color: var(--text-main);
}

.modal-hero-image {
    width: 100%;
    height: 320px;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin-bottom: 32px;
    box-shadow: var(--shadow-md);
}

.modal-body p {
    font-size: 1.125rem;
    line-height: 1.8;
    color: #374151;
    margin-bottom: 1.5rem;
}

.modal-body h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-top: 48px;
    margin-bottom: 24px;
    color: var(--text-main);
    position: relative;
    padding-bottom: 12px;
}

.modal-body h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 4px;
    background: var(--primary-light);
    border-radius: 2px;
}

.modal-body img:not(.modal-hero-image) {
    max-width: 100%;
    margin: 32px 0;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.modal-body ul,
.modal-body ol {
    margin-left: 24px;
    margin-bottom: 24px;
    font-size: 1.1rem;
}

body.modal-open {
    overflow: hidden;
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

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

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

/* Footer */
.footer {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    background: var(--bg-surface);
    padding: 40px 0;
    text-align: center;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 1024px) {
    .main-wrapper {
        grid-template-columns: 1fr;
        padding-top: 100px;
    }

    .portfolio-sidebar {
        position: sticky;
        top: 80px;
        z-index: 50;
        overflow-x: auto;
        padding: 16px;
        display: block;
        border-radius: 0;
        margin: -32px -32px 32px -32px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    }

    .sidebar-menu {
        display: flex;
        gap: 12px;
    }

    .sidebar-link {
        white-space: nowrap;
    }
}

@media (max-width: 640px) {
    .navbar {
        height: 60px;
    }

    .nav-menu {
        display: none;
    }

    .main-wrapper {
        padding: 80px 16px 40px;
        gap: 24px;
    }

    .portfolio-sidebar {
        margin: -16px -16px 24px -16px;
        top: 60px;
    }

    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal-content {
        max-width: 100%;
        min-height: 90vh;
        border-radius: 16px 16px 0 0;
        margin-bottom: 0;
    }

    .modal-body {
        padding: 24px;
    }

    .content-title,
    .modal-title {
        font-size: 1.75rem;
    }
}