/*
 * BH Project Carousel — v1.1.0
 * Avada-hardened: overrides flatten-3d, typography bleed, and border resets.
 * All selectors prefixed .bh- to avoid theme conflicts.
 */

/* ============================================================
   CSS custom properties (declared on the wrap so they cascade
   into all children, including the keyframe calc)
   ============================================================ */
.bh-carousel-wrap {
    --card-w: 320px;
    --card-h: 200px;
    --card-r: 12px;
    --gap:    18px;
    --vis-h:  740px;

    display:         flex !important;
    justify-content: center;
    align-items:     center;
    width:           100%;
    overflow:        visible !important;
    padding:         60px 0;
    box-sizing:      border-box;
    /* Reset any Avada margin/max-width overrides */
    max-width:       none !important;
    margin-left:     auto;
    margin-right:    auto;
    position:        relative;
    right:           -20%;  /* Avada's .fusion-column-wrapper adds 20% right padding to the first column */
}

/* ============================================================
   3-D tilt wrapper — rotates the whole assembly 14 deg CW
   The !important beats Avada's .fusion-column-wrapper resets
   ============================================================ */
.bh-carousel-tilt {
    transform:        rotate(14deg) !important;
    transform-origin: center center;
    /* Avada flattens 3-D contexts; re-open it here */
    transform-style:  preserve-3d !important;
    display:          block;
}

/* ============================================================
   Perspective shell — parent of the clipping container
   ============================================================ */
.bh-carousel-outer {
    perspective:        1800px !important;
    perspective-origin: center center;
    transform-style:    preserve-3d !important;
    display:            flex !important;
    align-items:        center;
    justify-content:    center;
}

/* ============================================================
   Clipping + mask container
   NOTE: overflow:hidden forces transform-style:flat on THIS
   element, but the perspective is set on its parent so the
   3-D effect is preserved at the right level.
   ============================================================ */
.bh-hero-carousel {
    /* clip-path replaces overflow:hidden — creates an angled parallelogram
       whose top and bottom edges follow the visual angle of the card stack
       (wrapper rotates 14 deg; clip angle ~15% offset matches that tilt).
       clip-path still forces transform-style:flat, so 3-D perspective on
       the parent is unaffected. */
    overflow:   visible !important;
    clip-path:  polygon(-73px 11.02%, 100% 0%, 100% 87%, -135px 104.32%);
    height:     var(--vis-h);
    width:      calc(var(--card-w) + 60px);
    position:   relative;
    flex-shrink: 0;
    /* Gradient runs at ~170 deg (slightly off-vertical) so the fade axis
       aligns with the angled clip edges rather than a flat horizontal. */
    /* Gradient axis at 172° = perpendicular to the 13%/87% clip edges;
       stops land exactly on those thresholds so the fade follows the line. */
    -webkit-mask-image: linear-gradient(
        172deg,
        transparent      0%,
        rgba(0,0,0,.55)  9%,
        black            13%,
        black            87%,
        rgba(0,0,0,.55)  91%,
        transparent      100%
    );
    mask-image: linear-gradient(
        172deg,
        transparent      0%,
        rgba(0,0,0,.55)  9%,
        black            13%,
        black            87%,
        rgba(0,0,0,.55)  91%,
        transparent      100%
    );
}

.bh-hero-carousel:has(.bh-card.bh-interactive:hover) {
    -webkit-mask-image: none;
    mask-image:         none;
}

/* ============================================================
   Scroll track — the 3-D isometric transform lives here
   ============================================================ */
.bh-scroll-track {
    display:        flex !important;
    flex-direction: column;
    gap:            var(--gap);
    will-change:    transform;
    transform:      rotateX(-18deg) rotateY(28deg); /* no !important — animation must override this */
    transform-style: preserve-3d !important;
    animation:      bh-scroll-up
                    calc(var(--bh-count, 5) * var(--bh-speed, 3s))
                    linear
                    infinite;
    /* Reset any Avada flex overrides */
    flex-wrap:      nowrap;
    align-items:    flex-start;
}

.bh-hero-carousel:has(.bh-card.bh-interactive:hover) .bh-scroll-track {
    animation-play-state: paused;
}

@keyframes bh-scroll-up {
    from {
        transform: rotateX(-18deg) rotateY(28deg) translateY(0);
    }
    to {
        transform: rotateX(-18deg) rotateY(28deg)
                   translateY(calc(-1 * var(--bh-count) * (var(--card-h) + var(--gap))));
    }
}

/* ============================================================
   Card shell
   ============================================================ */
