/* =================================================================
   SAFEA — Estilos da pesquisa de validação
   -----------------------------------------------------------------
   Complementa o CSS original do index.html. A identidade visual
   (rosa, branco, rosé e dourado) e as animações existentes ficam
   intactas — aqui só entram os componentes novos:
     • validação da Etapa 1
     • consentimentos
     • tela da Etapa 2 (pesquisa)
     • modal de privacidade
     • estados de carregamento das métricas
================================================================= */

/* --------- proteção geral contra rolagem horizontal --------- */
html, body { max-width: 100%; }
*, *::before, *::after { box-sizing: border-box; }
img, svg, video, canvas, table { max-width: 100%; }
.wrap, .form-card, .grid, .map-grid, .form-row { min-width: 0; }
.wrap > *, .grid > *, .map-grid > *, .form-row > * { min-width: 0; }

/* foco sempre visível */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--dourado);
  outline-offset: 2px;
  border-radius: 6px;
}
#br-map .uf:focus-visible { outline: 2px solid var(--dourado); outline-offset: 1px; }

/* =================================================================
   1) ETAPA 1 — validação e consentimento
================================================================= */
.form-card .field input,
.form-card .field select { font-size: 16px; }        /* impede zoom automático no iPhone */

.field-error {
  margin: 6px 2px 0;
  font-size: .82rem;
  line-height: 1.4;
  color: #b3243c;
  min-height: 0;
}
.field.has-error input,
.field.has-error select {
  border-color: #d94a63;
  background: #fff6f7;
}
.field.has-error input:focus,
.field.has-error select:focus { box-shadow: 0 0 0 4px rgba(217, 74, 99, .16); }

.form-intro {
  background: rgba(255, 255, 255, .6);
  border: 1px solid rgba(239, 113, 133, .25);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 20px;
  font-size: .88rem;
  color: var(--txt-soft);
  line-height: 1.6;
}
.form-intro b { color: var(--txt); }
.form-intro a { color: var(--rosa); font-weight: 600; text-decoration: underline; }

.consent-box {
  border: 1.5px solid rgba(239, 113, 133, .28);
  background: rgba(255, 255, 255, .62);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 6px 0 4px;
}
.consent-box.has-error { border-color: #d94a63; background: #fff6f7; }
.consent-box .field-error { margin-top: 8px; }

/* campo honeypot: invisível para pessoas, visível para robôs */
.hp-field {
  position: absolute !important;
  left: -9999px !important;
  width: 1px; height: 1px;
  overflow: hidden;
  opacity: 0;
}

/* leitor de tela */
.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;
}

/* =================================================================
   2) ALTERNATIVAS CLICÁVEIS (checkbox / radio)
================================================================= */
.opt-list { display: flex; flex-direction: column; gap: 10px; }

