/*---------------------------------------------------------
 * Single Project Carousel Styles
 * 
 * Extends the main carousel styles for single project pages
 * with project-specific content and layout adjustments
/----------------------------------------------------------*/

:root {
    --land-thumb-item-width: 100px;
    --land-thumb-item-height: 147px;
}
body {
    background-color: var(--color-accent-6);
}
.site-inner {
    margin-block-end: 60px;
}
/**---------------------------------------------------------
/** Layout Adjustments
/**--------------------------------------------------------*/

.single-project .site-inner {
    margin-block-start: 4rem;
}
.single-project .site-inner .wrap {
    width: 1368px; /* Limit width for single project */
    max-width: 90%;
    margin: 0 auto; /* Center the content */
}

/**---------------------------------------------------------
/** Blurred Image Background (only seen on landscape)
/**--------------------------------------------------------*/

/* Create two pseudo-elements for smooth crossfade transitions.
   This the 'page background img duplicate' for project pages.  */
.site-container.single-project-background::before,
.site-container.single-project-background::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 800px; /* Your specified height */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    filter: blur(20px) brightness(0.8);
    transform: scale(1.1); /* Prevent blur edge artifacts */
    z-index: -1;
    transition: opacity 0.5s ease-in-out;

    /* Sharp bottom edge using clip-path */
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 20px), 0 calc(100% - 20px));
}

/* Primary background layer */
.site-container.single-project-background::before {
    background-image: var(--single-project-bg-image, none);
    opacity: 1;
}

/* Secondary background layer for crossfading */
.site-container.single-project-background::after {
    background-image: var(--single-project-bg-image-next, none);
    opacity: 0;
}

/* When transitioning, fade in the secondary layer */
.site-container.single-project-background.transitioning::after {
    opacity: 1;
}

/* When transition complete, swap the layers */
.site-container.single-project-background.swapped::before {
    opacity: 0;
}

.site-container.single-project-background.swapped::after {
    opacity: 1;
}

/* Base styles for site container background */
.site-container.single-project-background {
    position: relative;
}

/* Ensure content is above background */
.site-container.single-project-background > * {
    position: relative;
    z-index: 1;
}

/*---------------------------------------------------------
 * Single Project Split Layout - Updated for Overlap
/----------------------------------------------------------*/

.single-project-section {
    position: relative;
    /* min-height: 100vh; */
    font-family: 'Roboto Flex', sans-serif;
}

/* Split Container - Using grid for precise overlap control */
.project-split-container {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr 61%;
    grid-template-rows: 1fr;
    width: 100%;
    /* min-height: 100vh; */
    align-items: center;
}

/* Left Panel - Project Information */
.project-info-panel {
    grid-column: 1;
    grid-row: 1;
    background: var(--color-accent-4);
    display: flex;
    align-items: flex-start;
    padding: 3rem;
    box-sizing: border-box;
    z-index: 1;
    min-height: 620px;
    /* Add some right padding to account for overlap */
    padding-inline-end: calc(3rem + 2rem); /* Original padding + overlap */
}

.project-info-content {
    width: 100%;
    max-width: 500px;
    container-type: inline-size;
    container-name: project-info;
}

.project-title {
    font-size: clamp(1.5rem, 0.5rem + 6.25vw, 3rem); /* Fallback for browsers without container query support */
    font-weight: 300;
    line-height: 1;
    margin: 0 0 1rem 0;
    color: var(--color-accent-1); /* Orange color from design */
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-block-end: 1px solid color-mix(in srgb, var(--color-accent-5), transparent 70%);
}

/* Container query for responsive font-size based on container width */
@container project-info (width >= 250px) {
    .project-title {
        font-size: 2rem; /* Mid-point between 1.5rem and 3rem */
    }
}

@container project-info (width >= 325px) {
    .project-title {
        font-size: 2.5rem; /* Stepping towards 3rem */
    }
}

@container project-info (width >= 400px) {
    .project-title {
        font-size: 3rem; /* Full size */
    }
}

@container project-info (width >= 400px) {
    .project-title {
        font-size: 3rem;
    }
}

.project-location {
    font-size: 1rem;
    color: var(--color-accent-1);
    font-weight: 400;
}

.project-description {
    margin: 2rem 0;
    line-height: 1.6;
    color: var(--color-primary-dark);
    font-size: 1rem;
}

