:root {
  --motion-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-reduced-motion: reduce) {
  .hero__video {
    visibility: hidden;
  }
}

@media (prefers-reduced-motion: no-preference) {
  /* A moving lip gives the frosted panel an underside as it unrolls.
     The logo knockout and mobile text travel inside the same reveal. */
  .hero__panel {
    animation: hero-unroll 1000ms cubic-bezier(0.22, 0.75, 0.28, 1) 360ms backwards;
  }

  .hero__panel::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background: linear-gradient(90deg,
      transparent, rgb(9 42 61 / 0.10) 33%, rgb(9 42 61 / 0.22) 57%,
      rgb(255 255 255 / 0.65) 87%, rgb(9 42 61 / 0.26))
      right center / clamp(19px, 4vw, 54px) 100% no-repeat;
    animation:
      hero-unroll-lip 1000ms cubic-bezier(0.22, 0.75, 0.28, 1) 360ms backwards,
      hero-unroll-shading 1000ms linear 360ms backwards;
  }

  .hero__slide {
    transform: translateY(-8px);
    transition: opacity 320ms ease, transform 420ms var(--motion-out);
  }

  .hero__slide.is-active {
    transform: translateY(0);
    transition: opacity 520ms ease 100ms, transform 720ms var(--motion-out) 100ms;
  }

  .hero__slide.is-active > * {
    animation: settle 680ms var(--motion-out) 140ms backwards;
  }

  .hero__slide:first-child > * {
    animation-delay: 520ms;
  }

  .page-hero__wave {
    animation: panel-sweep 800ms var(--motion-out) 460ms backwards;
  }

  .page-hero__mark {
    animation: settle 680ms var(--motion-out) 690ms backwards;
  }

  .site-header__logo,
  .site-header__contact > * {
    animation: settle 520ms var(--motion-out) var(--reveal-delay, 0ms) backwards;
  }

  .site-header__logo {
    --motion-from-x: -12px;
    --motion-from-y: 0px;
  }

  .site-header__contact > * {
    --motion-from-x: 12px;
    --motion-from-y: 0px;
    --reveal-delay: 80ms;
  }

  .site-header__contact > .btn {
    --reveal-delay: 160ms;
  }

  .motion-awaiting:not(:focus-within) {
    opacity: 0;
  }

  :is(.products__label, .cases__label, .site-footer__logo, .site-footer__address).motion-settle {
    --motion-from-x: -14px;
    --motion-from-y: 5px;
  }

  :is(.band .btn, .cases__carousel, .site-footer__elfa).motion-settle {
    --motion-from-x: 14px;
    --motion-from-y: 5px;
  }

  /* These classes are added once, as content reaches the viewport. */
  .motion-settle {
    animation: settle 620ms var(--motion-out) var(--reveal-delay, 0ms) backwards;
  }

  .stats__item.motion-settle {
    animation-duration: 420ms;
  }

  .motion-image {
    animation: image-reveal 900ms var(--motion-out) var(--reveal-delay, 0ms) backwards;
  }

  .industry__photo.motion-image {
    animation-name: photo-develop;
    animation-duration: 720ms;
  }

  .page-hero__photo {
    animation: page-hero-zoom 1350ms var(--motion-out) 350ms both;
    transform-origin: center 72%;
  }

  .leader.motion-settle .leader__photo,
  .tile.motion-settle .tile__photo {
    animation: photo-scale 900ms var(--motion-out) calc(var(--reveal-delay, 0ms) + 70ms) backwards;
  }

  .bio.is-open .bio__photo,
  .testimonials .carousel__track.motion-settle .is-active .testimonial__photo {
    animation: photo-develop 760ms var(--motion-out) 45ms backwards;
  }

  /* Keep the whole source frame inside the card throughout the entrance. */
  .cases__carousel.motion-settle .is-active .case-card__photo,
  .case-card__media.motion-settle .case-card__photo {
    --photo-start-scale: 0.97;
    animation: photo-develop 820ms var(--motion-out) backwards;
  }

  .leader.motion-settle {
    animation-duration: 440ms;
  }

  /* Keyboard navigation can jump directly to a region during an entrance. */
  :is(.motion-settle, .motion-image, .site-header__logo, .site-header__contact > *):focus-within {
    animation: none;
  }

  .carousel__item {
    transform: translateY(7px);
    transition: opacity 240ms ease, transform 400ms var(--motion-out), visibility 0s linear 400ms;
  }

  .carousel__item.is-active {
    z-index: 1;
    transform: translateY(0);
    transition: opacity 480ms ease, transform 620ms var(--motion-out), visibility 0s;
  }

  .site-nav .site-nav__link::after {
    transition: clip-path 290ms var(--motion-out), background-color 150ms ease;
  }

  .carousel__dot::before {
    transition: background-color 150ms ease, box-shadow 240ms ease, transform 240ms var(--motion-out);
  }

  .carousel__dot[aria-current="true"]::before {
    transform: scale(1.25);
  }

  .btn,
  .carousel__prev,
  .carousel__next {
    transition: background-color 150ms ease, box-shadow 240ms ease, transform 240ms var(--motion-out);
  }

  :is(.btn, .carousel__prev, .carousel__next):active {
    transform: scale(0.97);
  }

  .bio.is-open .bio__body {
    animation: settle 420ms var(--motion-out) 55ms backwards;
  }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  :is(.btn, .carousel__prev, .carousel__next):hover:not(:active) {
    transform: translateY(-2px);
  }

}

