/* Красные кеды · раздел «Заявка» (#contact) — «крышка закрывается»
   Фон — фирменный паттерн шнурков, плывёт по диагонали (одна плитка за 60 с).
   Текст лежит только на плашках (брендбук: «паттерн фоном, сообщение на белой/тёмной плашке»):
   тёмная плашка с заголовком и контактами, белая — с формой. */

.contact {
  --contact-tile: 480px;
  --contact-pad: clamp(22px, 3.4vw, 48px);
  isolation: isolate;
  overflow: clip;
}
.contact [hidden] { display: none !important; }

/* Паттерн: псевдоэлемент на плитку больше секции, двигаем только transform */
.contact__bg {
  position: absolute; inset: 0; z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.contact__bg::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  right: calc(var(--contact-tile) * -1);
  bottom: calc(var(--contact-tile) * -1);
  background: var(--red) url("../img/brand/pattern-red.webp") 0 0 / var(--contact-tile) var(--contact-tile) repeat;
  will-change: transform;
  animation: contact-drift-480 60s linear infinite;
}
.contact--idle .contact__bg::before { animation-play-state: paused; }
@keyframes contact-drift-480 { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-480px, -480px, 0); } }
@keyframes contact-drift-400 { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-400px, -400px, 0); } }

/* Сетка: слева тёмная плашка (заголовок + контакты), справа белая с формой */
.contact__grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "head card" "info card";
  column-gap: clamp(16px, 2vw, 28px);
  transform-origin: 50% 0;
}

/* Тёмная плашка (surface-ink в разметке): верх (заголовок) и низ (контакты) читаются как одна этикетка */
.contact__head,
.contact__info {
  background: var(--s-bg);
  color: var(--s-fg);
  min-width: 0;
  container-type: inline-size;
}
.contact__head {
  grid-area: head;
  display: grid;
  justify-items: start;
  gap: 18px;
  padding: var(--contact-pad) var(--contact-pad) clamp(24px, 2.6vw, 36px);
  border-radius: var(--r-m) var(--r-m) 0 0;
}
.contact__head .tag { --s-fg: var(--on-dark); --s-bg: var(--ink); }
.contact__title {
  margin-top: 10px;
  color: var(--paper);
  font-size: clamp(2rem, 4.2vw, 3.6rem);
  font-size: min(4.4rem, 11.6cqi);
  line-height: .96;
}
/* Длинное слово в заголовке (без выезда: «Обсудим автоматизацию», ставит lead.js) — кегль меньше, чтобы слово влезло целиком */
.contact__title.contact__title--long {
  font-size: clamp(1.25rem, 2vw, 2rem);
  font-size: min(3.2rem, 7.6cqi);
}
.contact__uz {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(1.15rem, 1.5vw, 1.45rem);
  line-height: 1.2;
  color: var(--paper);
  letter-spacing: -0.005em;
}
.contact__lead {
  margin-top: 6px;
  max-width: 40ch;
  color: var(--on-dark);
  font-size: clamp(1.0625rem, 1.2vw, 1.1875rem);
  font-weight: 500;
  line-height: 1.5;
}

.contact__info {
  grid-area: info;
  display: flex;
  flex-direction: column;
  padding: 0 var(--contact-pad) var(--contact-pad);
  border-radius: 0 0 var(--r-m) var(--r-m);
}
.contact__row {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding-block: clamp(18px, 2vw, 24px);
  border-top: 1.5px solid var(--s-line);
  min-width: 0;
}
.contact__label { color: var(--on-dark-muted); }
.contact__phone {
  max-width: 100%;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 2.6vw, 2.4rem);
  font-size: min(2.6rem, 8.6cqi);
  line-height: 1.05;
  letter-spacing: -0.015em;
  color: var(--paper);
  text-decoration: none;
  white-space: nowrap;
}
.contact__phone:hover { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: .16em; }
.contact__value {
  font-size: 1.1875rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--paper);
  text-decoration: none;
  overflow-wrap: anywhere;
}
a.contact__value:hover { text-decoration: underline; }
.contact__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
/* белый текст на красной кнопке — только крупный (≥ 18 px, полужирный) */
.contact__call,
.lead-manual__actions .btn--red { font-size: 1.125rem; }
.contact__map { margin-top: 4px; font-size: 1.125rem; color: var(--paper); }
.contact__map-arrow { width: 18px; height: 18px; flex: none; transition: transform .25s var(--ease-out); }
.contact__map:hover .contact__map-arrow { transform: translate(2px, -2px); }
.contact__note {
  /* примечание прижато к низу плашки, как подвал этикетки: плашка тянется до высоты формы */
  margin-top: auto;
  padding-top: clamp(18px, 2vw, 24px);
  border-top: 1.5px solid var(--s-line);
  max-width: 46ch;
  color: var(--on-dark-muted);
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1.5;
}

