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

body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    overflow: hidden;
    background-color: #141414;
    background-image: none;
    color: #333;
}

.gallery-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.infinite-canvas {
    position: absolute;
    width: 100vw;
    height: 100vh;
    transform-origin: center center;
    cursor: grab;
    background-color: #141414;
    background-image: none;
    will-change: transform;
    z-index: 1;
    -webkit-backface-visibility: hidden;
    -webkit-perspective: 1000;
    transform: translate3d(0, 0, 0);
}

.infinite-canvas:active {
    cursor: grabbing;
}

.gallery-card {
    position: absolute;
    width: 500px;
    height: 300px;
    background-color: #111;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, filter 0.5s ease;
    cursor: pointer;
    z-index: 2;
    pointer-events: auto;
    margin: 30px;
    filter: grayscale(0.3) brightness(0.9);
    -webkit-backface-visibility: hidden;
    -webkit-perspective: 1000;
    transform: translate3d(0, 0, 0);
    will-change: transform, opacity;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.gallery-card:hover {
    transform: none;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
    z-index: 10;
    filter: grayscale(0) brightness(1.05);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.gallery-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f0f0f0;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.gallery-card.loading::before {
    opacity: 1;
}

.gallery-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 2;
    position: relative;
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

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

.card-title {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 25px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: white;
    font-size: 18px;
    font-weight: 400;
    z-index: 3;
    letter-spacing: 0.5px;
    opacity: 0;
    transform: translateY(10px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}

.gallery-card:hover .card-title {
    opacity: 1;
    transform: translateY(0);
}

.card-tags {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 70%;
    justify-content: flex-end;
    z-index: 5;
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.gallery-card:hover .card-tags {
    opacity: 1;
    transform: translateY(0);
}

.card-tag {
    font-size: 10px;
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    border-radius: 6px;
    padding: 6px 10px;
    font-weight: 400;
    display: inline-block;
    white-space: nowrap;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.detail-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(25, 25, 25, 0.95);
    display: none;
    justify-content: center;
    align-items: flex-end;
    z-index: 1500;
    --detail-background-image: none;
    --detail-background-color: rgba(25, 25, 25, 0.95);
}

.detail-view::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: var(--detail-background-image);
    background-color: var(--detail-background-color);
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 0.8s ease;
    filter: brightness(0.3) blur(10px);
    z-index: -1;
}

.detail-view.active::before {
    opacity: 1;
}

.detail-content {
    position: relative;
    width: 70%;
    max-width: 800px;
    background-color: rgba(18, 18, 18, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 40px;
    max-height: 95vh;
    overflow-y: auto;
    border-top: none;
    transform: translateY(100%);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    margin-bottom: 0;
    color: white;
    -webkit-backface-visibility: hidden;
    -webkit-perspective: 1000;
    will-change: transform;
}

.detail-content::before {
    content: '';
    display: block;
    width: 40px;
    height: 3px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
}

.detail-content h2 {
    margin-top: 30px;
    margin-bottom: 30px;
    font-size: 28px;
    color: white;
    font-weight: 300;
    letter-spacing: 0.5px;
}

.detail-view.active .detail-content {
    transform: translateY(0);
    -webkit-transform: translateY(0);
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.5);
}

.close-button {
    position: absolute;
    top: 70px;
    right: 24px;
    font-size: 26px;
    background: rgba(34, 34, 34, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: white;
    transition: all 0.3s ease;
    z-index: 1200;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    padding: 0;
    line-height: 0;
}

.close-button:hover {
    opacity: 1;
    background-color: rgba(50, 50, 50, 0.9);
    border-color: rgba(255, 255, 255, 0.5);
}

#detail-title {
    font-size: 28px;
    font-weight: 300;
    margin-bottom: 30px;
    color: white;
    letter-spacing: 0.5px;
}

#detail-image-container {
    width: 100%;
    height: 400px;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
}

#detail-image-container .video-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
}

.detail-top-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

#detail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

#detail-body {
    font-size: 16px;
    line-height: 1.8;
    margin-bottom: 30px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 300;
}

.audio-container {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.audio-button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #0066cc;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.audio-button:hover {
    background-color: #0052a3;
}

.detail-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

.detail-navigation button {
    padding: 12px 24px;
    background-color: transparent;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s, border-color 0.3s;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.detail-navigation button:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Update styles for the logo container */
#logo-container {
    display: none;
    position: fixed;
    top: 20px;
    left: 30px;
    width: auto;
    height: auto;
    padding: 0;
    background-color: transparent;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    box-shadow: none;
}

