/* Página de recebimento do cartão musical (frentes 4 e 6, Telas do App).
   Spec: dorcas-visual/cartao-musical/design/spec-v1.md (seções 2, 4 e 5).
   Tamanhos de texto em rem sobre 17 px, que acompanham o tamanho de letra do
   aparelho e o zoom do navegador. Medidas de papel e margens em px. */

@font-face {
  font-family: 'Source Serif 4';
  src: url('/m/fontes/SourceSerif4.woff2') format('woff2');
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Source Serif 4';
  src: url('/m/fontes/SourceSerif4-Italic.woff2') format('woff2');
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  src: url('/m/fontes/AtkinsonHyperlegibleNext.woff2') format('woff2');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

/* ---------- Paleta 4.2 ---------- */
:root {
  color-scheme: light dark;
  --fundo: #FAEBDC;
  --capa: #F4D6D1;
  --lombada: #E6BBB5;
  --borda: #A8707C;
  --papel: #FDF6EE;
  --tinta: #520B39;
  --nome: #87394E;
  --apoio: #6B4A5E;
  --oliva: #465338;
  --linha: #E5CFCB;
  --foco: #520B39;
  --botao-fundo: #520B39;
  --botao-texto: #FAEBDC;
  --selo-fundo: #F4D6D1;
  --sombra-dobra: rgba(82, 11, 57, .16);
  --sombra-capa: #520B39;
  --sombra-cartao: 0 2px 6px rgba(82, 11, 57, .12), 0 12px 28px rgba(82, 11, 57, .10);
  --tex: 82, 11, 57;
  --tex-a: .018;
  --tex-b: .012;
  --tex-luz: rgba(255, 255, 255, .30);
  --escala: 1;
  --curva: cubic-bezier(0.45, 0, 0.20, 1);
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --sans: 'Atkinson Hyperlegible Next', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #1F0717;
    --capa: #4A1A3E;
    --lombada: #33102A;
    --borda: #84607A;
    --papel: #3D1734;
    --tinta: #FAEBDC;
    --nome: #EDB9C2;
    --apoio: #D6BFCB;
    --oliva: #BCCBA8;
    --linha: #4F2843;
    --foco: #F4D6D1;
    --botao-fundo: #EDB9C2;
    --botao-texto: #1F0717;
    --selo-fundo: #4A1A3E;
    --sombra-dobra: rgba(0, 0, 0, .35);
    --sombra-capa: #000000;
    --sombra-cartao: 0 2px 6px rgba(0, 0, 0, .40), 0 12px 28px rgba(0, 0, 0, .35);
    --tex: 250, 235, 220;
    --tex-a: .020;
    --tex-b: .014;
    --tex-luz: rgba(255, 255, 255, .04);
  }
}

/* ---------- Base: o texto segue o aparelho ---------- */
html { font-size: 106.25%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* iPhone: 17 px no padrão, cresce com o Tamanho do Texto do sistema. */
@supports (font: -apple-system-body) and (-webkit-touch-callout: none) {
  html { font: -apple-system-body; }
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--fundo);
  color: var(--tinta);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  overflow-wrap: break-word;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--foco); outline-offset: 4px; }
/* Alvos de foco programático (não interativos): o leitor de tela começa ali,
   sem moldura de botão em volta do texto. */
[tabindex="-1"]:focus-visible { outline: none; }
/* Arte ainda sem arquivo (carregando): papel liso, sem ícone de imagem. */
img:not([src]) { visibility: hidden; }
a { color: inherit; }

.papel, .papel-capa {
  background-image:
    radial-gradient(120% 90% at 30% 15%, var(--tex-luz), transparent 60%),
    repeating-linear-gradient(0deg, rgba(var(--tex), var(--tex-a)) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(var(--tex), var(--tex-b)) 0 1px, transparent 1px 5px);
}
.papel { background-color: var(--papel); }
.papel-capa { background-color: var(--capa); }

