/* ==========================================================
   My Misty — реферальная страница
   Макеты: 375 (мобильный) и 1440 (десктоп).
   < 1024px — мобильная раскладка (на планшете колонка до 560px),
   ≥ 1024px — десктопная.
   ========================================================== */

:root {
  --bg: #050b0f;
  --white: #edf2ff;
  --text: #edf2ff;
  --field: rgba(255, 255, 255, 0.06);
  --btn-text-dark: #121212;

  --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Cormorant Garamond", "Times New Roman", serif;

  --page-pad: 25px;          /* боковой отступ мобильного макета */
  --container: 560px;        /* предел ширины мобильной раскладки (планшет) */
  --col: 100%;               /* колонка блока с кодом и кнопками */

  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, p, ol {
  margin: 0;
}

ol {
  padding: 0;
  list-style: none;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
}

/* Длинные слова/коды не ломают вёрстку */
h1, h2, h3, p, .referral__code {
  overflow-wrap: anywhere;
}

:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.page {
  position: relative;
  overflow-x: clip;
  isolation: isolate;
}

/* Вертикальные направляющие мобильного макета (край — центр — край) */
.page::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 44px;
  bottom: 126px;
  left: 50%;
  width: min(100% - var(--page-pad) * 2, var(--container) - var(--page-pad) * 2);
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0.1;
  background:
    linear-gradient(var(--white), var(--white)) left / 1px 100% no-repeat,
    linear-gradient(var(--white), var(--white)) center / 1px 100% no-repeat,
    linear-gradient(var(--white), var(--white)) right / 1px 100% no-repeat;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding-left: max(var(--page-pad), env(safe-area-inset-left, 0px));
  padding-right: max(var(--page-pad), env(safe-area-inset-right, 0px));
}

/* Размытые градиентные «мазки» на фоне */
.bg {
  position: absolute;
  z-index: -1;
  pointer-events: none;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.bg--hero {
  top: 131px;
  left: calc(50% - 295px);
  width: 588px;
  height: 872px;
  background-image: url("/referral/assets/img/bg-mob-1.svg");
}

.bg--howto {
  top: 80px;
  left: calc(50% - 912px);
  width: 1556px;
  height: 1709px;
  background-image: url("/referral/assets/img/bg-mob-2.svg");
}

/* ---------------- Hero (мобильный) ---------------- */

.hero {
  position: relative;
  padding-top: 78px;
}

.hero__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 32px;
  line-height: 32px;
  text-transform: uppercase;
  max-width: 315px;
}

.hero__lead {
  margin-top: 24px;
  font-size: 18px;
  line-height: 26px;
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: 42px;
}

.step {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 146px;
  max-width: 100%;
}

.step:first-child {
  margin-left: 2px;
}

/* Зигзаг: второй шаг сдвинут во вторую половину колонки */
.step:nth-child(2) {
  margin-left: 50%;
  max-width: 50%;
}

.step:nth-child(3) {
  width: 187px;
}

.step__title {
  font-size: 18px;
  line-height: 26px;
  font-weight: 500;
}

.step__desc {
  font-size: 13px;
  line-height: 20px;
  letter-spacing: -0.13px;
}

.step__code {
  display: block;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-skip-ink: none;
  text-underline-position: from-font;
}

.step__code[hidden] {
  display: none;
}

/* Блок с кодом */
.referral {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: var(--col);
  margin: 24px auto 0;
  padding: 10px 0;
}

.referral__field-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.referral__label {
  font-size: 18px;
  line-height: 24px;
  font-variant-numeric: lining-nums tabular-nums;
}

.referral__field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  cursor: pointer;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease;
}

.referral__field:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
}

.referral__field:disabled {
  cursor: default;
}

.referral__field:disabled .referral__icon {
  opacity: 0.3;
}

.referral__code {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 22px;
  line-height: 28px;
  font-weight: 600;
  font-variant-numeric: lining-nums tabular-nums;
}

.referral__icon {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
}

/* Состояние «Скопировано» */
.referral__toast {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--white);
  color: var(--btn-text-dark);
  font-size: 13px;
  line-height: 20px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}

.referral__field.is-copied .referral__toast {
  opacity: 1;
  transform: none;
}

/* Кнопки сторов — в одну линию на всю ширину колонки */
.referral__stores {
  display: flex;
  gap: 12px;
}