#logo {
    width: auto;
    height: auto;
    max-height: 50px;
    object-fit: contain;
    filter: invert(1);
}

/* Optional: Add a subtle hover effect */
#logo-container:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
    transition: all 0.3s ease;
}

/* Adding styles for the YouTube video container */
.video-container {
    margin: 20px 0;
}

.video-container h3 {
    margin-bottom: 10px;
    font-size: 18px;
    color: #1a1a1a;
}

.video-wrapper {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    margin: 20px 0;
    background: rgba(0, 0, 0, 0.2);
}

.video-wrapper video {
    width: 100%;
    display: block;
    border-radius: 12px;
}

.video-pause-button {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s;
    color: white;
}

.video-pause-button:hover {
    background: rgba(0, 0, 0, 0.8);
}

.video-pause-button svg {
    width: 24px;
    height: 24px;
}

/* Hide video container if no video is present */
.video-container.hidden {
    display: none;
}

/* Path to Final Styles */
.path-to-final {
    margin: 25px 0 15px;
    padding-top: 20px;
    border-top: 1px solid #e5e5e5;
}

.path-to-final h3 {
    font-size: 22px;
    color: #1a1a1a;
    margin-bottom: 16px;
    font-weight: 600;
}

.path-rounds {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.path-round {
    background-color: #f9f9f9;
    border-radius: 8px;
    padding: 15px;
    border-left: 4px solid #1a1a1a;
}

.round-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.round-name {
    font-weight: 600;
    color: #222;
    font-size: 16px;
}

.round-score {
    color: #555;
    font-weight: 600;
    font-size: 14px;
}

.round-opponent {
    font-size: 15px;
    color: #444;
    margin-bottom: 8px;
    font-style: italic;
}

.round-description {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.detail-tags {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.detail-tag {
    font-size: 10px;
    background-color: transparent;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 6px 12px;
    font-weight: 400;
    display: inline-block;
    width: fit-content;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Card pause button styles */
.card-pause-button {
    position: absolute;
    bottom: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background-color: rgba(25, 25, 25, 0.8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0.7;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.card-pause-button svg {
    width: 24px;
    height: 24px;
    color: white;
    pointer-events: none; /* Ensures SVG doesn't interfere with clicks */
}

.gallery-card.has-video:hover .card-pause-button {
    opacity: 1;
    transform: scale(1.1);
}

/* Video styling in detail view */
.detail-video-container video {
    width: 100%;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* About Me card special styling */
.gallery-card[data-index="0"] {
    border: none;
    box-shadow: 0 8px 40px rgba(25, 25, 25, 0.35);
    background-color: #161616;
    filter: grayscale(0) brightness(1);
}

.gallery-card[data-index="0"]:hover {
    transform: none;
    box-shadow: 0 12px 50px rgba(25, 25, 25, 0.5);
    background-color: #1c1c1c;
}

.gallery-card[data-index="0"] .card-title {
    background: linear-gradient(transparent, rgba(25, 25, 25, 0.9));
    font-weight: 400;
    padding-bottom: 25px;
    letter-spacing: 1px;
}

.gallery-card[data-index="0"] .image-fallback {
    background-color: #161616 !important;
    font-size: 24px !important;
    letter-spacing: 1px;
    font-weight: 300;
}

/* Project Navigation */
.project-nav {
    position: fixed;
    top: 20px;
    bottom: auto;
    left: 50%;
    transform: translateX(-50%) translateY(0); /* Keep at top position */
    width: 70%;
    max-width: 800px;
    background-color: #0f0f0f;
    color: #fff;
    z-index: 2000;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    overflow: hidden;
    pointer-events: auto;
    opacity: 1;
}

/* Prepare for animation */
.project-nav.prepare-animation {
    transform: translateX(-50%) translateY(0); /* Keep at top */
    width: 0%;
    max-width: 800px;
    overflow: hidden;
}

/* Animation class for nav container - only animate width */
.project-nav.animate-in {
    animation: nav-width-expand 2.5s cubic-bezier(0.05, 0.7, 0.1, 1) forwards;
    overflow: hidden;
}

.project-nav.open {
    transform: translateX(-50%) translateY(0); /* Keep at top */
    opacity: 1;
}

.project-list-container {
    max-height: 0;
    overflow-y: hidden;
    padding: 0 20px 0;
    -webkit-overflow-scrolling: touch;
    position: relative;
    z-index: 2002; /* Higher z-index to ensure it's above other elements */
    pointer-events: auto;
    opacity: 0;
    transition: opacity 0.3s ease, max-height 0.5s cubic-bezier(0.16, 1, 0.3, 1), padding 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.project-nav.open .project-list-container {
    opacity: 1;
    max-height: 70vh;
    padding: 0 20px 20px;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto; /* Ensure scrolling works */
}

.project-list {
    padding: 10px 0;
}

.project-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: opacity 0.3s ease;
    position: relative;
    z-index: 1002;
}

.project-item:hover {
    opacity: 0.7;
}

.project-thumbnail {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
    margin-right: 15px;
    background-color: rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.project-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.project-title {
    font-size: 20px;
    margin-bottom: 5px;
    font-weight: 500;
}

.project-category {
    font-size: 14px;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.project-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 990;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: none;
}

.project-overlay.active {
    opacity: 1;
    pointer-events: auto;
    display: block;
}

/* Handle responsive layout for nav title */
@media (max-width: 600px) {
    .nav-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        width: 100%; /* Ensure full width */
    }
    
    .nav-tagline {
        display: none; /* Hide the tagline on mobile */
    }
    
    .nav-logo {
        width: 100%; /* Allow logo to fill the available space */
        max-width: 100%; /* Remove max-width restriction on mobile */
        min-height: 36px; /* Ensure logo has good height */
    }
    
    /* Add more space around the logo */
    .project-nav-header {
        padding: 25px 30px; /* Increased padding for more space */
        height: auto; /* Allow height to adjust to content */
        min-height: 70px; /* Ensure minimum height */
    }
}

/* Additional images and videos in detail view */
.additional-images {
    margin: 30px 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.additional-image-container {
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.additional-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    transition: transform 0.5s ease;
}

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

.additional-videos {
    margin: 20px 0;
}

.additional-video {
    width: 100%;
    border-radius: 12px;
    display: block;
}

/* Improve video styling in detail view */
#detail-video-container {
    margin: 30px 0;
}

#detail-video-container h3 {
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 300;
    letter-spacing: 0.5px;
    color: white;
}

#detail-video {
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    background-color: #111;
}

/* Video Pause Button */
.video-pause-button {
    position: absolute;
    bottom: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1200;
    transition: all 0.3s ease;
    opacity: 0;
}

.video-wrapper:hover .video-pause-button {
    opacity: 1;
}

.video-pause-button:hover {
    transform: scale(1.1);
    background-color: rgba(0, 0, 0, 0.8);
}

.video-pause-button svg {
    width: 24px;
    height: 24px;
    color: white;
}

.video-wrapper {
    position: relative;
}

#detail-video-container {
    position: relative;
}

/* Embedded video container styles */
.embedded-video-container {
    margin: 30px 0;
    width: 100%;
}

.embedded-video-container .video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    background-color: rgba(0, 0, 0, 0.2);
}

.embedded-video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

/* Additional videos in the additional-images container */
.additional-images .video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    margin: 20px 0;
}

.additional-images video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.side-by-side-videos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px 0;
}

.side-by-side-videos .video-wrapper {
    margin: 0;
}

.additional-videos {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.additional-video {
    width: 100%;
    border-radius: 12px;
    display: block;
}

/* Ensure videos are visible in the detail view */
.detail-view .video-wrapper {
    background-color: rgba(0, 0, 0, 0.2);
    min-height: 200px;
}

.detail-view video {
    background-color: transparent;
}

/* Add loading state for videos */
.video-wrapper::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: video-loading 1s linear infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-wrapper.loading::before {
    opacity: 1;
}

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

.video-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1150;
    cursor: pointer;
    border-radius: 12px;
}

.play-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transition: transform 0.3s ease;
}