.tile-water-filter {
  position: absolute;
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) and (min-width: 760px) {
  .tile {
    box-shadow: 0 2px 5px rgb(9 42 61 / 0.12);
  }

  .tile:is(:hover, :focus-within) {
    z-index: 2;
    box-shadow: 0 12px 24px rgb(9 42 61 / 0.25), 0 3px 8px rgb(9 42 61 / 0.16);
  }
}

@media (hover: hover) and (pointer: fine) and (min-width: 760px) and (prefers-reduced-motion: no-preference) {
  .tile {
    transition: transform 360ms var(--motion-out), box-shadow 360ms var(--motion-out);
  }

  .tile:is(:hover, :focus-within) {
    /* A slight expansion keeps the pointer over the card at its lower edge. */
    transform: translateY(-2px) scaleY(1.018);
  }

  .tile__back {
    background-image: linear-gradient(rgb(9 42 61 / 0.1), rgb(9 42 61 / 0.1));
    transition: opacity 300ms ease, background-color 300ms ease;
  }

  .tile__back::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.9;
    background: url(../assets/tile-mesh.png) left bottom / 100% auto no-repeat;
  }

  :is(.tile:hover, .tile:focus-within) .tile__back::after {
    filter: url(#tile-water);
  }

  .tile__back::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    mask: url(../assets/tile-mesh.png) left bottom / 100% auto no-repeat;
    background: linear-gradient(110deg, transparent 12%, rgb(213 235 255 / 0.32) 52%, transparent 88%)
      -110% center / 58% 100% no-repeat;
  }

  :is(.tile:hover, .tile:focus-within) .tile__back::before {
    animation: tile-mesh-sweep 680ms ease-out;
  }

  :is(.tile:hover, .tile:focus-within) .tile__text {
    animation: settle 420ms var(--motion-out) 35ms backwards;
  }

  :is(.tile:hover, .tile:focus-within) .tile__cta:not(:focus-visible) {
    animation: settle 420ms var(--motion-out) 115ms backwards;
  }
}

@keyframes tile-mesh-sweep {
  from { background-position-x: -150%; }
  to { background-position-x: 250%; }
}

@media (min-width: 760px) and (prefers-reduced-motion: no-preference) {
  .site-nav__list {
    animation: settle 520ms var(--motion-out) 245ms backwards;
  }
}

@media (max-width: 759.98px) and (prefers-reduced-motion: no-preference) {
  .site-nav__toggle:not(:focus-visible) {
    animation: settle 420ms var(--motion-out) 245ms backwards;
  }

  .nav-open .site-nav__list {
    animation: settle 320ms var(--motion-out);
  }
}

@keyframes hero-unroll {
  from { clip-path: inset(0 100% 0 0 round 0 8px 8px 0); }
  to { clip-path: inset(0 round 0 8px 8px 0); }
}

