/* Base styles */
:root {
    --primary-color: #2a2a2a;
    --secondary-color: #f5f5f5;
    --accent-color: #3498db;
    --text-color: #333;
    --light-text: #fff;
    --spacing-unit: 1rem;
}

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

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

body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--secondary-color);
    overflow-x: hidden; /* Prevent horizontal scrolling */
    width: 100%;
    max-width: 100vw;
    position: relative;
}

a {
    text-decoration: none;
    color: var(--accent-color);
    transition: color 0.3s ease;
}

a:hover {
    color: #2980b9;
}

h1, h2, h3, h4 {
    margin-bottom: var(--spacing-unit);
    font-weight: 700;
}

section {
    padding: 4rem 2rem;
}

#work {
    padding: 12rem 0; /* Greatly increased padding to accommodate expanded cards */
    background-image: url('../public/work-bg.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    position: relative;
    
    /* Performance optimizations */
    will-change: transform;
    
    /* Allow overflow for expanded cards */
    overflow: visible;
    z-index: 3; /* Higher than adjacent sections but still below modals */
}

#work::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.2);
    z-index: 0;
    pointer-events: none; /* Ensure this doesn't block interactions */
}

#work h2 {
    margin-left: 2rem;
    position: relative;
    z-index: 1;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Navigation */
header {
    background-color: rgba(42, 42, 42, 0.85); /* Starting color - will be dynamically changed */
    color: var(--light-text);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    transition: background-color 0.4s ease, color 0.4s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
}

nav ul {
    display: flex;
    list-style: none;
}

nav ul li {
    margin-left: 2rem;
}

nav ul li a {
    color: var(--light-text);
    transition: color 0.4s ease;
}

nav ul li a:hover {
    color: var(--accent-color);
}

/* Hero section */
#hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Align to top instead of center */
    align-items: center;
    text-align: center;
    padding-top: 20vh; /* Move content up by ~15% (100vh - 20vh = position at ~20% from top) */
    background-color: var(--primary-color);
    background-image: url('../public/hero-bg.jpg');
    background-size: cover;
    background-position: center center;
    background-attachment: fixed; /* Fix background image position */
    background-blend-mode: overlay;
    filter: brightness(2.25); /* Original brightness setting */
    position: relative;
    color: var(--light-text);
    z-index: 0; /* Ensure consistent z-index and prevent layering issues */
    transform: translateZ(0); /* Force GPU rendering */
    backface-visibility: hidden; /* Prevent flickering */
}

.hero-content {
    z-index: 5; /* Higher z-index to appear above the section */
    padding: 2.5rem;
    border-radius: 12px;
    background-color: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    max-width: 800px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    position: relative; /* Ensure z-index works correctly */
}

#hero h1 {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 0, 0, 0.4);
    letter-spacing: 1px;
}

#hero h2 {
    font-size: 1.8rem;
    font-weight: 400;
    margin-bottom: 2rem;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8), 0 0 10px rgba(0, 0, 0, 0.4);
    letter-spacing: 0.5px;
}

#hero p {
    font-size: 1.2rem;
    max-width: 600px;
    margin: 0 auto;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Work section - Carousel and Modals */
.carousel-container {
    position: relative;
    width: 92%; /* Slightly less than 100% to prevent edge effects */
    max-width: 1600px;
    margin: 0 auto;
    perspective: 1000px;
    padding: 8rem 0; /* Significantly increased padding to prevent clipping */
    z-index: 5; /* Higher than sections but lower than modals */
    
    /* Contain overflow to prevent horizontal scrolling */
    overflow-x: hidden;
}

.carousel {
    display: flex;
    transition: transform 0.5s ease;
    gap: 2.5rem; /* Increased gap between cards */
    transform-style: preserve-3d;
    will-change: transform;
    position: relative;
    z-index: 10; /* Ensure carousel content is above sections */
    margin: 0 10%; /* Add side margins to prevent cards from going to the edges */
    max-width: 100%;
    overflow: visible; /* Allow 3D effect but ensure parent contains overflow */
}