.play-button:hover {
    transform: scale(1.1);
}

.play-button svg {
    width: 60px;
    height: 60px;
    color: white;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.play-button span {
    color: white;
    font-size: 14px;
    font-weight: 300;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Special handling for Dyson project */
.dyson-project .video-wrapper {
    min-height: 250px;
}

/* Add better loading indicator for videos */
@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.video-wrapper.loading .video-play-overlay {
    background-color: rgba(0, 0, 0, 0.4);
}

.video-wrapper.loading .play-button {
    animation: pulse 1.5s infinite;
}

.video-wrapper.loading .play-button span {
    content: "Loading video...";
}

/* Make sure the loading animation is centered */
.video-wrapper.loading::before {
    opacity: 1;
    z-index: 1200;
}

/* Two-column layout for detail view */
.detail-columns {
    display: flex;
    gap: 40px;
    margin-bottom: 30px;
}

.detail-column-left {
    flex: 0 0 30%;
    min-width: 200px;
}

.detail-column-right {
    flex: 1;
}

.section-title {
    font-size: 18px;
    font-weight: 400;
    margin-bottom: 15px;
    color: white;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.detail-services {
    list-style: none;
    padding: 0;
    margin: 0 0 30px 0;
}

.detail-service {
    position: relative;
    padding: 8px 0 8px 24px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 15px;
    line-height: 1.5;
    font-weight: 300;
}

.detail-service::before {
    content: "→";
    position: absolute;
    left: 0;
    color: rgba(255, 255, 255, 0.5);
}

.detail-section {
    margin-bottom: 25px;
}

/* Move tags to column layout */
.detail-tags {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.detail-tag {
    font-size: 10px;
    background-color: transparent;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 6px 12px;
    font-weight: 400;
    display: inline-block;
    width: fit-content;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
    .detail-columns {
        flex-direction: column;
    }
    
    .detail-column-left, 
    .detail-column-right {
        width: 100%;
    }
    
    .detail-tags {
        flex-direction: row;
        flex-wrap: wrap;
        margin-bottom: 20px;
    }
    
    .detail-service {
        padding-left: 20px;
    }
}

/* Say Hi Button and Navigation Actions */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative; /* Create stacking context */
    z-index: 2002; /* Higher than nav header */
}

.say-hi-button {
    background: transparent;
    border: 1px solid #fff;
    color: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    letter-spacing: 0.5px;
    position: relative; /* Ensure button has its own stacking context */
    z-index: 2002; /* Higher than nav header */
}

.say-hi-button:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

.mobile-say-hi {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 20px;
}

.mobile-say-hi .say-hi-button {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    margin-top: 10px;
}

/* Contact Modal Styles */
.contact-modal {
    --detail-background-color: rgba(20, 20, 20, 0.95);
    pointer-events: none; /* Make the modal background not block other elements */
    z-index: 1600; /* Between default detail-view and project-nav */
}

.contact-modal .detail-content {
    pointer-events: auto; /* Make the modal content clickable */
}

/* Hide project-overlay when contact modal is visible */
.contact-modal.active ~ .project-overlay {
    z-index: 990; /* Keep below the nav */
}

.contact-content {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px 0;
}

.contact-email {
    text-align: center;
    color: white;
    font-size: 18px;
    margin-bottom: 30px;
    font-weight: 300;
    letter-spacing: 1px;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 15px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 16px;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
}

.checkbox-group {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.checkbox-group input {
    width: 18px;
    height: 18px;
}

.recaptcha-container {
    margin: 10px 0;
    display: flex;
    justify-content: center;
}

.submit-button {
    background: #fff;
    color: #000;
    border: none;
    padding: 14px 25px;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.submit-button:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
}

/* Media Queries for Mobile */
@media (max-width: 768px) {
    .desktop-only {
        display: none;
    }
    
    .mobile-only {
        display: block;
    }
    
    .contact-content {
        padding: 10px;
    }
    
    #contact-title {
        font-size: 22px;
        margin-bottom: 20px;
    }
    
    /* Make nav and modals wider on mobile */
    .project-nav {
        width: calc(100% - 32px); /* Full width minus 32px (16px on each side) */
        left: 50%;
        max-width: none;
        margin: 0; /* Remove margin as it interferes with centering */
        border-radius: 8px; /* Slightly smaller border radius on mobile */
    }
    
    /* Ensure prepare-animation class maintains same width settings */
    .project-nav.prepare-animation {
        width: 0%;
        max-width: none;
    }
    
    /* Update width-expand animation end state for mobile */
    @keyframes nav-width-expand-mobile {
        0% { 
            width: 0%; 
            opacity: 1;
        }
        100% { 
            width: calc(100% - 32px);
            opacity: 1;
        }
    }
    
    /* Apply mobile animation */
    .project-nav.animate-in {
        animation-name: nav-width-expand-mobile;
    }
    
    .detail-content {
        width: calc(100% - 32px);
        max-width: none;
        border-radius: 8px; /* Match the nav border-radius */
    }
    
    /* Match both header border radius */
    .project-nav-header {
        border-radius: 8px 8px 0 0;
    }
    
    /* Change gallery cards to portrait orientation on mobile */
    .gallery-card {
        width: 220px;
        height: 320px;
        margin: 15px;
    }
    
    .card-title {
        padding: 15px;
        font-size: 16px;
    }
    
    .card-tag {
        font-size: 8px;
        padding: 4px 8px;
    }
}

/* Success Message Styles */
.success-message {
    text-align: center;
    padding: 60px 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px; /* Ensure sufficient height */
}

.success-message .tick-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    margin-bottom: 30px;
}

.success-message .tick-icon svg {
    width: 40px;
    height: 40px;
    color: #4BB543; /* Green color for success */
}

.success-message h3 {
    color: #fff;
    font-size: 24px;
    margin-bottom: 15px;
}

.success-message p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 16px;
}

/* Submitting Button State */
.submit-button.submitting {
    position: relative;
    color: transparent; /* Hide the text while showing the dots */
}

.submit-button.submitting::after {
    content: 'Submitting';
    position: absolute;
    left: 0;
    right: 0;
    color: #000;
    animation: dotAnimation 1.5s infinite;
}

@keyframes dotAnimation {
    0% { content: 'Submitting'; }
    33% { content: 'Submitting.'; }
    66% { content: 'Submitting..'; }
    100% { content: 'Submitting...'; }
}

/* Loader styles */
#loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #1a1a1a;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    transition: opacity 0.5s ease-out;
}

