/* Home hero: fan-out 3D machine cards + background that follows the active card.
   Navbar and hero text are untouched. Loaded after hero-photo.css. */

#home .hero-deck {
    --cw: clamp(88px, 8.5vw, 140px);
    --ch: calc(var(--cw) * 1.42);
    --gap: clamp(8px, 1vw, 16px);
    --dir: 1;
    position: absolute;
    z-index: 4;
    inset-inline-start: 50%;
    inset-inline-end: 0;
    bottom: 2.4rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
html[dir="rtl"] #home .hero-deck, html[lang="ar"] #home .hero-deck { --dir: -1; }

/* ---- cards ---- */
#home .deck-stage {
    position: relative;
    height: calc(var(--ch) + 1.6rem);
    padding-block: .8rem;
    overflow: hidden;
    perspective: 1100px;
    perspective-origin: 30% 50%;
    touch-action: pan-y;
}
#home .deck-card {
    position: absolute;
    inset-inline-start: 1.5rem;
    top: .8rem;
    width: var(--cw);
    height: var(--ch);
    border-radius: 16px;
    overflow: hidden;
    color: #fff;
    text-decoration: none;
    background: #15181c;
    box-shadow: 0 14px 30px rgba(0, 0, 0, .45);
    transform-style: preserve-3d;
    backface-visibility: hidden;
    transform-origin: 50% 50%;
    /* closed (stacked, turned away) */
    opacity: 0;
    transform: translateX(0) rotateY(calc(var(--dir) * -78deg)) scale(.86);
    transition: transform .85s cubic-bezier(.22, 1, .36, 1), opacity .55s ease;
    transition-delay: calc(var(--o, 1) * 65ms);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
#home .hero-deck.is-open .deck-card {
    opacity: 1;
    transform:
        translateX(calc(var(--dir) * var(--k, 0) * (var(--cw) + var(--gap))))
        translateZ(calc(34px - var(--o) * 5px))
        rotateY(calc(var(--dir) * -7deg));
}
#home .hero-deck.is-open .deck-card.is-next { transform: translateX(0) translateZ(44px) rotateY(0); }
#home .hero-deck.is-open .deck-card.is-current {
    opacity: 0;
    pointer-events: none;
    transform: translateX(calc(var(--dir) * -70px)) translateZ(0) rotateY(calc(var(--dir) * 50deg)) scale(.8);
}
#home .hero-deck.is-open .deck-card.is-far { opacity: 0; pointer-events: none; }
#home .deck-card.no-anim { transition: none !important; }
#home .deck-card:hover { box-shadow: 0 18px 38px rgba(0, 0, 0, .55); filter: brightness(1.08); }
#home .deck-card:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

#home .deck-card img {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    pointer-events: none;
}
#home .deck-card::after {
    content: "";
    position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0) 38%, rgba(0,0,0,.82) 100%);
}
#home .deck-card-info {
    position: absolute; z-index: 2;
    inset-inline: .8rem; bottom: .8rem;
    display: flex; flex-direction: column; gap: .18rem;
    text-align: start;
}
#home .deck-card-line { display: block; width: 16px; height: 1.5px; background: #fff; margin-bottom: .15rem; }
#home .deck-card-info small { font-size: .72rem; letter-spacing: .08em; opacity: .85; }
#home .deck-card-info strong {
    font-size: clamp(.78rem, .9vw, .95rem);
    line-height: 1.25;
    font-weight: 700;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
    text-shadow: 0 1px 4px rgba(0,0,0,.6);
}

/* ---- controls ---- */
#home .deck-controls {
    display: flex; align-items: center; gap: .55rem;
    padding-inline-end: clamp(1rem, 4vw, 4rem);
    color: var(--hero-ctrl-ink, #fff);
}
#home .deck-btn {
    width: 32px; height: 32px; border-radius: 50%;
    display: inline-grid; place-items: center;
    border: 1px solid var(--hero-ctrl-line, rgba(255,255,255,.25));
    background: var(--hero-ctrl-bg, rgba(12,14,17,.7));
    color: inherit; cursor: pointer; padding: 0;
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    transition: transform .2s ease, background .2s ease;
}
#home .deck-btn svg { width: 14px; height: 14px; }
#home .deck-open { text-decoration: none; }
#home .deck-btn:hover { transform: scale(1.08); background: var(--site-red, #e53935); border-color: transparent; color: #fff; }
html[dir="rtl"] #home .deck-btn svg, html[lang="ar"] #home .deck-btn svg { transform: scaleX(-1); }
#home .deck-progress {
    flex: 1; height: 2px; border-radius: 2px; overflow: hidden;
    background: var(--hero-bar, rgba(255,255,255,.25));
}
#home .deck-progress i {
    display: block; height: 100%; width: 8%;
    background: var(--hero-bar-fill, #fff);
    transition: width .7s cubic-bezier(.22, 1, .36, 1);
}
html[dir="rtl"] #home .deck-progress i, html[lang="ar"] #home .deck-progress i { margin-inline-start: 0; }
#home .deck-count { display: inline-flex; align-items: baseline; gap: .15rem; direction: ltr; min-width: 3.2rem; justify-content: flex-end; }
#home .deck-count b { font-size: clamp(1.1rem, 1.7vw, 1.45rem); line-height: 1; font-weight: 700; }
#home .deck-count em { font-style: normal; font-size: .68rem; opacity: .7; }

