/* =========================================================
   Endereço das premiadas (THASSIA) · estilos
   Mobile-first: o padrão é o celular, o @media só alarga.
   Tokens em DESIGN.md.
   ========================================================= */

:root {
  --tinta: #101010;
  --papel: #fbf8f6;
  --campo: #ffffff;
  --linha: #d9d2cd;
  --marca: #b3121f;
  --marca-escura: #7d0b15;
  --apagado: #5e5550;
  --ok: #0f7a3d;
  --raio: 10px;
  --fonte: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--papel);
  color: var(--tinta);
  font: 400 1rem/1.5 var(--fonte);
  /* Sem o flash cinza no toque do Android/iOS */
  -webkit-tap-highlight-color: transparent;
}

::selection { background: var(--marca); color: #fff; }

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

/* ---------- Página ---------- */
.pagina {
  flex: 1;
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  /* Respeita o notch e a barra do iPhone */
  padding: max(2rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) 2.5rem max(1.25rem, env(safe-area-inset-left));
}

.topo { margin-bottom: 2rem; }

h1 {
  margin: 0 0 0.625rem;
  font-size: 1.75rem;
  line-height: 1.15;
  font-weight: 750;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.apoio {
  margin: 0;
  color: var(--apagado);
  text-wrap: pretty;
}

/* ---------- Blocos do formulário ---------- */
.bloco {
  margin: 0 0 2.25rem;
  padding: 0;
  border: 0;
  min-width: 0;
}

legend {
  padding: 0;
  margin-bottom: 1rem;
  font-size: 1.0625rem;
  font-weight: 700;
}

.campo { margin-bottom: 1.125rem; min-width: 0; }

label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.9375rem;
  font-weight: 600;
}

.opcional { font-weight: 400; color: var(--apagado); }

input[type="text"], input[type="email"], input[type="tel"], select {
  width: 100%;
  min-height: 3rem;
  padding: 0.75rem 0.875rem;
  /* 16px no mínimo: abaixo disso o iOS dá zoom ao focar */
  font: 400 1rem/1.25 var(--fonte);
  color: var(--tinta);
  background: var(--campo);
  border: 1.5px solid var(--linha);
  border-radius: var(--raio);
  caret-color: var(--marca);
  transition: border-color 160ms ease-out, box-shadow 160ms ease-out;
  appearance: none;
}

select {
  /* Seta desenhada (o appearance:none tira a nativa) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235e5550' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  background-size: 0.75rem;
  padding-right: 2.25rem;
}

input::placeholder { color: #8a817b; }

input:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--tinta);
  box-shadow: 0 0 0 3px rgb(179 18 31 / 0.22);
}

/* Campo com erro: borda na cor da marca + mensagem com ícone (nunca só cor) */
[aria-invalid="true"] { border-color: var(--marca); }

.dica {
  margin: 0.375rem 0 0;
  font-size: 0.875rem;
  color: var(--apagado);
}

.erro {
  display: flex;
  gap: 0.375rem;
  align-items: flex-start;
  margin: 0.375rem 0 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--marca);
}
.erro::before {
  content: "";
  flex: none;
  width: 1rem;
  height: 1rem;
  margin-top: 0.1rem;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='none' stroke='black' stroke-width='1.6'/%3E%3Cpath d='M8 4.5v4.2' stroke='black' stroke-width='1.6' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='11.3' r='1' fill='black'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='none' stroke='black' stroke-width='1.6'/%3E%3Cpath d='M8 4.5v4.2' stroke='black' stroke-width='1.6' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='11.3' r='1' fill='black'/%3E%3C/svg%3E") center / contain no-repeat;
}
.erro[hidden] { display: none; }

/* Quando o erro aparece, a dica sai (não empilhar dois textos) */
.campo:has(.erro:not([hidden])) .dica { display: none; }

/* ---------- CEP ---------- */
.cep-linha { display: flex; align-items: center; gap: 0.75rem; }
.cep-linha input { max-width: 10rem; }
.cep-status { font-size: 0.875rem; color: var(--apagado); }

/* ---------- Grades ---------- */
.grade-2, .grade-cidade { display: grid; gap: 0 0.875rem; }
.grade-2 { grid-template-columns: minmax(7.5rem, 2fr) 3fr; }
.grade-cidade { grid-template-columns: 1fr 6rem; }

/* ---------- Consentimento ---------- */
.consentimento {
  display: grid;
  grid-template-columns: 1.375rem 1fr;
  gap: 0.75rem;
  align-items: start;
}
.consentimento label { margin: 0; font-weight: 400; font-size: 0.9375rem; }
.consentimento input {
  width: 1.375rem;
  height: 1.375rem;
  margin: 0.0625rem 0 0;
  accent-color: var(--marca);
}
.consentimento input:focus-visible { outline: 3px solid rgb(179 18 31 / 0.35); outline-offset: 2px; }

.armadilha { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Botão ---------- */
.botao {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  width: 100%;
  min-height: 3.25rem;
  margin-top: 1.75rem;
  padding: 0 1.5rem;
  font: 700 1.0625rem/1 var(--fonte);
  white-space: nowrap; /* texto de botão nunca quebra linha */
  color: #fff;
  background: var(--marca);
  border: 0;
  border-radius: var(--raio);
  box-shadow: 0 6px 16px -6px rgb(125 11 21 / 0.45);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: background-color 160ms ease-out, transform 120ms ease-out;
}
.botao:active { transform: scale(0.985); background: var(--marca-escura); }
.botao:focus-visible { outline: 3px solid var(--tinta); outline-offset: 3px; }
.botao[disabled] { cursor: progress; background: var(--marca-escura); }

@media (hover: hover) {
  .botao:hover { background: var(--marca-escura); }
}

/* Spinner do envio */
.botao[aria-busy="true"]::before {
  content: "";
  width: 1.05rem;
  height: 1.05rem;
  border: 2px solid rgb(255 255 255 / 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: girar 700ms linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

.erro-geral { margin-top: 1rem; }

/* ---------- Sucesso ---------- */
.sucesso { outline: none; animation: entrar 220ms cubic-bezier(0.16, 1, 0.3, 1) both; }
.sucesso[hidden] { display: none; }
.sucesso-icone {
  width: 3rem;
  height: 3rem;
  padding: 0.6rem;
  margin-bottom: 1rem;
  border-radius: 50%;
  background: rgb(15 122 61 / 0.1);
  fill: none;
  stroke: var(--ok);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sucesso h2 { margin: 0 0 0.75rem; font-size: 1.5rem; letter-spacing: -0.02em; }
.sucesso p { margin: 0 0 0.5rem; }
.sucesso address {
  margin: 0 0 1.5rem;
  padding: 1rem 1.125rem;
  font-style: normal;
  line-height: 1.55;
  background: var(--campo);
  border: 1px solid var(--linha);
  border-radius: var(--raio);
  overflow-wrap: anywhere;
}
.sucesso a, .rodape a {
  color: var(--marca);
  font-weight: 600;
  text-underline-offset: 0.18em;
}

@keyframes entrar {
  from { opacity: 0; transform: translateY(8px); }
}

/* ---------- Rodapé ---------- */
.rodape {
  padding: 1.25rem 1.25rem max(1.25rem, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 0.8125rem;
  color: var(--apagado);
}

/* ---------- Telas maiores ---------- */
@media (min-width: 640px) {
  .pagina { padding-top: 4rem; }
  h1 { font-size: 2.25rem; }
  .botao { width: auto; min-width: 16rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
