/* Окно покупки сертификата (живёт внутри iframe на сайте магазина).
   Цвета и шрифты — переменные; тема магазина переопределяет их в /theme.css (из config/shop.js). */

:root {
  --accent: #E5484D;
  --accent-ink: #fff;
  --accent-soft: color-mix(in srgb, var(--accent) 9%, var(--surface));
  --accent-text: color-mix(in srgb, var(--accent) 78%, #000);
  --bg: #fff;
  --surface: #fff;           /* поля ввода, чипы */
  --raised: #fff;            /* выбранный сегмент, стрелки карусели */
  --soft: #f4f4f6;           /* второстепенные кнопки и плашки */
  --soft-hover: #ebebef;
  --ink: #1d1d1f;
  --ink-2: #4a4a52;
  --muted: #6e6e76;
  --placeholder: #a5a5ad;
  --line: #e4e4e9;
  --line-strong: #cdcdd4;
  --track: #e6e6eb;
  --focus-border: #8e8e96;
  --focus-ring: rgba(29, 29, 31, .07);
  --danger: #d4343a;
  --ok: #1a7f4b;
  --toast-bg: #1d1d1f;
  --toast-ink: #fff;
  --bar-bg: rgba(255, 255, 255, .8);
  --font: 'Manrope Variable', Manrope, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-display: var(--font);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

.app {
  position: relative;
  isolation: isolate;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}
/* Тёплый свет сверху, как от лампы над столом, и лёгкое «зерно» — фон не плоский.
   Цвета задаёт тема (--gc-aura, --gc-grain-opacity); без темы — ничего не видно. */
.app::before,
.app::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
.app::before {
  background:
    radial-gradient(80% 42% at 50% 16%, var(--gc-aura, transparent), transparent 72%),
    radial-gradient(120% 60% at 50% 120%, color-mix(in srgb, var(--gc-aura, transparent) 50%, transparent), transparent 70%);
}
.app::after {
  background: var(--gc-grain);
  mix-blend-mode: overlay;
  opacity: var(--gc-grain-opacity, 0);
}
::selection { background: color-mix(in srgb, var(--gc-gold, var(--accent)) 40%, transparent); }
input, textarea { caret-color: var(--accent); }
/* строки закреплены: когда полоса шагов скрыта, остальные блоки не должны съезжать */
.top { grid-row: 1; }
.progress { grid-row: 2; }
.body { grid-row: 3; }
.foot { grid-row: 4; }

/* ---------- Шапка и шаги ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 8px 20px;
}
.top__shop { color: var(--brand-ink, var(--muted)); font-family: var(--brand-font, var(--font-display)); font-size: 16px; font-weight: var(--brand-weight, 400); letter-spacing: .02em; }
.top__logo { display: block; width: auto; height: 22px; color: var(--brand-ink, var(--ink)); }
.top__title { font-family: var(--font-display); font-size: 18px; font-weight: var(--heading-weight, 700); letter-spacing: -.005em; }
.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: var(--soft);
  color: var(--ink);
  cursor: pointer;
}
.icon-btn:hover { background: var(--soft-hover); }
.is-standalone .icon-btn[data-act="close"] { display: none; }

.progress { padding: 4px 20px 6px; }
.progress ol {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.progress button {
  display: block;
  width: 100%;
  height: 16px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.progress button { position: relative; }
.progress button::before,
.progress button::after {
  content: '';
  display: block;
  height: 4px;
  border-radius: 2px;
  background: var(--track);
}
/* Заливка шага доезжает слева направо, а не перекрашивается */
.progress button::after {
  position: absolute;
  inset: 0 0 auto;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform .6s cubic-bezier(.65, 0, .35, 1);
}
.progress li.is-done button::after,
.progress li.is-current button::after { transform: scaleX(1); }
.progress li.is-todo button { cursor: default; }
.progress__label { margin-top: 2px; color: var(--muted); font-size: 13px; font-weight: 600; }

/* ---------- Тело шага ---------- */
.body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 20px 24px;
  outline: none;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--ink) 18%, transparent) transparent;
}
.boot { display: grid; place-items: center; height: 100%; }
.body { position: relative; }
/* Уходящий шаг: копия поверх, тает и уезжает в сторону (app.js → stepOut) */
.step--ghost {
  position: absolute;
  left: 20px;
  right: 20px;
  pointer-events: none;
}
/* Карточка сертификата в полёте между шагами (app.js → flyCard) */
.gift-card--flying {
  position: fixed;
  z-index: 70;
  margin: 0;
  transform-origin: 0 0;
  pointer-events: none;
}
.step__h {
  margin: 8px 0 16px;
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: var(--heading-weight, 700);
  line-height: 1.15;
  letter-spacing: -.01em;
  outline: none;
}
.step__lead { margin: -8px 0 16px; color: var(--muted); font-size: 15px; }