.project-description p {
    margin: 0 0 1rem 0;
}

.project-details {
    margin-top: 3rem;
}

.detail-section {
    margin-bottom: 2rem;
}

.detail-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-accent-1);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 0.5rem 0;
}

.detail-value {
    font-size: 1rem;
    color: var(--color-primary-dark);
    font-weight: 400;
    line-height: 1.4;
}

/* Right Panel - Carousel with overlap and elevation */
.project-carousel-panel {
    grid-column: 2;
    grid-row: 1;
    align-self: flex-start; /* Align to top of right panel */
    position: relative;
    background: #000;
    z-index: 2; /* Above the info panel */

    /* Create the overlap - move left by 2rem */
    margin-left: -2rem;

    /* Elevate the panel - move up by 150px */
    transform: translateY(-150px);

    /* Add height to compensate for the upward movement */
    /* min-height: calc(100vh + 150px); */
}

.single-project-gallery {
    height: 100%;
    width: 100%;
    position: relative;
}

/*---------------------------------------------------------
 * Single Project Carousel Overrides with Background Image
/----------------------------------------------------------*/

.single-project-carousel {
    width: 100%;
    position: relative;
    margin: 0;
    overflow: initial;

    /* With aspect-ratio */
    aspect-ratio: 1.467857;
    height: auto;
    max-height: 590px;
    padding-bottom: 0;

    /* Without aspect-ratio */
}

/* Add background image to the list container */
.single-project-carousel .list {
    /* background-image: url('/wp-content/themes/pdxwoodworking/images/project-carousel-background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat; */
    position: relative;
    width: 100%;
    height: 100%;
}
.single-project-carousel .list::before {
    position: absolute;
    content: '';
    inset: 0;
    background-image: url('/wp-content/themes/pdxwoodworking/images/walnut.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: brightness(0.4);
}

/* Single Project Carousel Items - EXACTLY like homepage carousel */
.single-project-carousel .list .item {
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0 0 0 0;
}

/* First item visible */
.single-project-carousel .list .item:nth-child(1) {
    z-index: 1;
    opacity: 1;
}

/* All other items hidden */
.single-project-carousel .list .item:not(:nth-child(1)) {
    z-index: 0;
    opacity: 0;
}

/* PREV transition - copied directly from carousel.css */
.single-project-carousel.prev .list .item:nth-child(2) {
    z-index: 2;
    opacity: 0;
}

/* .single-project-carousel.prev .list .item:nth-child(2) img {
    animation: outFrameSingleProject 0.5s linear 1 forwards;
    position: absolute;
    bottom: 0;
    left: 0;
}

@keyframes outFrameSingleProject {
    to {
        width: var(--land-thumb-item-width);
        height: var(--land-thumb-item-height);
        bottom: 2rem;
        left: 92%;
        border-radius: 0.25rem;
    }
} */

/* NEXT transition: Fade out the current image that becomes last */
.single-project-carousel.next .list .item:last-child {
    animation: fadeOutCurrent 1s ease-out forwards;
    z-index: 1; /* Below the growing image */
}

@keyframes fadeOutCurrent {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Remove content overlays - images only */
.single-project-carousel .list .item .content {
    display: none; /* Hide the content overlay completely */
}

/* Ensure images fill the space */
.single-project-carousel .list .item img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Default - will be overridden by JavaScript */
    filter: brightness(1); /* Remove the dark filter */
}

/* Reposition thumbnails for split layout */
.single-project-carousel .thumbnail {
    bottom: -5rem;
    left: calc(6rem + 96px);
    /* right: 2rem; */
    /* justify-content: center; */
    padding-inline-start: 0;
}

/* Reposition arrows for split layout */
.single-project-carousel .arrows {
    bottom: -5rem;
    left: 4rem;
    padding-inline-start: 0;
    /* right: 14rem; */
    /* width: auto; */
}

/*---------------------------------------------------------
 * Button Adjustments for Single Project
/----------------------------------------------------------*/

.single-project-carousel .list .item .buttons {
    /* Inherits positioning from carousel.css */
}

.single-project-carousel .list .item .buttons .btn-secondary {
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 0.25rem;
    background-color: transparent;
    font-family: 'Roboto Flex', sans-serif;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    transition: all 0.3s ease;
    text-transform: uppercase;
    font-size: 1rem;
    padding: 0.5rem 1rem;
}

.single-project-carousel .list .item .buttons .btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: #ffffff;
    color: #ffffff;
}

