/* Default (Light) Theme Styles */
:root {
    --bg-color: #f0f0f0;
    --text-color: #333;
    --link-color: #666;
    --header-bg: #fff;
    --footer-bg: #fff;
    --footer-text-color: #333;
}

/* Dark Mode Styles when data-theme="dark" is set on html */
[data-theme="dark"] {
    --bg-color: #121212;
    --text-color: #f5f5f5;
    --link-color: #666;
    --header-bg: #333333;
    --footer-bg: #333333;
    --footer-text-color: #f5f5f5;
}

/* Mobile nav styles - these should be outside theme definitions */
.mobile-nav {
    position: fixed;
    top: 0;
    right: 0;
    width: 100vw;
    height: 100dvh; /* FIX: Changed from 100vh to 100dvh */
    z-index: 1000;
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(.77,0,.18,1), opacity 0.4s cubic-bezier(.77,0,.18,1);
    background-color: var(--bg-color);
    will-change: transform, opacity;
}

body.nav-open .mobile-nav {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
    transition: transform 0.3s cubic-bezier(.77,0,.18,1), opacity 0.4s cubic-bezier(.77,0,.18,1);
}

html[data-theme="light"] body::before{
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    filter: url(#grainy);
    opacity: 0.5;
    mix-blend-mode: multiply;
    transition: opacity 0.3s ease-in-out;
}

html[data-theme="dark"] body::before{
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    filter: url(#grainy);
    opacity: 0.2;
    transition: opacity 0.3s ease-in-out;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

/* ==== RTL FIXES ==== */
html[dir="rtl"] { direction: rtl; }
html[dir="rtl"] .left-nav .name { margin-right: 0; margin-left: 30px; }
html[dir="rtl"] .left-nav a, html[dir="rtl"] .right-nav a { margin-left: 0; margin-right: 20px; }
html[dir="rtl"] nav a i { margin-left: 0; margin-right: 20px; }
html[dir="rtl"] .hero-top { justify-content: flex-end; }
html[dir="rtl"] .hero-top h1 { 
    text-align: right; 
    margin-left: 0;
    margin-right: 10px;
    padding-right: 15px;
}
html[dir="rtl"] .grid-column { 
    padding-right: 0; 
    padding-left: 2rem; 
}
html[dir="rtl"] .grid-column:last-child { 
    padding-left: 0; 
}
html[dir="rtl"] .mobile-nav-bottom {
    flex-direction: row-reverse;
}
html[dir="rtl"] .lang-switcher i {
    right: auto;
    left: 4px;
}
html[dir="rtl"] .lang-switcher select {
    padding: 4px 4px 4px 24px;
}
html[dir="rtl"] .nav-toggle {
    left: 20px;
    right: auto;
}
html[dir="rtl"] .mobile-nav {
    left: 0;
    right: auto;
    transform: translateX(-100%);
}
html[dir="rtl"] .nav-open .mobile-nav {
    transform: translateX(0);
}

body {
    font-family: Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    transition: background-color 0.4s ease, color 0.4s ease;
    position: relative;
    margin: 0;
    min-height: 100vh;
}

/* Add styles for when nav is open */
body.nav-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    /* FIX: Removed height: 100vh; */
}

body.nav-open main {
    visibility: hidden;
}

nav {
    display: flex;
    justify-content: space-between;
    padding: 20px 40px;
    align-items: baseline;
    position: relative;
    z-index: 1;
}

.left-nav,
.right-nav {
    display: flex;
    align-items: baseline;
}

.left-nav a.name {
    font-family: Helvetica, Arial, sans-serif;
    font-weight: bold;
    font-size: 36px;
    margin-right: 30px;
    color: #fff !important;
    text-decoration: none;
    margin-left: 0;
}

.left-nav a,
.right-nav a {
    font-family: 'Helvetica', 'Arial', sans-serif;
    color: #fff !important;
    text-decoration: none;
    margin-left: 20px;
    font-weight: 400;
    transition: color 0.4s ease;
}

.left-nav a.name {
    font-family: Helvetica, Arial, sans-serif;
    font-weight: bold;
    font-size: 36px;
    color: #fff !important;
    text-decoration: none;
    margin: 0 30px 0 0;
    padding: 0;
    display: inline-block;
}

.left-nav a:not(.name) {
    margin-left: 20px;
}

nav a i {
    font-size: 30px;
    color: #fff !important;
    margin-left: 20px;
    transition: color 0.4s ease;
}

.hero-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    position: relative;
    z-index: 1;
}

.hero-top {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex: 1;
    margin-left: 0;
    padding-left: 0;
    width: 100%;
}

.hero-top h1 {
    font-size: 10vw;
    font-weight: 300;
    letter-spacing: -1vw;
    margin: 0;
    width: 100%;
    line-height: 1.1;
    white-space: nowrap;
    text-align: left;
    margin-left: 10px;
    padding-left: 15px;
}

.hero-bottom {
    display: flex;
    flex: 1;
    padding: 40px;
    margin-top: -150px;
    margin-left: 10vw;
}

.about-left { max-width: 600px; }

.read-more,
.read-more:link,
.read-more:visited,
.read-more:hover,
.read-more:active {
    display: inline-block;
    margin-top: 10px;
    text-decoration: underline;
    color: var(--link-color) !important;
    -webkit-text-fill-color: var(--link-color) !important;
}
.about-container { flex: 1; padding: 40px 10vw; position: relative; z-index: 1; }
.about-main-title { font-size: 4.5vw; font-weight: 300; letter-spacing: -0.3vw; margin-bottom: 2rem; line-height: 1.1; max-width: 80%; }
.about-content { display: grid; grid-template-columns: 1fr 1fr; gap: 4rem; margin-top: 3rem; }
.about-text-column { display: flex; flex-direction: column; gap: 2rem; }
.about-lead { font-size: 1.5rem; line-height: 1.4; margin-bottom: 1rem; }
.about-details { display: flex; flex-direction: column; gap: 1.5rem; line-height: 1.6; }
.about-grid { display: flex; grid-template-columns: repeat(3, 1fr); gap: 2rem; }
.grid-column { 
    padding-right: 2rem; 
    border: none;
}
.grid-column:last-child { 
    padding-right: 0; 
}
.grid-column h3 { font-weight: 500; margin-bottom: 1.5rem; font-size: 1.1rem; }
.grid-column ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.8rem; }
.grid-column li { font-size: 0.95rem; color: #666; }
.projects-container { flex: 1; padding: 40px 10vw; position: relative; z-index: 1; }
.projects-main-title { font-size: 4vw; font-weight: 300; letter-spacing: -0.3vw; margin-bottom: 3rem; line-height: 1.1; }
.projects-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    width: 100%;
    margin: 2rem 0;
    align-items: stretch;
}
.project-box {
    background: var(--bg-color, #222);
    border-radius: 1rem;
    box-shadow: 0 2px 16px rgba(0,0,0,0.08);
    padding: 2rem;
    min-height: 260px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: box-shadow 0.2s;
}

.project-box:hover {
    box-shadow: 0 4px 24px rgba(0,0,0,0.16);
}

.project-card {
    padding: 2rem;
    border: 1px solid #eee;
    border-radius: 4px;
    border-left-width: 5px;
    border-left-style: solid;
    transition: transform 0.3s ease, border-color 0.3s ease, background-color 0.4s ease;
    width: 400px;
    height: 260px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    box-sizing: border-box;
    overflow: hidden;
}

.project-card:hover { transform: translateY(-5px); }
.project-card h3 { font-size: 1.4rem; margin-bottom: 1rem; font-weight: 500; }
.project-card p { line-height: 1.6; color: #666; margin-bottom: 1.5rem; }
.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0;
    justify-content: flex-start;
    align-items: flex-end;
}
.project-tags span {
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-size: 0.85rem;
    white-space: nowrap;
    color: #fff;
    background: #222;
    margin-right: 0.3em;
    margin-bottom: 0.3em;
    display: inline-block;
    transition: transform 0.2s ease;
}
.project-tags span:hover {
    transform: translateY(-2px);
}
.project-link { color: inherit; text-decoration: none; }
.lang-switcher { position: relative; display: flex; align-items: center; margin-left: 20px; color: var(--link-color); }
html[dir="rtl"] .lang-switcher { margin-left: 0; margin-right: 20px; }

.lang-switcher select { 
    appearance: none; 
    -webkit-appearance: none; 
    -moz-appearance: none; 
    background: transparent; 
    border: none; 
    font: inherit; 
    font-weight: 500; 
    cursor: pointer; 
    padding: 4px 24px 4px 4px; 
    color: var(--text-color);
    margin-right: 8px;
}

html[dir="rtl"] .lang-switcher select { padding: 4px 4px 4px 24px; }

.lang-switcher i { 
    position: absolute; 
    right: 4px; 
    pointer-events: none; 
    font-size: 1.2rem; 
    color: var(--text-color);
}
html[dir="rtl"] .lang-switcher i { right: auto; left: 4px; }
@keyframes spin-and-fade { from { transform: rotate(0deg); opacity: 1; } to { transform: rotate(360deg); opacity: 0; } }
.icon-animating { animation: spin-and-fade 0.4s ease-in-out; }

/* --- Hamburger Menu & Mobile Nav (3-Div Method) --- */
.nav-toggle {
    display: none;
    position: absolute;
    top: 20px;
    right: 1rem;
    z-index: 1002;
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 0;
    width: 44px;
    height: 44px;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
    pointer-events: auto;
}

.hamburger {
    width: 2em;
    height: 18px;
    position: relative;
}

.hamburger__line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--text-color);
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
}

