/* ------------------------------------------------------------------
   Секция 05 «Полный курс с ИИ-репетитором»
   Десктоп 155:15759, планшет 175:16067, телефон 175:16272.
   Десктоп — сцена 1600 px (zoom), координаты — из макета.
   Анимации (script.js): верхний блок собирается по очереди и
   периодически пересобирается, карточки курса раздаются слева
   направо, фразы во 2-й карточке падают с физикой, вкладки
   переключаются сами, в чате по очереди появляются сообщения.
   Без JS и при reduced motion видно финальное состояние.
   ------------------------------------------------------------------ */

.crs {
  margin-top: calc(120px * var(--s, 1));
  overflow: hidden;
  background: var(--c-bg);
}

.crs__stage {
  position: relative;
  isolation: isolate;
  width: 1600px;
  height: 2023px;
  margin: 0 auto;
  zoom: var(--s, 1);
}

/* ---------- Верхний блок: Лекса и преимущества ---------- */

.crs-top { position: absolute; inset: 0 0 auto; height: 799px; }

/* свечение рисуется поверх панели, как в макете */
.crs-top__glow {
  position: absolute;
  z-index: 2;
  left: 184px;
  top: 45px;
  width: 1232px;
  height: 880px;
  background: radial-gradient(50% 50% at 50% 50%, rgba(138, 56, 245, 0.62) 0%, rgba(110, 50, 220, 0.38) 40%, rgba(80, 40, 170, 0.14) 70%, rgba(46, 26, 86, 0) 100%);
  pointer-events: none;
}

.crs-top__lexa {
  position: absolute;
  z-index: 2;
  left: 381px;
  top: 0;
  width: 820px;
  height: 799px;
  overflow: hidden;
}
.crs-top__lexa img { display: block; width: 820px; height: auto; }
.crs-top__lexa::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(12, 12, 14, 0) 87.02%, #0c0c0e 98.08%);
}

.crs-bub,
.crs-pro {
  position: absolute;
  z-index: 3;
  background: #fff;
  border-radius: 30px;
  color: var(--c-ink);
}

.crs-bub {
  left: 1150px;
  top: 45px;
  width: 228px;
  height: 185px;
  transform-origin: 0 100%;
}
.crs-bub::before {
  content: "";
  position: absolute;
  left: -17px;
  top: 120px;
  width: 21px;
  height: 35px;
  background: inherit;
  clip-path: polygon(21px 0, 0 35px, 21px 30.4px);
}
.crs-bub__text {
  position: absolute;
  left: 0;
  right: 0;
  top: 28px;
  font: 400 54px/62px var(--font-display);
  letter-spacing: -0.01em;
  text-align: center;
}
.crs-bub__badge {
  position: absolute;
  left: 178px;
  top: -24px;
  width: 74px;
  height: 72px;
  overflow: visible;
  filter: drop-shadow(0 5px 7px rgba(0, 0, 0, 0.3));
}
.crs-bub__heart { transform-box: fill-box; transform-origin: 50% 50%; }

.crs-pros { margin: 0; padding: 0; list-style: none; }

