/* Global Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap');

@view-transition {
    navigation: auto;
}

/* Custom View Transitions */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.5s;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

::view-transition-old(root) {
    animation-name: fade-out;
}

::view-transition-new(root) {
    animation-name: fade-in;
}

@keyframes fade-out {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Ensuring Magic Move images are sharp during transition */
::view-transition-old(project-1),
::view-transition-new(project-1),
::view-transition-old(project-2),
::view-transition-new(project-2),
::view-transition-old(project-3),
::view-transition-new(project-3),
::view-transition-old(project-4),
::view-transition-new(project-4),
::view-transition-old(project-5),
::view-transition-new(project-5),
::view-transition-old(project-6),
::view-transition-new(project-6) {
    animation-duration: 0.8s;
    animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
    height: 100%;
}

:root {
    --bg-color: #000000;
    --text-color: #ffffff;
    --accent-color: #333333;
    --font-main: 'Space Mono', sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html.lenis,
html.lenis body {
    height: auto;
}

.lenis.lenis-smooth {
    scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
    overscroll-behavior: contain;
}

.lenis.lenis-stopped {
    overflow: hidden;
}

.lenis.lenis-scrolling iframe {
    pointer-events: none;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6,
p {
    margin: 0;
}

a {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

/* Utilities */
.container {
    width: 90%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.flex {
    display: flex;
}

.between {
    justify-content: space-between;
}

.center {
    align-items: center;
}

.grid {
    display: grid;
}

.uppercase {
    text-transform: uppercase;
}

/* Navigation */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 8px 8px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 9999;
    /* Very high */
    font-size: 12px;
    font-weight: 500;
    mix-blend-mode: difference;
    color: #ffffff;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 200px;
}

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

.globe-icon {
    display: block;
    opacity: 0.7;
}

.nav-content {
    display: flex;
    gap: 8vw;
    flex: 1;
    margin-left: 4vw;
}

.nav-bio {
    max-width: 420px;
    line-height: 1.4;
    color: #ffffff;
}

.nav-skills {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
    margin-left: auto;
}

.skill-group {
    display: flex;
    gap: 32px;
}

.skill-label {
    width: 120px;
    text-align: left;
    color: #ffffff;
}

.skill-list-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
    text-align: left;
    color: #ffffff;
}

.nav-right {
    width: 150px;
    display: flex;
    justify-content: flex-end;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .nav {
        flex-direction: column;
        padding: 24px;
        gap: 30px;
        height: auto;
    }

    .nav-left {
        width: 100%;
        /* Keep Time on top left */
    }

    .nav-right {
        position: absolute;
        top: 24px;
        right: 24px;
        /* Same padding as nav */
        width: auto;
    }

    .nav-content {
        margin-left: 0;
        flex-direction: column;
        gap: 20px;
    }

    .nav-bio {
        max-width: 100%;
    }

    .nav-skills {
        margin-left: 0;
        width: 100%;
        gap: 40px;
    }

    .skill-group {
        width: 100%;
        justify-content: space-between;
        /* Make label and list span width? */
        /* Or keep side by side but fluid */
    }

    .skill-label {
        width: auto;
        /* Allow flexible width */
    }
}

.location {
    color: #ffffff;
    white-space: nowrap;
}

.contact-link {
    position: relative;
}

.contact-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: currentColor;
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.3s ease;
}

.contact-link:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

/* Hero Section */
.hero {
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    /* Mobile fix */
    width: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible;
    /* Allow name to slide out and under section */
}

.bio-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
}

.bio-text {
    font-size: 16px;
    line-height: 1.5;
    color: #ccc;
    width: 100%;
    max-width: 400px;
}

.name-container {
    position: absolute;
    bottom: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom));
    /* Mobile safe area fix */
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 4vw;
}

/* Use vw for responsive massive text */
.hero-name {
    font-family: 'Space Mono', monospace;
    font-size: 15vw;
    font-weight: 400;
    line-height: 0.9;
    letter-spacing: -0.06em;
    text-align: center;
    color: var(--text-color);
    margin: 0;
    white-space: nowrap;
    pointer-events: none;
    z-index: 5;
    text-transform: uppercase;
}

