/*
 * Homepage Hero Slider — zt-puppet-v2
 * All rules are scoped under .zt-slider to avoid collisions.
 *
 * CSS custom properties:
 *   --slide-image-ratio   (default 0.6) — fraction of slot for image vs. content.
 *                         Not exposed in admin yet; change here to adjust 60/40 split.
 *   --slide-image-h       доля ВЫСОТЫ слота, отданная картинке в раскладке --top.
 *                         Раньше здесь стоял жёсткий max-height:400px: в слоте
 *                         высотой 880px это 45% и смотрелось верно, а в мобильном
 *                         слоте 466px те же 400px давали 86%, и картинка не
 *                         уменьшалась, а обрезалась по overflow обёртки.
 *                         45% подобраны так, чтобы на самом большом слоте
 *                         (1350x880) картинка осталась ~396px — как было.
 *                         ВАЖНО: значение продублировано в
 *                         ZT_Slider_Renderer::image_sizes_attr(), где из него
 *                         считается sizes. Менять надо в обоих местах.
 *   --btn-text            Per-slide button text color (set inline in PHP).
 *   --btn-bg              Per-slide primary button background (set inline in PHP).
 */

/* ═══════════════════════════════════════════════════
   1. SLOT GEOMETRY
═══════════════════════════════════════════════════ */

.zt-slider {
  --slide-image-ratio: 0.6;
  --slide-image-h: 45%;
  position: relative;
  display: block;
  width: 100%;
  color: #fff;
  overflow: hidden;
  outline: none; /* focus handled on controls */
}

/* ≥ 768px: слайдер занимает заднюю стену целиком — от нижней кромки
   ламбрекена до верха пола (рамку считает #fp-hero-stage в hero-stage.css).
   Слот сам становится контейнером размеров: картинка и текст меряются в
   долях ЕГО высоты (cqh), поэтому слайд целиком помещается и на HD
   (1280x720), и на 4K, а по вертикали стоит строго по центру стены.
   Ширина — между шторами: на широких экранах штора занимает ~19% с края. */
@media (min-width: 768px) {
  .zt-slider {
    --slide-image-h: 50cqh;
    width: min(56vw, 1100px);
    height: 100%;
    margin-inline: auto;
    container-type: size;
  }
}
@media (min-width: 1280px) {
  .zt-slider { width: min(60vw, 1100px); }
}

/* < 768px */
@media (max-width: 767px) {
  .zt-slider {
    width: calc(100% - 24px);
    aspect-ratio: 4 / 5;
    margin-top: 32px;
    margin-inline: auto;
    /* Слайдер лежит внутри #fp-hero-stage высотой --stage-h (66svh на мобиле).
       Аспект 4/5 на невысоком экране давал слот выше сцены: на 360x640 это
       420px + 32px отступа против 422px сцены. Потолок ограничивает высоту,
       ширина при этом остаётся полной — слот просто становится ниже. */
    max-height: calc(100% - 48px);
  }
}

/* The slider keeps this slot geometry inside #fp-hero-stage as well. */

/* ═══════════════════════════════════════════════════
   2. SLIDE TRACK & SLIDES — CROSSFADE (default)
═══════════════════════════════════════════════════ */

.zt-slider__track {
  position: relative;
  width: 100%;
  height: 100%;
}

.zt-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 600ms ease-out;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.zt-slide.is-active {
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
}

/* Micro-zoom: outgoing/incoming image subtly scales */
.zt-slide__image-wrap {
  transform: scale(1.02);
  transition: transform 600ms ease-out;
  overflow: hidden;
  flex-shrink: 0;
}

.zt-slide.is-active .zt-slide__image-wrap {
  transform: scale(1);
}

/* ═══════════════════════════════════════════════════
   3. HORIZONTAL SLIDE TRANSITION
═══════════════════════════════════════════════════ */

