/* Окно прокручивается само, когда не помещается по высоте. Пока открыт лист итога или экран
   успеха, прокрутка выключена: они прижаты к низу видимой части и прокручиваются внутри.
   Окно лежит вне сетки .page, поэтому оно само контейнер: иначе --u у кнопок внутри
   считалась бы от ширины экрана, и на ПК «Создать профиль» не влезал в кнопку */
.payment {
  position: relative;
  container-type: inline-size;
  min-height: min(760px, calc(100dvh - 32px));
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: 36px;
  background: var(--color-bg-alt);
}

.payment_sheet-open,
.payment_success-open {
  overflow-y: hidden;
}

.payment__screen {
  display: flex;
  flex-direction: column;
  padding: 24px 20px 24px;
  transition: filter 0.5s ease;
}

.payment_sheet-open .payment__screen,
.payment_success-open .payment__screen {
  filter: brightness(0.7);
}

.payment__top {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* «Моя подписка» — если на этом устройстве уже покупали: открывает ссылку заново */
.payment__mine {
  margin-left: auto;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgb(0 0 0 / 0.1);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.payment__back {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--color-black);
  border-radius: 50%;
  transition: transform var(--dur-fast) var(--ease-back);
}

.payment__back img {
  width: 7px;
  transform: rotate(-90deg);
}

.payment__back:active {
  transform: scale(0.9);
}

.payment__title,
.payment__subtitle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: clamp(20px, 5.9vw, 26px);
  font-weight: 400;
  line-height: 0.9;
}

.payment__title-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 17px;
  background: rgb(0 0 0 / 0.1);
  box-shadow: inset 0 0 0 0.5px rgb(0 0 0 / 0.12);
}

.payment__title-icon img {
  width: auto;
  height: 12px;
}

