/* ==========================================================================
   INSTITUTO HAVI YOSSEF — MÓDULO DE LEADS · formulário, modal, estados, FAB
   Segue o mockup aprovado: cartão claro, título em serifa, rótulos em
   versalete, campos arredondados e ação verde sólida.

   Consome os PRIMITIVOS de tokens.css (ink-*, gold-*), não os semânticos:
   dentro de .theme-dark os semânticos viram claros, e o cartão do
   formulário precisa continuar claro em qualquer fundo.

   Verde de ação #1E7A4A: branco sobre ele = 5,3:1 (AA). O #25D366 do
   WhatsApp com texto branco fica em 1,98:1 e reprova.
   ========================================================================== */

:root {
  --hy-acao:        #1E7A4A;
  --hy-acao-hover:  #17633C;
  --hy-acao-ring:   rgba(30, 122, 74, 0.28);
  --hy-erro:        #B42318;   /* 6,1:1 sobre branco */
  --hy-campo-bg:    #FFFDFB;
  --hy-campo-borda: #E3DED6;
  --hy-raio-campo:  10px;
  --hy-raio-card:   var(--r-xl, 22px);
}

/* --------------------------------------------------------------------------
   1. SLOT — reserva a altura antes do JS desenhar (CLS zero)
   -------------------------------------------------------------------------- */
