:root {
    /* Light Theme (Default) */
    --bg-primary: #FEFAE0;
    --bg-secondary: #F4F3EE;
    --text-primary: #2D3748;
    --text-secondary: #4A5568;
    --text-muted: #718096;
    --accent-primary: #B87A5C;
    --accent-secondary: #A98467;
    --accent-tertiary: #8A817C;
    --border-light: #E2E8F0;
    --card-bg: #FFFFFF;
    --header-bg: rgba(254, 250, 224, 0.95);
    --header-bg-scroll: rgba(254, 250, 224, 0.98);

    /* Common */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 24px -4px rgba(0, 0, 0, 0.1), 0 4px 8px -2px rgba(0, 0, 0, 0.06);
    --shadow-xl: 0 20px 40px -8px rgba(0, 0, 0, 0.12);
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-primary: #121212;
    /* Neutral Dark */
    --bg-secondary: #1E1E1E;
    /* Neutral Dark Gray */
    --text-primary: #E2E8F0;
    --text-secondary: #CBD5E1;
    --text-muted: #94A3B8;
    --accent-primary: #FB923C;
    /* Orange-400 */
    --accent-secondary: #F97316;
    /* Orange-500 */
    --accent-tertiary: #FDBA74;
    /* Orange-300 */
    --border-light: #2D2D2D;
    --card-bg: #1E1E1E;
    --header-bg: rgba(18, 18, 18, 0.95);
    --header-bg-scroll: rgba(18, 18, 18, 0.98);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.25), 0 2px 4px -2px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 10px 24px -4px rgba(0, 0, 0, 0.3), 0 4px 8px -2px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 40px -8px rgba(0, 0, 0, 0.35);
}

/* System-level dark mode support — applies when prefers-color-scheme: dark (before JS toggles data-theme) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #121212;
        --bg-secondary: #1E1E1E;
        --text-primary: #E2E8F0;
        --text-secondary: #CBD5E1;
        --text-muted: #94A3B8;
        --accent-primary: #FB923C;
        --accent-secondary: #F97316;
        --accent-tertiary: #FDBA74;
        --border-light: #2D2D2D;
        --card-bg: #1E1E1E;
        --header-bg: rgba(18, 18, 18, 0.95);
        --header-bg-scroll: rgba(18, 18, 18, 0.98);
        --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.25), 0 2px 4px -2px rgba(0, 0, 0, 0.15);
        --shadow-lg: 0 10px 24px -4px rgba(0, 0, 0, 0.3), 0 4px 8px -2px rgba(0, 0, 0, 0.2);
        --shadow-xl: 0 20px 40px -8px rgba(0, 0, 0, 0.35);
    }
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: "Google Sans Flex", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
    font-variation-settings: "slnt" 0, "wdth" 100, "GRAD" 0, "ROND" 0;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.65;
    letter-spacing: -0.01em;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Typography */
.font-display {
    font-family: "Google Sans Flex", -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
    font-variation-settings: "slnt" 0, "wdth" 100, "GRAD" 0, "ROND" 0;
}

.text-xl {
    font-size: 1.25rem;
}

.text-2xl {
    font-size: 1.5rem;
}

.text-3xl {
    font-size: 1.875rem;
}

.text-4xl {
    font-size: 2.25rem;
}

.text-5xl {
    font-size: 3rem;
}

.text-6xl {
    font-size: 3.75rem;
}

.font-light {
    font-weight: 300;
}

.font-normal {
    font-weight: 400;
}

.font-medium {
    font-weight: 500;
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.section {
    padding: 5rem 0;
}

.grid {
    display: grid;
    gap: 2rem;
}

.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Responsive Grid */
@media (max-width: 768px) {

    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    .grid-cols-2,
    .grid-cols-3 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }

    .container {
        padding: 0 1rem;
    }

    .section {
        padding: 3rem 0;
    }

    .card,
    .project-card,
    .hero-content,
    .hero-text,
    .hero-gallery,
    .contact-content {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .text-4xl {
        font-size: 2rem;
    }

    .text-5xl {
        font-size: 2.5rem;
    }

    .text-6xl {
        font-size: 3rem;
    }
}

/* Components */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: var(--transition);
    position: relative;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: color-mix(in srgb, var(--accent-primary) 50%, transparent);
}

