/* A Voz de Nazaré: pergaminho à luz de lamparina. Claro de dia, noite à luz de vela. */
:root {
  --papel: #f3ead8;
  --papel-2: #ebdfc6;
  --tinta: #3a2a1d;
  --tinta-suave: #6e5a45;
  --tinta-fraca: #9a8669;
  --ocre: #9c5a26;
  --ocre-forte: #7f4519;
  --brilho: rgba(232, 168, 84, .30);
  --fio: rgba(110, 82, 52, .22);
  --balao: #e4d4b4;
  --citacao: rgba(156, 90, 38, .07);
  --sombra: 0 10px 30px -18px rgba(70, 45, 20, .45);
  --raio: 18px;
  --largura: 44rem;
  --serifa: "Crimson Text", Georgia, "Times New Roman", serif;
  --titulo: "Cormorant Garamond", "Crimson Text", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --papel: #1b1410;
    --papel-2: #241a14;
    --tinta: #efe2cb;
    --tinta-suave: #c9b593;
    --tinta-fraca: #8f7b60;
    --ocre: #e2a35c;
    --ocre-forte: #f0b673;
    --brilho: rgba(232, 150, 60, .20);
    --fio: rgba(226, 190, 140, .16);
    --balao: #33261d;
    --citacao: rgba(226, 163, 92, .08);
    --sombra: 0 10px 30px -16px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--papel);
  color: var(--tinta);
  font-family: var(--serifa);
  font-size: 1.1875rem;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}
/* grão do papel */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .15 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
/* a luz da lamparina */
.luz {
  position: fixed; left: 50%; top: -22vh;
  width: 120vmax; height: 70vh;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, var(--brilho), transparent 70%);
  pointer-events: none; z-index: 0;
  animation: respirar 9s ease-in-out infinite;
}
@keyframes respirar { 50% { opacity: .72; transform: translateX(-50%) scale(1.04); } }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- topo ---------- */
.topo {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: max(.7rem, env(safe-area-inset-top)) 1.1rem .7rem;
  background: linear-gradient(var(--papel) 70%, transparent);
}
.marca {
  display: flex; align-items: center; gap: .5rem;
  background: none; border: 0; padding: .2rem; cursor: pointer;
  font-family: var(--titulo); font-size: 1.25rem; font-weight: 600; letter-spacing: .02em;
  color: var(--tinta);
  opacity: 0; transition: opacity .5s;
}
body.em-conversa .marca { opacity: 1; }
.chama { width: 1.35rem; height: 1.35rem; color: var(--ocre); }
.menu-botao {
  display: flex; align-items: center; gap: .5rem;
  font: inherit; font-size: .95rem; color: var(--tinta-suave);
  background: transparent; border: 1px solid var(--fio); border-radius: 999px;
  padding: .35rem .8rem; cursor: pointer;
  transition: border-color .2s, color .2s;
}
.menu-botao:hover { color: var(--tinta); border-color: var(--tinta-fraca); }
.menu-botao svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }

/* ---------- conversa ---------- */
.conversa {
  position: relative; z-index: 1;
  flex: 1;
  width: 100%; max-width: var(--largura);
  margin: 0 auto;
  padding: 0 1.25rem 1.5rem;
}
.abertura {
  text-align: center;
  padding: 9vh 0 2.2rem;
}
.abertura .chama.grande { width: 3.2rem; height: 3.2rem; animation: tremular 4s ease-in-out infinite; transform-origin: 50% 85%; }
@keyframes tremular { 25% { transform: rotate(-2deg) scaleY(1.03); } 60% { transform: rotate(1.5deg) scaleY(.98); } }
.abertura h1 {
  font-family: var(--titulo); font-weight: 600;
  font-size: clamp(2.6rem, 9vw, 3.8rem);
  line-height: 1.05; letter-spacing: .01em;
  margin: .6rem 0 .5rem;
}
.subtitulo { margin: 0; color: var(--tinta-suave); font-style: italic; font-size: 1.15rem; }
.ornamento { display: flex; align-items: center; justify-content: center; gap: .8rem; margin-top: 1.6rem; color: var(--ocre); font-size: .8rem; }
.ornamento span { width: 3.5rem; height: 1px; background: var(--fio); }
.abertura > * { animation: surgir .9s both cubic-bezier(.2, .7, .2, 1); }
.abertura > :nth-child(2) { animation-delay: .12s; }
.abertura > :nth-child(3) { animation-delay: .24s; }
.abertura > :nth-child(4) { animation-delay: .36s; }
@keyframes surgir { from { opacity: 0; transform: translateY(10px); } }