/* Белая плашка с формой */
.contact__card {
  grid-area: card;
  position: relative;
  display: grid;
  min-width: 0;
  padding: clamp(22px, 4vw, 56px);
  border-radius: var(--r-m);
  container: leadcard / inline-size;
}
/* фокус на белой плашке — красный (base.css на красном разделе делает его белым) */
.contact .contact__card :focus-visible { outline-color: var(--red); }

/* Форма */
.lead-form {
  display: grid;
  align-content: start;
  gap: clamp(22px, 2.4vw, 30px);
  min-width: 0;
}
.lead-form__top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px 24px;
  padding-bottom: clamp(16px, 2vw, 24px);
  border-bottom: 1.5px solid var(--s-line);
}
.lead-form__title { min-width: 0; outline: none; }
.lead-form__kicker { color: var(--s-muted); }
.lead-form__row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(18px, 2vw, 24px);
  align-items: start;
}
@container leadcard (max-width: 540px) {
  .lead-form__row { grid-template-columns: minmax(0, 1fr); }
}
.lead-form__opt {
  margin-left: 6px;
  font-size: .8125rem;
  font-weight: 400;
  color: var(--s-muted);
}
.lead-form__phone { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
/* поле-ловушка для ботов: вне экрана и вне порядка табуляции, но не display:none */
.lead-form__trap {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  pointer-events: none;
}
.lead-form__group { min-width: 0; margin: 0; padding: 0; border: 0; }
.lead-form__legend { display: block; padding: 0; margin-bottom: 12px; }
.lead-form .chip span { min-height: 44px; padding: 0 18px; transition: background-color .2s, color .2s, border-color .2s, transform .2s var(--ease-out); }
.lead-form .chip:active span { transform: scale(.97); }
/* «Автоматизация и ИИ» — маленькая красная точка-индикатор */
.lead-form__chip-ai span::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
  flex: none;
}
/* Файлы к заявке: зона «приложить или перетащить» (линия реза, как на развёртке коробки) и список с превью */
.lead-files { position: relative; display: grid; gap: 10px; min-width: 0; }
.lead-files__head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 4px 16px;
}
.lead-files__count { color: var(--s-muted); }
/* само поле выбора скрыто визуально, но остаётся в порядке табуляции; фокус рисуем на зоне */
.lead-files__input {
  position: absolute; top: 0; left: 0;
  width: 1px; height: 1px;
  margin: 0; padding: 0;
  opacity: 0;
  overflow: hidden;
  clip-path: inset(50%);
}
.lead-files__drop {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  min-width: 0;
  padding: 18px 20px;
  border: 2px dashed color-mix(in srgb, var(--s-fg) 24%, transparent);
  border-radius: 14px;
  background: var(--s-bg);
  cursor: pointer;
  transition: border-color .2s, background-color .2s;
}
.lead-files__drop:hover { border-color: var(--s-fg); }
.lead-files__input:focus-visible + .lead-files__drop { outline: 3px solid var(--red); outline-offset: 3px; }
.lead-files__input:disabled + .lead-files__drop { cursor: progress; opacity: .6; }
.lead-files__icon {
  display: grid; place-items: center;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  transition: background-color .2s, transform .25s var(--ease-out);
}
.lead-files__icon svg { width: 22px; height: 22px; transition: transform .25s var(--ease-out); }
.lead-files__drop:hover .lead-files__icon svg { transform: translateY(-2px); }
.lead-files__text { display: grid; gap: 4px; min-width: 0; }
.lead-files__line { font-weight: 600; font-size: 1.0625rem; line-height: 1.3; }
.lead-files__cta {
  text-decoration: underline;
  text-decoration-color: var(--red);
  text-decoration-thickness: 2px;
  text-underline-offset: .22em;
}
.lead-files__or { color: var(--s-muted); font-weight: 500; }
.lead-files__drop-now { display: none; }
.lead-files__hint { font-size: .875rem; line-height: 1.45; color: var(--s-muted); }
.lead-files__types { margin-top: 2px; font-size: .6875rem; color: var(--s-muted); overflow-wrap: anywhere; }
/* файлы тащат над плашкой */
.lead-files__drop.is-drag {
  border-style: solid;
  border-color: var(--red);
  background: color-mix(in srgb, var(--red) 6%, var(--paper));
}
.lead-files__drop.is-drag .lead-files__icon { background: var(--red); color: var(--ink); transform: scale(1.06); }
.lead-files__drop.is-drag .lead-files__cta,
.lead-files__drop.is-drag .lead-files__or { display: none; }
.lead-files__drop.is-drag .lead-files__drop-now { display: inline; }
.contact__card.is-dragging { box-shadow: inset 0 0 0 3px var(--red); }
/* лимит набран: зона остаётся рабочей (скажет, почему не добавилось), но тише */
.lead-files__drop.is-full .lead-files__icon { background: var(--muted); }
/* на тач-экранах перетаскивать нечем */
@media (hover: none) { .lead-files__or { display: none; } }
.lead-files__error { margin-top: -2px; }