.hamburger__line--1 { top: 0; }
.hamburger__line--2 { top: 50%; transform: translateY(-50%); }
.hamburger__line--3 { bottom: 0; }

body.nav-open .hamburger__line--1 {
    transform: translateY(7.5px) rotate(45deg);
}

body.nav-open .hamburger__line--2 {
    opacity: 0;
}

body.nav-open .hamburger__line--3 {
    transform: translateY(-7.5px) rotate(-45deg);
}

.nav-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

body.nav-open .nav-backdrop {
    opacity: 1;
    visibility: visible;
}

.mobile-nav {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100dvh; /* FIX: Use dynamic viewport height */
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out, background-color 0.4s ease;
    background-color: var(--bg-color);
    will-change: transform, background-color;
}

.mobile-nav-content {
    display: flex;
    flex-direction: column;
    height: 100%; /* FIX: Changed from 100vh to 100% to fill parent */
    min-height: 0;
    padding: 0 2rem 0;
    overflow-y: auto;
}

.mobile-nav-top { 
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    padding: 2rem 0 0 0;
}

.mobile-nav-top a { 
    font-size: 2rem; 
    font-weight: bold;
    text-align: center;
    padding: 1rem;
    color: var(--text-color);
    text-decoration: none;
}

.mobile-nav-bottom { 
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 3rem;
    padding: 0 0 1.5rem 0;
    width: 100%;
    background: var(--bg-color);
    box-shadow: 0 -2px 16px 0 rgba(0,0,0,0.04);
}

