/* ============================================
   Samuel 1 ano — Convite interativo
   Ajuste de áreas clicáveis: seção HIT AREAS
   ============================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  /* Altura real do Android (setada via JS em --app-h) */
  height: var(--app-h, 100dvh);
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #eaf6fb;
  color: #2a4a5a;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}

/* ---------- Layout ---------- */

.page {
  width: 100%;
  height: var(--app-h, 100dvh);
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.invite {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.video-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 430px;
  margin: 0 auto;
  background: #eaf6fb;
  overflow: hidden;
  border-radius: 0;
  user-select: none;
  -webkit-user-select: none;
}

@media (min-width: 480px) {
  .page {
    padding: 12px 0;
    align-items: center;
  }

  .invite {
    height: auto;
    max-height: calc(var(--app-h, 100dvh) - 24px);
    align-items: center;
  }

  .video-wrap {
    width: min(430px, calc((var(--app-h, 100dvh) - 24px) * 2160 / 3790));
    height: auto;
    max-height: calc(var(--app-h, 100dvh) - 24px);
    aspect-ratio: 2160 / 3790;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(40, 90, 120, 0.12);
  }
}

.invite-video {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  background: #eaf6fb;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  transition: opacity 0.32s ease;
}

.video-wrap.is-loop-fading .invite-video {
  opacity: 0;
}

.video-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  background: #eaf6fb;
}

/* Flash azul-claro no reinício do loop (esconde o “pulo” do vídeo) */
.loop-flash {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    #f4fbff 0%,
    #e8f4fa 45%,
    #dff0f8 100%
  );
  opacity: 0;
  transition: opacity 0.32s ease;
}

.video-wrap.is-loop-fading .loop-flash {
  opacity: 1;
}

/* ---------- Loading ---------- */

.loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e8f4fa;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.loading.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #7eb8d4;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .loading__dot {
    animation: none;
    opacity: 0.7;
  }

  .loading,
  .modal,
  .modal__panel,
  .invite-video,
  .loop-flash {
    transition: none !important;
  }
}

/* ============================================
   HIT AREAS — posições em % do container do vídeo
   Ajuste left/top/width/height conforme a arte.
   ============================================ */

.hit {
  position: absolute;
  z-index: 5;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  /* debug: descomente para ver as áreas
  outline: 1px dashed rgba(255, 0, 0, 0.5);
  background: rgba(255, 0, 0, 0.12);
  */
}

.hit:focus {
  outline: none;
}

.hit:focus-visible {
  outline: 2px solid rgba(60, 140, 180, 0.7);
  outline-offset: 2px;
}

.hit[hidden],
.hit:disabled {
  pointer-events: none;
  cursor: default;
}

/*
  Envelope (estado fechado) — cobre o quadrado inteiro do envelope,
  não só o selo. Ajuste left/top/width/height se a arte mudar.
*/
.hit--envelope {
  left: 10%;
  top: 30%;
  width: 80%;
  height: 40%;
  min-height: 44px;
}

/* Botões do convite aberto (ícones + rótulos) */
.hit--localizacao {
  left: 12%;
  top: 53%;
  width: 24%;
  height: 15%;
  min-height: 44px;
}

.hit--presente {
  left: 38%;
  top: 53%;
  width: 24%;
  height: 15%;
  min-height: 44px;
}

.hit--confirmar {
  left: 64%;
  top: 53%;
  width: 24%;
  height: 15%;
  min-height: 44px;
}

/* ---------- Botão de música ---------- */
/* Canto superior direito — longe do envelope e dos botões */

.music-btn {
  position: absolute;
  z-index: 20;
  top: max(10px, env(safe-area-inset-top, 10px));
  right: max(10px, env(safe-area-inset-right, 10px));
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
  color: #3a6a80;
  box-shadow: 0 2px 8px rgba(40, 90, 120, 0.12);
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.music-btn:hover {
  background: rgba(255, 255, 255, 0.92);
}

.music-btn:active {
  transform: scale(0.94);
}

.music-btn:focus {
  outline: none;
}

.music-btn:focus-visible {
  outline: 2px solid rgba(60, 140, 180, 0.7);
  outline-offset: 2px;
}

/* Ícones empilhados — transição entre mudo e som */
.music-btn__stack {
  position: relative;
  width: 22px;
  height: 22px;
  display: block;
}

.music-btn__icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  transition:
    opacity 0.28s ease,
    transform 0.32s cubic-bezier(0.34, 1.4, 0.64, 1);
  will-change: opacity, transform;
}