.opt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 48px;                     /* área de toque confortável */
  padding: 12px 14px;
  border-radius: 14px;
  border: 1.5px solid rgba(43, 34, 38, .12);
  background: rgba(255, 255, 255, .8);
  cursor: pointer;
  transition: border-color .25s var(--ease), background .25s var(--ease), box-shadow .25s var(--ease);
  font-size: 1rem;
  line-height: 1.45;
}
.opt:hover { border-color: rgba(239, 113, 133, .55); background: #fff; }
.opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.opt-box {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  margin-top: 1px;
  border-radius: 7px;
  border: 2px solid rgba(43, 34, 38, .28);
  background: #fff;
  display: grid; place-items: center;
  transition: border-color .2s, background .2s, transform .2s var(--ease);
}
.opt input[type="radio"] + .opt-box { border-radius: 50%; }
.opt-box::after {
  content: ""; width: 10px; height: 10px; border-radius: 3px;
  background: #fff; transform: scale(0); transition: transform .2s var(--ease);
}
.opt input[type="radio"] + .opt-box::after { border-radius: 50%; }
.opt input:checked + .opt-box {
  border-color: var(--rosa);
  background: linear-gradient(135deg, var(--rosa), var(--rosa-claro));
}
.opt input:checked + .opt-box::after { transform: scale(1); }
.opt.checked,
.opt:has(input:checked) {
  border-color: var(--rosa);
  background: rgba(239, 113, 133, .08);
  box-shadow: 0 8px 22px -16px rgba(239, 113, 133, .9);
}
.opt input:focus-visible + .opt-box { outline: 3px solid var(--dourado); outline-offset: 2px; }
.opt-text { flex: 1; min-width: 0; word-break: break-word; }

.opt-blocked { opacity: .45; cursor: not-allowed; }
.opt-blocked:hover { border-color: rgba(43, 34, 38, .12); background: rgba(255, 255, 255, .8); }

.opt-consent { border-style: dashed; }

/* =================================================================
   3) TELA DA PESQUISA (Etapa 2)
================================================================= */
body.survey-open { overflow: hidden; }

.survey-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  background: linear-gradient(180deg, #fbf6f2, #f7f5ec);
  overflow: hidden;
}
.survey-overlay.open { display: flex; flex-direction: column; }
.survey-overlay::before {
  content: "";
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(60% 40% at 10% 0%, rgba(245, 168, 183, .35), transparent 60%),
    radial-gradient(50% 40% at 95% 10%, rgba(201, 161, 90, .18), transparent 60%);
}

.survey-topbar {
  position: relative; z-index: 2;
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 14px;
  padding: calc(12px + env(safe-area-inset-top)) clamp(14px, 4vw, 28px) 12px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px -22px rgba(43, 34, 38, .5);
}
.survey-brand {
  font-family: 'Playfair Display', serif;
  font-weight: 800; font-size: 1.45rem; color: var(--rosa); line-height: 1;
}
.survey-brand span { color: var(--dourado); }
.survey-topbar .spacer { flex: 1; }
.survey-icon-btn {
  flex: 0 0 auto;
  width: 44px; height: 44px; border-radius: 12px;
  border: 1.5px solid rgba(239, 113, 133, .35);
  background: rgba(255, 255, 255, .7);
  color: var(--rosa); font-size: 1.3rem; line-height: 1;
  cursor: pointer; display: grid; place-items: center;
  transition: background .25s, transform .25s var(--ease);
}
.survey-icon-btn:hover { background: #fff; transform: translateY(-2px); }

.survey-progress-wrap { position: relative; z-index: 2; flex: 0 0 auto; padding: 10px clamp(14px, 4vw, 28px) 0; }
.survey-progress {
  height: 10px; border-radius: 50px;
  background: rgba(43, 34, 38, .09);
  overflow: hidden;
}
.survey-progress .fill {
  display: block; height: 100%; width: 0;
  border-radius: 50px;
  background: linear-gradient(90deg, var(--rosa), var(--dourado));
  transition: width .4s var(--ease);
}
.survey-progress-label {
  display: block; margin-top: 6px;
  font-size: .8rem; font-weight: 600; color: var(--txt-soft); letter-spacing: .3px;
}

.survey-body {
  position: relative; z-index: 2;
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 18px clamp(14px, 4vw, 28px) calc(28px + env(safe-area-inset-bottom));
}
.survey-inner { width: min(820px, 100%); margin: 0 auto; }

.survey-head h1 {
  font-size: clamp(1.6rem, 5vw, 2.3rem);
  line-height: 1.15; margin-bottom: 8px; color: var(--txt);
}
.survey-head h1:focus-visible { outline: 3px solid var(--dourado); outline-offset: 4px; }
.survey-head .survey-sub { color: var(--txt-soft); font-size: .95rem; margin-bottom: 6px; }
.survey-head .survey-person {
  font-size: .84rem; color: var(--txt-soft);
  background: rgba(255, 255, 255, .7);
  border: 1px solid rgba(239, 113, 133, .22);
  border-radius: 12px; padding: 10px 14px; margin-top: 12px;
}

/* bloco de descrição neutra do produto */
.survey-about {
  margin: 20px 0 4px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(201, 161, 90, .35);
  background: rgba(255, 255, 255, .78);
  padding: 18px 20px;
}
.survey-about h2 {
  font-family: 'Poppins', sans-serif;
  font-size: .78rem; font-weight: 700; letter-spacing: 2px;
  text-transform: uppercase; color: var(--dourado); margin-bottom: 8px;
}
.survey-about p { color: var(--txt); font-size: .96rem; line-height: 1.65; }

/* --------- blocos de pergunta --------- */
.q-block {
  border: 1px solid rgba(255, 255, 255, .8);
  background: rgba(255, 255, 255, .66);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  padding: clamp(18px, 4vw, 26px);
  margin: 18px 0;
  box-shadow: 0 18px 44px -34px rgba(43, 34, 38, .55);
  transition: border-color .3s, box-shadow .3s;
  min-width: 0;
}
.q-block.answered { border-color: rgba(239, 113, 133, .38); }
.q-block.has-error { border-color: #d94a63; background: #fff7f8; }

.q-legend {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.05rem, 3.4vw, 1.32rem);
  font-weight: 700; line-height: 1.35; color: var(--txt);
  padding: 0; margin-bottom: 10px; float: none; width: 100%;
}
.q-num {
  display: inline-block;
  font-family: 'Poppins', sans-serif;
  font-size: .74rem; font-weight: 700; letter-spacing: 1px;
  color: #fff; background: linear-gradient(135deg, var(--rosa), var(--rosa-claro));
  border-radius: 50px; padding: 3px 10px; margin-right: 8px; vertical-align: middle;
}
.q-hint { font-size: .88rem; font-weight: 600; color: var(--rosa); margin-bottom: 12px; }
.q-desc {
  font-size: .93rem; color: var(--txt); line-height: 1.6;
  background: rgba(247, 245, 236, .9);
  border-left: 3px solid var(--dourado);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 12px;
}
.q-counter {
  display: inline-block;
  font-size: .8rem; font-weight: 700; color: var(--dourado);
  background: rgba(201, 161, 90, .12);
  border-radius: 50px; padding: 4px 12px; margin-bottom: 12px;
}
.q-note { font-size: .8rem; color: var(--txt-soft); margin-top: 8px; line-height: 1.5; }
.q-error { margin-top: 10px; font-size: .85rem; font-weight: 600; color: #b3243c; }

.q-free { margin-top: 12px; }
.q-free.hidden, .hidden { display: none !important; }
.q-free label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.q-free input {
  width: 100%; max-width: 100%;
  padding: 13px 15px; border-radius: 13px;
  font-size: 16px; font-family: inherit;
  border: 1.5px solid rgba(43, 34, 38, .14);
  background: #fff; color: var(--txt);
}
.q-free input:focus {
  outline: none; border-color: var(--rosa);
  box-shadow: 0 0 0 4px rgba(239, 113, 133, .15);
}
.consent-inline { margin-top: 14px; }

/* --------- rodapé de ações --------- */
.survey-actions {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin: 26px 0 10px;
}
.survey-actions .btn { flex: 1 1 200px; justify-content: center; }
.survey-error {
  display: none;
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1.5px solid #e8a3ae;
  background: #fff6f7;
  color: #9c1f35;
  font-size: .92rem; line-height: 1.55;
}
.survey-error.show { display: block; }
.btn.is-loading { opacity: .75; cursor: progress; }

.survey-legal { margin-top: 18px; font-size: .78rem; color: var(--txt-soft); line-height: 1.6; }

/* --------- tela de conclusão --------- */
.survey-done { text-align: center; padding: clamp(20px, 6vw, 50px) 0; }
.survey-done:focus-visible { outline: none; }
.survey-done .check {
  width: 92px; height: 92px; border-radius: 50%; margin: 0 auto 22px;
  background: linear-gradient(135deg, var(--rosa), var(--rosa-claro));
  display: grid; place-items: center; box-shadow: var(--glow);
}
.survey-done .check svg { width: 44px; height: 44px; stroke: #fff; stroke-width: 3; fill: none; }
.survey-done h2 { font-size: clamp(1.5rem, 5vw, 2rem); color: var(--rosa); margin-bottom: 14px; }
.survey-done p { color: var(--txt); font-size: 1.02rem; line-height: 1.7; max-width: 620px; margin: 0 auto 12px; }
.survey-done .done-number {
  display: inline-block; margin-top: 6px;
  font-weight: 600; color: var(--dourado);
  background: rgba(201, 161, 90, .12);
  border-radius: 50px; padding: 8px 18px;
}
.survey-done .btn { margin-top: 24px; }

/* =================================================================
   4) MODAL DE PRIVACIDADE
================================================================= */
.privacy-modal {
  position: fixed; inset: 0; z-index: 210;
  display: none; align-items: center; justify-content: center;
  padding: clamp(12px, 4vw, 32px);
  background: rgba(28, 20, 24, .55);
  backdrop-filter: blur(6px);
}
.privacy-modal.open { display: flex; }
.privacy-card {
  width: min(700px, 100%);
  max-height: min(86vh, 900px);
  overflow-y: auto;
  background: #fff;
  border-radius: var(--radius);
  padding: clamp(22px, 4vw, 36px);
  box-shadow: var(--shadow-card);
}
.privacy-card h2 { font-size: 1.5rem; color: var(--rosa); margin-bottom: 6px; }
.privacy-card h3 {
  font-family: 'Poppins', sans-serif; font-size: .95rem; font-weight: 600;
  margin: 18px 0 6px; color: var(--txt);
}
.privacy-card p, .privacy-card li { color: var(--txt-soft); font-size: .92rem; line-height: 1.65; }
.privacy-card ul { margin: 6px 0 0 20px; }
.privacy-card .privacy-close { margin-top: 22px; width: 100%; justify-content: center; }
.privacy-card code {
  background: rgba(239, 113, 133, .1); color: var(--rosa);
  padding: 2px 7px; border-radius: 6px; font-size: .86rem; word-break: break-all;
}

/* =================================================================
   5) MÉTRICAS EM TEMPO REAL (seção do mapa e prova social)
================================================================= */
.map-metrics { grid-template-columns: repeat(2, 1fr); }
.metric b.is-loading {
  color: rgba(239, 113, 133, .35);
  animation: skeletonPulse 1.3s ease-in-out infinite;
}
@keyframes skeletonPulse { 0%, 100% { opacity: .45 } 50% { opacity: 1 } }

.stats-state {
  display: none;
  margin-top: 14px;
  font-size: .84rem;
  color: var(--txt-soft);
  background: rgba(255, 255, 255, .7);
  border: 1px dashed rgba(239, 113, 133, .35);
  border-radius: 12px;
  padding: 10px 14px;
}
.stats-state.show { display: block; }
.stats-state.is-error { color: #9c1f35; border-color: #e8a3ae; background: #fff6f7; }

.metric-legend { margin-top: 14px; font-size: .8rem; color: var(--txt-soft); line-height: 1.65; }
.metric-legend b { color: var(--txt); }

.map-tip .tip-rows { flex-wrap: wrap; }
.map-tip .tip-rows span { white-space: nowrap; }

/* =================================================================
   6) RESPONSIVO
================================================================= */
@media (max-width: 980px) {
  .map-metrics { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 680px) {
  .survey-topbar { padding-left: 14px; padding-right: 14px; }
  .survey-brand { font-size: 1.25rem; }
  .survey-actions { flex-direction: column; }
  .survey-actions .btn { width: 100%; flex: 1 1 auto; }
  .q-block { border-radius: 20px; }
  .opt { padding: 13px 13px; }
  .map-metrics { grid-template-columns: 1fr; }
  .privacy-card { border-radius: 20px; }
}
@media (max-width: 380px) {
  .q-legend { font-size: 1.02rem; }
  .opt { font-size: .96rem; }
}

@media (prefers-reduced-motion: reduce) {
  .survey-progress .fill, .opt, .opt-box, .q-block { transition: none !important; }
  .metric b.is-loading { animation: none; }
}


/* -----------------------------------------------------------------
   Aviso de simulação — aparece junto dos números públicos sempre que
   parte deles vier de registros simulados (campo simulatedIncluded
   do documento public_stats/summary).
----------------------------------------------------------------- */
.simulation-note{
  margin:10px auto 0;
  max-width:56ch;
  font-size:.78rem;
  line-height:1.55;
  color:var(--txt-soft,#6b5b62);
  background:rgba(201,161,90,.12);
  border:1px solid rgba(201,161,90,.4);
  border-radius:10px;
  padding:8px 14px;
  text-align:center;
}
.simulation-note[hidden]{display:none}