/*---------------------------------------------------------
 * Responsive adjustments for single project
/----------------------------------------------------------*/

/* @media screen and (max-height: 599px) {
    .single-project-carousel .list .item .project-details {
        bottom: calc(var(--land-thumb-bottom) + 60px);
        font-size: 0.8rem;
        padding: 0.75rem;
    }

    .single-project-carousel .list .item .detail-item .label {
        min-width: 100px;
        font-size: 0.8rem;
    }

    .single-project-carousel .list .item .des {
        bottom: calc(var(--land-thumb-bottom) + 120px);
        font-size: 0.9rem;
        padding: 0.75rem;
    }
} */

/*---------------------------------------------------------
 * Responsive Design for Split Layout - Updated for Grid
/----------------------------------------------------------*/

/* ß */

/*---------------------------------------------------------
 * Clean up old mobile viewport overrides - not needed in split layout
/----------------------------------------------------------*/

@media screen and (max-width: 1100px) {
    :root {
        --land-thumb-item-width: 100px;
        --land-thumb-item-height: 147px;
    }

    .single-project .site-container {
        position: relative;
    }

    .single-project .site-container.single-project-background::before,
    .single-project .site-container.single-project-background::after {
        background-image: none; /* Remove background images for mobile */
        height: 0; /* Prevent background from taking up space */
    }

    .single-project .site-inner {
        /* position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%; */
        margin-block-start: calc((var(--admin-bar-height, 0) + 2rem + 150px) * -1);
        margin-block-end: 0;

        position: relative;
        z-index: 2;
    }

    .single-project .site-inner > .wrap {
        width: 100%;
        max-width: 100%;
    }

    .single-project .project-split-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        align-items: flex-start;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .single-project .project-info-panel {
        grid-column: 1;
        grid-row: 2;
        padding-inline-end: 3rem; /* Adjust padding for mobile */
        padding-block-start: 8rem;
        /* padding-block-end: 400px; */
    }

    .single-project .project-info-panel .project-info-content {
        max-width: 100%;
    }

    .single-project .project-carousel-panel {
        grid-column: 1;
        grid-row: 1;
        height: auto;
        margin-left: 0;
        transform: none;
        position: relative;
    }

    .single-project .project-carousel-panel .carousel {
        min-height: auto;
        max-height: none;
    }

    .single-project .project-carousel-panel .single-project-carousel {
        width: 100%;
        aspect-ratio: 1.467857; /* Or whatever works best */
        height: auto;
        display: block;
    }

    .single-project .project-carousel-panel .single-project-carousel .list {
        overflow: hidden;
    }

    .single-project .project-carousel-panel .single-project-carousel .list .item {
        /* position: absolute;
        inset: 0; */
        width: 100%;
        height: 100%;
        display: block;
    }

    .single-project .project-carousel-panel .single-project-carousel .list .item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

    .single-project-carousel .list .item:not(:first-child) {
        display: none;
    }

    .single-project-carousel .thumbnail {
        bottom: -5rem;
        left: 12rem;
    }
}

/* Mobile adjustments for split layout */
@media (orientation: portrait) and (max-width: 768px) and (max-aspect-ratio: 0.615) {
    :root {
        --land-thumb-item-width: 50px;
        --land-thumb-item-height: 74px;
    }

    .single-project .project-carousel-panel .single-project-carousel {
        /* Fallback for iOS 15-16 */
        padding-bottom: 146.78%; /* 1.467857 * 100 */

        /* Modern browsers */
        aspect-ratio: 0.681818;
    }
    @supports (aspect-ratio: 1) {
        .single-project .project-carousel-panel .single-project-carousel {
            padding-bottom: 0;
        }
    }

    .single-project .thumbnail {
        left: calc(96px + 3rem);
        bottom: -3rem;
    }

    .single-project .thumbnail .item {
        width: var(--land-thumb-item-width, 150px);
        height: var(--land-thumb-item-height, 220px);
    }

    .single-project-carousel .arrows {
        bottom: calc(-48px + 1rem);
        left: 1rem;
    }

    .project-background {
        /* Ensure background covers mobile properly */
        /* transform: scale(1.2); */
    }

    .single-project-carousel {
        /* Override mobile carousel height constraints */
        /* height: 50vh; */ /* Adjusted for mobile split layout */
    }
}