@media (max-width: 768px) {
    .hero-name {
        font-size: 12vw;
        letter-spacing: -0.04em;
        line-height: 1;
    }
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: #666;
    margin-bottom: 20px;
}

/* Loader Styles */
body.pretzel-cursor-active,
body.pretzel-cursor-active * {
    cursor: none !important;
}

html,
body {
    background: #000000;
}

.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport height for mobile browsers */
    background: #000;
    z-index: 10000;
    /* Above everything */
    display: flex;
    justify-content: flex-end;
    /* Align to right */
    align-items: flex-end;
    /* Align to bottom */
    padding: 40px;
    /* Padding from edges */
    color: #fff;
}

.loader-text {
    font-variant-numeric: tabular-nums;
    font-size: 20rem;
    /* Way bigger */
    font-weight: 300;
    line-height: 0.8;
}

.loader-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 6px;
    background: #fff;
    z-index: 10000;
    transition: width 0.1s ease-out;
}

@media (max-width: 768px) {
    .loader {
        padding: calc(20px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-right));
        justify-content: flex-end;
        align-items: flex-end;
    }

    .loader-text {
        font-size: 8rem;
        line-height: 1;
        margin-bottom: 0;
    }

    body.pretzel-cursor-active,
    body.pretzel-cursor-active * {
        cursor: auto !important;
    }

    .custom-cursor {
        display: none !important;
    }
}

/* Sections */
.section {
    padding: 120px 0;
    position: relative;
    z-index: 10;
}

.projects-section {
    background-color: transparent;
}

.projects-section .container {
    width: 98%;
    max-width: 100%;
    padding: 0 1vw;
}

.skills-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 40px;
}

.skill-category {
    margin-bottom: 40px;
}

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

.skill-list li {
    font-size: clamp(24px, 4vw, 48px);
    font-weight: 500;
    line-height: 1.2;
    margin-bottom: 10px;
    color: #888;
    transition: color 0.3s ease;
}

.skill-list li:hover {
    color: #fff;
}

/* Projects */
.projects-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 80px;
}

@media (min-width: 768px) {
    .projects-grid {
        grid-template-columns: repeat(5, 1fr);
        column-gap: 14px;
        row-gap: 170px;
    }

    /* Pattern:
       Row 1: 2 cols | 3 cols
       Row 2: 3 cols | 2 cols 
       ... 
    */

    /* Odd items (1, 3, 5...) - Left Side */
    .projects-grid .project-card:nth-child(4n+1) {
        grid-column: span 2;
    }

    .projects-grid .project-card:nth-child(4n+3) {
        grid-column: span 3;
    }

    /* Even items (2, 4, 6...) - Right Side */
    .projects-grid .project-card:nth-child(4n+2) {
        grid-column: span 3;
    }

    .projects-grid .project-card:nth-child(4n+4) {
        grid-column: span 2;
    }

    /* Remove old vertical offset since grid gap handles spacing, 
       but if we want stagger, we can add margin-top to right column elements? 
       Reference has vertical stagger. Let's add margin-top to even items. 
    */
    .projects-grid .project-card:nth-child(even) {
        margin-top: 0;
        /* Remove stagger */
    }
}

.project-card {
    display: block;
}

/* Project Detail Images */
.detail-images-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    width: 100%;
}

.detail-image-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
    background-color: #111;
    /* Mobile: Show full image (no crop) */
    aspect-ratio: auto;
}

.detail-image-wrapper:first-child,
.detail-image-wrapper:last-child {
    aspect-ratio: auto;
}

.detail-image {
    width: 100%;
    height: auto;
    /* Natural height */
    object-fit: contain;
    /* Ensure full visibility */
    display: block;
    object-position: center;
}

