/* Faixa de Boas Festas e árvore. O roteiro da montagem usa --d (segundo em que cada peça entra,
 * definido no SVG por arvore.js) e --t (escala de tempo: NATAL_CONFIG.arvore.duracaoMs / 5200).
 * Animações só em transform e opacity. */

.festas,
.festas-reabrir {
  display: none;
}

:root[data-sazonal='natal'] .festas:not([hidden]) {
  display: block;
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--conteudo-max);
  margin: 0 auto;
  padding: 40px 24px 0;
}

:root[data-sazonal='natal'] body.buscando .festas {
  display: none;
}

/* ---------- Cartão: verde profundo, dourado e luz suave ---------- */
.festas__cartao {
  --px: 0px;
  --py: 0px;
  position: relative;
  display: grid;
  grid-template-columns: 1fr 240px;
  align-items: end;
  gap: 24px;
  min-height: 200px;
  padding: 24px 26px 0 32px;
  border-radius: 18px;
  background: radial-gradient(120% 140% at 85% 100%, rgba(212, 175, 55, 0.16) 0%, rgba(212, 175, 55, 0) 45%),
    radial-gradient(90% 120% at 0% 0%, #1a5a37 0%, rgba(22, 91, 51, 0) 60%),
    linear-gradient(135deg, #0b2a1f 0%, #071c16 55%, #04110d 100%);
  color: var(--neve, #f8f5e9);
  box-shadow: 0 24px 50px -26px rgba(4, 17, 13, 0.85), inset 0 0 0 1px rgba(212, 175, 55, 0.22);
  overflow: hidden;
}

/* filete dourado interno */
.festas__cartao::before {
  content: '';
  position: absolute;
  top: 7px;
  right: 7px;
  bottom: 13px;
  left: 7px;
  border: 1px solid rgba(212, 175, 55, 0.18);
  border-radius: 13px;
  pointer-events: none;
}

/* faixa dourada na borda de baixo */
.festas__cartao::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  background: linear-gradient(90deg, #8a6d1f, #d4af37 30%, #f3dc8a 50%, #d4af37 70%, #8a6d1f);
}

.festas__cartao--entrando .festas__textos {
  animation: festas-texto 900ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes festas-texto {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

/* luzes desfocadas ao fundo (bokeh), deslocando no sentido contrário do mouse */
.festas__bokeh {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  pointer-events: none;
  transform: translate(calc(var(--px) * -0.6), calc(var(--py) * -0.6));
  transition: transform 600ms ease-out;
}

.festas__bokeh i {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(243, 220, 138, 0.45) 0%, rgba(243, 220, 138, 0) 70%);
  animation: bokeh 9s ease-in-out infinite alternate;
}

.festas__bokeh i:nth-child(1) { width: 90px; height: 90px; top: 10%; left: 42%; }
.festas__bokeh i:nth-child(2) { width: 50px; height: 50px; top: 62%; left: 30%; animation-delay: -2s; }
.festas__bokeh i:nth-child(3) { width: 120px; height: 120px; top: -20%; left: 64%; animation-delay: -4s; opacity: 0.7; }
.festas__bokeh i:nth-child(4) { width: 36px; height: 36px; top: 30%; left: 12%; animation-delay: -6s; }
.festas__bokeh i:nth-child(5) {
  width: 70px;
  height: 70px;
  top: 55%;
  left: 55%;
  animation-delay: -3s;
  background: radial-gradient(circle, rgba(187, 37, 40, 0.35) 0%, rgba(187, 37, 40, 0) 70%);
}
.festas__bokeh i:nth-child(6) { width: 44px; height: 44px; top: 8%; left: 22%; animation-delay: -5s; }

@keyframes bokeh {
  from {
    transform: translate(0, 0) scale(1);
    opacity: 0.55;
  }
  to {
    transform: translate(18px, -10px) scale(1.15);
    opacity: 1;
  }
}

.festas__fechar {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(248, 245, 233, 0.08);
  color: #f8f5e9;
  cursor: pointer;
  transition: background var(--transicao);
}

.festas__fechar:hover {
  background: rgba(248, 245, 233, 0.2);
}

.festas__fechar svg {
  width: 16px;
  height: 16px;
}

.festas__textos {
  position: relative;
  z-index: 1;
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-bottom: 26px;
}

.festas__etiqueta {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #d4af37;
}

.festas__etiqueta svg {
  width: 15px;
  height: 15px;
  animation: girar 12s linear infinite;
}

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

.festas__titulo {
  margin: 0;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 32px;
  font-weight: 600;
  line-height: 1.12;
  color: #f8f5e9;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.35);
}

.festas__titulo strong {
  font-style: italic;
  font-weight: 700;
  color: #e6c45a;
  background: linear-gradient(180deg, #f6e4a1 0%, #d4af37 60%, #b08a26 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.festas__mensagem {
  margin: 0;
  max-width: 560px;
  font-size: 13.5px;
  color: rgba(248, 245, 233, 0.78);
}

.festas__contagem {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.festas__contagem:empty {
  display: none;
}

.festas__caixa {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 58px;
  padding: 8px 8px 6px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(248, 245, 233, 0.09), rgba(248, 245, 233, 0.03));
  box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.3), 0 8px 18px -12px rgba(0, 0, 0, 0.6);
}

.festas__caixa strong {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 21px;
  font-weight: 600;
  line-height: 1.1;
  color: #f8f5e9;
}

.festas__caixa small {
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #d4af37;
}

/* ---------- Cena da árvore ---------- */
.festas__cena {
  position: relative;
  z-index: 1;
  align-self: end;
  height: 226px;
}

.festas__palco {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  transform: translate(var(--px), var(--py));
  transition: transform 500ms ease-out;
}

.festas__particulas {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  pointer-events: none;
}

.arvore {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 210px;
  height: 250px;
  margin-left: -105px;
  overflow: visible;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.35));
}

.arvore__chao {
  fill: #f8f5e9;
  opacity: 0.95;
}

.arvore__neve {
  fill: #f8f5e9;
  opacity: 0.9;
}

.arvore__guirlanda {
  fill: none;
  stroke: #d4af37;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 1 5;
  animation: guirlanda 3s linear infinite;
}

@keyframes guirlanda {
  to {
    stroke-dashoffset: -24;
  }
}

.arvore__bola {
  transform-box: fill-box;
  transform-origin: 50% 0;
  animation: balancar 2.8s ease-in-out infinite;
}

.arvore__bola line {
  stroke: #b8962c;
  stroke-width: 1;
}

@keyframes balancar {
  0%,
  100% {
    transform: rotate(-6deg);
  }
  50% {
    transform: rotate(6deg);
  }
}

.arvore__luz--ouro {
  fill: #ffd86b;
}

.arvore__luz--vermelha {
  fill: #ff5a4f;
}

.arvore__luz--branca {
  fill: #fff8e1;
}

.arvore__luz {
  animation: luz calc(2.2s / var(--natal-luzes-vel, 1)) ease-in-out var(--p, 0s) infinite;
}

@keyframes luz {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

.arvore__estrela {
  cursor: pointer;
  outline: none;
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: estrela 3.6s ease-in-out infinite;
}

.arvore__brilho {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: brilho 2.4s ease-in-out infinite;
}

@keyframes estrela {
  0%,
  100% {
    transform: rotate(-5deg) scale(1);
  }
  50% {
    transform: rotate(5deg) scale(1.05);
  }
}

@keyframes brilho {
  0%,
  100% {
    opacity: 0.5;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

.arvore__estrela--acesa {
  animation: estrela-acesa 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes estrela-acesa {
  30% {
    transform: scale(1.45) rotate(30deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

.arvore__estrela:focus-visible polygon {
  stroke: #fff;
  stroke-width: 2.5;
}

.ent-brilho {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: 50% 50%;
}

.presente {
  cursor: pointer;
  outline: none;
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: pular 3.4s ease-in-out infinite;
}

@keyframes pular {
  0%,
  70%,
  100% {
    transform: translateY(0) scale(1, 1);
  }
  76% {
    transform: translateY(0) scale(1.07, 0.92);
  }
  84% {
    transform: translateY(-6px) scale(0.97, 1.04);
  }
  92% {
    transform: translateY(0) scale(1.03, 0.97);
  }
}

.presente:hover {
  animation-play-state: paused;
}

.presente:focus-visible rect:nth-of-type(1) {
  stroke: #fff;
  stroke-width: 2;
}

.presente__tampa {
  transform-box: fill-box;
  transform-origin: 0% 100%;
  transition: transform 380ms cubic-bezier(0.3, 1.6, 0.5, 1);
}

.presente:hover .presente__tampa {
  transform: translateY(-3px) rotate(-6deg);
}

.presente--aberto .presente__tampa,
.presente--aberto:hover .presente__tampa {
  transform: translateY(-16px) rotate(-28deg);
}

/* ---------- Roteiro da montagem ---------- */
.arvore--espera .ent,
.arvore--espera .arvore__luz {
  opacity: 0;
}

.arvore--espera .arvore__luz {
  animation: none;
}

.ent {
  transform-box: fill-box;
  transform-origin: 50% 100%;
}

.arvore--montando .ent {
  animation-duration: calc(0.8s * var(--t, 1));
  animation-delay: calc(var(--d) * 1s * var(--t, 1));
  animation-fill-mode: both;
}

.arvore--montando .ent-chao {
  animation-name: ent-chao;
  animation-timing-function: ease-out;
}

@keyframes ent-chao {
  from {
    opacity: 0;
    transform: scaleX(0.2);
  }
}

.arvore--montando .ent-tronco {
  animation-name: ent-tronco;
  animation-duration: calc(0.5s * var(--t, 1));
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes ent-tronco {
  from {
    opacity: 0;
    transform: scaleY(0);
  }
}

/* galhos: crescem de baixo para cima, abrindo com um leve balanço */
.arvore--montando .ent-galho {
  animation-name: ent-galho;
  animation-timing-function: cubic-bezier(0.2, 0.75, 0.3, 1);
}

@keyframes ent-galho {
  0% {
    opacity: 0;
    transform: scale(0.25, 0);
  }
  45% {
    opacity: 1;
  }
  65% {
    transform: scale(1.06, 1.08) rotate(-1.2deg);
  }
  82% {
    transform: scale(0.98, 0.97) rotate(0.6deg);
  }
  100% {
    transform: none;
  }
}

.arvore--montando .ent-guirlanda {
  animation-name: ent-surgir;
  animation-duration: calc(0.5s * var(--t, 1));
}

@keyframes ent-surgir {
  from {
    opacity: 0;
  }
}

/* bolas: uma a uma, com elasticidade */
.arvore--montando .ent-bola {
  transform-origin: 50% 50%;
  animation-name: ent-elastico;
  animation-duration: calc(0.65s * var(--t, 1));
  animation-timing-function: ease-out;
}

@keyframes ent-elastico {
  0% {
    opacity: 0;
    transform: scale(0);
  }
  55% {
    opacity: 1;
    transform: scale(1.28);
  }
  75% {
    transform: scale(0.9);
  }
  90% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

/* luzes: acendem em sequência e seguem pulsando */
.arvore--montando .arvore__luz {
  animation: luz-acende calc(0.3s * var(--t, 1)) ease-out calc(var(--d) * 1s * var(--t, 1)) both,
    luz calc(2.2s / var(--natal-luzes-vel, 1)) ease-in-out calc(var(--d) * 1s * var(--t, 1) + 0.3s) infinite;
}

@keyframes luz-acende {
  0% {
    opacity: 0;
  }
  60% {
    opacity: 1;
  }
  100% {
    opacity: 0.85;
  }
}

/* estrela: desce suavemente e se encaixa no topo, com um clarão */
.arvore--montando .ent-estrela {
  transform-origin: 50% 50%;
  animation-name: ent-estrela;
  animation-duration: calc(0.95s * var(--t, 1));
  animation-timing-function: cubic-bezier(0.22, 0.9, 0.3, 1.08);
}

@keyframes ent-estrela {
  0% {
    opacity: 0;
    transform: translateY(-95px) rotate(-90deg) scale(0.5);
  }
  30% {
    opacity: 1;
  }
  100% {
    transform: none;
  }
}

.arvore--montando .ent-brilho {
  animation: ent-clarao calc(1.1s * var(--t, 1)) ease-out calc((var(--d) + 0.75) * 1s * var(--t, 1)) both;
}

@keyframes ent-clarao {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  35% {
    opacity: 1;
    transform: scale(1.4);
  }
  100% {
    opacity: 0;
    transform: scale(1.8);
  }
}

/* presentes: um de cada vez, com escala, elasticidade e giro */
.arvore--montando .ent-presente {
  animation-name: ent-presente;
  animation-duration: calc(0.42s * var(--t, 1));
  animation-timing-function: ease-out;
}

@keyframes ent-presente {
  0% {
    opacity: 0;
    transform: translateY(-18px) scale(0) rotate(-28deg);
  }
  55% {
    opacity: 1;
    transform: translateY(0) scale(1.16) rotate(9deg);
  }
  78% {
    transform: scale(0.94) rotate(-4deg);
  }
  100% {
    transform: none;
  }
}

/* durante a montagem os laços contínuos esperam */
.arvore--montando .arvore__bola,
.arvore--montando .arvore__estrela,
.arvore--montando .presente {
  animation-play-state: paused;
}

/* ---------- Partículas ---------- */
.particula-inicial {
  position: absolute;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: #f3dc8a;
  box-shadow: 0 0 8px 2px rgba(212, 175, 55, 0.75);
  opacity: 0;
  animation: particula-sobe ease-out both;
}

@keyframes particula-sobe {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.4);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(1.1);
  }
}

.brilho-ambiente {
  position: absolute;
  width: 10px;
  height: 10px;
  color: #f3dc8a;
  opacity: 0;
  animation: brilho-ambiente ease-in-out infinite;
}

.brilho-ambiente svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 3px rgba(243, 220, 138, 0.9));
}

@keyframes brilho-ambiente {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.3) rotate(0);
  }
  50% {
    opacity: 1;
    transform: scale(1) rotate(45deg);
  }
}

.particula {
  position: absolute;
  z-index: 3;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 2px;
  pointer-events: none;
  animation: particula 1.1s cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}

.particula--estrela {
  width: 11px;
  height: 11px;
  margin: -5.5px 0 0 -5.5px;
  border-radius: 0;
  -webkit-clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

@keyframes particula {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0) scale(0.4);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), calc(var(--dy) + 40px)) rotate(var(--giro)) scale(1);
  }
}

/* ---------- Surpresas da saúde ---------- */
.surpresa {
  position: absolute;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 0;
  pointer-events: none;
  opacity: 0;
  animation: surpresa 2.2s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

.surpresa__selo {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  margin-top: -15px;
  border-radius: 50%;
  background: #fffdf6;
  color: var(--cor);
  box-shadow: 0 0 0 2px #d4af37, 0 8px 16px -6px rgba(0, 0, 0, 0.55), 0 0 18px rgba(243, 220, 138, 0.55);
}

.surpresa__selo svg {
  width: 17px;
  height: 17px;
}

.surpresa--principal .surpresa__selo {
  width: 38px;
  height: 38px;
  margin-top: -19px;
}

.surpresa--principal .surpresa__selo svg {
  width: 22px;
  height: 22px;
}

.surpresa__nome {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(7, 28, 22, 0.88);
  color: #f8f5e9;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.45);
}

@keyframes surpresa {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.2) rotate(0);
  }
  12% {
    opacity: 1;
  }
  32% {
    transform: translate(var(--dx), var(--dy)) scale(1.12) rotate(var(--giro));
  }
  42% {
    transform: translate(var(--dx), calc(var(--dy) + 4px)) scale(1) rotate(calc(var(--giro) * 0.5));
  }
  78% {
    opacity: 1;
    transform: translate(var(--dx), calc(var(--dy) - 6px)) scale(1) rotate(0);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), calc(var(--dy) - 22px)) scale(0.9) rotate(0);
  }
}

