/* Base Styles */
:root {
    /* Colors */
    --primary-color: #2D3436;
    --secondary-color: #0984E3;
    --accent-color: #00B894;
    --text-color: #2D3436;
    --background-color: #FFFFFF;
    --surface-color: #F5F6FA;
    --text-color-light: rgba(45, 52, 54, 0.6);
    --text-color-trans-10: rgba(45, 52, 54, 0.1);
    --surface-color-trans-5: rgba(45, 52, 54, 0.03);
    --error-color-trans-10: rgba(255, 118, 117, 0.1);
    --error-color: #FF7675;
    
    /* Typography */
    --font-primary: 'Space Grotesk', sans-serif;
    --font-size-base: 16px;
    --line-height-base: 1.6;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 2rem;
    --spacing-xl: 4rem;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Border Radius */
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 16px;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* --- Logo visibility for Dark Mode --- */
/* By default (light mode), show the light logo and hide the dark one */
.logo-light {
    display: block;
}
.logo-dark {
    display: none;
}

/* When dark mode is active, swap the display properties */
html.dark-mode .logo-light {
    display: none;
}
html.dark-mode .logo-dark {
    display: block;
}

/* --- Dark Mode Palette --- */
html.dark-mode {
    --primary-color: #E0E0E0;
    --secondary-color: #0984E3; /* Stays vibrant */
    --accent-color: #00B894; /* Stays vibrant */
    --text-color: #E0E0E0;
    --background-color: #1a1a1a;
    --surface-color: #2c2c2c;
    --text-color-light: rgba(224, 224, 224, 0.6);
    --text-color-trans-10: rgba(224, 224, 224, 0.1);
    --surface-color-trans-5: rgba(224, 224, 224, 0.05);
    --error-color-trans-10: rgba(255, 118, 117, 0.1);

    /* Dark mode specific shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
}

/* Reset & Base Styles */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: var(--font-size-base);
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    line-height: var(--line-height-base);
    color: var(--text-color);
    background-color: var(--background-color);
    transition: background-color var(--transition-normal), color var(--transition-normal);
    overflow-x: hidden;
}

/* Navigation */
.nav-container {
    background: var(--surface-color);
    border-radius: 14px;
    margin: 0 auto; /* Horizontal centering is handled by auto margins */
    max-width: 98vw;
    box-shadow: var(--shadow-md);
    padding: 0;
    position: sticky;
    top: 16px; /* The distance from the top when it becomes sticky */
    z-index: 9999;
    transition: background-color var(--transition-normal), box-shadow var(--transition-normal);
    transform: translateZ(0); /* Ensure it stays above other 3D elements */
    -webkit-transform: translateZ(0); 
}
.nav-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 2.5rem;
    min-height: 54px;
}
.logo {
    display: flex;
    align-items: center;
    font-size: 1.3rem;
    color: var(--text-color);
    font-weight: 600;
    letter-spacing: 0.5px;
}
.logo img {
    height: 32px;
    width: auto;
    margin-right: 10px;
}
.logo a {
    display: flex;
    align-items: center;
}
.logo a:focus-visible {
    outline: 2px solid var(--secondary-color);
    outline-offset: 4px;
    border-radius: var(--border-radius-sm);
}
.nav-links {
    display: flex;
    flex: 1 1 auto;
    justify-content: center;
    align-items: center;
    gap: 2.5rem;
}
.nav-link {
    color: var(--text-color);
    font-size: 1.05rem;
    font-weight: 400;
    text-decoration: none;
    padding: 0.2rem 0.7rem;
    transition: color 0.2s;
    letter-spacing: 0.2px;
}
.nav-link:hover {
    color: var(--secondary-color);
}
.nav-social-icons {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    margin-left: 1.5rem;
}
.nav-social-link, .nav-social-link i {
    color: var(--text-color) !important;
}
.nav-social-link:hover i {
    color: var(--accent-color) !important; /* Use accent color for hover */
    transform: scale(1.18) rotate(-8deg);
    transition: transform 0.3s, color 0.3s;
}
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1002;
    padding: 10px;
}
.menu-toggle span {
    display: block;
    width: 28px;
    height: 3px;
    margin: 5px 0;
    background: var(--text-color);
    border-radius: 2px;
    transition: 0.3s;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    background: transparent;
    border: 1px solid var(--text-color-trans-10);
    color: var(--text-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.theme-toggle-btn:hover {
    background: var(--surface-color);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.theme-toggle-btn i {
    position: absolute;
    transition: transform 0.4s ease, opacity 0.4s ease;
}

/* Light mode: show moon, hide sun */
.theme-toggle-btn .fa-sun {
    transform: translateY(150%) scale(0.5);
    opacity: 0;
}

/* Dark mode: show sun, hide moon */
html.dark-mode .theme-toggle-btn .fa-moon {
    transform: translateY(-150%) scale(0.5);
    opacity: 0;
}
html.dark-mode .theme-toggle-btn .fa-sun {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Theme toggle text visibility */
.theme-text-dark {
    display: none;
}
html.dark-mode .theme-text-light {
    display: none;
}
html.dark-mode .theme-text-dark {
    display: inline; /* Use inline to keep it on the same line */
}

/* Mobile Navigation Styles */
@media (max-width: 900px) {
    .nav-container {
        max-width: 95vw; /* Use a max-width to contain the nav */
        margin: 0 auto; /* Center the nav bar horizontally */
        border-radius: 12px; /* Add back some rounding for a floating effect */
        top: 8px; /* Adjust the sticky position for mobile view */
    }
    .nav-content {
        padding: 0.5rem 1rem;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
    .menu-toggle {
        display: block;
    }
    .container {
        /* Use 100% width to respect parent's boundaries and padding */
        width: 100%;
        padding: 0 0.5rem;
        box-sizing: border-box;
    }
    .logo {
        /* Ensure logo doesn't take up too much space */
        flex-shrink: 0;
    }
    .nav-links {
        display: none; /* Hide links by default */
        position: absolute;
        top: calc(100% + 5px); /* Position below the nav bar */
        left: 50%;
        transform: translateX(-50%);
        width: 100%;
        margin: 0 auto;
        background: var(--surface-color);
        flex-direction: column;
        align-items: center;
        padding: 1.5rem 0; /* Slightly more vertical padding */
        border-radius: 12px; /* Softer corners */
        box-shadow: 0 8px 30px rgba(0,0,0,0.25); /* More prominent shadow */
        gap: 1.2rem; /* Slightly more space between links */
        z-index: 1001; /* Ensure it's below the toggle button */
    }
    .nav-links.active {
        display: flex; /* Show when active */
    }
    #theme-toggle-mobile {
        display: flex; /* Ensure flex properties apply */
        justify-content: center;
        align-items: center;
        /* This is a button inside the mobile nav links */
        width: auto;
        height: auto;
        border-radius: var(--border-radius-md);
        gap: 0.7rem;
        padding: 0.5rem 1rem;
        margin-top: 1rem;
        border: 1px solid var(--text-color-trans-10);
        background: var(--surface-color-trans-5);
        font-size: 1rem;
        overflow: visible; /* Prevent clipping icons */
    }
    /* Reset icon styles for mobile button to fix overlap */
    #theme-toggle-mobile i {
        position: static;
        transform: none;
        opacity: 1;
    }
    /* Mobile theme icon visibility */
    #theme-toggle-mobile .theme-icon-sun {
        display: none;
    }
    html.dark-mode #theme-toggle-mobile .theme-icon-moon {
        display: none;
    }
    html.dark-mode #theme-toggle-mobile .theme-icon-sun {
        display: inline-block;
    }
    .nav-links.active .mobile-social-section {
        display: flex; /* Ensure social section is visible when menu is active */
    }
    .nav-link {
        font-size: 1.15rem;
        padding: 0.5rem 0;
        width: 100%;
        text-align: center;
        color: var(--text-color);
    }
    .nav-actions {
        display: none; /* Hide desktop actions container on mobile */
    }
    .menu-toggle {
        display: flex; /* Show hamburger menu */
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 30px; /* Smaller width */
        height: 30px; /* Smaller height */
        padding: 0; /* Remove padding */
    }
    .menu-toggle span {
        display: block;
        width: 24px; /* Smaller span width */
        height: 2px; /* Thinner span */
        margin: 3px 0; /* Reduced margin */
        background: var(--text-color);
        border-radius: 2px;
        transition: 0.3s;
    }
    /* Show mobile social icons inside the expanded menu */
        .mobile-social-section {
        display: none; /* Hidden by default on mobile */
        flex-direction: column;
        margin-top: 1.5rem; /* Adjusted margin from menu items */
        padding-top: 1rem; /* Adjusted internal padding */
        border-top: 1px solid var(--text-color-trans-10);
        text-align: center;
    }
    .nav-links.active .mobile-social-section {
        display: flex; /* Show when menu is active */
    }
    .mobile-social-title {
        color: #00b894;
        font-size: 0.8rem; /* Even smaller font for title */
        font-weight: 600;
        margin-bottom: 0.4rem; /* Reduced margin */
    }
    .mobile-social-icons {
        display: flex;
        justify-content: center;
        gap: 0.8rem; /* Smaller gap between icons */
    }
    .mobile-social-link {
        color: var(--text-color);
        font-size: 0.9rem; /* Smaller icon size */
        transition: color 0.2s, transform 0.2s;
    }
    .mobile-social-link:hover {
        color: var(--secondary-color);
        transform: scale(1.1);
    }
}
@media (max-width: 600px) {
    .nav-content {
        padding: 0.5rem 0.5rem;
    }
}
html {
    max-width: 100vw;
    overflow-x: hidden;
}