/* ---------- Faixa da marca ---------- */
.faixa {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  column-gap: 12px;
  min-height: 48px;
  padding: 0 16px;
  max-width: 760px;
  margin: 0 auto;
}
.marca {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  font: 700 0.882rem/1.2 var(--sans);
  color: var(--apoio);
}
.coracao { display: block; height: 20px; width: auto; }
.botao-som {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  min-width: 48px;
  padding: 4px 8px;
  margin-right: -8px;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--oliva);
  font: 700 1rem/1.25 var(--sans);
  cursor: pointer;
}
.icone {
  flex: none;
  width: 20px;
  height: 20px;
  background-color: currentColor;
  -webkit-mask: var(--icone) center / contain no-repeat;
  mask: var(--icone) center / contain no-repeat;
}
.botao-som[data-som="tocando"] { --icone: url('/icones/silenciar.svg'); }
.botao-som[data-som="parado"] { --icone: url('/icones/ouvir-de-novo.svg'); }
.botao-som[data-som="bloqueado"] { --icone: url('/icones/musica.svg'); }
html[data-escala="grande"] .botao-som { flex-basis: 100%; margin-right: 0; justify-content: flex-start; }

/* ---------- Sem JavaScript ---------- */
html.sem-js main { display: none; }
.sem-js-aviso {
  max-width: 30rem;
  margin: 48px auto;
  padding: 0 16px;
  text-align: center;
  font: 600 1.176rem/1.4 var(--serif);
}

/* ---------- Palco e medidas do cartão ---------- */
main { container-type: inline-size; display: block; }
.vista-cartao {
  --aba: 20px;
  --P: min(calc(100cqi - 52px), max(240px, calc((100svh - 118px) * 5 / 7)), 340px);
  --H: calc(var(--P) * 1.4);
  padding-top: 8px;
}
html[data-escala="grande"] .vista-cartao {
  --aba: 0px;
  --P: min(calc(100cqi - 32px), max(240px, calc((100svh - 118px) * 5 / 7)), 340px);
}
@media (min-width: 560px) {
  .vista-cartao,
  html[data-escala="grande"] .vista-cartao {
    --P: min(calc((100cqi - 32px) / 2), max(240px, calc((100svh - 118px) * 5 / 7)), 340px);
    --aba: var(--P);
  }
}

.palco { display: flex; justify-content: center; padding: 0 16px; }
.objeto {
  position: relative;
  display: grid;
  grid-template-columns: var(--aba) var(--P);
  perspective: 1600px;
  /* Celular: a capa aberta sai pela esquerda; só a aba fica à vista. */
  clip-path: inset(-140px -60px -140px 0);
  transition: transform 1100ms var(--curva), opacity 125ms ease-out;
}
@media (min-width: 560px) {
  .objeto { clip-path: none; transform: translateX(calc(var(--P) / -2)); }
  [data-estado="abrindo"] .objeto,
  [data-estado="aberto"] .objeto { transform: translateX(0); }
}
.objeto.esmaecer { opacity: 0; }

.vaga-esquerda { grid-column: 1; }

/* Página direita (dedicatória). Fechada, tem exatamente a altura da capa. */
.pagina-direita {
  grid-column: 2;
  position: relative;
  height: var(--H);
  overflow: hidden;
  border: 1px solid var(--borda);
  border-radius: 4px;
  box-shadow: var(--sombra-cartao);
}
.pagina-direita::before {
  content: '';
  position: absolute;
  z-index: 1;
  left: 0; top: 0; bottom: 0;
  width: 18px;
  background: linear-gradient(90deg, var(--sombra-dobra), transparent);
  pointer-events: none;
}
html[data-escala="grande"] .pagina-direita::before { width: 6px; }
[data-estado="aberto"] .pagina-direita { height: auto; min-height: var(--H); }