.lead-files__list { list-style: none; display: grid; gap: 8px; min-width: 0; }
.lead-files__item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 8px;
  border: 1.5px solid var(--s-line);
  border-radius: 14px;
  background: var(--s-bg);
  animation: lead-file-in .45s var(--ease-out) both;
}
@keyframes lead-file-in { from { transform: translateY(8px); opacity: .001; } to { transform: none; opacity: 1; } }
.lead-files.is-flash .lead-files__item { animation: lead-flash-field 1.4s var(--ease-out); }
/* превью: шахматка под прозрачным логотипом, как в редакторе */
.lead-files__thumb {
  display: grid; place-items: center;
  width: 52px; height: 52px;
  overflow: hidden;
  border-radius: 10px;
  background: repeating-conic-gradient(var(--soft) 0 25%, var(--paper) 0 50%) 0 0 / 12px 12px;
  box-shadow: inset 0 0 0 1px var(--s-line);
}
.lead-files__thumb img { width: 100%; height: 100%; object-fit: contain; }
/* не картинка: бирка с расширением, как артикул на коробке */
.lead-files__thumb--doc { background: var(--ink); box-shadow: none; }
.lead-files__badge { color: var(--paper); font-size: .6875rem; letter-spacing: .06em; }
.lead-files__meta { display: grid; gap: 3px; min-width: 0; }
.lead-files__name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  min-width: 0;
  font-weight: 600;
  font-size: .9375rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.lead-files__info { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; color: var(--s-muted); font-size: .6875rem; }
.lead-files__src { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.lead-files__src::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
.lead-files__remove {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--s-line);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--s-fg);
  font-size: .875rem;
  font-weight: 600;
  transition: border-color .2s, color .2s;
}
.lead-files__remove svg { width: 14px; height: 14px; flex: none; }
.lead-files__remove:hover { border-color: var(--red); color: var(--red-press); }
.lead-files__remove:disabled { opacity: .5; cursor: progress; }
@container leadcard (max-width: 420px) {
  .lead-files__drop { gap: 12px; padding: 14px; }
  .lead-files__icon { width: 40px; height: 40px; }
  .lead-files__item { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; padding: 6px; }
  .lead-files__thumb { width: 44px; height: 44px; }
  .lead-files__remove { padding: 0 11px; }
}

/* подсветка того, что подставил другой раздел */
.lead-form .chip.is-flash span { animation: lead-flash 1.2s var(--ease-out); }
.lead-form__comment.is-flash { animation: lead-flash-field 1.4s var(--ease-out); }
@keyframes lead-flash {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--red) 55%, transparent); }
  100% { box-shadow: 0 0 0 14px color-mix(in srgb, var(--red) 0%, transparent); }
}
@keyframes lead-flash-field {
  0%, 35% { border-color: var(--red); }
  100% { border-color: var(--s-line); }
}