@media (min-width: 901px) {
    .menu-toggle,
    .mobile-social-section,
    #theme-toggle-mobile {
        display: none;
    }
    .nav-links {
        display: flex;
    }
    .nav-actions {
        display: flex;
        align-items: center;
        gap: 1.5rem;
    }
    .nav-social-icons {
        display: flex;
    }
    #theme-toggle-desktop {
        display: flex; /* Ensure it's visible on desktop */
    }

    /* Apply transform transition only on desktop to prevent resize glitches */
    .nav-container {
        transition: transform 0.4s ease, background-color var(--transition-normal), box-shadow var(--transition-normal);
    }

    /* Hides the navigation on scroll down (desktop only) */
    .nav-container.nav-hidden {
        transform: translateY(-110%);
    }
}


/* Hero Section */
.hero-section {
    min-height: calc(100vh - 72px);
    margin-top: 0;
    padding-top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 3rem var(--spacing-lg) 2rem;
    background: linear-gradient(135deg, var(--surface-color) 0%, var(--background-color) 100%);
}

.hero-content {
    text-align: center;
    max-width: 800px;
}

.hero-content h1 {
    font-size: 4rem;
    font-weight: 700;
    margin-bottom: var(--spacing-md);
    line-height: 1.2;
}

.hero-content h1.glitch-text {
    position: relative;
}

