/* Mapa das Raízes Familiares — estilos (mobile-first) */

:root {
  --bg-top: #120C08;
  --bg-bottom: #1C130C;
  --text: #F6ECD9;
  --text-2: #D8CFBF;
  --amber: #F2B84B;
  --copper: #C7772E;
  --btn-hi: #F5C25B;
  --btn-lo: #E0952F;
  --ink: #1A0F05;
  --card-bg: rgba(255, 235, 200, 0.07);
  --card-border: rgba(242, 184, 75, 0.35);
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --dur: 250ms;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg-top);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.5;
  background: var(--bg-top);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Fundo marrom-escuro com degradê suave (fixo, funciona no iOS) */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-top) 30%, var(--bg-bottom) 100%);
}

p { margin: 0; }
h1, h2, h3 { margin: 0; font-weight: 700; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--text);
  outline-offset: 3px;
  border-radius: 6px;
}
h1:focus, h1:focus-visible, p:focus { outline: none; }

.destaque { color: var(--amber); }

/* ---------- Logo ---------- */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--amber);
}
.emblem {
  display: block;
  height: 40px;
  width: auto;
}
.logo-words {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  color: var(--amber);
}
.logo-l1 {
  font-size: 19px;
  letter-spacing: 0.2em;
  margin-right: -0.2em;
}
.logo-rule {
  height: 1px;
  margin: 5px 0 5px;
  background: linear-gradient(90deg, rgba(242, 184, 75, 0.9), rgba(242, 184, 75, 0.5));
}
.logo-l2 {
  font-size: 9.5px;
  letter-spacing: 0.42em;
  margin-right: -0.42em;
}
.logo-lg { gap: 16px; }
.logo-lg .emblem { height: 64px; }
.logo-lg .logo-l1 { font-size: 31px; }
.logo-lg .logo-rule { margin: 7px 0 7px; }
.logo-lg .logo-l2 { font-size: 15px; }

/* ---------- Topo fixo (telas internas) ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding-top: env(safe-area-inset-top, 0);
  background: linear-gradient(180deg, rgba(18, 12, 8, 0.98) 0%, rgba(18, 12, 8, 0.95) 80%, rgba(18, 12, 8, 0) 100%);
}
.topbar-inner {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 20px 12px;
}
.topbar-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 64px;
}
.back {
  position: absolute;
  left: 0;
  top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 56px;
  min-width: 56px;
  margin-left: -10px;
  padding: 0 10px;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  touch-action: manipulation;
  opacity: 0.75;
}
.back:hover { opacity: 1; color: var(--text); }
@media (max-width: 374px) {
  .back span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

.progress {
  position: relative;
  height: 4px;
  margin-top: 6px;
  border-radius: 999px;
  background: rgba(242, 184, 75, 0.18);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--copper), var(--amber));
  transition: width 500ms cubic-bezier(.4, 0, .2, 1);
}

/* ---------- Conteúdo ---------- */
.app {
  position: relative;
  z-index: 2;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(76px + env(safe-area-inset-top, 0px)) 20px calc(40px + env(safe-area-inset-bottom, 0px));
}
body.has-progress .app { padding-top: calc(100px + env(safe-area-inset-top, 0px)); }
body.is-intro .app { padding: 0; }

.screen {
  display: flex;
  flex-direction: column;
  transition: opacity var(--dur) ease-out, transform var(--dur) ease-out;
}
.screen.is-entering {
  opacity: 0;
  transform: translateY(12px);
}

.h-question {
  font-family: var(--serif);
  font-size: clamp(25px, 7vw, 28px);
  line-height: 1.2;
  color: var(--text);
}
.lead { color: var(--text-2); }