.festas__anuncio {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Botão para reabrir ---------- */
.festas-reabrir {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #165b33, #071c16);
  color: #d4af37;
  box-shadow: 0 10px 24px -10px rgba(4, 17, 13, 0.9), inset 0 0 0 1px rgba(212, 175, 55, 0.4);
  cursor: pointer;
  transition: transform var(--transicao-suave);
}

:root[data-sazonal='natal'] .festas-reabrir:not([hidden]) {
  display: grid;
  place-items: center;
}

.festas-reabrir:hover {
  transform: translateY(-2px) rotate(-6deg);
}

.festas-reabrir svg {
  width: 22px;
  height: 22px;
}

/* fora da tela: laços pausados */
.festas--fora * {
  animation-play-state: paused !important;
}

/* ---------- Telas menores ---------- */
@media (max-width: 899px) {
  :root[data-sazonal='natal'] .festas:not([hidden]) {
    padding: 36px 16px 0;
  }

  .festas__cartao {
    grid-template-columns: 1fr 156px;
    gap: 10px;
    padding: 18px 16px 0 20px;
    min-height: 0;
  }

  .festas__titulo {
    font-size: 25px;
  }

  .festas__cena {
    height: 176px;
  }

  .arvore {
    width: 150px;
    height: 178px;
    margin-left: -75px;
  }

  .festas__caixa {
    min-width: 46px;
  }
}

@media (max-width: 560px) {
  .festas__cartao {
    grid-template-columns: 1fr 112px;
    padding-right: 8px;
  }

  .festas__cena {
    height: 134px;
  }

  .arvore {
    width: 112px;
    height: 134px;
    margin-left: -56px;
  }

  .festas__mensagem {
    display: none;
  }

  .festas__caixa {
    min-width: 40px;
    padding: 6px 4px 5px;
  }

  .festas__caixa strong {
    font-size: 17px;
  }
}