@media (min-width: 768px) {
    .detail-images-grid {
        grid-template-columns: 2fr 1fr;
        gap: 20px;
        align-items: start;
    }

    /* Add padding to right image only */
    .detail-image-wrapper:last-child {
        padding-right: 40px;
        aspect-ratio: 3/4;
        /* Restore portrait for desktop */
    }

    .detail-image-wrapper:first-child {
        aspect-ratio: auto;
        /* Restore auto for desktop */
    }

    /* On desktop, we want cover for fixed ratios, or auto for landscape? */
    /* Restore cover for the portrait image */
    .detail-image-wrapper:last-child .detail-image {
        height: 100%;
        object-fit: cover;
    }
}


/* First image - show full image without cropping (DESKTOP ONLY) */
@media (min-width: 768px) {
    .detail-image-wrapper:first-child .detail-image {
        width: 100%;
        height: auto;
        /* Allow natural height */
        object-fit: unset;
        object-position: unset;
    }
}

/* Alternating Grid (Project 3) */
.alternating-grid {
    grid-template-columns: 1fr !important;
    /* Stack vertically */
    gap: 40px !important;
}

/* Mobile defaults for alternating grid -> 5/3 handled by generic rule */
.alternating-grid .detail-image-wrapper {
    width: 100%;
    /* aspect-ratio: 5/3 inherited */
    background-color: transparent;
}

@media (min-width: 768px) {
    .alternating-grid .detail-image-wrapper {
        width: 66.666%;
        aspect-ratio: auto;
        /* Desktop override */
    }

    .alternating-grid .detail-image-wrapper .detail-image {
        width: 100%;
        height: auto;
        object-fit: unset;
        object-position: unset;
    }

    .alternating-grid .detail-image-wrapper:last-child {
        justify-self: end;
        margin-left: auto;
        padding-right: 0;
    }

    .alternating-grid .detail-image-wrapper:last-child .detail-image {
        width: 100%;
        height: auto;
        object-fit: unset;
        object-position: unset;
    }
}

/* Project 2 specific fixes */
/* Custom Split Grid (Project 1 & 2) */
.custom-split-grid {
    /* Mobile default: Stacked */
    grid-template-columns: 1fr !important;
    gap: 40px !important;
}

@media (min-width: 768px) {
    .custom-split-grid {
        gap: 40px !important;
        grid-template-columns: 2fr 1fr !important;
    }

    .custom-split-grid .detail-image-wrapper:last-child {
        aspect-ratio: auto;
        background-color: transparent;
        width: 100%;
        padding: 0;
        justify-self: end;
        display: flex;
        justify-content: flex-end;
    }

    .custom-split-grid .detail-image-wrapper:last-child .detail-image {
        width: 100%;
        height: auto;
        object-fit: unset;
    }
}

.project-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 5/3;
    overflow: hidden;
    margin-bottom: 0;
    /* Minimized spacing */
    background-color: #111;
}

.project-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    background-color: #1a1a1a;
    transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.project-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.project-card:hover .project-overlay {
    opacity: 1;
}

.project-overlay span {
    padding: 12px 24px;
    background: #fff;
    color: #000;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    transform: translateY(10px);
    transition: transform 0.3s ease;
}

.project-card:hover .project-overlay span {
    transform: translateY(0);
}

.project-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding-top: 0px;
}

.project-name {
    font-weight: 500;
    color: #fff;
    position: relative;
    /* Base for pseudo-element */
    display: inline-block;
}

.project-name::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: currentColor;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.project-card:hover .project-name::after {
    transform: scaleX(1);
}

.project-year {
    color: #666;
}

/* Footer */
.footer {
    height: 100vh;
    width: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border-top: none;
    /* Remove border if any from older styles */
    padding: 0;
}

.footer-name {
    /* Use same centering as hero */
    position: absolute;
    bottom: 40px;
    /* Match hero */
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 4vw;
}

.footer-name .hero-name {
    opacity: 1;
    /* Match visible hero name */
}