/* ---------- Botão principal ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 58px;
  padding: 12px 20px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--btn-hi) 0%, var(--btn-lo) 100%);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 0 22px rgba(242, 184, 75, 0.35), 0 8px 20px -8px rgba(224, 149, 47, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: filter 120ms ease-out, transform 120ms ease-out;
}
.btn:active { filter: brightness(0.94); transform: translateY(1px); }
.btn-pulse { animation: pulse 2.5s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 22px rgba(242, 184, 75, 0.35), 0 8px 20px -8px rgba(224, 149, 47, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.4); }
  50% { box-shadow: 0 0 34px rgba(242, 184, 75, 0.6), 0 8px 24px -6px rgba(224, 149, 47, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.4); }
}

/* ---------- Abertura ---------- */
.screen-intro {
  min-height: 100vh;
  min-height: 100dvh;
}
.hero {
  position: relative;
  /* a foto ocupa o espaço que sobra acima do texto: o botão nunca sai da primeira tela */
  flex: 1 1 auto;
  min-height: 200px;
  max-height: 440px;
  overflow: hidden;
}
.hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 10%;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 52%, rgba(0, 0, 0, 0.55) 76%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 52%, rgba(0, 0, 0, 0.55) 76%, transparent 100%);
}
/* escurece o topo da foto para o logo ler bem */
.hero::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 150px;
  background: linear-gradient(180deg, rgba(18, 12, 8, 0.55), rgba(18, 12, 8, 0));
  pointer-events: none;
}
.hero-logo {
  position: absolute;
  z-index: 1;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
}
.intro-body {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  margin-top: -64px; /* o título entra na parte dissolvida da foto */
  padding: 0 6% calc(18px + env(safe-area-inset-bottom, 0px));
}
.h-display {
  font-family: var(--serif);
  font-size: clamp(28px, 7.4vw, 34px);
  line-height: 1.15;
  letter-spacing: -0.005em;
  color: var(--text);
  text-shadow: 0 2px 14px rgba(18, 12, 8, 0.85);
}
.intro-sub {
  margin-top: 14px;
  font-size: 18px;
  line-height: 1.5;
  color: var(--text-2);
}
.intro-body .btn { margin-top: 22px; }
@media (min-width: 390px) {
  .intro-sub { font-size: 19px; }
}
/* telas muito baixas: compacta um pouco mais */
@media (max-height: 660px) {
  .intro-sub { margin-top: 10px; font-size: 17px; line-height: 1.45; }
  .intro-body .btn { margin-top: 16px; }
  .intro-body { margin-top: -56px; }
}
/* em telas largas, a foto também dissolve nas laterais */
@media (min-width: 520px) {
  .hero-img {
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 52%, rgba(0, 0, 0, 0.55) 76%, transparent 100%), linear-gradient(90deg, transparent 0%, #000 12%, #000 88%, transparent 100%);
    -webkit-mask-composite: source-in;
    mask-image: linear-gradient(180deg, #000 0%, #000 52%, rgba(0, 0, 0, 0.55) 76%, transparent 100%), linear-gradient(90deg, transparent 0%, #000 12%, #000 88%, transparent 100%);
    mask-composite: intersect;
  }
}

/* ---------- Perguntas ---------- */
.screen-q { padding-top: 12px; }
.screen-q .h-question { margin-bottom: 26px; }
.answers {
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.answer {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 11px 16px 11px 12px;
  border: 1px solid var(--card-border);
  border-radius: 18px;
  background: var(--card-bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 160ms, border-color 160ms, box-shadow 160ms;
}
.answer:active { background: rgba(242, 184, 75, 0.1); }
@media (hover: hover) {
  .answer:hover { border-color: rgba(242, 184, 75, 0.6); }
}
.answer-letter {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--btn-hi), var(--btn-lo));
  color: var(--ink);
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}
.answer-text { flex: 1 1 auto; }
.answer.is-selected {
  border-color: var(--amber);
  box-shadow: inset 0 0 0 1px var(--amber), 0 0 18px rgba(242, 184, 75, 0.18);
  background: rgba(242, 184, 75, 0.14);
}

/* ---------- Nome ---------- */
.screen-name { padding-top: 12px; }
.screen-name .h-question { margin-bottom: 10px; }
.screen-name .lead { margin-bottom: 26px; }
.field {
  display: block;
  width: 100%;
  height: 58px;
  padding: 0 18px;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-family: var(--sans);
  font-size: 20px;
  outline: none;
  transition: border-color 160ms, box-shadow 160ms;
  -webkit-appearance: none;
  appearance: none;
}
.field::placeholder { color: rgba(216, 207, 191, 0.55); }
.field:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(242, 184, 75, 0.18); }
.field[aria-invalid="true"] { border-color: var(--copper); box-shadow: 0 0 0 3px rgba(199, 119, 46, 0.25); }
.field-error {
  min-height: 24px;
  margin: 8px 2px 18px;
  font-size: 15px;
  line-height: 1.4;
  color: #F0C79A;
}