.loader-content {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.loader-card-stack {
    position: absolute;
    width: 500px;
    height: 300px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2001;
    perspective: 800px;
}

.loader-card {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: #252525;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
    transform-origin: center center;
    transform: translate(-50%, -50%) scale(0.6) rotate(0deg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #555;
    left: 50%;
    top: 50%;
    will-change: transform, opacity;
}

.loader-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.loader-card.show {
    opacity: 1;
}

.loader-percentage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 35vw;
    font-weight: 900;
    color: #333;
    font-family: sans-serif;
    z-index: 2000;
}

/* Mobile styles for loader cards */
@media (max-width: 768px) {
    .loader-card-stack {
        width: 220px;
        height: 320px;
    }
}

/* Add these keyframes and animation styles for navigation */
@keyframes nav-width-expand {
    0% { 
        width: 0%; 
        opacity: 1;
        left: 50%;
        transform: translateX(-50%) translateY(0);
    }
    100% { 
        width: 70%; 
        opacity: 1;
        left: 50%;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes nav-items-slide-down {
    0% { transform: translateY(-20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

/* Animation for nav items - slide down instead of up */
.project-nav .project-item,
.project-nav .nav-title,
.project-nav .nav-actions {
    opacity: 0;
}

.project-nav.items-animate .project-item,
.project-nav.items-animate .nav-title,
.project-nav.items-animate .nav-actions {
    animation: nav-items-slide-down 0.8s cubic-bezier(0, 0, 0.2, 1) forwards;
}

/* Stagger the animation delay for items */
.project-nav.items-animate .nav-title {
    animation-delay: 0.1s;
}

.project-nav.items-animate .nav-actions {
    animation-delay: 0.2s;
}

.project-nav.items-animate .project-item:nth-child(1) {
    animation-delay: 0.3s;
}

.project-nav.items-animate .project-item:nth-child(2) {
    animation-delay: 0.4s;
}

.project-nav.items-animate .project-item:nth-child(3) {
    animation-delay: 0.5s;
}

.project-nav.items-animate .project-item:nth-child(4) {
    animation-delay: 0.6s;
}

.project-nav.items-animate .project-item:nth-child(5) {
    animation-delay: 0.7s;
}

.project-nav.items-animate .project-item:nth-child(n+6) {
    animation-delay: 0.8s;
}

/* Overlay for navigation */
.project-nav::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0);
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 980;
    opacity: 0;
    visibility: hidden;
}

.project-nav.open::before {
    background-color: rgba(0, 0, 0, 0.5);
    pointer-events: all;
    z-index: 1500; /* Higher z-index to block interaction with gallery */
    opacity: 1;
    visibility: visible;
}

/* Existing nav styles */
.project-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    height: 60px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px 12px 0 0;
    z-index: 2001;
}

.nav-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-logo {
    width: 50%;
    height: auto;
    display: block;
    max-width: 170px; /* Reduced from 150px */
}

.nav-tagline {
    font-size: 14px;
    font-weight: 300;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
}

.nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
    padding: 4px;
    cursor: pointer;
    position: relative;
    z-index: 1010;
}

.nav-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: white;
    transition: transform 0.3s ease, opacity 0.3s ease;
    position: absolute;
    left: 0;
    right: 0;
}

.nav-toggle span:nth-child(1) {
    top: 4px;
}

.nav-toggle span:nth-child(2) {
    top: 50%;
    transform: translateY(-50%);
}

.nav-toggle span:nth-child(3) {
    bottom: 4px;
}

.project-nav.open .nav-toggle span:nth-child(1) {
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
}

.project-nav.open .nav-toggle span:nth-child(2) {
    opacity: 0;
}

.project-nav.open .nav-toggle span:nth-child(3) {
    top: 50%;
    transform: translateY(-50%) rotate(-45deg);
}

/* Update nav styles to prevent interaction with gallery when open */
.project-nav.open {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
    isolation: isolate; /* Create stacking context */
}

/* Cookie Overlay */
.cookie-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1999998; /* Just below the banner */
    display: none;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.cookie-overlay.show {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* Cookie Banner */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #1a1a1a;
    color: #fff;
    padding: 20px 30px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1999999; /* Just below the modal */
    display: flex;
    justify-content: space-between;
    align-items: center;
    transform: translateY(100%);
    transition: transform 0.4s ease-in-out;
}

.cookie-banner.show {
    transform: translateY(0);
}

/* Cookie Modal */
.cookie-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.cookie-modal.active {
    opacity: 1;
    pointer-events: auto;
    display: flex;
}

.cookie-policy-content {
    background-color: #fff;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    border-radius: 8px;
    padding: 0;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.4s ease;
    pointer-events: auto;
    touch-action: pan-y;
    isolation: isolate;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}

.cookie-modal.active .cookie-policy-content {
    transform: translateY(0);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    font-weight: 600;
    color: #333;
}

.close-modal {
    font-size: 24px;
    color: #888;
    cursor: pointer;
    transition: color 0.2s;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
}

.close-modal:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
    color: #333;
    overflow-y: auto;
    pointer-events: auto;
    touch-action: pan-y;
    isolation: isolate;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
}

