/* =====================================================================
   forms.css — формы: окно «Join the Movement» (Consumers / Businesses) и подписка в подвале.
   Отправка и капча Cloudflare Turnstile — js/main.js (п. 7), обработчик — functions/api/form.js.
   ===================================================================== */

/* поля ввода — общий вид для всех форм */
.form :is(input, textarea), .subscribe input {
  width: 100%; min-width: 0; height: 42px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, .85);
  font: 400 15px var(--text); color: #000;
  transition: border-color .2s, box-shadow .2s;
}
.subscribe input { height: 38px; border-radius: 5px; }
.form textarea { height: 96px; padding: 11px 14px; line-height: 1.35; resize: vertical; }
:is(.form, .subscribe) :is(input, textarea)::placeholder { color: #7d97ac; }
:is(.form, .subscribe) :is(input, textarea):focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(50, 206, 216, .25); }
:is(.form, .subscribe) .is-invalid { border-color: #d64545; }

.form { display: flex; flex-direction: column; gap: 12px; }
.form__row  { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form__foot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; margin-top: 4px; }
.form .btn  { width: auto; min-width: 179px; gap: 16px; }
.form button[disabled], .subscribe button[disabled] { opacity: .6; cursor: progress; }

/* идёт отправка: стрелка в кнопке → крутилка, поля приглушены */
.is-sending .btn[disabled] { opacity: 1; cursor: progress; background: var(--navy); }
.is-sending .btn::after {
  -webkit-mask: none; mask: none; background: none;
  width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: form-spin .7s linear infinite;
}
.is-sending :is(input, textarea) { cursor: progress; color: #4a6275; }
.is-pending [data-msg] { color: var(--navy); font-weight: 500; }

/* подписка в подвале отправлена: кнопка «Subscribed ✓», заметное сообщение */
.subscribe.is-done .btn { background: var(--navy); }
.subscribe.is-done .btn::after {
  -webkit-mask: none; mask: none; background: none; width: 5px; height: 10px; margin: -3px 2px 0 0;
  border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.subscribe.is-done input { border-color: #1d7f86; }
.subscribe.is-done [data-msg], .subscribe.is-error [data-msg] { font-size: 13px; font-weight: 500; }
@keyframes form-spin { to { transform: rotate(360deg); } }

/* ошибка: лёгкое «встряхивание» сообщения */
.is-error [data-msg]:not(:empty) { animation: form-shake .35s; }
@keyframes form-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* отправлено (окно Join): форма скрыта, вместо неё — панель с галочкой */
.form.is-sent > :not(.form__success) { display: none; }
.form__success { display: none; flex-direction: column; align-items: center; gap: 8px; padding: 18px 0 6px; text-align: center; }
.form.is-sent .form__success { display: flex; animation: form-in .4s ease-out; }
.form__success h3 { font: 600 22px/1.2 var(--head); color: var(--navy); }
.form__success p  { max-width: 360px; font-size: 15px; line-height: 1.4; color: #3d5466; }
.form__check {
  width: 52px; height: 52px; border-radius: 50%; background: var(--cyan); position: relative; margin-bottom: 4px;
  animation: form-pop .45s cubic-bezier(.2, 1.6, .4, 1);
}
.form__check::after {
  content: ""; position: absolute; left: 18px; top: 13px; width: 12px; height: 22px;
  border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg);
}
.form__again { margin-top: 6px; font: 500 14px var(--text); color: var(--navy); text-decoration: underline; cursor: pointer; background: none; border: 0; }
@keyframes form-in  { from { opacity: 0; transform: translateY(8px); } }
@keyframes form-pop { from { transform: scale(.3); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .form__success, .form__check, .is-error [data-msg] { animation: none !important; }
}

/* сообщение под формой */
[data-msg] { font-size: 13px; line-height: 1.3; }
.is-error [data-msg] { color: #d64545; }
.is-done  [data-msg] { color: #1d7f86; }

/* капча показывается, только если Cloudflare попросит подтвердить, что вы человек */
[data-captcha]:empty { display: none; }
.subscribe [data-captcha] { flex-basis: 100%; }

@media (max-width: 739px) {
  .form { gap: 8px; }
  .form__row { grid-template-columns: 1fr; gap: 8px; }
  .form :is(input, textarea), .subscribe input { height: 36px; font-size: 14px; }
  .subscribe input { height: 31px; }
  .form textarea { height: 72px; }
  .form .btn { min-width: 144px; }
}

/* пока показана панель «отправлено», декоративный квадрат окна убираем — он наезжает на галочку */
.modal__decor { transition: opacity .3s; }
.modal__box:has(.form.is-active.is-sent) .modal__decor { opacity: 0; }