.dedicatoria {
  position: relative;
  height: 100%;
  padding: 56px 20px 24px 24px;
  color: var(--tinta);
}
[data-estado="aberto"] .dedicatoria { height: auto; min-height: var(--H); }
/* Celular até 150%: só a página do cartão rola, com esmaecido na base. */
@media (max-width: 559.98px) {
  html:not([data-escala="grande"]) [data-estado="aberto"] .dedicatoria {
    max-height: max(var(--H), calc(100svh - 72px));
    overflow-y: auto;
    overflow-x: hidden;
  }
}
html[data-escala="grande"] .dedicatoria { padding: 56px 12px 24px 14px; }

.esmaecido {
  position: absolute;
  left: 1px; right: 1px; bottom: 0;
  height: 24px;
  background: linear-gradient(to bottom, transparent, var(--papel));
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
}
.pagina-direita.tem-mais .esmaecido { opacity: 1; }

.sombra-capa {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: var(--sombra-capa);
  opacity: 0;
  pointer-events: none;
}

/* Ponta do ramo: atravessa a dobra e entra no canto de cima da página. */
.ponta {
  position: absolute;
  left: -1px;
  top: 0;
  width: calc(var(--P) * 84 / 500);
  aspect-ratio: 84 / 98;
  pointer-events: none;
}
.ponta img { display: block; width: 100%; height: 100%; }
.ponta-halo { opacity: 0; }

.para, .mensagem, .assinatura {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: manual;
}
.para { font: italic 600 1.235rem/1.3 var(--serif); }
.mensagem {
  margin-top: 14px;
  font: 400 1.235rem/1.55 var(--serif);
  font-variation-settings: 'opsz' 20;
}
.para[hidden] + .mensagem { margin-top: 0; }
.mensagem.media { font-size: 1.118rem; line-height: 1.6; }
.mensagem.longa { font-size: 1rem; line-height: 1.6; }
.assinatura {
  margin-top: 18px;
  text-align: right;
  font: italic 600 1.118rem/1.3 var(--serif);
  color: var(--nome);
}
html[data-escala="grande"] .assinatura { text-align: left; }
.quebra { overflow-wrap: anywhere; }

/* ---------- Capa (o botão inteiro) ---------- */
.capa {
  position: absolute;
  z-index: 3;
  top: 0;
  bottom: 0;
  left: var(--aba);
  width: var(--P);
  height: var(--H);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  cursor: pointer;
  transform-origin: left center;
  transform-style: preserve-3d;
  -webkit-tap-highlight-color: transparent;
  transition: transform 1100ms var(--curva);
}
.capa:disabled { cursor: default; }
[data-estado="abrindo"] .capa,
[data-estado="aberto"] .capa { transform: rotateY(-180deg); cursor: default; }
[data-estado="aberto"] .capa { height: auto; }

.face {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  border: 1px solid var(--borda);
  border-radius: 4px;
  box-shadow: var(--sombra-cartao);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.tras { transform: rotateY(180deg); }
.arte { position: absolute; inset: 0; display: block; }
.arte img { display: block; width: 100%; height: 100%; }
.tras .arte { bottom: auto; aspect-ratio: 5 / 7; }
.brilho-capa { opacity: 0; }

.lombada { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--lombada); }
.dobra { position: absolute; top: 0; bottom: 0; width: 18px; pointer-events: none; }
.dobra-capa { left: 3px; background: linear-gradient(90deg, var(--sombra-dobra), transparent); }
.dobra-interior { right: 0; background: linear-gradient(270deg, var(--sombra-dobra), transparent); }

.titulo-capa {
  position: absolute;
  left: 16px;
  right: 16px;
  /* Ancorado pelo topo: em uma linha o centro fica em ≈ 62%; com texto
     ampliado o título quebra para baixo, sem subir sobre o ramo. */
  top: 58.5%;
  display: block;
  text-align: center;
  color: var(--tinta);
}
#titulo-capa {
  display: block;
  font: 600 calc(clamp(26px, calc(var(--P) * 0.11), 37px) * min(var(--escala), 1.3))/1.1 var(--serif);
  font-variation-settings: 'opsz' 60;
}
.para-capa {
  display: block;
  margin-top: 6px;
  font: italic 600 calc(18px * min(var(--escala), 1.3))/1.3 var(--serif);
  color: var(--nome);
}
.capa:focus-visible { outline-offset: 4px; }

