/* ServiceSwiss — motion layer.
   Loaded by every page. All entrance motion is opt-in: motion.js marks the
   document, so a blocked or failed script leaves a static, fully readable
   page. Nothing below animates on load by itself. */

:root {
  --sw-out: cubic-bezier(.16, 1, .3, 1);
  --sw-in: cubic-bezier(.4, 0, .2, 1);
  --sw-step: 72ms;
}

/* ---------- cross-page continuity ---------- */

@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }

  .header {
    view-transition-name: sw-header;
  }

  h1 {
    view-transition-name: sw-title;
  }
}

/* ---------- focal sequence: clarity ----------
   The photograph resolves, then the copy comes into focus behind it. The
   individual `scale` longhand is used wherever the page also drives
   `transform` (homepage parallax), so the two compose. */

.sw-in {
  animation: sw-rise .74s var(--sw-out) backwards;
  animation-delay: calc(var(--sw-i, 0) * var(--sw-step));
}

@keyframes sw-rise {
  from {
    opacity: 0;
    transform: translate3d(0, 18px, 0);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* The title carries a view-transition-name, so the browser snapshots it at
   the instant the incoming page starts painting. Rising from a transparent
   frame would make the shared title morph from nothing, so it shifts into
   focus instead: the motion survives, the snapshot is always complete. */
.sw-blur {
  animation-name: sw-focus;
}

@keyframes sw-focus {
  from {
    transform: translate3d(0, 16px, 0);
    filter: blur(6px);
  }

  to {
    transform: none;
    filter: blur(0);
  }
}

html.sw-motion .hero-image {
  animation: sw-clarify 1.25s var(--sw-out) backwards 40ms;
}

@keyframes sw-clarify {
  from {
    scale: 1.06;
    filter: blur(7px) brightness(.8);
  }

  to {
    scale: 1;
    filter: blur(0) brightness(1);
  }
}

html.sw-motion .hero-visual img {
  animation: sw-curtain 1s var(--sw-out) backwards 140ms;
}

@keyframes sw-curtain {
  from {
    clip-path: inset(0 0 100% 0);
    scale: 1.05;
  }

  to {
    clip-path: inset(0 0 0 0);
    scale: 1;
  }
}

/* The strip under the hero confirms the claim beside the photograph: the
   marks land one after the other. */
html.sw-motion .trust-item {
  animation: sw-rise .55s var(--sw-out) backwards;
  animation-delay: calc(430ms + var(--sw-i, 0) * 70ms);
}

html.sw-motion .trust-item svg {
  animation: sw-mark .5s var(--sw-out) backwards;
  animation-delay: calc(450ms + var(--sw-i, 0) * 70ms);
}

@keyframes sw-mark {
  from {
    opacity: 0;
    scale: .7;
  }

  to {
    opacity: 1;
    scale: 1;
  }
}

/* ---------- light sweep: a polished surface ---------- */

.sw-sweep {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.sw-sweep::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-115%);
  background: linear-gradient(104deg, transparent 36%, #ffffff5c 50%, transparent 64%);
}

.sw-sweep:hover::after,
.sw-sweep:focus-visible::after {
  animation: sw-sweep .9s var(--sw-out);
}

@keyframes sw-sweep {
  0% {
    opacity: 0;
    transform: translateX(-115%);
  }

  22% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateX(115%);
  }
}

/* ---------- nav continuity ---------- */

.dropdown-menu {
  opacity: 0;
  visibility: hidden;
  translate: 0 -8px;
  transition: opacity .2s var(--sw-out), translate .2s var(--sw-out), visibility .2s;
}

.nav-item:hover .dropdown-menu,
.nav-item:focus-within .dropdown-menu,
.has-dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  translate: 0;
}

.dropdown-menu a {
  opacity: 0;
  transform: translate3d(-6px, 0, 0);
  transition: transform .22s var(--sw-out), opacity .22s var(--sw-out), background .15s, color .15s;
}

.nav-item:hover .dropdown-menu a,
.nav-item:focus-within .dropdown-menu a,
.has-dropdown.open .dropdown-menu a {
  opacity: 1;
  transform: none;
  transition-delay: calc(var(--sw-k, 0) * 28ms), calc(var(--sw-k, 0) * 28ms), 0s, 0s;
}

.nav-links.open {
  animation: sw-drop .3s var(--sw-out) backwards;
}

@keyframes sw-drop {
  from {
    opacity: 0;
    transform: translate3d(0, -10px, 0);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* The header gains weight once content slides beneath it. */
.header {
  border-bottom: 1px solid transparent;
  transition: box-shadow .25s var(--sw-in), border-color .25s var(--sw-in);
}

.header.is-scrolled {
  border-bottom-color: var(--line);
  box-shadow: 0 10px 28px -18px rgba(20, 30, 40, .45);
}

/* ---------- state changes ---------- */

details[open]> :not(summary) {
  animation: sw-open .4s var(--sw-out) backwards;
}

@keyframes sw-open {
  from {
    opacity: 0;
    transform: translate3d(0, -6px, 0);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

dialog[open] {
  animation: sw-dialog .34s var(--sw-out) backwards;
}

dialog[open]::backdrop {
  animation: sw-veil .34s var(--sw-out) backwards;
}

dialog[open] img {
  animation: sw-veil .5s var(--sw-out) backwards 60ms;
}

@keyframes sw-dialog {
  from {
    opacity: 0;
    transform: translateY(16px) scale(.97);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes sw-veil {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

html.sw-motion .preview.is-in {
  animation: sw-rise .6s var(--sw-out) backwards;
}

.feedback[data-state] {
  animation: sw-open .34s var(--sw-out) backwards;
}

/* ---------- sticky quote bar ----------
   Once the reader has left the hero, where its own call to action has
   already done its job, this keeps asking for a quote one thumb-reach
   away. It stays hidden until the page is scrolled, so the two buttons are
   never on screen together. Mobile only: on desktop the header button is
   permanently visible, so a fixed bar would just repeat it. */

.quote-bar {
  display: none;
}

@media (max-width:880px) {
  .quote-bar {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    padding: 10px 20px calc(10px + env(safe-area-inset-bottom));
    background: #ffffffed;
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
    transform: translateY(115%);
    transition: transform .32s var(--sw-out);
  }

  .quote-bar.is-visible {
    transform: translateY(0);
  }

  .quote-bar-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    min-height: 50px;
    padding: 13px 20px;
    border: 1px solid var(--blue);
    border-radius: 4px;
    background: var(--blue);
    color: white;
    font-weight: 600;
    font-size: 16px;
  }

  .quote-bar-cta:active {
    background: #084b8a;
  }

  .quote-bar-cta svg {
    width: 19px;
    height: 19px;
    flex-shrink: 0;
  }

  /* the bar must not cover the last lines of the page */
  body:has(.quote-bar.is-visible) .footer {
    padding-bottom: 96px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .quote-bar {
    transition: none;
  }
}

/* ---------- reduced motion: gentler, never blank ---------- */

@media (prefers-reduced-motion: reduce) {

  .sw-in,
  html.sw-motion .hero-image,
  html.sw-motion .hero-visual img,
  html.sw-motion .trust-item,
  html.sw-motion .trust-item svg,
  html.sw-motion .preview.is-in,
  .nav-links.open,
  details[open]> :not(summary),
  dialog[open],
  dialog[open]::backdrop,
  dialog[open] img,
  .feedback[data-state] {
    animation: none;
  }

  .sw-sweep:hover::after,
  .sw-sweep:focus-visible::after {
    animation: none;
    opacity: .4;
    transform: none;
  }
}