/* ==========================================================================
   Future Rize — interaction layer
   Things that respond to the visitor: cursor, tilt, spotlight, magnetic
   buttons, scroll parallax, word reveals, page transitions.
   Loaded after motion.css. Remove the two "interact" lines in
   layouts/app.blade.php to switch it all off.
   ========================================================================== */

:root {
    --fx-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --fx-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Page enter / leave ─────────────────────────────────────────────────── */
/* Fades the whole page; the class is removed once it finishes so nothing is
   left holding a stacking context (the projects modal relies on z-index). */
@keyframes fxPageIn { from { opacity: 0; } to { opacity: 1; } }
body.fx-entering { animation: fxPageIn 0.45s var(--fx-ease) both; }
body.fx-leaving { opacity: 0; transition: opacity 0.22s ease; }

/* ── Cursor follower (mouse only) ───────────────────────────────────────── */
.fx-cursor {
    position: fixed; top: 0; left: 0; z-index: 9999;
    width: 36px; height: 36px; margin: -18px 0 0 -18px;
    border: 1.5px solid var(--gold);
    border-radius: 50%;
    pointer-events: none;
    display: flex; align-items: center; justify-content: center;
    font: 600 0.68rem/1 'DM Sans', sans-serif;
    letter-spacing: 0.12em; text-transform: uppercase;
    color: transparent;
    opacity: 0;
    transition: width 0.35s var(--fx-ease), height 0.35s var(--fx-ease),
                margin 0.35s var(--fx-ease), background 0.3s, border-color 0.3s,
                color 0.2s, opacity 0.3s;
    will-change: transform;
}
.fx-cursor.is-on { opacity: 0.9; }
.fx-cursor.is-link {
    width: 56px; height: 56px; margin: -28px 0 0 -28px;
    background: rgba(201,168,76,0.12);
}
.fx-cursor.is-view {
    width: 84px; height: 84px; margin: -42px 0 0 -42px;
    background: var(--gold); border-color: var(--gold);
    color: var(--forest);
}
.fx-cursor.is-text { opacity: 0; }
.fx-cursor.is-down { width: 26px; height: 26px; margin: -13px 0 0 -13px; }

/* ── Spotlight that follows the mouse on dark sections ──────────────────── */
.hero, .page-hero, .proj-hero, .services-bg, .cta-section, footer, .stats-bar {
    isolation: isolate;
}
.services-bg, .cta-section, footer, .stats-bar { position: relative; }
.fx-spot {
    position: absolute; inset: 0; z-index: -1;
    pointer-events: none;
    background: radial-gradient(520px circle at var(--sx, 50%) var(--sy, 50%),
                rgba(201,168,76,0.16), transparent 60%);
    opacity: 0;
    transition: opacity 0.6s ease;
}
.fx-spot-host:hover > .fx-spot { opacity: 1; }

/* ── Hero mouse parallax ────────────────────────────────────────────────── */
.hero::before, .page-hero::before {
    translate: calc(var(--px, 0) * -18px) calc(var(--py, 0) * -18px);
    transition: translate 0.6s var(--fx-ease);
}
.hero h1, .page-hero h1 {
    translate: calc(var(--px, 0) * 10px) calc(var(--py, 0) * 8px);
    transition: translate 0.6s var(--fx-ease);
}
.hero-stats {
    translate: calc(var(--px, 0) * -14px) calc(var(--py, 0) * -10px);
    transition: translate 0.6s var(--fx-ease);
}

/* ── 3D tilt + glare on cards ───────────────────────────────────────────── */
body .fx-tilt.fx-tilt {
    position: relative;
    transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg))
               translateY(var(--lift, 0px));
    transition: transform 0.5s var(--fx-ease), box-shadow 0.4s, border-color 0.3s,
                background 0.3s;
    will-change: transform;
    backface-visibility: hidden;
}
/* keeps rounded corners and overflow clipping intact while rotated */
body .project-card.fx-tilt { -webkit-mask-image: -webkit-radial-gradient(white, black); }
body .fx-tilt.fx-tilt.is-tilting { transition: transform 0.12s linear, box-shadow 0.4s,
                                               border-color 0.3s, background 0.3s; }
