/* ==========================================================================
   Roanoke Game Truck - motion layer (motion.css)
   Pairs with motion.js. See MOTION-NOTES.md for the selector/effect map.

   Rules of the road
   - Only transform / opacity / filter are animated. No layout properties.
   - Nothing is hidden unless JS is running: pre-animation states hang off
     html.js-motion (set by motion.js or the optional inline head snippet),
     or off attributes/classes that only motion.js adds ([data-rv], .rgt-*).
   - All real movement lives inside (prefers-reduced-motion: no-preference).
     Outside that block there are only instant state changes.
   ========================================================================== */

/* ---------- 1. Always-on states (instant, no animation) ------------------ */

/* Arcade button press. Red CTAs are matched by their inline "arcade shadow"
   colour, so no markup changes are needed. .rgt-btn is a manual hook. */
:is(a, button)[style*="#A50E14" i]:active,
.rgt-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #A50E14 !important; /* shadow collapses under the cap */
}

/* FAQ "+" turns into "x" while a question is open. */
[data-section] details[open] > summary > span[aria-hidden="true"] {
  transform: rotate(45deg);
}

/* Sticky booking bar. .rgt-bar is added by motion.js only. */
.rgt-bar:not(.is-up) {
  transform: translateY(130%);
  visibility: hidden;
}

/* Marquee option is inert unless motion is allowed (see section 9). */
.rgt-mq,
.rgt-mq-track { display: contents; }
.rgt-mq-track[aria-hidden="true"] { display: none; }

/* Never print or reduce-motion a hidden reveal state. */
@media print {
  [data-rv] { opacity: 1 !important; transform: none !important; }
  .rgt-bar { display: none !important; }
}

