/* Ruch na stronie. Ten plik nie ładuje się w edytorze.
   Wszystko jest w jednym bloku, więc „ogranicz ruch” w systemie wyłącza całość. */

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

  html {
    scroll-behavior: smooth;
  }

  /* Wejście strony: nagłówek odsłania się od dołu, reszta podjeżdża */

  .cf-hero h1,
  .cf-intro h1 {
    animation: cf-unveil 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }

  .cf-hero__text > .cf-lead,
  .cf-intro .cf-lead {
    animation: cf-rise 0.8s 0.18s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }

  .cf-hero__text > .wp-block-buttons,
  .cf-intro .cf-lead ~ * {
    animation: cf-rise 0.8s 0.32s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }

  .cf-hero .cf-fact {
    animation: cf-rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
    animation-delay: calc(0.45s + var(--n, 0) * 0.12s);
  }

  .cf-fact:nth-child(2) {
    --n: 1;
  }

  .cf-fact:nth-child(3) {
    --n: 2;
  }

  .cf-intro {
    position: relative;
  }

  .cf-intro::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 2px;
    background: var(--cf-foil);
    transform-origin: left;
    animation: cf-draw-x 1.4s 0.3s cubic-bezier(0.65, 0, 0.35, 1) both;
  }

  @keyframes cf-unveil {
    from {
      clip-path: inset(0 0 100% 0);
      transform: translateY(0.35em);
    }
    to {
      clip-path: inset(-0.2em -0.2em -0.2em -0.2em);
      transform: none;
    }
  }

  @keyframes cf-rise {
    from {
      opacity: 0;
      transform: translateY(22px);
    }
  }

  @keyframes cf-draw-x {
    from {
      transform: scaleX(0);
    }
  }

  /* Wejścia przy przewijaniu */

  .cf-anim--rise {
    opacity: 0;
    transform: translateY(34px);
    transition:
      opacity 0.8s cubic-bezier(0.2, 0.7, 0.2, 1),
      transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
    transition-delay: calc(var(--i, 0) * 0.09s);
  }

  .cf-anim--rise.is-in {
    opacity: 1;
    transform: none;
  }

  /* Przycinany jest obrazek, nie ramka: obserwator uważa w całości przycięty element za niewidoczny. */

  .cf-anim--wipe img {
    clip-path: inset(100% 0 0 0);
    transform: scale(1.22);
  }

  .cf-anim--wipe.is-in img {
    clip-path: inset(0);
    transform: none;
    animation: cf-wipe 1.1s cubic-bezier(0.65, 0, 0.2, 1) backwards;
    animation-delay: calc(var(--i, 0) * 0.12s);
  }

  @keyframes cf-wipe {
    from {
      clip-path: inset(100% 0 0 0);
      transform: scale(1.22);
    }
  }

  /* Pudełko: wieko unosi się przy pierwszym pokazaniu */

  .cf-box__grid {
    position: relative;
    perspective: 1100px;
  }

  .cf-anim--lid .cf-box__grid::after {
    content: "";
    position: absolute;
    z-index: 2;
    inset: -2px;
    border-radius: 22px;
    background: var(--cf-pine-900) url("../img/icon-light.webp") center / 8.5rem auto no-repeat;
    box-shadow: inset 0 0 0 2px rgb(220 192 126 / 0.6);
    transform-origin: top;
    transition:
      transform 1.2s 0.15s cubic-bezier(0.65, 0, 0.2, 1),
      opacity 0.35s 1s;
    pointer-events: none;
  }

  .cf-anim--lid.is-in .cf-box__grid::after {
    opacity: 0;
    transform: rotateX(104deg);
  }

  .cf-box.is-ready .cf-box__cell {
    animation: cf-pop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2) backwards;
    transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
    transition: transform 0.25s;
  }

  .cf-box__cell:nth-child(2) {
    animation-delay: 0.07s !important;
  }

  .cf-box__cell:nth-child(3) {
    animation-delay: 0.14s !important;
  }

  .cf-box__cell:nth-child(4) {
    animation-delay: 0.21s !important;
  }

  @keyframes cf-pop {
    from {
      opacity: 0;
      transform: scale(0.94) translateY(10px);
    }
  }

  .cf-box__tabs button {
    transition:
      background-color 0.2s,
      color 0.2s,
      transform 0.2s;
  }

  .cf-box__tabs button:active {
    transform: scale(0.95);
  }

  /* Filary: złota linia rośnie z góry, pod kursorem filar się rozświetla */

  .cf-pillar {
    position: relative;
    border-left-color: transparent;
  }

  .cf-pillar::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -1px;
    width: 2px;
    background: linear-gradient(#f0d897, #8c6a2c);
    transform-origin: top;
    transition: transform 1.2s 0.25s cubic-bezier(0.65, 0, 0.35, 1);
  }

  .cf-pillar.cf-anim:not(.is-in)::before {
    transform: scaleY(0);
  }

  .cf-pillar::after {
    content: "";
    position: absolute;
    z-index: -1;
    inset: -1.25rem -1rem -1.25rem 0;
    background: linear-gradient(90deg, rgb(220 192 126 / 0.16), transparent 70%);
    opacity: 0;
    transition: opacity 0.4s;
  }

  .cf-pillars {
    isolation: isolate;
  }

  .cf-pillar:hover::after {
    opacity: 1;
  }

  /* Kroki: złota linia prowadzi od 1 do 3 w rytmie przewijania */

  .cf-steps {
    position: relative;
  }

  .cf-step__number {
    transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.4);
  }

  .cf-step:hover .cf-step__number {
    transform: translateY(-4px) scale(1.08);
  }

  @media (min-width: 48rem) {
    .cf-motion .cf-steps::before {
      content: "";
      position: absolute;
      top: 1.4rem;
      right: calc((100% - 6rem) / 3 + 0.75rem);
      left: 3.5rem;
      height: 1px;
      background: var(--cf-foil);
      transform: scaleX(var(--progress, 0));
      transform-origin: left;
    }

    .cf-motion .cf-mist .cf-step__number {
      position: relative;
      padding-right: 1rem;
      background: var(--cf-foil), var(--cf-mist);
      -webkit-background-clip: text, border-box;
      background-clip: text, border-box;
    }
  }

  /* Oferta, wiersze, tabele */

  .cf-offer__item {
    position: relative;
  }

  .cf-offer__item::before {
    content: "";
    position: absolute;
    top: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--cf-foil);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.5s cubic-bezier(0.65, 0, 0.35, 1);
  }

  .cf-offer__item:hover::before {
    transform: none;
  }

  .cf-offer__item h3,
  .cf-row__term {
    transition: transform 0.35s;
  }

  .cf-offer__item:hover h3,
  .cf-row:hover .cf-row__term {
    transform: translateX(8px);
  }

  .cf-table tbody tr {
    transition: background-color 0.2s;
  }

  .cf-table tbody tr:hover {
    background: rgb(13 59 38 / 0.04);
  }

  /* Zdjęcia */

  .cf-photo:not(.cf-anim) img,
  .cf-photo.is-in img {
    transition: transform 1s cubic-bezier(0.2, 0.7, 0.2, 1);
    transition-delay: 0s;
  }

  .cf-photo:hover img {
    transform: scale(1.06) !important;
  }

  .cf-photo-wide {
    overflow: hidden;
  }

  @supports (animation-timeline: view()) {
    .cf-photo-wide img {
      animation: cf-parallax linear both;
      animation-timeline: view();
    }

    @keyframes cf-parallax {
      from {
        transform: scale(1.22) translateY(-7%);
      }
      to {
        transform: scale(1.22) translateY(7%);
      }
    }

    /* Zdanie wypełnia się kolorem podczas przewijania */
    .cf-statement:not(.cf-statement--small) {
      background: linear-gradient(90deg, var(--cf-pine) 50%, rgb(13 59 38 / 0.18) 50%) 100% 0 / 200% 100%;
      -webkit-background-clip: text;
      background-clip: text;
      color: transparent;
      animation: cf-fill linear both;
      animation-timeline: view();
      animation-range: entry 60% cover 50%;
    }

    @keyframes cf-fill {
      to {
        background-position: 0 0;
      }
    }

    /* Postęp czytania pod nagłówkiem */
    .cf-header::after {
      content: "";
      position: absolute;
      right: 0;
      bottom: -1px;
      left: 0;
      height: 2px;
      background: var(--cf-foil);
      transform-origin: left;
      animation: cf-draw-x linear both;
      animation-timeline: scroll(root);
    }
  }

  /* Przyciski i nawigacja */

  .cf-button,
  .wp-block-button .wp-block-button__link {
    position: relative;
    overflow: hidden;
    transition:
      background-color 0.2s,
      border-color 0.2s,
      color 0.2s,
      transform 0.2s,
      box-shadow 0.2s;
  }

  .cf-button:hover,
  .wp-block-button .wp-block-button__link:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -10px rgb(7 38 23 / 0.55);
  }

  .cf-button:active,
  .wp-block-button .wp-block-button__link:active {
    transform: none;
  }

  .cf-button::after,
  .wp-block-button .wp-block-button__link::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -60%;
    width: 40%;
    background: linear-gradient(100deg, transparent, rgb(240 216 151 / 0.55), transparent);
    transform: skewX(-18deg);
    transition: left 0.6s;
    pointer-events: none;
  }

  .cf-button:hover::after,
  .wp-block-button .wp-block-button__link:hover::after {
    left: 130%;
  }

  .cf-header {
    transition: box-shadow 0.3s;
  }

  .cf-header.is-scrolled {
    box-shadow: 0 10px 30px -22px rgb(7 38 23 / 0.6);
  }

  .cf-logo > img {
    transition: transform 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.3);
  }

  .cf-logo:hover > img {
    transform: rotate(-6deg) scale(1.06);
  }

  @media (min-width: 64rem) {
    .cf-menu--primary a {
      background: var(--cf-foil) 0 100% / 0 2px no-repeat;
      transition:
        background-size 0.35s,
        color 0.2s;
    }

    .cf-menu--primary :is(a:hover, .current-menu-item > a) {
      background-size: 100% 2px;
    }
  }

  .cf-nav.is-open .cf-menu--primary li,
  .cf-nav.is-open .cf-nav__actions {
    animation: cf-rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
    animation-delay: calc(var(--n, 0) * 0.06s);
  }

  .cf-menu--primary li:nth-child(2) {
    --n: 1;
  }

  .cf-menu--primary li:nth-child(3) {
    --n: 2;
  }

  .cf-menu--primary li:nth-child(4) {
    --n: 3;
  }

  .cf-nav__actions {
    --n: 4;
  }

  .cf-footer a {
    transition:
      color 0.2s,
      padding-left 0.3s;
  }

  .cf-menu--footer a:hover {
    padding-left: 6px;
  }

  /* Formularze i ramki */

  .cf-field :is(input, select, textarea) {
    transition:
      border-color 0.2s,
      box-shadow 0.25s;
  }

  .cf-field :is(input, select, textarea):focus {
    box-shadow: inset 0 -2px 0 var(--cf-gold);
  }

  .cf-field__help.is-error {
    animation: cf-shake 0.4s;
  }

  @keyframes cf-shake {
    25% {
      transform: translateX(-5px);
    }
    75% {
      transform: translateX(5px);
    }
  }

  .cf-form__status.is-ok {
    animation: cf-pop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  }

  .cf-aside.cf-anim::before {
    clip-path: inset(0 100% 100% 0);
    transition: clip-path 1.3s 0.3s cubic-bezier(0.65, 0, 0.35, 1);
  }

  .cf-aside.is-in::before {
    clip-path: inset(0);
  }

  .cf-card {
    transition: box-shadow 0.4s;
  }

  .cf-card:hover {
    box-shadow: 0 24px 50px -36px rgb(7 38 23 / 0.45);
  }

  /* Taśma z hasłami */

  .cf-marquee.is-running .cf-marquee__track {
    animation: cf-slide 36s linear infinite;
  }

  .cf-marquee:hover .cf-marquee__track {
    animation-play-state: paused;
  }

  @keyframes cf-slide {
    to {
      transform: translateX(-25%);
    }
  }
}
