/* Movement on the customer pages. Load after the page's own sheets; pair with tmm-motion.js in <head>.
   One easing family, 250-600ms, transform and opacity only, so nothing shifts and everything stays clickable while it moves.
   Nothing here hides content by itself: load-in needs html.tmm-load (set by the script on a fresh visit only, removed when done), and
   scroll-in needs .tmm-rise (added by the script to sections below the fold). No script or reduced motion = the finished page. */
:root { --tmm-m-ease: cubic-bezier(.2, .7, .2, 1); --tmm-m-s: 280ms; --tmm-m-m: 420ms; --tmm-m-l: 560ms; --tmm-m-gap: 60ms; }
@keyframes tmm-in { from { opacity: 0; transform: translate3d(0, 14px, 0); } }
@keyframes tmm-in-lead { from { opacity: .4; transform: translate3d(0, 12px, 0); } }   /* headline and photo: painted from frame one, so LCP is not delayed */
@keyframes tmm-fade { from { opacity: 0; } }
@keyframes tmm-photo { from { opacity: .55; transform: scale(1.035); } }
@keyframes tmm-fwd { from { opacity: 0; transform: translate3d(16px, 0, 0); } }
@keyframes tmm-back { from { opacity: 0; transform: translate3d(-16px, 0, 0); } }
@keyframes tmm-bar { from { transform: translate3d(0, 100%, 0); } }
@keyframes tmm-price { from { opacity: .15; transform: translate3d(0, 8px, 0); } }
@keyframes tmm-old { to { opacity: 0; } }
@keyframes tmm-new { from { opacity: 0; transform: translate3d(0, 10px, 0); } }

