/* =========================================================
   Canny Tech — motion layer
   Everything here is progressive: it only runs when JS adds
   html.motion (which it skips for prefers-reduced-motion).
   ========================================================= */

/* ---------- Page-to-page transitions (Chromium cross-document) ---------- */
@view-transition { navigation: auto; }
.site-header { view-transition-name: site-header; }
::view-transition-old(root) { animation: vt-out .22s ease both; }
::view-transition-new(root) { animation: vt-in .38s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-10px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(14px); } }
@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
}

/* ---------- Scroll progress ---------- */
.scroll-progress { position: fixed; top: 0; inset-inline: 0; height: 3px; z-index: 60; pointer-events: none; }
.scroll-progress span {
    display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), #5FD3FF);
    transform: scaleX(var(--p, 0)); transform-origin: left;
}
html[dir="rtl"] .scroll-progress span { transform-origin: right; background: linear-gradient(270deg, var(--cyan), #5FD3FF); }

/* ---------- Header hides on scroll down ---------- */
.site-header { transition: transform .35s var(--ease), border-color .25s, box-shadow .25s; }
.site-header.is-hidden { transform: translateY(-100%); }

/* ---------- Scroll reveals ---------- */
.motion .rv {
    opacity: 0; transform: translate3d(0, 34px, 0);
    transition: opacity .8s var(--ease), transform .9s var(--ease);
    transition-delay: calc(var(--i, 0) * 90ms);
}
.motion .rv.in { opacity: 1; transform: none; }
.motion .rv-scale { transform: scale(.94) translate3d(0, 20px, 0); }

/* ---------- Hero headline: words rise one by one ---------- */
.hw { display: inline-block; overflow: hidden; vertical-align: top; padding: .12em .02em .22em; margin: -.12em -.02em -.22em; }
.hw > span { display: inline-block; }
.motion .hw > span { transform: translateY(115%); animation: word-up .95s var(--ease) forwards; animation-delay: calc(.12s + var(--i, 0) * 75ms); }
@keyframes word-up { to { transform: none; } }
/* Hidden until split into words; fades in on its own if the script never runs */
.motion .hero-title:not(.is-split) { opacity: 0; animation: fade-up .6s 1.2s var(--ease) forwards; }
.motion .hero .since,
.motion .hero .hero-lead,
.motion .hero .domain-box,
.motion .hero .hero-links { opacity: 0; animation: fade-up .9s var(--ease) forwards; }
.motion .hero .since { animation-delay: .05s; }
.motion .hero .hero-lead { animation-delay: .65s; }
.motion .hero .domain-box { animation-delay: .8s; }
.motion .hero .hero-links { animation-delay: .95s; }
@keyframes fade-up { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }

/* ---------- Hero spotlight follows the pointer ---------- */
.hero::before {
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .5s;
    background: radial-gradient(520px circle at var(--mx, 70%) var(--my, 40%), rgba(0, 174, 239, .16), transparent 62%);
}
.hero.is-lit::before { opacity: 1; }
.hero-grid { position: relative; z-index: 1; }

/* ---------- Hero visual: 3D tilt + depth parallax ---------- */
.hero-visual { perspective: 1400px; }
.hero-stage { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateY(calc(var(--tx, 0) * 7deg)) rotateX(calc(var(--ty, 0) * -6deg)); will-change: transform; }
.hero-stage .bracket { translate: calc(var(--tx, 0) * -6px) calc(var(--ty, 0) * -6px); }
.hero-stage .browser { translate: calc(var(--tx, 0) * 10px) calc(var(--ty, 0) * 8px); }
.hero-stage .phone { translate: calc(var(--tx, 0) * 26px) calc(var(--ty, 0) * 20px); }

/* Skeleton shimmer inside the mock: the site is "loading" */
.motion .mock-nav span,
.motion .phone-row,
.motion .wm-line {
    background: linear-gradient(90deg, var(--grey-300) 0%, #E8EDF1 40%, var(--grey-300) 80%) 0 0 / 300% 100%;
    animation: shimmer 2.4s linear infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -200% 0; } }

/* Mock rebuilds when the domain changes */
.browser-body.rebuild .mock-hero,
.browser-body.rebuild .mock-tiles span,
.phone.rebuild .phone-card,
.phone.rebuild .phone-row { animation: rebuild .7s var(--ease) both; }
.browser-body.rebuild .mock-tiles span:nth-child(1) { animation-delay: .08s; }
.browser-body.rebuild .mock-tiles span:nth-child(2) { animation-delay: .16s; }
.browser-body.rebuild .mock-tiles span:nth-child(3) { animation-delay: .24s; }
.phone.rebuild .phone-card { animation-delay: .1s; }
.phone.rebuild .phone-row { animation-delay: .2s; }
@keyframes rebuild { 0% { opacity: 0; transform: scale(.9) translateY(8px); } 100% { opacity: 1; transform: none; } }
.mock-btn { position: relative; overflow: hidden; }
.motion .mock-btn::after {
    content: ""; position: absolute; inset: 0; transform: translateX(-120%);
    background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.7) 50%, transparent 70%);
    animation: sweep 3.2s 1.6s ease-in-out infinite;
}
@keyframes sweep { 0%, 60% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }

