/* =========================================
   PROJECT DETAIL PAGE - CLEAN IMPLEMENTATION
   Based on Ea-Web-study-case-px.jpg reference
   ========================================= */

/* Reset for project body */
body.project-body {
    margin: 0;
    padding: 0;
}

/* ===================
   1. HERO SECTION (Full Screen)
   =================== */
.project-hero {
    width: 100vw;
    height: 100vh;
    position: relative;
    margin: 0;
    padding: 0;
    background: #000;
    /* Prevents white flash during Vimeo crossfade */
    /* Breakout from any parent container */
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
}

.project-hero-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ===================
   2. MAIN GRID CONTAINER
   =================== */
/* ===================
   2. MAIN GRID CONTAINER
   =================== */
.project-grid-container {
    display: grid;
    grid-template-columns: minmax(auto, 280px) 1fr;
    gap: 0;
    max-width: 100%;
    margin: 100px 0;
    padding-left: 20px;
    padding-right: 20px;
    /* Equal right padding */
}

/* ===================
   3. SIDEBAR (Left Column - Static)
   =================== */
/* ===================
   3. SIDEBAR GROUP (Title, Meta, Credits)
   =================== */
.sidebar-group-top {
    grid-column: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-right: 50px;
    padding-left: 15px;
    margin-bottom: 2rem;
    /* Gap before next sidebar item */

    overflow-wrap: break-word;
    /* Ensure text doesn't overflow */
    word-break: break-word;
    hyphens: auto;
}

/* Sidebar Items (Injected blocks) */
.sidebar-item {
    grid-column: 1;
    padding-right: 50px;
    padding-left: 15px;
    margin-bottom: 1.5rem;
    /* Gap between sidebar items */

    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

/* Revert old sidebar generic class if needed, or keep for legacy/shared */
.project-sidebar {
    /* LEGACY - Kept for safety, but mostly replaced by above */
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Typography for Sidebar */
.project-title h1 {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 1.25rem;
    font-weight: bold;
    line-height: 1.3;
    margin: 0 0 1.5rem 0;
    text-transform: none;
}

.project-meta {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 0.875rem;
    line-height: 1.8;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
}

.project-meta span {
    display: block;
    margin-bottom: 0.2rem;
}

.project-credits {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    /* Removed white-space: pre-line — was causing text to expand beyond max-width */
}

/* Universal rule: covers both creditsHTML and role/name paths */
.project-credits,
.project-credits * {
    font-size: 0.8rem !important;
    line-height: 1.5;
}

.credit-item {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 0.6rem;
    /* Reduced by ~3pt (12px -> ~9px) */
    line-height: 1.6;
    margin-bottom: 0.5rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.credit-role {
    display: inline;
    font-weight: bold;
    margin-right: 4px;
    margin-bottom: 0;
}

.credit-name {
    display: inline;
    font-weight: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ===================
   4. MAIN CONTENT ITEMS
   =================== */
.main-item {
    grid-column: 2;
    padding-right: 16px;
    display: flex;
    flex-direction: column;
    margin-bottom: 4vw;
    /* Responsive spacing to next module */
}

/* Full Width Items */
.full-width-item {
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 0;
    margin-bottom: 20px;
    padding: 0;
    /* Remove internal padding to align directly to grid bounds */
    box-sizing: border-box;
}

/* Text blocks styling */
.content-text {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 0.95rem;
    line-height: 1.6;
    max-width: 650px;
    width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
    margin-top: 0;
    margin-bottom: 1.5rem;
}

/* Constrain all children: admin uses contenteditable which saves <div>/<br> as HTML on Enter */
.content-text *,
.content-text div,
.content-text p,
.content-text span {
    max-width: 650px !important;
    width: auto !important;
    display: block;
    overflow-wrap: break-word;
    word-break: break-word;
}


/* ===================
   5. IMAGES
   =================== */

/* DOUBLE COLUMN GRID (image-duo) */
.image-duo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 0;
    align-items: start;
    width: 100%;
    box-sizing: border-box;
}

/* STYLE 1: Right-aligned images (within content column) */
.image-style-1 {
    width: 100%;
    height: auto;
    display: block;
    margin-top: 0;
    margin-bottom: 20px;
    box-sizing: border-box;
}

/* STYLE 2: Full-width within grid (not viewport) */
.image-style-2-wrapper {
    /* Stay within page boundaries, span both columns */
    width: 100%;
    margin-top: 0;
    margin-bottom: 0;
    grid-column: 1 / -1;
    /* Span sidebar + content */
    padding: 0;
    /* Align directly */
    box-sizing: border-box;
    /* User goal: Total Visual Alignment */
}

.image-style-2 {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

/* ===================
   6. RESPONSIVE
   =================== */
@media (max-width: 1200px) {
    .project-grid-container {
        grid-template-columns: 1fr;
        margin: 60px 20px;
        gap: 3rem;
    }

    .project-sidebar {
        padding-right: 0;
        padding-left: 0;
        max-width: 600px;
    }

    .image-style-2-wrapper {
        margin-top: 0;
        margin-bottom: 0;
        padding: 0;
    }

    .image-duo {
        grid-template-columns: 1fr;
    }
}

/* ===================
   VIDEO SUPPORT
   =================== */

/* Ensure videos behave exactly like images */
video.project-hero-bg,
video.image-style-1,
video.image-style-2 {
    width: 100%;
    height: auto;
    object-fit: contain;
    /* Use contain instead of cover to maintain aspect ratio */
    display: block;
}

/* Image Style 1 videos match image styling exactly */
video.image-style-1 {
    margin-top: 0;
    margin-bottom: 20px;
    box-sizing: border-box;
}

/* Hero videos should cover */
video.project-hero-bg {
    height: 100%;
    object-fit: cover;
}

/* HTML Media Wrapper (Iframes/Vimeo) */
.html-media-wrapper-hero,
.vimeo-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    overflow: hidden;
    z-index: 0;
}

.html-media-wrapper-hero iframe,
.vimeo-wrapper iframe {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100vw;
    height: 56.25vw;
    /* 16:9 Aspect Ratio */
    min-height: 100vh;
    min-width: 177.77vh;
    /* 16:9 Aspect Ratio */
    transform: translate(-50%, -50%);
    pointer-events: none;
}

/* Generic HTML Content Wrapper */
.html-media-wrapper {
    width: 100%;
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 */
    height: 0;
    margin: 0;
}

.html-media-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    border: none;
}

/* ===================
   VIMEO HERO REVEAL (NO DIP TO BACKGROUND)
   Iframe loads behind the poster at full opacity.
   When ready, the poster fades out, revealing the video.
   =================== */
.vimeo-poster-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 2;
    transition: opacity 0.8s ease;
    pointer-events: none;
}

/* The Vimeo iframe wrapper starts at full opacity, but hidden simply by z-index ranking */
.vimeo-crossfade-wrapper {
    opacity: 1;
    /* Always 1, no transition needed */
    z-index: 1;
}

/* JS adds .vimeo-hidden to the poster once video plays */
.vimeo-poster-img.vimeo-hidden {
    opacity: 0;
    pointer-events: none;
}

/* ===================
   LAZY IMAGE BLUR-UP
   Images start blurred, transition to sharp once loaded.
   =================== */
img.lazy-image {
    filter: blur(14px);
    transform: scale(1.04);
    transition: filter 0.55s ease, transform 0.55s ease;
    will-change: filter, transform;
}

img.lazy-image.img-loaded {
    filter: none;
    transform: scale(1);
}

/* ===================
   7. THREE-PANEL PROJECT NAVIGATION
   =================== */
.project-nav-area {
    position: relative;
    width: 100vw;
    height: 60vh;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    background: #000;
    color: #fff;
    margin-bottom: -50px;
}

/* Dividers between panels */
.project-nav-area .nav-panel:not(:last-child) {
    border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.nav-panel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    overflow: hidden;
    cursor: pointer;
}

/* Hover background image for Prev/Next */
.nav-hover-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.nav-hover-bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    /* No transition here — animation takes full control on hover */
    transform: scale(1.08);
    will-change: opacity, transform, filter;
}