.modal-body h3 {
    margin: 20px 0 10px 0;
    font-weight: 600;
}

.modal-body p, .modal-body ul {
    margin-bottom: 15px;
    line-height: 1.6;
}

.modal-body ul {
    padding-left: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    text-align: right;
    flex-shrink: 0;
}

.modal-footer .button {
    background-color: #000;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s, transform 0.2s;
    white-space: nowrap;
    position: relative;
    z-index: 2000000;
    width: 100%;
    text-align: center;
}

.modal-footer .button:hover {
    background-color: #333;
    transform: translateY(-1px);
}

/* Add scrollbar styling for better visibility */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Ensure all modal content is interactive */
.modal-header,
.modal-body,
.modal-footer {
    pointer-events: auto;
    touch-action: pan-y;
    isolation: isolate;
    -webkit-overflow-scrolling: touch;
}

/* Block all interactions with gallery when modal is active */
body .cookie-modal.active ~ .gallery-container,
body .cookie-modal.active ~ .infinite-canvas,
body .cookie-modal.active ~ .gallery-card,
body .cookie-modal.active ~ .detail-view {
    pointer-events: none !important;
    touch-action: none !important;
    user-select: none !important;
    overflow: hidden !important;
}

/* Cookie Banner Styles */
.cookie-banner p {
    margin: 0;
    line-height: 1.5;
    padding-right: 20px;
    max-width: 60%;
    position: relative;
    z-index: 2000000;
}