/* Smooth transitions */
.project-info-panel {
    transition: all 0.3s ease;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .project-info-panel {
        background: rgba(255, 255, 255, 0.98);
    }

    .project-title {
        color: #000;
    }

    .detail-label {
        color: #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .project-info-panel {
        transition: none;
    }

    .project-background {
        filter: blur(5px); /* Less aggressive blur */
    }
}

/* Print styles */
@media print {
    .single-project-section {
        display: block;
        height: auto;
        overflow: visible;
    }

    .project-background {
        display: none;
    }

    .project-split-container {
        flex-direction: column;
    }

    .project-info-panel,
    .project-carousel-panel {
        width: 100%;
        background: #fff;
    }

    .single-project-carousel .thumbnail,
    .single-project-carousel .arrows {
        display: none;
    }
}

/*---------------------------------------------------------
 * Animation timing adjustments for single project
/----------------------------------------------------------*/

/* Adjust content animation delays to accommodate project details */
.single-project-carousel .list .item:nth-child(1) .content .title {
    animation-delay: 1.2s !important;
}

.single-project-carousel .list .item:nth-child(1) .content .des {
    animation-delay: 1.6s !important;
}

.single-project-carousel .list .item:nth-child(1) .content .project-details {
    animation-delay: 2s !important;
}

.single-project-carousel .list .item:nth-child(1) .content .buttons {
    animation-delay: 2.2s !important;
}

/*---------------------------------------------------------
 * Single project thumbnails
/----------------------------------------------------------*/

.single-project-carousel .thumbnail {
    /* Inherits all styles from carousel.css */
    /* Could add project-specific thumbnail styling here if needed */
}

/*---------------------------------------------------------
 * Print styles for single projects
/----------------------------------------------------------*/

@media print {
    .single-project-carousel-section {
        height: auto;
        overflow: visible;
    }

    .single-project-carousel .list .item {
        position: relative;
        height: auto;
        page-break-inside: avoid;
        margin-bottom: 2rem;
    }

    .single-project-carousel .list .item img {
        max-width: 100%;
        height: auto;
    }

    .single-project-carousel .list .item .content {
        position: relative;
        background: #fff;
        color: #000;
        padding: 1rem;
        margin-top: 1rem;
    }

    .single-project-carousel .thumbnail,
    .single-project-carousel .arrows,
    .single-project-carousel .time {
        display: none;
    }
}

/*---------------------------------------------------------
 * Accessibility improvements for single projects
/----------------------------------------------------------*/

.single-project-carousel .list .item .project-details,
.single-project-carousel .list .item .des {
    /* Ensure good contrast */
    background: rgba(0, 0, 0, 0.8);
}

/* Focus states for keyboard navigation */
.single-project-carousel .list .item .buttons .btn-secondary:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .single-project-carousel .list .item .project-details,
    .single-project-carousel .list .item .des {
        background: rgba(0, 0, 0, 0.95);
        border: 1px solid #ffffff;
    }

    .single-project-carousel .list .item .detail-item .label {
        color: #ffffff;
        font-weight: 700;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .single-project-carousel .list .item .project-details,
    .single-project-carousel .list .item .des {
        animation: none;
        opacity: 0.9;
        transform: none;
    }
}

/*---------------------------------------------------------
 * Full Screen Image Modal - ADDED TO YOUR CSS
/----------------------------------------------------------*/

/* Modal overlay */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    /* background: var(--color-primary-dark); */
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.image-modal::before {
    position: absolute;
    content: '';
    inset: 0;
    background-image: url('/wp-content/themes/pdxwoodworking/images/walnut.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: brightness(0.4);
}

.image-modal.active {
    opacity: 1;
    visibility: visible;
}

/* Modal content container */
.modal-content {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
}

/* Modal image */
.modal-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* Close button */
.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: background 0.3s ease;
    z-index: 10001;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Navigation buttons */
.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: background 0.3s ease, opacity 0.3s ease;
    z-index: 10001;
}

.modal-nav:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-nav.prev {
    left: 30px;
}

.modal-nav.next {
    right: 30px;
}

