/* ============================================================================
   ÁTRIO · FORM
   Mobile-first. O desktop é a exceção (media query no fim de cada bloco).
   ========================================================================== */

/* ---------- tokens ------------------------------------------------------- */
:root {
  /* cor */
  --ink:          #ffffff;
  --ink-title:    #f8f8fa;   /* títulos — branco quebrado, menos duro que #fff */
  --ink-desc:     #cdd1d4;   /* descrições */
  --ink-soft:     rgba(255, 255, 255, 0.66);
  --ink-faint:    rgba(255, 255, 255, 0.34);
  --line:         rgba(255, 255, 255, 0.26);
  --line-strong:  rgba(255, 255, 255, 0.72);
  --surface:      rgba(255, 255, 255, 0.05);
  --surface-hi:   rgba(255, 255, 255, 0.10);
  --accent:       #1c3a8e;
  --accent-lit:   #2950b4;
  --ok:           #34d399;   /* verde de confirmação — tela final */
  --void:         #050507;

  /* curvas — a personalidade do movimento mora aqui */
  --out-expo:  cubic-bezier(0.16, 1, 0.30, 1);   /* entradas: rápido e assenta  */
  --out-quart: cubic-bezier(0.25, 1, 0.50, 1);   /* uso geral                    */
  --in-quart:  cubic-bezier(0.50, 0, 0.75, 0);   /* saídas: some e acelera       */
  --pop:       cubic-bezier(0.34, 1.45, 0.64, 1);/* seleção: pulinho de vida     */

  /* tempo */
  --t-enter: 620ms;
  --t-exit:  300ms;
  --t-tap:   180ms;
  --stagger: 62ms;

  /* medidas */
  --gutter: 26px;
  --measure: 620px;
  --bar-h: 92px;
}

/* ---------- reset -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--void);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
               "Helvetica Neue", Inter, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
img { display: block; max-width: 100%; }

/* ============================================================================
   FUNDO — respira devagar, sem chamar atenção
   ========================================================================== */
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: var(--void); }

.bg__image {
  position: absolute;
  inset: -6%;
  background: url("assets/bg.jpg") center/cover no-repeat;
  /* deslocamento sutil a cada pergunta: dá sensação de percorrer um espaço */
  transform: translate3d(0, calc(var(--bg-shift, 0) * -1px), 0) scale(1.04);
  transition: transform 1200ms var(--out-expo);
  will-change: transform;
  animation: breathe 44s ease-in-out infinite alternate;
}
@keyframes breathe {
  from { scale: 1;     translate: 0 0; }
  to   { scale: 1.085; translate: -1.5% -1%; }
}

.bg__glow {
  position: absolute; inset: -20%;
  background:
    radial-gradient(38% 30% at 22% 74%, rgba(64, 150, 190, 0.30), transparent 70%),
    radial-gradient(34% 26% at 78% 26%, rgba(120, 96, 190, 0.22), transparent 70%);
  filter: blur(30px);
  mix-blend-mode: screen;
  opacity: 0.55;
  animation: wander 34s ease-in-out infinite alternate;
}
@keyframes wander {
  from { transform: translate3d(-3%, 2%, 0) scale(1); }
  to   { transform: translate3d(4%, -3%, 0) scale(1.14); }
}

/* GRÃO
   O arquivo do fundo é o gradiente liso, sem grão gravado. O grão entra aqui,
   desenhado pelo navegador na resolução real da tela — num celular 3x ele sai
   com 3x mais detalhe, em vez de ser uma textura ampliada virando mancha.
   `overlay` faz a variação acontecer em torno do tom que já existe, sem
   clarear o preto. */
.bg__grain {
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='turbulence' baseFrequency='0.75' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='discrete' tableValues='1'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23g)'/%3E%3C/svg%3E");
  background-size: 240px 240px;
  background-repeat: repeat;
  mix-blend-mode: overlay;
  opacity: 0.42;
  pointer-events: none;
}
/* `stitchTiles` faz o ladrilho de 240px casar nas bordas, sem emenda visível */

