/*
 * Hudrat — motion layer.
 * Everything here only switches on when hudrat-motion.js has put `hd-motion` on <html>,
 * so without JS (or with "reduce motion" in the OS) the site looks exactly as before.
 */

/* ---------- gold scroll progress ---------- */
.hd-progress {
    position: fixed;
    inset: 0 0 auto 0;
    height: 2px;
    z-index: 1000;
    background: linear-gradient(90deg, var(--hd-gold-lite), var(--hd-gold), var(--hd-gold-2));
    transform: scaleX(0);
    transform-origin: 0 50%;
    pointer-events: none;
}
[dir="rtl"] .hd-progress { transform-origin: 100% 50%; }

/* ---------- header slides in ---------- */
.hd-motion .hd-header { animation: hdDrop .9s cubic-bezier(.16, 1, .3, 1) both; }
@keyframes hdDrop { from { opacity: 0; transform: translateY(-24px); } }

/* ---------- home: first screen ---------- */
.hd-motion .hd-hero-photo {
    transform-origin: 60% 40%;
    animation: hdKenBurns 2.2s cubic-bezier(.16, 1, .3, 1) both;
    will-change: transform, translate;
}
@keyframes hdKenBurns { from { transform: scale(1.12); } to { transform: scale(1.02); } }

.hd-motion .hd-hero-inner > * { opacity: 0; transform: translateY(28px); animation: hdUp 1s cubic-bezier(.16, 1, .3, 1) forwards; }
.hd-motion .hd-hero-inner > :nth-child(1) { animation-delay: .25s; }
.hd-motion .hd-hero-inner > :nth-child(2) { opacity: 1; transform: none; animation: none; } /* h1: animated word by word */
.hd-motion .hd-hero-inner > :nth-child(3) { animation-delay: .95s; }
.hd-motion .hd-hero-inner > :nth-child(4) { animation-delay: 1.1s; }
.hd-motion .hd-hero-inner > :nth-child(5) { animation-delay: 1.25s; }
@keyframes hdUp { to { opacity: 1; transform: none; } }

/* h1 words rise out of a mask */
.hd-w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .2em; margin-bottom: -.2em; }
/* the word starts well below its window (its top must not show in the room left for the tails of the letters) and fades in as it rises */
.hd-w > span { display: inline-block; transform: translateY(135%); opacity: 0; animation: hdWord 1s cubic-bezier(.16, 1, .3, 1) forwards; animation-delay: calc(.35s + var(--i) * 70ms); }
@keyframes hdWord { 0% { opacity: 0; } 35% { opacity: 1; } to { transform: none; opacity: 1; } }

/* the gold accent word gets an underline that draws itself */
.hd-motion .hd-hero h1 em { position: relative; }
.hd-motion .hd-hero h1 em::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    bottom: .04em;
    height: 2px;
    background: linear-gradient(90deg, var(--hd-gold-lite), var(--hd-gold));
    transform: scaleX(0);
    transform-origin: left;
    animation: hdLine 1s 1.3s cubic-bezier(.65, 0, .35, 1) forwards;
}
[dir="rtl"].hd-motion .hd-hero h1 em::after { transform-origin: right; }
@keyframes hdLine { to { transform: scaleX(1); } }

/* ---------- reveal on scroll ---------- */
.hd-motion [data-rv] {
    opacity: 0;
    transform: translateY(36px);
    transition: opacity 1s cubic-bezier(.16, 1, .3, 1), transform 1s cubic-bezier(.16, 1, .3, 1);
    transition-delay: var(--rd, 0ms);
}
.hd-motion [data-rv="fade"] { transform: none; }
.hd-motion [data-rv="left"] { transform: translateX(-40px); }
.hd-motion [data-rv="right"] { transform: translateX(40px); }
[dir="rtl"].hd-motion [data-rv="left"] { transform: translateX(40px); }
[dir="rtl"].hd-motion [data-rv="right"] { transform: translateX(-40px); }
.hd-motion [data-rv].is-in { opacity: 1; transform: none; }

/* photos fade in and settle from a slight zoom (opacity + transform only: stays on the GPU) */
.hd-motion [data-curtain] { opacity: 0; transition: opacity 1.2s cubic-bezier(.16, 1, .3, 1); transition-delay: var(--rd, 0ms); }
.hd-motion [data-curtain] img { transform: scale(1.12); transition: transform 2s cubic-bezier(.16, 1, .3, 1); transition-delay: var(--rd, 0ms); }
.hd-motion [data-curtain].is-in { opacity: 1; }
.hd-motion [data-curtain].is-in img { transform: scale(1); }
.hd-motion [data-curtain].is-in:hover img { transform: scale(1.07); }

