:root {
  --linho: #aa675a;
  --papel: #f8e7d5;
  --vinho: #68182c;
  --tinta: #531d27;
  --ouro: #b38b51;
  --luz: #fff1d5;
  --sombra: rgba(60, 17, 15, .36);
  --cera: #75192d;
  color-scheme: light;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--tinta);
  background: var(--linho);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--linho) url("assets/linho.jpg") left center / cover no-repeat;
  pointer-events: none;
}
button { font: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible {
  outline: 3px solid var(--vinho);
  outline-offset: 4px;
  box-shadow: 0 0 0 5px var(--luz);
}
/* O foco vai para o "Mãe," só para o leitor de tela começar por ali; não é um controle. */
.greeting:focus { outline: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.experience { width: 100%; }
.painel {
  min-width: 0;
  min-height: 100vh;
  min-height: 100svh;
  padding: 36px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.opening {
  width: min(100%, 690px);
  display: grid;
  justify-items: center;
  gap: clamp(22px, 5vmin, 54px);
}
/* Envelope: a frente é a imagem da referência; o verso (aba, bolso e forro) só aparece na abertura. */
.envelope {
  --papel-envelope: #ecada0 url("assets/papel-envelope.png") 0 0 / 23.9% auto;
  --ponta: 57%;
  position: relative;
  width: 100%;
  aspect-ratio: 796 / 582;
  isolation: isolate;
  perspective: 1300px;
}
.envelope > div, .verso > div { position: absolute; pointer-events: none; }
.sombra-envelope {
  inset: 1.2% .7% 1.2% .6%;
  border-radius: 3px;
  background: var(--sombra);
  filter: blur(3px);
  transform: translate(1px, 7px);
}
.cartao { inset: 0; transform-style: preserve-3d; }
.frente, .verso { position: absolute; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.frente { inset: 0; background: url("assets/envelope.png") center / 100% 100% no-repeat; }
.verso {
  inset: 1.2% .7% 1.2% .6%;
  visibility: hidden;
  transform: rotateY(180deg);
  perspective: 900px;
  perspective-origin: 50% 0;
}
/* Fora da abertura o verso some de vez (alguns navegadores deixam a aba 3D vazar pela frente). */
.is-opening .verso { visibility: visible; }
.bolso svg, .aba svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.fundo {
  inset: 0;
  z-index: 1;
  border-radius: 2px;
  background: linear-gradient(180deg, #7c4037, #a9695d 45%, #c08376);
  box-shadow: inset 0 5px 9px rgba(60, 17, 15, .45);
}
.janela { z-index: 3; overflow: hidden; }
.voo { position: absolute; left: 0; top: 0; }
.voo .letter { position: absolute; left: 0; top: 0; margin: 0; transform-origin: 0 0; }
.bolso-sombra { inset: 0; z-index: 4; filter: drop-shadow(0 -1.5px 2.5px rgba(70, 20, 15, .38)); }
.bolso {
  position: absolute;
  inset: 0;
  border-radius: 2px;
  background: var(--papel-envelope);
  clip-path: polygon(0 0, 50% var(--ponta), 100% 0, 100% 100%, 0 100%);
}
.bolso .lado { fill: rgba(255, 238, 228, .1); }
.bolso .direito { fill: rgba(255, 238, 228, .04); }
.bolso .base { fill: rgba(122, 48, 36, .08); }
.vinco { fill: none; stroke: rgba(112, 42, 32, .3); stroke-width: 1; vector-effect: non-scaling-stroke; }
.vinco.luz { stroke: rgba(255, 236, 226, .55); }
.aba-sombra {
  left: 0; top: 0; width: 100%; height: var(--ponta);
  z-index: 5;
  filter: blur(2.5px);
  transform: translateY(2.5px);
}
.aba-sombra i, .aba > div {
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.aba-sombra i { background: rgba(80, 25, 20, .34); }
.aba {
  left: 0; top: 0; width: 100%; height: var(--ponta);
  z-index: 6;
  transform-origin: 50% 0;
  transform-style: preserve-3d;
}
.aba > div { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.aba-fora {
  background: linear-gradient(180deg, rgba(255, 244, 236, .16), rgba(255, 244, 236, 0) 55%, rgba(122, 48, 36, .06)), var(--papel-envelope);
}
.aba-dentro {
  transform: rotateY(180deg);
  background: var(--papel) url("assets/papel-textura.png") center / 112px 248px repeat;
}
.filete { fill: none; stroke: var(--ouro); stroke-width: 1; vector-effect: non-scaling-stroke; }
.luz-aba { position: absolute; inset: 0; background: #4a1712; opacity: 0; }
.open-letter {
  padding: 0;
  border: 0;
  width: 64%;
  min-height: 48px;
  display: grid;
  align-content: center;
  background: transparent;
  border-radius: 28px;
  filter: drop-shadow(0 6px 3px var(--sombra));
  transition: transform 180ms ease, filter 180ms ease;
}
.open-letter img { display: block; width: 100%; height: auto; }
@media (hover:hover) {
  .open-letter:hover { transform: translateY(-2px); filter: drop-shadow(0 8px 5px var(--sombra)); }
}
.open-letter:active { transform: translateY(2px); }
.is-opening .painel { position: relative; z-index: 2; }

.previa { display: none; }
.papel {
  position: relative;
  isolation: isolate;
  align-self: start;
  color: var(--vinho);
  padding: clamp(28px, 6%, 60px);
  filter: drop-shadow(2px 5px 3px var(--sombra));
}
.papel::before, .papel::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: -1;
}
.papel::before { inset: 15px; background: var(--papel) url("assets/papel-textura.png") center / 112px 248px repeat; }
.papel::after { inset: 0; border: 26px solid transparent; border-image: url("assets/papel.png") 49 51 48 51 / 26px / 0 stretch round; }
.letter {
  width: min(94%, 650px);
  margin: 14px auto 0;
  padding-block: clamp(26px, 4vw, 52px);
  padding-inline: clamp(30px, 7vw, 60px);
}
.rubrica { margin: 0 auto 6px; }
.saudacao { width: clamp(88px, 26%, 188px); }
.saudacao img, .autografo { width: 100%; height: auto; display: block; }
.family-photo {
  width: min(91%, 430px);
  position: relative;
  margin: 0 auto clamp(15px, 2vw, 25px);
  padding: clamp(4px, .55vw, 8px);
  background: linear-gradient(145deg, #fff3db, #e7c69b);
  box-shadow: 0 2px 5px var(--sombra);
}
.family-photo svg { display: block; width: 100%; height: auto; }
.canto {
  position: absolute;
  width: 12%;
  aspect-ratio: 53 / 51;
  background: url("assets/cantoneira.png") center / contain no-repeat;
  pointer-events: none;
}
.se { top: -1%; left: -1%; }
.sd { top: -1%; right: -1%; transform: scaleX(-1); }
.ie { bottom: -1%; left: -1%; transform: scaleY(-1); }
.id { bottom: -1%; right: -1%; transform: scale(-1); }
.letter-copy, .signature-prefix {
  color: var(--tinta);
  font-size: clamp(1.1875rem, 1.05rem + .45vw, 1.375rem);
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.letter-copy p { margin: 0 0 1.1em; }
.despedida {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 8px;
}
.signature { margin-top: 32px; }
.despedida > div { min-width: 0; }
.autografo { width: min(100%, 236px); margin-top: .3em; }
.gravura { display: block; width: clamp(42px, 24%, 145px); height: auto; flex: none; }
.credito {
  margin: 18px auto 8px;
  padding: 0 20px;
  max-width: 650px;
  text-align: center;
  color: var(--luz);
  font-size: .8125rem;
  line-height: 1.5;
  text-shadow: 0 1px 2px rgba(60, 17, 15, .6);
}
.credito a { color: inherit; }
body:not(.is-open) .credito { display: none; }
#alternar-musica {
  border: 1px solid var(--ouro);
  background: var(--cera);
  color: var(--luz);
  border-radius: 24px;
  padding: 8px 18px;
  min-height: 44px;
  font: 500 1rem/1.3 Georgia, serif;
  box-shadow: 0 3px 10px var(--sombra);
}
#alternar-musica::before { content: ""; display: inline-block; width: .6em; height: .7em; margin-right: .5em; background: currentColor; clip-path: polygon(0 0,100% 50%,0 100%); }
#alternar-musica[data-tocando="true"]::before { clip-path: polygon(0 0,36% 0,36% 100%,64% 100%,64% 0,100% 0,100% 100%,0 100%); }
@media (max-width: 899px) {
  .is-open .painel { display: contents; }
  .is-open .opening { display: none; }
  .is-open .experience { padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
  #alternar-musica { position: fixed; bottom: max(12px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 3; white-space: nowrap; }
}
@media (min-width: 900px) {
  .experience {
    width: min(100%, 150svh, 1680px);
    margin-inline: auto;
    display: grid;
    grid-template-columns: minmax(0, 1.21fr) minmax(0, 1fr);
    align-items: start;
    gap: 1.4%;
    padding: 1.1vh 1.9% 2vh;
    container-type: inline-size;
  }
  .painel {
    position: sticky;
    top: 0;
    height: 98svh;
    min-height: 0;
    padding: 0;
    gap: 3cqw;
  }
  .opening { width: 100%; gap: 3.4cqw; }
  .open-letter { width: 63%; }
  .previa {
    display: block;
    font-size: clamp(1rem, 1.9cqw, 2rem);
    line-height: 1.13;
    padding: 2.4cqw 4.8cqw 3.4cqw;
    margin: 0 auto;
    width: 100%;
    min-height: 64cqw;
  }
  .papel::before { inset: 2cqw; }
  .papel::after { border-image-width: 3.4cqw; }
  .previa .saudacao { width: 14cqw; margin: 0 auto .2cqw; }
  .previa .family-photo { width: 90%; margin-bottom: 1cqw; }
  .previa .family-photo svg { aspect-ratio: 1.035; height: auto; }
  .previa .amostra p { margin: 0 0 .48em; }
  .previa .amostra p:nth-child(2) { padding-right: 10%; }
  .previa .despedida { margin-top: 1.1cqw; min-height: 5cqw; }
  .previa .autografo { width: 17cqw; margin-top: .35em; }
  .previa .gravura { width: 10cqw; position: absolute; bottom: -.4cqw; right: -1cqw; }
  .is-open .previa { display: none; }
  .letter { width: 100%; margin: 0; padding: 2.4cqw 4.6cqw 3.4cqw; }
  .letter .saudacao { width: 13cqw; }
  .letter .family-photo { width: 90%; }
  .credito { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
