/* Erode */
@font-face {
  font-family: 'Erode';
  src: url('../assets/fonts/Erode.woff2') format('woff2'),
       url('../assets/fonts/Erode.woff') format('woff'),
       url('../assets/fonts/Erode.ttf') format('truetype');
  font-weight: 300 700;
  font-display: swap;
  font-style: normal;
}

/* Tanker */
@font-face {
  font-family: 'Tanker';
  src: url('../assets/fonts/Tanker.woff2') format('woff2'),
       url('../assets/fonts/Tanker.woff') format('woff'),
       url('../assets/fonts/Tanker.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
  font-style: normal;
}

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

/* Custom Text Selection */
::selection {
    background-color: #333;
    color: #fff;
}

::-moz-selection {
    background-color: #333;
    color: #fff;
}

/* Page Transition Overlay */
.page-transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

body {
    font-family: 'Erode', serif;
    background-color: #ffffff;
    color: #000000;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    cursor: default;
    opacity: 0; /* Hidden initially for fade-in */
}

body.is-loaded {
    opacity: 1;
    transition: opacity 0.4s ease-in-out;
}

body.is-exiting {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* Fallback if JS fails */
.no-js body {
    opacity: 1;
}


/* Header */
.site-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.8rem 2rem;
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    z-index: 10000;
    background: #ffffff;
    border: 2px solid #000; /* Thicker stroke */
    gap: 3rem; /* Space between items */
    box-shadow: 0 10px 30px rgba(0,0,0,0.1); /* Subtle lift */
    transition: all 0.3s ease;
}

/* Project Navigation (Integrated in right panel) */
.project-nav {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 2rem;
    max-width: 800px;
    border-top: 1px solid #000; /* Matched other borders */
    padding-top: 2rem;
    padding-bottom: 6rem;
    margin-top: 0;
    padding-left: 0; 
}

/* Mobile Fixed Navigation Box */
.mobile-project-nav {
    display: none;
}

@media (max-width: 768px) {
    .project-nav {
        display: none !important;
    }

    .mobile-project-nav {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 1.2rem;
        position: fixed;
        bottom: 25px;
        left: 50%;
        transform: translateX(-50%);
        width: auto; /* Match header behavior */
        min-width: 280px; /* Ensure enough space for links */
        z-index: 10000;
        background: #ffffff;
        border: 2px solid #000;
        box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        gap: 1.5rem; /* Match header gap */
    }

    .mobile-project-nav a {
        font-family: 'Erode', serif; /* Match header link font */
        font-size: 0.85rem;
        text-transform: none; /* Header links are not all caps */
        color: #000 !important; /* Force visibility */
        opacity: 1 !important;
        text-decoration: none;
        white-space: nowrap;
        position: relative;
    }

    /* Add the hover underline effect to match header links */
    .mobile-project-nav a::after {
        content: '';
        position: absolute;
        bottom: -2px;
        left: 0;
        width: 0%;
        height: 1px;
        background: #000;
        transition: width 0.3s ease;
    }

    .mobile-project-nav a:hover::after {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .mobile-project-nav {
        padding: 0.4rem 0.8rem; /* Exact match to .site-header */
        bottom: 15px;
        width: 90%; 
        max-width: 350px; /* Exact match to .site-header */
        gap: 0.8rem; /* Exact match to .site-header */
    }
    .mobile-project-nav a {
        font-size: 0.8rem;
    }
}

.project-nav a {
    font-family: 'Tanker', sans-serif;
    font-size: 0.9rem;
    text-transform: uppercase;
    color: #999;
    letter-spacing: 0.05em;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.project-nav a:hover {
    color: #000;
}

.project-nav a#prev-project-link:hover {
    transform: translateX(-5px);
}

.project-nav a#next-project-link:hover {
    transform: translateX(5px);
}

@media (max-width: 768px) {
    .site-header {
        padding: 0.5rem 1.2rem;
        gap: 1.5rem;
        top: 15px;
    }
}

@media (max-width: 480px) {
    .site-header {
        padding: 0.4rem 0.8rem;
        gap: 0.8rem;
        top: 10px;
        width: 90%; 
        max-width: 350px;
        justify-content: space-between; 
    }
    
    .project-nav a {
        font-size: 0.8rem;
    }
}

.logo {
    font-family: 'Tanker', sans-serif;
    font-weight: 400;
    font-size: 1.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    order: 2; /* Logo in center */
    text-decoration: none;
    color: #000;
}

@media (max-width: 768px) {
    .logo {
        font-size: 1rem;
    }
}

/* Header Links */
.header-link {
    font-family: 'Erode', serif;
    text-decoration: none;
    color: #000;
    font-weight: 400;
    font-size: 1rem;
    position: relative;
    order: 1; /* Work on left */
}

@media (max-width: 768px) {
    .header-link {
        font-size: 0.85rem;
    }
}

.header-link.right {
    order: 3; /* Contact on right */
}

.header-link.active {
    font-weight: 400;
}

.header-link.active::after {
    display: none;
}

.header-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0%;
    height: 1px;
    background: #000;
    transition: width 0.3s ease;
}