/* escurece topo e base para o texto e a barra sempre terem contraste */
.bg__vignette {
  position: absolute; inset: 0;
  background:
    linear-gradient(to bottom, rgba(0,0,0,0.62) 0%, rgba(0,0,0,0) 26%),
    linear-gradient(to top,    rgba(0,0,0,0.60) 0%, rgba(0,0,0,0) 30%);
}

/* ============================================================================
   PROGRESSO
   ========================================================================== */
.progress {
  position: fixed; z-index: 40;
  top: max(10px, env(safe-area-inset-top));
  left: 14px; right: 14px;
  transition: opacity 420ms var(--out-quart);
}
/* abertura e tela final não têm progresso a mostrar */
body.no-progress .progress { opacity: 0; }
.progress__track {
  height: 3px; border-radius: 99px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}
.progress__fill {
  height: 100%; border-radius: 99px;
  background: var(--ink);
  transform: scaleX(0); transform-origin: left center;
  transition: transform 760ms var(--out-expo);
}

/* ============================================================================
   LOGO
   ========================================================================== */
.brand {
  position: fixed; z-index: 30;
  top: calc(max(10px, env(safe-area-inset-top)) + 35px);
  left: 0; right: 0;
  display: flex; justify-content: center;
  pointer-events: none;
  transition: opacity 340ms var(--out-quart), transform 340ms var(--out-quart);
}
/* o arquivo do logo é recortado rente ao desenho, sem margem em volta:
   a largura aqui é a do desenho em si, não a de uma caixa com respiro */
.brand__mark { width: 133px; height: auto; opacity: 0.96; }

/* teclado aberto no celular: o logo sai de cena para dar espaço */
body.kb-open .brand { opacity: 0; transform: translateY(-14px); }

/* ============================================================================
   PALCO
   ========================================================================== */
.stage {
  position: fixed; inset: 0; z-index: 20;
  padding: 0 var(--gutter) var(--bar-h);
}

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: flex-start;
  /* --pad-fit é calculado no form.js: o bloco fica a 28vh do topo quando cabe,
     e sobe o necessário quando a pergunta é longa. */
  padding: var(--pad-fit, 28vh) var(--gutter) var(--bar-h);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition:
    opacity var(--t-enter) var(--out-quart),
    transform var(--t-enter) var(--out-expo);
  will-change: transform, opacity;
}
body.kb-open .screen { padding-top: 9vh; }

/* estado inicial da entrada / estado final da saída */
.screen.is-entering { opacity: 0; transform: translate3d(0, var(--from, 34px), 0); }
.screen.is-leaving  {
  opacity: 0; transform: translate3d(0, var(--to, -26px), 0);
  transition-duration: var(--t-exit);
  transition-timing-function: var(--in-quart);
  pointer-events: none;
}

/* cascata dos elementos internos — o "charme" está aqui */
.screen [data-anim] {
  transition:
    opacity 560ms var(--out-quart),
    transform 560ms var(--out-expo);
  transition-delay: calc(var(--i, 0) * var(--stagger) + 60ms);
}
.screen.is-entering [data-anim] { opacity: 0; transform: translate3d(0, 18px, 0); }
.screen.is-leaving  [data-anim] { transition-delay: 0ms; }

.screen__inner { width: 100%; max-width: var(--measure); margin: 0 auto; }

/* ============================================================================
   CABEÇALHO DA PERGUNTA
   ========================================================================== */
/* só o número, sem caixa — funciona como um fólio de página */
.q__badge {
  display: block;
  margin-bottom: 14px;
  font-size: 14px; font-weight: 600; line-height: 1;
  letter-spacing: 0.02em;
  color: rgba(248, 248, 250, 0.55);
  font-variant-numeric: tabular-nums;
}

.q__title {
  margin: 0;
  font-size: clamp(22px, 5.7vw, 26px);
  font-weight: 500;
  line-height: 1.26;
  letter-spacing: -0.019em;
  color: var(--ink-title);
  text-wrap: balance;
}