.cookie-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 2000000;
}

.cookie-button {
    padding: 10px 15px;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    border: 1px solid #fff;
    white-space: nowrap;
    position: relative;
    z-index: 2000000;
}

.settings-button {
    background-color: transparent;
    color: #fff;
}

.settings-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.reject-button {
    background-color: transparent;
    color: #fff;
}

.reject-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.accept-button {
    background-color: #fff;
    color: #000;
}

.accept-button:hover {
    background-color: #eee;
}

/* Block all interactions when cookie banner is shown */
body.cookie-banner-active .gallery-container,
body.cookie-banner-active .infinite-canvas,
body.cookie-banner-active .gallery-card,
body.cookie-banner-active .detail-view {
    pointer-events: none !important;
}

body.cookie-banner-active .cookie-banner,
body.cookie-banner-active .cookie-overlay,
body.cookie-banner-active .cookie-modal,
body.cookie-banner-active .cookie-banner *,
body.cookie-banner-active .cookie-modal * {
    pointer-events: auto !important;
}

/* Cookie Settings Toggle Switch */
.cookie-setting-group {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.cookie-setting-group:last-child {
    border-bottom: none;
}

.cookie-setting-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #2196F3;
}

input:focus + .slider {
    box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

.switch.disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.switch.disabled .slider {
    cursor: not-allowed;
}

/* Mobile adjustments for cookie banner */
@media (max-width: 768px) {
    .cookie-banner {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px;
    }
    
    .cookie-banner p {
        padding-right: 0;
        margin-bottom: 15px;
        width: 100%;
        max-width: 100%;
    }
    
    .cookie-actions {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }
    
    .cookie-button {
        width: 100%;
        padding: 12px;
        text-align: center;
    }
    
    .cookie-policy-content {
        width: 95%;
        max-height: 85vh;
    }
}

/* Add a wrapper to ensure modal content is isolated */
.cookie-modal-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000000;
    pointer-events: none;
    -webkit-overflow-scrolling: touch;
}