/* ---- background follows the active card ---- */
#home .hero-deck-bg {
    opacity: 0;
    transition: opacity 1s ease;
    object-fit: cover;
    object-position: center;
    width: 100%;
    height: 100%;
}
    #home .hero-deck-bg.is-on { opacity: var(--hero-photo-opacity, 1); }
#home.deck-on .hero-photo-en,
#home.deck-on .hero-photo-ar,
#home.deck-on .hero-photo-mob { opacity: 0 !important; transition: opacity 1s ease; }
html:not([data-theme="light"]) #home .hero-photo::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(90deg, rgba(0,0,0,.62) 0%, rgba(0,0,0,.22) 55%, rgba(0,0,0,0) 100%);
}
html[dir="rtl"]:not([data-theme="light"]) #home .hero-photo::after,
html[lang="ar"]:not([data-theme="light"]) #home .hero-photo::after {
    background: linear-gradient(270deg, rgba(0,0,0,.62) 0%, rgba(0,0,0,.22) 55%, rgba(0,0,0,0) 100%);
}

/* ---- desktop: keep the text clear of the cards ---- */
@media (min-width: 992px) {
    html body #home .hero-copy { max-width: min(47%, 640px) !important; }
}

/* ---- tablet / mobile: cards sit under the buttons ---- */
@media (max-width: 991px) {
    html body #home.w3l-banner {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto;
        height: auto !important;
        min-height: 100svh !important;
        padding-bottom: 0 !important;
    }
    html body #home .hero-photo { grid-area: 1 / 1 / -1 / -1; }
    html body #home .hero-stage { grid-area: 1 / 1; min-height: 0; }
    #home .hero-deck {
        --cw: clamp(72px, 20vw, 110px);
        --gap: 8px;
        position: relative; grid-area: 2 / 1;
        inset: auto; bottom: auto;
        margin-top: 1rem;
        padding-inline-start: 0;
        gap: .45rem;
    }
    #home .deck-stage { height: calc(var(--ch) + 1rem); padding-block: .5rem; }
    #home .deck-card { top: .5rem; inset-inline-start: 1.4rem; }
    #home .deck-stage { perspective-origin: 20% 50%; }
    #home .deck-controls { padding-inline: 1.4rem; }
    #home .deck-btn { width: 28px; height: 28px; }
    #home .deck-btn svg { width: 12px; height: 12px; }
    #home .deck-count { min-width: 2.8rem; }
    #home .deck-count b { font-size: 1.05rem; }
    #home .deck-count em { font-size: .62rem; }
    #home .deck-progress { height: 1.5px; }
}

/* ---- mobile preview only: full-strength photos filling the whole hero ---- */
@media (max-width: 767px) {
#home .hero-deck-bg.is-on { opacity: var(--hero-photo-opacity, 1); }
    html:not([data-theme="light"]) #home .hero-photo::after,
    html[dir="rtl"]:not([data-theme="light"]) #home .hero-photo::after,
    html[lang="ar"]:not([data-theme="light"]) #home .hero-photo::after {
        background: linear-gradient(180deg, rgba(0,0,0,.5) 0%, rgba(0,0,0,.18) 45%, rgba(0,0,0,.55) 100%);
    }
}

/* ---- mobile / tablet: no gap between the hero and the trusted brands strip ---- */
@media (max-width: 991px) {
    html body #home + .trusted-brands,
    .js-landing #home + .trusted-brands.reveal-section,
    .js-landing #home + .trusted-brands.reveal-section.is-visible {
        transform: none !important;
        opacity: 1 !important;
        transition: none !important;
        margin-top: 0 !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    #home .deck-card { transition-duration: .01s; transition-delay: 0s !important; }
    #home .hero-deck-bg { transition-duration: .01s; }
}