/* section kicker: a short gold line draws in front of it */
.hd-motion .hd-head .hd-eyebrow,
.hd-motion .hd-why .hd-eyebrow,
.hd-motion .hd-cta .hd-eyebrow { display: inline-flex; align-items: center; gap: 10px; }
.hd-motion .hd-head .hd-eyebrow::before,
.hd-motion .hd-why .hd-eyebrow::before,
.hd-motion .hd-cta .hd-eyebrow::before {
    content: "";
    width: 28px;
    height: 1px;
    background: var(--hd-gold);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .9s .3s cubic-bezier(.65, 0, .35, 1);
}
[dir="rtl"].hd-motion .hd-eyebrow::before { transform-origin: right; }
.hd-motion .is-in .hd-eyebrow::before,
.hd-motion .hd-eyebrow.is-in::before { transform: scaleX(1); }

/* ---------- hover polish ---------- */
.hd-motion .hd-card.is-done { transition: box-shadow .6s, transform .6s cubic-bezier(.16, 1, .3, 1), border-color .6s; transition-delay: 0s; }
.hd-motion .hd-card.is-in:hover { transform: translateY(-8px); border-color: var(--hd-gold-lite); box-shadow: 0 26px 50px -26px rgba(138, 95, 55, .45); }
.hd-card-photo { overflow: hidden; }
.hd-card-photo img { transition: transform 1.2s cubic-bezier(.16, 1, .3, 1); }
.hd-card:hover .hd-card-photo img { transform: scale(1.07); }

.hd-cm { overflow: hidden; }
.hd-cm img { transition: transform 1.4s cubic-bezier(.16, 1, .3, 1) !important; }
.hd-cm:hover img { transform: scale(1.07) !important; }
.hd-op img { transition: transform 1.4s cubic-bezier(.16, 1, .3, 1) !important; }

/* light sweep across the photo on hover */
.hd-op::before, .hd-cm::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(105deg, transparent 35%, rgba(255, 240, 215, .28) 50%, transparent 65%);
    transform: translateX(-120%);
    transition: transform 1.1s cubic-bezier(.16, 1, .3, 1);
}
.hd-op:hover::before, .hd-cm:hover::before { transform: translateX(120%); }

/* buttons: arrow nudges, gold ones get a shine */
.hd-btn .hd-arrow { display: inline-block; transition: transform .35s cubic-bezier(.16, 1, .3, 1); }
.hd-btn:hover .hd-arrow { transform: translateX(5px); }
[dir="rtl"] .hd-btn:hover .hd-arrow { transform: translateX(-5px); }
.hd-btn--gold, .hd-btn--dark { position: relative; overflow: hidden; isolation: isolate; }
.hd-btn--gold::after, .hd-btn--dark::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 60%;
    left: 0;
    transform: translateX(-140%) skewX(-20deg);
    z-index: -1;
    background: linear-gradient(105deg, transparent, rgba(255, 255, 255, .35), transparent);

    transition: transform .9s cubic-bezier(.16, 1, .3, 1);
}
.hd-btn--gold:hover::after, .hd-btn--dark:hover::after { transform: translateX(260%) skewX(-20deg); }

/* why-us + services cards */
.hd-why-item i, .hd-sv i { transition: transform .5s cubic-bezier(.16, 1, .3, 1), background .3s, color .3s; }
.hd-why-item:hover i, .hd-sv:hover i { transform: translateY(-4px) rotate(-8deg); }
.hd-motion .hd-sv.is-done { transition: transform .6s cubic-bezier(.16, 1, .3, 1), box-shadow .6s; transition-delay: 0s; }
.hd-motion .hd-sv.is-in:hover { transform: translateY(-8px); box-shadow: 0 26px 50px -26px rgba(138, 95, 55, .45); }
.hd-sv-num { transition: transform .6s cubic-bezier(.16, 1, .3, 1), opacity .6s; }
.hd-sv:hover .hd-sv-num { transform: scale(1.25); opacity: 1; }