.cookie-modal-wrapper.active {
    pointer-events: auto;
}

/* Ensure modal content is above everything */
.cookie-modal-wrapper .cookie-policy-content,
.cookie-modal-wrapper .modal-header,
.cookie-modal-wrapper .modal-body,
.cookie-modal-wrapper .modal-footer {
    position: relative;
    z-index: 2000001;
    -webkit-overflow-scrolling: touch;
}

/* Cookie Widget Button */
.cookie-widget-button {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background-color: #000;
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2000000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, background-color 0.3s ease;
    pointer-events: auto;
    touch-action: auto;
    isolation: isolate;
}

.cookie-widget-button:hover {
    transform: scale(1.1);
    background-color: #333;
}

.cookie-widget-button svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* Cookie Modal */
.cookie-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.cookie-modal.active {
    opacity: 1;
    pointer-events: auto;
    display: flex;
}

.cookie-policy-content {
    background-color: #fff;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    border-radius: 8px;
    padding: 0;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.4s ease;
    pointer-events: auto;
    touch-action: pan-y;
    isolation: isolate;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}

.cookie-modal.active .cookie-policy-content {
    transform: translateY(0);
}

/* Block all interactions with gallery when modal is active */
body .cookie-modal.active ~ .gallery-container,
body .cookie-modal.active ~ .infinite-canvas,
body .cookie-modal.active ~ .gallery-card,
body .cookie-modal.active ~ .detail-view {
    pointer-events: none !important;
    touch-action: none !important;
    user-select: none !important;
    overflow: hidden !important;
}

/* Ensure all modal content is interactive */
.modal-header,
.modal-body,
.modal-footer {
    pointer-events: auto;
    touch-action: pan-y;
    isolation: isolate;
    -webkit-overflow-scrolling: touch;
}

/* Position cookie widget under banner */
.cookie-banner.show ~ .cookie-widget-button {
    bottom: 80px; /* Adjust this value based on your banner height */
}

/* Add styles to block all interactions when modal is active */
body.cookie-modal-active {
    overflow: hidden;
}

body.cookie-modal-active .gallery-container,
body.cookie-modal-active .infinite-canvas,
body.cookie-modal-active .gallery-card,
body.cookie-modal-active .detail-view,
body.cookie-modal-active .project-nav,
body.cookie-modal-active #logo-container {
    pointer-events: none !important;
    touch-action: none !important;
    user-select: none !important;
    overflow: hidden !important;
}

/* Mobile modal positioning */
@media (max-width: 768px) {
    .cookie-modal,
    .detail-view,
    .contact-modal {
        align-items: flex-start;
        padding-top: 60px; /* Space for the navigation bar */
    }
    
    .cookie-policy-content,
    .detail-content {
        max-height: calc(100vh - 70px);
        margin-top: 10px;
        border-radius: 12px;
    }
    
    /* Safe area inset for iPhones with notch/dynamic island */
    @supports (padding-top: env(safe-area-inset-top)) {
        .cookie-modal,
        .detail-view,
        .contact-modal {
            padding-top: calc(60px + env(safe-area-inset-top));
        }
    }
    
    /* Ensure modal body is scrollable */
    .modal-body {
        max-height: calc(100vh - 180px);
    }
}

/* iPhone specific adjustments */
@media only screen 
and (device-width: 390px) 
and (device-height: 844px),
only screen 
and (device-width: 428px) 
and (device-height: 926px),
only screen 
and (device-width: 430px) 
and (device-height: 932px) {
    .cookie-modal,
    .detail-view,
    .contact-modal {
        padding-top: 80px;
    }
    
    .cookie-policy-content,
    .detail-content {
        max-height: calc(100vh - 90px);
    }
}