.header-link:hover::after {
    width: 100%;
}

/* Main Grid */
.grid-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 columns for mobile as requested */
    width: 100%;
    padding-top: 0; /* No space for header, it floats over */
}

@media (min-width: 768px) {
    .grid-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .grid-container {
        grid-template-columns: repeat(4, 1fr); /* 4 columns like Gufram desktop often does */
    }
}

/* Project Item */
.project-item {
    position: relative;
    aspect-ratio: 1 / 1; /* Perfect Square */
    border-right: 1px solid #000; /* Black lines */
    border-bottom: 1px solid #000; /* Black lines */
    overflow: hidden;
    text-decoration: none; /* For the anchor tag */
    display: block;
}

/* Mobile Info (Titles visible on mobile) */
.mobile-info {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.9); /* Readable background */
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.mobile-info h3 {
    font-family: 'Tanker', sans-serif;
    margin: 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    color: #000;
}

.mobile-info span {
    font-family: 'Erode', serif;
    font-size: 0.7rem;
    color: #555;
    text-transform: uppercase;
}

.project-item.item-loaded .mobile-info {
    opacity: 1;
}

@media (max-width: 1024px) {
    .mobile-info {
        display: block; /* Show on tablet/mobile */
    }
    /* Disable the hover parallax/cursor effect on touch devices if desired, 
       but user just asked for visible titles. */
    .project-cursor {
        display: none !important; /* Hide floating cursor on mobile */
    }
}

/* Borders for edges */
.grid-container {
    border-top: 1px solid #000; /* Black lines */
    border-left: 1px solid #000; /* Black lines */
}

.image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Placeholder Style */
.image-wrapper.placeholder {
    background-color: #f5f5f5;
    color: #999;
    font-weight: 700;
    text-transform: uppercase;
    text-align: center;
    padding: 1rem;
}

.image-wrapper.placeholder .fg-layer {
    font-size: 1.2rem;
    pointer-events: none;
}

/* Background Layer */
.bg-layer {
    position: absolute;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    background-size: cover;
    background-position: center;
    opacity: 0;
    /* Longer transition with a custom bezier for smoother deceleration */
    transition: opacity 0.4s ease, transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    z-index: 1;
    will-change: transform; /* Hint to the browser for optimization */
}

/* Foreground Layer */
.fg-layer {
    position: relative;
    z-index: 2;
    width: 100%; /* Match background precisely */
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none; 
    will-change: transform; /* Hint for optimization */
}

.fg-layer img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Cover full square to match bg-layer */
    opacity: 0; /* Hidden initially for fade-in */
    transition: opacity 0.4s ease, filter 0.3s ease;
    transform-origin: center;
    filter: saturate(0.9);
    transform: translateZ(0); /* Force GPU acceleration for filters in Chrome */
}

.project-item.item-loaded .fg-layer img {
    opacity: 1;
}

/* Heavy drop shadow for PNGs that disappears on hover */
.fg-layer img.is-png {
    /* Stacked shadows for much higher density and visibility */
    /* Reordered: saturate first, then shadows. Often more stable in Chrome. */
    filter: saturate(0.9)
            drop-shadow(0 20px 50px var(--avg-color, rgba(0,0,0,0.4))) 
            drop-shadow(0 10px 20px var(--avg-color, rgba(0,0,0,0.3)));
}

/* On hover: remove shadow */
.project-item:hover .fg-layer img {
    filter: none;
}

.project-item:hover .bg-layer {
    opacity: 1;
}

.bg-layer.bg-loaded {
    opacity: 0; /* Hidden on desktop even if loaded */
}

.project-item:hover .bg-layer.bg-loaded {
    opacity: 1;
}

