/* ============================================================
   Food AI — Motion FX styles
   Layered on top of design.css. Everything degrades cleanly
   when prefers-reduced-motion: reduce is set.
   ============================================================ */

/* ---------- FX canvas layers ---------- */
#fxParticles {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 1200ms ease 400ms;
}
.hero.is-detected #fxParticles,
.hero.is-scanning #fxParticles { opacity: 1; }

#fxPhotoParticles {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 1400ms ease 1600ms;
}
.hero.is-detected #fxPhotoParticles { opacity: 1; }

/* Hero content sits above the ambient particle layer */
.hero__grid,
.hero > .shell:last-of-type { position: relative; z-index: 2; }

/* ---------- Hero scan sweep (one shot on load) ---------- */
/* Screen blend keeps the photo luminous instead of washing it grey. */
.hero__photo::before {
    content: '';
    position: absolute;
    left: 0; right: 0;
    bottom: 0;
    height: 68%;
    z-index: 4;
    pointer-events: none;
    mix-blend-mode: screen;
    background: linear-gradient(
        to bottom,
        rgba(7, 148, 71, 0) 0%,
        rgba(7, 148, 71, .12) 46%,
        rgba(11, 166, 83, .34) 92%,
        rgba(11, 166, 83, .46) 100%
    );
    opacity: 0;
    transform: translateY(-100%);
}
.hero__photo.is-scanning::before {
    animation: fxScanSweep 1900ms cubic-bezier(.5, 0, .3, 1) forwards;
}
@keyframes fxScanSweep {
    0%   { opacity: 0;    transform: translateY(-100%); }
    12%  { opacity: 1;    transform: translateY(-100%); }
    88%  { opacity: 1;    transform: translateY(100%); }
    100% { opacity: 0;    transform: translateY(100%); }
}

/* A hairline that rides with the sweep. Uses its own element so it does not
   collide with the permanent gradient on .hero__photo::after. */
.hero__scanline {
    position: absolute;
    left: 0; right: 0;
    bottom: 0;
    height: 68%;
    z-index: 5;
    pointer-events: none;
    overflow: hidden;
}
.hero__scanline::before {
    content: '';
    position: absolute;
    left: 0; right: 0;
    height: 2px;
    background: linear-gradient(to right, transparent, var(--brand-500) 20%, var(--lemon-500) 80%, transparent);
    box-shadow: 0 0 14px 2px rgba(11, 166, 83, .45);
    opacity: 0;
    transform: translateY(0);
}
.hero__photo.is-scanning .hero__scanline::before {
    animation: fxScanLine 1900ms cubic-bezier(.5, 0, .3, 1) forwards;
}
@keyframes fxScanLine {
    0%   { opacity: 0; transform: translateY(0); }
    14%  { opacity: 1; }
    86%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(340px); }
}

/* ---------- Tilt + specular glare ---------- */
[data-tilt] {
    transform-style: preserve-3d;
    will-change: transform;
    transition: transform 420ms var(--ease);
}
[data-tilt].is-tilting { transition: transform 90ms linear; }

.fx-glare {
    position: absolute;
    inset: 0;
    z-index: 6;
    pointer-events: none;
    border-radius: inherit;
    opacity: 0;
    background: radial-gradient(
        420px circle at var(--gx, 50%) var(--gy, 50%),
        rgba(255, 255, 255, .34),
        rgba(255, 255, 255, .08) 42%,
        transparent 68%
    );
    transition: opacity 320ms ease;
}
.is-tilting > .fx-glare { opacity: 1; }

/* ---------- Magnetic + ripple ---------- */
.btn, .tool, .header__cta {
    position: relative;
    overflow: hidden;
    will-change: transform;
}
.btn--primary, .btn--onDark { transform: translateZ(0); }

.fx-ripple {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(circle, rgba(255,255,255,.42), rgba(255,255,255,0) 70%);
    transform: scale(0);
    animation: fxRipple 650ms var(--ease) forwards;
}
@keyframes fxRipple {
    to { transform: scale(2.6); opacity: 0; }
}
.tool .fx-ripple { background: radial-gradient(circle, rgba(7,148,71,.20), rgba(7,148,71,0) 70%); }

/* ---------- Scroll progress bar ---------- */
#fxProgress {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: 3px;
    z-index: 120;
    pointer-events: none;
    background: linear-gradient(to right, var(--brand-600), var(--lemon-500));
    transform: scaleX(0);
    transform-origin: left;
}

/* ---------- Parallax ---------- */
[data-parallax] { transform: translate3d(0, var(--py, 0px), 0); will-change: transform; }
.hero__card { transform: translate3d(0, var(--py, 0px), 0); }

/* ---------- Word-by-word heading reveal ---------- */
[data-split] .fx-word {
    display: inline-block;
    overflow: hidden;
    vertical-align: bottom;
    padding-bottom: .12em;
    margin-bottom: -.12em;
}
[data-split] .fx-word__i {
    display: inline-block;
    transform: translateY(105%);
    transition: transform 720ms var(--ease);
    transition-delay: calc(var(--i, 0) * 42ms);
}
[data-split].is-split-in .fx-word__i { transform: translateY(0); }

/* The hero title carries an <em> highlight; keep the underline out of the
   clipping box created by .fx-word overflow:hidden. */
.hero__title em::after { z-index: 0; }
.hero__title em { position: relative; z-index: 1; }
.hero__title em .fx-word { position: relative; z-index: 1; }

/* ---------- Scan sweep over the demo phone ---------- */
/* Replays on every step change so each step reads as a fresh scan. */
.how__scan {
    position: absolute;
    top: 0; bottom: 0;
    left: 50%;
    width: 252px;
    transform: translateX(-50%);
    z-index: 3;
    pointer-events: none;
    overflow: hidden;
    opacity: 0;
}
.how__scan::before {
    content: '';
    position: absolute;
    left: 0; right: 0;
    height: 90px;
    background: linear-gradient(to bottom,
        rgba(7, 148, 71, 0) 0%,
        rgba(7, 148, 71, .16) 62%,
        rgba(11, 166, 83, .52) 94%,
        rgba(255, 196, 0, .72) 100%);
    mix-blend-mode: screen;
    transform: translateY(-100%);
}
.how__scan::after {
    content: '';
    position: absolute;
    left: 0; right: 0;
    height: 2px;
    background: linear-gradient(to right, transparent, var(--lemon-500) 30%, var(--brand-500) 70%, transparent);
    box-shadow: 0 0 12px 2px rgba(255, 196, 0, .5);
    transform: translateY(-100%);
}
.how__stage.is-scanning .how__scan { opacity: 1; }
.how__stage.is-scanning .how__scan::before {
    animation: howSweep 820ms cubic-bezier(.4, 0, .3, 1) forwards;
}
.how__stage.is-scanning .how__scan::after {
    animation: howSweepLine 820ms cubic-bezier(.4, 0, .3, 1) forwards;
}
@keyframes howSweep {
    0%   { opacity: 0; transform: translateY(-100%); }
    15%  { opacity: 1; }
    85%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(640px); }
}
@keyframes howSweepLine {
    0%   { opacity: 0; transform: translateY(-100%); }
    18%  { opacity: 1; }
    82%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(640px); }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    #fxParticles, #fxPhotoParticles { display: none; }
    .hero__photo::before, .hero__scanline { display: none; }
    [data-split] .fx-word__i { transform: none; transition: none; }
    [data-tilt], [data-parallax] { transform: none !important; }
    .fx-glare { display: none; }
    #fxProgress { display: none; }
}