/* Estado mudo (padrão): mostra X, esconde ondas */
.music-btn.is-muted .music-btn__icon--off {
  opacity: 1;
  transform: scale(1) rotate(0deg);
  pointer-events: none;
}

.music-btn.is-muted .music-btn__icon--on {
  opacity: 0;
  transform: scale(0.55) rotate(-20deg);
  pointer-events: none;
}

/* Estado com som: mostra ondas, esconde X */
.music-btn.is-on .music-btn__icon--on {
  opacity: 1;
  transform: scale(1) rotate(0deg);
  pointer-events: none;
}

.music-btn.is-on .music-btn__icon--off {
  opacity: 0;
  transform: scale(0.55) rotate(20deg);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .music-btn__icon {
    transition: opacity 0.15s ease;
  }

  .music-btn.is-muted .music-btn__icon--on,
  .music-btn.is-on .music-btn__icon--off {
    transform: none;
  }
}

/* ---------- Modais ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal.is-open {
  opacity: 1;
  visibility: visible;
}

.modal[hidden] {
  display: none;
}

.modal.is-open[hidden] {
  display: flex;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 45, 60, 0.45);
  cursor: pointer;
}

.modal__panel {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(20, 45, 60, 0.18);
  max-height: min(90dvh, 90vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.25s ease;
}

.modal.is-open .modal__panel {
  transform: translateY(0) scale(1);
}

.modal__panel--small {
  width: min(100%, 320px);
  padding: 28px 24px 24px;
  text-align: center;
}

.modal__panel--image {
  width: min(100%, 360px);
  padding: 40px 12px 12px;
  background: #f7fbfd;
}

/* ---------- Tela cheia (sugestão de presente) ---------- */
/* Direto no body + altura real do Android (--app-h) */

.app-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  width: 100%;
  height: var(--app-h, 100dvh);
  z-index: 200;
  margin: 0;
  padding: 0;
  background: #eaf6fb;
  display: block;
  overflow: hidden;
  transform: translate3d(100%, 0, 0);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.25s ease,
    visibility 0.35s;
}

.app-screen.is-open {
  transform: translate3d(0, 0, 0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.app-screen[hidden] {
  display: none !important;
}

.app-screen.is-open[hidden] {
  display: block !important;
}

/*
  fill = estica e cobre 100% sem faixa preta/branca
  (no Android o contain/cover às vezes deixa vão)
*/
.app-screen__media {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  object-fit: fill;
  object-position: center center;
  background: #eaf6fb;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
  border: 0;
  outline: 0;
}

/* Esconde qualquer resquício de controles nativos */
.app-screen__media::-webkit-media-controls {
  display: none !important;
}

.app-screen__media::-webkit-media-controls-enclosure {
  display: none !important;
}

.app-screen__back {
  position: absolute;
  z-index: 26;
  top: max(10px, env(safe-area-inset-top, 10px));
  left: max(10px, env(safe-area-inset-left, 10px));
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  color: #3a6a80;
  font-size: 1.35rem;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(40, 90, 120, 0.12);
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.2s ease, transform 0.15s ease;
}

.app-screen__back:hover {
  background: rgba(255, 255, 255, 0.95);
}

.app-screen__back:active {
  transform: scale(0.94);
}

.app-screen__back:focus {
  outline: none;
}

.app-screen__back:focus-visible {
  outline: 2px solid rgba(60, 140, 180, 0.7);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .app-screen {
    transition: opacity 0.15s ease, visibility 0.15s;
    transform: none;
  }

  .app-screen.is-open {
    transform: none;
  }
}

.modal__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #5a7a8a;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.modal__close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #2a4a5a;
}

.modal__close:focus {
  outline: none;
}

.modal__close:focus-visible {
  outline: 2px solid rgba(60, 140, 180, 0.7);
  outline-offset: 2px;
}

.modal__title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #2a4a5a;
  margin-bottom: 12px;
}

.modal__address {
  font-size: 0.95rem;
  line-height: 1.45;
  color: #3a5a6a;
  margin-bottom: 20px;
  white-space: pre-line;
}

.modal__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 22px;
  border-radius: 999px;
  background: #4a9bc7;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.modal__btn:hover {
  background: #3d8ab5;
}

.modal__btn:focus {
  outline: none;
}

.modal__btn:focus-visible {
  outline: 2px solid rgba(60, 140, 180, 0.9);
  outline-offset: 3px;
}

.modal__image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  object-fit: contain;
  -webkit-user-drag: none;
  user-select: none;
}

/* Bloqueia scroll do body quando modal aberto */
body.modal-open {
  overflow: hidden;
}