.loading-placeholder {
    width: 100%;
    text-align: center;
    padding: 3rem 0;
    font-style: italic;
    color: #888;
}

.project-card {
    flex: 0 0 300px;
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.5s ease;
    cursor: pointer;
    transform-origin: center center;
    backface-visibility: hidden;
    will-change: transform, opacity;
    margin: 0 10px; /* Add horizontal margin to cards */
    position: relative; /* For focus indicator */
    
    /* Force hardware acceleration and prerender */
    -webkit-backface-visibility: hidden;
    -webkit-perspective: 1000;
    -webkit-transform: translate3d(0,0,0);
    transform: translate3d(0,0,0);
    z-index: 10; /* Higher z-index to prevent clipping by adjacent sections */
}

/* Focus indicator for keyboard navigation */
.project-card:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-color), 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Centered card styles for keyboard navigation */
.project-card.centered {
    box-shadow: 0 0 0 3px var(--accent-color), 0 6px 12px rgba(0, 0, 0, 0.2);
    z-index: 15 !important;
}

/* Disable the absolute positioning for centered cards */
/* Remove the special hover effect for centered cards */

/* When a modal is active, ensure all cards stay below it, but don't affect z-index otherwise */
.project-modal-overlay.active ~ .carousel-container .project-card,
.project-modal-overlay.active ~ #work .carousel-container .project-card {
    z-index: 1 !important;
}

/* When modal is NOT active, allow cards to expand freely */
.carousel-container .project-card {
    z-index: auto; /* Let natural stacking context determine z-index */
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    z-index: 20 !important; /* Ensure hovered cards are always on top */
}

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

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

/* Media thumbnail styling */
.media-thumbnail {
    position: relative;
}

.media-thumbnail .play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
}

.media-thumbnail .play-overlay::after {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 20px 0 20px 35px;
    border-color: transparent transparent transparent #ffffff;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.3));
    transition: transform 0.3s ease;
}

.project-card:hover .media-thumbnail .play-overlay::after {
    transform: scale(1.2);
}

.project-info {
    padding: 1rem;
}

.project-info h3 {
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.project-summary {
    font-size: 0.9rem;
    color: #555;
}

.project-year {
    font-size: 0.9rem;
    color: #777;
    margin-top: 0.3rem;
    font-style: italic;
}

.carousel-control {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: var(--light-text);
    border: none;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.9;
    transition: all 0.3s ease;
    z-index: 15; /* Higher z-index to ensure buttons are always clickable */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.carousel-control:hover {
    opacity: 1;
}

.carousel-control.prev {
    left: 4%;
}

.carousel-control.next {
    right: 4%;
}

.carousel-control.active-direction {
    background-color: var(--accent-color);
    transform: translateY(-50%) scale(1.2);
    opacity: 1;
}

/* Project Modal */
.project-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999; /* Very high z-index */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none; /* Initially no pointer events */
    transform: translateZ(0); /* Force GPU acceleration */
}

.project-modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* Enable pointer events when active */
}

.project-modal {
    background-color: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    display: none;
    position: relative;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
    z-index: 10000; /* Extremely high z-index */
}

.project-modal.active {
    display: block;
    animation: modalFadeIn 0.4s forwards;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--primary-color);
    color: var(--light-text);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: background-color 0.3s ease;
}

.modal-close:hover {
    background-color: #444;
}

.modal-content {
    padding: 2rem;
}