.hy-form-slot { position: relative; }
.js .hy-form-slot:not(.is-ready) { min-height: 39rem; }
.js .hy-form-slot:not(.is-ready) > .hy-fallback { visibility: hidden; }
.hy-fallback {
  padding: var(--sp-6, 1.5rem);
  font-size: var(--fs-300, 0.875rem);
  color: var(--ink-600, #4A4640);
}
.hy-fallback a { color: var(--hy-acao); font-weight: 600; text-decoration: underline; }

.hy-card {
  padding: clamp(1.25rem, 3.5vw, 2rem);
  border: 1px solid var(--ink-100, #E3DED6);
  border-radius: var(--hy-raio-card);
  background: linear-gradient(180deg, #FFFFFF 0%, #FCFAF7 100%);
  box-shadow: var(--shadow-lg, 0 34px 68px -26px rgba(36, 34, 31, 0.18));
  color: var(--ink-600, #4A4640);
}

/* --------------------------------------------------------------------------
   2. FORMULÁRIO
   -------------------------------------------------------------------------- */
.hy-form { display: grid; gap: 1rem; margin: 0; }
.hy-form[hidden], .hy-ok[hidden] { display: none; }

.hy-form__head { display: grid; gap: 0.375rem; margin-block-end: 0.25rem; }
.hy-form__title {
  margin: 0;
  font-family: var(--font-display, Georgia, serif);
  font-size: clamp(1.5rem, 1.3rem + 0.9vw, 1.875rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink-900, #24221F);
  text-wrap: balance;
}
.hy-form__sub {
  margin: 0;
  max-width: 40ch;
  font-size: var(--fs-300, 0.875rem);
  line-height: 1.55;
  color: var(--ink-500, #6B6660);
}

.hy-field { display: grid; gap: 0.4375rem; }
.hy-field__label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-700, #3C3935);
}
.hy-field__input {
  width: 100%;
  min-height: 3.25rem;              /* 52px: alvo de toque confortável */
  padding: 0.75rem 1rem;
  border: 1px solid var(--hy-campo-borda);
  border-radius: var(--hy-raio-campo);
  background-color: var(--hy-campo-bg);
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 1rem;                  /* 16px: o iOS não dá zoom ao focar */
  line-height: 1.3;
  color: var(--ink-900, #24221F);
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
  -webkit-appearance: none;
  appearance: none;
}
.hy-field__input::placeholder { color: #8A847C; opacity: 1; }   /* 3,9:1 — placeholder não é rótulo */
.hy-field__input:hover { border-color: var(--ink-200, #C4BDB3); }
.hy-field__input:focus {
  outline: none;
  border-color: var(--gold-500, #AD8748);
  box-shadow: 0 0 0 4px rgba(173, 135, 72, 0.18);
  background-color: #FFFFFF;
}
.hy-field__input[aria-invalid='true'] {
  border-color: var(--hy-erro);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12);
}

.hy-field__select { position: relative; }
.hy-field__select::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 1.125rem;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 1.5px solid var(--ink-600, #4A4640);
  border-bottom: 1.5px solid var(--ink-600, #4A4640);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.hy-field__select .hy-field__input { padding-inline-end: 2.75rem; cursor: pointer; text-overflow: ellipsis; }

.hy-field__erro {
  margin: 0;
  min-height: 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--hy-erro);
}
.hy-field__erro:empty { display: none; }

/* Consentimento */
.hy-check {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  column-gap: 0.75rem;
  row-gap: 0.25rem;
  margin-block-start: 0.125rem;
}
.hy-check__input {
  width: 1.375rem;
  height: 1.375rem;
  margin: 0.0625rem 0 0;
  accent-color: var(--hy-acao);
  cursor: pointer;
}
.hy-check__input[aria-invalid='true'] { outline: 2px solid var(--hy-erro); outline-offset: 2px; }
.hy-check__label {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ink-600, #4A4640);
  cursor: pointer;
}
.hy-check__label a {
  color: var(--ink-900, #24221F);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--gold-400, #C2A167);
}
.hy-check .hy-field__erro { grid-column: 2; }

/* Honeypot: fora da tela, fora do leitor de tela, fora do Tab. */
.hy-hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px; height: 1px;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   3. BOTÃO DE AÇÃO
   -------------------------------------------------------------------------- */
.hy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  width: 100%;
  min-height: 3.5rem;
  margin-block-start: 0.25rem;
  padding: 0.875rem 1.25rem;
  border: 0;
  border-radius: 12px;
  background-color: var(--hy-acao);
  box-shadow: 0 10px 24px -12px rgba(30, 122, 74, 0.7);
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  line-height: 1.2;
  color: #FFFFFF;
  cursor: pointer;
  transition: background-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.hy-btn svg { width: 1.25rem; height: 1.25rem; flex: none; }
.hy-btn:hover { background-color: var(--hy-acao-hover); transform: translateY(-1px); }
.hy-btn:active { transform: none; }
.hy-btn:focus-visible { outline: 3px solid var(--hy-acao-ring); outline-offset: 3px; }
.hy-btn[disabled] { opacity: 0.72; cursor: progress; transform: none; }

.hy-form__status {
  margin: 0;
  font-size: 0.8125rem;
  text-align: center;
  color: var(--ink-500, #6B6660);
}
.hy-form__status:empty { display: none; }

.hy-form__alt { margin: 0; text-align: center; }
.hy-form__direto {
  display: inline-block;
  padding: 0.5rem 0.25rem;          /* alvo de toque ≥ 24px de altura */
  font-size: 0.875rem;
  color: var(--ink-600, #4A4640);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--ink-200, #C4BDB3);
}
.hy-form__direto:hover { color: var(--hy-acao); text-decoration-color: currentColor; }

/* --------------------------------------------------------------------------
   4. ESTADO DE SUCESSO
   -------------------------------------------------------------------------- */
.hy-ok {
  display: grid;
  justify-items: center;
  gap: 0.625rem;
  padding-block: 1rem;
  text-align: center;
  outline: none;
}
.hy-ok__icone {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background-color: rgba(30, 122, 74, 0.1);
  color: var(--hy-acao);
}
.hy-ok__icone svg { width: 1.75rem; height: 1.75rem; }
.hy-ok__titulo {
  margin: 0.25rem 0 0;
  font-family: var(--font-display, Georgia, serif);
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--ink-900, #24221F);
}
.hy-ok__texto { margin: 0; font-size: 0.9375rem; color: var(--ink-600, #4A4640); }
.hy-ok__texto--sm { max-width: 32ch; font-size: 0.8125rem; color: var(--ink-500, #6B6660); }
.hy-ok__codigo {
  margin: 0.125rem 0 0.375rem;
  padding: 0.5rem 1.125rem;
  border: 1px solid var(--gold-300, #D9BE8D);
  border-radius: 10px;
  background-color: var(--gold-50, #FBF6EE);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 1.625rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--gold-700, #6E5228);
}
.hy-ok .hy-btn { max-width: 22rem; }
.hy-ok__novo {
  padding: 0.5rem;
  border: 0;
  background: none;
  font-size: 0.8125rem;
  color: var(--ink-500, #6B6660);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   5. MODAL
   -------------------------------------------------------------------------- */
html.hy-modal-open { overflow: hidden; }
html.hy-modal-open body { padding-inline-end: var(--hy-sbw, 0px); }

.hy-modal {
  width: min(30rem, calc(100% - 2rem));
  max-width: none;
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--hy-raio-card);
  background: transparent;
  overflow: visible;
  color: var(--ink-600, #4A4640);
}
.hy-modal::backdrop {
  background-color: rgba(19, 18, 17, 0.62);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.hy-modal[open] { animation: hy-entra 280ms cubic-bezier(0.16, 1, 0.3, 1); }
.hy-modal--fallback[open] {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal, 500);
  box-shadow: 0 0 0 100vmax rgba(19, 18, 17, 0.62);
}
@keyframes hy-entra {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.hy-modal__card {
  position: relative;
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(1.25rem, 4vw, 2rem);
  border: 1px solid var(--ink-100, #E3DED6);
  border-radius: var(--hy-raio-card);
  background: linear-gradient(180deg, #FFFFFF 0%, #FCFAF7 100%);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.55);
}
.hy-modal .hy-form__title { padding-inline-end: 2.5rem; }

.hy-modal__fechar {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-700, #3C3935);
  cursor: pointer;
}
.hy-modal__fechar:hover { background-color: var(--c-mist, #F2EFEA); }
.hy-modal__fechar:focus-visible { outline: 2px solid var(--gold-600, #8F6C36); outline-offset: 2px; }
.hy-modal__fechar svg { width: 1.25rem; height: 1.25rem; }

/* --------------------------------------------------------------------------
   6. BOTÃO FLUTUANTE
   -------------------------------------------------------------------------- */
.hy-fab {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, calc(env(safe-area-inset-bottom) + 0.75rem));
  z-index: calc(var(--z-header, 200) - 1);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 3.5rem;
  padding: 0 1.25rem 0 1.0625rem;
  border: 0;
  border-radius: 999px;
  background-color: var(--hy-acao);
  box-shadow: 0 14px 30px -10px rgba(19, 18, 17, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.18) inset;
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 0.9375rem;
  font-weight: 600;
  color: #FFFFFF;
  cursor: pointer;
  transition: transform 260ms cubic-bezier(0.16, 1, 0.3, 1), opacity 200ms ease, background-color 160ms ease;
}
.hy-fab svg { width: 1.5rem; height: 1.5rem; flex: none; }
.hy-fab:hover { background-color: var(--hy-acao-hover); }
.hy-fab:focus-visible { outline: 3px solid var(--gold-300, #D9BE8D); outline-offset: 3px; }
.hy-fab.is-hidden,
html.hy-modal-open .hy-fab { opacity: 0; transform: translateY(140%); pointer-events: none; }

@media (max-width: 29.99em) {
  .hy-fab { padding: 0; width: 3.5rem; justify-content: center; }
  .hy-fab__txt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}

@media (prefers-reduced-motion: reduce) {
  .hy-modal[open] { animation: none; }
  .hy-btn, .hy-fab, .hy-field__input { transition: none; }
}

@media print {
  .hy-fab, .hy-modal { display: none !important; }
}
