:root {
  --perola: #FFFDF8;
  --linho: #F5EEDF;
  --ouro: #B8913F;
  --ouro-claro: #EAD49C;
  --ouro-escuro: #8A6A26;
  --tinta: #3B3122;
  --tinta-suave: #6E604A;
  --foil: linear-gradient(100deg, #8A6A26 0%, #B8913F 20%, #DCBD74 36%, #B8913F 50%, #8F6F29 66%, #CFAE5F 84%, #8A6A26 100%);
  --serif: "Bodoni Moda", "Bodoni 72", Didot, Georgia, serif;
  --script: "Pinyon Script", "Snell Roundhand", "Apple Chancery", cursive;
  --topo: calc(env(safe-area-inset-top) + 60px);
  --base: calc(env(safe-area-inset-bottom) + 44px);
  --entra: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }

html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.6;
  color: var(--tinta);
  background: radial-gradient(120% 75% at 50% 42%, #FFFFFF 0%, var(--perola) 55%, var(--linho) 135%) var(--perola);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--ouro-escuro);
  outline-offset: 4px;
}

#poeira {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.palco {
  position: fixed;
  inset: 0;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  touch-action: none;
  z-index: 1;
}

/* ---------- Cenas e transições ---------- */

.cena {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--topo) 28px var(--base);
  opacity: 0;
  visibility: hidden;
  transform: scale(1.04);
  filter: blur(6px);
  transition:
    opacity .8s ease,
    transform 1.4s var(--entra),
    filter .8s ease,
    visibility 0s linear .8s;
}

.cena.ativa {
  opacity: 1;
  visibility: visible;
  transform: none;
  filter: none;
  transition-delay: .25s, .25s, .25s, 0s;
}

.cena.saiu { transform: scale(.96); }

/* Elementos que surgem em sequência; o reset só acontece depois que a cena some */
.r {
  opacity: 0;
  transform: translateY(12px);
  filter: blur(3px);
  transition:
    opacity 1s ease,
    transform 1.2s var(--entra),
    filter 1s ease;
  transition-delay: calc(.55s + var(--i, 0) * .4s);
}

.ativa .r {
  opacity: 1;
  transform: none;
  filter: none;
}

.cena:not(.ativa) .r {
  transition-duration: 0s;
  transition-delay: .9s;
}

/* ---------- Tipografia ---------- */

.ouro {
  background: var(--foil);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: brilho 7s ease-in-out infinite alternate;
}

@keyframes brilho {
  from { background-position: 0% 0; }
  to { background-position: 100% 0; }
}

/* Nomes "escritos" da esquerda para a direita */
.nome {
  display: block;
  font-family: var(--script);
  font-weight: 400;
  line-height: 1.2;
  padding: 0 .35em;
  -webkit-mask-image: linear-gradient(90deg, #000 40%, transparent 60%);
  mask-image: linear-gradient(90deg, #000 40%, transparent 60%);
  -webkit-mask-size: 260% 100%;
  mask-size: 260% 100%;
  -webkit-mask-position: 100% 0;
  mask-position: 100% 0;
  transition: -webkit-mask-position 1.8s cubic-bezier(.5, .1, .25, 1) var(--d, .5s), mask-position 1.8s cubic-bezier(.5, .1, .25, 1) var(--d, .5s);
}

.ativa .nome {
  -webkit-mask-position: 0 0;
  mask-position: 0 0;
}

.cena:not(.ativa) .nome {
  transition-duration: 0s;
  transition-delay: .9s;
}

.linha {
  margin: 0;
  font-style: italic;
  font-size: 16px;
  color: var(--tinta-suave);
  letter-spacing: .01em;
}

.sub {
  margin: 10px 0 0;
  max-width: 26ch;
  font-size: 16px;
  color: var(--tinta-suave);
  text-wrap: balance;
}

.versiculo {
  margin: 0;
  max-width: 21ch;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(20px, 2.9dvh, 24px);
  line-height: 1.45;
  color: var(--tinta);
  text-wrap: balance;
}

.ref {
  display: block;
  margin-top: 14px;
  font-style: normal;
  font-size: 14px;
  letter-spacing: .1em;
  color: var(--ouro-escuro);
}

/* ---------- Selo ---------- */

/* Os raios ficam sempre centralizados na medalha */
.halo { position: relative; }

.raios {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(190vw, 900px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  opacity: .55;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(closest-side, #000 30%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 30%, transparent 100%);
  transition: transform 1.3s var(--entra), opacity 1.1s ease;
}

.raios svg {
  width: 100%;
  height: 100%;
  animation: gira 140s linear infinite;
}

@keyframes gira { to { transform: rotate(360deg); } }

.halo-selo { margin-top: -6dvh; }

.selo {
  position: relative;
  display: block;
  width: min(62vw, 250px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  transition: transform .15s ease;
}

.selo:active { transform: scale(.96); }

.selo::before,
.selo::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 1px solid var(--ouro);
  border-radius: 50%;
  animation: pulso 3s ease-out infinite;
  pointer-events: none;
}

.selo::after { animation-delay: 1.5s; }

@keyframes pulso {
  0% { transform: scale(1); opacity: .7; }
  100% { transform: scale(1.4); opacity: 0; }
}

.medalha {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 14px 22px rgba(138, 106, 38, .28)) drop-shadow(0 2px 3px rgba(138, 106, 38, .35));
}

.medalha svg { display: block; width: 100%; height: 100%; }

.medalha .reflexo {
  transform: translateX(-160px) skewX(-18deg);
  animation: reflexo 4.5s ease-in-out 1.2s infinite;
}

@keyframes reflexo {
  0% { transform: translateX(-160px) skewX(-18deg); }
  45%, 100% { transform: translateX(260px) skewX(-18deg); }
}

.onda {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--ouro-claro);
  opacity: 0;
  pointer-events: none;
}

.convite {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--base) + 6dvh);
  margin: 0;
  font-style: italic;
  font-size: 17px;
  color: var(--tinta-suave);
  animation: respira 3s ease-in-out infinite;
}