.nav-panel:hover .nav-hover-bg img {
    opacity: 0.6;
    transform: scale(1);
    /* Transition handles the reveal; glitch animation layered on top */
    transition: opacity 0.4s ease, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Collage for Back to Works */
.nav-back-collage {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    opacity: 0;
    transition: opacity 0.5s ease;
    overflow: hidden;
}

.collage-item {
    background-size: cover;
    background-position: center;
    filter: brightness(0.5);
}

.nav-back:hover .nav-back-collage {
    opacity: 1;
}

/* Nav label text */
.nav-label {
    position: relative;
    z-index: 2;
    font-family: 'Crit', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 14px;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: #fff;
    opacity: 0.7;
    transition: opacity 0.3s ease, letter-spacing 0.4s ease;
    text-align: center;
    padding: 0 20px;
}

.nav-panel:hover .nav-label {
    opacity: 1;
    letter-spacing: 3.5px;
}

/* Panel direction arrows (subtle) */
.nav-prev::before {
    content: '←';
    position: absolute;
    left: 24px;
    z-index: 2;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.3);
    transition: color 0.3s, transform 0.3s;
}

.nav-prev:hover::before {
    color: rgba(255, 255, 255, 0.8);
    transform: translateX(-4px);
}

.nav-next::after {
    content: '→';
    position: absolute;
    right: 24px;
    z-index: 2;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.3);
    transition: color 0.3s, transform 0.3s;
}

.nav-next:hover::after {
    color: rgba(255, 255, 255, 0.8);
    transform: translateX(4px);
}

