/* --- Variables --- */
:root {
    --bg: #ffffff;
    --text: #000000;
    --accent: #444444; 
    --brand: #16697A;
    --line: #eeeeee;
    --nav-bg: rgba(255, 255, 255, 0.9);
    --gap: 30px;
    --anim-speed: 0.7s;
    --ease: cubic-bezier(0.2, 1, 0.3, 1);
}

[data-theme="dark"] {
    --bg: #111111;
    --text: #ffffff;
    --accent: #aaaaaa;
    --line: #222222;
    --nav-bg: rgba(17, 17, 17, 0.9);
}

/* --- Global --- */
* { 
    box-sizing: border-box; 
    scroll-behavior: smooth; 
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

#about, #work, #contact {
    scroll-margin-top: 140px; /* Increased to accommodate the tall desktop nav bar */
}

@media (max-width: 768px) {
    #about, #work, #contact {
        scroll-margin-top: 90px; /* Reduced for the shorter mobile nav bar */
    }
}

.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* --- Top Controls --- */
.top-controls {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    padding: 15px 5% 10px;
    background: var(--bg);
    position: relative;
    z-index: 1001; 
    transition: background-color 0.3s ease;
}

.control-btn {
    width: 42px;
    height: 42px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s var(--ease), background-color 0.3s, border-color 0.3s, color 0.3s;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}

[data-theme="dark"] .control-btn { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); }

/* Wrap the hover state to only trigger on devices with a mouse/trackpad */
@media (hover: hover) {
    .control-btn:hover { transform: scale(1.1); color: var(--brand); border-color: var(--brand); }
}

.control-btn svg { 
    width: 18px; 
    height: 18px; 
    fill: none;
    stroke: currentColor; 
    stroke-width: 2; 
    stroke-linecap: round; 
    stroke-linejoin: round; 
}

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

.lang-toggle {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* --- Navigation --- */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--nav-bg);
    backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--line);
    padding: 25px 5%;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.logo-container { 
    display: flex; 
    align-items: center; 
    text-decoration: none; 
    z-index: 1002; 
}

.logo-file { 
    height: 80px; 
    width: auto; 
    display: block; 
    filter: var(--logo-filter, none); 
}

[data-theme="dark"] .logo-file { filter: invert(1); }

.nav-links { display: flex; align-items: center; }

.nav-links a {
    margin-left: 25px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s;
    opacity: 0.8;
    position: relative;
    padding-bottom: 4px;
}

.nav-links a:hover, 
.nav-links a.active { color: var(--brand); opacity: 1; }

.nav-links a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 1px;
    bottom: 0;
    left: 0;
    background-color: var(--brand);
    transition: width 0.3s var(--ease);
}

.nav-links a.active::after { width: 100%; }

.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 26px;
    height: 18px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1002;
    padding: 0;
    outline: none;
}

.hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--text);
    transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
    border-radius: 2px;
}

@media (max-width: 768px) {
    nav { padding: 15px 5%; }
    .logo-file { height: 50px; }
    
    .hamburger { display: flex; }
    
    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--nav-bg);
        border-bottom: 1px solid var(--line);
        flex-direction: column;
        align-items: center;
        padding: 0;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height 0.4s var(--ease), opacity 0.4s var(--ease);
        z-index: 1001;
    }
    
    .nav-links.open { max-height: 400px; opacity: 1; padding: 30px 0; }
    .nav-links a { margin: 15px 0; font-size: 1.1rem; }
    
    .hamburger.open span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
    .hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
    .hamburger.open span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }
}

/* --- About Section --- */
.about-section { 
    padding: 80px 5%; 
    display: flex;
    flex-direction: column;
    gap: 40px;
    max-width: 1100px; 
    margin: 0 auto; 
}

.about-image { 
    order: 2; 
    width: 100%; 
    max-width: 300px;
    margin: 0 auto;
}

.about-text { order: 1; }

