/* ============================================
   FILM PORTFOLIO CAROUSEL - GSAP Infinite
   Dynamic CSS - Inherits from theme (Ollie compatible)
   ============================================ */

/* Wrapper fullscreen - inherits background from Gutenberg block */
.fpc-carousel-wrapper {
    position: relative;
    width: 100vw;
    height: var(--fpc-height, 100vh);
    overflow: hidden;
    /* Full-bleed via negative margin — no transform to avoid GSAP conflicts */
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    /* Inherit typography from theme */
    font-family: inherit;
}



.fpc-carousel-wrapper.is-dragging {
    cursor: grabbing !important;
}

/* Empêcher la sélection bleue au drag */
.fpc-carousel-wrapper {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Assurer que les images ne bloquent pas le drag mais restent cliquables */
.fpc-poster-image img {
    pointer-events: none;
    /* Evite le drag natif de l'image */
}

/* Track - layout is handled purely via absolute positioning by GSAP */
.fpc-carousel-track {
    width: 100%;
    height: 100%;
    will-change: transform;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Poster item */
.fpc-poster-item {
    position: absolute;
    /* GSAP handles all positioning via transforms */
    top: 50%;
    left: 50%;
    /* No CSS transform — GSAP controls xPercent, yPercent, scale */
    height: 70%;
    aspect-ratio: 2 / 3;
    border-radius: var(--fpc-poster-radius, 0);
    overflow: hidden;
    cursor: grab;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    /* GPU acceleration for buttery-smooth mobile animations */
    will-change: transform, opacity;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* z-index is controlled by GSAP animation — no CSS hover override */

/* Link wrapper */
.fpc-poster-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

/* Image container */
.fpc-poster-image {
    position: absolute;
    inset: 0;
    background: #1a1a1a;
}

.fpc-poster-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* Overlay sombre pour les affiches non centrales */
.fpc-dark-overlay {
    position: absolute;
    inset: 0;
    background: #000;
    opacity: 0;
    /* Géré par GSAP */
    pointer-events: none;
    z-index: 1;
    /* Sous l'overlay avec infos, mais sur l'image */
}

/* Overlay avec infos - uniquement en bas de l'image */
.fpc-poster-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top,
            rgba(0, 0, 0, 0.85) 0%,
            rgba(0, 0, 0, 0.5) 60%,
            transparent 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 25px;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 2;
}

@media (hover: hover) and (pointer: fine) {

    .fpc-poster-item:hover .fpc-poster-overlay,
    .fpc-poster-overlay.fpc-overlay-always {
        opacity: 1;
    }

    /* In landing mode, completely hide the per-poster info overlay on hover */
    .fpc-mode-landing .fpc-poster-item:hover .fpc-poster-overlay {
        opacity: 0 !important;
    }
}

/* Landing Page Veil — covers only the poster track */
.fpc-landing-veil {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

/* Pseudo-element carries the background so opacity doesn't affect the CTA button */
.fpc-landing-veil::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--fpc-veil-color, #000000);
    opacity: var(--fpc-veil-opacity, 0.7);
    z-index: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

/* Children render above the pseudo-element background */
.fpc-landing-veil > * {
    position: relative;
    z-index: 1;
}

@media (hover: hover) and (pointer: fine) {
    .fpc-carousel-wrapper:hover .fpc-landing-veil {
        opacity: 1;
        pointer-events: auto;
    }
}

/* On touch devices, the veil is always visible but allows touch drag through it */
@media (hover: none) and (pointer: coarse) {
    .fpc-carousel-wrapper.fpc-mode-landing .fpc-landing-veil {
        opacity: 1;
        pointer-events: none;
        /* Let touches pass through to the carousel */
    }

    /* Lighter background on touch: override the pseudo-element opacity */
    .fpc-carousel-wrapper.fpc-mode-landing .fpc-landing-veil::before {
        opacity: calc(var(--fpc-veil-opacity, 0.7) * 0.57);
        /* ~40% of desktop opacity for a lighter mobile veil */
    }

    .fpc-carousel-wrapper.fpc-mode-landing .fpc-landing-veil .wp-block-button {
        pointer-events: auto;
        /* Only the CTA is clickable */
    }

    /* Note: info hiding is now global for mobile below in max-width 768px */
}

.fpc-landing-cta {
    display: inline-block !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    max-height: none !important;
    flex: none !important;
    align-self: center !important;
    border-radius: var(--fpc-cta-radius, 0) !important;
    font-size: 1.1rem !important;
    padding: 18px 50px !important;
    margin: 0 !important;
    letter-spacing: 0.1em;
    font-weight: 600;
    text-decoration: none !important;
    cursor: pointer;
    box-sizing: border-box !important;
    line-height: 1.2 !important;
    position: relative !important;
    z-index: 10 !important;
    color: var(--fpc-cta-color, #000000) !important;
    font-family: var(--fpc-cta-font-family, inherit) !important;
    text-transform: var(--fpc-cta-text-transform, none) !important;
}

.fpc-landing-veil .fpc-landing-cta,
.fpc-carousel-wrapper .fpc-landing-cta,
.fpc-landing-cta * {
    color: var(--fpc-cta-color, #000000) !important;
}

.fpc-landing-cta * {
    font-family: var(--fpc-cta-font-family, inherit) !important;
    text-transform: var(--fpc-cta-text-transform, none) !important;
}

/* Theme style CTA adjustments */
.fpc-landing-veil .wp-block-button.is-style-fill {
    margin: 0 !important;
}

.fpc-landing-veil .wp-block-button__link.fpc-cta-theme-style {
    text-decoration: none !important;
    white-space: nowrap;
}

.fpc-landing-veil .wp-block-button__link,
.fpc-landing-veil .wp-block-button__link * {
    font-family: var(--fpc-cta-font-family, inherit) !important;
    text-transform: var(--fpc-cta-text-transform, none) !important;
}

/* Titre - inherits theme typography */
.fpc-poster-title {
    margin: 0 0 8px 0;
    font-size: clamp(1rem, 2vw, 1.4rem);
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    /* Inherit heading font from theme (Ollie uses --wp--preset--font-family--heading) */
    font-family: var(--wp--preset--font-family--heading, inherit);
}

/* Description courte (optionnelle) */
.fpc-poster-desc {
    margin: 0 0 12px 0;
    font-size: 0.9rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.9);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    /* Limite à 3 lignes */
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-family: var(--wp--preset--font-family--body, inherit);
}

/* Meta infos - inherits theme typography */
.fpc-poster-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    /* Inherit body font from theme */
    font-family: var(--wp--preset--font-family--body, inherit);
}

.fpc-year {
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    font-weight: 600;
}

.fpc-director {
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Tablet */
@media (max-width: 1024px) {
    /* No flex padding needed anymore */
}

/* Mobile */
@media (max-width: 768px) {
    .fpc-carousel-wrapper {
        height: var(--fpc-height, 80vh);
        /* Optimise touch handling */
        -webkit-overflow-scrolling: touch;
        /* Allow vertical scroll by default; JS locks to none during horizontal swipe */
        touch-action: pan-y;
    }

    /* Slightly smaller posters on mobile for better centering & breathing room */
    .fpc-poster-item {
        height: 60%;
    }

    /* Completely hide poster info overlays on mobile to keep a clean look */
    .fpc-poster-overlay {
        display: none !important;
    }

    /* Reduced box shadow on mobile for performance */
    .fpc-poster-item {
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    }

    .fpc-poster-title {
        font-size: 0.95rem;
    }

    .fpc-poster-meta {
        font-size: 0.75rem;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .fpc-carousel-wrapper {
        height: var(--fpc-height, 70vh);
    }

    .fpc-poster-item {
        height: 55%;
    }
}

/* ============================================
   LOADING STATE
   ============================================ */
.fpc-poster-image::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
            #1a1a1a 0%,
            #2a2a2a 50%,
            #1a1a1a 100%);
    background-size: 200% 100%;
    animation: fpc-shimmer 1.5s infinite;
    opacity: 1;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.fpc-poster-image img[src=""],
.fpc-poster-image img:not([src]) {
    opacity: 0;
}

/* Hide shimmer once a valid image is loaded */
.fpc-poster-image:has(img[src]:not([src=""]))::before {
    opacity: 0;
    pointer-events: none;
}

@keyframes fpc-shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* ============================================
   CLICK ACTIONS: EXPAND & OVERLAY
   ============================================ */

/* Inline Expand Container (below carousel, two columns) */
.fpc-inline-container {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    background: var(--fpc-expand-bg, #000);
    color: var(--fpc-expand-text, #fff);
    font-family: var(--wp--preset--font-family--base, inherit);
    overflow: hidden;
}

.fpc-inline-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 60px 50px;
    position: relative;
}

.fpc-inline-header {
    text-align: center;
    margin-bottom: 60px;
}

.fpc-inline-title {
    font-size: var(--fpc-inline-title-size, 2rem);
    font-weight: 600;
    margin: 0;
    color: inherit;
    font-family: var(--wp--preset--font-family--heading, inherit);
    letter-spacing: 0.05em;
    text-transform: var(--fpc-inline-title-transform, uppercase);
    /* Fixes JS HTML entity apostrophe issue */
}

.fpc-inline-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
}

.fpc-inline-label {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 25px;
    color: inherit;
}

.fpc-inline-col-left {
    font-size: var(--fpc-inline-left-size, 1.15rem);
    line-height: 1.6;
    color: inherit;
}

.fpc-inline-col-right {
    font-size: var(--fpc-inline-right-size, 1.15rem);
    line-height: 1.6;
    color: inherit;
}

.fpc-inline-col-left p,
.fpc-inline-col-right p {
    margin-bottom: 1.2em;
}

/* Remove default link styling for the action button to make it blend in if kept */
.fpc-inline-container .fpc-details-actions a {
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
    margin-top: 20px;
    display: inline-block;
}

.fpc-inline-container .fpc-btn-primary {
    background: transparent;
    padding: 0;
    border-radius: 0;
}

/* Format the raw technical details if they come as paragraphs/spans */
.fpc-details-technical-raw p {
    margin-bottom: 1.5em;
}

/* Mobile: stack columns */
@media (max-width: 768px) {
    .fpc-inline-wrapper {
        padding: 25px 20px;
    }

    .fpc-inline-header {
        flex-direction: column;
        gap: 5px;
    }

    .fpc-inline-columns {
        grid-template-columns: 1fr;
        gap: 25px;
    }
}

/* Netflix Expand Container (in-flow below carousel) */
.fpc-expand-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 75%;
    /* Takes bottom 75% of carousel height */
    background: #111;
    color: #fff;
    z-index: 10;
    box-shadow: 0 -20px 40px rgba(0, 0, 0, 0.8);
    display: flex;
}

/* Cinematic Overlay Modale (Fullscreen) */
.fpc-global-overlay-modal {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    /* Dark background */
    z-index: 999999;
    color: #fff;
    overflow-y: auto;
    font-family: inherit;
}

/* Common Layout for Details (Inside Expand or Overlay) */
.fpc-details-wrapper {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
    position: relative;
    max-width: 1400px;
    margin: 0 auto;
}

/* Cinematic Overlay Specific Layout */
.fpc-global-overlay-modal .fpc-details-wrapper {
    flex-direction: column;
}

.fpc-details-poster-area {
    width: 40%;
    height: 100%;
    position: relative;
    flex-shrink: 0;
}

.fpc-global-overlay-modal .fpc-details-poster-area {
    width: 100%;
    height: 50vh;
    /* Hero Banner style */
}

/* The actual poster image animating in via gsap.flip */
.fpc-flip-poster {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    box-shadow: 20px 0 40px rgba(0, 0, 0, 0.5);
}

.fpc-global-overlay-modal .fpc-flip-poster {
    object-position: 50% 20%;
    mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
    box-shadow: none;
}

.fpc-details-content-area {
    flex-grow: 1;
    padding: 40px 50px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.fpc-global-overlay-modal .fpc-details-content-area {
    padding: 0 50px 50px 50px;
    margin-top: -80px;
    /* Overlap the faded hero image */
    position: relative;
    z-index: 2;
}


/* Content Typography */
.fpc-details-title {
    font-size: clamp(2rem, 4vw, 3.5rem);
    font-weight: 800;
    margin: 0 0 10px 0;
    line-height: 1.1;
    font-family: var(--wp--preset--font-family--heading, inherit);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.fpc-details-meta {
    display: flex;
    gap: 15px;
    font-size: 1rem;
    color: #aaa;
    margin-bottom: 30px;
    font-weight: 500;
}

.fpc-details-meta span {
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 12px;
    border-radius: 4px;
}

.fpc-details-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 40px;
}

.fpc-details-synopsis {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #ddd;
}

.fpc-details-synopsis p {
    margin-bottom: 1em;
}

.fpc-details-technical {
    font-size: 0.95rem;
    color: #bbb;
    line-height: 1.5;
}

.fpc-details-technical p {
    margin-bottom: 0.8em;
}

/* Actions */
.fpc-details-actions {
    margin-top: 30px;
}

.fpc-btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    color: #000;
    padding: 12px 24px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
    transition: background 0.2s;
}

.fpc-btn-primary:hover {
    background: #ddd;
}

/* Close Button */
.fpc-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: all 0.2s;
}

.fpc-global-overlay-modal .fpc-close-btn {
    position: fixed;
    /* Stays in viewport for full modal */
    top: 30px;
    right: 30px;
    background: rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.3);
}

.fpc-close-btn:hover {
    background: #fff;
    color: #000;
    transform: scale(1.1);
}

/* Mobile Adjustments for Click Actions */
@media (max-width: 768px) {
    .fpc-expand-container {
        height: 75%;
    }

    .fpc-details-wrapper {
        flex-direction: column;
    }

    .fpc-details-poster-area {
        width: 100%;
        height: 30%;
    }

    .fpc-global-overlay-modal .fpc-details-poster-area {
        height: 40vh;
    }

    .fpc-details-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .fpc-details-content-area {
        padding: 20px;
    }

    .fpc-global-overlay-modal .fpc-details-content-area {
        padding: 0 20px 30px 20px;
        margin-top: -40px;
    }

    .fpc-details-title {
        font-size: 2rem;
    }
}