/* The logo dots breathe */
.motion .hero .bracket-dots i { animation: dot-in .5s var(--ease) both, bob 3.6s 1.4s ease-in-out infinite; }
.motion .hero .bracket-dots i:nth-child(2) { animation-delay: .85s, 1.7s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

/* ---------- Buttons: shine + magnetic ---------- */
.btn { position: relative; overflow: hidden; isolation: isolate; }
.btn-primary::after {
    content: ""; position: absolute; inset: 0; z-index: -1; transform: translateX(-110%);
    background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.55) 50%, transparent 80%);
    transition: transform .7s var(--ease);
}
.btn-primary:hover::after { transform: translateX(110%); }
[data-magnetic] { transition: translate .35s var(--ease), background-color .2s, color .2s, border-color .2s, transform .2s; translate: var(--mgx, 0) var(--mgy, 0); }

/* ---------- Marquee band ---------- */
html, body { overflow-x: clip; }
.marquee-wrap { overflow: hidden; padding-block: clamp(14px, 2.4vw, 30px); }
.marquee {
    background: var(--navy); color: #fff; overflow: hidden; padding-block: clamp(20px, 3vw, 34px);
    transform: rotate(-1.6deg); margin-block: clamp(10px, 2vw, 24px); width: 104%; margin-inline: -2%;
    border-block: 4px solid var(--cyan); direction: ltr;
}
html[dir="rtl"] .marquee { transform: rotate(1.6deg); }
.marquee-track { display: flex; width: max-content; direction: ltr; will-change: transform; }
.marquee-group { display: flex; align-items: center; flex: none; }
.marquee-item {
    font-family: var(--font-display); font-weight: 700; font-size: clamp(1.6rem, 4vw, 3.1rem);
    line-height: 1.3; white-space: nowrap; padding-inline: clamp(18px, 2.6vw, 38px);
}
.marquee-group > .marquee-item:nth-child(4n+3) { color: var(--cyan); }
.marquee-sep { display: inline-flex; gap: 7px; }
.marquee-sep i { width: 14px; height: 14px; border-radius: 50%; background: var(--grey); display: block; }
html:not(.motion) .marquee-track { flex-wrap: wrap; width: auto; justify-content: center; }
html:not(.motion) .marquee-group + .marquee-group { display: none; }

