/* =========================================================
   Sarah Reilly's Creations — scrapbook animations (PREVIEW)
   ---------------------------------------------------------
   Load AFTER styles.css, together with js/animations.js.

   How it stays out of the way of the layout:
   - Every animation uses the individual `translate`, `rotate`
     and `scale` properties, which stack on top of the
     `transform: rotate(...)` tilts already in styles.css, so
     no tilt or position is overwritten.
   - Everything is inside `prefers-reduced-motion: no-preference`,
     so visitors who turn motion off see the normal static site.
   - Scroll reveals only hide things once animations.js has added
     the `.anim-ready` class, so without JS nothing is hidden.

   Sections:
   1. Hero entrance (runs on page load)
   2. Scroll reveals (cards, tiles, polaroids, headings)
   3. Hand-drawn bits (price circles, step circles, tape)
   4. Hover + tap
   5. Small ambient details
   6. Page entrances: About, Portfolio, Order
   7. Touch screens (phones/tablets): tap + scroll-focus
      instead of hover
   ========================================================= */

@media (prefers-reduced-motion: no-preference) {

    :root {
        --anim-ease-out: cubic-bezier(.22, 1, .36, 1);   /* soft landing */
        --anim-ease-pop: cubic-bezier(.34, 1.56, .64, 1); /* small overshoot */
    }

    /* =====================================================
       1. HERO ENTRANCE
       ===================================================== */

    /* flyer + reel drop in, tilted extra, then settle into their tilt */
    /* the flyer is the page's Largest Contentful Paint, so it stays fully visible
       (no opacity fade) and starts moving immediately; the drop is motion only */
    .collage-1 {
        animation: hero-drop 0.9s var(--anim-ease-out) both;
    }

    .collage-2 {
        animation: hero-drop-alt 0.9s var(--anim-ease-out) 0.15s both;
    }

    @keyframes hero-drop {
        from { translate: -10px -50px; rotate: -7deg; }
        to   { translate: 0 0;         rotate: 0deg; }
    }

    @keyframes hero-drop-alt {
        from { translate: 10px -50px; rotate: 7deg; }
        to   { translate: 0 0;        rotate: 0deg; }
    }

    @keyframes pin-drop {
        from { opacity: 0; translate: -10px -50px; rotate: -7deg; }
        to   { opacity: 1; translate: 0 0;        rotate: 0deg; }
    }

    @keyframes pin-drop-alt {
        from { opacity: 0; translate: 10px -50px; rotate: 7deg; }
        to   { opacity: 1; translate: 0 0;       rotate: 0deg; }
    }

    /* thumb tacks press in after the paper lands */
    .tack {
        animation: tack-press 0.45s var(--anim-ease-pop) both;
    }

    .tack-1 { animation-delay: 0.95s; }
    .tack-2 { animation-delay: 1.1s; }

    @keyframes tack-press {
        0%   { opacity: 0; scale: 1.8; translate: 0 -14px; }
        60%  { opacity: 1; scale: 0.85; translate: 0 0; }
        100% { opacity: 1; scale: 1; }
    }

    /* marker highlight sweeps under "your vision" */
    .hero-text mark::after {
        transform-origin: left center;
        animation: marker-sweep 0.7s var(--anim-ease-out) 0.6s both;
    }

    @keyframes marker-sweep {
        from { scale: 0 1; }
        to   { scale: 1 1; }
    }

    /* "made by hand, not AI!" note fades in, then the arrows draw on */
    .hero-note {
        animation: fade-up 0.5s var(--anim-ease-out) 1.2s both;
    }

    .hero-arrow {
        animation: arrow-draw 0.6s ease-out both;
    }

    .hero-arrow-left  { animation-delay: 1.5s; }
    .hero-arrow-right { animation-delay: 1.65s; }

    /* each arrow starts at its top-left and curves down-right
       (the left one is mirrored), so revealing left → right reads as drawing */
    @keyframes arrow-draw {
        from { clip-path: inset(0 100% 0 0); }
        to   { clip-path: inset(0 0 0 0); }
    }

    /* sticky note slaps on, badge stamps down */
    .hero-sticky {
        animation: fade-up 0.6s var(--anim-ease-pop) 1.3s both;
    }

    .stamp {
        animation: stamp-down 0.5s var(--anim-ease-pop) 1.55s both;
    }

    @keyframes stamp-down {
        0%   { opacity: 0; scale: 2.2; }
        70%  { opacity: 1; scale: 0.92; }
        100% { opacity: 1; scale: 1; }
    }

    @keyframes fade-up {
        from { opacity: 0; translate: 0 18px; }
        to   { opacity: 1; translate: 0 0; }
    }

    /* =====================================================
       2. SCROLL REVEALS
       animations.js adds .reveal to the targets and
       .is-visible once each one scrolls into view.
       --reveal-delay staggers items in the same row.
       ===================================================== */

    .anim-ready .reveal {
        opacity: 0;
        translate: 0 32px;
        rotate: 2.5deg;
        transition:
            opacity 0.6s var(--anim-ease-out),
            translate 0.7s var(--anim-ease-out),
            rotate 0.7s var(--anim-ease-out);
        transition-delay: var(--reveal-delay, 0ms);
    }

    .anim-ready .reveal:nth-child(even) {
        rotate: -2.5deg;
    }

    .anim-ready .reveal.is-visible {
        opacity: 1;
        translate: 0 0;
        rotate: 0deg;
    }

    /* =====================================================
       3. HAND-DRAWN BITS
       These play once their card has been revealed.
       ===================================================== */

    /* hand-drawn circles around $30 / $60 */
    .anim-ready .price-card .price::before,
    .anim-ready .price-card .price::after {
        clip-path: inset(0 100% 0 0);
    }

    .anim-ready .price-card.is-visible .price::before {
        animation: circle-draw 0.6s ease-out calc(var(--reveal-delay, 0ms) + 0.45s) both;
    }

    .anim-ready .price-card.is-visible .price::after {
        animation: circle-draw 0.6s ease-out calc(var(--reveal-delay, 0ms) + 0.7s) both;
    }

    /* red circles around the 1-2-3 step numbers */
    .anim-ready .step .step-num::before,
    .anim-ready .step .step-num::after {
        clip-path: inset(0 100% 0 0);
    }

    .anim-ready .step.is-visible .step-num::before {
        animation: circle-draw 0.5s ease-out calc(var(--reveal-delay, 0ms) + 0.4s) both;
    }

    .anim-ready .step.is-visible .step-num::after {
        animation: circle-draw 0.5s ease-out calc(var(--reveal-delay, 0ms) + 0.6s) both;
    }

    @keyframes circle-draw {
        from { clip-path: inset(0 100% 0 0); }
        to   { clip-path: inset(0 0 0 0); }
    }

    /* tape strips stretch onto the card just after it lands */
    .anim-ready .tile.reveal::before,
    .anim-ready .price-card.reveal::before,
    .anim-ready .step.reveal::before {
        opacity: 0;
    }

    .anim-ready .tile.is-visible::before,
    .anim-ready .price-card.is-visible::before,
    .anim-ready .step.is-visible::before {
        animation: tape-on 0.4s var(--anim-ease-out) calc(var(--reveal-delay, 0ms) + 0.35s) both;
    }

    @keyframes tape-on {
        from { opacity: 0;    scale: 0.2 1; }
        to   { opacity: 0.85; scale: 1 1; }
    }

    /* =====================================================
       4. HOVER + TAP
       ===================================================== */

    /* pick a card up off the board: straighten, lift, deeper shadow */
    .tile,
    .polaroid,
    .price-card,
    .step,
    .pick-card,
    .note-step,
    .value-card {
        transition:
            transform 0.35s var(--anim-ease-pop),
            box-shadow 0.35s ease,
            opacity 0.6s var(--anim-ease-out),
            translate 0.7s var(--anim-ease-out),
            rotate 0.7s var(--anim-ease-out);
        transition-delay: 0ms, 0ms, var(--reveal-delay, 0ms), var(--reveal-delay, 0ms), var(--reveal-delay, 0ms);
    }

    @media (hover: hover) {
        .tile:hover,
        .polaroid:hover,
        .price-card:hover,
        .step:hover,
        .pick-card:hover,
        .note-step:hover,
        .value-card:hover {
            transform: rotate(0deg) translateY(-6px);
            box-shadow: 4px 16px 28px rgba(0, 0, 0, 0.18);
            transition-delay: 0ms;
        }

        /* the tile's own image frame gets the deeper shadow too */
        .tile:hover > img,
        .tile:hover .video-thumbs {
            box-shadow: 4px 14px 24px rgba(0, 0, 0, 0.2);
            transition: box-shadow 0.35s ease;
        }

        /* tape on taped buttons wiggles on hover */
        .btn-tape:hover::before {
            animation: tape-wiggle 0.5s ease-in-out;
        }

        /* scribble underline redraws on hover */
        .tile-link:hover,
        .tile-link:focus-visible {
            animation: scribble-redraw 0.45s ease-out;
        }

        /* sticky note tips a little when hovered
           (uses rotate, which the entrance animation doesn't touch) */
        .hero-sticky {
            transition: rotate 0.35s var(--anim-ease-pop);
        }

        .hero-sticky:hover {
            rotate: 3deg;
        }

        /* rounded hero buttons lift slightly */
        .hero-buttons .btn {
            transition: translate 0.2s var(--anim-ease-pop), box-shadow 0.2s ease;
        }

        .hero-buttons .btn:hover {
            translate: 0 -3px;
            box-shadow: 0 6px 14px rgba(46, 82, 71, 0.22);
        }
    }

    /* taped buttons press down when clicked or tapped */
    .btn-tape:active {
        translate: 3px 3px;
        box-shadow: 0 0 0 var(--Deep-green);
    }

    @keyframes tape-wiggle {
        0%, 100% { rotate: 0deg; }
        30%      { rotate: 6deg; }
        65%      { rotate: -4deg; }
    }

    @keyframes scribble-redraw {
        from { background-size: 0% 12px; }
        to   { background-size: 100% 12px; }
    }

    /* =====================================================
       5. SMALL AMBIENT DETAILS (kept very subtle)
       ===================================================== */

    /* star / sparkle doodles slowly sway */
    .sparkle-1,
    .sparkle-2,
    .cta-sparkle-1,
    .cta-sparkle-2 {
        animation: doodle-sway 5s ease-in-out infinite;
    }

    .sparkle-2,
    .cta-sparkle-2 {
        animation-duration: 6.5s;
        animation-delay: -2s;
    }

    @keyframes doodle-sway {
        0%, 100% { rotate: -8deg; scale: 1; }
        50%      { rotate: 8deg;  scale: 1.08; }
    }

    /* =====================================================
       6. PAGE ENTRANCES
       ===================================================== */

    /* ---------- About: hero ---------- */
    .about-hero .eyebrow { animation: fade-up 0.5s var(--anim-ease-out) 0.1s both; }
    .about-hero h1       { animation: fade-up 0.6s var(--anim-ease-out) 0.2s both; }
    .about-hero .lead    { animation: fade-up 0.6s var(--anim-ease-out) 0.35s both; }
    .about-hero .btn-pill { animation: fade-up 0.6s var(--anim-ease-pop) 0.5s both; }

    /* portrait drops in like the home page flyer, then its tape goes on */
    .about-portrait {
        animation: pin-drop-alt 0.9s var(--anim-ease-out) 0.3s both;
    }

    .about-portrait::before {
        animation: tape-on 0.4s var(--anim-ease-out) 1s both;
    }

    .about-location {
        animation: fade-up 0.5s var(--anim-ease-out) 1.2s both;
    }

    /* polaroid tape (Giving back photo) goes on after it's revealed */
    .anim-ready .polaroid-photo.reveal::before { opacity: 0; }

    .anim-ready .polaroid-photo.is-visible::before {
        animation: tape-on 0.4s var(--anim-ease-out) 0.45s both;
    }

    /* quick facts numbers pop as they appear */
    .anim-ready .facts-grid > li.is-visible strong {
        animation: stamp-down 0.45s var(--anim-ease-pop) calc(var(--reveal-delay, 0ms) + 0.2s) both;
    }

    /* ---------- Portfolio: hero ---------- */
    .hero-card {
        animation: fade-up 0.6s var(--anim-ease-out) 0.1s both;
    }

    /* the two flyers slide out from behind the card */
    .peek-left {
        animation: peek-out-left 0.7s var(--anim-ease-out) 0.45s both;
    }

    .peek-right {
        animation: peek-out-right 0.7s var(--anim-ease-out) 0.6s both;
    }

    @keyframes peek-out-left {
        from { opacity: 0; translate: 90px 10px; rotate: 8deg; }
        to   { opacity: 1; translate: 0 0;     rotate: 0deg; }
    }

    @keyframes peek-out-right {
        from { opacity: 0; translate: -90px 10px; rotate: -7deg; }
        to   { opacity: 1; translate: 0 0;      rotate: 0deg; }
    }

    /* filter sticky notes keep their own hover/active transitions */
    .anim-ready .filter.reveal {
        transition:
            opacity 0.6s var(--anim-ease-out),
            translate 0.7s var(--anim-ease-out),
            rotate 0.7s var(--anim-ease-out),
            transform var(--duration) var(--ease),
            background var(--duration);
        transition-delay: var(--reveal-delay, 0ms), var(--reveal-delay, 0ms), var(--reveal-delay, 0ms), 0ms, 0ms;
    }

    /* push pins on the flyer prints press in after each print lands */
    .anim-ready .print.reveal::before { opacity: 0; }

    .anim-ready .print.is-visible::before {
        animation: tack-press 0.45s var(--anim-ease-pop) calc(var(--reveal-delay, 0ms) + 0.4s) both;
    }

    /* picking a filter reshuffles the cards that are showing */
    .just-filtered .print,
    .just-filtered .phone-row > li,
    .just-filtered .tile {
        animation: reshuffle 0.5s var(--anim-ease-pop) both;
        animation-delay: var(--shuffle-delay, 0ms);
    }

    @keyframes reshuffle {
        from { opacity: 0; translate: 0 24px; scale: 0.94; }
        to   { opacity: 1; translate: 0 0;    scale: 1; }
    }

    /* flyer close-up pops open */
    .lightbox[open] {
        animation: lightbox-pop 0.35s var(--anim-ease-pop);
    }

    .lightbox[open]::backdrop {
        animation: backdrop-fade 0.3s ease-out;
    }

    @keyframes lightbox-pop {
        from { opacity: 0; scale: 0.85; rotate: -2deg; }
        to   { opacity: 1; scale: 1;    rotate: 0deg; }
    }

    @keyframes backdrop-fade {
        from { opacity: 0; }
        to   { opacity: 1; }
    }

    /* ---------- Order: how-to notes ---------- */
    /* squiggle arrow between the sticky notes draws on after each note lands */
    .anim-ready .note-step.reveal::after {
        clip-path: inset(0 100% 0 0);
    }

    .anim-ready .note-step.is-visible::after {
        animation: arrow-draw 0.45s ease-out calc(var(--reveal-delay, 0ms) + 0.5s) both;
    }

    /* ---------- Order: the request form ---------- */
    /* each step slides in when you hit Next / Back */
    .notebook.is-enhanced .form-step.is-active {
        animation: step-in 0.4s var(--anim-ease-out);
    }

    @keyframes step-in {
        from { opacity: 0; translate: 28px 0; }
        to   { opacity: 1; translate: 0 0; }
    }

    /* the next tape strip in the progress bar sticks down */
    .progress li.is-active {
        animation: tape-stick 0.35s var(--anim-ease-pop);
    }

    @keyframes tape-stick {
        0%   { scale: 1 1; }
        40%  { scale: 1.15 1.4; }
        100% { scale: 1 1; }
    }

    /* notebook tape goes on after the notebook is revealed */
    .anim-ready .notebook.reveal::before { opacity: 0; }

    .anim-ready .notebook.is-visible::before {
        animation: tape-on-notebook 0.4s var(--anim-ease-out) 0.45s both;
    }

    @keyframes tape-on-notebook {
        from { opacity: 0;   scale: 0.2 1; }
        to   { opacity: 0.9; scale: 1 1; }
    }

    /* =====================================================
       7. TOUCH SCREENS
       Phones and tablets can't hover, so:
       - the card in the middle of the screen gets the
         "picked up" look (animations.js adds .in-focus)
       - tapping anything gives a quick press-down
       ===================================================== */
    @media (hover: none) {

        .tile,
        .polaroid,
        .price-card,
        .step,
        .pick-card,
        .note-step,
        .value-card,
        .print,
        .polaroid-photo {
            transition:
                transform 0.45s var(--anim-ease-pop),
                box-shadow 0.45s ease,
                scale 0.15s ease,
                opacity 0.6s var(--anim-ease-out),
                translate 0.7s var(--anim-ease-out),
                rotate 0.7s var(--anim-ease-out);
            transition-delay: 0ms, 0ms, 0ms, var(--reveal-delay, 0ms), var(--reveal-delay, 0ms), var(--reveal-delay, 0ms);
        }

        /* scroll-focus: the card you're looking at straightens and lifts */
        .tile.in-focus,
        .polaroid.in-focus,
        .price-card.in-focus,
        .step.in-focus,
        .pick-card.in-focus,
        .note-step.in-focus,
        .value-card.in-focus,
        .print.in-focus,
        .polaroid-photo.in-focus {
            transform: rotate(0deg) translateY(-6px);
            box-shadow: 4px 16px 28px rgba(0, 0, 0, 0.18);
        }

        /* tap: quick press-down on cards */
        .tile:active,
        .polaroid:active,
        .price-card:active,
        .pick-card:active,
        .note-step:active,
        .value-card:active,
        .print:active,
        .polaroid-photo:active {
            scale: 0.97;
        }

        /* tap: buttons push down, tape wiggles */
        .btn-tape:active::before {
            animation: tape-wiggle 0.5s ease-in-out;
        }

        .btn-pill,
        .hero-buttons .btn,
        .filter {
            transition-property: scale, transform, background, box-shadow;
            transition-duration: 0.15s, var(--duration), var(--duration), 0.2s;
        }

        .btn-pill:active,
        .hero-buttons .btn:active,
        .filter:active {
            scale: 0.94;
        }

        /* tap: scribble underline redraws */
        .tile-link:active {
            animation: scribble-redraw 0.45s ease-out;
        }

        /* sticky note and badge give a little wiggle when tapped */
        .hero-sticky:active,
        .stamp:active {
            animation: tap-wiggle 0.45s ease-in-out;
        }

        /* nav links: marker sweeps in while tapping */
        header nav ul a:active::after {
            scale: 1 1;
        }
    }

    @keyframes tap-wiggle {
        0%, 100% { rotate: 0deg; }
        30%      { rotate: 4deg; }
        65%      { rotate: -3deg; }
    }
}