.zt-slider--slide .zt-slider__track {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

.zt-slider--slide .zt-slider__track.no-transition {
  transition: none !important;
}

.zt-slider--slide .zt-slide {
  position: relative;
  inset: auto;
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  opacity: 1;
  pointer-events: auto;
  transition: none;
}

/* Active/inactive handled by JS translateX on the track, not opacity */
.zt-slider--slide .zt-slide__image-wrap {
  transform: none;
  transition: none;
}

/* ═══════════════════════════════════════════════════
   4. KEN BURNS ANIMATIONS
═══════════════════════════════════════════════════ */

@keyframes kb-0 {
  from {
    transform: scale(1) translate(0, 0);
  }
  to {
    transform: scale(1.08) translate(0, 0);
  }
}

@keyframes kb-1 {
  from {
    transform: scale(1.05) translate(0, 0);
  }
  to {
    transform: scale(1) translate(0, -2%);
  }
}

@keyframes kb-2 {
  from {
    transform: scale(1) translate(0, 0);
  }
  to {
    transform: scale(1.06) translate(2%, 0);
  }
}

@keyframes kb-3 {
  from {
    transform: scale(1.04) translate(0, 0);
  }
  to {
    transform: scale(1) translate(-2%, -2%);
  }
}

.zt-slider--ken-burns .ken-burns-0 {
  animation: kb-0 8s linear infinite alternate;
}
.zt-slider--ken-burns .ken-burns-1 {
  animation: kb-1 8s linear infinite alternate;
}
.zt-slider--ken-burns .ken-burns-2 {
  animation: kb-2 8s linear infinite alternate;
}
.zt-slider--ken-burns .ken-burns-3 {
  animation: kb-3 8s linear infinite alternate;
}

/* Pause KB animation while autoplay is paused */
.zt-slider--ken-burns:not(.is-playing) .zt-slide__image-wrap,
.zt-slider--ken-burns.is-reduced-motion .zt-slide__image-wrap {
  animation-play-state: paused;
}

/* ═══════════════════════════════════════════════════
   5. IMAGE & CONTENT LAYOUT — POSITION VARIANTS
═══════════════════════════════════════════════════ */

/* --- top: image+content group v-centered; image h-centered --- */
.zt-slide--top {
  flex-direction: column;
  justify-content: center; /* v-center the image+content group */
  align-items: center;
}

.zt-slide--top .zt-slide__image-wrap {
  width: 100%;
  /* Высота — доля слота, а не max-height на auto-высоте: .zt-slide растянут
     inset:0, поэтому процент здесь определённый, и max-height:100% у картинки
     внутри гарантированно разрешается в пиксели. Тот же рецепт, что у
     --left/--right, где он давно работает. */
  height: var(--slide-image-h);
  flex: 0 0 auto;
  display: flex;
  justify-content: center; /* h-center image within its row */
  align-items: center;     /* было flex-end — из-за этого срезало верх логотипа */
}

/* Тот же рецепт, что у --left/--right: картинка вписывается в обёртку целиком
   и никогда не обрезается, потолок задан долей слота, а не пикселями. */
.zt-slide--top .zt-slide__image-wrap img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.zt-slide--top .zt-slide__content {
  height: auto;
  width: 100%;
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* --- left: image v-centered in its column, pair h-centered --- */
.zt-slide--left {
  flex-direction: row;
  align-items: center; /* v-center both columns */
  justify-content: center;
}

.zt-slide--left .zt-slide__image-wrap {
  width: calc(var(--slide-image-ratio) * 100%);
  height: 100%;
  flex-shrink: 0;
  display: flex;
  align-items: center; /* v-center image within its column */
  justify-content: center; /* h-center image within its column */
}

.zt-slide--left .zt-slide__image-wrap img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.zt-slide--left .zt-slide__content {
  width: calc((1 - var(--slide-image-ratio)) * 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* --- right: image v-centered in its column, pair h-centered --- */
.zt-slide--right {
  flex-direction: row-reverse;
  align-items: center;
  justify-content: center;
}

.zt-slide--right .zt-slide__image-wrap {
  width: calc(var(--slide-image-ratio) * 100%);
  height: 100%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zt-slide--right .zt-slide__image-wrap img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.zt-slide--right .zt-slide__content {
  width: calc((1 - var(--slide-image-ratio)) * 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* --- No image: content fills slot --- */
.zt-slide:not(:has(.zt-slide__image-wrap)) .zt-slide__content,
.zt-slide--no-image .zt-slide__content {
  width: 100%;
  height: 100%;
  max-width: 720px;
  margin-inline: auto;
  justify-content: center;
  align-items: flex-start;
}

/* Mobile: force top layout regardless of saved position */
@media (max-width: 767px) {
  .zt-slide--left,
  .zt-slide--right {
    flex-direction: column;
    align-items: center;
    justify-content: center;  /* группа «картинка + текст» по центру слота */
  }

  .zt-slide--left .zt-slide__image-wrap,
  .zt-slide--right .zt-slide__image-wrap {
    width: 100%;
    height: var(--slide-image-h);
    flex: 0 0 auto;
  }

  .zt-slide--left .zt-slide__content,
  .zt-slide--right .zt-slide__content {
    width: 100%;
    height: auto;
    flex: 0 1 auto;
    min-height: 0;
  }
}

/* ═══════════════════════════════════════════════════
   6. CONTENT AREA INNER LAYOUT
═══════════════════════════════════════════════════ */

.zt-slide__content {
  padding: 1.5rem 2rem;
  box-sizing: border-box;
  max-width: 640px;
}

.zt-slide__text-blocks {
  display: flex;
  flex-direction: column;
}

.zt-tb {
  margin: 0;
  line-height: inherit;
}

/* 1rem gap between same-size adjacent blocks */
.zt-tb + .zt-tb {
  margin-top: 1rem;
}

/* 1.5rem gap when size changes */
.zt-tb + .zt-tb--gap-change {
  margin-top: 1.5rem;
}

/* 2rem gap from text blocks to buttons */
.zt-slide__buttons {
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

@media (max-width: 767px) {
  .zt-slide__buttons {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ═══════════════════════════════════════════════════
   7. TEXT SIZE SCALE
═══════════════════════════════════════════════════ */

.zt-tb--small {
  font-size: clamp(18px, 2.5vw, 30px);
  line-height: 1.55;
}

.zt-tb--medium {
  font-size: clamp(26px, 3.75vw, 45px);
  line-height: 1.35;
}

.zt-tb--large {
  font-size: clamp(36px, 5vw, 60px);
  line-height: 1.05;
  font-weight: 600;
  font-family: "Playfair Display", serif;
}

/* ═══════════════════════════════════════════════════
   8. SLIDE BUTTONS
   Visual tokens copied verbatim from existing slider
   (border-radius:0, uppercase, letter-spacing, padding, font-weight 600).
   Colors come from per-slide inline CSS variables.
═══════════════════════════════════════════════════ */

.zt-slide__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  line-height: 1.25rem;
  padding: 0.5rem 2rem; /* matches old px-8 py-4 */
  border-radius: 0;
  border: 1px solid rgba(255, 255, 255, 0.45);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em; /* matches old tracking-widest */
  text-decoration: none;
  cursor: pointer;
  transition: background-color 200ms ease;
  white-space: nowrap;
  color: var(--btn-text, #ffffff);
}

.zt-slide__btn--primary {
  background-color: var(--btn-bg, #420101);
}

.zt-slide__btn--secondary {
  background-color: transparent;
}

.zt-slide__btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.zt-slide__btn--primary:hover {
  /* Overlay 10% white on top of the colored background */
  background-color: color-mix(in srgb, var(--btn-bg, #420101) 90%, white);
}

.zt-slide__btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════
   9. CONTROLS WRAPPER
═══════════════════════════════════════════════════ */

.zt-slider__controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.zt-slider__controls > * {
  pointer-events: auto;
}

/* ═══════════════════════════════════════════════════
   10. PAGINATION DOTS
   Style copied verbatim from existing slider:
   rectangular bars, border-radius:0, same colors.
═══════════════════════════════════════════════════ */

.zt-slider__bottom {
  position: absolute;
  bottom: 1.75rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 11;
}

.zt-slider__dots {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.zt-slider__dot {
  display: block;
  width: 28px;
  height: 3px;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.4);
  border: none;
  padding: 0;
  cursor: pointer;
  transition:
    background 0.3s,
    width 0.3s;
}

.zt-slider__dot.is-active {
  background: #f6f4ee;
  width: 44px;
}

.zt-slider__dot:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════
   11. ARROWS
   Style copied verbatim from existing slider buttons.
═══════════════════════════════════════════════════ */

.zt-slider__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 11;
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 0;
  color: white;
  backdrop-filter: blur(4px);
  cursor: pointer;
  transition: background 0.2s;
}

.zt-slider__arrow--prev {
  left: 1.5rem;
}
.zt-slider__arrow--next {
  right: 1.5rem;
}

.zt-slider__arrow:hover {
  background: rgba(255, 255, 255, 0.2);
}

.zt-slider__arrow:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.zt-slider__arrow svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* ═══════════════════════════════════════════════════
   12. PLAY / PAUSE BUTTON
═══════════════════════════════════════════════════ */

.zt-slider__playpause {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 0;
  color: white;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.zt-slider__playpause:hover {
  background: rgba(255, 255, 255, 0.2);
}

.zt-slider__playpause:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.zt-slider__icon svg {
  width: 0.875rem;
  height: 0.875rem;
}

/* ═══════════════════════════════════════════════════
   13. PROGRESS BAR
═══════════════════════════════════════════════════ */

.zt-slider__progress-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  overflow: hidden;
}

@keyframes zt-progress {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

.zt-slider__progress {
  height: 100%;
  background: #7a1e2a; /* burgundy; --accent fallback */
  transform-origin: left center;
  transform: scaleX(0);
  animation: zt-progress linear forwards;
  animation-play-state: paused;
}

.zt-slider__progress.is-active {
  animation-play-state: running;
}

/* ═══════════════════════════════════════════════════
   14. LIVE REGION (visually hidden)
═══════════════════════════════════════════════════ */

.zt-slider__live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════
   15. REDUCED MOTION
═══════════════════════════════════════════════════ */

.zt-slider.is-reduced-motion .zt-slide,
.zt-slider.is-reduced-motion .zt-slide__image-wrap {
  transition: none !important;
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .zt-slider .zt-slide,
  .zt-slider .zt-slide__image-wrap,
  .zt-slider .zt-slider__track,
  .zt-slider .zt-slider__dot,
  .zt-slider .zt-slider__progress {
    transition: none !important;
    animation: none !important;
  }
}

/* ── Мобильный слайд ───────────────────────────────
   Кегли из секции 7 упираются в свой нижний предел уже на 375px и перестают
   сжиматься, поэтому на iPhone SE текст не помещался: «Вас вітає» и «Театр
   Ляльок» уезжали за нижний край. Здесь предел опущен, а шаг привязан к
   ширине экрана, чтобы текст продолжал уменьшаться вместе с ним. */
@media (max-width: 767px) {
  .zt-slide__content {
    padding: 0.75rem 1rem;
  }

  .zt-tb--small {
    font-size: clamp(11px, 3.4vw, 18px);
    line-height: 1.45;
  }

  .zt-tb--medium {
    font-size: clamp(15px, 5vw, 26px);
    line-height: 1.3;
  }

  .zt-tb--large {
    font-size: clamp(20px, 7.2vw, 36px);
    line-height: 1.1;
  }

  /* отбивки между блоками тоже от ширины, иначе на узком экране они съедают
     больше места, чем сам текст */
  .zt-tb + .zt-tb {
    margin-top: clamp(0.3rem, 1.8vw, 1rem);
  }

  .zt-tb + .zt-tb--gap-change {
    margin-top: clamp(0.45rem, 2.6vw, 1.5rem);
  }

  .zt-slide__buttons {
    margin-top: clamp(0.75rem, 4vw, 2rem);
  }
}


/* ═══════════════════════════════════════════════════
   9. DESKTOP FIT — слайд вписан в высоту стены
   Размеры текста — доли высоты слота (cqh), отступы между строками тоже:
   всё сжимается вместе с картинкой, и ничего не вылезает за стену.
═══════════════════════════════════════════════════ */
@media (min-width: 768px) {
  .zt-slide--top { justify-content: center; padding-block: 3cqh; box-sizing: border-box; }

  .zt-slide--top .zt-slide__image-wrap {
    height: var(--slide-image-h);
    flex: 0 1 auto;
    min-height: 0;
    margin-bottom: 3cqh;
  }

  .zt-slide--top .zt-slide__content {
    flex: 0 0 auto;
    max-width: none;
    padding: 0 1rem;
  }

  .zt-slide--top .zt-tb--large  { font-size: clamp(22px, 7.4cqh, 84px); line-height: 1.08; }
  .zt-slide--top .zt-tb--medium { font-size: clamp(16px, 4.6cqh, 56px); line-height: 1.25; }
  .zt-slide--top .zt-tb--small  { font-size: clamp(13px, 3.4cqh, 36px); line-height: 1.4; }

  .zt-slide--top .zt-tb + .zt-tb               { margin-top: 1.2cqh; }
  .zt-slide--top .zt-tb + .zt-tb--gap-change   { margin-top: 2.2cqh; }
  .zt-slide--top .zt-slide__buttons            { margin-top: 3cqh; }
}

/* Невысокая стена (HD-ноутбуки): эмблема меньше, чтобы не давила на текст.
   Правило смотрит на высоту самого слота, а не окна. */
@container (max-height: 700px) { .zt-slide--top { --slide-image-h: 46cqh; } }
@container (max-height: 600px) { .zt-slide--top { --slide-image-h: 42cqh; } }
@container (max-height: 520px) { .zt-slide--top { --slide-image-h: 40cqh; } }