@keyframes respira {
  0%, 100% { opacity: .45; }
  50% { opacity: 1; }
}

/* Abertura do selo */
body.abrindo .selo::before,
body.abrindo .selo::after { animation: none; opacity: 0; }

body.abrindo .selo .medalha { animation: abre 1.1s cubic-bezier(.3, .1, .2, 1) forwards; }

@keyframes abre {
  0% { transform: scale(1); }
  14% { transform: scale(.9); }
  45% { transform: scale(1.06); filter: brightness(1.2) drop-shadow(0 0 30px rgba(234, 212, 156, .9)); }
  100% { transform: scale(1.5); opacity: 0; filter: brightness(1.6) blur(6px); }
}

body.abrindo .onda { animation: onda 1.3s ease-out var(--d) forwards; }

@keyframes onda {
  0% { transform: scale(.9); opacity: .9; }
  100% { transform: scale(3.4); opacity: 0; }
}

body.abrindo .cena-selo .raios {
  transform: translate(-50%, -50%) scale(1.7);
  opacity: 0;
}

body.abrindo .convite { animation: none; opacity: 0; transition: opacity .3s; }

.clarao {
  position: fixed;
  left: 50%;
  top: 45%;
  width: 60vmax;
  height: 60vmax;
  margin: -30vmax 0 0 -30vmax;
  border-radius: 50%;
  background: radial-gradient(circle, #FFFFFF 0%, rgba(255, 251, 240, .96) 38%, rgba(234, 212, 156, .35) 62%, rgba(234, 212, 156, 0) 72%);
  opacity: 0;
  transform: scale(0);
  pointer-events: none;
  z-index: 4;
}

body.abrindo .clarao { animation: clarao 1.8s ease-out .15s forwards; }

@keyframes clarao {
  0% { transform: scale(.1); opacity: 0; }
  30% { opacity: 1; }
  55% { transform: scale(3); opacity: 1; }
  100% { transform: scale(3.6); opacity: 0; }
}

/* ---------- Barra de progresso ---------- */

.progresso {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 14px);
  left: 18px;
  right: 18px;
  display: flex;
  gap: 5px;
  z-index: 10;
  opacity: 0;
  transition: opacity .8s ease .6s;
}

body[data-cena]:not([data-cena="0"]) .progresso { opacity: 1; }
body.pausado .progresso { opacity: .45; transition-delay: 0s; }

.seg {
  flex: 1;
  height: 2px;
  border-radius: 2px;
  background: rgba(184, 145, 63, .22);
  overflow: hidden;
}

.seg i {
  display: block;
  height: 100%;
  background: var(--ouro);
  transform: scaleX(0);
  transform-origin: left;
}

/* ---------- Nomes ---------- */

.nomes {
  margin: 18px 0 6px;
  font-weight: 400;
  font-size: clamp(58px, 17vw, 82px);
}