.mobile-nav-bottom a,
.mobile-nav-bottom .lang-switcher,
.mobile-nav-bottom a.github-icon,
.mobile-nav-bottom a.cv-icon,
.mobile-nav-bottom a#mobile-theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    text-decoration: none;
    padding: 0.5rem;
}

.mobile-nav-bottom i {
    font-size: 2rem;
    color: var(--text-color);
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.nav-open .nav-toggle:not(.nav-toggle-mobile) {
    opacity: 0;
}

html[dir="rtl"] .mobile-nav-bottom { 
    text-align: right;
}

.mobile-nav-bottom .lang-switcher {
    justify-content: flex-start;
    margin-left: 0;
}

html[dir="rtl"] .mobile-nav-bottom .lang-switcher {
    justify-content: flex-end;
}

body.nav-open::after {
    display: none;
}

.nav-open .mobile-nav {
    transform: translateX(0);
}

.mobile-nav-top a,
.mobile-nav-bottom a,
.mobile-nav-bottom .lang-switcher,
.mobile-nav-bottom .nav-action-icon {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s cubic-bezier(.77,0,.18,1), transform 0.3s cubic-bezier(.77,0,.18,1);
    will-change: opacity, transform;
}

.nav-open .mobile-nav-top a,
.nav-open .mobile-nav-bottom a,
.nav-open .mobile-nav-bottom .lang-switcher,
.nav-open .mobile-nav-bottom .nav-action-icon {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger the animation of nav items */
.nav-open .mobile-nav-top a:nth-child(1) { transition-delay: 0.45s; }
.nav-open .mobile-nav-top a:nth-child(2) { transition-delay: 0.55s; }
.nav-open .mobile-nav-top a:nth-child(3) { transition-delay: 0.65s; }
.nav-open .mobile-nav-bottom a:nth-child(1) { transition-delay: 0.75s; }
.nav-open .mobile-nav-bottom a:nth-child(2) { transition-delay: 0.85s; }
.nav-open .mobile-nav-bottom .lang-switcher { transition-delay: 0.95s; }
.nav-open .mobile-nav-bottom .nav-action-icon { transition-delay: 1.05s; }

/* ============================================= */
/* === STYLES FOR NEW PROJECT DETAIL SECTION === */
/* ============================================= */

/* Main container for the new content */
.project-detail-container {
    max-width: 900px;
    margin: 2rem auto; /* Centers the content and adds space top/bottom */
    padding: 0 2rem;
    flex: 1; /* Ensures it takes up available space */
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Left-align all direct children */
}

/* Back button with left arrow and underline */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem; /* Space between icon and text */
    text-decoration: underline;
    color: var(--text-color);
    font-size: 1rem;
    margin-bottom: 2rem;
}

.back-link i {
    font-size: 1.2rem;
}

/* Project Title */
.project-title {
    font-size: 3rem;
    font-weight: bold;
    color: var(--text-color);
    margin: 0 0 1rem 0; /* Reduced bottom margin */
}

/* NEW: Image container for arrows and counter */
.project-image-container {
    position: relative;
    width: 100%;
    max-width: 800px; /* Max width of the image area */
    aspect-ratio: 16 / 9; /* Enforce a 16:9 aspect ratio */
    margin-bottom: 1rem; /* Reduced bottom margin */
    overflow: hidden; /* Hide parts of the image that overflow */
    border-radius: 8px;
    background-color: #2a2a2a; /* Dark placeholder for loading */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Project Image */
.project-image {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Fit image within the container without stretching */
    display: block;
}

/* NEW: Navigation buttons (arrows) */
.image-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    opacity: 0; /* Hidden by default */
}

.project-image-container:hover .image-nav-btn {
    opacity: 1; /* Show on hover */
}

.image-nav-btn:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.image-nav-btn.prev {
    left: 10px;
}

.image-nav-btn.next {
    right: 10px;
}

/* NEW: Image counter (e.g., "1 / 3") */
.image-counter {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.9rem;
}

/* Tags are now closer to the image */
.project-tags {
    margin-bottom: 1.5rem;
}

/* Container for GitHub and Demo links */
.project-links {
    display: flex;
    gap: 2rem; /* Space between the links */
    margin-bottom: 2rem;
}

/* UPDATED: Styling for GitHub and Demo links for a continuous underline */
.project-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-color);
    text-decoration: none; /* Remove the default, broken underline */
    /* border-bottom: 2px solid var(--text-color); Add a solid border that spans the full width */
    padding-bottom: 3px; /* Adjusts the space between the text/icon and the underline */
    font-size: 1.1rem;
    /* font-weight: 500; */
}

/* This rule for the icon size remains the same */
.project-links a i {
    font-size: 1.4rem;
}

/* Short summary text */
.project-summary {
    font-size: 1.2rem;
    font-weight: 500;
    line-height: 1.6;
    color: var(--text-color);
    margin-bottom: 2rem;
    border-left: 3px solid var(--text-color); /* Adds a little emphasis */
    padding-left: 1rem;
    margin-bottom: 1.5rem; /* Reduced margin */
}

/* Long description section */
.project-description {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-color);
}

.project-description p {
    margin-bottom: 1rem;
}


/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    .project-title {
        font-size: 2.2rem;
    }

    .project-detail-container {
        padding: 0 1rem;
        margin-top: 1rem;
        align-items: center; /* Center content on mobile */
    }

    .project-image-container {
        width: 100%; /* Full width on mobile */
    }

    .project-summary,
    .project-description,
    .project-links,
    .project-tags {
        align-self: flex-start; /* Re-align text to the left on mobile */
    }
}