/* How one screen gives way to the next.

   Travel. Screens move the way the story does: going on, the screen you're leaving lifts off the top
   while the next rises from below; going back, the other way. The move starts slowly, and in that
   beat everything on the old screen leaves, piece by piece (its exit). The new screen's own
   entrance plays as it arrives.

   Handoffs. Four changes aren't a travel, because the two screens share something:
     film-handoff        the opening film dissolves into the kickoff stadium
     field-handoff       kickoff, games and scoreboard sit in one stadium, so they swap in place
     attendance-handoff  kickoff to games, going on: the field doesn't even fade
     moment-handoff      a filmed cut covers the screen you're leaving
   app.js sets these on the frame, with .story-back while the story is going backwards.

   Exits. Each screen's pieces leave when it stops being .active. They're written against
   :not(.active), not .is-exiting, so a piece that has left stays gone if the viewer moves on again
   mid-travel. slides.js starts each exit from wherever the piece had got to, so leaving a screen
   halfway through its entrance is smooth too. Two rules that follow from how it does that:
   - a piece that has an entrance animation needs an exit animation (not a transition), or it is
     held as it was until the screen comes back;
   - .fx pieces take theirs from --despawn, --od (how long) and --o (how late), as in slides.css.
   --away is which way a leaving piece heads (-1 up, 1 down) and --from which side an arriving one
   comes from, so pieces move with the travel. Exits last about .3s: by then the screen is on its way. */

.football .slide {--away:1;opacity:0;transition:none}
.football .slide.before {--away:-1}
.football .slide.active {opacity:1}
.football .slide:not(.active) {pointer-events:none}
.football.field-handoff .slide[data-shared-field] {transform:none}
/* These are shown by rules that outlast their screen. Off screen they follow it instead. */
.football .slide:not(.active) :is(.moment-content,.moment-cut),
.football .s-pack.is-revealed:not(.active) .pack-card-flight {visibility:inherit}