/* ---------- Подвал с кнопками ---------- */
.foot {
  display: flex;
  gap: 10px;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  /* тонкая линия сверху, к краям тает */
  background:
    linear-gradient(90deg, transparent, var(--hairline, var(--line)) 18% 82%, transparent) top / 100% 1px no-repeat,
    var(--bg);
}
.foot:empty { display: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: filter .15s, transform .1s, background-color .15s;
}
.btn:active { transform: scale(.98); }
.btn svg { flex: none; width: 20px; height: 20px; }
.btn--primary {
  flex: 1;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 84%, #fff), var(--accent) 60%);
  color: var(--accent-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), 0 12px 26px -14px color-mix(in srgb, var(--accent) 80%, transparent);
}
.btn--primary:hover { filter: brightness(1.06); }
.btn--ghost { background: var(--soft); color: var(--ink); }
.btn--ghost:hover { background: var(--soft-hover); }
.btn--block { width: 100%; }
.btn--small { min-height: 38px; padding: 0 14px; border-radius: 11px; font-size: 14px; background: var(--ink); color: var(--bg); }
.btn + .btn--block { margin-top: 10px; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.is-loading { color: transparent !important; position: relative; pointer-events: none; }
.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2.5px solid color-mix(in srgb, var(--accent-ink) 35%, transparent);
  border-top-color: var(--accent-ink);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn--ghost.is-loading::after {
  border-color: color-mix(in srgb, var(--ink) 18%, transparent);
  border-top-color: var(--ink);
}
.spinner {
  display: inline-block;
  width: 30px;
  height: 30px;
  border: 3px solid color-mix(in srgb, var(--ink) 12%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Номинал ---------- */
.hero { position: relative; isolation: isolate; max-width: 300px; margin: 2px auto 20px; }
.hero::before,
.review-card::before { /* тёплый свет под карточкой */
  content: '';
  position: absolute;
  inset: -18% -16% -30%;
  z-index: -1;
  background: radial-gradient(closest-side, var(--gc-aura, transparent), transparent);
  pointer-events: none;
}
.hero .gift-card,
.review-card .gift-card {
  box-shadow: 0 2px 4px rgba(0, 0, 0, .2), 0 28px 46px -24px rgba(0, 0, 0, .75),
    inset 0 0 0 1px color-mix(in srgb, var(--gc-gold, #fff) 20%, transparent);
}
.hero .gift-card__amount { font-variant-numeric: tabular-nums; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chip {
  min-height: 52px;
  padding: 0 6px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font-family: var(--num-font, inherit);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color .2s, background-color .2s, color .2s;
}
.chip:hover { border-color: var(--line-strong); }
.chip.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.chip--other { font-family: inherit; font-size: 15px; }
/* Только фиксированные номиналы: пять кнопок — три сверху, две пошире снизу */
.chips--fixed[data-count='5'] { grid-template-columns: repeat(6, 1fr); }
.chips--fixed[data-count='5'] .chip { grid-column: span 2; }
.chips--fixed[data-count='5'] .chip:nth-child(n + 4) { grid-column: span 3; }

/* ---------- Поля ---------- */
.field { display: grid; gap: 6px; margin-top: 16px; border: 0; padding: 0; min-width: 0; }
.field__label { padding: 0; font-size: 14px; font-weight: 700; }
.field__opt { color: var(--muted); font-weight: 500; }
.field__row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.field__hint { margin: 0; color: var(--muted); font-size: 13px; }
.field__error { margin: 0; color: var(--danger); font-size: 13px; font-weight: 600; }
.field__error:empty { display: none; }

.input {
  width: 100%;
  min-height: 52px;
  padding: 13px 16px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font-size: 16px; /* 16px — иначе iPhone приближает страницу при вводе */
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder { color: var(--placeholder); }
/* фокус — нейтральный: фирменный цвет бывает красным и выглядел бы как ошибка */
.input:focus { border-color: var(--focus-border); box-shadow: 0 0 0 4px var(--focus-ring); }
.input.is-invalid { border-color: var(--danger); }
.input.is-invalid:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 16%, transparent); }
.textarea { min-height: 132px; resize: none; line-height: 1.45; }
.input-wrap { position: relative; }
.input-suffix {
  position: absolute;
  top: 50%;
  right: 16px;
  translate: 0 -50%;
  color: var(--muted);
  font-weight: 700;
  pointer-events: none;
}
.input--rub { padding-right: 42px; font-weight: 700; font-variant-numeric: tabular-nums; }
.counter { color: var(--muted); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.counter.is-near { color: var(--accent-text); }
.counter.is-full { color: var(--danger); }

.suggest {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-self: start;
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.suggest svg { width: 16px; height: 16px; }

/* ---------- Карусель обложек ---------- */
.carousel {
  --item: min(74cqw, 330px);
  position: relative;
  margin: 0 -20px;
  container-type: inline-size;
}
.carousel__track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 10px calc((100cqw - var(--item)) / 2) 14px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  outline: none;
}
.carousel__track::-webkit-scrollbar { display: none; }
.carousel__track.is-gliding { scroll-snap-type: none; } /* плавная прокрутка стрелками: привязка не мешает */
.carousel__item {
  flex: 0 0 var(--item);
  padding: 0;
  border: 0;
  background: none;
  text-align: center;
  scroll-snap-align: center;
  cursor: pointer;
  /* --p — положение относительно центра (-1…1), --a — расстояние; ставит app.js при прокрутке */
  opacity: calc(1 - var(--a, 0) * .42);
  transform: perspective(900px) rotateY(calc(var(--p, 0) * -16deg)) scale(calc(1 - var(--a, 0) * .1));
  transform-origin: 50% 45%;
  will-change: transform;
}
.carousel__item .gift-card { transition: box-shadow .5s ease; }
.carousel__item.is-on .gift-card {
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5.5px var(--accent), 0 16px 30px -12px rgba(0, 0, 0, .4);
}
.carousel__name { display: block; margin-top: 12px; font-size: 15px; font-weight: 700; }
.carousel__arrow {
  position: absolute;
  top: calc(50% - 36px);
  z-index: 2;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--raised);
  color: var(--ink);
  box-shadow: 0 2px 12px rgba(0, 0, 0, .18);
  cursor: pointer;
  transition: opacity .2s;
}
.carousel__arrow--prev { left: 10px; }
.carousel__arrow--next { right: 10px; }
.carousel__arrow[disabled] { opacity: 0; pointer-events: none; }
@media (hover: none) { .carousel__arrow { display: none; } }
.dots { display: flex; justify-content: center; gap: 4px; margin-top: 2px; }
.dots + .field__error + .chips { margin-top: 10px; } /* открытка и номинал на одном экране */
.dot {
  position: relative;
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: var(--track);
  cursor: pointer;
  transition: transform .35s cubic-bezier(.16, 1, .3, 1), background-color .35s;
}
.dot::before { content: ''; position: absolute; inset: -8px -4px; } /* палец промахивается — увеличиваем зону нажатия */
.dot.is-on { background: var(--accent); transform: scale(1.4); }

/* ---------- Доставка ---------- */
.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--soft);
}
.seg__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color .2s, color .2s, box-shadow .2s;
}
.seg__btn svg { width: 18px; height: 18px; }
.seg__btn.is-on { background: var(--raised); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 2px 8px rgba(0, 0, 0, .06); }

.note {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--soft);
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.45;
}

.choice { display: grid; gap: 8px; }
.choice__item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.choice__item:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice__item input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.when { display: grid; grid-template-columns: 1.35fr 1fr; gap: 8px; margin-top: 8px; }
.when .input { min-width: 0; }

/* ---------- Проверка ---------- */
.review-card { position: relative; isolation: isolate; max-width: 280px; margin: 0 auto 16px; }
.summary { margin: 16px 0 0; border: 1px solid var(--hairline, var(--line)); border-radius: 16px; }
.summary__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  padding: 12px 8px 12px 14px;
  border-top: 1px solid var(--hairline, var(--line));
}
.summary__row:first-child { border-top: 0; }
.summary dt { grid-column: 1; color: var(--muted); font-size: 13px; font-weight: 600; }
.summary dd { grid-column: 1; margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.summary__msg {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink-2);
  font-weight: 500 !important;
  white-space: pre-line;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.summary__edit {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.summary__edit:hover { background: var(--accent-soft); }
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.45;
  cursor: pointer;
}
.check input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); }
.check a { color: inherit; text-decoration-color: var(--line-strong); text-underline-offset: 2px; }

