/* ------------------------------------------------------------------
   Секция 10 «Связь» — «Пиши нам в Telegram»
   Десктоп 121:20583, планшет 175:17224, телефон 175:17496.
   Десктоп — сцена 1600 px, масштабируется через --s (script.js).
   Справа — макет окна Telegram: список чатов и открытый диалог.
   Анимация появления (.is-anim): текст проявляется, окно поднимается,
   чаты выезжают по очереди, сообщение «всплывает», точки печатают.
   ------------------------------------------------------------------ */

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

.cnt__stage {
  position: relative;
  display: flex;
  align-items: flex-start;
  width: 1600px;
  margin: 0 auto;
  padding: 40px;
  zoom: var(--s, 1);
}

/* фиолетовое свечение за окном чата */
.cnt__glow {
  position: absolute;
  left: 705px;
  top: 74px;
  width: 992px;
  height: 501px;
  border-radius: 250.5px;
  background: rgba(117, 32, 252, 0.3);
  filter: blur(120px);
  pointer-events: none;
}

/* ---------- Текст слева ---------- */

.cnt__head {
  position: relative;
  flex: none;
  width: 580px;
  padding-top: 103px;
}

.cnt__mail {
  --k: 1.3;
  position: relative;
  width: 125px;
  height: 86px;
}

/* конверт → самолётик (как в артефакте): сцена 500×150, конверт в ней
   стоит в (14, 60) размером 96×66 и масштабом --k совпадает с .cnt__mail */
.cnt__fly {
  position: absolute;
  left: calc(-14px * var(--k));
  top: calc(-60px * var(--k));
  width: 500px;
  height: 150px;
  transform: scale(var(--k));
  transform-origin: 0 0;
  pointer-events: none;
}
.cnt__trail {
  position: absolute;
  inset: 0;
  width: 500px;
  height: 150px;
  overflow: visible;
}
.cnt__trail-m { stroke-dasharray: 1; stroke-dashoffset: 1; }

