/* Native cross-document transitions: browsers without support ignore this rule. */
@view-transition {
  navigation: auto;
}

:root {
  --ffgf-transition-header-height: 80px;
}

/* The shared bar gets its own snapshot, so the page content can change beneath it. */
.ffgf-site-header {
  view-transition-name: ffgf-header;
}

/* A small brand signal, never a loading indicator and never an interactive layer. */
.ffgf-transition-line {
  position: fixed;
  z-index: 2500;
  top: var(--ffgf-transition-header-height);
  left: 0;
  width: 100%;
  height: 2px;
  pointer-events: none !important;
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left center;
  background: linear-gradient(90deg, #d4202c 0%, #ee4a55 62%, rgba(238, 74, 85, .18) 100%);
  box-shadow: 0 0 14px rgba(212, 32, 44, .32);
  will-change: opacity, transform;
  view-transition-name: ffgf-signature-line;
}

.ffgf-page-transitioning .ffgf-transition-line {
  animation: ffgf-signature-line-in 230ms cubic-bezier(.2, .8, .2, 1) both;
}

::view-transition-old(root) {
  animation: ffgf-page-out 180ms ease-in both;
}

::view-transition-new(root) {
  animation: ffgf-page-in 300ms cubic-bezier(.2, .8, .2, 1) both;
}

/* Keep the common header calm while root content fades and moves. */
::view-transition-group(ffgf-header) {
  animation-duration: 180ms;
  animation-timing-function: ease-out;
}

/* The completed line quietly clears away with the outgoing document. */
::view-transition-old(ffgf-signature-line) {
  animation: ffgf-signature-line-out 220ms ease-out both;
  transform-origin: left center;
}

::view-transition-new(ffgf-signature-line) {
  animation: none;
  opacity: 0;
}

/*
 * The history card becomes a shared element only for its own, intentional click.
 * Keeping the name opt-in prevents unrelated page changes from animating a card.
 */
html.ffgf-history-transitioning .ffgf-history-card,
html.ffgf-history-transition-target .ffgf-history-hero {
  view-transition-name: ffgf-history-hero;
}

::view-transition-group(ffgf-history-hero) {
  animation-duration: 500ms;
  animation-timing-function: cubic-bezier(.2, .8, .2, 1);
}

::view-transition-image-pair(ffgf-history-hero) {
  isolation: isolate;
}

::view-transition-old(ffgf-history-hero) {
  animation: ffgf-history-card-out 440ms cubic-bezier(.2, .8, .2, 1) both;
  mix-blend-mode: normal;
}

::view-transition-new(ffgf-history-hero) {
  animation: ffgf-history-hero-in 500ms cubic-bezier(.2, .8, .2, 1) both;
  mix-blend-mode: normal;
}

/* The Fuhrpark card follows the same opt-in rule, with its own transition identity. */
html.ffgf-fleet-transitioning .ffgf-fleet-transition-card,
html.ffgf-fleet-transition-target .ffgf-fleet-hero {
  view-transition-name: ffgf-fleet-shell;
}

::view-transition-group(ffgf-fleet-shell) {
  animation-duration: 480ms;
  animation-timing-function: cubic-bezier(.2, .8, .2, 1);
}

::view-transition-image-pair(ffgf-fleet-shell) {
  isolation: isolate;
}

::view-transition-old(ffgf-fleet-shell) {
  animation: ffgf-fleet-card-out 420ms cubic-bezier(.2, .8, .2, 1) both;
  mix-blend-mode: normal;
}

::view-transition-new(ffgf-fleet-shell) {
  animation: ffgf-fleet-hero-in 480ms cubic-bezier(.2, .8, .2, 1) both;
  mix-blend-mode: normal;
}

@keyframes ffgf-page-out {
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}

@keyframes ffgf-page-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@keyframes ffgf-signature-line-in {
  0% {
    opacity: 0;
    transform: scaleX(0);
  }
  16% {
    opacity: .95;
  }
  100% {
    opacity: 1;
    transform: scaleX(1);
  }
}

@keyframes ffgf-signature-line-out {
  from {
    opacity: 1;
    clip-path: inset(0 0 0 0);
  }
  to {
    opacity: 0;
    clip-path: inset(0 0 0 100%);
  }
}

@keyframes ffgf-history-card-out {
  0%, 56% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes ffgf-history-hero-in {
  0%, 18% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes ffgf-fleet-card-out {
  0%, 54% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes ffgf-fleet-hero-in {
  0%, 16% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@media (min-width: 901px) {
  :root {
    --ffgf-transition-header-height: 108px;
  }

  :root.ffgf-header-compact {
    --ffgf-transition-header-height: 84px;
  }
}

@media (max-width: 900px) {
  :root.ffgf-header-compact {
    --ffgf-transition-header-height: 68px;
  }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation-duration: .01ms !important;
  }

  .ffgf-transition-line {
    display: none;
  }
}

@media (max-width: 700px) {
  html.ffgf-history-transitioning .ffgf-history-card,
  html.ffgf-history-transition-target .ffgf-history-hero,
  html.ffgf-fleet-transitioning .ffgf-fleet-transition-card,
  html.ffgf-fleet-transition-target .ffgf-fleet-hero {
    view-transition-name: none;
  }
}