.q__desc {
  margin: 12px 0 0;
  font-size: 15.5px;
  line-height: 1.45;
  color: var(--ink-desc);
  letter-spacing: -0.005em;
  text-wrap: pretty;
}

.q__body { margin-top: 40px; }

/* ============================================================================
   CAMPOS DE TEXTO
   ========================================================================== */
.field { position: relative; padding-bottom: 2px; }

.field__input {
  display: block; width: 100%;
  padding: 0 0 12px;
  border: 0; background: none; outline: none;
  font-size: 22px; font-weight: 400; letter-spacing: -0.014em;
  line-height: 1.4;
  caret-color: #6f96ff;
}
.field__input::placeholder { color: var(--ink-faint); }
textarea.field__input { resize: none; min-height: 96px; }

.field__line { position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--line); }
.field__line::after {
  content: ""; position: absolute; inset: 0;
  background: var(--ink);
  transform: scaleX(0); transform-origin: left center;
  transition: transform 520ms var(--out-expo);
}
.field.is-focus .field__line::after { transform: scaleX(1); }

/* telefone */
.phone { display: flex; align-items: center; gap: 14px; }
.phone__ddi {
  display: flex; align-items: center; gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 22px; white-space: nowrap;
}
.phone__flag { font-size: 21px; line-height: 1; }
.phone__caret { width: 14px; height: 14px; opacity: 0.55; }
.phone .field { flex: 1; }

/* contador de caracteres do texto longo */
.field__count {
  position: absolute; right: 0; bottom: 14px;
  font-size: 12px; color: var(--ink-faint);
  opacity: 0; transition: opacity 240ms var(--out-quart);
}
.field.is-focus .field__count { opacity: 1; }

/* ============================================================================
   OPÇÕES
   ========================================================================== */
.opts { display: flex; flex-direction: column; gap: 10px; }

/* listas de 6 alternativas ou mais respiram menos, para caberem na tela */
.opts--dense { gap: 7px; }
.opts--dense .opt { padding: 12px 16px; font-size: 16px; }

.opt {
  display: flex; align-items: center; gap: 13px;
  width: 100%; padding: 15px 16px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: 16.5px; line-height: 1.35; letter-spacing: -0.008em;
  transition:
    background 220ms var(--out-quart),
    border-color 220ms var(--out-quart),
    transform var(--t-tap) var(--out-quart);
}
.opt:active { transform: scale(0.985); }

.opt__key {
  flex: none;
  display: grid; place-items: center;
  width: 25px; height: 25px;
  border: 1px solid var(--line); border-radius: 6px;
  font-size: 11.5px; font-weight: 600; line-height: 1;
  transition: background 200ms var(--out-quart), color 200ms var(--out-quart),
              border-color 200ms var(--out-quart), transform 320ms var(--pop);
}
.opt__label { flex: 1; }

.opt.is-on { background: var(--surface-hi); border-color: var(--line-strong); }
.opt.is-on .opt__key {
  background: var(--ink); color: #0a0a0c; border-color: var(--ink);
  transform: scale(1.08);
}

/* campo livre do "Outro": fica com altura zero até ser escolhido */
.choice { display: block; }
.other {
  max-height: 0; opacity: 0; overflow: hidden;
  transition: max-height 440ms var(--out-expo),
              opacity 300ms var(--out-quart),
              margin-top 440ms var(--out-expo);
}
.other .field { padding: 0 16px 2px; }
.other.is-open { max-height: 120px; opacity: 1; margin-top: 14px; }

/* ============================================================================
   DROPDOWN
   ========================================================================== */
.dd { position: relative; }
.dd__caret {
  position: absolute; right: 2px; bottom: 14px;
  width: 18px; height: 18px; opacity: 0.5;
  transition: transform 300ms var(--out-expo);
  pointer-events: none;
}
.dd.is-open .dd__caret { transform: rotate(180deg); }