/* ---------- developers: endless ribbon ---------- */
.hd-motion .hd-devs .hd-wrap { max-width: none; padding-inline: 0; }
.hd-motion .hd-devs-list {
    display: flex;
    width: max-content;
    animation: hdRibbon var(--hd-ribbon, 40s) linear infinite;
}
[dir="rtl"].hd-motion .hd-devs-list { animation-name: hdRibbonRtl; }
.hd-motion .hd-devs-list a { flex: none; min-width: 240px; padding: 0 34px; border-inline-start: 1px solid var(--hd-line) !important; transition: color .3s; }
.hd-motion .hd-devs-list a:hover { color: var(--hd-gold); }
.hd-motion .hd-devs { overflow: hidden; position: relative; }
.hd-motion .hd-devs::before, .hd-motion .hd-devs::after { content: ""; position: absolute; top: 0; bottom: 0; width: 12%; z-index: 1; pointer-events: none; }
.hd-motion .hd-devs::before { left: 0; background: linear-gradient(90deg, #fff, rgba(255,255,255,0)); }
.hd-motion .hd-devs::after { right: 0; background: linear-gradient(270deg, #fff, rgba(255,255,255,0)); }
@keyframes hdRibbon { to { transform: translateX(-50%); } }
@keyframes hdRibbonRtl { to { transform: translateX(50%); } }

/* ---------- WhatsApp button breathes ---------- */
.hd-motion .hd-wa-fab::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 2px solid currentColor;
    opacity: 0;
    animation: hdPing 2.8s 2s ease-out infinite;
    pointer-events: none;
}
@keyframes hdPing { 0% { opacity: .55; transform: scale(1); } 80%, 100% { opacity: 0; transform: scale(1.7); } }

@media (prefers-reduced-motion: reduce) {
    .hd-motion *, .hd-motion *::before, .hd-motion *::after { animation: none !important; transition: none !important; }
    .hd-motion [data-rv], .hd-motion .hd-hero-inner > *, .hd-w > span { opacity: 1 !important; transform: none !important; }
    .hd-motion [data-curtain] { clip-path: none !important; }
}

/* parallax room for the "why" photo */
.hd-motion .hd-why-photo { overflow: hidden; }


/* ---------- page transitions: gold sweep, then an ivory panel with the word HUDRAT ----------
   Drawn with html::before / html::after so it exists before <body> is parsed
   (no flash when the next page starts loading). Kept short: ~0.3 s out, ~0.4 s in. */
html.hd-motion::before,
html.hd-motion::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 3000;
    pointer-events: none;
    transform: translateY(100%);
}
html.hd-motion::before { background: linear-gradient(135deg, var(--hd-gold-2, #d2a56c), var(--hd-gold, #a67548)); }
html.hd-motion::after {
    content: "HUDRAT";
    display: grid;
    place-items: center;
    background: #fbf8f3;
    color: var(--hd-gold, #a67548);
    font: 700 clamp(34px, 5vw, 56px)/1 Georgia, "Times New Roman", serif;
    letter-spacing: .32em;
    text-indent: .32em;            /* keeps the spaced-out word optically centred */
    direction: ltr;
}

/* leaving: gold comes up, the panel right behind it */
html.hd-leaving::before { animation: hdCoverIn .28s cubic-bezier(.65, 0, .35, 1) forwards; }
html.hd-leaving::after { animation: hdCoverIn .28s .05s cubic-bezier(.65, 0, .35, 1) forwards; }

/* arriving: the page starts covered, the word holds for a blink, then both panels lift away */
html.hd-entering::before,
html.hd-entering::after { transform: translateY(0); }
html.hd-entered::after { animation: hdCoverOut .42s .1s cubic-bezier(.65, 0, .35, 1) forwards; }
html.hd-entered::before { animation: hdCoverOut .42s .17s cubic-bezier(.65, 0, .35, 1) forwards; }

@keyframes hdCoverIn { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes hdCoverOut { from { transform: translateY(0); } to { transform: translateY(-100%); } }

/* ---------- smoothness ----------
   The over-hero header blurred whatever scrolled under it on every frame; at 97% white the blur
   was invisible anyway, so it is dropped. Moving layers get their own GPU layer. */
.hd-header--over.scrolled, .hd-header--over.menu-open, .site-header { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(255, 255, 255, .98); }
.hd-motion .hd-devs-list { will-change: transform; }
.hd-progress { will-change: transform; }
html.hd-motion::before, html.hd-motion::after { will-change: transform; }
.hd-motion [data-rv]:not(.is-done), .hd-motion [data-curtain]:not(.is-done) img { will-change: transform, opacity; }

/* ---------- scroll-linked effects run on the compositor ----------
   Parallax and the progress bar used to be moved from a scroll listener, which always lags one
   frame behind the real scroll and makes the big hero photo shimmer. Scroll-driven animations
   are stepped by the browser together with the scroll itself. Where they are not supported
   (older Firefox/Safari) both effects are simply off. */
.hd-progress { display: none; }
@supports (animation-timeline: scroll()) {
    .hd-motion .hd-progress {
        display: block;
        animation: hdProgress linear both;
        animation-timeline: scroll(root block);
    }
    .hd-motion .hd-hero-photo {
        animation: hdKenBurns 2.2s cubic-bezier(.16, 1, .3, 1) both, hdParallax linear both;
        animation-timeline: auto, scroll(root block);
        animation-range: normal, 0 120vh;
    }
}
@keyframes hdProgress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes hdParallax { from { translate: 0 0; } to { translate: 0 36vh; } }