/* Performance optimizations for mobile devices */
@media (max-width: 768px) {
    /* Reduce animation complexity */
    .gallery-card, 
    .detail-content,
    .cookie-policy-content,
    .modal-content {
        transition: transform 0.3s ease, opacity 0.3s ease;
        will-change: auto; /* Only use will-change when actively animating */
    }
    
    /* Reduce shadow complexity */
    .gallery-card,
    .detail-content,
    .cookie-policy-content {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }
    
    /* Simplify filters for better performance */
    .gallery-card {
        filter: none;
    }
    
    .gallery-card:hover {
        filter: none;
    }
    
    /* Reduce transform complexity */
    .gallery-card:hover img {
        transform: scale(1.04);
        -webkit-transform: scale(1.04);
    }
    
    /* Optimize modal rendering */
    .cookie-modal,
    .detail-view,
    .contact-modal {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        background-color: rgba(0, 0, 0, 0.8);
    }
    
    /* Fix for iPhone rendering issues */
    .infinite-canvas,
    .gallery-card,
    .detail-content,
    .cookie-policy-content {
        transform: translate3d(0, 0, 0);
        -webkit-transform: translate3d(0, 0, 0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
    
    /* Prevent excessive repaints */
    body.cookie-modal-active,
    body.modal-open {
        overflow: hidden !important;
        position: fixed;
        width: 100%;
        height: 100%;
    }
    
    /* Reduce parallax effects */
    .detail-view::before {
        filter: brightness(0.3);
        background-attachment: scroll;
    }
}

/* Further optimizations for low-end devices */
@media (max-width: 480px) {
    /* Disable hover effects on mobile */
    .gallery-card:hover {
        transform: none !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
    }
    
    .gallery-card:hover img {
        transform: none !important;
        -webkit-transform: none !important;
    }
    
    /* Reduce animation further */
    * {
        transition-duration: 0.2s !important;
    }
    
    /* Simplify scrolling */
    .modal-body,
    .detail-content,
    .project-list-container {
        -webkit-overflow-scrolling: auto;
    }
}

/* Loading indicator for modals */
.detail-view.loading::before {
    opacity: 1;
    background-image: none !important;
    background-color: rgba(25, 25, 25, 0.95) !important;
}

.loading-indicator {
    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.4);
    color: white;
    font-size: 16px;
    z-index: 10;
    border-radius: 8px;
}

.loading-indicator .spinner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

/* Performance optimizations for modal content */
.detail-view {
    will-change: opacity;
    contain: layout style size;
}

.detail-content {
    will-change: transform;
    contain: layout style;
}

.detail-view video {
    contain: layout style size;
}

/* Ensure Dyson project loads efficiently */
.detail-view.active[style*="--detail-background-color: rgba(25, 25, 25, 0.95)"] {
    background-color: rgba(25, 25, 25, 0.95) !important;
}

/* Prevent any modal persistence issues */
.detail-view:not(.active) {
    pointer-events: none !important;
}

/* Fix content height for better scrolling */ 
.detail-content {
    max-height: 95vh;
    overflow-y: auto;
}

/* Gallery Card Optimizations */
.gallery-card {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
}

/* Remove video-specific styles since we're not using videos in cards anymore */
.gallery-card video,
.gallery-card.has-video,
.card-pause-button {
    display: none !important;
}

/* Optimize image loading */
.gallery-card img {
    will-change: transform;
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Reduce animation complexity for better performance */
.gallery-card:hover img {
    transform: scale(1.05);
    -webkit-transform: scale(1.05);
}

/* Further mobile optimizations */
@media (max-width: 768px) {
    .gallery-card {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        filter: none !important;
    }
    
    .gallery-card:hover {
        transform: none !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
    }
    
    .gallery-card:hover img {
        transform: none !important;
        -webkit-transform: none !important;
    }
    
    .gallery-card img {
        transition: none !important;
    }
}

/* Mobile Modal Animations */
@media (max-width: 768px) {
    /* Enhanced slide-up animation for all modals on mobile */
    .detail-content,
    .cookie-policy-content,
    .contact-modal .detail-content {
        transform: translateY(100%);
        transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
        will-change: transform;
        transform-origin: bottom center;
    }
    
    .detail-view.active .detail-content,
    .cookie-modal.active .cookie-policy-content,
    .contact-modal.active .detail-content {
        transform: translateY(0);
        animation: modal-slide-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }
    
    @keyframes modal-slide-up {
        0% {
            transform: translateY(100%);
            opacity: 0.8;
        }
        100% {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    /* Enhanced slide-down animation when closing modals */
    .detail-view:not(.active) .detail-content,
    .cookie-modal:not(.active) .cookie-policy-content,
    .contact-modal:not(.active) .detail-content {
        animation: modal-slide-down 0.5s cubic-bezier(0.36, 0, 0.66, -0.56) forwards;
    }
    
    @keyframes modal-slide-down {
        0% {
            transform: translateY(0);
            opacity: 1;
        }
        100% {
            transform: translateY(100%);
            opacity: 0.8;
        }
    }
} 