.nomes .e {
  display: block;
  margin: -.05em 0 -.1em;
  font-family: var(--serif);
  font-style: italic;
  font-size: .36em;
  line-height: 1.3;
  color: var(--ouro-escuro);
}

.traco {
  width: 200px;
  height: 20px;
  margin: 10px 0 18px;
  overflow: visible;
}

.traco path {
  fill: none;
  stroke: var(--ouro);
  stroke-width: 1;
  stroke-linecap: round;
}

.t-esq, .t-dir {
  stroke-dasharray: 104;
  stroke-dashoffset: 104;
  transition: stroke-dashoffset 1.6s cubic-bezier(.6, .1, .2, 1) 2.9s;
}

.t-cruz {
  opacity: 0;
  transition: opacity 1s ease 2.6s;
}

.ativa .t-esq, .ativa .t-dir { stroke-dashoffset: 0; }
.ativa .t-cruz { opacity: 1; }

.cena:not(.ativa) .traco path { transition-duration: 0s; transition-delay: .9s; }

.data {
  margin: 0;
  font-size: 17px;
  letter-spacing: .06em;
  color: var(--ouro-escuro);
}

.dica {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 22px);
  margin: 0;
  font-style: italic;
  font-size: 13px;
  color: var(--tinta-suave);
  opacity: 0;
}

.ativa .dica.mostrar { animation: dica 6s ease 1.5s forwards; }

@keyframes dica {
  0% { opacity: 0; }
  15%, 75% { opacity: .8; }
  100% { opacity: 0; }
}

/* ---------- Arco (moldura em forma de janela de capela) ---------- */

.arco {
  position: relative;
  isolation: isolate;
  margin: 0 0 26px;
  padding: 8px;
  aspect-ratio: 3 / 4;
  border-radius: 999px 999px 12px 12px;
}

.arco.grande { width: min(74vw, 320px, calc(54dvh * .75)); }
.arco.medio { width: min(62vw, 270px, calc(44dvh * .75)); margin: 18px 0 0; }

.arco::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid var(--ouro);
  border-radius: inherit;
  opacity: 0;
  transform: scale(1.05);
  transition: opacity 1.4s ease .3s, transform 1.6s var(--entra) .3s;
}

.arco::after {
  content: "";
  position: absolute;
  inset: -16% -26%;
  z-index: -1;
  background: radial-gradient(closest-side, rgba(234, 212, 156, .55), rgba(234, 212, 156, 0));
  opacity: 0;
  transition: opacity 2.4s ease .6s;
}

.ativa .arco::before { opacity: 1; transform: none; }
.ativa .arco::after { opacity: 1; }

.janela {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 999px 999px 6px 6px;
  background: var(--linho);
  clip-path: inset(100% 0 0 0);
  transition: clip-path 1.7s cubic-bezier(.65, .05, .2, 1) .55s;
}

.ativa .janela { clip-path: inset(0 0 0 0); }

.janela img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.18);
  transition: transform 8s cubic-bezier(.2, .6, .3, 1) .55s;
}

.ativa .janela img { transform: scale(1.02); }

.cena:not(.ativa) .janela,
.cena:not(.ativa) .janela img,
.cena:not(.ativa) .arco::before,
.cena:not(.ativa) .arco::after {
  transition-duration: 0s;
  transition-delay: .9s;
}

/* Enquanto a foto não é colocada na pasta */
.vazia {
  background: linear-gradient(165deg, #FFFDF7 0%, #F1E5C9 100%);
}

.vazia::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 40%;
  width: 22px;
  height: 34px;
  transform: translate(-50%, -50%);
  background:
    linear-gradient(var(--ouro), var(--ouro)) 50% 0 / 1px 100% no-repeat,
    linear-gradient(var(--ouro), var(--ouro)) 0 30% / 100% 1px no-repeat;
}

.vazia::after {
  content: "Foto: " attr(data-arquivo);
  position: absolute;
  left: 0;
  right: 0;
  top: calc(40% + 34px);
  font-style: italic;
  font-size: 13px;
  color: var(--ouro-escuro);
}

.legenda {
  margin: 0;
  font-weight: 400;
  font-style: italic;
  font-size: clamp(21px, 6vw, 25px);
  line-height: 1.3;
  color: var(--tinta);
}

/* ---------- Cordão de três dobras ---------- */

.cordao {
  width: 110px;
  height: min(36dvh, 290px);
  margin-bottom: 30px;
  overflow: visible;
  clip-path: inset(0 -20px 100% -20px);
  transition: clip-path 3.2s cubic-bezier(.55, .1, .3, 1) .5s;
}

