/* ------------------------------------------------------------------
   Секция 03 «Тренируйся перед важными событиями»
   Десктоп 121:17611, планшет 175:15166, телефон 175:15193,
   карточка 109:56457. Десктоп — сцена 1600 px (zoom: var(--s));
   секция закрепляется, лента карточек едет по горизонтали (script.js).
   Планшет/телефон — нативная горизонтальная прокрутка.
   ------------------------------------------------------------------ */

.cases {
  position: relative;
  margin-top: calc(120px * var(--s, 1));
}

.cases__pin {
  position: sticky;
  top: 0;
  /* режем только по горизонтали: свечение уходит вверх в отступ между секциями */
  overflow-x: clip;
  overflow-y: visible;
}

.cases__stage {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 56px;
  width: 1600px;
  margin: 0 auto;
  padding: 40px 40px 45px;
  zoom: var(--s, 1);
}

/* ---------- Свечение ---------- */

.cases__glow {
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
}
.cases__glow--a {
  left: 900px; top: 120px; width: 760px; height: 700px;
  background: rgba(117, 32, 252, 0.35);
  filter: blur(110px);
}
.cases__glow--b {
  left: 1180px; top: 560px; width: 300px; height: 240px;
  background: rgba(229, 249, 116, 0.14);
  filter: blur(90px);
}
.cases__glow--c {
  left: -220px; top: -240px; width: 640px; height: 520px;
  background: rgba(138, 56, 245, 0.2);
  filter: blur(110px);
}

/* ---------- Заголовок ---------- */

.cases__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.cases__head h2 {
  margin: 0;
  font: 400 46px/105% var(--font-display);
  letter-spacing: -0.01em;
  color: #fff;
  white-space: nowrap;
}

.cases__lead {
  margin: 22px 0 0;
  font: 400 22px/145% var(--font-text);
  color: rgba(255, 255, 255, 0.72);
}

.cases__btn {
  display: inline-flex;
  align-items: center;
  height: 62px;
  margin-top: 34px;
  padding: 0 25px;
  border-radius: 999px;
  background: var(--c-lime);
  color: var(--c-ink);
  font: 400 18px/125% var(--font-display);
  white-space: nowrap;
  transition: background-color .2s;
}
.cases__btn:hover { background: #d6eb5c; }

/* ---------- Лента карточек ---------- */

.cases__view {
  align-self: stretch;
  margin: -23px -40px -28px;
  padding: 23px 40px 28px;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 3.5%, #000 88%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 3.5%, #000 88%, transparent);
}

.cases__track {
  display: flex;
  gap: 20px;
  width: max-content;
  margin: 0;
  padding: 0;
  list-style: none;
  will-change: transform;
}

/* ---------- Карточка ---------- */

.case {
  --r: 32px;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  flex: none;
  width: 430px;
  height: 529px;
  border-radius: var(--r);
  background: #141418;
  outline: none;
}
.case:focus-visible { box-shadow: inset 0 0 0 2px var(--c-lime); }
/* копии для бесконечной ленты нужны только на планшете и телефоне (script.js) */
@media (min-width: 1024px) { .case--clone { display: none; } }

.case__img {
  position: absolute;
  z-index: -2;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .4s ease-out, filter .4s ease-out;
}

/* Default: лёгкое затемнение снизу; Active: сильнее, под чат */
.case::before,
.case::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  transition: opacity .4s ease-out;
}
.case::before {
  background: linear-gradient(to bottom, rgba(12, 12, 14, 0.05) 30%, rgba(12, 12, 14, 0.92) 100%);
}
.case::after {
  background: linear-gradient(to bottom, rgba(12, 12, 14, 0.3), rgba(12, 12, 14, 0.95));
  opacity: 0;
}