/* Luz que percorre o caule da página esquerda (uma vez). */
.luz-caule {
  position: absolute;
  left: 14%;
  top: 92%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 246, 232, .55), rgba(255, 246, 232, 0) 70%);
  opacity: 0;
  pointer-events: none;
}

/* ---------- Brilho: uma única vez, depois calma ---------- */
.brilhar .brilho-capa { animation: brilho 600ms ease-in-out 0ms 1 both; }
.brilhar .sombra-capa { animation: sombra 1100ms linear 0ms 1 both; }
.brilhar .luz-caule { animation: caule 900ms ease-in-out 700ms 1 both; }
.brilhar .ponta-halo { animation: brilho 600ms ease-in-out 1250ms 1 both; }
@keyframes brilho { 0% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 0; } }
@keyframes sombra { 0% { opacity: 0; } 50% { opacity: .18; } 100% { opacity: 0; } }
@keyframes caule {
  0% { left: 14%; top: 92.3%; opacity: 0; }
  10% { opacity: 1; }
  30% { left: 33.6%; top: 71.4%; }
  55% { left: 58.4%; top: 48.6%; }
  80% { left: 82%; top: 19.4%; }
  90% { opacity: 1; }
  100% { left: 100%; top: 8.3%; opacity: 0; }
}

/* ---------- Abaixo do papel ---------- */
.toque {
  margin: 16px 16px 0;
  text-align: center;
  font: 700 1rem/1.3 var(--sans);
  color: var(--apoio);
  cursor: pointer;
}
[data-estado]:not([data-estado="fechado"]) .toque { display: none; }
.preparando {
  margin: 16px 16px 0;
  text-align: center;
  font: 400 1rem/1.5 var(--sans);
  color: var(--apoio);
}
.depois { display: flex; justify-content: center; padding: 0 16px; }
.botao-quieto {
  min-height: 48px;
  margin-top: 8px;
  padding: 8px 16px;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--oliva);
  font: 700 1rem/1.25 var(--sans);
  cursor: pointer;
}

/* ---------- Convite, fora do papel ---------- */
.convite, .painel, .indisponivel, .erro {
  max-width: 432px;
  margin: 0 auto;
  padding: 0 16px;
}
.convite {
  margin-top: 32px;
  padding-top: 32px;
  border-top: 1px solid var(--linha);
  max-width: 400px;
  box-sizing: content-box;
  text-align: left;
}
.convite.entrando { animation: entrar 400ms ease-out both; }
@keyframes entrar { from { opacity: 0; } to { opacity: 1; } }
.convite h2 {
  margin: 0;
  font: 600 1.176rem/1.3 var(--serif);
}
.botao-cheio {
  display: block;
  width: 100%;
  max-width: 400px;
  min-height: 52px;
  margin-top: 12px;
  padding: 12px 20px;
  border: 0;
  border-radius: 14px;
  background: var(--botao-fundo);
  color: var(--botao-texto);
  font: 700 1rem/1.25 var(--sans);
  cursor: pointer;
}
.conheca { margin: 24px 0 0; font: 400 0.941rem/1.5 var(--sans); }
.botao-link {
  min-height: 48px;
  margin: 4px 0 0;
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--tinta);
  font: 700 1rem/1.3 var(--sans);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-align: left;
  max-width: 100%;
  overflow-wrap: anywhere;
  -webkit-hyphens: auto;
  hyphens: auto;
  cursor: pointer;
}