/* ---------- Services: lively rows ---------- */
.service-icon { transition: background-color .3s, color .3s, transform .45s cubic-bezier(.34, 1.56, .64, 1); }
.service-row:hover .service-icon { background: var(--cyan); color: var(--navy); transform: rotate(-8deg) scale(1.08); }
.service-text { transition: transform .35s var(--ease); }
.service-row:hover .service-text { transform: translateX(var(--shift, 6px)); }
html[dir="rtl"] .service-row { --shift: -6px; }
.service-block .service-icon { transition: transform .45s cubic-bezier(.34, 1.56, .64, 1), background-color .3s, color .3s; }
.service-block:hover .service-icon { transform: translateY(-4px) rotate(-6deg); background: var(--cyan); color: var(--navy); }

/* ---------- Work cards: tilt, glare, scrolling mock ---------- */
.work-media { transform: perspective(1000px) rotateX(var(--ry, 0deg)) rotateY(var(--rx, 0deg)); transition: transform .5s var(--ease), box-shadow .5s; will-change: transform; }
.work-item:hover .work-media { box-shadow: 0 40px 60px -40px rgba(10, 37, 64, .55); }
.work-media::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .4s;
    background: radial-gradient(400px circle at var(--gx, 50%) var(--gy, 0%), rgba(255,255,255,.28), transparent 55%);
}
.work-item:hover .work-media::after { opacity: 1; }
.work-mock { display: flex; flex-direction: column; }
.wm-viewport { flex: 1; min-height: 0; overflow: hidden; }
.wm-body { transition: transform 2.6s cubic-bezier(.45, 0, .2, 1); }
.work-item:hover .wm-body { transform: translateY(-46%); }
.wm-banner { height: 70px; border-radius: 10px; background: var(--accent); opacity: .85; margin-block: 6px; }

/* ---------- Process: line draws, steps light up ---------- */
.motion .steps::before { transform: scaleX(0); transform-origin: left; transition: transform 1.8s var(--ease) .2s; }
html[dir="rtl"].motion .steps::before { transform-origin: right; }
.motion .steps.in::before { transform: scaleX(1); }
.motion .step.rv { transition-delay: calc(.25s + var(--i, 0) * 280ms); }
.motion .step.in .step-num { animation: num-on .7s calc(.35s + var(--i, 0) * 280ms) var(--ease) both; }
@keyframes num-on {
    0% { transform: scale(.6); box-shadow: 0 0 0 0 rgba(0, 174, 239, .6); }
    60% { transform: scale(1.12); }
    100% { transform: none; box-shadow: 0 0 0 14px rgba(0, 174, 239, 0); }
}

/* ---------- CTA: drifting bracket ---------- */
.motion .cta-bracket { animation: drift 9s ease-in-out infinite; }
@keyframes drift { 0%, 100% { translate: 0 0; rotate: 0deg; } 50% { translate: -18px 10px; rotate: -4deg; } }

/* ---------- FAQ: smooth open (where supported) ---------- */
:root { interpolate-size: allow-keywords; }
.faq details::details-content { block-size: 0; overflow: hidden; transition: block-size .45s var(--ease), content-visibility .45s allow-discrete; }
.faq details[open]::details-content { block-size: auto; }

/* ---------- Page heads: bracket draws in ---------- */
.motion .page-head-bracket { animation: bracket-in 1s .1s var(--ease) both; }
.motion .page-title, .motion .page-head .lead, .motion .crumbs { opacity: 0; animation: fade-up .9s var(--ease) forwards; }
.motion .page-title { animation-delay: .1s; }
.motion .page-head .lead { animation-delay: .25s; }

/* ---------- Plans lift ---------- */
.plan { transition: transform .4s var(--ease), box-shadow .4s; }
.plan:hover { transform: translateY(-8px); box-shadow: 0 34px 60px -40px rgba(10, 37, 64, .45); }

/* ---------- WhatsApp: gentle ping ---------- */
.motion .wa-float::before {
    content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid #25D366;
    animation: ping 2.8s 3s cubic-bezier(0, 0, .2, 1) infinite;
}
@keyframes ping { 0% { transform: scale(1); opacity: .8; } 80%, 100% { transform: scale(1.7); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    .work-media, .hero-stage { transform: none !important; }
    .work-item:hover .wm-body { transform: none; }
}