.bh-card {
    width:        var(--card-w) !important;
    height:       var(--card-h) !important;
    border-radius: var(--card-r) !important;
    overflow:     visible !important;      /* must be visible for 3-D edges */
    background:   #1a1a2e !important;
    position:     relative !important;
    cursor:       default;
    flex-shrink:  0 !important;
    /* Reset Avada border/outline/padding that leaks into divs */
    border:       none !important;
    outline:      none;
    padding:      0 !important;
    margin:       0 !important;
    list-style:   none;
    /* 3-D depth: preserve-3d lets edge children fold correctly */
    transform-style: preserve-3d !important;
    filter:       drop-shadow(24px 28px 36px rgba(0,0,0,.65));
    transition:   transform .4s ease, filter .4s ease;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.bh-card.bh-interactive { cursor: pointer; }

.bh-card.bh-interactive:hover,
.bh-card.bh-interactive:focus-visible {
    /* Scale up and add orange glow — counter-rotation not used because
       the 3-D rotation lives on the parent track, not the card itself. */
    transform: scale(1.08) !important;
    filter: drop-shadow(0 24px 48px rgba(0,0,0,.85))
            drop-shadow(0 0 36px rgba(249,115,22,.45)) !important;
    outline: none;
    z-index: 10;
    position: relative;
}

/* ============================================================
   Card image layer
   ============================================================ */
.bh-card-img {
    position:          absolute !important;
    inset:             0;
    background-size:   cover;
    background-position: center;
    background-color:  #0d0d1a;
    border-radius:     var(--card-r) !important;   /* clip to card shape */
    border:            1px solid rgba(255,255,255,.10) !important;
    margin:            0 !important;
    padding:           0 !important;
    overflow:          hidden;
    transform:         translateZ(0);  /* own compositing layer */
}

.bh-card-img--empty {
    background-image: linear-gradient(
        135deg,
        #1a1a2e 0%,
        #16213e 50%,
        #0f3460 100%
    ) !important;
}

/* Dark gradient overlay — text legibility */
.bh-card-img::after {
    content:  '' !important;
    position: absolute;
    inset:    0;
    background: linear-gradient(
        to top,
        rgba(0,0,0,.80)  0%,
        rgba(0,0,0,.08) 55%,
        transparent     100%
    );
    pointer-events: none;
}


/* ============================================================
   3-D card edges — fold as bottom/right face in preserve-3d space
   ============================================================ */
.bh-card-edge-bottom {
    width:          100%;
    height:         8px;
    background:     linear-gradient(to bottom, #1a2535, #0e1520);
    border-left:    1px solid rgba(255,255,255,.07);
    border-right:   1px solid rgba(0,0,0,.4);
    border-bottom:  1px solid rgba(0,0,0,.4);
    border-radius:  0 0 6px 6px;
    transform-origin: top;
    transform:      rotateX(-90deg) translateZ(0);
    flex-shrink:    0;
    pointer-events: none;   /* purely decorative — never intercept clicks */
}

.bh-card-edge-side {
    position:       absolute !important;
    top:            0;
    right:          -8px;
    width:          8px;
    height:         calc(100% - 8px);
    background:     linear-gradient(to right, #0a1220, #060c18);
    border-radius:  0 10px 6px 0;
    transform-origin: left;
    transform:      rotateY(90deg);
    border:         1px solid rgba(0,0,0,.3) !important;
    border-left:    none !important;
    pointer-events: none;   /* purely decorative — never intercept clicks */
}

/* ============================================================
   Card footer text — reset Avada typography
   ============================================================ */
.bh-card-body {
    position:   absolute !important;
    bottom:     0;
    left:       0;
    right:      0;
    padding:    10px 14px 12px !important;
    z-index:    2;
    /* Stop Avada flex rules from collapsing this */
    display:    block !important;
}

.bh-card-tag {
    display:        inline-block !important;
    font-size:      10px !important;
    font-weight:    600 !important;
    text-transform: uppercase !important;
    letter-spacing: .08em !important;
    color:          rgba(255,255,255,.60) !important;
    margin:         0 0 3px !important;
    padding:        0 !important;
    line-height:    1.4 !important;
    background:     none !important;
    border:         none !important;
    /* Reset Avada heading/span styles */
    text-shadow:    none;
}

.bh-card-title {
    font-size:      14px !important;
    font-weight:    600 !important;
    color:          #ffffff !important;
    line-height:    1.35 !important;
    text-shadow:    0 1px 4px rgba(0,0,0,.55) !important;
    white-space:    nowrap;
    overflow:       hidden;
    text-overflow:  ellipsis;
    text-align:     right;
    margin:         0 !important;
    padding:        0 !important;
    /* Reset Avada heading resets */
    text-transform: none;
    letter-spacing: normal;
    background:     none !important;
    border:         none !important;
}

/* ============================================================
   Modal — matches portfolio.html layout exactly
   image left (54%) | content right (46%)
   ============================================================ */

.bh-modal {
    position:        fixed !important;
    inset:           0;
    top:             0 !important;
    left:            0 !important;
    right:           0 !important;
    bottom:          0 !important;
    z-index:         100000 !important;
    display:         flex;
    align-items:     center;
    justify-content: center;
    padding:         1.5rem;
    box-sizing:      border-box;
    font-family:     Inter, system-ui, sans-serif !important;
}

.bh-modal[hidden] { display: none !important; }

.bh-modal-backdrop {
    position:   absolute !important;
    inset:      0;
    background: rgba(0,0,0,.80) !important;
}

/* Panel — side-by-side flex, matches portfolio */
.bh-modal-panel {
    position:      relative !important;
    z-index:       1;
    display:       flex !important;
    flex-direction: row !important;
    width:         min(900px, 96vw) !important;
    max-height:    92vh;
    overflow:      hidden !important;
    background:    linear-gradient(150deg, #141f30, #0a1220) !important;
    border:        1px solid rgba(255,255,255,.12) !important;
    border-radius: 8px !important;
    box-shadow:    0 40px 90px rgba(0,0,0,.85) !important;
    animation:     bh-modal-appear .24s cubic-bezier(.22,.61,.36,1) both;
    /* Reset Avada */
    padding:       0 !important;
    margin:        0 auto !important;
}

@keyframes bh-modal-appear {
    from { opacity: 0; transform: scale(.96) translateY(10px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* Close button */
.bh-modal-close {
    position:        absolute !important;
    top:             .8rem !important;
    right:           .8rem !important;
    width:           30px !important;
    height:          30px !important;
    min-width:       0 !important;
    min-height:      0 !important;
    background:      rgba(0,0,0,.35) !important;
    border:          1px solid rgba(255,255,255,.12) !important;
    border-radius:   50% !important;
    color:           rgba(255,255,255,.75) !important;
    font-size:       1rem !important;
    line-height:     1 !important;
    cursor:          pointer;
    display:         flex !important;
    align-items:     center;
    justify-content: center;
    z-index:         3;
    padding:         0 !important;
    box-shadow:      none !important;
    text-shadow:     none !important;
    transition:      background .15s;
}
.bh-modal-close:hover { background: rgba(255,255,255,.18) !important; }

/* Image column — 54% width, left side */
.bh-modal-img-col {
    flex:          0 0 54% !important;
    position:      relative !important;
    overflow:      hidden !important;
    aspect-ratio:  800 / 420;
    background:    #0a1220;
    /* Reset Avada */
    padding:       0 !important;
    margin:        0 !important;
    border:        none !important;
}

.bh-modal-img-col img {
    width:         100% !important;
    height:        100% !important;
    object-fit:    cover !important;
    object-position: top left !important;
    display:       block !important;
    border:        none !important;
    margin:        0 !important;
    padding:       0 !important;
    max-width:     none !important;
    border-radius: 0 !important;
}

/* Right-edge fade blends image into panel background */
.bh-modal-img-fade {
    position:   absolute !important;
    inset:      0;
    background: linear-gradient(to right, transparent 70%, #0a1220) !important;
    pointer-events: none;
}

/* Content column — right side */
.bh-modal-content {
    flex:           1 !important;
    padding:        2rem 2rem 2rem 1.5rem !important;
    display:        flex !important;
    flex-direction: column;
    justify-content: center;
    overflow-y:     auto;
}

/* Tag chip — orange with border, matches portfolio */
.bh-modal-tag {
    display:        inline-block !important;
    font-size:      .68rem !important;
    font-weight:    700 !important;
    letter-spacing: .14em !important;
    text-transform: uppercase !important;
    color:          #f97316 !important;
    border:         1px solid rgba(249,115,22,.35) !important;
    border-radius:  4px !important;
    padding:        .2em .65em !important;
    margin:         0 0 .8rem !important;
    width:          fit-content !important;
    background:     none !important;
    line-height:    1.4 !important;
    text-shadow:    none !important;
}

/* Modal title */
.bh-modal-content h2 {
    font-size:      1.5rem !important;
    font-weight:    700 !important;
    color:          #fff !important;
    margin:         0 0 .75rem !important;
    line-height:    1.2 !important;
    padding:        0 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    border:         none !important;
    background:     none !important;
}

/* Description */
#bh-modal-desc {
    font-size:   .88rem !important;
    line-height: 1.65 !important;
    color:       rgba(255,255,255,.60) !important;
    margin:      0 0 1.5rem !important;
    padding:     0 !important;
    flex:        1;
}

/* CTA button — orange, matches portfolio */
.bh-modal-cta {
    display:         inline-flex !important;
    align-items:     center;
    gap:             .5rem;
    padding:         .6em 1.2em !important;
    background:      #f97316 !important;
    color:           #fff !important;
    border-radius:   8px !important;
    font-size:       .83rem !important;
    font-weight:     600 !important;
    text-decoration: none !important;
    border:          none !important;
    box-shadow:      none !important;
    transition:      opacity .15s;
    line-height:     1 !important;
    text-transform:  none !important;
    letter-spacing:  normal !important;
    width:           fit-content !important;
}
.bh-modal-cta:hover         { opacity: .85 !important; color: #fff !important; }
.bh-modal-cta[hidden]       { display: none !important; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 540px) {
    .bh-carousel-wrap {
        --card-w: 260px;
        --card-h: 162px;
        --vis-h:  602px;
        padding: 40px 0;
    }
}