.hero-content h1.glitch-text::before,
.hero-content h1.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--surface-color); /* Match the hero background */
    overflow: hidden;
}

.hero-content h1.glitch-text::before {
    left: 2px;
    text-shadow: -2px 0 var(--accent-color);
    animation: glitch-anim-1 2s infinite linear alternate-reverse;
}

.hero-content h1.glitch-text::after {
    left: -2px;
    text-shadow: -2px 0 var(--secondary-color);
    animation: glitch-anim-2 1.5s infinite linear alternate-reverse;
}

.subtitle {
    font-size: 1.25rem;
    color: var(--text-color);
    opacity: 0.8;
    margin-bottom: var(--spacing-lg);
}

.cta-buttons {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--border-radius-md);
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--secondary-color);
    color: #FFFFFF;
}

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

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-icon {
    transition: transform var(--transition-normal);
}

.btn:hover .btn-icon {
    transform: translateX(4px);
}

/* Scroll Indicator */
.scroll-indicator {
    margin-top: auto; /* Push to the bottom */
    padding-bottom: 2rem; /* Add some space at the bottom */
}

.mouse {
    width: 30px;
    height: 50px;
    border: 2px solid var(--text-color);
    border-radius: 20px;
    position: relative;
}

.wheel {
    width: 4px;
    height: 8px;
    background: var(--text-color);
    border-radius: 2px;
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    animation: scroll 1.5s infinite;
}

.arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.arrow span {
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-color);
    border-bottom: 2px solid var(--text-color);
    transform: rotate(45deg);
    animation: arrow 1.5s infinite;
}

.arrow span:nth-child(2) {
    animation-delay: 0.2s;
}

.arrow span:nth-child(3) {
    animation-delay: 0.4s;
}