.btn {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 10px 14px 12px 15px;
  border-radius: 8px;
  font-size: 14px;
  line-height: normal;
  font-weight: 500;
  letter-spacing: -0.14px;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

/* Очень узкие экраны (< 360): разрешаем перенос, чтобы не было горизонтального скролла */
@media (max-width: 359px) {
  .btn {
    padding-left: 8px;
    padding-right: 8px;
    white-space: normal;
  }
}

.btn:hover {
  opacity: 0.85;
}

.btn--light {
  background: var(--white);
  color: var(--btn-text-dark);
}

.btn--dark {
  background: var(--bg);
  color: var(--text);
}

.referral__rules {
  align-self: center;
  font-size: 12px;
  line-height: 16px;
  text-decoration: underline;
  text-decoration-skip-ink: none;
  text-underline-position: from-font;
}

/* ---------------- Как воспользоваться (мобильный) ---------------- */

.howto {
  position: relative;
  padding-top: 46px;
}

.howto__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 32px;
  line-height: 32px;
  text-transform: uppercase;
  max-width: 315px;
}

.scenarios {
  position: relative;
  width: 100%;
  max-width: var(--container);
  margin: 24px auto 0;
  padding: 0 var(--page-pad);
}

/*
 * Сценарий: вертикальная «рельса» (линия — текст — линия) у одного края
 * и телефон. Внизу сценария — горизонтальная линия к рельсе следующего.
 * Все отличия сценариев — в переменных ниже.
 */
.scenario {
  --line-inset: 21px;     /* где проходит вертикальная линия относительно края колонки */
  --line-top: 49px;
  --gap-top: 24px;
  --gap-bottom: 24px;
  --rail-w: 164px;
  --phone-x: 44%;
  --phone-w: 57.5%;
  --phone-pt: 157px;
  --phone-pb: 24px;
  --conn-l: 21px;
  --conn-r: 22px;

  position: relative;
  padding: var(--phone-pt) 0 var(--phone-pb);
}

/* горизонтальная соединительная линия */
.scenario::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: var(--conn-l);
  right: var(--conn-r);
  height: 1px;
  background: var(--white);
}

.scenario__rail {
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: var(--rail-w);
  max-width: 100%;
  pointer-events: none;
}

.scenario__line {
  width: 1px;
  margin-left: var(--line-inset);
  background: var(--white);
}

.scenario__line--top {
  flex: 0 0 var(--line-top);
}

.scenario__line--bottom {
  flex: 1 1 0;
}

.scenario__text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: var(--gap-top) 0 var(--gap-bottom);
  pointer-events: auto;
}

.scenario__title {
  font-size: 22px;
  line-height: 28px;
  font-weight: 400;
  font-variant-numeric: lining-nums tabular-nums;
}

.scenario__desc {
  font-size: 13px;
  line-height: 20px;
  letter-spacing: -0.13px;
}

.scenario__phone {
  display: block;
  width: var(--phone-w);
  margin-left: var(--phone-x);
}

.scenario__phone img {
  width: 100%;
  height: auto;
}

.scenario--2 {
  --line-top: 39px;
  --gap-top: 23px;
  --gap-bottom: 27px;
  --rail-w: 190px;
  --phone-x: 6.8%;
  --phone-pt: 153px;
  --phone-pb: 0px;
  --conn-l: 22px;
  --conn-r: 21px;
}

/* рельса справа, текст выровнен вправо */
.scenario--2 .scenario__rail {
  left: auto;
  right: 0;
  align-items: flex-end;
  text-align: right;
}

.scenario--2 .scenario__line {
  margin-left: 0;
  margin-right: 22px;
}

.scenario--3 {
  --line-top: 80px;
  --gap-bottom: 44px;
  --rail-w: 245px;
  --phone-x: 35.7%;
  --phone-pt: 334px;
  --phone-pb: 0px;
  --conn-l: 22px;
  --conn-r: 22px;
}

.scenario--3 .scenario__line {
  margin-left: 22px;
}

.desktop-only {
  display: none;
}

/* ---------------- Футер ---------------- */

.footer {
  padding: 34px var(--page-pad) calc(22px + var(--safe-bottom));
  text-align: center;
  font-size: 10px;
  line-height: 14px;
  opacity: 0.3;
}

/* ==========================================================
   Десктоп (макет 1440)
   ========================================================== */
