/* Galeria filmowa - pas kadrów prowadzony przewijaniem */
.ax-cinegal {
  /*
   * Tor sekcji. 460vh to cztery i pół ekranu zapasu na przesuw pasa - tyle
   * potrzeba, żeby dziesięć kadrów przejechało przez kadr bez wyścigu.
   */
  height: 460vh;
  /*
   * Sekcja stoi między dwoma jasnymi pasami, więc najciemniejszy ton zamykał ją
   * zbyt szczelnie - zdjęcia świeciły z czarnej dziury. Bierzemy o stopień
   * jaśniejszy granat, ten sam co sekcja z hotspotami i kontakt.
   */
  background: var(--ax-ink);
  color: var(--ax-paper);
  --ax-cinegal-muted: rgba(244, 241, 235, 0.65);
  --ax-cinegal-dim: rgba(244, 241, 235, 0.5);
  --ax-cinegal-faint: rgba(244, 241, 235, 0.45);
  --ax-cinegal-rule: rgba(244, 241, 235, 0.08);
  --ax-cinegal-tick: rgba(244, 241, 235, 0.22);
  --ax-cinegal-e: cubic-bezier(0.16, 1, 0.3, 1);
}

.ax-cinegal__stick {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: clamp(80px, 12vh, 150px) 0 clamp(56px, 8vh, 110px);
}

/* --- Nagłówek --- */

.ax-cinegal__head {
  padding: 0 var(--ax-gutter);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px 32px;
  flex-wrap: wrap;
  margin-bottom: clamp(28px, 5vh, 64px);
}

.ax-cinegal__eyebrow {
  display: block;
  margin-bottom: 16px;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ax-cinegal-dim);
}

.ax-cinegal__heading {
  margin: 0;
  font-weight: 600;
  font-size: clamp(40px, 5.2vw, 88px);
  line-height: 0.92;
  letter-spacing: -0.04em;
}

.ax-cinegal__heading .ax-heading-italic {
  color: var(--ax-steel-light);
}

.ax-cinegal__aside {
  display: grid;
  gap: 14px;
  justify-items: end;
}

.ax-cinegal__intro {
  margin: 0;
  max-width: 36ch;
  font-size: clamp(14px, 1vw, 16px);
  line-height: 1.55;
  color: var(--ax-cinegal-muted);
  text-wrap: pretty;
}

.ax-cinegal__counter {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ax-cinegal-dim);
  font-variant-numeric: tabular-nums;
}

/* --- Pas kadrów --- */

.ax-cinegal__mid {
  display: grid;
  align-content: start;
  min-height: 0;
  padding-top: clamp(8px, 1.5vh, 20px);
}

.ax-cinegal__track {
  display: flex;
  gap: clamp(12px, 1.4vw, 22px);
  padding: 0 var(--ax-gutter);
  align-items: start;
  will-change: transform;
}

.ax-cinegal__card {
  flex: 0 0 auto;
  display: grid;
  gap: 14px;
  margin: 0;
  /* Skala przychodzi z pętli rAF co klatkę - krótkie liniowe dojście ją gładzi. */
  transition: transform 0.2s linear;
  will-change: transform;
}

.ax-cinegal__frame {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  /*
   * Kadr musi zmieścić się razem z nagłówkiem i linią postępu w jednym oknie,
   * dlatego wysokość liczy się z okna, a nie z szerokości karty.
   */
  height: min(50svh, 480px, calc(100svh - 480px));
  min-height: 220px;
  aspect-ratio: 4 / 3;
  border-radius: var(--ax-radius);
  overflow: hidden;
  /* Ciemniej od sekcji, żeby puste kadry były widoczne, dopóki zdjęcie się ładuje. */
  background: var(--ax-ink-deep);
  cursor: zoom-in;
}

.ax-cinegal__img {
  /* Nadmiar 12% szerokości to zapas na parallax zdjęcia wewnątrz kadru. */
  width: 112%;
  height: 100%;
  object-fit: cover;
  margin-left: -6%;
  display: block;
  will-change: transform;
  transition: filter 0.6s;
}

.ax-cinegal__card:not(.is-focus) .ax-cinegal__img {
  filter: saturate(0.75) brightness(0.96);
}

.ax-cinegal__zoom {
  position: absolute;
  left: 0;
  top: 0;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  border-radius: 50%;
  background: var(--ax-glass-photo-badge-dark-bg);
  backdrop-filter: var(--ax-glass-photo-badge-dark-blur);
  -webkit-backdrop-filter: var(--ax-glass-photo-badge-dark-blur);
  border: 1px solid rgba(244, 241, 235, 0.35);
  color: var(--ax-paper);
  display: grid;
  place-items: center;
  font-size: 8.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 500;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.35s, transform 0.5s var(--ax-cinegal-e);
  pointer-events: none;
  will-change: left, top;
}

@media (hover: hover) and (pointer: fine) {
  /* Kursor zastępuje bąbel „Powiększ" chodzący za wskaźnikiem. */
  .ax-cinegal__frame {
    cursor: none;
  }

  .ax-cinegal__card:hover .ax-cinegal__zoom {
    opacity: 1;
    transform: scale(1);
  }
}

.ax-cinegal__frame:focus-visible {
  outline: 2px solid var(--ax-steel-light);
  outline-offset: 3px;
}

.ax-cinegal__caption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--ax-cinegal-muted);
}