.about-image img { 
    width: 100%; 
    height: auto; 
    aspect-ratio: 1 / 1;
    object-fit: cover; 
    border-radius: 0; 
    display: block; 
}

.about-text h2 { 
    font-size: 2.2rem; 
    font-weight: 300; 
    margin: 0 0 20px; 
    letter-spacing: -0.5px; 
    line-height: 1.1;
}

.about-text p { 
    color: var(--accent); 
    font-size: 1.1rem; 
    max-width: 650px; 
    font-weight: 300; 
    transition: color 0.3s ease; 
    margin: 0;
}

@media (min-width: 800px) { 
    .about-section { flex-direction: row; align-items: center; gap: 60px; } 
    .about-image { order: 1; flex: 0 0 24%; max-width: 216px; margin: 0; }
    .about-image img { height: 216px; width: 216px; object-fit: cover; object-position: center center; }
    .about-text { order: 2; flex: 1; display: flex; flex-direction: column; justify-content: center; min-height: 380px; }
    .about-text h2 { margin-top: -8px; }
}

/* --- Filter Controls --- */
.filter-section {
    padding: 20px 5% 30px; 
    border-top: 1px solid var(--line);
    transition: border-color 0.3s ease;
    position: relative;
    z-index: 100;
}

.filter-container { display: flex; gap: 40px; flex-wrap: wrap; }
.mobile-filter-btn { display: none; }

.filter-btn { 
    background: none; 
    border: none; 
    padding: 5px 0; 
    font-size: 0.75rem; 
    font-weight: 500; 
    text-transform: uppercase; 
    letter-spacing: 1.5px; 
    color: var(--text); 
    opacity: 0.6; 
    cursor: pointer; 
    border-bottom: 1px solid transparent; 
    transition: color 0.3s, border-color 0.3s, opacity 0.3s, background-color 0.3s; 
}

.filter-btn:hover { opacity: 1; }
.filter-btn.active { opacity: 1; color: var(--brand); border-bottom: 1px solid var(--brand); }

@media (max-width: 768px) {
    .about-section { padding: 80px 5%; }
    .filter-section { padding: 15px 5% 20px; } 
    
    .mobile-filter-btn {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 14px 20px;
        background: var(--bg);
        color: var(--text);
        border: 1px solid var(--line);
        border-radius: 6px;
        font-family: 'Inter', sans-serif;
        font-size: 0.85rem;
        text-transform: uppercase;
        letter-spacing: 1px;
        cursor: pointer;
        transition: background-color 0.3s, border-color 0.3s;
    }
    
    .mobile-filter-btn strong { color: var(--brand); font-weight: 600; margin-left: 5px; }
    .mobile-filter-btn svg { transition: transform 0.3s ease; }
    .mobile-filter-btn.open svg { transform: rotate(180deg); }

    .filter-container {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: calc(100% - 10px);
        left: 5%;
        width: 90%;
        background: var(--nav-bg); 
        backdrop-filter: blur(15px);
        border: 1px solid var(--line);
        border-radius: 6px;
        box-shadow: 0 10px 25px rgba(0,0,0,0.1);
        padding: 0;
        gap: 0;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: all 0.3s var(--ease);
        overflow: hidden;
    }
    
    [data-theme="dark"] .filter-container { box-shadow: 0 10px 25px rgba(0,0,0,0.5); }
    .filter-container.open { opacity: 1; visibility: visible; transform: translateY(0); }

    .filter-btn {
        padding: 16px 20px;
        text-align: left;
        border-bottom: 1px solid var(--line);
        width: 100%;
        margin: 0;
        opacity: 1;
        border-left: 3px solid transparent;
    }
    
    .filter-btn:last-child { border-bottom: none; }
    .filter-btn.active { background: rgba(22, 105, 122, 0.05); border-bottom: 1px solid var(--line); border-left: 3px solid var(--brand); }
    .filter-btn:last-child.active { border-bottom: none; }
}