/* Mobile: Backgrounds always visible and no drop-shadows */
body.is-mobile .bg-layer.bg-loaded {
    opacity: 1;
}

@media (max-width: 1024px) {
    .fg-layer img.is-png {
        filter: saturate(0.9); /* Keep saturation but remove shadows on mobile */
    }
    
    .project-item:hover .fg-layer img {
        animation: none; /* Disable hover animation on mobile to avoid jitter */
    }

    .bg-layer {
        opacity: 0; /* Still hidden until .bg-loaded is added by JS */
        /* Increase buffer for parallax to prevent gaps */
        width: 130%;
        height: 130%;
        top: -15%;
        left: -15%;
    }
    .bg-layer.bg-loaded {
        opacity: 1;
    }
}

/* Custom Cursor / Pop-up */
.project-cursor {
    position: fixed;
    top: 0;
    left: 0;
    background: #fff;
    border: 1px solid #000;
    padding: 10px 15px;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%) scale(0); /* Centered on mouse, hidden initially */
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    min-width: 150px;
}

.project-cursor.active {
    transform: translate(20px, 20px) scale(1); /* Offset from mouse so it doesn't cover it */
}

.project-cursor h2 {
    font-family: 'Tanker', sans-serif;
    font-size: 1.1rem;
    font-weight: 400;
    margin: 0;
    text-transform: uppercase;
}

.project-cursor p {
    font-family: 'Erode', serif;
    font-size: 0.75rem;
    color: #555;
    margin: 0;
}

/* Footer */
.site-footer {
    padding: 1.5rem 2rem;
    background: #fff;
    border-top: 2px solid #000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.footer-link {
    font-family: 'Tanker', sans-serif;
    font-size: 0.8rem;
    text-transform: uppercase;
    text-decoration: none;
    color: #000;
    letter-spacing: 0.05em;
    transition: opacity 0.3s ease;
}

.footer-link:hover {
    opacity: 0.5;
}

.footer-copyright {
    font-family: 'Erode', serif;
    font-size: 0.75rem;
    color: #000;
}

@media (max-width: 768px) {
    .site-footer {
        padding: 1.5rem 1rem;
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    .footer-links {
        gap: 1rem;
        justify-content: center;
    }
    .footer-link {
        font-size: 0.75rem;
    }
}

/* =========================================
   Project Page Specific Styles (Moved from HTML)
   ========================================= */

.project-page-container {
    display: flex;
    width: 100vw;
}

@media (min-width: 769px) {
    /* Only apply height/overflow restrictions when on a project or contact page */
    body.project-template, 
    body.contact-template,
    body.project-template html,
    body.contact-template html {
        height: 100vh;
        overflow: hidden;
    }
    
    body.project-template,
    body.contact-template {
        display: flex;
        flex-direction: column;
    }

    .project-page-container {
        flex: 1;
        height: 0; 
        min-height: 0;
        padding-top: 0; 
        overflow: hidden;
    }

    /* Left Side: Image Slider */
    .project-media {
        flex: 1;
        height: 100%;
        overflow-y: auto;
        overflow-x: hidden;
        background: #fff;
        scrollbar-width: none; 
        -ms-overflow-style: none;  
    }
    .project-media::-webkit-scrollbar {
        display: none; 
    }

    /* Right Side: Content */
    .project-info {
        flex: 1;
        height: 100%;
        overflow-y: auto;
        padding: 4rem 10%; 
        padding-top: 150px; 
        background: #fff;
        display: flex;
        flex-direction: column;
        justify-content: flex-start; 
        border-left: none; /* Explicitly ensure no left border */
    }

    body.project-template .site-footer {
        display: none; 
    }
}

/* Skeleton / Wireframe Loader */
.media-item {
    width: 100%;
    margin-bottom: 0;
    display: block;
    min-height: 200px; /* Reduced placeholder height */
    background: #f0f0f0;
    position: relative;
    overflow: hidden;
    transition: min-height 0.3s ease;
}

.media-item.is-loaded {
    min-height: 0; /* Remove height constraint once loaded */
    background: transparent;
}

@media (max-width: 768px) {
    .media-item {
        min-height: 100px;
    }
}

.media-item::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background-image: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0,
        rgba(255, 255, 255, 0.2) 20%,
        rgba(255, 255, 255, 0.5) 60%,
        rgba(255, 255, 255, 0)
    );
    animation: skeleton-shimmer 2s infinite;
    z-index: 1;
}

