/* ==========================================================================
   KIYIZGROUP — вопросы и ответы (/faq)
   Раскадрованное видео на липкой сцене и карточки вопросов поверх неё.
   Кадры рисует page.js; без него остаются первый кадр и обычный список.
   ========================================================================== */

.faq-page {
  /* Тон бумаги — светлее фона ролика: карточка читается как лист,
     положенный на тот же стол, а не как окно поверх видео */
  --fq-paper: #efe6da;
  --fq-card: rgba(252, 250, 246, 0.9);
  --fq-shadow: 0 24px 60px rgba(70, 45, 25, 0.14);
  /* Бордовый шнура из ролика. Только линейки и метки, не текст:
     на светлой карточке он слабее --ink-mute */
  --fq-cord: #7a2433;
  background: var(--fq-paper);
}

/* ---------- сцена ---------- */
.fq {
  position: relative;
}
.fq__stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: var(--fq-paper);
}
.fq__media {
  position: absolute;
  inset: 0;
}
.fq__media picture,
.fq__poster,
.fq__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.fq__poster {
  object-fit: cover;
  /* Предмет в ролике левее центра, карточки — справа */
  object-position: 32% 50%;
}
.fq__canvas {
  display: block;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.fq.is-ready .fq__canvas {
  opacity: 1;
}

/* Полоса общего прогресса — под шапкой */
.fq__bar {
  position: absolute;
  top: var(--nav-h);
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(17, 17, 17, 0.06);
}
.fq__bar span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--fq-cord);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* Название раздела на телефоне — над кадром */
.fq__chapter {
  display: none;
}

/* ---------- оглавление сбоку (широкий экран) ---------- */
.fq__rail {
  display: none;
}

/* ---------- шаги ---------- */
.fq__steps {
  position: relative;
  z-index: 2;
  /* Шаги поднимаются на высоту сцены и прокручиваются поверх неё */
  margin-top: -100vh;
  margin-top: -100svh;
}
.fq-part {
  display: block;
}
.fq-step {
  box-sizing: border-box;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--pad);
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  /* Переход по якорю из оглавления — карточка посреди окна */
  scroll-margin-top: 15vh;
}
.fq-step--part {
  min-height: 60vh;
}
.fq-step--intro {
  min-height: 100vh;
  min-height: 100svh;
  padding-top: calc(var(--nav-h) + 24px);
  padding-bottom: 40px;
}
.fq-step--cta {
  min-height: 100vh;
  min-height: 100svh;
}

/* ---------- карточка ---------- */
.fq-card {
  width: min(470px, 42vw);
  background: var(--fq-card);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  backdrop-filter: blur(14px) saturate(1.1);
  border: 1px solid rgba(17, 17, 17, 0.07);
  border-radius: 18px;
  padding: 28px 30px 30px;
  box-shadow: var(--fq-shadow);
}
.fq-card--intro {
  width: min(560px, 46vw);
  padding: 30px 34px 32px;
}
.fq-card--cta {
  width: min(520px, 44vw);
}
.fq-card__num {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.fq-card__num::before {
  content: '';
  flex: 0 0 28px;
  height: 1px;
  background: var(--fq-cord);
}
.fq-card__of {
  font-weight: 500;
}
.fq-card__h1 {
  font-size: clamp(1.7rem, 2.6vw, 2.35rem);
  line-height: 1.12;
  font-weight: 600;
  margin: 0 0 16px;
}
.fq-card__title {
  font-size: clamp(1.45rem, 2.1vw, 1.95rem);
  line-height: 1.15;
  font-weight: 600;
  margin: 0 0 10px;
}
.fq-card__q {
  font-size: clamp(1.12rem, 1.45vw, 1.32rem);
  line-height: 1.3;
  font-weight: 600;
  margin: 0 0 12px;
}
.fq-card__lead {
  margin: 0 0 10px;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink);
}
.fq-card__a {
  margin: 0;
  font-size: 0.97rem;
  line-height: 1.62;
  color: var(--ink-soft);
}
.fq-card__meta {
  margin: 0;
  font-size: 0.86rem;
  color: var(--ink-mute);
}
.fq-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.fq-crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-bottom: 18px;
  font-size: 0.78rem;
  color: var(--ink-mute);
}
.fq-crumbs a {
  border-bottom: 1px solid var(--line);
}
.fq-crumbs a:hover {
  color: var(--ink);
  border-bottom-color: currentColor;
}

/* Оглавление в первой карточке */
.fq-index {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
  display: grid;
  gap: 2px;
  border-top: 1px solid var(--line);
}
.fq-index a {
  display: flex;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 500;
  transition: padding 0.25s ease, color 0.25s ease;
}
.fq-index a:hover {
  padding-left: 6px;
  color: var(--fq-cord);
}
.fq-index span {
  flex: 0 0 auto;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  padding-top: 2px;
}

.fq-hint {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 0;
  font-size: 0.8rem;
  color: var(--ink-mute);
}
.fq-hint__wheel {
  position: relative;
  flex: 0 0 18px;
  height: 28px;
  border: 1.5px solid currentColor;
  border-radius: 10px;
}
.fq-hint__wheel::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 6px;
  width: 2px;
  height: 6px;
  margin-left: -1px;
  border-radius: 1px;
  background: currentColor;
  animation: fq-wheel 1.6s ease-in-out infinite;
}
@keyframes fq-wheel {
  0% { transform: translateY(0); opacity: 1; }
  70% { transform: translateY(8px); opacity: 0; }
  100% { transform: translateY(0); opacity: 0; }
}

/* ---------- появление карточек ----------
   Класс fq--live ставит page.js: без скрипта все карточки видны сразу */