.ax-cinegal__cap-num {
  font-style: normal;
  font-size: 9.5px;
  letter-spacing: 0.2em;
  font-weight: 500;
  color: var(--ax-cinegal-faint);
}

/* --- Linia postępu --- */

.ax-cinegal__prog {
  position: relative;
  margin: clamp(32px, 5vh, 56px) var(--ax-gutter) 0;
  height: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ax-cinegal__prog::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--ax-cinegal-rule);
}

.ax-cinegal__tick {
  position: relative;
  width: 1px;
  height: 6px;
  background: var(--ax-cinegal-tick);
}

.ax-cinegal__marker {
  position: absolute;
  top: 50%;
  left: 0;
  width: 44px;
  height: 1px;
  background: var(--ax-steel-light);
  transform: translate(-50%, -50%);
  /* Pozycję niesie pętla rAF - dodatkowe przejście zostawiałoby smugę. */
  transition: none;
}

.ax-cinegal__marker-x {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 12px;
  transform: translate(-50%, -50%);
  /* Znak siada na kresce, więc kasuje ją tłem sekcji - musi trzymać się z nim w parze. */
  background: var(--ax-ink);
  display: grid;
  place-items: center;
}

.ax-cinegal__marker-glyph {
  display: block;
  width: 14px;
  height: 12px;
  fill: var(--ax-steel-light);
}

/* --- Powiększenie --- */

.ax-cinegal__lb {
  position: fixed;
  inset: 0;
  z-index: 750;
  background: rgba(11, 15, 34, 0.86);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
  color: var(--ax-paper);
}

.ax-cinegal__lb[hidden] {
  display: none;
}

.ax-cinegal__lb.is-open {
  opacity: 1;
  pointer-events: auto;
}

.ax-cinegal__lb-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px var(--ax-gutter);
}

.ax-cinegal__lb-count {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(244, 241, 235, 0.6);
}

.ax-cinegal__lb-close {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(244, 241, 235, 0.3);
  background: none;
  color: var(--ax-paper);
  font-size: 18px;
  cursor: pointer;
}

.ax-cinegal__lb-stage {
  position: relative;
  min-height: 0;
  display: grid;
  /*
   * Jawna ścieżka kadru. Bez niej wiersz dobiera się do zdjęcia, procent
   * w max-height nie ma się o co oprzeć i wysokie kadry wychodziły poza
   * ekran, spychając podpis pod krawędź.
   */
  grid-template-rows: minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 0 clamp(60px, 8vw, 120px);
}

.ax-cinegal__lb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.8);
  animation: ax-cinegal-lb-in 0.8s var(--ax-cinegal-e) both;
}

@keyframes ax-cinegal-lb-in {
  from {
    opacity: 0;
    transform: scale(0.97);
  }

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

.ax-cinegal__lb-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(244, 241, 235, 0.3);
  background: rgba(11, 15, 34, 0.35);
  color: var(--ax-paper);
  font-size: 20px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.ax-cinegal__lb-arrow--prev {
  left: clamp(16px, 3vw, 48px);
}

.ax-cinegal__lb-arrow--next {
  right: clamp(16px, 3vw, 48px);
}

.ax-cinegal__lb-cap {
  margin: 0;
  text-align: center;
  padding: 18px var(--ax-gutter) 26px;
  font-size: 15px;
  font-weight: 500;
}

/* --- Wejście --- */

.ax-cinegal [data-anim] {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 1.1s var(--ax-cinegal-e) var(--ax-cinegal-delay, 0s),
    transform 1.1s var(--ax-cinegal-e) var(--ax-cinegal-delay, 0s);
}

.ax-cinegal [data-anim].is-in {
  opacity: 1;
  transform: none;
}

/* --- Telefon: zwykła szyna ze snapem, bez sticky --- */

@media (max-width: 900px) {
  .ax-cinegal {
    height: auto;
    /*
     * Nagłówek tej sekcji jest wysoki (nadtytuł, dwuwierszowy tytuł, wstęp,
     * licznik), więc standardowy odstęp od górnej krawędzi zostawiał go bez
     * powietrza. Dokładamy kilkanaście pikseli u góry, a odbieramy je z odstępu
     * nad szyną - tam pustki było za dużo.
     */
    padding: calc(var(--ax-sec-pad-m) + 14px) 0 var(--ax-sec-end);
  }

  .ax-cinegal__head {
    margin-bottom: 24px;
  }

  .ax-cinegal__stick {
    position: static;
    height: auto;
    display: block;
    overflow: visible;
    padding: 0;
  }

  .ax-cinegal__mid {
    padding-top: 0;
  }

  /*
   * Bez sticky nie ma czego przesuwać transformem - pas wraca do natywnego
   * przewijania, a wartości ustawione w pętli rAF muszą zejść z elementów.
   */
  .ax-cinegal__track {
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 10px;
    scrollbar-width: none;
    transform: none !important;
  }

  .ax-cinegal__track::-webkit-scrollbar {
    display: none;
  }

  .ax-cinegal__card {
    scroll-snap-align: start;
    transform: none !important;
  }

  .ax-cinegal__img {
    transform: none !important;
  }

  .ax-cinegal__frame {
    height: auto;
    width: 78vw;
  }

  .ax-cinegal__prog {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ax-cinegal [data-anim],
  .ax-cinegal__card,
  .ax-cinegal__img,
  .ax-cinegal__zoom,
  .ax-cinegal__lb {
    transition-duration: 0s;
    transition-delay: 0s;
  }

  .ax-cinegal__lb-img {
    animation: none;
  }
}