.card:focus-within {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.75rem;
    border-radius: var(--radius-sm);
    font-weight: 550;
    text-decoration: none;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    font-size: 0.925rem;
    letter-spacing: 0.01em;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    background-color: var(--accent-secondary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-secondary {
    background-color: transparent;
    color: var(--accent-secondary);
    border: 1.5px solid var(--accent-secondary);
}

.btn-secondary:hover {
    background-color: var(--accent-secondary);
    color: white;
    transform: translateY(-1px);
}

.btn-secondary:active {
    transform: translateY(0);
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--header-bg);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    backdrop-filter: blur(12px) saturate(180%);
    border-bottom: 1px solid color-mix(in srgb, var(--border-light) 60%, transparent);
    z-index: 1000;
    transition: var(--transition);
}

.header.scrolled {
    background: var(--header-bg-scroll);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    border-bottom-color: var(--border-light);
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    /* Compact padding */
}

.logo {
    font-size: 1.375rem;
    font-weight: 650;
    color: var(--accent-secondary);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.nav-links {
    display: flex;
    gap: 1.75rem;
    list-style: none;
    align-items: center;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.925rem;
    transition: var(--transition);
    position: relative;
    padding: 0.25rem 0;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-primary);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--accent-primary);
    border-radius: 1px;
    transition: var(--transition);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background-color: var(--bg-secondary);
    color: var(--accent-primary);
}

.sun-icon {
    display: block;
}

.moon-icon {
    display: none;
}

[data-theme="dark"] .sun-icon {
    display: none;
}

[data-theme="dark"] .moon-icon {
    display: block;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--bg-primary);
        padding: 1rem;
        border-bottom: 1px solid var(--border-light);
    }

    .nav-links-open {
        display: flex;
    }

    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 2.5rem;
        height: 2.5rem;
        flex: 0 0 auto;
    }

    .theme-toggle {
        margin-left: 0;
        margin-right: 0;
        flex: 0 0 auto;
    }

    .nav {
        gap: 0.25rem;
        justify-content: space-between;
        min-width: 0;
    }

    .logo {
        flex: 1 1 auto;
        min-width: 0;
    }
}

/* Hero Section */
.hero {
    padding: 8rem 0 4rem;
    /* Increased padding to prevent header overlap */
    display: flex;
    align-items: center;
    min-height: 100vh;
}

.hero-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
}

@media (max-width: 768px) {
    .hero-content {
        display: flex;
        flex-direction: column-reverse;
        text-align: center;
        gap: 2rem;
        /* Image on top on mobile */
    }

    .hero-buttons {
        justify-content: center;
        flex-direction: column;
        align-items: stretch;
    }

    .hero-buttons .btn {
        width: 100%;
    }

    .hero-text h1 {
        font-size: clamp(1.8rem, 8.5vw, 2.4rem);
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .hero-text .subtitle {
        font-size: 1rem;
        overflow-wrap: anywhere;
    }

    .hero {
        min-height: auto;
        padding: 6.5rem 0 3rem;
    }
}

.hero-text h1 {
    font-size: 3rem;
    /* Fallback for older browsers */
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    margin-bottom: 1rem;
    line-height: 1.2;
}

.hero-text .subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Skip Navigation (Accessibility) */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    background: var(--accent-primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0 var(--radius) var(--radius) 0;
    text-decoration: none;
    font-weight: 600;
    z-index: 10000;
    transition: top 0.2s;
}
.skip-link:focus {
    top: 0;
}

/* Focus Visible (Accessibility) */
:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 3px;
}

/* Projects Section */
.project-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: var(--transition-slow);
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: color-mix(in srgb, var(--accent-primary) 40%, transparent);
}

.project-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.project-card:hover .project-image {
    transform: scale(1.02);
}

.project-content {
    padding: 1.25rem 1.5rem 1.5rem;
}

.project-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

.project-description {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.925rem;
    line-height: 1.6;
}

.project-tags {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.tag {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.tag-live {
    background-color: color-mix(in srgb, var(--accent-primary) 15%, var(--bg-secondary));
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
}

.btn-block {
    width: 100%;
}

.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--accent-primary);
}

.timeline-item {
    position: relative;
    margin-bottom: 2rem;
    padding-left: 2rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 0.5rem;
    width: 12px;
    height: 12px;
    background-color: var(--accent-primary);
    border-radius: 50%;
}