/* ---------- Carregamento ---------- */
.screen-loading {
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 160px);
  text-align: center;
  gap: 28px;
}
.screen-loading .emblem { height: 120px; }
.loading-msgs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 360px;
  outline: none;
}
.loading-msg {
  position: relative;
  font-size: 17px;
  line-height: 1.4;
  animation: msgEntra 300ms ease-out both;
}
@media (min-width: 390px) { .loading-msg { font-size: 18px; } }
.loading-msg.is-atual { color: var(--text); }
.loading-msg.is-feita { color: var(--text-2); animation: none; }
/* check âmbar à esquerda das mensagens concluídas */
.loading-msg.is-feita::before {
  content: "";
  display: inline-block;
  vertical-align: -2px;
  margin-right: 6px;
  width: 16px;
  height: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.4l3.1 3.1L13 4.6' fill='none' stroke='%23F2B84B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
/* reticências animadas da mensagem atual */
.loading-dots {
  display: inline-block;
  width: 0;
  overflow: hidden;
  vertical-align: bottom;
  animation: reticencias 1.2s steps(4, end) infinite;
}
@keyframes reticencias { to { width: 1.05em; } }
@keyframes msgEntra { from { opacity: 0; } to { opacity: 1; } }
/* a árvore aparece de cima para baixo: copa, tronco e por fim as raízes (3 s) */
.emblem-drawing { clip-path: inset(0 0 100% 0); animation: revelar 2.8s cubic-bezier(.45, .05, .35, 1) forwards; }
@keyframes revelar { to { clip-path: inset(0 0 0 0); } }

/* ---------- Resultado: quatro blocos (compacto) ---------- */
body.is-result .app { max-width: 552px; padding-left: 16px; padding-right: 16px; padding-bottom: 24px; padding-top: calc(66px + env(safe-area-inset-top, 0px)); }
.screen-result { gap: 15px; }
.rb { padding: 20px 24px; font-size: 17px; line-height: 1.5; border-radius: 20px; overflow: hidden; }
.rb > * + * { margin-top: 10px; }
.rb-rotulo { font-size: 12px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; line-height: 1.4; }
.rb-titulo { font-family: var(--serif); font-size: 22px; line-height: 1.14; }
.rb-titulo:focus { outline: none; }
.rb-fecho { font-family: var(--serif); font-size: 18px; line-height: 1.3; }

/* 1 · alerta */
.rb-alerta { background: linear-gradient(180deg, #5E1D14 0%, #7C2A1D 100%); color: var(--text); }
.rb-alerta .rb-rotulo { color: var(--amber); }
.rb-icone { display: block; width: 28px; height: 28px; fill: none; stroke: var(--amber); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.rb-alerta .rb-icone + .rb-rotulo { margin-top: 6px; }

/* 2 · o erro */
.rb-erro { background: #F6ECD9; color: #2A1A0E; }
.rb-erro .rb-rotulo { color: #9A5A1C; }

/* 3 · a esperança (rótulo um pouco mais escuro: #9A5A1C dá 3,9:1 sobre este bege) */
.rb-esperanca { background: #E8D8B8; color: #2A1A0E; }
.rb-esperanca .rb-rotulo { color: #844C16; }
.rb-chamada { font-weight: 700; }
.rb-passos { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rb-passos li { display: flex; align-items: flex-start; gap: 12px; }
.rb-num {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #9A5A1C;
  color: #F6ECD9;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
.rb-passo { margin: 0; font-size: 17px; line-height: 1.5; }
.rb-passo-titulo { font-size: 15px; font-weight: 700; letter-spacing: 0.06em; }

/* 4 · próximo passo */
.rb-proximo { background: #1A110B; border: 1px solid rgba(242, 184, 75, 0.35); color: var(--text); padding-top: 22px; padding-bottom: 22px; }
.rb-proximo .btn { margin-top: 12px; font-size: 15px; letter-spacing: 0.01em; padding-left: 8px; padding-right: 8px; }
.rb-rodape { text-align: center; font-size: 14px; line-height: 1.4; color: var(--text-2); }

/* ---------- Movimento reduzido: sem animações ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .screen.is-entering { opacity: 1; transform: none; }
  .emblem-drawing { clip-path: none; }
  .loading-dots { width: auto; }
}