.cnt__env {
  position: absolute;
  left: 14px;
  top: 60px;
  width: 96px;
  height: 66px;
  perspective: 400px;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.45));
}
.cnt__half {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  transform-origin: 50% 50%;
}
.cnt__half--l { clip-path: inset(0 50% 0 0); }
.cnt__half--r { clip-path: inset(0 0 0 50%); }
.cnt__half svg,
.cnt__lbl {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.cnt__plane {
  position: absolute;
  left: 0;
  top: 0;
  width: 44px;
  height: 44px;
  offset-path: path("M62 93C91 66.5 131 57.5 150 75.5C164 89.5 148 104.5 135 94.5C122 84.5 144 63.5 181 66.5C217 69.5 241 61.5 271 49.5");
  offset-anchor: 14px 28px;
  offset-rotate: auto 39deg;
  offset-distance: 0%;
  opacity: 0;
  filter: drop-shadow(0 6px 18px rgba(229, 249, 116, 0.45));
}
.cnt__plane svg {
  display: block;
  width: 44px;
  height: 44px;
  fill: var(--c-lime);
  transform-origin: 14px 28px;
}

.cnt__puff { position: absolute; left: 62px; top: 93px; }
.cnt__puff i {
  position: absolute;
  left: -3px;
  top: -3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-lime);
  opacity: 0;
}
.cnt__puff i:nth-child(1) { --x: -34px; --y: -18px; }
.cnt__puff i:nth-child(2) { --x: 30px; --y: -24px; }
.cnt__puff i:nth-child(3) { --x: -26px; --y: 22px; }
.cnt__puff i:nth-child(4) { --x: 36px; --y: 16px; }
.cnt__puff i:nth-child(5) { --x: 2px; --y: -36px; }
.cnt__puff i:nth-child(6) { --x: -4px; --y: 32px; background: #a774ff; }

.cnt__head h2 {
  margin: 26px 0 0;
  font: 400 72px/76px var(--font-display);
  color: #fff;
}
.cnt__head h2 > span:first-child { display: block; }

.cnt__l2 {
  display: flex;
  align-items: flex-start;
}

/* лаймовая плашка, повёрнутая вокруг левого верхнего угла */
.cnt__tag {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 422px;
  height: 80px;
  margin: 8px 0 0 0.246em;
  border-radius: 20px;
  background: var(--c-lime);
  color: #14111c;
  line-height: 80px;
  transform: rotate(-2deg);
  transform-origin: 0 0;
}

.cnt__head p {
  margin: 21.3px 0 0;
  font: 400 20px/30px var(--font-text);
  color: rgba(255, 255, 255, 0.72);
}
.cnt__head p + p { margin-top: 14px; }

/* ---------- Окно Telegram ---------- */

.cnt__card {
  position: relative;
  display: flex;
  flex: none;
  width: 940px;
  height: 560px;
  padding: 1px;
  border-radius: 32px;
  background: #141418;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
/* рамка поверх содержимого */
.cnt__card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  pointer-events: none;
}

/* список чатов */
.cnt__side {
  flex: none;
  width: 319px;
  padding: 22.75px 12px 0;
  background: #18171f;
}

.cnt__side-h {
  margin: 0 0 0 10px;
  font: 400 22px/22px var(--font-display);
  color: #fff;
}

.cnt__chats {
  margin: 35.25px 0 0;
  padding: 0;
  list-style: none;
}

.cnt-chat {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 74px;
  padding: 0 10px;
  border-radius: 16px;
}
.cnt-chat.is-active { background: #7a4be0; }
.cnt-chat[role="button"] { cursor: pointer; transition: background-color 0.3s; }
.cnt-chat[role="button"]:not(.is-active):hover { background: rgba(255, 255, 255, 0.05); }
.cnt-chat:focus-visible { outline: 2px solid var(--c-lime); outline-offset: -2px; }

.cnt-chat__ava {
  display: grid;
  flex: none;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
}
.cnt-chat__ava svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cnt-chat__ava--lexa { background: linear-gradient(135deg, #8a38f5, #d4baff 55%, #e5f974); }
.cnt-chat__ava--lexa img {
  width: calc(100% - 3px);
  height: calc(100% - 3px);
  border-radius: 50%;
  background: #2a2233;
  object-fit: cover;
}
.cnt-chat__ava--lime { background: var(--c-lime); }
.cnt-chat__ava--lime svg { stroke: #14111c; }
.cnt-chat__ava--violet { background: #8a38f5; }
.cnt-chat__ava--violet svg { stroke: #fff; }

.cnt-chat__txt {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.cnt-chat__txt b {
  font: 700 15px/20px var(--font-text);
  color: #fff;
}
.cnt-chat__msg {
  overflow: hidden;
  font: 400 14px/18px var(--font-text);
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.cnt-chat.is-active .cnt-chat__msg { color: rgba(255, 255, 255, 0.72); }

.cnt-chat__meta {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.cnt-chat__meta time {
  font: 400 12px/16px var(--font-text);
  color: rgba(255, 255, 255, 0.4);
}
.cnt-chat.is-active .cnt-chat__meta time { color: rgba(255, 255, 255, 0.72); }
.cnt-chat__meta i {
  min-width: 22px;
  height: 18px;
  border-radius: 9px;
  background: var(--c-lime);
  color: #14111c;
  font: normal 700 12px/18px var(--font-text);
  text-align: center;
  transition: opacity 0.3s, transform 0.3s;
}
.cnt-chat.is-read .cnt-chat__meta i { opacity: 0; transform: scale(0.4); }

/* открытый диалог */
.cnt__pane {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  background: radial-gradient(120% 90% at 80% 0, #221a3a, #141219 60%);
}

.cnt__top {
  display: flex;
  flex: none;
  align-items: flex-start;
  gap: 12px;
  height: 78px;
  padding: 16px 24px 0;
  background: rgba(20, 18, 25, 0.6);
}
.cnt__top .cnt-chat__ava { width: 42px; height: 42px; }

.cnt__who {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.cnt__who b {
  font: 700 16px/20px var(--font-text);
  color: #fff;
}
.cnt__who span {
  font: 400 13px/16px var(--font-text);
  color: #a774ff;
}

.cnt__msgs {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 26px;
}

.cnt__bubble {
  align-self: flex-end;
  padding: 10px 14px 9px;
  border-radius: 18px 18px 6px 18px;
  background: #7a4be0;
  color: #fff;
  font: 400 16px/1.35 var(--font-text);
  white-space: nowrap;
}
.cnt__bubble small {
  display: block;
  margin-top: 5px;
  font: 400 12px/16px var(--font-text);
  text-align: right;
  opacity: 0.6;
}

.cnt__bubble--in {
  align-self: flex-start;
  max-width: 82%;
  border-radius: 18px 18px 18px 6px;
  background: #24212d;
  white-space: normal;
}

.cnt__typing {
  display: flex;
  align-self: flex-start;
  gap: 4px;
  padding: 12px 16px;
  border-radius: 18px 15.5px 15.5px 6px;
  background: #24212d;
}
.cnt__typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
}

.cnt__btn {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 58px;
  margin: 18px 20px 24px;
  border-radius: 999px;
  background: var(--c-lime);
  color: var(--c-ink);
  font: 400 17px/20px var(--font-display);
  white-space: nowrap;
  transition: background-color 0.2s, transform 0.2s;
}
.cnt__btn svg { flex: none; width: 30px; height: 30px; fill: #141418; }
.cnt__btn:hover { background: #d6eb5c; }
.cnt__btn:active { transform: scale(0.97); }

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

.cnt.is-anim .cnt__head > * {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s, transform 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  transition-delay: calc(var(--i, 0) * 0.1s);
}
.cnt.is-anim .cnt__head > h2 { --i: 1; }
.cnt.is-anim .cnt__head > p { --i: 2; }
.cnt.is-anim .cnt__head > p + p { --i: 3; }
.cnt.is-anim .cnt__head.is-go > * { opacity: 1; transform: none; }

/* плашка «Telegram» докручивается до своего угла */
.cnt.is-anim .cnt__tag {
  transform: rotate(-9deg) scale(0.9);
  transition: transform 0.8s cubic-bezier(0.3, 1.5, 0.4, 1) 0.35s;
}
.cnt.is-anim .cnt__head.is-go .cnt__tag { transform: rotate(-2deg); }

/* окно поднимается, внутри по очереди: чаты, сообщение, «печатает», кнопка */
.cnt.is-anim .cnt__card {
  opacity: 0;
  transform: translateY(48px) scale(0.97);
  transition: opacity 0.6s, transform 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.05);
}
.cnt.is-anim .cnt__card.is-go { opacity: 1; transform: none; }

.cnt.is-anim .cnt-chat {
  opacity: 0;
  transform: translateX(-20px);
  transition: opacity 0.5s, transform 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  transition-delay: calc(0.3s + var(--i) * 0.08s);
}
.cnt.is-anim .cnt__card.is-go .cnt-chat { opacity: 1; transform: none; }

/* сообщения сценария (script.js): появляются по одному */
.cnt.is-anim .cnt__msgs > * {
  animation: cnt-msg 0.5s cubic-bezier(0.3, 1.4, 0.5, 1) both;
}
.cnt.is-anim .cnt__bubble { transform-origin: 100% 100%; }
.cnt.is-anim .cnt__bubble--in,
.cnt.is-anim .cnt__typing { transform-origin: 0 100%; }
.cnt.is-anim .cnt__card:not(.is-go) .cnt__msgs > * { visibility: hidden; }
@keyframes cnt-msg {
  from { opacity: 0; transform: translateY(12px) scale(0.85); }
}

/* статус в шапке диалога меняется плавно */
.cnt.is-anim .cnt__who span.is-swap { animation: cnt-fade 0.3s both; }
@keyframes cnt-fade { from { opacity: 0; } }

.cnt.is-anim .cnt__btn {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s 0.5s, transform 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.1) 0.5s,
    background-color 0.2s;
}
.cnt.is-anim .cnt__card.is-go .cnt__btn { opacity: 1; transform: none; }
.cnt.is-anim .cnt__card.is-go .cnt__btn:active { transform: scale(0.97); transition-delay: 0s; }

/* конверт складывается в самолётик и улетает по пунктиру — цикл 5.2 s,
   запускается, когда заголовок появился на экране */
.cnt.is-anim .cnt__head.is-go .cnt__trail-m { animation: cnt-trail 5.2s linear infinite; }
.cnt.is-anim .cnt__head.is-go .cnt__env { animation: cnt-env 5.2s cubic-bezier(.4, 0, .2, 1) infinite; }
.cnt.is-anim .cnt__head.is-go .cnt__half--l { animation: cnt-fold-l 5.2s cubic-bezier(.5, 0, .3, 1) infinite; }
.cnt.is-anim .cnt__head.is-go .cnt__half--r { animation: cnt-fold-r 5.2s cubic-bezier(.5, 0, .3, 1) infinite; }
.cnt.is-anim .cnt__head.is-go .cnt__lbl { animation: cnt-lbl 5.2s linear infinite; }
.cnt.is-anim .cnt__head.is-go .cnt__plane { animation: cnt-plane 5.2s linear infinite; }
.cnt.is-anim .cnt__head.is-go .cnt__plane svg { animation: cnt-pop 5.2s cubic-bezier(.3, 1.6, .5, 1) infinite; }
.cnt.is-anim .cnt__head.is-go .cnt__puff i { animation: cnt-puff 5.2s ease-out infinite; }

@keyframes cnt-trail {
  0%, 44% { stroke-dashoffset: .98; opacity: 1; }
  88% { stroke-dashoffset: 0; opacity: 1; }
  96%, 100% { stroke-dashoffset: 0; opacity: 0; }
}
@keyframes cnt-env {
  0% { opacity: 0; transform: translateY(16px) scale(.85) rotate(-6deg); }
  8% { opacity: 1; transform: none; }
  22% { opacity: 1; transform: translateY(-6px) rotate(-3deg); }
  34% { opacity: 1; transform: translateY(-2px) scale(.78) rotate(8deg); }
  38%, 100% { opacity: 0; transform: scale(.4) rotate(14deg); }
}
@keyframes cnt-fold-l {
  0%, 24% { transform: none; }
  35%, 100% { transform: translateX(10px) scaleX(.2) skewY(8deg); }
}
@keyframes cnt-fold-r {
  0%, 24% { transform: none; }
  35%, 100% { transform: translateX(-10px) scaleX(.2) skewY(-8deg); }
}
@keyframes cnt-lbl {
  0%, 24% { opacity: 1; }
  28%, 100% { opacity: 0; }
}
@keyframes cnt-plane {
  0%, 36% { opacity: 0; offset-distance: 0%; }
  38% { opacity: 1; offset-distance: 0%; }
  44% { offset-distance: 2%; }
  88% { opacity: 1; offset-distance: 100%; }
  94%, 100% { opacity: 0; offset-distance: 100%; }
}
@keyframes cnt-pop {
  0%, 35% { transform: scale(.2); }
  42% { transform: scale(1.15); }
  46%, 100% { transform: scale(1); }
}
@keyframes cnt-puff {
  0%, 35% { opacity: 0; transform: none; }
  37% { opacity: 1; }
  50% { opacity: 0; transform: translate(var(--x), var(--y)) scale(.4); }
  100% { opacity: 0; }
}

/* кнопка «дышит», по ней пробегает блик; на наведении замирает */
.cnt__btn { position: relative; overflow: hidden; }
.cnt__btn::after {
  content: "";
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: -30%;
  width: 36%;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0));
  transform: skewX(-20deg) translateX(-120%);
  pointer-events: none;
}
.cnt.is-anim .cnt__card.is-go .cnt__btn { animation: cnt-beat 3s ease-in-out 1.1s infinite; }
.cnt.is-anim .cnt__card.is-go .cnt__btn::after { animation: cnt-shine 3s cubic-bezier(.45, 0, .25, 1) 1.1s infinite; }
.cnt.is-anim .cnt__card.is-go .cnt__btn:hover,
.cnt.is-anim .cnt__card.is-go .cnt__btn:hover::after { animation-play-state: paused; }

@keyframes cnt-beat {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 rgba(229, 249, 116, 0); }
  50% { transform: scale(1.03, 1.08); box-shadow: 0 14px 44px rgba(229, 249, 116, 0.35); }
}
@keyframes cnt-shine {
  0%, 35% { transform: skewX(-20deg) translateX(-120%); }
  75%, 100% { transform: skewX(-20deg) translateX(560%); }
}

/* точки «печатает» — постоянно, если анимации не отключены */
@media (prefers-reduced-motion: no-preference) {
  .cnt__typing i { animation: cnt-dot 1.2s ease-in-out infinite; }
  .cnt__typing i:nth-child(2) { animation-delay: 0.15s; }
  .cnt__typing i:nth-child(3) { animation-delay: 0.3s; }
}
@keyframes cnt-dot {
  0%, 60%, 100% { opacity: 0.45; transform: none; }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ------------------------------------------------------------------
   Планшет 768–1023: текст над окном
   ------------------------------------------------------------------ */

@media (max-width: 1023px) {
  /* свечение выходит за край экрана — режем только по горизонтали */
  .cnt { margin-top: 96px; }

  .cnt__stage {
    display: block;
    width: auto;
    padding: 24px 32px;
    zoom: 1;
  }

  .cnt__glow {
    left: 292px;
    top: 300px;
    width: 595px;
    height: 301px;
    border-radius: 150.5px;
    filter: blur(72px);
  }

  .cnt__head { width: auto; padding-top: 4px; }
  .cnt__head h2 { margin-top: 16.5px; font-size: 50px; line-height: 72.5px; }
  .cnt__tag {
    width: 295px;
    height: 56px;
    margin-top: 12px;
    border-radius: 14px;
    line-height: 56px;
  }
  .cnt__head br { display: none; }
  .cnt__head p { margin-top: 24.3px; font-size: 18px; line-height: 22px; }

  .cnt__card { width: auto; height: 520px; margin-top: 40.2px; padding: 0; }

  .cnt__side { width: 306px; padding-top: 22.25px; }
  .cnt__side-h { font-size: 18px; line-height: 18px; }
  .cnt__chats { margin-top: 33.75px; }

  .cnt-chat { height: auto; padding: 12px 10px; }
  .cnt-chat__txt { gap: 0; }
  .cnt-chat__msg { white-space: normal; }
  .cnt-chat.is-active .cnt-chat__msg { font-size: 16px; line-height: 22px; }
  .cnt-chat__meta i { height: 16px; border-radius: 8px; line-height: 16px; }

  .cnt__btn { height: 62px; }
}

/* ------------------------------------------------------------------
   Телефон < 768: список чатов над диалогом
   ------------------------------------------------------------------ */

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

  .cnt__stage { padding: 16px; }

  .cnt__glow { left: -86px; top: 700px; }

  .cnt__head { padding-top: 0; }
  .cnt__mail { --k: .73; width: 70px; height: 48px; }
  .cnt__head h2 { margin-top: 46.9px; font-size: 40px; line-height: 51.4px; }
  .cnt__tag {
    width: 236px;
    height: 48px;
    margin-top: 5.7px;
    border-radius: 11px;
    line-height: 48px;
  }
  .cnt__head p { margin-top: 25.86px; font-size: 16px; line-height: 18px; }

  .cnt__card { flex-direction: column; height: auto; margin-top: 32.1px; }

  .cnt__side { width: auto; padding: 17px 12px 12px; }
  .cnt__side-h { font-size: 16px; line-height: 16px; }
  .cnt__chats { margin-top: 13px; }

  .cnt-chat { height: 74px; padding: 0 10px; }
  .cnt-chat__msg { white-space: nowrap; }
  .cnt-chat.is-active .cnt-chat__msg { font-size: 14px; line-height: 18px; }

  .cnt__top { padding: 16px 22px 0; }
  .cnt__msgs { flex: none; height: 196px; padding: 20px 16px 0; }
  .cnt__btn { height: 58px; margin: 16px 16px 24px; }
}