.ativa .cordao { clip-path: inset(-10px -20px -10px -20px); }
.cena:not(.ativa) .cordao { transition-duration: 0s; transition-delay: .9s; }

/* ---------- Galeria ---------- */

.cena-galeria {
  justify-content: flex-end;
  padding: 0;
}

.galeria {
  position: absolute;
  inset: 0;
  background: var(--linho);
}

.cena-galeria::before,
.cena-galeria::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 1;
}

.cena-galeria::before {
  top: 0;
  height: 22%;
  background: linear-gradient(rgba(255, 253, 248, .75), rgba(255, 253, 248, 0));
}

.cena-galeria::after {
  bottom: 0;
  height: 52%;
  background: linear-gradient(to top, var(--perola) 0%, rgba(255, 253, 248, .93) 30%, rgba(255, 253, 248, 0) 100%);
}

.gfoto {
  position: absolute;
  inset: 0;
  opacity: 0;
  overflow: hidden;
  transition: opacity 1.5s ease;
}

.gfoto.on { opacity: 1; }

.gfoto img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.14);
  transition: transform 0s 1.6s;
}

.gfoto:nth-child(even) img { transform: scale(1.02) translateX(0); }

.gfoto.on img {
  transform: scale(1.02);
  transition: transform 7.5s cubic-bezier(.2, .6, .3, 1);
}

.gfoto:nth-child(even).on img { transform: scale(1.14) translateX(-2%); }

.gfoto.vazia::before { top: 34%; }
.gfoto.vazia::after { top: calc(34% + 34px); }

.galeria-texto {
  position: relative;
  z-index: 2;
  padding: 0 28px var(--base);
}

/* ---------- Cecilia ---------- */

.nome-filha {
  margin: 4px 0 0;
  font-size: clamp(64px, 19vw, 88px);
}

/* ---------- Bênção ---------- */

.cruz {
  width: 16px;
  height: 22px;
  margin: 30px 0 26px;
}

.cruz path {
  fill: none;
  stroke: var(--ouro);
  stroke-width: 1;
}

.mensagem {
  margin: 0;
  max-width: 28ch;
  font-size: clamp(16px, 2.3dvh, 18px);
  line-height: 1.7;
  color: var(--tinta);
  text-wrap: pretty;
}

.assinatura {
  margin: 18px 0 0;
  font-family: var(--script);
  font-size: 36px;
  line-height: 1.15;
  color: var(--ouro-escuro);
  white-space: pre-line;
}

/* ---------- Final ---------- */

.halo-final { margin-top: -4dvh; }
.halo-final .raios { opacity: .45; }

.halo-final .medalha {
  width: min(38vw, 150px);
  height: auto;
  aspect-ratio: 1;
}

.nomes-final {
  margin: 22px 0 10px;
  font-size: clamp(44px, 13vw, 60px);
}

.rever {
  margin-top: 40px;
  padding: 11px 28px;
  border: 1px solid var(--ouro);
  border-radius: 999px;
  background: rgba(255, 253, 248, .6);
  font-style: italic;
  font-size: 16px;
  color: var(--ouro-escuro);
}

.rever:active { background: var(--linho); }

/* ---------- Som ---------- */

.som {
  position: absolute;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  z-index: 10;
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(184, 145, 63, .45);
  border-radius: 50%;
  background: rgba(255, 253, 248, .75);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.som[hidden] { display: none; }

.som svg { width: 20px; height: 20px; }

.som path {
  fill: none;
  stroke: var(--ouro-escuro);
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.som .risco { display: none; }
.som.mudo .ondas { display: none; }
.som.mudo .risco { display: inline; }

/* ---------- Telas baixas (iPhone SE e afins) ---------- */

@media (max-height: 700px) {
  :root {
    --topo: calc(env(safe-area-inset-top) + 48px);
    --base: calc(env(safe-area-inset-bottom) + 34px);
  }
  .nomes { font-size: clamp(52px, 15vw, 70px); }
  .cruz { margin: 20px 0 18px; }
  .arco { margin-bottom: 18px; }
}

/* ---------- Movimento reduzido ---------- */

@media (prefers-reduced-motion: reduce) {
  .cena { transform: none; filter: none; }
  .r { transform: none; filter: none; }
  .raios svg,
  .ouro,
  .medalha .reflexo,
  .selo::before,
  .selo::after,
  .convite { animation: none; }
  .janela img,
  .gfoto img { transform: none !important; transition: none !important; }
}