.fq--live .fq-card {
  opacity: 0;
  transform: translateY(36px) scale(0.98);
  transition:
    opacity 0.45s ease,
    transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.fq--live .fq-card > * {
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.45s ease,
    transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.fq--live .is-active .fq-card,
.fq--live .is-active .fq-card > * {
  opacity: 1;
  transform: none;
}
/* Вопрос раньше ответа: сначала заголовок, потом текст */
.fq--live .is-active .fq-card > :nth-child(2) { transition-delay: 0.06s; }
.fq--live .is-active .fq-card > :nth-child(3) { transition-delay: 0.16s; }
.fq--live .is-active .fq-card > :nth-child(n + 4) { transition-delay: 0.24s; }

@media (prefers-reduced-motion: reduce) {
  .fq--live .fq-card,
  .fq--live .fq-card > * {
    transform: none;
    transition: opacity 0.2s linear;
  }
  .fq-hint__wheel::after {
    animation: none;
  }
}

/* ---------- широкий экран: разделы над карточками ----------
   Правый верхний угол кадра пуст на всём ролике: предмет стоит левее
   и ниже, а внизу слева к концу оказывается коробка. Оглавление в потоке
   нулевой высоты и стоит после сцены, поэтому появляется, только когда
   первая карточка уезжает вверх. */
@media (min-width: 1100px) {
  .fq__rail {
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 14px;
    position: sticky;
    z-index: 3;
    top: calc(var(--nav-h) + 18px);
    height: 0;
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 0 var(--pad);
  }
  .fq__rail ol {
    order: 2;
    display: flex;
    gap: 2px;
    list-style: none;
    margin: 0;
    padding: 5px;
    background: rgba(252, 250, 246, 0.78);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: 30px;
    border: 1px solid rgba(17, 17, 17, 0.06);
  }
  .fq__rail a {
    display: flex;
    gap: 8px;
    padding: 7px 11px;
    border-radius: 24px;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--ink-mute);
    transition: background 0.25s ease, color 0.25s ease;
  }
  .fq__rail em {
    display: none;
    font-style: normal;
    letter-spacing: 0.02em;
  }
  .fq__rail a:hover {
    color: var(--ink);
  }
  .fq__rail a[aria-current='true'] {
    background: var(--ink);
    color: #fff;
  }
  .fq__rail a[aria-current='true'] em {
    display: inline;
  }
  .fq__count {
    order: 1;
    margin: 12px 0 0;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    color: var(--ink-soft);
  }
}

/* ---------- телефон и планшет: кадр сверху, карточка снизу ---------- */
@media (max-width: 899px) {
  .fq__media {
    top: var(--nav-h);
    bottom: auto;
    height: calc(64vh - var(--nav-h));
  }
  @supports (height: 1svh) {
    .fq__media {
      height: calc(64svh - var(--nav-h));
    }
  }
  /* Нижний край кадра растворяется в бумаге */
  .fq__media::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 30%;
    background: linear-gradient(to bottom, rgba(239, 230, 218, 0), var(--fq-paper));
    pointer-events: none;
  }
  .fq__poster {
    object-position: 50% 50%;
  }
  .fq__chapter {
    display: block;
    position: absolute;
    top: calc(var(--nav-h) + 14px);
    left: var(--pad);
    z-index: 2;
    margin: 0;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(252, 250, 246, 0.82);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-soft);
  }
  .fq__chapter:empty {
    display: none;
  }
  .fq-step {
    min-height: 82vh;
    min-height: 82svh;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 4svh;
    scroll-margin-top: 0;
  }
  .fq-step--part {
    min-height: 70svh;
  }
  .fq-step--intro,
  .fq-step--cta {
    min-height: 100svh;
  }
  .fq-card,
  .fq-card--intro,
  .fq-card--cta {
    width: 100%;
    max-width: 560px;
    padding: 22px 22px 24px;
    border-radius: 16px;
    --fq-card: rgba(252, 250, 246, 0.94);
  }
  .fq-card__a {
    font-size: 0.94rem;
    line-height: 1.58;
  }
  /* Первая карточка длиннее экрана телефона. Она начинается с середины,
     чтобы первый экран показывал кадр, а не сплошной текст */
  .fq-step--intro {
    align-items: flex-start;
    padding-top: 50vh;
    padding-top: 50svh;
  }
  .fq-index a {
    font-size: 0.84rem;
    padding: 8px 0;
  }
  .fq-card__lead {
    font-size: 0.94rem;
  }
}

@media (max-width: 420px) {
  .fq-card__actions .btn {
    width: 100%;
  }
}

.fq-index b {
  font-weight: inherit;
}

/* ---------- справа налево (арабский) ----------
   Карточки и разделы остаются справа, над пустой частью кадра: в RTL
   «конец» строки слева, и без этого они легли бы прямо на предмет */
[dir='rtl'] .fq-step,
[dir='rtl'] .fq__rail {
  justify-content: flex-start;
}
[dir='rtl'] .fq-index a:hover {
  padding-left: 0;
  padding-right: 6px;
}
@media (max-width: 899px) {
  [dir='rtl'] .fq-step {
    justify-content: center;
  }
  [dir='rtl'] .fq__chapter {
    left: auto;
    right: var(--pad);
  }
}
[dir='rtl'] .fq__bar span {
  transform-origin: 100% 50%;
}
/* Номера «04 / 36» и «1–7» — всегда слева направо: в арабском тексте
   цифры с пробелами вокруг черты иначе встают в обратном порядке */
.fq-card__n,
.fq__count {
  direction: ltr;
  unicode-bidi: isolate;
}