.msg { margin: 1.4rem 0; animation: surgir .5s both cubic-bezier(.2, .7, .2, 1); }
.msg.pessoa {
  margin-left: auto;
  width: fit-content; max-width: 85%;
  background: var(--balao);
  padding: .7rem 1.05rem;
  border-radius: var(--raio) var(--raio) 6px var(--raio);
  white-space: pre-wrap; overflow-wrap: anywhere;
  box-shadow: var(--sombra);
}
.msg.voz { position: relative; padding-left: 1.2rem; }
.msg.voz::before {
  content: ""; position: absolute; left: 0; top: .45rem; bottom: .45rem;
  width: 2px; border-radius: 2px;
  background: linear-gradient(var(--ocre), transparent);
  opacity: .55;
}
.msg.voz p { margin: 0 0 .85rem; }
.msg.voz p:last-child { margin-bottom: 0; }
.msg.voz h3 { font-family: var(--titulo); font-size: 1.3rem; font-weight: 600; margin: 1.1rem 0 .3rem; color: var(--ocre-forte); }
.msg.voz ul, .msg.voz ol { margin: 0 0 .85rem; padding-left: 1.3rem; }
.msg.voz li { margin: .25rem 0; }
.msg.voz strong { font-weight: 600; }
.msg.voz blockquote {
  margin: 1rem 0;
  padding: .8rem 1.1rem .8rem 2.2rem;
  position: relative;
  background: var(--citacao);
  border-radius: 4px 14px 14px 4px;
  font-style: italic;
  font-size: 1.22rem;
}
.msg.voz blockquote::before {
  content: "“"; position: absolute; left: .55rem; top: -.15rem;
  font-family: var(--titulo); font-size: 2.6rem; font-style: normal; color: var(--ocre); opacity: .7;
}
.msg.voz blockquote cite {
  display: block; margin-top: .35rem;
  font-style: normal; font-size: .82rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ocre-forte);
}
.msg.voz.erro { color: var(--tinta-suave); font-style: italic; }
.msg.crise { background: var(--citacao); padding: 1rem 1.2rem 1rem 1.5rem; border-radius: 6px 16px 16px 6px; }
.msg.crise .ligar { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }

.sistema { text-align: center; color: var(--tinta-fraca); font-style: italic; font-size: 1rem; margin: 1rem 0; animation: surgir .5s both; }

/* escolhas iniciais: um convite, nunca uma porta */
.escolhas { display: flex; flex-wrap: wrap; gap: .55rem; margin: 1rem 0 0 1.2rem; }
.escolha, .botao-ligar {
  font: inherit; font-size: 1rem; color: var(--tinta);
  background: transparent;
  border: 1px solid var(--fio); border-radius: 999px;
  padding: .45rem 1rem; cursor: pointer; text-decoration: none;
  transition: background .2s, border-color .2s, transform .15s;
}
.escolha:hover, .botao-ligar:hover { background: var(--citacao); border-color: var(--ocre); }
.escolha:active { transform: scale(.97); }
.escolha.principal, .botao-ligar.principal { background: var(--ocre); border-color: var(--ocre); color: var(--papel); }

/* fontes da resposta */
.fontes { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .9rem; }
.fonte {
  font: inherit; font-size: .8rem; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ocre-forte);
  background: transparent; border: 1px solid var(--fio); border-radius: 6px;
  padding: .2rem .55rem; cursor: pointer;
}
.fonte[aria-expanded="true"] { background: var(--citacao); border-color: var(--ocre); }
.fonte-texto {
  flex-basis: 100%;
  font-size: 1rem; color: var(--tinta-suave);
  border-left: 2px solid var(--fio); padding: .2rem 0 .2rem .8rem; margin: .1rem 0 .3rem;
}
.fonte-texto sup { color: var(--ocre); font-size: .7em; margin-right: .15em; }
.de-qual { font-size: .78rem; color: var(--tinta-fraca); margin-top: .5rem; font-style: italic; }

/* escrevendo */
.escrevendo { display: inline-flex; gap: .35rem; padding: .4rem 0 .4rem 1.2rem; }
.escrevendo i { width: .42rem; height: .42rem; border-radius: 50%; background: var(--ocre); opacity: .3; animation: pulsar 1.4s infinite; }
.escrevendo i:nth-child(2) { animation-delay: .2s; }
.escrevendo i:nth-child(3) { animation-delay: .4s; }
@keyframes pulsar { 40% { opacity: .9; transform: translateY(-3px); } }
.cursor::after { content: "▍"; color: var(--ocre); opacity: .6; animation: piscar 1s steps(2) infinite; margin-left: 1px; }
@keyframes piscar { 50% { opacity: 0; } }