@media (prefers-reduced-motion: no-preference) {
  /* ---- 1. Load-in, staggered. --i is the place in the queue. ---- */
  html.tmm-load :is(.site-header, .tmm-b-header) :is(.brand, .tmm-b-brand, .header-actions, .tmm-b-header__end) { animation: tmm-fade var(--tmm-m-m) var(--tmm-m-ease) backwards; }
  html.tmm-load :is(.home-hero__photo, .jm-photo) { animation: tmm-photo 600ms var(--tmm-m-ease) backwards; }
  html.tmm-load :is(.home-hero__title, .hero-h, .tmm-b-title h1) { animation: tmm-in-lead var(--tmm-m-l) var(--tmm-m-ease) backwards; }
  html.tmm-load :is(.home-hero__lede, .hero-sub, .tmm-b-title h1 ~ p, .home-reg, .plate-entry, #startBtn, .home-tiles > li, .trust-i, .tmm-b-title__form) { animation: tmm-in var(--tmm-m-l) var(--tmm-m-ease) backwards; animation-delay: calc(var(--i, 1) * var(--tmm-m-gap)); }
  html.tmm-load :is(.home-hero__lede, .hero-sub, .tmm-b-title h1 ~ p) { --i: 1; }
  html.tmm-load :is(.plate-entry, .tmm-b-title__form) { --i: 2; }
  html.tmm-load .home-reg { animation: none; }
  html.tmm-load .home-reg__plate-wrap { animation: tmm-in var(--tmm-m-l) var(--tmm-m-ease) backwards; animation-delay: calc(2 * var(--tmm-m-gap)); }
  html.tmm-load .home-reg__go, html.tmm-load #startBtn { animation: tmm-in var(--tmm-m-l) var(--tmm-m-ease) backwards; animation-delay: calc(3 * var(--tmm-m-gap)); }
  html.tmm-load :is(.home-tiles > li, .trust-i):nth-child(1) { --i: 4; } html.tmm-load :is(.home-tiles > li, .trust-i):nth-child(2) { --i: 5; }
  html.tmm-load :is(.home-tiles > li, .trust-i):nth-child(3) { --i: 6; } html.tmm-load :is(.home-tiles > li, .trust-i):nth-child(4) { --i: 7; }

  /* ---- 2. Sections on scroll ---- */
  .tmm-rise { opacity: 0; transform: translate3d(0, 20px, 0); }
  .tmm-rise.is-in { opacity: 1; transform: none; transition: opacity var(--tmm-m-l) var(--tmm-m-ease), transform var(--tmm-m-l) var(--tmm-m-ease); transition-delay: calc(var(--k, 0) * var(--tmm-m-gap)); }

  /* ---- 3. Order steps: new step comes from the side you are going to. Children move, never the step itself: the fixed
     action bar and the Direct Debit sheet are measured from the screen, and a moving ancestor would carry them. ---- */
  .screen-in { animation: none; }
  .screen-in .panel > :not(.row-btns--bar):not(.pay-actions) { animation: tmm-fwd var(--tmm-m-m) var(--tmm-m-ease) backwards; }
  html[data-tmm-dir="back"] .screen-in .panel > :not(.row-btns--bar):not(.pay-actions) { animation-name: tmm-back; }
  .screen-in .panel > :nth-child(2) { animation-delay: 45ms; } .screen-in .panel > :nth-child(3) { animation-delay: 90ms; } .screen-in .panel > :nth-child(4) { animation-delay: 135ms; } .screen-in .panel > :nth-child(n+5) { animation-delay: 170ms; }
  @media (max-width: 600px) {
    .screen-in .panel > :has(.dd-sched, .row-btns--bar):not(.row-btns--bar) { animation-name: tmm-fade !important; }
    .screen-in .row-btns--bar, .screen-in .pay-actions.row-btns--bar { animation: tmm-bar var(--tmm-m-m) var(--tmm-m-ease) backwards; }
  }

  /* ---- 4. Price reveal ---- */
  .amt-pop { animation: tmm-price 320ms var(--tmm-m-ease); }
  #svcTotalBar, #perNest { animation: tmm-in var(--tmm-m-m) var(--tmm-m-ease); }

  /* ---- 5. Menu, Direct Debit sheet, toast: both ways where the browser can, in only where it can't ---- */
  :is(.home-nav, .tmm-b-nav) { transition: opacity var(--tmm-m-s) var(--tmm-m-ease), transform var(--tmm-m-s) var(--tmm-m-ease), display var(--tmm-m-s) allow-discrete; }
  @media (max-width: 1023.98px) {
    body:not(.nav-open) :is(.home-nav, .tmm-b-nav) { opacity: 0; transform: translate3d(0, -10px, 0); }
    body.nav-open :is(.home-nav, .tmm-b-nav) { opacity: 1; transform: none; }
    @starting-style { body.nav-open :is(.home-nav, .tmm-b-nav) { opacity: 0; transform: translate3d(0, -10px, 0); } }
  }
  html[data-skin="jack"] body:not(.nav-open) :is(.home-nav, .tmm-b-nav) { opacity: 0; transform: translate3d(0, -10px, 0); }
  html[data-skin="jack"] body.nav-open :is(.home-nav, .tmm-b-nav) { opacity: 1; transform: none; }
  @starting-style { html[data-skin="jack"] body.nav-open :is(.home-nav, .tmm-b-nav) { opacity: 0; transform: translate3d(0, -10px, 0); } }
  @media (min-width: 0px) {
    .dd-sched-body { opacity: 0; transform: translate3d(0, -6px, 0); transition: opacity var(--tmm-m-s) var(--tmm-m-ease), transform var(--tmm-m-s) var(--tmm-m-ease), display var(--tmm-m-s) allow-discrete; }
    .dd-sched.is-open .dd-sched-body { opacity: 1; transform: none; transition-duration: 360ms; }
    @starting-style { .dd-sched.is-open .dd-sched-body { opacity: 0; transform: translate3d(0, -6px, 0); } }
    .dd-sched-chev { transition: transform var(--tmm-m-s) var(--tmm-m-ease); }
  }
  .dd-reveal.dd-in > * { animation-duration: var(--tmm-m-m); animation-timing-function: var(--tmm-m-ease); }
  .flow-toast { transition: transform 360ms var(--tmm-m-ease), opacity 360ms var(--tmm-m-ease); }

  /* ---- 6. Press ---- */
  :is(.tmm-btn, .btn, .cta, .home-tile, .keeper-c) { transition: transform 160ms var(--tmm-m-ease), background-color 200ms var(--tmm-m-ease), box-shadow 200ms var(--tmm-m-ease); }
  :is(.tmm-btn, .btn, .cta, .home-tile, .keeper-c):active:not(:disabled) { transform: scale(.975); transition-duration: 70ms; }

  /* ---- 7. Page to page (Chrome, Edge, Safari 18.2; others just load). The script skips it on Back, Forward and refresh. ---- */
  @view-transition { navigation: auto; }
  :is(.site-header, .tmm-b-header) { view-transition-name: tmm-header; }
  /* Home to the vehicle step: the plate travels, the rest of the page follows. */
  .home-hero .home-reg__plate-wrap, html.tmm-arrive #vehPlate > .reg-plate { view-transition-name: tmm-plate; }
  ::view-transition-group(tmm-plate) { animation-duration: 420ms; animation-timing-function: var(--tmm-m-ease); }
  ::view-transition-old(tmm-plate), ::view-transition-new(tmm-plate) { height: 100%; object-fit: contain; }
  ::view-transition-old(root) { animation: tmm-old 160ms var(--tmm-m-ease) both; }
  ::view-transition-new(root) { animation: tmm-new 320ms var(--tmm-m-ease) both; }
  ::view-transition-group(tmm-header) { animation-duration: 260ms; }
}
@media print { .tmm-rise { opacity: 1 !important; transform: none !important; } }