.crs-pro {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 410px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.crs-pro--l1 { left: 40px; top: 125px; height: 226px; }
.crs-pro--l2 { left: 40px; top: 431px; height: 226px; }
.crs-pro--r1 { left: 1150px; top: 420px; height: 200px; }
.crs-pro--r2 { left: 1150px; top: 700px; height: 194px; }

.crs-pro h3 { margin: 0; font: 400 27px/32.4px var(--font-display); }
.crs-pro p { margin: 0; font: 400 17px/26.35px var(--font-text); }
.crs-pro--l1 p { width: 325px; }


.crs-pro__ic { position: absolute; width: 37px; height: 37px; }
.crs-pro--l1 .crs-pro__ic { left: 339px; top: 35px; }
.crs-pro--l2 .crs-pro__ic { left: 353px; top: 35px; width: 36px; height: 36px; }
.crs-pro--r1 .crs-pro__ic { left: 339px; top: 35px; }
.crs-pro--r2 .crs-pro__ic { left: 330px; top: 34px; width: 33px; }

/* ---------- Панель ---------- */

.crs-panel {
  position: absolute;
  z-index: 1;
  left: 40px;
  top: 799px;
  width: 1520px;
  height: 1206px;
  border-radius: 52px;
  background: #2a1a5e url("../assets/s5/panel.webp") 0 0 / 100% 100% no-repeat;
}

.crs-panel__head { position: absolute; left: 40px; top: 116px; }
.crs-panel__head h2 {
  margin: 0;
  font: 400 54px/62.1px var(--font-display);
  letter-spacing: -0.01em;
  color: #fff;
  white-space: nowrap;
}
.crs-panel__head p {
  margin: 21px 0 0;
  font: 400 22px/31.9px var(--font-text);
  color: rgba(255, 255, 255, 0.72);
}

.crs-stats {
  position: absolute;
  left: 40px;
  top: 339px;
  display: flex;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.crs-stats li {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 186px;
  height: 84px;
  padding: 0 24px;
  border-radius: 24px;
  background: #fff;
  color: var(--c-ink);
  font: 600 16px/20px var(--font-text);
}
.crs-stats li + li { width: 227px; }
.crs-stats li { white-space: nowrap; }
.crs-stats b { font: 400 27px/32.4px var(--font-display); }

.crs-tabs {
  position: absolute;
  right: 40px;
  top: 349px;
  display: flex;
  gap: 4px;
  padding: 6px;
  border-radius: 32px;
  background: #fff;
}
.crs-tab {
  height: 52px;
  padding: 0 30px;
  border: 0;
  border-radius: 26px;
  background: transparent;
  color: var(--c-ink);
  font: 400 16px/20px var(--font-display);
  cursor: pointer;
  transition: background-color 0.25s, color 0.25s;
}
.crs-tab.is-on { background: #7a4be0; color: #fff; }
.crs-tab:not(.is-on):hover { background: rgba(122, 75, 224, 0.1); }

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

/* карточки по 307 px с шагом 283: каждая следующая наезжает
   на предыдущую на 24 px и отбрасывает тень влево */
.crs-grid {
  position: absolute;
  left: 40px;
  top: 498px;
  display: grid;
  grid-template-columns: repeat(4, 283px) 307px;
  row-gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.crs-card {
  position: relative;
  width: 307px;
  height: 307px;
  overflow: hidden;
  border-radius: 30px;
  background: var(--c-ink);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), -40px 0 70px rgba(0, 0, 0, 0.45);
  transition: transform 0.25s, box-shadow 0.25s;
}
.crs-card:nth-child(5n + 1) { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); }
.crs-card:hover {
  transform: translateY(-3px);
  box-shadow: inset 0 0 0 1px rgba(229, 249, 116, 0.4), -40px 0 70px rgba(0, 0, 0, 0.45);
}
.crs-card:nth-child(5n + 1):hover { box-shadow: inset 0 0 0 1px rgba(229, 249, 116, 0.4); }

.crs-card > img {
  position: absolute;
  z-index: -1;
  inset: 0;
  width: 100%;
  height: 100%;
}
.crs-card--photo { isolation: isolate; }

.crs-card h3 {
  margin: 0;
  padding: 24px 24px 0;
  font: 400 22px/27.5px var(--font-display);
  color: #fff;
}

.crs-card__ic { position: absolute; color: var(--c-lime); }
.crs-card--light .crs-card__ic { color: #7a4be0; }
.crs-card__ic--wave { left: 174px; top: 180px; width: 82px; height: 78px; }
.crs-card__ic--chats { left: 173px; top: 169px; width: 100px; height: 100px; }
.crs-card__ic--mail { left: 179px; top: 185px; width: 88px; height: 68px; }
.crs-card__ic--people { left: 179px; top: 185px; width: 90px; height: 74px; }
.crs-card__ic--text,
.crs-card__ic--calendar,
.crs-card__ic--globe,
.crs-card__ic--cap { left: 180px; top: 182px; width: 80px; height: 80px; }

.crs-card--violet {
  background:
    radial-gradient(214.9px 153.5px at 245.6px 245.6px, rgba(229, 249, 116, 0.18) 0%, rgba(229, 249, 116, 0) 70%),
    linear-gradient(167deg, #8f63f4 0%, #6b3ee0 45%, #4b23b8 100%);
}
.crs-card--light { background: linear-gradient(180deg, #f4f1fb 0%, #e6def7 100%); }
.crs-card--light h3 { color: var(--c-ink); }

/* Фразы: падают сверху и раскладываются (script.js) */
.crs-card--phrase { border-radius: 34px; background: #211a38; }

.crs-drop { position: absolute; display: block; }
.crs-drop > span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  text-align: center;
}
.crs-drop--q { left: 22px; top: 26.3px; width: 189px; height: 92px; }
.crs-drop--q > span {
  border-radius: 23px 23px 23px 7px;
  background: #7a4be0;
  color: #fff;
  font: 400 25px/27.5px var(--font-display);
  transform: rotate(-4deg);
}
.crs-drop--a { left: 116.8px; top: 142.2px; width: 139px; height: 72px; }
.crs-drop--a > span {
  border-radius: 21px 21px 7px 21px;
  background: #fff;
  color: #1b1430;
  font: 600 18px/21.6px var(--font-text);
  transform: rotate(6deg);
}
.crs-drop--tape { left: 23.9px; top: 242.6px; width: 147px; height: 38px; }
.crs-drop--tape > span {
  border-radius: 19px;
  background: var(--c-lime);
  color: #111;
  font: 700 16px/20px var(--font-text);
  transform: rotate(-8deg);
}
.crs-card--phrase.is-wait .crs-drop { visibility: hidden; }

/* «Грамматика»: лаймовая карточка, тёмная плашка */
.crs-card--phrase.is-grammar { background: var(--c-lime); }
.crs-card--phrase.is-grammar .crs-drop--tape > span { background: #211a38; color: var(--c-lime); }
/* «Экзамены»: ответ длиннее */
.crs-card--phrase.is-exam .crs-drop--a { left: 86px; top: 134px; width: 196px; }

/* Чат */
.crs-card--chat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 34px;
  background: var(--c-phone) url("../assets/s5/chatbg.webp") 0 0 / 100% 100% no-repeat;
}
.crs-msg {
  position: relative;
  flex: none;
  width: 251px;
  margin: 0;
  padding: 10.5px 10px;
  color: #fff;
  font: 500 17px/26.35px var(--font-text);
  transition: opacity 0.4s, transform 0.4s;
}
.crs-msg p { margin: 0; }
.crs-msg--me {
  border-radius: 23px 23px 2px 23px;
  background: linear-gradient(121deg, #8c65cc 27.4%, #a791cc 100%);
}
.crs-msg__ticks { position: absolute; right: 8px; bottom: 8px; width: 19px; height: 12px; }
.crs-msg--lexa {
  display: flex;
  flex-direction: column;
  gap: 7px;
  border-radius: 23px 23px 23px 2px;
  background: rgba(255, 255, 255, 0.06);
}

/* ---------- Анимации (включает script.js, класс .is-anim) ---------- */

.crs.is-anim .crs-top__lexa { opacity: 0; transition: opacity 0.8s ease; }
.crs.is-anim .crs-top.is-go .crs-top__lexa { opacity: 1; }

.crs.is-anim .crs-bub,
.crs.is-anim .crs-pro {
  opacity: 0;
  transform: translateY(24px) scale(0.97);
  transition: opacity 0.6s, transform 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  transition-delay: var(--d);
}
.crs.is-anim .crs-top:not(.is-go) .crs-bub { transform: scale(0.6) rotate(6deg); }
.crs.is-anim .crs-top.is-go .crs-bub,
.crs.is-anim .crs-top.is-go .crs-pro { opacity: 1; transform: none; }
.crs.is-anim .crs-top.is-go .crs-pro:hover { transform: translateY(-4px); transition-delay: 0s; }
.crs.is-anim .crs-top.is-go.is-hide .crs-bub {
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  transition: opacity 0.35s, transform 0.35s;
  transition-delay: 0s;
}

.crs.is-anim .crs-bub__heart { animation: crsBeat 1.6s ease-in-out infinite; }
@keyframes crsBeat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.18); }
  30% { transform: scale(1); }
  45% { transform: scale(1.12); }
}

/* карточки раздаются слева направо, будто выезжают из-под соседней */
.crs.is-anim .crs-card {
  opacity: 0;
  transform: translateX(-90px) scale(0.94);
  transition: opacity 0.5s, transform 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.1), box-shadow 0.25s;
  transition-delay: var(--d, 0s);
}
.crs.is-anim .crs-grid.is-go .crs-card { opacity: 1; transform: none; }
.crs.is-anim .crs-grid.is-go .crs-card:hover { transform: translateY(-3px); transition-delay: 0s; }

.crs.is-anim .crs-msg { opacity: 0; transform: translateY(8px); }
.crs.is-anim .crs-msg.is-on { opacity: 1; transform: none; }

/* ------------------------------------------------------------------
   Планшет 768–1023: всё в потоке, карточки курса листаются
   ------------------------------------------------------------------ */

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

  .crs__stage {
    width: auto;
    height: auto;
    zoom: 1;
  }

  /* Лекса и пузырь привязаны к центру, преимущества — сеткой под фото */
  .crs-top {
    position: relative;
    inset: auto;
    height: auto;
    padding: 552px 32px 0;
  }

  .crs-top__glow { left: calc(50% - 431px); top: -40px; width: 862px; height: 616px; }

  .crs-top__lexa { left: calc(50% - 272px); width: 544px; height: 530px; }
  .crs-top__lexa img { width: 544px; }

  .crs-bub {
    left: calc(50% + 103px);
    top: 20px;
    width: 188px;
    height: 148px;
    border-radius: 26px;
  }
  .crs-bub::before {
    left: -15px;
    top: 102px;
    width: 18px;
    height: 30px;
    clip-path: polygon(18px 0, 0 30px, 18px 26.1px);
  }
  .crs-bub__text { top: 25px; font-size: 42px; line-height: 47.5px; }
  .crs-bub__badge { left: 147px; top: -25px; width: 72px; height: 70px; }

  .crs-pros {
    position: relative;
    z-index: 3;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  .crs-pro,
  .crs-pro--sm {
    position: relative;
    left: auto;
    top: auto;
    width: auto;
    height: 194px;
    gap: 23px;
    padding: 32px 20px;
  }
  .crs-pro--r1 { order: 1; }
  .crs-pro--l2 { order: 2; }
  .crs-pro--r2 { order: 3; }

  .crs-pro h3,
  .crs-pro--sm h3 { font-size: 22px; line-height: 26.4px; }
  .crs-pro p,
  .crs-pro--sm p,
  .crs-pro--l1 p { width: auto; font-size: 16px; line-height: 18.4px; }

  .crs-pro .crs-pro__ic { left: auto; right: 22px; top: 34px; }

  /* Панель: фон собран из тех же пятен, что в макете */
  .crs-panel {
    position: relative;
    left: auto;
    top: auto;
    width: auto;
    height: auto;
    margin: 32px 24px 0;
    padding: 55px 0 44px;
    overflow: hidden;
    border-radius: 40px;
    background:
      radial-gradient(283px 381px at 505px 771px, rgba(229, 249, 116, 0.18), rgba(229, 249, 116, 0)),
      radial-gradient(432px 596px at 795px 406px, rgba(90, 40, 200, 0.75), rgba(90, 40, 200, 0)),
      radial-gradient(432px 542px at 302px 611px, rgba(122, 75, 224, 0.75), rgba(122, 75, 224, 0)),
      radial-gradient(432px 542px at 569px 289px, rgba(196, 160, 255, 0.6), rgba(196, 160, 255, 0)),
      #2a1a5e;
  }

  .crs-panel__head { position: static; padding: 0 32px; }
  .crs-panel__head h2 { font-size: 44px; line-height: 50.6px; white-space: normal; }
  .crs-panel__head p { margin-top: 10px; font-size: 18px; line-height: 32px; }
  .crs-panel__head p br { display: none; }

  .crs-stats { position: static; margin: 32px 32px 0; }
  .crs-stats li,
  .crs-stats li + li { width: auto; height: 78px; }
  .crs-stats b { font-size: 22px; line-height: 26.4px; }

  .crs-tabs { position: static; width: max-content; margin: 16px 32px 0; }

  /* Карточки — те же 307 px, ужатые zoom до 250 (как в макете:
     вместе с фразами и чатом). Отступы ниже — в единицах до zoom */
  .crs-grid {
    --z: 0.8143;
    position: static;
    grid-template-columns: repeat(4, 284.9px) 307px;
    row-gap: 19.65px;
    margin: -9.8px 0 -49.1px;
    padding: 49.1px 39.3px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 39.3px;
    scrollbar-width: none;
    zoom: var(--z);
  }
  .crs-grid::-webkit-scrollbar { display: none; }
  .crs-card { scroll-snap-align: start; }

  .crs-card h3 { padding: 30px 30.7px 0; }
}

/* ------------------------------------------------------------------
   Телефон < 768
   ------------------------------------------------------------------ */

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

  .crs-top { padding: 464px 16px 0; }

  .crs-top__glow { left: calc(50% - 273px); top: 40px; width: 554px; height: 396px; }

  .crs-top__lexa { left: calc(50% - 231px); top: 66px; width: 390px; height: 380px; }
  .crs-top__lexa img { width: 390px; }

  .crs-bub {
    left: calc(50% + 36px);
    top: 90px;
    width: 132px;
    height: 110px;
    border-radius: 19px;
  }
  .crs-bub::before {
    left: -11px;
    top: 74px;
    width: 13px;
    height: 21px;
    clip-path: polygon(13px 0, 0 21px, 13px 18.3px);
  }
  .crs-bub__text { top: 18px; font-size: 30px; line-height: 35.5px; }
  .crs-bub__badge { left: 106px; top: -18px; width: 52px; height: 50.5px; }

  .crs-pros { grid-template-columns: 1fr; gap: 12px; }

  .crs-pro,
  .crs-pro--sm { height: 170px; gap: 28px; padding: 20px; }

  .crs-pro h3,
  .crs-pro--sm h3 { font-size: 20px; line-height: 24px; }
  .crs-pro p,
  .crs-pro--sm p,
  .crs-pro--l1 p { font-size: 15px; line-height: 18px; }

  .crs-pro .crs-pro__ic { top: 22px; }

  .crs-panel {
    margin: 24px 16px 0;
    padding: 40px 0 32px;
    border-radius: 32px;
    background:
      radial-gradient(283px 381px at 366px 771px, rgba(229, 249, 116, 0.18), rgba(229, 249, 116, 0)),
      radial-gradient(432px 596px at 587px 406px, rgba(90, 40, 200, 0.75), rgba(90, 40, 200, 0)),
      radial-gradient(432px 542px at 336px 611px, rgba(122, 75, 224, 0.75), rgba(122, 75, 224, 0)),
      radial-gradient(432px 542px at 472px 289px, rgba(196, 160, 255, 0.6), rgba(196, 160, 255, 0)),
      #2a1a5e;
  }

  .crs-panel__head { padding: 0 12px; }
  .crs-panel__head h2 { font-size: 30px; line-height: 36px; }
  .crs-panel__head p { margin-top: 12px; font-size: 15px; line-height: 30px; }

  .crs-stats { gap: 12px; margin: 24px 12px 0; }
  .crs-stats li,
  .crs-stats li + li { flex: 1 1 0; height: 80px; padding: 0 12px; font-size: 13px; line-height: 16px; }
  .crs-stats b { font-size: 20px; line-height: 24px; }
  .crs-stats span { width: min-content; white-space: normal; }

  .crs-tabs { width: auto; gap: 0; margin: 16px 12px 0; }
  .crs-tab { flex: 1 1 auto; height: 50px; padding: 0 6px; font-size: 14px; }

  /* 230 px из 307 */
  .crs-grid {
    --z: 0.7492;
    grid-template-columns: repeat(4, 288.3px) 307px;
    row-gap: 16px;
    margin: -21.4px 0 -42.7px;
    padding: 53.4px 26.7px 42.7px;
    scroll-padding: 0 26.7px;
  }

  .crs-card h3 { padding: 30.7px 26.7px 0 34.7px; font-size: 21.4px; line-height: 1.25; }
}