.modal-content img {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

/* Modal navigation buttons */
.modal-nav {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-nav-btn {
    background-color: var(--accent-color);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: all 0.2s ease;
    pointer-events: auto;
    margin: 0 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.modal-nav-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.modal-nav-btn.prev {
    margin-left: -25px;
}

.modal-nav-btn.next {
    margin-right: -25px;
}

.modal-text h3 {
    margin-bottom: 1rem;
    font-size: 1.8rem;
}

.modal-text p {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.project-description {
    margin: 1.5rem 0;
    line-height: 1.8;
    color: #333;
}

.project-links {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.project-links a {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: var(--accent-color);
    color: white;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.3s ease;
}

.project-links a:hover {
    background-color: #2980b9;
}

/* Embedded media styles */
.project-media {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.media-embed {
    width: 100%;
}

.youtube-embed,
.iframe-embed {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
}

.youtube-embed iframe,
.iframe-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.instagram-embed {
    position: relative;
    width: 100%;
    overflow: hidden;
    margin: 0 auto;
    max-width: 540px;
    background-color: black;
    border-radius: 8px;
    padding-bottom: 10px;
    height: 260px; /* Reduced by 60px as requested */
}

.instagram-embed iframe {
    border: none !important;
    position: relative !important;
    background-color: black;
    border-radius: 4px;
    width: 100%;
    transform: scale(1.01); /* Slightly enlarge to hide borders */
    margin-top: -60px; /* Hide the Instagram header */
    margin-bottom: -260px; /* Even more aggressively crop Instagram footer */
    height: 580px; /* Make taller to account for margins */
    pointer-events: auto; /* Ensure video controls remain clickable */
}

.video-controls {
    position: absolute;
    text-align: center;
    bottom: 5px;
    right: 10px;
    z-index: 10;
}

.video-controls a {
    color: #fff;
    font-size: 0.8rem;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    text-decoration: none;
    background-color: rgba(0,0,0,0.5);
    padding: 2px 8px;
    border-radius: 4px;
}

.video-controls a:hover {
    opacity: 1;
}

/* Instagram feed section */
#instagram-feed {
    padding: 4rem 2rem;
    background-color: #f8f8f8;
}

.instagram-grid {
    margin-top: 2rem;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

/* Juicer-specific styles */
.juicer-feed {
    font-family: inherit !important;
}

.juicer-feed h1.referral {
    display: none !important; /* Hide the Juicer branding */
}

.juicer-feed .j-paginate {
    border: 2px solid #333 !important;
    color: #333 !important;
    border-radius: 8px !important;
    font-weight: bold !important;
    transition: all 0.3s ease !important;
    font-family: inherit !important;
}

.juicer-feed .j-paginate:hover {
    background-color: #333 !important;
    color: white !important;
}

.instagram-link {
    text-align: center;
    margin-top: 20px;
    font-weight: bold;
}

.instagram-post {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    background-color: #fff;
    transition: all 0.3s ease;
    position: relative;
    height: 100%;
}

.instagram-post:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.instagram-post a {
    text-decoration: none;
    color: inherit;
    display: block;
    height: 100%;
}

.instagram-post img {
    width: 100%;
    height: 300px;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.instagram-post:hover img {
    transform: scale(1.05);
}

.instagram-post-info {
    padding: 1rem;
    font-size: 0.9rem;
    background: linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,0.7));
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    color: white;
}

.caption {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Video post styling */
.video-post .video-thumbnail {
    position: relative;
}

.video-post .play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
}

.video-post .play-overlay::after {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 15px 0 15px 30px;
    border-color: transparent transparent transparent #ffffff;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5));
}

/* Loading and placeholder styles */
.instagram-grid .loading-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: #888;
    font-style: italic;
}

.instagram-note {
    text-align: center;
    margin-top: 2rem;
    color: #888;
    font-style: italic;
}

.placeholder-post {
    opacity: 0.7;
}

/* About section */
#about {
    background-image: url('../public/images/about-bg.jpeg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    position: relative;
    color: white;
    z-index: 1; /* Lower z-index than work section */
    
    /* Performance optimizations */
    will-change: transform;
}

#about::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7); /* Dark overlay for readability */
    z-index: 0;
}

#about h2, #about .about-content {
    position: relative;
    z-index: 1;
}

#about h2 {
    margin-bottom: 2rem;
    font-size: 2.5rem;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.8);
    display: inline-block;
    padding: 0.5rem 1.5rem;
    background-color: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: 8px;
}

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