.custom-cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 24px;
    /* Match pretzel-icon width */
    height: 24px;
    /* Match pretzel-icon height */
    pointer-events: none;
    z-index: 9999;
    color: #fff;
    mix-blend-mode: difference;
    transform: translate(-50%, -50%);
    opacity: 0;
    /* Hidden by default */
}

body.pretzel-cursor-active .custom-cursor {
    opacity: 1;
}

.custom-cursor svg {
    width: 100%;
    height: 100%;
}

.pretzel-icon {
    cursor: pointer !important;
    /* Always clickable */
    pointer-events: all;
}

.footer-content {
    display: none;
    /* Hide content for pure loop visual */
}

.footer-links a {
    margin-right: 20px;
    transition: color 0.3s;
}

.footer-links a:hover {
    color: #fff;
}

.footer-credits {
    display: flex;
    flex-direction: column;
    text-align: right;
    gap: 5px;
}

/* Project Detail View */
.project-detail-view {
    background-color: #000;
    min-height: 100vh;
    padding: 0 1vw 10vh 1vw;
    color: #fff;
    font-family: 'Inter', sans-serif;
}

.detail-nav {
    padding: 5px 0;
}

.back-link {
    color: #666;
    text-decoration: none;
    font-size: 14px;
    border-bottom: 1px solid #666;
    transition: all 0.3s ease;
}

.back-link:hover {
    color: #fff;
    border-bottom: 1px solid #fff;
}

.project-detail-hero {
    width: 100%;
    height: 70vh;
    /* Limit height to 70% of viewport */
    margin-bottom: 40px;
    /* Add some space between hero and text */
    overflow: hidden;
}

.project-detail-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Ensure image covers the area */
    display: block;
}

.project-detail-metadata {
    display: grid;
    grid-template-columns: 1.5fr 3.5fr 1fr 2fr 1fr;
    gap: 40px;
    padding: 0 1vw;
    align-items: start;
}

.metadata-col p,
.metadata-col li {
    font-size: 13px;
    color: #fff;
    line-height: 1.6;
    margin: 0;
}

/* Label colors for Name and Services heading */
.metadata-col.label p {
    color: #fff;
    font-size: 13px;
    font-weight: 400;
    margin-bottom: 0;
    text-transform: none;
}

.metadata-col h3 {
    color: #666;
    font-size: 13px;
    font-weight: 400;
    margin-bottom: 0;
    text-transform: none;
}

.metadata-col h3 {
    margin-bottom: 0;
}

.metadata-col ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.metadata-col .visit-website {
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid #fff;
    display: inline-block;
    padding-bottom: 2px;
    font-size: 13px;
}

@media (max-width: 900px) {
    .project-detail-metadata {
        grid-template-columns: 2fr 1fr 1fr;
        gap: 30px 20px;
    }

    /* Title */
    .metadata-col:nth-child(1) {
        grid-column: 1 / 3;
        grid-row: 1;
    }

    /* Visit Website */
    .metadata-col:nth-child(5) {
        grid-column: 3;
        grid-row: 1;
        text-align: right !important;
    }

    /* Description */
    .metadata-col:nth-child(2) {
        grid-column: 1;
        grid-row: 2;
    }

    /* Services Label */
    .metadata-col:nth-child(3) {
        grid-column: 2;
        grid-row: 2;
    }

    /* Services List */
    .metadata-col:nth-child(4) {
        grid-column: 3;
        grid-row: 2;
    }
}

@media (max-width: 600px) {
    .project-detail-metadata {
        grid-template-columns: 1.5fr 1fr;
        gap: 20px 10px;
    }

    .metadata-col:nth-child(1) {
        grid-column: 1;
        grid-row: 1;
    }

    .metadata-col:nth-child(5) {
        grid-column: 2;
        grid-row: 1;
    }

    .metadata-col:nth-child(2) {
        grid-column: 1 / 3;
        grid-row: 2;
    }

    .metadata-col:nth-child(3) {
        grid-column: 1;
        grid-row: 3;
    }

    .metadata-col:nth-child(4) {
        grid-column: 2;
        grid-row: 3;
    }
}