/* About Section */
.about-section {
    padding: var(--spacing-xl) 0;
    background: var(--background-color);
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

.section-header {
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

.section-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: var(--spacing-md);
}

.about-content {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: var(--spacing-xl);
    align-items: center;
}

.about-image {
    position: relative;
}

.about-image .image-wrapper {
    position: relative;
    border-radius: 50%;
    overflow: visible;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 1.5px 8px rgba(0,184,148,0.12);
    width: 400px;
    height: 400px;
    margin: 0 auto;
    background: linear-gradient(135deg, #00b894, #0984e3, #e1306c, #f9ca24, #00b894);
    background-size: 400% 400%;
    animation: gradientBorder 6s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes gradientBorder {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.about-image .parallax-image {
    width: 350px;
    height: 350px;
    object-fit: cover;
    object-position: center top;
    border: 10px solid var(--background-color);
    border-radius: 50%;
    box-shadow: 0 4px 24px rgba(0,0,0,0.18);
    background: var(--background-color);
    transition: transform 0.5s cubic-bezier(.23,1.02,.64,.97), box-shadow 0.5s;
    z-index: 2;
    position: relative;
}

.about-image .image-wrapper:hover .parallax-image {
    transform: scale(1.07) rotate(-2deg);
    box-shadow: 0 8px 40px 0 rgba(0,184,148,0.18), 0 2px 16px rgba(9,132,227,0.13);
}

.about-image .image-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border-radius: 50%;
    pointer-events: none;
    background: linear-gradient(120deg, rgba(9,132,227,0.12) 0%, rgba(225,48,108,0.12) 100%);
    opacity: 0.7;
    z-index: 3;
    transition: opacity 0.4s;
    animation: overlayGlow 3s ease-in-out infinite alternate;
}

@keyframes overlayGlow {
    0% { box-shadow: 0 0 0 0 rgba(0,184,148,0.18); }
    100% { box-shadow: 0 0 32px 8px rgba(0,184,148,0.12); }
}

.about-image .image-wrapper:hover .image-overlay {
    opacity: 1;
}

.profile-name-title {
    text-align: center;
}

.profile-name-title h3 {
    margin: 10px 0 0 0;
    font-size: 1.25rem;
    font-weight: 600;
}
.profile-name-title p {
    margin: 0;
    font-size: 1rem;
    color: var(--text-color-light);
}
@media (max-width: 600px) {
    .about-image .image-wrapper {
        width: 250px;
        height: 250px;
    }
    .about-image .parallax-image {
        width: 210px;
        height: 210px;
        border-width: 6px;
        object-fit: cover;
        object-position: center top;
    }
}

.about-text {
    font-size: 1.1rem;
}

.lead-text {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: var(--spacing-md);
    color: var(--secondary-color);
}

/* Skills Grid */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.skill-category {
    background: var(--surface-color-trans-5);
    border-radius: 15px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    border: 1px solid var(--text-color-trans-10);
    backdrop-filter: blur(10px);
}

.skill-category:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-color);
}

.skill-category h3 {
    color: var(--accent-color);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.skill-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.skill-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    color: var(--text-color);
    transition: all 0.3s ease;
}

.skill-list li:hover {
    color: var(--accent-color);
    transform: translateX(5px);
}

.skill-icon {
    color: var(--accent-color);
    font-size: 1.1rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-color-trans-5);
    border-radius: 6px;
    transition: all 0.3s ease;
}

.skill-list li:hover .skill-icon {
    background: var(--accent-color);
    color: var(--background-color);
    transform: rotate(10deg);
}

/* Category-specific colors */
.skill-category[data-category="it"] {
    border-left: 3px solid #4CAF50;
}

.skill-category[data-category="support"] {
    border-left: 3px solid #2196F3;
}

.skill-category[data-category="development"] {
    border-left: 3px solid #FF9800;
}

.skill-category[data-category="media"] {
    border-left: 3px solid #E91E63;
}

/* Gallery Section */
.gallery-section {
    padding: var(--spacing-xl) 0;
    background: var(--background-color);
}

.gallery-grid {
    /* Use CSS Columns for a dynamic masonry effect on all screen sizes */
    display: block;
    column-count: 4;
    column-gap: 1rem;
    margin-top: 1.5rem;
}

.gallery-item {
    cursor: pointer;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    /* Consolidate transitions for hover and scroll animations */
    transition: opacity 0.6s ease-out, 
                transform 0.6s ease-out, 
                box-shadow 0.3s ease;
    margin-bottom: 1rem; /* Add space between items vertically */
    break-inside: avoid; /* Prevent items from breaking across columns */
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.gallery-item img {
    width: 100%;
    height: auto; /* Let the image define its own height to maintain aspect ratio */
    min-height: 50px; /* Prevent total collapse before load */
    display: block; /* Prevents extra space below the image */
    transition: transform 0.5s ease;
    will-change: transform; /* Hint for smoother animation */
}
}

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

.gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.6rem 0.9rem;
    background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, transparent 100%);
    color: #fff;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.gallery-caption-text {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Desktop: slide up on hover */
.gallery-item:hover .gallery-caption {
    transform: translateY(0);
}
/* Mobile: always visible */
@media (max-width: 768px) {
    .gallery-caption {
        transform: translateY(0);
    }
}

/* Responsive Gallery */
@media (max-width: 1200px) {
    .gallery-grid {
        column-count: 3; /* Adjust column count for medium screens */
    }
}

@media (max-width: 768px) {
    .gallery-grid {
        display: block;
        column-count: 2;
        column-gap: 1rem;
    }
    .gallery-item {
        display: inline-block; /* Essential for masonry to not cut off */
        width: 100%;
        margin-bottom: 1rem;
        break-inside: avoid;
        -webkit-column-break-inside: avoid;
        transform: translateZ(0); /* Keep HW acceleration for smooth scroll */
        -webkit-backface-visibility: hidden; /* Fix for flickering/disappearing on iOS */
        backface-visibility: hidden;
    }
    .scroll-indicator {
        bottom: 0.5rem;
    }
}

/* Loading States */
.gallery-item.loading {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-item.loading::before {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid var(--text-color-trans-10);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error State */
.gallery-item.error {
    background: var(--error-color-trans-10);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--error-color);
    font-size: 0.9rem;
    text-align: center;
    padding: 1rem;
}

/* Gallery Modal */
.gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.gallery-modal.active {
    display: flex;
}

.modal-content {
    position: relative;
    /* Make the container shrink-to-fit the image */
    display: inline-block;
    line-height: 0; /* Remove extra space below the image */
}

.modal-content img {
    /* Constrain the image to the viewport */
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    display: block;
}

.modal-close,
.custom-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 300;
    color: #FFFFFF;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.modal-close:hover,
.custom-modal-close:hover {
    background: var(--accent-color);
    transform: scale(1.1) rotate(90deg);
    border-color: transparent;
}

/* Hide custom cursor when modal is active */
.gallery-modal.active ~ .cursor,
.gallery-modal.active ~ .cursor-follower {
    display: none !important;
}

/* Ensure default cursor for modal content */
.gallery-modal * {
    cursor: default;
}

/* Ensure pointer cursor for close buttons */
.modal-close, .custom-modal-close { cursor: pointer; }

/* Video Modal (Custom) */
.custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none; /* Controlled by JS, which sets it to 'flex' */
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.custom-modal-content {
    position: relative;
    background: #000;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    line-height: 0; /* Removes extra space around video */
}

#customModalVideo {
    max-width: 90vw;
    max-height: 90vh;
    display: block;
    background: #000;
    outline: none;
}

/* Video Section */
.video-section {
    padding: var(--spacing-xl) 0;
    background: var(--background-color);
}

.video-grid {
    columns: 3;
    column-gap: 1rem;
    margin-top: 2rem;
}
@media (max-width: 1024px) {
    .video-grid { columns: 2; }
}
@media (max-width: 768px) {
    .video-grid {
        columns: 2;
        column-gap: 0.75rem;
    }
}
.video-item {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: var(--border-radius-lg);
    background: #000;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    break-inside: avoid;
    margin-bottom: 0.85rem;
    display: inline-block; /* Required for CSS columns masonry */
}

/* Thumbnail — fills card naturally */
.video-thumbnail-video {
    width: 100%;
    height: auto;
    max-height: 320px;
    object-fit: cover;
    display: block;
    border-radius: inherit;
    transition: opacity 0.3s ease;
    background: #111;
}
/* Preview video — hidden, shows on hover */
.video-preview {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    max-height: 320px;
    object-fit: cover;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    border-radius: inherit;
}
.video-item:hover .video-preview { opacity: 1; pointer-events: auto; }
.video-item:hover .video-thumbnail { opacity: 0; }

.video-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.22);
    opacity: 0;
    transition: opacity 0.25s ease;
    z-index: 2;
    pointer-events: none;
    border-radius: inherit;
}
.video-item:hover .video-overlay { opacity: 1; pointer-events: auto; }

.play-btn-modern {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.22);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.35);
    transition: transform 0.2s ease, background 0.2s ease;
    flex-shrink: 0;
}
.play-btn-modern i {
    color: #fff;
    font-size: 0.75rem;
    margin-left: 2px;
    line-height: 1;
    display: block;
}
.video-item:hover .play-btn-modern,
.video-item:active .play-btn-modern {
    transform: scale(1.15);
    background: rgba(255,255,255,0.32);
}