.lead-form__submit { display: grid; gap: 12px; }
.lead-form__btn { min-height: 64px; font-size: 1.0625rem; }
.lead-form__legal { font-size: .875rem; line-height: 1.45; color: var(--s-muted); }
.lead-form__status {
  padding: 10px 14px;
  border-left: 3px solid var(--red);
  background: var(--soft);
  border-radius: 0 var(--r-s) var(--r-s) 0;
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--ink);
}
.lead-form__status:empty { display: none; }
/* во время отправки состояние уже видно на кнопке и в прогрессе: строку статуса оставляем только для скринридера */
.lead-form.is-loading .lead-form__status {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Прогресс загрузки файлов: красный шнурок растёт, чёрный наконечник едет по нему */
.lead-form__progress { --p: 0; display: grid; gap: 8px; }
.lead-form__progress-track { position: relative; height: 12px; }
.lead-form__progress-track::before {
  content: "";
  position: absolute; left: 0; right: 0; top: 5px;
  height: 2px;
  border-radius: 2px;
  background: var(--s-line);
}
.lead-form__progress-fill {
  position: absolute; left: 0; right: 0; top: 4px;
  height: 4px;
  border-radius: 2px;
  background: var(--red);
  transform-origin: 0 50%;
  transform: scaleX(var(--p));
  transition: transform .3s var(--ease-out);
}
.lead-form__progress-tip {
  position: absolute; top: 0;
  left: calc(var(--p) * (100% - 22px));
  width: 22px; height: 12px;
  border-radius: 6px;
  background: var(--ink);
  transition: left .3s var(--ease-out);
}
.lead-form__progress-label { color: var(--s-muted); }
.lead-form__progress.is-done .lead-form__progress-tip { animation: lead-tip-wait .9s var(--ease-io) infinite alternate; }
@keyframes lead-tip-wait { from { transform: translateX(0); } to { transform: translateX(-10px); } }

/* Состояние отправки: наконечник едет по шнурку */
.lead-form__aglet {
  display: none;
  position: relative;
  width: 58px; height: 12px;
  flex: none;
}
.lead-form__aglet-lace {
  position: absolute; left: 0; right: 0; top: 5px;
  height: 2px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--paper) 30%, transparent);
}
.lead-form__aglet-lace::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background: var(--paper);
  transform-origin: 0 50%;
  animation: lead-lace .8s var(--ease-io) infinite alternate;
}
.lead-form__aglet-tip {
  position: absolute; left: 0; top: 0;
  width: 22px; height: 12px;
  border-radius: 6px;
  background: var(--paper);
  box-shadow: inset -6px 0 0 var(--red);
  animation: lead-tip-slide .8s var(--ease-io) infinite alternate;
}
@keyframes lead-tip-slide { from { transform: translateX(0); } to { transform: translateX(36px); } }
@keyframes lead-lace { from { transform: scaleX(.08); } to { transform: scaleX(.7); } }
.lead-form.is-loading .lead-form__aglet { display: inline-block; }
.lead-form.is-loading .lead-form__arrow { display: none; }
.lead-form.is-loading .lead-form__btn { cursor: progress; }
.lead-form.is-loading .lead-form__btn:hover { transform: none; }

/* Плашки после отправки */
.lead-done,
.lead-manual {
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 18px;
  min-width: 0;
  animation: lead-rise .7s var(--ease-out) both;
}
.lead-form.is-back { animation: lead-rise .6s var(--ease-out) both; }
@keyframes lead-rise { from { transform: translateY(22px); opacity: .001; } to { transform: none; opacity: 1; } }