@keyframes hero-unroll-lip {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

@keyframes hero-unroll-shading {
  0%, 100% { opacity: 0; }
  10%, 64% { opacity: 0.8; }
}

@keyframes panel-sweep {
  from { clip-path: polygon(0 0, 0 0, 0 100%, 0 100%); }
  60% { clip-path: polygon(0 0, 93% 0, 85% 100%, 0 100%); }
  to { clip-path: polygon(0 0, 110% 0, 100% 100%, 0 100%); }
}

@keyframes settle {
  from { opacity: 0; translate: var(--motion-from-x, 0px) var(--motion-from-y, 12px); }
  to { opacity: 1; translate: 0 0; }
}

@keyframes image-reveal {
  from {
    clip-path: inset(0 0 14% 0 round 12px);
    opacity: 0;
    scale: 0.93;
    translate: 0 12px;
  }
  to {
    clip-path: inset(0 round 12px);
    opacity: 1;
    scale: 1;
    translate: 0 0;
  }
}

@keyframes photo-develop {
  from {
    opacity: 0.32;
    scale: var(--photo-start-scale, 0.95);
  }
  to {
    opacity: 1;
    scale: 1;
  }
}

@keyframes page-hero-zoom {
  from { opacity: 0.55; scale: 1; }
  to { opacity: 1; scale: 1.07; }
}

@keyframes photo-scale {
  from { scale: 0.95; }
  to { scale: 1; }
}

/* Soften discrete cards and photo frames while retaining full-bleed bands. */
:is(.tile, .leader, .case-card) {
  border-radius: clamp(8px, 1vw, 14px);
  overflow: clip;
}

.case-card--wide {
  border-start-start-radius: 0;
  border-start-end-radius: 0;
}

:is(.inspired__image, .products__image, .testimonial__photo) {
  border-radius: clamp(8px, 1vw, 14px);
}

.hero__logo {
  border-radius: 0 0 14px 14px;
}

@supports (mask: radial-gradient(#000, transparent)) {
  @media (prefers-reduced-motion: no-preference) {
    :is(.inspired__cta, .products__cta, .cases__cta, .approach__cta, .case-card__cta) {
      --arrow-rest: var(--slate-dark);
      --arrow-light: #55a4df;
      --arrow-pulse-width: clamp(42px, 20%, 140px);
      --arrow-period: 3.3s;
    }

    .case-card__cta {
      --arrow-rest: #aabed2;
      --arrow-light: var(--white);
      --arrow-pulse-width: 65%;
      --arrow-period: 2.2s;
    }

    .btn.arrow-button-waiting:not(:focus-visible) {
      pointer-events: none;
      transition: none;
      color: transparent;
      border-color: transparent;
      background-color: transparent;
      background-image: none;
      box-shadow: none;
    }

    .arrow-button-waiting:not(.arrow-animated, :focus-visible)::before,
    .arrow-button-waiting:not(.arrow-animated, :focus-visible)::after {
      opacity: 0;
    }

    .btn.arrow-animated {
      transition: background-color 160ms ease, color 160ms ease,
        border-color 160ms ease, box-shadow 240ms ease, transform 240ms var(--motion-out);
    }

    .arrow-animated::before {
      mask: var(--arrow-mask);
      background: linear-gradient(90deg, transparent, var(--arrow-light) 43% 65%, transparent)
        0 center / var(--arrow-pulse-width) 100% no-repeat var(--arrow-rest);
      animation:
        arrow-build var(--arrow-build-duration) steps(var(--arrow-steps), end) backwards,
        arrow-dots var(--arrow-period) linear var(--arrow-build-duration) infinite;
    }

    .arrow-animated::after {
      background-color: var(--arrow-rest);
      animation:
        arrow-tip-in 135ms ease-out var(--arrow-build-duration) backwards,
        arrow-tip var(--arrow-period) linear calc(var(--arrow-build-duration) + 135ms) infinite;
    }

    .arrow-animated:not(.arrow-in-view)::before,
    .arrow-animated:not(.arrow-in-view)::after,
    .carousel__item[inert] .arrow-animated::before,
    .carousel__item[inert] .arrow-animated::after {
      animation-play-state: paused;
    }
  }
}

@keyframes arrow-build {
  from { clip-path: inset(0 var(--arrow-end) 0 var(--arrow-start)); }
  to { clip-path: inset(0 0 0 var(--arrow-start)); }
}

@keyframes arrow-tip-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes arrow-dots {
  from { background-position-x: calc(-1 * var(--arrow-pulse-width)); }
  76%, to { background-position-x: calc(100% + var(--arrow-pulse-width)); }
}

@keyframes arrow-tip {
  0%, 64%, 94%, 100% { background-color: var(--arrow-rest); }
  74%, 81% { background-color: var(--arrow-light); }
}

.btn {
  position: relative;
  background-image: linear-gradient(180deg, rgb(255 255 255 / 0.12), transparent 55%, rgb(9 42 61 / 0.1));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.16), 0 2px 5px rgb(9 42 61 / 0.14);
}

.btn:is(:hover, :focus-visible) {
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.24), 0 4px 10px rgb(9 42 61 / 0.2);
}