/* ---------- Оплата ---------- */
.pay { padding: 18px; border: 1.5px solid var(--line); border-radius: 18px; }
.pay__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pay__label { color: var(--muted); font-size: 13px; font-weight: 600; }
.pay__sum { font-size: 30px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.badge {
  padding: 5px 10px;
  border-radius: 999px;
  background: #fff3d1;
  color: #875800;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.pay__methods { display: flex; gap: 6px; margin: 16px 0 10px; }
.pm { padding: 8px 12px; border-radius: 10px; background: var(--soft); color: var(--muted); font-size: 14px; font-weight: 700; }
.pm.is-on { background: var(--ink); color: var(--bg); }
.fake { display: grid; gap: 8px; }
.fake__row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fake__input {
  min-height: 48px;
  padding: 13px 14px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--placeholder);
  font-size: 15px;
}
.pay__note { margin: 12px 0 16px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.pay__wait { display: grid; justify-items: center; gap: 14px; padding: 40px 0; color: var(--muted); text-align: center; }
.pay__fail {
  padding: 16px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--danger) 14%, var(--bg));
  color: var(--ink);
  font-weight: 600;
}
.pay__fail p { margin: 0 0 12px; }
#yk-form { min-height: 300px; }

/* ---------- Готово ---------- */
.done { padding-top: 6px; text-align: center; }
.done__env { /* конверт с печатью: место сверху — сертификат опускается в него сверху */
  position: relative;
  isolation: isolate;
  width: min(230px, 62%);
  aspect-ratio: 100 / 68;
  margin: 100px auto 24px; /* открытый клапан выше конверта — ему нужно место */
  container-type: inline-size;
}
.done__env::before { /* тёплый свет за конвертом */
  content: '';
  position: absolute;
  inset: -40% -30%;
  z-index: -1;
  background: radial-gradient(closest-side, var(--gc-aura, transparent), transparent);
  pointer-events: none;
}
.done .step__h { margin-bottom: 6px; }
.done__lead { margin: 0 0 18px; color: var(--ink-2); }
.done__list { display: grid; gap: 8px; margin: 0 0 20px; padding: 0; list-style: none; text-align: left; }
.done__list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--soft);
  font-size: 15px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.done__list svg { flex: none; width: 20px; height: 20px; margin-top: 1px; color: var(--muted); }

/* ---------- Предпросмотр открытки ---------- */
.preview {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: linear-gradient(172deg, var(--page-bg1, #fff), var(--page-bg2, #f4f4f6));
  animation: fade-in .25s ease both;
}
.preview__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 10px 12px 10px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bar-bg);
  color: var(--ink);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 15px;
  font-weight: 700;
}
.preview__scroll { overflow-y: auto; overscroll-behavior: contain; }
.preview .gcs { --stage-min: calc(100dvh - 58px); }
@keyframes fade-in { from { opacity: 0; } }

/* ---------- Сообщения ---------- */
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 92px;
  z-index: 60;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
  animation: toast-in .25s ease both;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (min-width: 600px) {
  /* открыт напрямую, не во фрейме, на широком экране — держим ширину окна */
  .is-standalone .app { max-width: 480px; margin: 0 auto; box-shadow: 0 0 0 1px var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  .preview, .toast { animation: none; }
  .progress button::after { transition: none; }
  .carousel__item { transform: none; opacity: calc(1 - var(--a, 0) * .42); }
}