.lead-done { align-self: center; padding-block: clamp(12px, 3vw, 40px); }
.lead-done__lace { width: clamp(150px, 40%, 220px); height: auto; overflow: visible; }
.lead-done__path {
  fill: none;
  stroke: var(--red);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: lead-draw 1.1s var(--ease-out) .15s both;
}
.lead-done__tip {
  fill: none;
  stroke: var(--ink);
  stroke-width: 13;
  stroke-linecap: round;
  transform-box: fill-box;
  transform-origin: 0 100%;
  animation: lead-tip-in .45s var(--ease-out) 1.05s both;
}
@keyframes lead-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes lead-tip-in { from { transform: scale(.2); opacity: .001; } to { transform: none; opacity: 1; } }
.lead-done__title,
.lead-manual__title { font-size: clamp(1.5rem, 2.6vw, 2.2rem); outline: none; }
.lead-done__text,
.lead-manual__text { font-size: var(--fs-lead); line-height: 1.5; color: var(--s-muted); max-width: 46ch; }
.lead-done__again { margin-top: 8px; }

.lead-done__files {
  max-width: 52ch;
  padding: 10px 14px;
  border-left: 3px solid var(--ink);
  border-radius: 0 var(--r-s) var(--r-s) 0;
  background: var(--soft);
  color: var(--ink);
  font-size: var(--fs-small);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.lead-done__files.is-failed { border-left-color: var(--red); }
.lead-done__ig { font-size: 1.125rem; }

/* Ручной режим с файлами: честно — файлы сами не ушли */
.lead-manual__files {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  border: 2px dashed color-mix(in srgb, var(--red) 70%, transparent);
  border-radius: 12px;
}
.lead-manual__files-title { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); }
.lead-manual__files-title::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.lead-manual__files-text { font-size: var(--fs-small); line-height: 1.5; color: var(--s-muted); }
.lead-manual__files-list { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.lead-manual__file {
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
  font-size: .6875rem;
  text-transform: none;
  letter-spacing: .02em;
  overflow-wrap: anywhere;
}

.lead-manual__fail {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-radius: var(--r-s);
  background: var(--soft);
  color: var(--ink);
}
.lead-manual__fail::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.lead-manual__pre {
  width: 100%;
  max-height: 300px;
  margin: 0;
  padding: 16px 18px;
  overflow: auto;
  border: 1.5px solid var(--s-line);
  border-radius: 12px;
  background: var(--soft);
  color: var(--ink);
  font-family: var(--f-mono);
  font-size: .875rem;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}
.lead-manual__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.lead-manual__hint { font-size: var(--fs-small); font-weight: 600; color: var(--ink); }
.lead-manual__hint:empty { display: none; }
.lead-manual__call {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px 16px;
  width: 100%;
  padding-top: 18px;
  border-top: 1.5px solid var(--s-line);
}
.lead-manual__call-label { color: var(--s-muted); flex-basis: 100%; }
.lead-manual__num {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(1.25rem, 2vw, 1.6rem);
  line-height: 1.1;
  user-select: all;
  white-space: nowrap;
}
.lead-manual__edit {
  padding: 4px 0;
  border: 0;
  background: none;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: .2em;
}
.lead-manual__edit:hover { color: var(--red); }

/* Планшет и телефон: одна колонка — заголовок, форма, контакты */
@media (max-width: 1023px) {
  .contact__grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "head" "card" "info";
    row-gap: clamp(24px, 5vw, 36px);
  }
  .contact__head { border-radius: var(--r-m); padding-bottom: var(--contact-pad); }
  .contact__info { border-radius: var(--r-m); padding-top: 4px; }
  .contact__info > .contact__row:first-of-type { border-top: 0; }
  .contact__title { font-size: min(4.4rem, 11.2cqi); }
  .contact__phone { font-size: min(2.6rem, 9cqi); }
}
@media (max-width: 600px) {
  .contact { --contact-tile: 400px; }
  .contact__bg::before { animation-name: contact-drift-400; }
  .lead-form__top { display: grid; }
  .lead-form .chip span { padding: 0 15px; font-size: .9375rem; }
}

@media (prefers-reduced-motion: reduce) {
  .contact__bg::before { animation: none; }
  .lead-form__aglet-tip, .lead-form__aglet-lace::before { animation: none; }
  .lead-form__aglet-tip { transform: translateX(18px); }
  .lead-form__progress-fill, .lead-form__progress-tip { transition: none; }
  .lead-form__aglet-lace::before { transform: scaleX(.4); }
}