.case__body {
  position: absolute;
  left: 29px;
  right: 29px;
  bottom: 29px;
  display: flex;
  flex-direction: column;
  transition: opacity .25s ease-out, transform .25s ease-out;
}
.case__num {
  font: 600 12px/125% var(--font-text);
  color: var(--c-lime);
}
.case__title {
  margin: 5px 0 0;
  font: 400 28px/115% var(--font-display);
  letter-spacing: -0.02em;
  color: #fff;
}
.case__text {
  margin: 8px 0 0;
  font: 500 16px/150% var(--font-text);
  color: rgba(255, 255, 255, 0.72);
}

.case.is-active .case__img { transform: scale(1.05); filter: brightness(.7); }
.case.is-active::before { opacity: 0; }
.case.is-active::after { opacity: 1; }
.case.is-active .case__body { opacity: 0; transform: translateY(12px); }

/* ---------- Чат в активной карточке ---------- */

.cs-chat {
  position: absolute;
  left: 22px;
  right: 26px;
  bottom: 23px;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.case.is-active .cs-chat { opacity: 1; transition: none; }

/* реплика выезжает снизу и выталкивает прошлые вверх (FLIP в script.js) */
.cs-step {
  display: none;
  flex-direction: column;
}
.cs-step.is-on {
  display: flex;
  animation: cs-up .5s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes cs-up { from { opacity: 0; transform: translateY(40px) scale(.96); } }
@media (prefers-reduced-motion: reduce) { .cs-step.is-on { animation: none; } }
.cs-step + .cs-step { margin-top: 10px; }

.cs-lb {
  width: 311px;
  padding: 13px 12px;
  border-radius: 27px 27px 27px 3px;
  background: rgba(255, 255, 255, 0.06);
  font: 400 16px/135% var(--font-text);
  color: #fff;
}
.cs-lb p { margin: 0; }
.cs-lb p + p { margin-top: 8px; }

.cs-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.cs-voice {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.cs-voice svg { width: 20px; height: 20px; }
.cs-tr {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px 0 7px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  font: 500 12px/135% var(--font-text);
  color: rgba(255, 255, 255, 0.8);
}
.cs-tr > span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
}
.cs-tr svg { width: 13px; height: 13px; }

.cs-ub {
  position: relative;
  padding: 13px 34px 13px 12px;
  border-radius: 27px 27px 3px 27px;
  background: linear-gradient(116deg, #8c65cc 27%, #a791cc 100%);
  font: 400 16px/135% var(--font-text);
  color: #fff;
}
.cs-ub p { margin: 0; }
.cs-ub em {
  font-style: normal;
  color: #ff9d9d;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.cs-ub__check {
  position: absolute;
  right: 9px;
  bottom: 9px;
  width: 18px;
  height: 11px;
  color: #fff;
}

.cs-chip {
  align-self: flex-end;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  margin: -3px 0 10px;
  padding: 0 12px 0 7px;
  border-radius: 18px;
  background: rgba(229, 249, 116, 0.1);
  box-shadow: inset 0 0 5px rgba(229, 249, 116, 0.16);
  font: 500 12px/135% var(--font-text);
  color: var(--c-lime);
}
.cs-chip__i {
  display: flex;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
}
.cs-chip__i svg { width: 22px; height: 22px; }

/* ---------- Появление (включает script.js, класс .is-anim) ---------- */

.cases.is-anim .cases__head > *,
.cases.is-anim .case {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity .6s, transform .8s cubic-bezier(.2, .9, .3, 1.05);
}
.cases.is-anim .cases__lead { transition-delay: .1s; }
.cases.is-anim .cases__btn { transition-delay: .2s; }
.cases.is-anim .case:nth-child(2) { transition-delay: .08s; }
.cases.is-anim .case:nth-child(3) { transition-delay: .16s; }
.cases.is-anim .case:nth-child(4) { transition-delay: .24s; }
.cases.is-anim .case:nth-child(5) { transition-delay: .32s; }
.cases.is-anim .case:nth-child(n+6) { transition-delay: .4s; }
.cases.is-anim .cases__head.is-go > *,
.cases.is-anim .cases__view.is-go .case { opacity: 1; transform: none; }
/* кнопка: после появления — только свой ховер */
.cases.is-anim .cases__head.is-go .cases__btn { transition: opacity .6s .2s, transform .8s .2s cubic-bezier(.2, .9, .3, 1.05), background-color .2s; }

/* ------------------------------------------------------------------
   Планшет и телефон: лента листается пальцем
   ------------------------------------------------------------------ */

@media (max-width: 1023px) {
  .cases { margin-top: 96px; }

  .cases__pin { position: static; }

  .cases__stage {
    gap: 44px;
    width: auto;
    padding: 32px 0 32px;
    zoom: 1;
  }

  .cases__glow--a { left: 388px; }
  .cases__glow--b { left: 618px; }

  .cases__head { padding: 0 32px; }
  .cases__head h2 { max-width: 640px; font-size: 36px; line-height: 40px; white-space: normal; }
  .cases__lead { margin-top: 18px; font-size: 18px; line-height: 22px; }
  .cases__btn { margin-top: 30px; }

  .cases__view {
    margin: -23px 0 -28px;
    padding: 23px 0 28px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }
  .cases__view::-webkit-scrollbar { display: none; }

  .cases__track { gap: 16px; padding: 0 32px; }
  .case { scroll-snap-align: center; scroll-snap-stop: always; }

  .cs-voice { width: 32px; height: 32px; }
  .cs-tr, .cs-chip { height: 32px; }
  .cs-tr > span, .cs-chip__i { width: 20px; height: 20px; }
  .cs-chip__i svg { width: 20px; height: 20px; }
}

@media (max-width: 767px) {
  .cases { margin-top: 72px; }

  .cases__stage { gap: 32px; padding: 24px 0 24px; }

  .cases__glow--a { left: 45px; top: 220px; width: 361px; height: 332px; filter: blur(52px); }
  .cases__glow--b { left: 155px; top: 429px; width: 141px; height: 113px; filter: blur(42px); }
  .cases__glow--c { left: -64px; top: 49px; width: 304px; height: 247px; filter: blur(52px); }

  .cases__head { padding: 0 16px; }
  .cases__head h2 { font-size: 26px; line-height: 30px; }
  .cases__lead { margin-top: 13px; font-size: 15px; line-height: 140%; }
  .cases__br { display: none; }
  .cases__btn { height: 58px; margin-top: 18px; padding: 0 24px; font-size: 16px; }

  /* ряд в макете фиксированной высоты 529, карточки 441 прижаты к верху */
  .cases__track { align-items: flex-start; height: 529px; gap: 12px; padding: 0 16px; }

  .case { --r: 24px; width: 327px; height: 441px; }

  .case__body { left: 22px; right: 22px; bottom: 20px; }
  .case__num { font-size: 12px; }
  .case__title { margin-top: 6px; font-size: 24px; }
  .case__text { margin-top: 6px; font-size: 14px; line-height: 140%; }

  .cs-chat { left: 17px; right: 20.5px; bottom: 18.5px; }
  .cs-step + .cs-step { margin-top: 9px; }

  .cs-lb {
    width: 236px;
    padding: 9.25px 9px;
    border-radius: 20px 20px 19px 2px;
    font-size: 12px;
    line-height: 18px;
  }
  .cs-lb p + p { margin-top: 9px; }

  .cs-tools { gap: 8px; margin-top: 6px; }
  .cs-voice { width: 30px; height: 30px; }
  .cs-voice svg { width: 18px; height: 18px; }
  .cs-tr { gap: 4px; height: 29px; padding: 0 8px 0 7px; font-size: 11px; }
  .cs-tr > span { width: 18px; height: 18px; }
  .cs-tr svg { width: 11px; height: 11px; }

  .cs-ub {
    padding: 9.25px 32px 9.25px 9px;
    border-radius: 17px 20px 2px 17px;
    font-size: 12px;
    line-height: 18px;
  }
  .cs-ub__check { right: 8px; bottom: 8px; }

  .cs-chip { gap: 4px; height: 30px; margin: -4px 0 8.5px; padding: 0 8px 0 5px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .case__img,
  .case::before,
  .case::after,
  .case__body,
  .cs-chat,
  .cs-step { transition: none !important; }
}