.payment__plans {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.payment__plan {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "name price"
    "devices price";
  align-items: center;
  column-gap: 8px;
  row-gap: 10px;
  width: 100%;
  min-height: 86px;
  padding: 16px clamp(12px, 3.6vw, 16px) 16px clamp(16px, 6vw, 31px);
  border-radius: 25px;
  background: rgb(0 0 0 / 0.1);
  text-align: left;
  transition:
    background-color 0.4s ease,
    box-shadow 0.4s ease,
    transform 0.4s var(--ease-back);
}

.payment__plan::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 2px;
  border-radius: inherit;
  background: var(--gradient-glass-stroke);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.payment__plan[aria-checked="true"] {
  background: var(--color-black);
  box-shadow:
    0 32px 22px -30px rgb(0 0 0 / 0.45),
    inset 2.5px 2.5px 16.5px -2.5px rgb(255 255 255 / 0.7),
    inset -2.5px -6.25px 17.5px -5.5px rgb(144 137 246 / 0.6),
    inset -8px -9.25px 15px -2.5px rgb(255 255 255 / 0.2);
  transform: scale(1.02);
}

.payment__plan-name {
  grid-area: name;
  align-self: end;
  font-family: var(--font-display);
  font-size: clamp(15px, 4.6vw, 20px);
  font-weight: 500;
  line-height: 0.9;
  color: var(--color-ink-30);
}

.payment__plan[aria-checked="true"] .payment__plan-name {
  padding-bottom: 0.25em;
  margin-bottom: -0.25em;
  background: var(--gradient-holo);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.payment__plan-devices {
  grid-area: devices;
  align-self: start;
  font-size: 14px;
  font-weight: 500;
  line-height: 0.9;
  color: var(--color-ink-30);
}

.payment__plan[aria-checked="true"] .payment__plan-devices {
  color: rgb(255 255 255 / 0.5);
}

/* Сумма и «/ нед» стоят на одной базовой линии, а вся строка — по центру плашки: во flex
   выравнивание по базовой линии прижимало текст к верху */
.payment__plan-price {
  grid-area: price;
  display: grid;
  grid-auto-flow: column;
  place-content: center;
  align-items: baseline;
  gap: 0.25em;
  min-width: clamp(96px, 30vw, 144px);
  height: 54px;
  padding-inline: 8px;
  border-radius: 14px;
  background: rgb(255 255 255 / 0.1);
  box-shadow: inset 2.5px 2.5px 16.5px -2.5px rgb(255 255 255 / 0.8), inset 0 0 0 1px rgb(164 184 255 / 0.25);
  font-family: var(--font-display);
  font-size: 14px;
  white-space: nowrap;
  color: rgb(1 1 1 / 0.3);
}

.payment__plan-price b {
  font-size: clamp(16px, 4.6vw, 20px);
  font-weight: 500;
}

.payment__plan[aria-checked="true"] .payment__plan-price {
  color: var(--color-white);
  box-shadow:
    inset 2.5px 2.5px 16.5px -2.5px rgb(255 255 255 / 0.8),
    inset -2.5px -3.25px 7.5px -2.5px #000000,
    inset 1.25px 1.25px 20px -2.5px var(--color-white),
    inset 0 0 0 1px rgb(164 184 255 / 0.4);
}

.payment__plan-hit {
  position: absolute;
  top: -14px;
  left: -10px;
  width: 64px;
  rotate: 6deg;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.payment__plan[aria-checked="true"] .payment__plan-hit {
  opacity: 1;
}

.payment__subtitle {
  justify-content: center;
  margin-top: clamp(36px, 11vh, 99px);
}

.payment__periods {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.payment__period {
  position: relative;
  height: 40px;
  border-radius: 14px;
  background: rgb(0 0 0 / 0.1);
  font-family: var(--font-display);
  font-size: clamp(11px, 3vw, 13px);
  line-height: 1;
  color: var(--color-ink-30);
  transition: background-color 0.35s ease, color 0.35s ease, box-shadow 0.35s ease;
}

.payment__period[aria-checked="true"] {
  background: var(--color-black);
  color: var(--color-white);
  box-shadow: inset 5px 5px 15px -2px rgb(255 255 255 / 0.8), inset -2.5px -2.5px 9px 0 rgb(255 255 255 / 0.7), 0 6px 6px -4px rgb(0 0 0 / 0.3);
}

/* Стикер скидки лежит на нижней половине кнопки, у левого края, как в макете */
.payment__period-sticker {
  position: absolute;
  top: 50%;
  left: 16%;
  width: 64%;
  pointer-events: none;
}

.payment__pay {
  justify-content: space-between;
  width: 100%;
  min-height: 86px;
  margin-top: 27px;
  padding: 0 16px 0 clamp(20px, 7vw, 30px);
  font-size: clamp(22px, 6.4vw, 28px);
}

.payment__pay-sum {
  display: grid;
  place-items: center;
  min-width: 122px;
  height: 54px;
  padding-inline: 18px;
  border-radius: 30px;
  background: var(--color-pink);
  box-shadow:
    inset 2.5px 2.5px 16.5px -2.5px rgb(255 255 255 / 0.8),
    inset -2.5px -3.25px 7.5px -2.5px #000000,
    inset 1.25px 1.25px 30px -2.5px var(--color-white);
  font-size: clamp(17px, 4.6vw, 20px);
  font-weight: 500;
  color: var(--color-black);
}

/* Лист итога — плавающая белая карточка, как в кадре 286: поля 20 px, скругление 60 */
.payment__sheet,
.payment__status,
.payment__success {
  position: absolute;
  right: clamp(12px, 4.5vw, 20px);
  bottom: clamp(12px, 4.5vw, 20px);
  left: clamp(12px, 4.5vw, 20px);
  z-index: 2;
  display: flex;
  flex-direction: column;
  max-height: calc(100% - 2 * clamp(12px, 4.5vw, 20px));
  overflow-y: auto;
  scrollbar-width: none;
  padding: 10px clamp(16px, 5.5vw, 24px) 20px;
  border-radius: clamp(40px, 13.6vw, 60px);
  background: var(--color-white);
  box-shadow: 0 24px 40px -24px rgb(0 0 0 / 0.35);
  animation: payment-sheet 0.6s var(--ease-out);
}

.payment__sheet[hidden],
.payment__status[hidden],
.payment__success[hidden] {
  display: none;
}

/* Видимая ручка 50 × 6, нажимать можно на полосу 88 × 24 — она возвращает к выбору тарифа */
.payment__handle {
  position: relative;
  flex: none;
  align-self: center;
  width: 88px;
  height: 24px;
}

.payment__handle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 50px;
  height: 6px;
  border-radius: 10px;
  background: rgb(0 0 0 / 0.1);
  translate: -50% -50%;
}

.payment__sheet-icon {
  width: clamp(64px, 20vw, 91px);
  opacity: 0.1;
}

.payment__sum {
  margin-top: clamp(18px, 6.6vw, 29px);
  font-family: var(--font-display);
  font-size: clamp(44px, 13vw, 60px);
  font-weight: 500;
  line-height: 1;
}

.payment__currency {
  font-size: 0.66em;
}

.payment__sum-label {
  margin-top: 18px;
  font-family: var(--font-display);
  font-size: 18px;
}

.payment__details {
  display: grid;
  gap: 9px;
  margin-top: clamp(24px, 9.5vw, 42px);
  padding-bottom: 17px;
  border-bottom: 1px solid rgb(0 0 0 / 0.12);
}

.payment__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
  font-size: clamp(14px, 4.1vw, 18px);
  color: var(--color-ink-30);
}

.payment__row dd {
  margin: 0;
  font-size: clamp(13px, 3.6vw, 16px);
  text-align: right;
  white-space: nowrap;
  color: var(--color-ink);
}

.payment__value {
  display: flex;
  align-items: center;
  gap: 4px;
}

.payment__avatar,
.payment__device {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 17px;
  background: rgb(0 0 0 / 0.1);
}

.payment__avatar img {
  width: 15px;
}

.payment__device img {
  width: 10px;
}

.payment__count {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding-inline: 6px;
  border-radius: 17px;
  background: var(--color-black);
  font-size: 14px;
  font-weight: 700;
  color: var(--color-white);
}

/* Стрелки срока — маленькие треугольники по бокам значения, как в макете */
.payment__step {
  position: relative;
  flex: none;
  width: 18px;
  height: 24px;
}

.payment__step::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  border-block: 4px solid transparent;
  border-left: 6px solid var(--color-black);
  translate: -50% -50%;
}

.payment__step_less::before {
  rotate: 180deg;
}

.payment__step:disabled {
  opacity: 0.2;
  cursor: default;
}

.payment__tariff {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "label thumb"
    "name thumb";
  align-items: center;
  row-gap: 9px;
  padding-block: 12px;
  border-bottom: 1px solid rgb(0 0 0 / 0.12);
}

.payment__tariff-label {
  grid-area: label;
  align-self: end;
  font-size: 12px;
  color: var(--color-ink-40);
}

.payment__tariff-name {
  grid-area: name;
  align-self: start;
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--payment-tariff, #8523c6);
}

.payment__tariff_plan_personal { --payment-tariff: #22a870; }
.payment__tariff_plan_advanced { --payment-tariff: #6f5699; }
.payment__tariff_plan_family { --payment-tariff: #f5197b; }
.payment__tariff_plan_constructor { --payment-tariff: #8523c6; }

.payment__tariff-thumb {
  grid-area: thumb;
  display: grid;
  place-items: center;
  width: 69px;
  height: 52px;
  border-radius: 14px;
  background: radial-gradient(120% 120% at 50% 20%, #ffffff 30%, #e6e6e6), rgb(255 255 255 / 0.7);
  box-shadow: 0 4px 8px -6px rgb(9 9 9 / 0.25), inset 0 0 0 1px rgb(255 255 255 / 0.8);
}

.payment__tariff-thumb img {
  width: 43px;
}

/* Поля кнопки уже, чем у button_size_m: иначе «Создать профиль» не влезает в карточку */
.payment__confirm {
  flex: none;
  width: 100%;
  margin-top: 24px;
  padding-inline: 12px;
}

.payment__success {
  z-index: 3;
  align-items: center;
  padding-top: 0;
  overflow: visible;
  text-align: center;
}

.payment__badge {
  position: relative;
  width: 170px;
  aspect-ratio: 1;
  margin-top: -86px;
}

.payment__badge-star {
  position: absolute;
  inset: -12%;
  width: 124%;
  max-width: none;
  animation: payment-star 0.9s var(--ease-back) both;
}

/* Вектор галочки в файле перевёрнут — в макете «√» */
.payment__badge-check {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36%;
  rotate: 180deg;
  translate: -50% -50%;
  animation: payment-check 0.7s var(--ease-back) 0.35s both;
}

.payment__sticker {
  position: absolute;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.05;
  color: var(--color-black);
  -webkit-text-stroke: 0.62em var(--color-white);
  paint-order: stroke fill;
  filter: drop-shadow(0 4px 10px rgb(0 0 0 / 0.12));
  animation: payment-check 0.7s var(--ease-back) 0.55s both;
}

.payment__sticker_thanks {
  top: 62%;
  left: -58%;
  rotate: 10deg;
}

.payment__sticker_done {
  top: 52%;
  right: -62%;
  rotate: -15deg;
}

.payment__success-text {
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: clamp(18px, 5.2vw, 23px);
  line-height: 1.05;
  color: var(--color-ink-40);
}

@keyframes payment-sheet {
  from {
    transform: translateY(100%);
  }

  to {
    transform: none;
  }
}

@keyframes payment-star {
  from {
    opacity: 0;
    transform: scale(0.3) rotate(-90deg);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes payment-check {
  from {
    opacity: 0;
    scale: 0.4;
  }

  to {
    opacity: 1;
    scale: 1;
  }
}

@media (max-width: 767px) {
  .payment {
    min-height: 100dvh;
    border-radius: 32px 32px 0 0;
  }
}

/* На узких экранах стикеры «Спасибо!» и «Успешная оплата» не должны уходить за край окна */
@media (max-width: 400px) {
  .payment__badge {
    width: 150px;
  }

  .payment__sticker {
    font-size: 14px;
  }

  .payment__sticker_thanks {
    left: -44%;
  }

  .payment__sticker_done {
    right: -46%;
  }
}

/* Почта, способ оплаты и продление на листе итога */
.payment__form {
  display: flex;
  flex-direction: column;
  padding-top: 14px;
}

.payment__renew {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.3;
  color: var(--color-ink);
  cursor: pointer;
}

.payment__renew input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--color-black);
}

.payment__label {
  font-size: 12px;
  color: var(--color-ink-40);
}

.payment__input {
  width: 100%;
  height: 48px;
  margin-top: 6px;
  padding-inline: 16px;
  border: 1.5px solid rgb(0 0 0 / 0.12);
  border-radius: 16px;
  background: rgb(0 0 0 / 0.04);
  font-size: 16px;
  color: var(--color-ink);
  transition: border-color 0.2s ease;
}

.payment__input:focus {
  border-color: var(--color-black);
  outline: none;
}

.payment__input[aria-invalid="true"] {
  border-color: #e5484d;
}

.payment__input + .payment__label {
  margin-top: 14px;
}

.payment__methods {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 6px;
}

.payment__error {
  min-height: 1.3em;
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.3;
  color: #e5484d;
}

.payment__form .payment__confirm {
  margin-top: 8px;
}

.payment__confirm:disabled {
  opacity: 0.6;
  cursor: progress;
}

.payment__note {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
  color: var(--color-ink-40);
}

/* Ожидание оплаты: крутилка и текст по центру карточки */
.payment__status {
  z-index: 3;
  align-items: center;
  padding-block: 36px 24px;
  text-align: center;
}

.payment__spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgb(0 0 0 / 0.1);
  border-top-color: var(--color-black);
  border-radius: 50%;
  animation: payment-spin 0.9s linear infinite;
}

.payment__status-title {
  margin-top: 20px;
  font-family: var(--font-display);
  font-size: clamp(20px, 5.9vw, 26px);
  line-height: 1;
}

.payment__status-text {
  margin-top: 12px;
  font-size: 15px;
  line-height: 1.35;
  color: var(--color-ink-40);
}

/* Ссылка подписки на экране успеха */
.payment__link {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: 18px;
}

.payment__link-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding-inline: 12px;
  border-radius: 14px;
  background: rgb(0 0 0 / 0.06);
  font-size: 13px;
  color: var(--color-ink);
  text-overflow: ellipsis;
}

.payment__copy {
  flex: none;
  height: 44px;
  padding-inline: 14px;
  border-radius: 14px;
  background: var(--color-black);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-white);
}

.payment__link-hint {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--color-ink-40);
}

.payment__success .payment__confirm {
  margin-top: 16px;
}

.payment__telegram {
  margin-top: 12px;
  font-size: 14px;
  color: var(--color-ink-40);
  text-decoration: underline;
  text-underline-offset: 3px;
}

@keyframes payment-spin {
  to {
    rotate: 360deg;
  }
}

@media (prefers-reduced-motion: reduce) {
  .payment__spinner {
    animation-duration: 2.4s;
  }
}

/* Инструкция по подключению на экране успеха */
.payment__howto {
  list-style: decimal;
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
  padding-left: 1.3em;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  color: var(--color-ink);
}

.payment__howto a {
  text-decoration: underline;
  text-underline-offset: 2px;
}