.about-text {
    line-height: 1.8;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.about-text {
    padding: 1.5rem;
    border-radius: 8px;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    display: block;
    line-height: 1.8;
}

.about-text p {
    margin-bottom: 1rem;
    display: inline;
}

/* Add a line break between paragraphs instead of margins */
.about-text p:after {
    content: "\A\A";
    white-space: pre;
    display: block;
    height: 1rem;
}

.about-image {
    display: flex;
    justify-content: center;
    align-items: center;
}

.about-image img {
    width: 77%; /* 77% width = ~60% of original area (√0.6 ≈ 0.77) */
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Contact section */
#contact {
    text-align: center;
    background-color: rgba(20, 20, 25, 0.7); /* Dark overlay */
    background-image: url('../public/images/footer-bg.png');
    background-size: cover;
    background-position: center center; /* Center precisely */
    background-attachment: fixed; /* Fix background image position */
    background-blend-mode: overlay;
    color: var(--light-text);
    position: relative;
    margin-bottom: 0; /* Remove any margin to connect seamlessly with footer */
    padding-bottom: 4rem; /* Extra padding at bottom for visual balance */
}

#contact::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 0;
}

#contact h2, #contact p, #contact .contact-links {
    position: relative;
    z-index: 1;
}

.contact-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 2rem;
}

.contact-link {
    padding: 0.5rem 1.5rem;
    border: 2px solid var(--light-text);
    border-radius: 4px;
    color: var(--light-text);
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.contact-link:hover {
    background-color: var(--light-text);
    color: var(--primary-color);
}

/* Icon styles for contact links */
.icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 10px;
    vertical-align: middle;
    fill: currentColor; /* This makes the SVG icon inherit the text color */
}

/* Custom SVG paths for the icons */
.linkedin-icon svg {
    width: 20px;
    height: 20px;
}

.instagram-icon svg {
    width: 20px;
    height: 20px;
}

.github-icon svg {
    width: 20px;
    height: 20px;
}

.email-icon svg {
    width: 20px;
    height: 20px;
}

/* Footer */
footer {
    background-color: rgba(20, 20, 25, 0.8); /* Slightly darker overlay */
    background-image: url('../public/images/footer-bg.png');
    background-size: cover;
    background-position: center center; /* Center precisely */
    background-attachment: fixed; /* Fix background image position */
    background-blend-mode: overlay;
    color: var(--light-text);
    text-align: center;
    padding: 2rem;
    position: relative;
}

footer::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 0;
}

footer p {
    position: relative;
    z-index: 1;
}

/* Mobile-specific styles */
.mobile-device section {
    background-attachment: scroll !important; /* Scroll backgrounds on mobile to avoid rendering issues */
}

/* Handle overflow issues */
.has-overflow {
    overflow-x: hidden !important;
}

.has-overflow .carousel-container {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
}

.has-overflow #work {
    overflow: hidden !important;
}

/* Responsive design */
@media (max-width: 768px) {
    nav {
        flex-direction: column;
        gap: 1rem;
    }
    
    nav ul li {
        margin-left: 1rem;
    }
    
    #hero h1 {
        font-size: 2.5rem;
    }
    
    #hero h2 {
        font-size: 1.5rem;
    }
    
    .about-content {
        grid-template-columns: 1fr;
    }
    
    .contact-links {
        flex-direction: column;
        gap: 1rem;
    }
    
    /* Optimize carousel for mobile */
    .carousel-container {
        padding: 4rem 0;
    }
    
    .carousel {
        gap: 1.5rem;
    }
    
    .carousel-control {
        width: 40px;
        height: 40px;
    }
    
    /* Ensure modals work well on mobile */
    .project-modal {
        width: 95%;
        max-height: 85vh;
    }
    
    .modal-content {
        padding: 1.5rem;
    }
    
    /* Hide modal navigation on smaller screens */
    .modal-nav-btn {
        width: 40px;
        height: 40px;
        margin: 0 0.5rem;
    }
}