/* espaço para a setinha não encostar no texto */
.dd .field__input { padding-right: 38px; }

.dd__list {
  margin-top: 12px;
  max-height: 46vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.dd__list::-webkit-scrollbar { width: 0; height: 0; }
.dd__list .opt { animation: optIn 420ms var(--out-expo) backwards; }
@keyframes optIn {
  from { opacity: 0; transform: translate3d(0, 10px, 0); }
}
.dd__empty { padding: 14px 2px; color: var(--ink-faint); font-size: 15px; }

/* ============================================================================
   ESCALA
   ========================================================================== */
/* grid em vez de flex: as duas fileiras ficam com colunas do mesmo tamanho */
.scale { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.scale__dot {
  height: 52px;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface);
  font-size: 16px; font-variant-numeric: tabular-nums;
  transition: background 200ms var(--out-quart), border-color 200ms var(--out-quart),
              transform 320ms var(--pop);
}
.scale__dot.is-on {
  background: var(--ink); color: #0a0a0c; border-color: var(--ink);
  transform: translateY(-3px);
}

/* ============================================================================
   BOTÕES
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 56px; padding: 0 26px;
  border-radius: 11px;
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
  transition: transform var(--t-tap) var(--out-quart),
              background 200ms var(--out-quart),
              box-shadow 260ms var(--out-quart),
              opacity 200ms var(--out-quart);
}
.btn:active { transform: scale(0.972); }

.btn--primary {
  flex: 1;
  background: var(--accent);
  box-shadow: 0 10px 30px -12px rgba(30, 62, 147, 0.95);
}
.btn--primary:hover { background: var(--accent-lit); }

.btn--ghost {
  flex: none; width: 56px; padding: 0;
  background: var(--accent); opacity: 0.92;
}
.btn--ghost:hover { background: var(--accent-lit); }

.btn__hint { display: none; font-size: 13px; font-weight: 400; opacity: 0.62; }
.btn__hint b { font-weight: 600; }

/* pergunta obrigatória ainda em branco: o botão recua, mas continua clicável —
   tocar nele mostra o aviso em vez de não fazer nada. */
.btn.is-off { opacity: 0.58; box-shadow: none; }

/* barra fixa do celular */
.actionbar {
  position: fixed; z-index: 50;
  left: 0; right: 0; bottom: 0;
  display: flex; gap: 10px;
  padding: 15px 16px calc(15px + env(safe-area-inset-bottom));
  background: rgba(8, 10, 14, 0.55);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  backdrop-filter: blur(26px) saturate(150%);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  /* --kb é a altura do teclado do celular: a barra sobe junto */
  transform: translateY(calc(-1 * var(--kb, 0px)));
  transition: transform 420ms var(--out-expo), opacity 300ms var(--out-quart);
}
.actionbar.is-hidden { transform: translateY(110%); opacity: 0; pointer-events: none; }
#btnBack.is-hidden { display: none; }

/* botão dentro da tela — só aparece no desktop */
.screen__actions { display: none; margin-top: 36px; align-items: center; gap: 16px; }

/* ============================================================================
   TELA DE ABERTURA E TELA FINAL
   ========================================================================== */
.hero__title {
  margin: 0;
  font-size: clamp(29px, 7.8vw, 37px);
  font-weight: 700; line-height: 1.14; letter-spacing: -0.032em;
  color: var(--ink-title);
  text-wrap: balance;
}
.hero__sub {
  margin: 14px 0 0;
  font-size: 18px; font-weight: 500; line-height: 1.35;
  letter-spacing: -0.014em;
  color: var(--ink-title);
  text-wrap: balance;
}
.hero__desc {
  margin: 20px 0 0;
  font-size: 16.5px; line-height: 1.5;
  color: var(--ink-desc);
  text-wrap: pretty;
}
.hero__sub + .hero__desc { margin-top: 14px; }
.hero { text-align: center; }
.hero .screen__actions { justify-content: center; }

/* o traço do "check" se desenha.
   O SVG tem viewBox de 24 e aparece com 62px, então cada unidade de
   stroke-width vira ~2,6px na tela: 1,25 aqui é um traço fino de verdade. */
.done__mark { width: 62px; height: 62px; margin: 0 auto 26px; display: block; }
.done__mark circle, .done__mark path {
  fill: none; stroke: var(--ok); stroke-width: 1.25;
  stroke-linecap: round; stroke-linejoin: round;
}
.done__mark circle { stroke-dasharray: 176; stroke-dashoffset: 176; opacity: 0.45;
  animation: draw 900ms var(--out-expo) 120ms forwards; }
.done__mark path   { stroke-dasharray: 40;  stroke-dashoffset: 40;
  animation: draw 520ms var(--out-expo) 620ms forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ============================================================================
   ERRO
   ========================================================================== */
.err {
  display: flex; align-items: center; gap: 8px;
  margin-top: 14px;
  font-size: 14.5px; color: #ff9a9a;
  animation: errIn 380ms var(--out-expo);
}
@keyframes errIn { from { opacity: 0; transform: translateY(-6px); } }
.shake { animation: shake 420ms cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

/* ============================================================================
   DESKTOP
   ========================================================================== */
@media (min-width: 860px) {
  :root { --gutter: 40px; --bar-h: 0px; --measure: 680px; }

  .progress { top: 0; left: 0; right: 0; }
  .progress__track { height: 4px; border-radius: 0; }

  .brand { top: 44px; }
  .brand__mark { width: 151px; }

  /* no desktop o conteúdo fica no centro óptico, não no topo */
  .screen { justify-content: center; padding: 120px var(--gutter) 90px; --pad-fit: 120px; }

  .q__title { font-size: 29px; letter-spacing: -0.022em; }
  .q__desc  { font-size: 17px; }
  .field__input { font-size: 27px; }
  .phone__ddi { font-size: 27px; }
  .opt { font-size: 17px; padding: 16px 18px; }
  .hero__title { font-size: 40px; }
  .hero__sub  { font-size: 19.5px; }
  .hero__desc { font-size: 18.5px; max-width: 560px; margin-inline: auto; }

  .opt:hover { background: var(--surface-hi); border-color: rgba(255, 255, 255, 0.42); }
  .scale { grid-template-columns: repeat(11, 1fr); }
  .scale__dot:hover { background: var(--surface-hi); }

  /* a barra fixa dá lugar ao botão inline + dica de teclado */
  .actionbar { display: none; }
  .screen__actions { display: flex; }
  .btn--primary { flex: none; }
  .btn__hint { display: inline; }

  /* navegação discreta no canto */
  .nav {
    position: fixed; z-index: 50; right: 28px; bottom: 28px;
    display: flex; gap: 2px;
    border-radius: 10px; overflow: hidden;
    box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.8);
  }
  .nav__btn {
    width: 42px; height: 40px;
    display: grid; place-items: center;
    background: var(--accent);
    transition: background 200ms var(--out-quart), opacity 200ms var(--out-quart);
  }
  .nav__btn:hover { background: var(--accent-lit); }
  .nav__btn.is-off { opacity: 0.35; pointer-events: none; }
}
@media (max-width: 859px) { .nav { display: none; } }

/* ============================================================================
   ACESSIBILIDADE — quem pediu menos movimento, recebe menos movimento
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 140ms !important;
    transition-delay: 0ms !important;
  }
  .screen.is-entering, .screen.is-leaving { transform: none; }
  .screen.is-entering [data-anim] { transform: none; }
  .bg__image, .bg__glow { animation: none; }
}

/* o anel de foco vale para botões e opções.
   nos campos de texto quem sinaliza o foco é o traço que cresce embaixo. */
:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.85); outline-offset: 3px; border-radius: 6px; }
.field__input:focus-visible { outline: none; }
::selection { background: rgba(255, 255, 255, 0.22); }
