/* Straightshot: surface and card motion, layered on splash.css. Grain, livery stripes and the travelling shot. */

:root {
  /* Grain: asphalt aggregate (lightest pixel #323335) and poured concrete (darkest pixel #E1E3E5).
     Livery: the stripe device. Bars 3u, gaps 1u, tails cut at 10deg and stepped back. */
  --grain-asphalt: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='g' x='0' y='0' width='1' height='1' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='3' seed='8' stitchTiles='stitch' result='n'/%3E%3CfeColorMatrix in='n' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0'/%3E%3CfeComponentTransfer result='hi'%3E%3CfeFuncA type='discrete' tableValues='0 0 0 0 0 .05 .09 .12 .12 .12'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix in='n' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0'/%3E%3CfeComponentTransfer result='lo'%3E%3CfeFuncA type='discrete' tableValues='.5 .5 .5 .3 .1 0 0 0 0 0'/%3E%3C/feComponentTransfer%3E%3CfeMerge%3E%3CfeMergeNode in='lo'/%3E%3CfeMergeNode in='hi'/%3E%3C/feMerge%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23g)'/%3E%3C/svg%3E");
  --grain-concrete: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='g' x='0' y='0' width='1' height='1' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.6' numOctaves='3' seed='3' stitchTiles='stitch' result='n'/%3E%3CfeColorMatrix in='n' values='0 0 0 0 .086 0 0 0 0 .09 0 0 0 0 .102 1 0 0 0 0'/%3E%3CfeComponentTransfer result='lo'%3E%3CfeFuncA type='discrete' tableValues='.05 .05 .05 .035 .015 0 0 0 0 0'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix in='n' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0'/%3E%3CfeComponentTransfer result='hi'%3E%3CfeFuncA type='discrete' tableValues='0 0 0 0 0 .3 .6 .7 .7 .7'/%3E%3C/feComponentTransfer%3E%3CfeMerge%3E%3CfeMergeNode in='lo'/%3E%3CfeMergeNode in='hi'/%3E%3C/feMerge%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23g)'/%3E%3C/svg%3E");
  --stripes-chalk: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8000 44'%3E%3Cpath fill='%23fff' d='M26.12 0H8000V12H24ZM14.12 32H8000V44H12Z'/%3E%3Cpath fill='%23F0500F' d='M2.12 16H8000V28H0Z'/%3E%3C/svg%3E");
  --stripes-ink: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8000 44'%3E%3Cpath fill='%2316171A' d='M26.12 0H8000V12H24ZM14.12 32H8000V44H12Z'/%3E%3Cpath fill='%23F0500F' d='M2.12 16H8000V28H0Z'/%3E%3C/svg%3E");
  --stripe-h: 33px;
  --shot: var(--flare);  /* the travelling bar */
  --rise: 14px;          /* the timeline steps' own rise */
  --ease-shot: cubic-bezier(0.23, 1, 0.32, 1);
}

/* One progress value per card, 0 to 1. 1 is the finished card and the default, so without scroll-timeline support,
   or with reduced motion, everything simply shows. Inherited so pseudo-elements and content can read it. */
@property --card-p { syntax: "<number>"; inherits: true; initial-value: 1; }
@keyframes card-in { from { --card-p: 0; } to { --card-p: 1; } }

/* ================= Grain: the grounds become the materials they are named after ================= */
.hero, .equipment { background-image: var(--grain-concrete); }
.proof, .how, .quote { background-image: var(--grain-asphalt); }
/* Stat cells go clear so the bar's grain runs through them; their dividers become hard box-shadows. */
.proof__list { background: none; }
.stat { background: none; }
.stat + .stat { box-shadow: 0 -1px var(--tarmac); }
@media (min-width: 720px) { .stat + .stat { box-shadow: -1px 0 var(--tarmac); } }
@media (min-width: 1100px) { .stat + .stat { box-shadow: none; } }
/* The small Flare time in the log is only just AA on plain Asphalt, so over grain it sits on a solid label. */
.route__log { width: fit-content; margin-left: -8px; padding: 3px 8px; background: var(--asphalt); }

/* ================= Livery: the truck's stripes, cut-end bands and index tabs ================= */
/* Hero: the stripes run from the copy's edge, under the buttons, and tuck in behind the photo cut. */
.hero__copy::after {
  content: ""; display: block; height: var(--stripe-h); margin: clamp(32px, 4vw, 48px) -50vw 0 0;
  background: var(--stripes-ink) 0 0 / auto 100% no-repeat;
}
@media (max-width: 719px) { .hero__copy::after { height: 22px; margin-top: 14px; } } /* phones: a slimmer band so the rig shows sooner */
.hero__photo { z-index: 1; }
/* The quote section wears it along its top edge: tails at the content edge, bars off the right.
   The stripes appear twice on the page: here and in the hero. */