/* Mobile: Project Detail Pages */
@media (max-width: 768px) {

    /* === HERO: Shorter on mobile === */
    .project-hero {
        height: 50vh;
        min-height: 280px;
        margin-left: 0;
        margin-right: 0;
        width: 100%;
    }

    .project-hero-bg {
        object-fit: contain;
    }

    /* === GRID CONTAINER: Stack fully, tighter margins === */
    .project-grid-container {
        grid-template-columns: 1fr;
        margin: 40px 0;
        padding-left: 16px;
        padding-right: 16px;
        gap: 0;
    }

    /* === SIDEBAR: Remove right padding, full width === */
    .sidebar-group-top {
        padding-right: 0;
        padding-left: 0;
        margin-bottom: 1.5rem;
    }

    .sidebar-item {
        padding-right: 0;
        padding-left: 0;
    }

    .project-sidebar {
        padding-right: 0;
        padding-left: 0;
        max-width: 100%;
    }

    .project-title h1 {
        font-size: 1.1rem;
    }

    .project-meta {
        font-size: 0.8rem;
    }

    /* === MAIN CONTENT: Full width on mobile === */
    .main-item {
        grid-column: 1;
        padding-right: 0;
        margin-bottom: 24px;
    }

    .full-width-item {
        grid-column: 1;
        padding: 0;
    }

    /* === TEXT: Narrower limit for readability === */
    .content-text {
        max-width: 100%;
        font-size: 0.85rem;
    }

    .content-text *,
    .content-text div,
    .content-text p,
    .content-text span {
        max-width: 100% !important;
    }

    /* === IMAGES: Full width, no crop === */
    .image-style-1,
    .image-style-2 {
        width: 100%;
        height: auto;
        object-fit: contain;
    }

    .image-duo {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .image-style-2-wrapper {
        grid-column: 1;
    }

    /* === VIDEOS: Contain on mobile === */
    video.project-hero-bg {
        object-fit: contain;
        height: 100%;
    }

    video.image-style-1,
    video.image-style-2 {
        width: 100%;
        height: auto;
        object-fit: contain;
    }

    /* === NAV PANELS: Stack vertically === */
    .project-nav-area {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(3, 1fr);
        height: auto;
        margin-left: 0;
        margin-right: 0;
        width: 100%;
    }

    .nav-panel {
        height: 80px;
        border-right: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    }

    .nav-label {
        font-size: 12px;
    }

    .nav-prev::before,
    .nav-next::after {
        display: none;
    }
}

/* ===================
   8. CSS RGB GLITCH EFFECT (nav panels)
   =================== */

/* Image glitch on hover: quick chromatic aberration pulse */
@keyframes nav-rgb-glitch {
    0% {
        filter: none;
    }

    20% {
        filter: saturate(2) hue-rotate(15deg) brightness(1.1);
        transform: scale(0.999) translateX(-3px);
    }

    40% {
        filter: saturate(0.7) hue-rotate(-10deg);
        transform: scale(1) translateX(2px);
    }

    60% {
        filter: none;
        transform: scale(1) translateX(0);
    }

    80% {
        filter: saturate(1.4) hue-rotate(6deg);
    }

    100% {
        filter: none;
        transform: scale(1);
    }
}

/* Text RGB split on hover */
@keyframes nav-label-glitch {
    0% {
        text-shadow: none;
    }

    15% {
        text-shadow: -3px 0 rgba(255, 0, 60, 0.85), 3px 0 rgba(0, 210, 255, 0.85);
        letter-spacing: 3px;
    }

    30% {
        text-shadow: 2px 0 rgba(255, 0, 60, 0.5), -2px 0 rgba(0, 210, 255, 0.5);
    }

    50% {
        text-shadow: -1px 0 rgba(255, 0, 60, 0.3), 1px 0 rgba(0, 210, 255, 0.3);
    }

    70% {
        text-shadow: none;
        letter-spacing: 3.5px;
    }

    85% {
        text-shadow: -2px 0 rgba(255, 0, 60, 0.4), 2px 0 rgba(0, 210, 255, 0.4);
    }

    100% {
        text-shadow: none;
    }
}

/* Trigger glitch when hovering nav-prev or nav-next */
.nav-prev:hover .nav-hover-bg img,
.nav-next:hover .nav-hover-bg img {
    opacity: 0.6;
    transform: scale(1);
    transition: opacity 0.4s ease, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    animation: nav-rgb-glitch 0.55s ease 0.1s forwards;
}

.nav-panel:hover .nav-label {
    animation: nav-label-glitch 0.6s ease forwards;
}

/* Back to Works: no image glitch (collage), just subtle label pulse */
.nav-back:hover .nav-label {
    animation: nav-label-glitch 0.6s ease forwards;
}

/* Collage items get a very subtle color shift */
.nav-back:hover .collage-item {
    filter: brightness(0.5) saturate(1.6) hue-rotate(10deg);
    transition: filter 0.35s ease;
}