@media (min-width: 1024px) {
  :root {
    --text: #e9ecee;
    --container: 1440px;
    --col: min(634px, 100%);
  }

  .page::before,
  .mobile-only {
    display: none;
  }

  .bg--hero {
    top: -132px;
    left: calc(50% - 925px);
    width: 1861px;
    height: 1633px;
    background-image: url("/referral/assets/img/bg-desktop.svg");
  }

  .bg--howto {
    display: none;
  }

  .hero {
    padding-top: 170px;
    text-align: center;
  }

  .hero__title {
    max-width: none;
    font-size: 64px;
    line-height: 64px;
    letter-spacing: 1.6px;
  }

  .hero__lead {
    margin-top: 25px;
    font-size: 28px;
    line-height: 38px;
  }

  .steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 40px;
    max-width: 1340px;
    margin: 109px auto 0;
  }

  .step,
  .step:first-child,
  .step:nth-child(2),
  .step:nth-child(3) {
    width: auto;
    max-width: 404px;
    margin: 0 auto;
    align-items: center;
  }

  .step__title {
    font-size: 28px;
    line-height: 38px;
    font-weight: 400;
  }

  .step__desc {
    font-size: 18px;
    line-height: 26px;
    letter-spacing: -0.18px;
  }

  .step:first-child .step__desc {
    max-width: 299px;
  }

  .referral {
    gap: 24px;
    margin-top: 130px;
  }

  .referral__label {
    font-size: 28px;
    line-height: 38px;
  }

  .referral__field {
    min-height: 64px;
    padding: 10px;
  }

  .referral__code {
    font-size: 28px;
    line-height: 38px;
    font-weight: 700;
  }

  .referral__toast {
    font-size: 14px;
  }

  .btn {
    min-height: 70px;
    font-size: 28px;
    line-height: 38px;
    font-weight: 400;
    letter-spacing: 0;
  }

  .referral__rules {
    padding-bottom: 2px;
    border-bottom: 1px solid var(--white);
    font-size: 14px;
    line-height: 20px;
    font-weight: 500;
    letter-spacing: -0.14px;
    text-decoration: none;
    color: var(--white);
  }

  .howto {
    padding-top: 87px;
  }

  .howto__title {
    max-width: 999px;
    margin: 0 auto;
    font-size: 64px;
    line-height: 64px;
    letter-spacing: 1.6px;
    text-align: center;
  }

  .scenarios {
    margin-top: 92px;
    padding: 0;
  }

  /* На десктопе рельса центрирована по своей вертикальной линии */
  .scenario {
    --rail-x: 25%;
    --line-top: 204px;
    --gap-top: 92px;
    --gap-bottom: 92px;
    --rail-w: 368px;
    --phone-x: 44.58%;
    --phone-w: 32.08%;
    --phone-pt: 54px;
    --phone-pb: 64px;
    --conn-l: 25%;
    --conn-r: 16.39%;
  }

  .scenario__rail,
  .scenario--2 .scenario__rail {
    left: var(--rail-x);
    right: auto;
    width: min(var(--rail-w), calc(2 * min(var(--rail-x), 100% - var(--rail-x)) - 32px));
    transform: translateX(-50%);
    align-items: center;
    text-align: center;
  }

  .scenario__line,
  .scenario--2 .scenario__line,
  .scenario--3 .scenario__line {
    margin: 0;
  }

  .scenario__title {
    font-size: 28px;
    line-height: 38px;
  }

  .scenario__desc {
    font-size: 18px;
    line-height: 26px;
    letter-spacing: -0.18px;
  }

  .scenario--2 {
    --rail-x: 83.61%;
    --line-top: 289px;
    --rail-w: 253px;
    --phone-x: 30.42%;
    --phone-pt: 172px;
    --phone-pb: 2px;
    --conn-l: 17.43%;
    --conn-r: 16.39%;
  }

  .scenario--3 {
    --rail-x: 17.43%;
    --line-top: 352px;
    --rail-w: 436px;
    --phone-x: 44.58%;
    --phone-pt: 334px;
    --phone-pb: 0px;
    --conn-l: 17.43%;
    --conn-r: 13.75%;
  }

  .desktop-only {
    display: revert;
  }

  .footer {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 222px 0 calc(97px + var(--safe-bottom)) 75%;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