/* ---------- rodapé e caixa ---------- */
.rodape {
  position: sticky; bottom: 0; z-index: 5;
  padding: .9rem 1rem max(.7rem, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--papel) 28%);
}
.caixa {
  display: flex; align-items: flex-end; gap: .5rem;
  max-width: var(--largura); margin: 0 auto;
  background: var(--papel-2);
  border: 1px solid var(--fio); border-radius: 26px;
  padding: .45rem .45rem .45rem 1.1rem;
  box-shadow: var(--sombra);
  transition: border-color .2s, box-shadow .2s;
}
.caixa:focus-within { border-color: var(--ocre); box-shadow: var(--sombra), 0 0 0 4px var(--citacao); }
textarea {
  flex: 1; resize: none; border: 0; outline: 0; background: transparent;
  font: inherit; color: var(--tinta); line-height: 1.45;
  padding: .45rem 0; max-height: 9.5rem; min-height: 1.45em;
}
textarea::placeholder { color: var(--tinta-fraca); font-style: italic; }
.enviar {
  flex: none; width: 2.75rem; height: 2.75rem; border-radius: 50%;
  border: 0; cursor: pointer;
  background: var(--ocre); color: var(--papel);
  display: grid; place-items: center;
  transition: transform .15s, opacity .2s, background .2s;
}
.enviar svg { width: 1.3rem; height: 1.3rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.enviar:hover:not(:disabled) { background: var(--ocre-forte); }
.enviar:active:not(:disabled) { transform: scale(.92); }
.enviar:disabled { opacity: .35; cursor: default; }
.aviso { max-width: var(--largura); margin: .55rem auto 0; text-align: center; font-size: .8rem; color: var(--tinta-fraca); line-height: 1.4; }
.link { font: inherit; color: var(--ocre-forte); background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

/* ---------- painéis ---------- */
.painel {
  width: min(30rem, calc(100% - 2rem));
  max-height: calc(100dvh - 3rem);
  border: 1px solid var(--fio); border-radius: 20px;
  background: var(--papel); color: var(--tinta);
  padding: 1.6rem 1.5rem 1.2rem;
  box-shadow: 0 30px 80px -30px rgba(40, 25, 10, .6);
}
.painel::backdrop { background: rgba(30, 20, 12, .38); backdrop-filter: blur(3px); }
.painel[open] { animation: surgir .35s both cubic-bezier(.2, .7, .2, 1); }
.painel h2 { font-family: var(--titulo); font-weight: 600; font-size: 1.7rem; line-height: 1.15; margin: 0 0 .4rem; }
.painel p { margin: 0 0 .8rem; font-size: 1.05rem; }
.painel a { color: var(--ocre-forte); }
.nota { color: var(--tinta-suave); font-style: italic; }
.credito { font-size: .82rem !important; color: var(--tinta-fraca); }
.opcoes { display: grid; gap: .5rem; margin: 1rem 0; }
.opcao {
  display: flex; justify-content: space-between; align-items: baseline;
  font: inherit; text-align: left; color: var(--tinta);
  background: transparent; border: 1px solid var(--fio); border-radius: 12px;
  padding: .7rem 1rem; cursor: pointer;
}
.opcao small { color: var(--tinta-fraca); font-size: .85rem; }
.opcao[aria-checked="true"] { border-color: var(--ocre); background: var(--citacao); }
.opcao[aria-checked="true"]::after { content: "✓"; color: var(--ocre); margin-left: .5rem; }
.painel hr { border: 0; border-top: 1px solid var(--fio); margin: 1rem 0; }
.acao {
  display: block; width: 100%;
  font: inherit; color: var(--papel); background: var(--ocre);
  border: 0; border-radius: 12px; padding: .7rem 1rem; cursor: pointer; margin-top: .5rem;
}
.acao.discreta { background: transparent; color: var(--tinta-suave); }

:focus-visible { outline: 2px solid var(--ocre); outline-offset: 3px; }

@media (max-width: 520px) {
  body { font-size: 1.125rem; }
  .conversa { padding: 0 1rem 1rem; }
  .abertura { padding-top: 6vh; }
  .msg.pessoa { max-width: 90%; }
  .menu-botao span { max-width: 9.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
