/* ==========================================================================
   HOME PAGE - Page-specific styles only
   ========================================================================== */

/* Note: Global styles are in global.css */

/* Home: Nav matches section-content max-width (640px) – flush with body content, no extra padding on desktop */
.home .header-container {
    width: 75%;
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 0;
    padding-right: 0;
}

/* Home Sticky Nav at top – padding so content clears the bar */
.home .container {
    padding-top: 72px;
    padding-bottom: 0;
}

/* Home Sticky Nav: fixed to top, floating bar with max width and border */
.header-sticky {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 720px;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(29, 29, 29, 0.1);
    border-radius: 999px;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.header-sticky .header-container {
    padding: 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* Home: sticky nav content full width within bar */
.home .header-sticky .header-container {
    width: 100%;
    max-width: none;
    padding-left: 32px;
    padding-right: 32px;
    box-sizing: border-box;
}

.header-sticky.visible {
    opacity: 1;
}

/* Static Header */
header {
    padding: 32px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: transparent;
    z-index: 100;
    position: relative;
}

/* Navigation */
nav {
    display: flex;
    gap: 32px;
    align-items: center;
}

nav a {
    color: #919191;
    text-decoration: none;
    font-size: 16px;
    font-weight: 400;
    transition: color 0.2s;
}

nav a.active {
    color: #2D352D;
}

nav a:hover {
    color: #2D352D;
}

/* Hero Parallax Wrapper - sticky so it participates in overscroll rubber band, sits behind content so it scrolls over. */
/* Full viewport height so nav + hero are the only visible content; "What I do" sits just below fold */
.hero-parallax-wrapper {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 96px); /* Fill viewport below nav – "What I do" sits just below fold */
    padding-top: 24px; /* Gap between nav and hero */
    z-index: -1;
    pointer-events: none;
    width: 100vw;
    margin-left: calc(-50vw + 50%); /* break out of container for full viewport width */
}

/* Hero Section - centered with responsive width; whitespace around on wider viewports */
.hero-section {
    display: flex;
    flex: 1;
    justify-content: center;
    align-items: center;
    width: 75%; /* Wider viewports: 75% with max 1080px */
    max-width: 1080px;
    padding: 0 24px;
    box-sizing: border-box;
}

/* Hero box - fits within viewport; vertically and horizontally centred with whitespace */
.hero-box {
    background-color: #DDEBD4;
    box-shadow: 0 0 80px rgba(221, 235, 212, 0.85);
    transition: background-color 0.6s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    aspect-ratio: 8 / 5;
    height: auto;
    min-height: 0;
    /* Cap height so hero fits in viewport – nav ~96px, padding-top 24px, gap below ~80px */
    max-height: min(720px, calc(100vh - 200px));
    padding: 80px 48px;
    border-radius: var(--radius-2xl);
    display: flex;
    justify-content: center;
    align-items: center;
    transform-origin: center center;
}

.hero-content {
    max-width: 640px;
}

.hero-content h1 {
    text-align: center;
    margin-bottom: 0;
    color: #2D352D;
}

/* Glitch word - dynamic hero text with smooth width transition */
.glitch-word-wrapper {
    display: inline-block;
    overflow: visible;
    vertical-align: bottom;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.glitch-word {
    display: inline-block;
    white-space: nowrap;
    position: relative;
}

/* Case study / writing titles - allow wrapping for long text */
.glitch-title {
    white-space: normal;
}

.glitch-title::before,
.glitch-title::after {
    white-space: normal;
}

/* When showing alt text on hover - prevent wrapping during glitch */
.glitch-title.glitch-showing-alt {
    white-space: nowrap;
}

.glitch-title.glitch-showing-alt::before,
.glitch-title.glitch-showing-alt::after {
    white-space: nowrap;
}

/* RGB split / chromatic aberration - offset red and cyan copies */
.glitch-word::before,
.glitch-word::after {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
}

.glitch-word.glitch-active::before {
    color: #FF0040;
    text-shadow: 0 0 2px #FF0040;
    animation: glitch-rgb-before var(--glitch-duration, 0.5s) steps(6) forwards;
}

.glitch-word.glitch-active::after {
    color: #00D4FF;
    text-shadow: 0 0 2px #00D4FF;
    animation: glitch-rgb-after var(--glitch-duration, 0.5s) steps(6) forwards;
}

@keyframes glitch-rgb-before {
    0%, 100% { transform: translate(0, 0); opacity: 0; }
    16% { transform: translate(calc(-3px * var(--glitch-intensity, 1)), calc(1px * var(--glitch-intensity, 1))); opacity: 0.85; }
    33% { transform: translate(calc(2px * var(--glitch-intensity, 1)), calc(-2px * var(--glitch-intensity, 1))); opacity: 0.85; }
    50% { transform: translate(calc(-2px * var(--glitch-intensity, 1)), calc(2px * var(--glitch-intensity, 1))); opacity: 0.85; }
    66% { transform: translate(calc(3px * var(--glitch-intensity, 1)), calc(-1px * var(--glitch-intensity, 1))); opacity: 0.85; }
    83% { transform: translate(0, 0); opacity: 0; }
}

@keyframes glitch-rgb-after {
    0%, 100% { transform: translate(0, 0); opacity: 0; }
    16% { transform: translate(calc(3px * var(--glitch-intensity, 1)), calc(-1px * var(--glitch-intensity, 1))); opacity: 0.85; }
    33% { transform: translate(calc(-2px * var(--glitch-intensity, 1)), calc(2px * var(--glitch-intensity, 1))); opacity: 0.85; }
    50% { transform: translate(calc(2px * var(--glitch-intensity, 1)), calc(-2px * var(--glitch-intensity, 1))); opacity: 0.85; }
    66% { transform: translate(calc(-3px * var(--glitch-intensity, 1)), calc(1px * var(--glitch-intensity, 1))); opacity: 0.85; }
    83% { transform: translate(0, 0); opacity: 0; }
}

.glitch-word.glitch-active {
    animation: glitch var(--glitch-duration, 0.5s) steps(6) forwards;
}

@keyframes glitch {
    0%, 100% {
        text-shadow: none;
        transform: translate(0) skew(0deg);
        font-style: normal;
        filter: none;
        opacity: 1;
    }
    8% {
        text-shadow: calc(-4px * var(--glitch-intensity, 1)) 0 2px #FF0040, calc(4px * var(--glitch-intensity, 1)) 0 2px #00D4FF, calc(-2px * var(--glitch-intensity, 1)) calc(2px * var(--glitch-intensity, 1)) 3px #FF0040;
        transform: translate(calc(-4px * var(--glitch-intensity, 1)), calc(3px * var(--glitch-intensity, 1))) skew(calc(-12deg * var(--glitch-intensity, 1)));
        font-style: italic;
        filter: brightness(1.3) blur(0.5px);
    }
    16% {
        text-shadow: calc(4px * var(--glitch-intensity, 1)) 0 2px #00D4FF, calc(-4px * var(--glitch-intensity, 1)) 0 2px #FF0040, calc(2px * var(--glitch-intensity, 1)) calc(-2px * var(--glitch-intensity, 1)) 3px #00D4FF;
        transform: translate(calc(4px * var(--glitch-intensity, 1)), calc(-3px * var(--glitch-intensity, 1))) skew(calc(12deg * var(--glitch-intensity, 1)));
        font-style: italic;
        filter: blur(0.5px);
    }
    24% {
        text-shadow: calc(-3px * var(--glitch-intensity, 1)) calc(2px * var(--glitch-intensity, 1)) 2px #FF0040, calc(3px * var(--glitch-intensity, 1)) calc(-2px * var(--glitch-intensity, 1)) 2px #00D4FF;
        transform: translate(calc(-3px * var(--glitch-intensity, 1)), calc(-4px * var(--glitch-intensity, 1))) skew(calc(-8deg * var(--glitch-intensity, 1)));
        font-style: italic;
        filter: brightness(1.2) blur(0.5px);
    }
    32% {
        text-shadow: calc(3px * var(--glitch-intensity, 1)) calc(-2px * var(--glitch-intensity, 1)) 2px #00D4FF, calc(-3px * var(--glitch-intensity, 1)) calc(2px * var(--glitch-intensity, 1)) 2px #FF0040;
        transform: translate(calc(3px * var(--glitch-intensity, 1)), calc(4px * var(--glitch-intensity, 1))) skew(calc(8deg * var(--glitch-intensity, 1)));
        font-style: normal;
        filter: blur(0.5px);
    }
    42% {
        text-shadow: calc(-5px * var(--glitch-intensity, 1)) 0 3px #FF0040, calc(5px * var(--glitch-intensity, 1)) 0 3px #00D4FF;
        transform: translate(calc(-2px * var(--glitch-intensity, 1)), calc(2px * var(--glitch-intensity, 1))) skew(calc(-15deg * var(--glitch-intensity, 1)));
        font-style: italic;
        filter: brightness(1.35) blur(0.5px);
    }
    52% {
        text-shadow: calc(5px * var(--glitch-intensity, 1)) 0 3px #00D4FF, calc(-5px * var(--glitch-intensity, 1)) 0 3px #FF0040;
        transform: translate(calc(2px * var(--glitch-intensity, 1)), calc(-2px * var(--glitch-intensity, 1))) skew(calc(15deg * var(--glitch-intensity, 1)));
        font-style: italic;
        filter: blur(0.5px);
    }
    62% {
        text-shadow: calc(-1px * var(--glitch-intensity, 1)) calc(1px * var(--glitch-intensity, 1)) 1px rgba(255, 0, 64, 0.4), calc(1px * var(--glitch-intensity, 1)) calc(-1px * var(--glitch-intensity, 1)) 1px rgba(0, 212, 255, 0.4);
        transform: translate(calc(-1px * var(--glitch-intensity, 1)), calc(1px * var(--glitch-intensity, 1))) skew(calc(-5deg * var(--glitch-intensity, 1)));
        font-style: italic;
        filter: brightness(1.15) blur(0.4px);
    }
    72% {
        text-shadow: calc(-2px * var(--glitch-intensity, 1)) 0 2px #FF0040, calc(2px * var(--glitch-intensity, 1)) 0 2px #00D4FF;
        transform: translate(calc(1px * var(--glitch-intensity, 1)), calc(-1px * var(--glitch-intensity, 1))) skew(calc(5deg * var(--glitch-intensity, 1)));
        font-style: normal;
        filter: blur(0.5px);
    }
    85% {
        text-shadow: none;
        transform: translate(0) skew(0deg);
        font-style: normal;
        filter: none;
        opacity: 1;
    }
}

/* Sections */
.section {
    margin-bottom: 80px;
    scroll-margin-top: 80px;
}

#about {
    scroll-margin-top: 120px;
}

#about .section-content h3 {
    margin-bottom: 32px;
}