.quote { position: relative; }
.quote::before {
  content: ""; position: absolute; top: clamp(24px, 3vw, 40px); left: var(--m); right: 0; height: var(--stripe-h);
  background: var(--stripes-chalk) 0 0 / auto 100% no-repeat;
  clip-path: inset(0 calc((1 - var(--card-p)) * 100%) 0 0); /* painted on from the tails as the section arrives */
}
/* Service rows: a Flare index tab hangs from each row's top rule, its tail cut at 10deg like the stripes. */
.svc { counter-reset: svc; }
.svc__item { position: relative; counter-increment: svc; }
.svc__item::before {
  --h: 24px;
  content: counter(svc, decimal-leading-zero) / ""; position: absolute; top: 0; right: 0;
  height: var(--h); padding: 0 10px 0 calc(10px + var(--h) * tan(var(--slant)));
  background: var(--flare); color: var(--asphalt);
  font: 700 .75rem/var(--h) var(--font-mono); letter-spacing: .08em;
  clip-path: polygon(calc(var(--h) * tan(var(--slant))) 0, 100% 0, 100% 100%, 0 100%);
}
/* Spec table: the header is an Asphalt band with a 10deg cut end; on phones each card's trailer name sits on one. */
@media (min-width: 860px) {
  .spec thead th { padding: 12px 16px; border-bottom: 0; background: var(--asphalt); color: var(--chalk); }
  .spec thead th:last-child { clip-path: polygon(0 0, 100% 0, calc(100% - 44px * tan(var(--slant))) 100%, 0 100%); }
  .spec :is(tbody th, td) { padding-left: 16px; }
}
@media (max-width: 859px) {
  .spec tbody tr { padding-top: 0; }
  .spec tbody th {
    margin: 0 -16px 4px; padding: 13px 16px 12px; border-bottom: 0; background: var(--asphalt); color: var(--chalk);
    clip-path: polygon(0 0, 100% 0, calc(100% - 48px * tan(var(--slant))) 100%, 0 100%);
  }
}

/* ================= Shot: the mark's bar, nose first, runs along each group's rule and leaves ================= */
:where(.svc, .ranges, .drivers, .map, .spec thead, .spec tbody tr) { position: relative; }
:where(.svc, .ranges, .drivers, .map)::before, .spec thead::after, .spec tbody tr::after {
  content: ""; position: absolute; z-index: 1; left: 0; right: 0; top: 0; height: 5px;
  background: var(--shot); pointer-events: none;
  --l: min(40%, 240px);                         /* shot length */
  --x: calc(var(--card-p) * (100% + var(--l))); /* nose tip: from the left edge to one length past the right */
  clip-path: polygon(calc(var(--x) - var(--l)) 0, calc(var(--x) - 2.5px) 0, var(--x) 50%, calc(var(--x) - 2.5px) 100%, calc(var(--x) - var(--l)) 100%);
}
:where(.svc, .ranges)::before { top: -4px; }     /* centred on the 3px rule */
.spec thead::after { top: auto; bottom: -4px; }  /* along the foot of the header band */
@media (min-width: 860px) { .spec tbody tr::after { display: none; } } /* rows share the header's shot */
/* Rows land behind the shot with the timeline steps' fade and rise. The big panels (drivers, map) hold still: only
   the shot crosses them. Stat cells and the quote form have no entrance: the stats sit at the fold and menu jumps land
   on the form, so either would show half-drawn. */
:where(.svc__item, .spec tbody tr, .ranges > div) {
  opacity: var(--card-p);
  translate: 0 calc((1 - var(--card-p)) * var(--rise));
}

/* ================= Motion: everything that moves is in here ================= */
@keyframes livery-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: no-preference) {
  /* Hero livery is on screen at load, so it runs on the clock: painted on from the tails, once. */
  .hero__copy::after { animation: livery-in 900ms var(--ease-shot) 200ms both; }

  @supports (animation-timeline: view()) {
    /* Rows and panels: each on its own view timeline, finishing in the bottom 240-280px of the screen. */
    :where(.svc__item, .spec tbody tr, .ranges > div) { animation: card-in linear both; animation-timeline: view(); animation-range: cover 40px cover 240px; }
    :where(.drivers, .map) { animation: card-in linear both; animation-timeline: view(); animation-range: cover 40px cover 280px; }
    /* The shot runs on its group's timeline, a little ahead of the first row. */
    :where(.svc, .ranges, .spec thead) { view-timeline: --g block; }
    :where(.svc, .ranges)::before, .spec thead::after { animation: card-in linear both; animation-timeline: --g; animation-range: cover 0px cover 260px; }
    /* Section livery: painted on as the section's top edge comes up the screen. */
    .quote::before { animation: card-in linear both; animation-timeline: view(); animation-range: cover 0px cover 380px; }
  }
}