.video-title {
    position: absolute;
    bottom: 0; left: 0;
    right: 0;
    padding: 0.6rem 0.9rem;
    background: linear-gradient(to top, rgba(0,0,0,0.75), transparent);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 3;
    text-align: left;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.video-item:hover .video-title {
    transform: translateY(0);
}
/* Mobile: always visible */
@media (max-width: 768px) {
    .video-title {
        transform: translateY(0);
    }
}

.video-container {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
}

.video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Loading States */
.video-item.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--surface-color);
    z-index: 3;
}

.video-item.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid var(--secondary-color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 4;
}

.video-item.error::before {
    content: 'Error loading video';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--error-color);
    font-size: 0.9rem;
    z-index: 4;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Contact Section */
.contact-section {
    padding: var(--spacing-xl) 0;
    background: var(--background-color);
}

.contact-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.contact-info {
    margin-bottom: var(--spacing-lg);
}

.contact-details {
    margin: var(--spacing-lg) 0;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    font-size: 1.1rem;
    color: var(--text-color);
}

.contact-item i {
    color: var(--secondary-color);
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.contact-item span {
    font-weight: 500;
}

.social-links {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.social-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: var(--text-color);
    text-decoration: none;
    transition: color var(--transition-normal);
}

.social-link:hover {
    color: var(--secondary-color);
}

.contact-form {
    background: var(--background-color);
    padding: var(--spacing-xl);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
}

.form-group {
    position: relative;
    margin-bottom: 2rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.8rem 0;
    font-size: 1rem;
    color: var(--text-color);
    border: none;
    border-bottom: 2px solid var(--surface-color);
    outline: none;
    background: transparent;
    transition: border-color var(--transition-normal);
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

.form-group label {
    position: absolute;
    top: var(--spacing-md);
    left: var(--spacing-md);
    color: var(--text-color);
    opacity: 0.6;
    transition: all var(--transition-normal);
    pointer-events: none;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.form-group input:focus + label,
.form-group textarea:focus + label,
.form-group input:not(:placeholder-shown) + label,
.form-group textarea:not(:placeholder-shown) + label {
    top: -20px;
    left: 0;
    font-size: 0.875rem;
    color: var(--secondary-color);
    opacity: 1;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--background-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loader {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.loader-circle {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 4px solid var(--surface-color);
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-logo {
    height: 60px;
    width: auto;
    object-fit: contain;
    animation: fadeInOut 1.5s ease-in-out infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeInOut {
    0% { opacity: 0.3; }
    50% { opacity: 1; }
    100% { opacity: 0.3; }
}

/* Animations */
@keyframes scroll {
    0% {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateX(-50%) translateY(20px);
        opacity: 0;
    }
}

@keyframes arrow {
    0% {
        opacity: 0;
        transform: rotate(45deg) translate(-10px, -10px);
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: rotate(45deg) translate(10px, 10px);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .hero-section {
        min-height: auto;
        padding-top: 2rem;
        padding-bottom: 2rem;
    }

    .about-content,
    .contact-content {
        grid-template-columns: 1fr;
    }
    
    .about-image {
        max-width: 500px;
        margin: 0 auto;
    }
}

/* Specific rule for iPad Pro */
@media (min-width: 1024px) and (max-width: 1366px) {
    .hero-section {
        min-height: auto;
        padding-top: 3rem;
        padding-bottom: 3rem;
    }
}

@media (max-width: 768px) {
    .hero-section {
        padding-top: 6rem; /* Reduced top padding for mobile */
        min-height: auto; /* Allow section to size naturally */
        padding-bottom: 4rem;
    }

    .hero-content h1 {
        font-size: 2.8rem; /* Adjust font size for smaller screens */
    }

    .subtitle {
        font-size: 1.1rem;
    }

    .cta-buttons {
        flex-direction: column; /* Stack buttons vertically */
        align-items: center; /* Center-align buttons */
    }

    .btn {
        width: 80%; /* Make buttons wider */
        text-align: center; /* Center text inside buttons */
        justify-content: center;
    }

    .experience-grid {
        grid-template-columns: 1fr;
    }


    /* Disable the hover-to-preview effect on mobile */
    .video-item:hover .video-preview {
        opacity: 0;
        pointer-events: none;
    }

    .scroll-indicator {
        display: none; /* Hide the scroll indicator on mobile */
    }
}

@media (max-width: 480px) {
    .hero-content h1 {
        font-size: 2.2rem; /* Further adjust font size */
    }

.subtitle {
    font-size: 1rem;
}

.section-title {
    font-size: 2rem;
}

.skills-grid {
    grid-template-columns: 1fr;
}
}

.experience-item {
    background: var(--surface-color);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.experience-section {
    padding: var(--spacing-xl) 0;
    background: var(--background-color);
}

.experience-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-lg);
    margin-top: var(--spacing-lg);
}



.experience-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.experience-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    position: relative;
    background: var(--surface-color);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm);
}

.experience-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform var(--transition-normal);
}

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

.experience-content {
    padding: var(--spacing-md);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.experience-content h3 {
    color: var(--secondary-color);
    font-size: 1.2rem;
    margin-bottom: var(--spacing-xs);
}

.experience-role {
    color: var(--accent-color);
    font-weight: 500;
    margin-bottom: var(--spacing-sm);
}

.experience-description {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-color);
    opacity: 0.9;
}

@media (max-width: 1200px) {
    .experience-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .experience-grid {
        grid-template-columns: 1fr;
    }
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-size: 1.1rem;
    color: var(--text-color);
    background: var(--background-color);
    border-radius: 8px;
    padding: 0.5rem 1.2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.25s, color 0.25s, box-shadow 0.25s;
    cursor: pointer;
}

.contact-item:hover {
    color: var(--secondary-color);
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,119,181,0.13);
}

.contact-item i {
    color: var(--secondary-color);
    font-size: 1.3rem;
    transition: color 0.25s;
}

.social-icons-row {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 2.5rem;
    margin: 1.5rem 0 1.5rem 0;
    flex-wrap: nowrap;
}

.social-icon-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-color);
    font-size: 1.1rem;
    transition: color 0.2s;
}

.social-icon-link i {
    font-size: 2.8rem;
    margin-bottom: 0.5rem;
    transition: transform 0.3s, color 0.3s;
}

.social-icon-link span {
    font-size: 1rem;
    margin-top: 0.2rem;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.social-icon-link[data-platform="linkedin"]:hover i { color: #0077b5; transform: scale(1.18) rotate(-8deg); }
.social-icon-link[data-platform="tiktok"]:hover i { color: #000; transform: scale(1.18) rotate(8deg); }
.social-icon-link[data-platform="facebook"]:hover i { color: #1877f3; transform: scale(1.18) rotate(-8deg); }
.social-icon-link[data-platform="instagram"]:hover i { color: #e1306c; transform: scale(1.18) rotate(8deg); }
.social-icon-link[data-platform="whatsapp"]:hover i { color: #25d366; transform: scale(1.18) rotate(-8deg); }

.contact-row {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 2.5rem;
    margin-bottom: 2rem;
    flex-wrap: nowrap;
}

@media (max-width: 768px) {
    .social-icons-row {
        /* Reverted to a wrapping row, icons are shrunk to fit on one line */
        display: flex;
        flex-wrap: nowrap; /* Force icons onto a single line */
        justify-content: center;
        gap: 1rem; /* Further reduced gap to help items fit */
        padding: 0 0.5rem; /* Add slight horizontal padding */
    }
    .social-icon-link i {
        font-size: 2rem; /* Further shrink icons to save space */
    }
    .social-icon-link span {
        display: block; /* Ensure text is visible */
        font-size: 0.7rem; /* Further shrink text to fit */
    }
    .contact-row {
        /* Stack contact items vertically for clear, tappable actions */
        flex-direction: column;
        gap: 1rem;
        width: 100%;
        max-width: 350px;
        margin-left: auto;
        margin-right: auto;
    }
    .contact-item {
        width: 100%;
        justify-content: center; /* Center the content within the button-like item */
        padding: 0.8rem 1rem;
    }
}

.contact-email-link {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s, text-decoration 0.2s;
}
.contact-email-link:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

.contact-phone-link {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s, text-decoration 0.2s;
}
.contact-phone-link:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

.site-footer {
    width: 100%;
    background: var(--background-color);
    padding: 1.2rem 0;
    text-align: center;
    font-size: 1.05rem;
    color: var(--text-color-light);
    letter-spacing: 1px;
    border-top: 1px solid var(--text-color-trans-10);
    margin-top: 2rem;
}
.site-footer p {
    margin: 0;
}

.scroll-to-top-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background-color: var(--secondary-color);
    color: #FFFFFF !important; /* Ensure icon color is white */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    cursor: pointer;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.3s ease;
    box-shadow: var(--shadow-md);
    pointer-events: none;
    text-decoration: none;
}

.scroll-to-top-btn.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.scroll-to-top-btn:hover {
    background-color: var(--accent-color);
    transform: scale(1.1);
}

.floating-bg-icons {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%; /* Use 100% to avoid overflow from scrollbars */
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

/* Hide on desktop by default */
@media (min-width: 901px) {
    .scroll-to-top-btn {
        display: none !important;
    }
}
.floating-bg-icons .icon {
    position: absolute;
    /* Make icons large, blurred, and subtle for a modern "aurora" effect */
    font-size: 25rem; /* Much larger to act as color blobs */
    opacity: 0.15;
    user-select: none;
    pointer-events: none;
    animation: floatIcon 18s ease-in-out infinite;
    filter: blur(100px); /* Heavy blur to create soft color washes */
    transition: opacity 0.5s ease;
}

@media (max-width: 768px) {
    .video-overlay {
        opacity: 1 !important;
        background: transparent;
    }
    .video-title {
        transform: translateY(0) !important;
    }
    .floating-bg-icons .icon {
        filter: blur(40px); /* Reduce blur load */
        animation: none; /* Stop continuous repaints */
        opacity: 0.1;
    }
}

html.dark-mode .floating-bg-icons .icon {
    opacity: 0.1; /* Make them even more subtle in dark mode */
}
.floating-bg-icons .icon-code {
    color: var(--secondary-color);
    top: 5%; left: -5%; animation-delay: 0s;
}
.floating-bg-icons .icon-social {
    color: var(--accent-color);
    top: 20%; right: -10%; animation-delay: 3s;
}
.floating-bg-icons .icon-design {
    color: #e1306c; /* A pinkish color to add variety */
    top: 60%; left: 20%; animation-delay: 6s;
}
.floating-bg-icons .icon-network {
    color: #f9ca24; /* A yellowish color for more variety */
    bottom: -10%; right: 30%; animation-delay: 9s;
}
@keyframes floatIcon {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-30px) scale(1.08); }
}

.tech-stack-section {
    padding: var(--spacing-xl) 0;
    background: var(--background-color);
}
.tech-icons-grid {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 2rem;
    justify-content: flex-start;
    align-items: center;
    margin-top: 2rem;
    padding: 0.5rem 1rem 1.5rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    cursor: grab;
}
.tech-icons-grid::-webkit-scrollbar { display: none; }
.tech-icons-grid:active { cursor: grabbing; }
.tech-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 2.5rem;
    color: var(--secondary-color);
    background: var(--surface-color-trans-5);
    border-radius: 12px;
    padding: 1.2rem 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: background 0.3s, color 0.3s, transform 0.2s;
    min-width: 90px;
}
.tech-icon span {
    font-size: 1rem;
    margin-top: 0.5rem;
    color: var(--text-color);
    font-weight: 500;
}
.tech-icon:hover {
    background: var(--secondary-color);
    color: #FFFFFF;
    transform: translateY(-6px) scale(1.08);
}
.tech-icon:hover span {
    color: #FFFFFF;
}

/* Mobile & tablet: smaller icons */
@media (max-width: 1024px) {
    .tech-icon {
        flex-shrink: 0;
        font-size: 2rem;
        padding: 1rem;
        min-width: 80px;
    }
    .tech-icon span { font-size: 0.82rem; }
}

.cursor-follower.clicked {
    transform: scale(0.8);
}

/* --- Scroll-Triggered Animations (Desktop Only) --- */

/* Default State (Mobile): Visible and interactive */
.section-header,
.about-content,
.gallery-item,
.video-item,
.contact-content,
.experience-item,
.tech-icon {
    /* No animation properties here - purely native behavior for mobile */
    opacity: 1;
    transform: translateZ(0); /* Keep GPU acceleration for smooth scrolling */
    -webkit-transform: translateZ(0);
}

/* Desktop Animation Logic */
@media (min-width: 769px) {
    /* 1. Initial state for elements that will be animated */
    .section-header,
    .about-content,
    .gallery-item,
    .video-item,
    .contact-content,
    .experience-item,
    .tech-icon {
        opacity: 0;
        transform: translateY(20px);
        transition: opacity 0.6s ease-out, transform 0.6s ease-out;
        will-change: opacity, transform;
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }

    /* 2. The state to apply when the .animate class is added by JavaScript */
    .animate {
        opacity: 1;
        transform: translateY(0);
    }
}