.body-text a {
    color: #2D352D;
    text-decoration: none;
}

/* Keylines */
.keyline {
    height: 0.5px;
    background-color: rgba(29, 29, 29, 0.1);
    max-width: 640px;
    margin: 0 auto;
}

.keyline-above-work {
    margin-bottom: 48px;
}

.keyline-below-about {
    margin-top: 80px;
}

/* Work Grid */
.work-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 48px;
    max-width: 860px;
    margin: 0 auto;
}

/* Work Cards Gallery */
.work-cards-container {
    position: relative;
    margin-top: 24px;
    margin-bottom: 48px;
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
   display: none;
}

.work-cards-scroll {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.work-cards-scroll::-webkit-scrollbar {
    display: none;
}

.work-card {
    flex: 0 0 280px;
    background: #ffffff;
    border: 1px solid rgba(29, 29, 29, 0.1);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.work-card-company {
    font-family: 'Inter', sans-serif;
    font-optical-sizing: auto;
    font-weight: 400;
    font-size: 18px;
    color: #2D352D;
}

.work-card-role {
    font-family: 'Inter', sans-serif;
    font-optical-sizing: auto;
    font-weight: 400;
    font-size: 14px;
    color: #919191;
}

.work-card-dates {
    font-family: 'Inter', sans-serif;
    font-optical-sizing: auto;
    font-weight: 400;
    font-size: 14px;
    color: #919191;
}

/* Fade overlays */
.fade-left,
.fade-right {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 120px;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.3s;
}

.fade-left {
    left: 0;
    background: linear-gradient(to right, #ffffff 0%, rgba(255, 255, 255, 0) 100%);
    opacity: 0;
}

.fade-left.visible {
    opacity: 1;
}

.fade-right {
    right: 0;
    background: linear-gradient(to left, #ffffff 0%, rgba(255, 255, 255, 0) 100%);
}

.fade-right.hidden {
    opacity: 0;
}

/* Navigation arrows */
.scroll-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: #ffffff;
    border: 1px solid rgba(29, 29, 29, 0.1);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    transition: opacity 0.3s, background-color 0.2s;
    color: #2D352D;
    font-family: 'Inter', sans-serif;
}

.scroll-arrow svg {
    width: 16px;
    height: 16px;
}

.scroll-arrow:hover {
    background-color: #F7F7F9;
}

.scroll-arrow-left {
    left: 0;
    opacity: 0;
    pointer-events: none;
}

.scroll-arrow-left.visible {
    opacity: 1;
    pointer-events: auto;
}

.scroll-arrow-right {
    right: 0;
}

.scroll-arrow-right.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Work Items */
.work-item {
    text-decoration: none;
    display: block;
}

.work-image {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    aspect-ratio: 1771/1057;
    background-color: #F7F7F9;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    overflow: hidden;
    border: 1px solid transparent;
    transition: border-color 0.2s, border-width 0.2s;
}

.work-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.work-item:hover .work-image img {
    transform: scale(1.03);
}

.work-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    max-width: 640px;
    margin: 0 auto;
}

.work-title {
    flex: 1;
}

.work-item h4 {
    text-decoration: none;
    margin-bottom: 8px;
}

.work-company {
    font-size: 16px;
    color: #2D352D;
    opacity: 0.5;
}

.arrow {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2D352D;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.arrow svg {
    width: 24px;
    height: 24px;
}

/* Coming soon pill - same grey as writing-item container (#F7F7F9) */
.coming-soon-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    background-color: #F7F7F9;
    color: rgba(45, 53, 45, 0.5);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    border-radius: 999px;
    flex-shrink: 0;
}

/* Non-interactive work item - no hover effects */
.work-item-coming-soon:hover .work-image img {
    transform: none;
}


/* Writing Section */
.writing-item {
    text-decoration: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 32px;
    border-radius: var(--radius-lg);
    background-color: #F7F7F9;
}

.writing-info h4 {
    margin-bottom: 8px;
}

.writing-source {
    font-size: 16px;
    color: #2D352D;
    opacity: 0.5;
}

/* Contact Section - Home specific positioning */
.contact-section {
    margin-top: 120px;
    position: relative;
    z-index: 2;
}

/* Hero spacer - maintains document flow when hero is fixed (JS updates on load/resize) */
.hero-spacer {
    min-height: 780px;
}

/* Hero container – responsive width: 85% on medium viewports */
@media (max-width: 1024px) {
    .home .header-sticky .header-container {
        width: 85%;
    }
    .hero-section {
        width: 85%;
        max-width: none;
    }
    .hero-box {
        max-height: min(562px, calc(100vh - 200px));
    }
}

/* Responsive – 95% width on mobile, hero fits viewport */
@media (max-width: 768px) {
    .nav-link-fun {
        display: none;
    }

    nav {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 16px;
    }

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

    /* Mobile only: 32px left/right padding so nav/time sit 32px from screen edge (like case study) */
    .home .header-sticky .header-container {
        width: 100%;
        max-width: none;
        padding: 24px 32px;
        box-sizing: border-box;
    }

    .hero-parallax-wrapper {
        padding: 16px; /* 16px whitespace around hero */
        max-height: calc(100vh - 96px);
        overflow: hidden;
    }
        
    .hero-section {
        padding: 0;
        width: 95%;
        max-width: none;
        align-items: stretch;
    }

    /* Hero fits viewport with 16px whitespace on all sides */
    .hero-box {
        width: 100%;
        height: calc(100vh - 96px - 32px);
        max-height: calc(100vh - 96px - 32px);
        min-height: 0;
        padding: 48px 32px;
    }

    .hero-spacer {
        min-height: 692px;
    }

    .section {
        margin-bottom: 48px;
    }

    .contact-section {
        margin-top: 80px;
        padding: 48px 24px;
    }
}

@media (max-width: 480px) {
    .hero-box {
        padding: 32px 24px;
        border-radius: var(--radius-lg);
    }

    .hero-spacer {
        min-height: 656px;
    }
}