/* Hide nav buttons when there's only one image */
.modal-nav.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Loading state */
.modal-image.loading {
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

/* Add cursor pointer and hover effect to current carousel image */
.single-project-carousel .list .item:first-child img {
    cursor: pointer;
}

.single-project-carousel .list .item:first-child img:hover {
    filter: brightness(1.1);
    transition: filter 0.3s ease;
}

/* Mobile adjustments for modal */
@media (max-width: 768px) {
    .modal-close {
        top: 10px;
        right: 10px;
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .modal-nav {
        width: 50px;
        height: 50px;
        font-size: 18px;
    }

    .modal-nav.prev {
        left: 15px;
    }

    .modal-nav.next {
        right: 15px;
    }

    .modal-content {
        max-width: 98vw;
        max-height: 98vh;
    }
}

/*---------------------------------------------------------
 * Mobile Carousel List Background Transitions
/----------------------------------------------------------*/

/* When mobile background is active, use pseudo-element for blurred background */
.single-project-carousel .list.mobile-background-active {
    position: relative;
    /* No overflow hidden - let animations work properly */
}

/* Create blurred background using ::before pseudo-element */
.single-project-carousel .list.mobile-background-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: var(--mobile-bg-image);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(20px) brightness(0.8);
    transform: scale(1.1);
    z-index: 0;
    transition: background-image 0.5s ease-in-out;
}

/* Ensure carousel items are above the blurred background */
.single-project-carousel .list.mobile-background-active .item {
    position: relative;
    z-index: 1;
}

/* Reset the original background when mobile background is active */
.single-project-carousel .list.mobile-background-active {
    background-image: none !important;
}
/* .single-project-carousel .list .item.prev-item {
    background: red !important;
    border: 10px solid yellow !important;
    opacity: 0;
    animation: prevItemFadeIn 1s ease-out forwards !important;
}

@keyframes prevItemFadeIn {
    0% {
        opacity: 0;
        background: blue !important;
    }
    100% {
        opacity: 0.5;
        background: green !important;
    }
} */

/*---------------------------------------------------------
* iOS Safari specific fixes for thumbnail visibility 
/----------------------------------------------------------*/

/* Allow thumbnails to overflow the carousel container on iOS */
@supports (-webkit-touch-callout: none) {
    /* This targets WebKit browsers (Safari) */
    .carousel {
        overflow: visible !important;
    }

    /* Ensure the carousel list maintains its clipping for images */
    .carousel .list {
        overflow: hidden;
        position: relative;
        z-index: 1;
    }

    /* Ensure thumbnails have higher z-index to appear above */
    .carousel .thumbnail {
        z-index: 102 !important;
        position: absolute;
    }

    /* Ensure arrows stay above everything */
    .carousel .arrows {
        z-index: 103 !important;
        right: 11rem;
        bottom: -4rem;
    }
}

/* Alternative approach: iOS-specific media query */
@media screen and (-webkit-min-device-pixel-ratio: 2) {
    /* This targets high-DPI devices (most iOS devices) */
    .ios-browser .carousel,
    .carousel {
        overflow: visible;
    }

    .ios-browser .carousel .list,
    .carousel .list {
        overflow: hidden;
        border-radius: 0; /* Remove any border-radius that might clip */
    }
}

/* More specific iOS detection */
@supports ((-webkit-appearance: none) and (not (overflow: -webkit-marquee))) and (not ((-webkit-transform-style: preserve-3d) and (not (-webkit-transform-style: preserve-3d)))) {
    .carousel {
        overflow-y: visible;
        overflow-x: visible;
    }

    .carousel .list {
        overflow: hidden;
    }
}

/* Ensure mobile portrait maintains proper layout */
@media (orientation: portrait) and (max-width: 768px) {
    .carousel {
        overflow: visible !important;
    }

    /* Keep the main image area clipped */
    .carousel .list {
        overflow: hidden;
        position: relative;
    }

    /* Ensure thumbnails can extend beyond carousel bounds */
    .carousel .thumbnail {
        position: absolute;
        z-index: 102;
        /* Add a subtle drop shadow to help thumbnails stand out */
        filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    }

    /* For single project pages */
    .single-project-carousel {
        overflow: visible !important;
    }

    .single-project-carousel .list {
        overflow: hidden;
    }
}