/* ---------- Painéis "Criar meu cartão" e "Experimentar uma leitura" ---------- */
.painel { padding-top: 16px; }
.painel h1 { margin: 12px 0 8px; font: 600 1.412rem/1.25 var(--serif); }
.painel p { margin: 0; }
.selo {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--selo-fundo);
  color: var(--tinta);
  font: 700 0.882rem/1.4 var(--sans);
}
.capas { list-style: none; margin: 24px 0 8px; padding: 0; }
.capas li { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 16px; }
.capa-mini {
  position: relative;
  width: 160px;
  height: 224px;
  border: 1px solid var(--borda);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--sombra-cartao);
}
.capa-mini img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.capa-nome { font: 700 1rem/1.3 var(--sans); text-align: center; }
.painel .botao-cheio { margin-top: 24px; }

/* ---------- Indisponível e erro ---------- */
.indisponivel { padding-top: 48px; padding-bottom: 32px; text-align: center; }
.indisponivel h1 { margin: 0; font: 600 1.176rem/1.35 var(--serif); }
.erro { display: flex; justify-content: center; padding-top: 8px; }
.papel-erro {
  width: min(100%, 340px);
  min-height: calc(min(100cqi - 32px, 340px) * 1.4);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 20px;
  border: 1px solid var(--borda);
  border-radius: 4px;
  box-shadow: var(--sombra-cartao);
  text-align: center;
}
.papel-erro p { margin: 0; font: 400 1rem/1.5 var(--sans); }

/* ---------- Rodapé ---------- */
.rodape {
  max-width: 432px;
  margin: 40px auto 0;
  padding: 16px 16px 32px;
  border-top: 1px solid var(--linha);
  color: var(--apoio);
  font: 400 0.882rem/1.45 var(--sans);
}
.rodape p { margin: 0 0 8px; }
.rodape-teste { font-weight: 700; }
.rodape a { display: inline-block; min-height: 48px; padding: 12px 0; line-height: 1.45; overflow-wrap: anywhere; }
.rodape p:has(a) { margin-bottom: 0; }
/* Link do e-mail e o ponto final juntos; o e-mail ainda quebra se não couber. */
.junto { white-space: nowrap; }
/* Quebra só nos <wbr> do endereço; nada parte entre o "br" e o ponto. */
.junto a { display: inline; padding: 12px 0; white-space: normal; overflow-wrap: normal; }
.sobre summary {
  display: flex;
  align-items: center;
  min-height: 48px;
  font-weight: 700;
  color: var(--tinta);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.sobre p { margin-top: 4px; }

/* ---------- Movimento reduzido: fade de 250 ms, sem giro nem brilho ---------- */
@media (prefers-reduced-motion: reduce) {
  .objeto { transition: opacity 125ms ease-out; }
  .capa { transition: none; }
  .brilhar .brilho-capa,
  .brilhar .sombra-capa,
  .brilhar .luz-caule,
  .brilhar .ponta-halo,
  .convite.entrando { animation: none; }
  .esmaecido { transition: none; }
}

/* ---------- Verso (costas do cartão), abaixo do papel depois de abrir ---------- */
.verso {
  position: relative;
  width: min(calc(100% - 32px), 240px);
  aspect-ratio: 5 / 7;
  margin: 24px auto 0;
  border: 1px solid var(--borda);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--sombra-cartao);
}
html[data-escala="grande"] .verso { width: min(calc(100% - 32px), 300px); aspect-ratio: auto; }
.verso-marca {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 84%;
  transform: translateY(-50%);
  margin: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: left;
  font: 600 1rem/1.25 var(--serif);
  font-variation-settings: 'opsz' 60;
  color: var(--tinta);
}
/* Texto ampliado: o ornamento da arte ficaria sob o texto; fica só o papel
   com o filete, e o texto centralizado cresce sem teto. */
html[data-escala="grande"] .verso .arte { display: none; }
html[data-escala="grande"] .verso::after {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px solid var(--borda);
  border-radius: 4px;
  opacity: .7;
  pointer-events: none;
}
html[data-escala="grande"] .verso-marca { position: relative; top: auto; left: auto; right: auto; transform: none; min-height: 280px; padding: 32px 24px; flex-direction: column; justify-content: center; text-align: center; }
.verso-marca picture { flex: none; }
.verso-marca img { display: block; height: 28px; width: auto; }