@media (prefers-reduced-motion:no-preference) {
  /* ---------- Travel ---------- */
  .football .slide {transition:transform .6s cubic-bezier(.7,0,.2,1),opacity 0s .6s,visibility 0s .6s}
  .football .slide.active {transition-delay:0s}
  .football.snap .slide {transition:none}

  /* ---------- Handoffs ---------- */
  .football.film-handoff .intro-film:not(.active) {
    transform:none;
    transition:opacity .34s ease,visibility 0s .34s;
  }
  .football.film-handoff .kickoff.active {
    transform:none;
    transition:none;
    animation:kickoff-handoff .32s .14s ease both;
  }
  @keyframes kickoff-handoff {from {opacity:0}}

  .football.field-handoff .slide[data-shared-field] {transition:opacity 0s .6s,visibility 0s .6s}
  .football.field-handoff .slide[data-shared-field].active {transition:none}
  .football.attendance-handoff .s-games.active {
    animation:attendance-field-in .46s .2s cubic-bezier(.21,.67,.3,1) both;
  }
  @keyframes attendance-field-in {from {opacity:0;transform:translateY(1.8cqh)}}

  /* The cut fades up over the screen being left, which stays put underneath it */
  .football .slide.active.has-current-cut {transition:opacity .22s ease-out .1s}
  .football.moment-handoff .slide.is-exiting {transform:none;transition:opacity 0s .5s,visibility 0s .5s}

  /* ---------- Exits ---------- */
  @keyframes story-lift {to {opacity:0;translate:0 calc(var(--away) * 5cqh)}}
  /* for pieces placed with translate, which the one above would move off their mark */
  @keyframes story-lift-t {to {opacity:0;transform:translateY(calc(var(--away) * 5cqh))}}
  @keyframes story-fade-out {to {opacity:0}}
  @keyframes story-shrink {to {opacity:0;scale:.92}}

  /* Kickoff: the words go, and the pass carries on past the camera */
  .kickoff .kickoff-cue {--despawn:story-lift;--od:.14s}
  .kickoff .kickoff-title-hit {--despawn:kickoff-hit-out;--od:.2s}
  .kickoff .kickoff-title-lead {--despawn:story-lift;--od:.17s}
  .kickoff .pigskin {--despawn:kickoff-pass-out;--od:.4s}
  @keyframes kickoff-hit-out {to {opacity:0;scale:1.2}}
  @keyframes kickoff-pass-out {
    68% {opacity:1}
    to {opacity:0;translate:calc(-50% + 36cqw) calc(-50% - 5cqh);rotate:-24deg;scale:2.5}
  }
  /* The drawn ball is in .bg, whose animations only run while a slide is up (styles.css) */
  .football .has-kickoff-scene:not(.active) .bg .kickoff-scene {
    animation:kickoff-ball-out .4s cubic-bezier(.5,0,.85,.55) both;
    animation-play-state:running;
  }
  @keyframes kickoff-ball-out {
    from {visibility:visible;opacity:1}
    68% {opacity:1}
    to {visibility:hidden;opacity:0;transform:translate(36cqw,-5cqh) scale(2.5)}
  }

  /* Games: the heading lifts and the schedule parts, odd rows left and even rows right */
  .s-games .attendance-intro-word {--despawn:story-lift;--od:.24s}
  .s-games :is(.attendance-total > .fx,.attendance-label) {--despawn:story-lift;--od:.26s}
  .s-games .attendance-total > .wheel {--despawn:none}
  .s-games .match-row {--despawn:match-row-out;--od:.32s;--row-side:-1}
  .s-games .match-row:nth-child(even) {--row-side:1}
  @keyframes match-row-out {to {opacity:0;translate:calc(var(--row-side) * 38cqw) 0}}
  /* On the way to the scoreboard the camera pushes on through it */
  .football.field-handoff[data-active-slide~="scoreboard"] .s-games:not(.active) .body {
    animation:games-push-through .5s cubic-bezier(.4,0,.75,.6) both;
  }
  @keyframes games-push-through {to {scale:1.14}}

  /* Scoreboard: the board powers down, the crowd sits, and going back the camera pulls away */
  .scoreboard:not(.active) .scoreboard-screen {animation:scoreboard-power-off .3s linear both}
  @keyframes scoreboard-power-off {
    18% {opacity:.25}
    30% {opacity:.85}
    52% {opacity:.15}
    66% {opacity:.5}
    to {opacity:0}
  }
  .scoreboard:not(.active) :is(.scoreboard-optics,.scoreboard-confetti) {animation:story-fade-out .24s ease-in both}
  .scoreboard:not(.active) .scoreboard-crowd > div {animation:scoreboard-crowd-sit .34s var(--exit) both}
  .scoreboard:not(.active) .scoreboard-crowd-back {animation-delay:.05s}
  @keyframes scoreboard-crowd-sit {to {translate:0 9cqh}}
  .football.field-handoff .scoreboard:not(.active) .scoreboard-rig {
    animation:scoreboard-pull-away .46s cubic-bezier(.4,0,.6,1) both;
  }
  @keyframes scoreboard-pull-away {
    55% {opacity:1}
    to {transform:scale(.86);filter:blur(5px);opacity:0}
  }

  /* Card pack: the sealed pack is tossed aside; an opened hand of cards is thrown, top card first */
  .s-pack:not(.active) .pack-heading {animation:story-lift .26s var(--exit) both}
  .s-pack:not(.active) :is(.pack-instruction,.pack-studio) {animation:story-fade-out .18s ease-in both}
  .s-pack:not(.active) :is(.pack-film,.pack-wrapper) {animation:pack-toss .4s var(--exit) .03s both}
  @keyframes pack-toss {
    to {opacity:0;transform:translateY(calc(var(--away) * 13cqh)) rotate(calc(var(--away) * -9deg)) scale(.86)}
  }
  .s-pack.is-revealed:not(.active) .pack-card-mount {
    animation:pack-card-toss .38s var(--exit) calc(.03s + var(--card-distance,0) * .045s) both;
  }
  @keyframes pack-card-toss {
    to {
      opacity:0;
      translate:calc(var(--card-offset,0) * 30%) calc(var(--away) * 26cqh);
      rotate:calc(var(--card-offset,0) * 15deg + var(--away) * 6deg);
      scale:.9;
    }
  }
  .s-pack:not(.active) .pack-actions {animation:story-lift-t .24s var(--exit) both}

  /* Jersey: the spotlights swing off and the case drops back into the dark */
  .s-jersey:not(.active) .jersey-spotlights i {animation:jersey-light-out .3s var(--exit) both}
  .s-jersey:not(.active) .jersey-spotlights i + i {animation-delay:.05s}
  @keyframes jersey-light-out {to {opacity:0;transform:rotate(-13deg)}}
  .s-jersey:not(.active) .jersey-stage > h2 {animation:story-lift-t .24s var(--exit) both}
  .s-jersey:not(.active) .jersey-tap {animation:story-fade-out .16s ease-in both}
  .s-jersey:not(.active) .jersey-case {animation:jersey-case-out .32s var(--exit) .04s both}
  @keyframes jersey-case-out {to {opacity:0;transform:translateY(calc(var(--away) * 4cqh)) scale(.9)}}
  .s-jersey:not(.active) .jersey-story {animation:story-shrink .3s var(--exit) both}
  .s-jersey:not(.active) .jersey-footer {animation:story-lift-t .22s var(--exit) both}

  /* The featured game: the title lifts, the score card tips away and the team names part */
  .s-moment .rivalry-heading {--despawn:story-lift;--od:.24s}
  .s-moment .rivalry-media {--despawn:rivalry-media-out;--od:.3s}
  @keyframes rivalry-media-out {
    to {opacity:0;transform:perspective(900px) rotateX(calc(var(--away) * -40deg)) scale(.92)}
  }
  .s-moment:not(.active) .rivalry-score-preview {animation:story-fade-out .18s ease-in both}
  .s-moment:not(.active) .rivalry-team-labels span {animation:rivalry-label-out .28s var(--exit) .04s both}
  .rivalry-team-labels span:first-child {--label-side:-1}
  @keyframes rivalry-label-out {to {opacity:0;translate:calc(var(--label-side,1) * 12cqw) 0}}
  .s-moment:not(.active) .rivalry-scene {animation:rivalry-scene-out .4s var(--exit) both}
  .rivalry-scene {transform-origin:50% 78%}
  @keyframes rivalry-scene-out {to {opacity:0;scale:1.06}}

  /* Fan type: the result leaves in reading order, the medal turning away; a wheel still in play sinks */
  .football .s-fan:not(.active) .fan-result > :is(.eyebrow,h2,.fan-copy,.fan-share-button) {
    animation:story-lift .26s var(--exit) both;
  }
  .football .s-fan:not(.active) .fan-result > .fan-medallion {animation:fan-medallion-out .3s var(--exit) .05s both}
  .football .s-fan:not(.active) .fan-result > h2 {animation-delay:.025s}
  .football .s-fan:not(.active) .fan-result > .fan-copy {animation-delay:.075s}
  .football .s-fan:not(.active) .fan-result > .fan-share-button {animation-delay:.1s}
  @keyframes fan-medallion-out {to {opacity:0;transform:perspective(440px) rotateY(55deg) scale(.8)}}
  .s-fan:not(.active) .fan-prompt {animation:story-lift-t .24s var(--exit) both}
  .s-fan:not(.active) :is(.fan-wheel-window,.fan-pointer) {animation:fan-wheel-out .34s var(--exit) both}
  @keyframes fan-wheel-out {to {opacity:0;transform:translateY(9cqh)}}

  /* Coach: a message that was playing stays on screen, paused, and travels off with it */
  .s-coach:not(.active) .coach-portrait {animation:coach-photo-out .28s var(--exit) both}
  @keyframes coach-photo-out {to {opacity:0;scale:.86}}
  .s-coach:not(.active) h2 {animation:story-fade-out .18s ease-in both}
  .s-coach:not(.active) .coach-call {
    translate:0 calc(var(--away) * 3cqh);
    transition:opacity .22s ease,translate .3s var(--exit),visibility 0s .3s;
  }
  .s-coach:not(.active) .coach-playback {transition:opacity .22s ease,visibility 0s .22s}
  .s-coach.was-watching:not(.active) .coach-video,
  .s-coach.was-watching:not(.active)::after {opacity:1}
  .s-coach.was-watching:not(.active) .coach-portrait {visibility:hidden}
  .s-coach.active:not(.has-video-started) .coach-video {transition:none}   /* gone before the screen is back */

  /* ---------- Entrances the travel needs ---------- */
  /* These screens used to fade up whole. Now their pieces arrive from the side the screen comes from. */
  .football .s-pack,.football .s-jersey {--from:1}
  .football.story-back :is(.s-pack,.s-jersey) {--from:-1}
  @keyframes story-arrive {from {opacity:0;transform:translateY(calc(var(--from) * 3.5cqh))}}

  .s-pack.active:not(.is-opening,.is-revealed) .pack-heading {
    animation:story-arrive .5s cubic-bezier(.2,.8,.2,1) .16s backwards;
  }
  .s-pack.active:not(.is-opening,.is-revealed) .pack-instruction {animation:story-arrive .45s ease-out .62s backwards}
  .football .s-pack.active.has-pack-film:not(.is-opening,.is-revealed) .pack-film {
    animation:pack-arrive .78s cubic-bezier(.22,.9,.28,1) .12s backwards,
              pack-bob 3.6s ease-in-out .9s infinite,pack-film-rattle 6.4s ease-in-out .9s infinite;
  }
  .football .s-pack.active:not(.has-pack-film,.is-opening,.is-revealed) .pack-wrapper {
    animation:pack-arrive-scale .6s cubic-bezier(.22,.9,.28,1.2) .12s backwards,
              pack-bob 3.6s ease-in-out .8s infinite,pack-rattle 6.5s ease-in-out .8s infinite;
  }
  .football .s-pack.active:not(.is-opening,.is-revealed) .pack-film::after,
  .football .s-pack.active:not(.has-pack-film,.is-opening,.is-revealed) .pack-shell::after {animation-delay:.72s}
  @keyframes pack-arrive {
    from {opacity:0;transform:translateY(calc(var(--from) * 20cqh)) rotate(calc(var(--from) * 9deg)) scale(.8)}
    55% {opacity:1;transform:translateY(calc(var(--from) * -1.2cqh)) rotate(calc(var(--from) * -1.6deg)) scale(1.03)}
    to {transform:none}
  }
  @keyframes pack-arrive-scale {from {opacity:0;scale:.78}}
  /* Coming back to cards already pulled: they're dealt in again, top card first */
  .s-pack.active.is-returning .pack-card-mount {
    animation:pack-card-deal .56s cubic-bezier(.2,.85,.3,1.08) calc(.14s + var(--card-distance,0) * .07s) backwards;
  }
  @keyframes pack-card-deal {
    from {
      opacity:0;
      translate:calc(var(--card-offset,0) * 5.75%) calc(var(--from) * 24cqh);
      rotate:calc(var(--card-offset,0) * 9deg + var(--from) * 7deg);
    }
  }
  .s-pack.active.is-returning .pack-actions {animation:story-arrive .42s ease-out .4s backwards}
  /* ...and to a jersey already made */
  .s-jersey.active.is-jersey-returning :is(.jersey-case,.jersey-story) {
    animation:jersey-return .5s cubic-bezier(.2,.8,.2,1) .14s backwards;
  }
  .s-jersey.active.is-jersey-returning :is(.jersey-stage > h2,.jersey-footer) {
    animation:story-arrive .45s cubic-bezier(.2,.8,.2,1) .26s backwards;
  }
  @keyframes jersey-return {from {opacity:0;scale:.92}}
}