/* ==========================================================================
   Everything below only runs when the visitor allows motion
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {

  html { scroll-behavior: smooth; } /* in-page nav links glide, no scroll-jacking */

  /* Pause every looping animation in sections that are off screen. */
  .rgt-off,
  .rgt-off *,
  .rgt-off::before, .rgt-off::after,
  .rgt-off *::before, .rgt-off *::after {
    animation-play-state: paused !important;
  }

  /* ---------- 2. Hero ---------------------------------------------------- */

  /* Hex pattern: oversized so it can drift + parallax without showing edges */
  [data-section="hero"] > svg:first-of-type {
    top: -70px !important;
    right: auto !important;
    bottom: auto !important;
    left: -50px !important;
    width: calc(100% + 100px);
    height: calc(100% + 140px);
    transform: translate3d(0, var(--rgt-py, 0px), 0); /* --rgt-py set on scroll */
    animation: rgt-drift 24s ease-in-out infinite alternate;
    will-change: transform;
  }

  /* Gold swoosh: slow sideways sway + swell, anchored to the bottom edge */
  [data-section="hero"] > svg:nth-of-type(2) {
    left: -4% !important;
    width: 108% !important;
    transform-origin: 50% 100%;
    animation: rgt-wave 8s ease-in-out infinite alternate;
    will-change: transform;
  }

  /* Intro sequence (CSS only, so it still finishes if motion.js never loads).
     Skipped when the page had already painted before the class arrived. */
  html.js-motion:not(.js-late) [data-section="hero"] p:first-child,
  html.js-motion:not(.js-late) [data-section="hero"] h1 ~ :not(ul),
  html.js-motion:not(.js-late) [data-section="hero"] form {
    animation: rgt-rise .7s cubic-bezier(.2, .8, .2, 1) backwards;
  }
  html.js-motion:not(.js-late) [data-section="hero"] h1 ~ p   { animation-delay: .45s; }
  html.js-motion:not(.js-late) [data-section="hero"] h1 ~ div { animation-delay: .6s; }
  html.js-motion:not(.js-late) [data-section="hero"] form     { animation-delay: .75s; }

  /* Feature pills + rating badge pop in */
  html.js-motion:not(.js-late) [data-section="hero"] h1 ~ ul > li,
  html.js-motion:not(.js-late) [data-section="hero"] img + div {
    animation: rgt-pop .5s cubic-bezier(.34, 1.56, .64, 1) backwards;
    animation-delay: .8s;
  }
  html.js-motion:not(.js-late) [data-section="hero"] h1 ~ ul > li:nth-child(2) { animation-delay: .88s; }
  html.js-motion:not(.js-late) [data-section="hero"] h1 ~ ul > li:nth-child(3) { animation-delay: .96s; }
  html.js-motion:not(.js-late) [data-section="hero"] h1 ~ ul > li:nth-child(n+4) { animation-delay: 1.04s; }
  html.js-motion:not(.js-late) [data-section="hero"] img + div { animation-delay: 1.1s; }

  /* Headline: held back briefly until motion.js splits it into words.
     If motion.js never arrives the whole headline fades in by itself. */
  html.js-motion:not(.js-late) [data-section="hero"] h1:not(.rgt-split) {
    animation: rgt-fade .4s ease-out 1s backwards;
  }
  .rgt-w {
    display: inline-block;
    animation: rgt-word .55s cubic-bezier(.34, 1.56, .64, 1) backwards;
    animation-delay: calc(var(--i, 0) * 60ms + 60ms);
  }

  /* Photo: screen "power-on" once loaded, then a breathing cyan glow */
  .rgt-poweron { animation: rgt-power 1s ease-out; }
  .rgt-glow { position: relative; isolation: isolate; }
  .rgt-glow::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: 20px;
    box-shadow: 0 0 0 8px rgba(95, 212, 255, .35), 0 0 48px 12px rgba(95, 212, 255, .65);
    opacity: 0;
    pointer-events: none;
    animation: rgt-glow 3.2s ease-in-out 1.2s infinite alternate;
  }

  /* ---------- 3. Red arcade buttons -------------------------------------- */

  :is(a, button)[style*="#A50E14" i],
  .rgt-btn {
    transition: transform .12s ease-out;
  }

  /* Attention ring: hero primary CTA + "Book the Combo" only */
  [data-section="hero"] a[style*="#A50E14" i],
  [data-section="combo"] a[style*="#A50E14" i],
  [data-motion~="pulse"] {
    position: relative;
  }
  [data-section="hero"] a[style*="#A50E14" i]::after,
  [data-section="combo"] a[style*="#A50E14" i]::after,
  [data-motion~="pulse"]::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 0 0 3px #FFC72C;
    opacity: 0;
    pointer-events: none;
    animation: rgt-ring 2.8s ease-out 2.2s infinite;
  }
  [data-section="hero"] a[style*="#A50E14" i]:is(:hover, :focus-visible)::after,
  [data-section="combo"] a[style*="#A50E14" i]:is(:hover, :focus-visible)::after,
  [data-motion~="pulse"]:is(:hover, :focus-visible)::after {
    animation: none;
  }

  /* ---------- 4. FAQ ----------------------------------------------------- */

  [data-section] details > summary > span[aria-hidden="true"] {
    transition: transform .2s ease-out;
  }
  [data-section] details[open] > :not(summary) {
    animation: rgt-drop .3s ease-out;
  }

  /* Neon flicker: the gold "FAQ" word, or anything with data-motion="neon" */
  [data-section="faq"] h2 > span,
  [data-motion~="neon"] {
    text-shadow: 0 0 18px rgba(255, 199, 44, .45);
    animation: rgt-neon 7s linear 2s infinite;
  }

  /* ---------- 5. Game pills ---------------------------------------------- */

  .rgt-pills > span,
  .rgt-mq-track > span { transition: transform .15s ease-out; }

  /* Optional marquee (data-motion="marquee" on the pill strip) */
  .rgt-mq {
    display: flex;
    flex: 1 1 100%;
    min-width: 0;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
            mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
  }
  .rgt-mq-track,
  .rgt-mq-track[aria-hidden="true"] {
    display: flex;
    flex: none;
    gap: 14px;
    padding: 4px 14px 4px 0;
    white-space: nowrap;
    animation: rgt-mq 26s linear infinite;
  }
  .rgt-mq:hover .rgt-mq-track { animation-play-state: paused; }

  /* ---------- 6. Hover play (mouse / trackpad only) ---------------------- */
  @media (hover: hover) {

    :is(a, button)[style*="#A50E14" i]:hover:not(:active),
    .rgt-btn:hover:not(:active) {
      transform: translateY(-2px);
    }

    /* Cards lift */
    [data-section="packages"] article:not([data-section]),
    [data-section="reviews"] figure,
    [data-section="parties"] a:has(> img),
    [data-section="bounce"] a:has(> img) {
      transition: transform .28s cubic-bezier(.2, .8, .3, 1.4);
    }
    [data-section="packages"] article:not([data-section]):hover,
    [data-section="reviews"] figure:hover,
    [data-section="parties"] a:has(> img):hover,
    [data-section="bounce"] a:has(> img):hover {
      transform: translateY(-6px);
    }

    /* Photo inside party / bounce cards zooms (card already clips it) */
    [data-section="parties"] a > img,
    [data-section="bounce"] a > img {
      transition: transform .5s cubic-bezier(.2, .8, .2, 1);
    }
    [data-section="parties"] a:hover > img,
    [data-section="bounce"] a:hover > img {
      transform: scale(1.07);
    }

    /* Gallery: tilt + zoom */
    [data-section="gallery"] img {
      transition: transform .35s cubic-bezier(.2, .8, .3, 1.3), filter .35s ease-out;
    }
    [data-section="gallery"] img:hover {
      transform: scale(1.035) rotate(-1.4deg);
      filter: saturate(1.15) brightness(1.05);
      z-index: 1;
    }
    [data-section="gallery"] img:nth-child(even):hover {
      transform: scale(1.035) rotate(1.4deg);
    }

    /* Game pills wiggle */
    .rgt-pills > span:hover,
    .rgt-mq-track > span:hover {
      animation: rgt-wiggle .5s ease-in-out;
    }
  }

  /* ---------- 7. Sticky booking bar -------------------------------------- */

  .rgt-bar {
    transition: transform .45s cubic-bezier(.2, .8, .2, 1), visibility 0s linear 0s;
  }
  .rgt-bar:not(.is-up) {
    transition-delay: 0s, .45s; /* stay focusable-free only after it has left */
  }
  /* If the head snippet is used and motion.js never loads, the bar still
     arrives by itself after a short wait. */
  html.js-motion [data-section="stickybar"]:not(.rgt-bar) {
    animation: rgt-bar-in .45s ease-out 2.5s backwards;
  }

  /* ---------- 8. Scroll reveal (kept last so it wins over hover rules) ---- */

  html.js-motion [data-rv] {
    opacity: 0;
    transform: translate3d(0, 26px, 0);
  }
  html.js-motion [data-rv="pop"]  { transform: scale(.86); }
  html.js-motion [data-rv="left"] { transform: translate3d(-28px, 0, 0); }
  html.js-motion [data-rv].is-in {
    opacity: 1;
    transform: none;
    transition: opacity .5s ease-out, transform .65s cubic-bezier(.2, .9, .3, 1.25);
    transition-delay: calc(var(--rv-i, 0) * 80ms);
  }

  /* ---------- 9. Keyframes ----------------------------------------------- */

  @keyframes rgt-drift { from { translate: -40px 0; } to { translate: 40px 0; } }
  @keyframes rgt-wave {
    from { transform: translateX(-3%) scaleY(1); }
    to   { transform: translateX(3%) scaleY(1.22); }
  }
  @keyframes rgt-rise { from { opacity: 0; transform: translate3d(0, 22px, 0); } }
  @keyframes rgt-pop  { from { opacity: 0; transform: scale(.6); } }
  @keyframes rgt-fade { from { opacity: 0; } }
  @keyframes rgt-word {
    from { opacity: 0; transform: translate3d(0, .45em, 0) scale(.7) rotate(-5deg); }
  }
  @keyframes rgt-power {
    0%   { filter: brightness(.25) saturate(0); }
    16%  { filter: brightness(1.3) saturate(.5); }
    26%  { filter: brightness(.5) saturate(.3); }
    42%  { filter: brightness(1.18) saturate(1.15); }
    100% { filter: brightness(1) saturate(1); }
  }
  @keyframes rgt-glow { from { opacity: .15; } to { opacity: .9; } }
  @keyframes rgt-ring {
    0%        { opacity: .85; transform: scale(1); }
    45%, 100% { opacity: 0; transform: scale(1.16, 1.5); }
  }
  @keyframes rgt-drop { from { opacity: 0; transform: translate3d(0, -8px, 0); } }
  @keyframes rgt-neon {
    0%, 90%, 93%, 96%, 100% { opacity: 1; }
    91.5% { opacity: .5; }
    94.5% { opacity: .78; }
  }
  @keyframes rgt-wiggle {
    0%, 100% { transform: rotate(0) scale(1); }
    25% { transform: rotate(-5deg) scale(1.08); }
    60% { transform: rotate(4deg) scale(1.08); }
    85% { transform: rotate(-2deg) scale(1.04); }
  }
  @keyframes rgt-mq { to { transform: translate3d(-100%, 0, 0); } }
  @keyframes rgt-bar-in { from { transform: translateY(130%); } }
}