/* --- Fluid Grid --- */
.portfolio-container { 
    position: relative; 
    width: 70%; 
    margin: 0 auto; 
    transition: height var(--anim-speed) var(--ease); 
}

.portfolio-item { 
    position: absolute; 
    width: calc(33.33% - 20px); 
    transition: transform var(--anim-speed) var(--ease), opacity 0.4s var(--ease), visibility 0.4s var(--ease), outline-offset 0.2s; 
    cursor: pointer; 
    opacity: 0; 
    visibility: hidden; 
    border-radius: 4px;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
    will-change: transform, opacity;
}

.portfolio-item:focus { outline: none; }
.portfolio-item:focus img, .portfolio-item:hover img { transform: translateY(-4px); box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2); opacity: 0.9; }

.portfolio-item.is-loaded { opacity: 1; visibility: visible; }
.portfolio-item.is-hidden { opacity: 0 !important; visibility: hidden !important; pointer-events: none !important; }

.portfolio-item img { 
    width: 100%; 
    height: auto; 
    display: block; 
    border-radius: 2px; 
    transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease), opacity 0.4s var(--ease); 
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.item-details { padding: 15px 0 45px; display: none; }

.item-details span { 
    font-size: 0.6rem; 
    font-weight: 600; 
    text-transform: uppercase; 
    color: var(--accent); 
    letter-spacing: 1px; 
    transition: color 0.3s ease;
}

.item-details h3 { 
    margin: 6px 0 0; 
    font-size: 1.15rem; 
    font-weight: 400; 
    letter-spacing: -0.2px; 
    transition: color 0.3s ease;
}

@media (max-width: 1000px) { .portfolio-item { width: calc(50% - 15px); } }
@media (max-width: 600px) { .portfolio-item { width: 100%; } }

/* --- Lightbox --- */
.lightbox { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: var(--bg); 
    z-index: 2000; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    opacity: 0; 
    visibility: hidden; 
    transition: 0.4s var(--ease); 
    padding: 5vw; 
}

.lightbox.active { opacity: 1; visibility: visible; }

.lightbox-content { 
    display: flex; 
    max-width: 1200px; 
    width: 100%; 
    gap: 60px; 
    align-items: center; 
    position: relative; 
}

.close-lightbox { 
    position: fixed; 
    top: 30px; 
    right: 30px; 
    font-size: 3rem; 
    font-weight: 100; 
    color: var(--text); 
    cursor: pointer; 
    z-index: 2100; 
    transition: color 0.3s ease; 
}

.lightbox-img { 
    max-width: 65%; 
    max-height: 80vh; 
    object-fit: contain; 
    user-select: none; 
    -webkit-user-drag: none;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
    will-change: transform;
}

.lightbox-info { width: 35%; }

.lightbox-info h2 { 
    font-size: 2.5rem; 
    font-weight: 300; 
    margin-bottom: 20px; 
    letter-spacing: -1.5px; 
    transition: color 0.3s ease; 
}

.lightbox-info p { font-weight: 300; color: var(--accent); line-height: 1.7; }

.lightbox-info a { 
    color: var(--brand); 
    font-weight: 600; 
    text-decoration: none; 
    border-bottom: 1px solid var(--brand); 
    transition: color 0.3s, border-color 0.3s; 
}

.lightbox-info a:hover { color: var(--text); border-color: var(--text); }

.info-btn {
    display: none;
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: none;
    color: var(--text);
    border: none;
    padding: 10px 20px;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
    z-index: 2100;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 4px;
    opacity: 0.6;
    transition: opacity 0.3s;
}

.info-btn:hover { opacity: 1; }