body .fx-tilt.fx-tilt:hover { --lift: -6px; }
.fx-glare {
    position: absolute; inset: 0; z-index: 2;
    border-radius: inherit;
    pointer-events: none;
    background: radial-gradient(380px circle at var(--gx, 50%) var(--gy, 50%),
                var(--glare, rgba(255,255,255,0.14)), transparent 55%);
    opacity: 0;
    transition: opacity 0.4s ease;
}
.fx-tilt:hover > .fx-glare, .fx-glow:hover > .fx-glare { opacity: 1; }
.fx-glow { position: relative; }
.feature-card, .mvvo-card, .contact-detail-item, .stat-item { --glare: rgba(201,168,76,0.16); }
.project-card { --glare: rgba(255,255,255,0.22); }

/* ── Magnetic buttons (uses `translate`, so it stacks with transforms) ──── */
.fx-magnet {
    translate: var(--bx, 0px) var(--by, 0px);
    transition: translate 0.45s var(--fx-spring), transform 0.25s var(--fx-ease),
                box-shadow 0.3s, background 0.3s, color 0.3s, border-color 0.3s;
}
.fx-magnet.is-pulling { transition: translate 0.15s linear, transform 0.25s var(--fx-ease),
                                    box-shadow 0.3s, background 0.3s, color 0.3s,
                                    border-color 0.3s; }

/* ── Click ripple ───────────────────────────────────────────────────────── */
.fx-ripple-host { position: relative; overflow: hidden; }
.fx-ripple {
    position: absolute; border-radius: 50%;
    width: 12px; height: 12px; margin: -6px 0 0 -6px;
    background: currentColor; opacity: 0.28;
    pointer-events: none;
    animation: fxRipple 0.6s var(--fx-ease) forwards;
}
@keyframes fxRipple { to { transform: scale(28); opacity: 0; } }

/* ── Headline words rise in as the section scrolls into view ────────────── */
.fx-split.reveal { opacity: 1; transform: none; }
.fx-w {
    display: inline-block;
    opacity: 0;
    transform: translateY(0.55em) rotate(2deg);
    transform-origin: left bottom;
    transition: opacity 0.6s ease, transform 0.8s var(--fx-ease);
    transition-delay: calc(var(--i, 0) * 45ms + 60ms);
}
.fx-split.visible .fx-w, .fx-split.fx-in .fx-w { opacity: 1; transform: none; }
.page-hero h1.fx-split { animation: none !important; }

/* ── Images: curtain reveal + scroll parallax ───────────────────────────── */
.fx-wipe {
    clip-path: inset(0 0 100% 0);
    transition: clip-path 1.1s var(--fx-ease);
}
.fx-wipe.fx-in { clip-path: inset(0 0 0 0); }
.fx-para { overflow: hidden; }
.fx-para img, .fx-para video {
    scale: 1.14;
    translate: 0 var(--pp, 0px);
    will-change: translate;
}

/* ── Services page: the side nav follows your position ──────────────────── */
.services-nav-item.is-current { background: rgba(201,168,76,0.08); }
.services-nav-item.is-current .services-nav-num,
.services-nav-item.is-current .services-nav-label { color: var(--gold); }

/* ── Sections lift slightly as they arrive ──────────────────────────────── */
.fx-rise { transform: translateY(40px); opacity: 0.4;
           transition: transform 1s var(--fx-ease), opacity 1s ease; }
.fx-rise.fx-in { transform: none; opacity: 1; }

/* ── Touch screens: no hover-only effects ───────────────────────────────── */
@media (hover: none), (pointer: coarse) {
    .fx-cursor, .fx-glare, .fx-spot { display: none; }
    body .fx-tilt.fx-tilt { transform: none; }
}

/* ── Respect "reduce motion" ────────────────────────────────────────────── */
/* "Reduce motion": keep everything except the large movements (cards
   tilting, buttons pulling, images and hero layers drifting). */
@media (prefers-reduced-motion: reduce) {
    body .fx-tilt.fx-tilt, .fx-magnet { transform: none; translate: none; }
    .fx-para img, .fx-para video { scale: 1; translate: none; }
    .hero::before, .page-hero::before, .hero h1, .page-hero h1, .hero-stats { translate: none; }
}