/* Contact Section */
.contact-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
}

@media (max-width: 768px) {
    .contact-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.925rem;
    transition: var(--transition);
    background-color: var(--card-bg);
    color: var(--text-primary);
}

.form-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.form-input:hover {
    border-color: color-mix(in srgb, var(--accent-primary) 50%, var(--border-light));
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 15%, transparent);
}

.contact-info {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.contact-icon {
    width: 48px;
    height: 48px;
    background-color: var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.social-links {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.social-link {
    width: 48px;
    height: 48px;
    background-color: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.social-link:hover {
    background-color: var(--accent-primary);
    color: white;
    transform: translateY(-2px);
}

/* Footer */
.footer {
    background-color: var(--bg-secondary);
    padding: 2rem 0;
    text-align: center;
    border-top: 1px solid var(--border-light);
}

/* Animations - Progressive Enhancement */
/* Content visible by default (no JS fallback) */
.fade-in {
    opacity: 1;
    transform: none;
}

/* Only apply animations when JS is enabled */
.fade-in.js-enabled {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: opacity, transform;
    /* GPU acceleration for low-end devices */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.fade-in.js-enabled.visible,
.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .fade-in.js-enabled {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* Staggered delays for grid items */
.grid>div:nth-child(1) {
    transition-delay: 0.1s;
}

.grid>div:nth-child(2) {
    transition-delay: 0.2s;
}

.grid>div:nth-child(3) {
    transition-delay: 0.3s;
}

.grid>div:nth-child(4) {
    transition-delay: 0.4s;
}

/* Pulse Animation for Primary Button */
@keyframes pulse-soft {
    0% {
        box-shadow: 0 0 0 0 rgba(var(--accent-primary), 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(var(--accent-primary), 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(var(--accent-primary), 0);
    }
}

.btn-primary.pulse {
    animation: pulse-soft 2s infinite;
}

/* Enhanced Card Hover */
.card,
.project-card {
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease, border-color 0.3s ease;
}

.card:hover,
.project-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Mobile Menu Transition */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--bg-primary);
        padding: 1rem;
        border-bottom: 1px solid var(--border-light);
        z-index: 999;
    }

    .nav-links.nav-links-open {
        display: flex;
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }
}

@media (max-width: 768px) {
    .blog-card-content,
    .blog-card-title,
    .blog-card-excerpt,
    .blog-card-meta,
    .blog-article-title,
    .blog-article-subtitle {
        min-width: 0;
        overflow-wrap: anywhere;
        word-break: break-word;
    }
}

.blog-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* Utilities */
.text-center {
    text-align: center;
}

.mb-1 {
    margin-bottom: 0.25rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-6 {
    margin-bottom: 1.5rem;
}

.mb-8 {
    margin-bottom: 2rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mt-8 {
    margin-top: 2rem;
}

/* Hero Gallery */
.hero-gallery {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(12, 1fr);
    gap: 1rem;
    height: 500px;
    position: relative;
}

.gallery-item {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

/* Main Image (Left Side - 60%) */
.gallery-item.main {
    grid-column: 1 / 8;
    grid-row: 1 / 13;
    z-index: 1;
}

.gallery-item.main img {
    object-position: center top;
}

/* Sub Image 1 (Top Right - 40%) */
.gallery-item.sub-1 {
    grid-column: 8 / 13;
    grid-row: 1 / 7;
    z-index: 1;
}

/* Sub Image 2 (Bottom Right - 40%) */
.gallery-item.sub-2 {
    grid-column: 8 / 13;
    grid-row: 7 / 13;
    z-index: 1;
    border: none;
    /* Remove border for cleaner look */
}

/* Responsive Gallery */
@media (max-width: 768px) {
    .hero-gallery {
        display: flex;
        flex-direction: column;
        height: auto;
        gap: 1rem;
        margin-top: 2rem;
    }

    .gallery-item.main,
    .gallery-item.sub-1,
    .gallery-item.sub-2 {
        grid-column: auto;
        grid-row: auto;
        width: 100%;
        height: 300px;
        /* Fixed height for mobile images */
    }

    .gallery-item.sub-1,
    .gallery-item.sub-2 {
        display: none;
        /* Hide extra images on mobile to save space, or remove this line to show all */
    }
}