.media-item.is-loaded::after {
    display: none;
}

@keyframes skeleton-shimmer {
    100% {
        transform: translateX(100%);
    }
}

.media-item img {
    width: 100%;
    height: auto;
    display: block;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.media-item.is-loaded img {
    opacity: 1;
}

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    width: 100%;
    background: #000;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.media-item.is-loaded .video-wrapper {
    opacity: 1;
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.project-title-large {
    font-family: 'Tanker', sans-serif;
    font-size: 5rem;
    font-weight: 400;
    line-height: 0.85;
    margin-bottom: 2rem;
    text-transform: uppercase;
    letter-spacing: -0.02em;
}

.project-category-large {
    font-size: 1.4rem;
    color: #555;
    margin-bottom: 4rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.project-description {
    font-size: 1.2rem;
    line-height: 1.7;
    margin-bottom: 4rem;
    max-width: 800px;
    color: #333;
}

/* Credits & Details Grid */
.project-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    max-width: 800px;
    border-top: 1px solid #000;
    padding-top: 3rem;
    margin-bottom: 4rem;
}

.spec-group {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.spec-item h4 {
    font-family: 'Tanker', sans-serif;
    font-size: 0.9rem;
    text-transform: uppercase;
    margin-bottom: 0.8rem;
    color: #999;
    letter-spacing: 0.05em;
}

.spec-item p {
    font-size: 1.1rem;
    font-weight: 400;
    line-height: 1.4;
}

/* Services Section */
.project-services {
    max-width: 800px;
    border-top: 1px solid #000;
    padding-top: 3rem;
    padding-bottom: 3rem; /* Reduced padding */
}

.project-services h4 {
    font-family: 'Tanker', sans-serif;
    font-size: 0.9rem;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
    color: #999;
    letter-spacing: 0.05em;
    text-decoration: none;
}

.project-services p {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #000;
}

/* Animation Classes */
.fade-in-up {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }
.delay-6 { animation-delay: 0.6s; }
.delay-7 { animation-delay: 0.7s; }
.delay-8 { animation-delay: 0.8s; }

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

/* Mobile Responsive - Merged */
@media (max-width: 1024px) {
    .project-info {
        padding: 4rem 5%;
        padding-top: 150px;
    }
    .project-title-large {
        font-size: 3.5rem;
    }
}

@media (max-width: 768px) {
    body {
        overflow: auto;
    }
    .project-page-container {
        flex-direction: column;
        height: auto;
    }
    .project-info {
        order: -1;
        height: auto;
        padding: 1.5rem 1.2rem; /* Reduced padding */
        padding-top: 100px;
        overflow: visible;
        border-bottom: 1px solid #000;
    }
    .project-media {
        order: 1;
        height: auto;
        width: 100%;
        overflow: visible;
    }
    .project-title-large {
        font-size: 2.2rem; /* Slightly smaller title */
        margin-bottom: 0.5rem; /* Reduced margin */
        line-height: 0.9;
    }
    .project-category-large {
        font-size: 1rem;
        margin-bottom: 1.5rem; /* Reduced margin */
    }
    .project-description {
        font-size: 1rem;
        line-height: 1.5;
        margin-bottom: 2rem; /* Reduced margin */
    }
    .project-details-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem; /* Reduced gap */
        padding-top: 2rem; /* Reduced padding */
        margin-bottom: 2rem; /* Reduced margin */
    }
    .section-divider {
        margin: 2rem 0; /* Reduced margin */
    }
    .spec-item h4 {
        margin-bottom: 0.4rem; /* Tighter headers */
    }
    .project-services {
        padding-top: 2rem; /* Reduced padding */
        padding-bottom: 2rem; /* Reduced padding */
    }
    .project-services h4 {
        margin-bottom: 0.8rem;
    }
    .site-footer {
        display: flex; /* Show footer on mobile again as it's a scroll page */
    }
}

/* Credit Links */
.credit-link {
    color: inherit;
    text-decoration: none;
    text-underline-offset: 3px;
    transition: opacity 0.3s ease;
}

.credit-link:hover {
    opacity: 0.6;
}

.section-divider {
    width: 100%;
    max-width: 800px;
    height: 2px;
    background-color: #ddd;
    margin: 4rem 0;
    display: block;
    flex-shrink: 0;
}