.is-animating-text {
  position: relative;
}

.animated-text {
  display: contents;
  padding: inherit;
}

@media (prefers-reduced-motion: no-preference) {
  .stats__item.motion-pending {
    opacity: 0;
  }

  :is(h2, .band__text, .page-hero__title, .case-card__details dt, .case-card__details dd).motion-pending {
    color: transparent;
  }

  .animated-text__original {
    opacity: 0;
  }

  .animated-text__frame {
    position: absolute;
    inset: 0;
    padding: inherit;
  }

  .animated-text--number .animated-text__frame {
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .animated-text__frame {
    display: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .case-detail-wipe {
    width: fit-content;
    animation: case-detail-wipe 210ms var(--motion-out) both;
  }
}

@keyframes case-detail-wipe {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0); }
}

.btn-trace {
  position: absolute;
  inset: -3px;
  width: calc(100% + 6px);
  height: calc(100% + 6px);
  pointer-events: none;
}

.leader {
  position: relative;
}

.leader-trace {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  --trace-color: #2479b9;
}

.leader:has(.leader__toggle[aria-expanded="true"]) > .leader-trace {
  --trace-color: #8dcaff;
}

:is(.btn-trace, .leader-trace) rect {
  fill: none;
  stroke: var(--trace-color, #8dcaff);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
  opacity: 0;
}

.btn:is(:hover, :focus-visible) > .btn-trace rect,
.leader:is(:hover, :focus-within) > .leader-trace rect {
  stroke-dashoffset: 0;
  opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
  :is(.btn-trace, .leader-trace) rect {
    transition: stroke-dashoffset 520ms cubic-bezier(0.32, 0, 0.67, 0), opacity 0s linear 520ms;
  }

  .btn:is(:hover, :focus-visible) > .btn-trace rect,
  .leader:is(:hover, :focus-within) > .leader-trace rect {
    transition: stroke-dashoffset 520ms cubic-bezier(0.33, 1, 0.68, 1), opacity 0s;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .industry__strip {
    background-color: var(--navy);
  }
}


.drawn-wave {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  .has-drawn-waves > .drawn-wave {
    display: block;
    position: absolute;
    inset: 0 0 0 auto;
    width: 100%;
    height: 100%;
    pointer-events: none;
  }

  .has-drawn-mesh {
    position: relative;
    isolation: isolate;
    background-image: none;
  }

  .has-drawn-mesh > .drawn-wave--mesh {
    z-index: -1;
    border-radius: inherit;
  }

  .industry__band.has-drawn-mesh::after {
    content: '';
    position: absolute;
    z-index: -1;
    inset: 0;
    pointer-events: none;
    background: var(--industry-scrim);
  }

  .page-hero__wave.has-drawn-waves {
    background: none;
  }

  .case-card.has-drawn-waves {
    position: relative;
  }

  .case-card.has-drawn-waves > .drawn-wave {
    z-index: 1;
    width: 37.25%;
    mask-image: linear-gradient(to right, transparent, #000 38%);
  }

  .case-card--wide.has-drawn-waves > .drawn-wave {
    width: min(29.48%, 398px);
  }

  .case-card.has-drawn-waves .case-card__media::after,
  .case-card.has-drawn-waves .case-card__body {
    background-image: none;
  }

  .case-card.has-drawn-waves .case-card__body > * {
    position: relative;
    z-index: 2;
  }
}


@media (prefers-reduced-motion: no-preference) {
  .copy-rule-pending::before {
    transform: scaleY(0);
  }

  .copy-rule-drawing::before {
    animation: copy-rule-draw 460ms var(--motion-out) both;
  }
}

@keyframes copy-rule-draw {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}