@media (max-width: 900px) { 
    .lightbox { padding: 0; }
    .lightbox-img { max-width: 100%; max-height: 100vh; padding: 20px; }
    .lightbox-content { justify-content: center; }
    
    .lightbox-info { 
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        background: var(--nav-bg);
        backdrop-filter: blur(15px);
        padding: 40px 5% 80px; 
        border-top: 1px solid var(--line);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.4s var(--ease), visibility 0.4s var(--ease), background-color 0.3s ease, border-color 0.3s ease;
        z-index: 2050;
        max-height: 60vh;
        overflow-y: auto;
    }

    .lightbox-info h2 { font-size: 1.6rem; margin-bottom: 10px; letter-spacing: -1px; }
    .lightbox-info.show-drawer { opacity: 1; visibility: visible; }
    .info-btn { display: block; }
}

/* --- Contact Section --- */
.contact-section { 
    padding: 100px 5%; 
    border-top: 1px solid var(--line); 
    max-width: 1100px; 
    margin: 80px auto; 
    display: block; 
    transition: border-color 0.3s ease; 
}

.contact-info h2 { font-size: 2.2rem; font-weight: 300; margin: 0 0 20px; letter-spacing: -0.5px; }
.contact-info p { font-weight: 300; color: var(--accent); font-size: 1.1rem; line-height: 1.7; transition: color 0.3s ease; }

.contact-form { margin-top: 40px; display: flex; flex-direction: column; gap: 25px; max-width: 600px; }

.form-group { position: relative; margin-top: 10px; }

.form-group label { 
    position: absolute;
    top: 16px;
    left: 15px;
    font-size: 0.95rem; 
    font-weight: 400; 
    color: var(--accent); 
    background: var(--bg); 
    padding: 0 4px;
    transition: 0.3s var(--ease); 
    pointer-events: none; 
}

.contact-form input, .contact-form textarea {
    width: 100%; 
    padding: 16px 15px; 
    border: 1px solid var(--line); 
    background: transparent; 
    color: var(--text);
    font-family: 'Inter', sans-serif; 
    font-size: 1rem; 
    border-radius: 4px; 
    transition: border-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease;
}

.contact-form input:focus, .contact-form textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22, 105, 122, 0.1); }

.contact-form input::placeholder, .contact-form textarea::placeholder { color: transparent; transition: color 0.3s ease; }
.contact-form input:focus::placeholder, .contact-form textarea:focus::placeholder { color: var(--accent); opacity: 0.4; }

.contact-form input:focus ~ label,
.contact-form input:not(:placeholder-shown) ~ label,
.contact-form textarea:focus ~ label,
.contact-form textarea:not(:placeholder-shown) ~ label {
    top: -10px;
    left: 10px;
    font-size: 0.75rem;
    color: var(--brand);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.submit-btn {
    align-self: flex-start; 
    padding: 12px 30px; 
    background: var(--text); 
    color: var(--bg); 
    border: none;
    border-radius: 4px; 
    font-family: 'Inter', sans-serif; 
    font-size: 0.9rem; 
    font-weight: 500; 
    text-transform: uppercase;
    letter-spacing: 1px; 
    cursor: pointer; 
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.2s ease; 
    margin-top: 5px;
}

.submit-btn:hover { background: var(--brand); transform: translateY(-2px); }

.form-result { font-size: 0.9rem; font-weight: 500; margin-top: 15px; display: none; }
.form-result.success { color: #4CAF50; display: block; }
.form-result.error { color: #f44336; display: block; }

/* --- Footer --- */
footer { 
    padding: 60px 5%; 
    border-top: 1px solid var(--line); 
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    font-size: 0.65rem; 
    color: var(--accent); 
    text-transform: uppercase; 
    letter-spacing: 2px; 
    font-weight: 400; 
    transition: border-color 0.3s ease, color 0.3s ease; 
}

.social-links { display: flex; gap: 25px; }

.social-links a {
    color: var(--text);
    opacity: 0.6;
    transition: opacity 0.3s, color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.social-links a:hover { opacity: 1; color: var(--brand); }

.social-links svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- Mobile Typography --- */
@media (max-width: 768px) {
    .about-text h2, .contact-info h2 {
        font-size: 1.65rem;
    }
}