/* =========================================================
   THE WEDDING POST — Marcos & Nicolle
   Flipbook de jornal (StPageFlip, modo HTML)
   ========================================================= */

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

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

body {
  font-family: "Tinos", "Times New Roman", Times, serif;
  color: #1b1a18;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  /* "Mesa" escura e quente, com vinheta suave */
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255, 244, 222, .10) 0%, rgba(0, 0, 0, 0) 55%),
    radial-gradient(ellipse at 50% 50%, #3a352e 0%, #24211d 60%, #171512 100%);
  background-attachment: fixed;
}

/* ---------- Seção 00 — Abertura (vídeo) ---------- */
.intro {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255, 244, 222, .10) 0%, rgba(0, 0, 0, 0) 55%),
    radial-gradient(ellipse at 50% 50%, #3a352e 0%, #24211d 60%, #171512 100%);
  cursor: pointer;
  touch-action: manipulation;
  opacity: 1;
  transition: opacity .45s ease;
  outline: none;
}

.intro[hidden] { display: none; }
.intro.is-playing { cursor: default; }
.intro.is-leaving { opacity: 0; pointer-events: none; }

.intro-card {
  position: fixed;
  overflow: hidden;
  border-radius: 2px;
  background: #756a36;
  box-shadow:
    0 2px 3px rgba(0, 0, 0, .25),
    0 14px 28px rgba(0, 0, 0, .35),
    0 30px 60px -10px rgba(0, 0, 0, .45);
  /* Fallback antes do JS alinhar exatamente com a capa */
  width: min(94vw, calc(84dvh * 655 / 1024));
  aspect-ratio: 655 / 1024;
  transition: transform .25s ease;
}

.intro:not(.is-playing):active .intro-card {
  transform: scale(.994);
}

.intro-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  background: #756a36;
}

/* ---------- Palco ---------- */
.stage {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding:
    max(10px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right))
    max(6px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));
  touch-action: none;
}

.book-holder {
  position: relative;
  flex: 0 0 auto;
  transition: transform .75s cubic-bezier(.22, .8, .25, 1);
  will-change: transform;
}

.book {
  position: relative;
  margin: 0 auto;
  touch-action: none;
}

/* A lib grava min-width/min-height inline; o tamanho é controlado pelo JS */
.book.stf__parent { min-width: 0 !important; min-height: 0 !important; touch-action: none; }

/* Sombra do jornal sobre a mesa (segue as folhas visíveis) */
.book-shadow {
  position: absolute;
  top: 0;
  height: 100%;
  left: 0;
  width: 100%;
  border-radius: 2px;
  box-shadow:
    0 2px 3px rgba(0, 0, 0, .25),
    0 14px 28px rgba(0, 0, 0, .35),
    0 30px 60px -10px rgba(0, 0, 0, .45);
  transition: left .75s cubic-bezier(.22, .8, .25, 1), width .75s cubic-bezier(.22, .8, .25, 1);
  pointer-events: none;
}

/* ---------- Páginas ---------- */
.page { background-color: #e7e6e2; overflow: hidden; }
.sheet { position: absolute; inset: 0; background-color: var(--paper, #e7e6e2); overflow: hidden; }

.page .frame {
  position: absolute;
  overflow: hidden;
}

/* Proporção da página do livro: 580 x 1000 (0.58).
   Imagens 552x1024 (0.539) -> altura total, centradas na largura.
   Imagens 655x1024 (0.640) -> largura total, centradas na altura.
   Nunca há corte nem deformação; a sobra usa a mesma cor do papel. */
.frame--narrow { top: 0; height: 100%; width: 92.942%; left: 3.529%; }
.frame--wide   { left: 0; width: 100%; height: 90.676%; top: 4.662%; }

.page img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

/* Textura de papel fosco + luz de leitura (muito sutil) */
.sheet::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: .5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .42 0 0 0 0 .38 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Iluminação e leve curvatura das bordas */
.sheet::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    linear-gradient(to right, rgba(0,0,0,.07) 0%, rgba(0,0,0,0) 3.5%, rgba(0,0,0,0) 96.5%, rgba(0,0,0,.05) 100%),
    linear-gradient(to bottom, rgba(255,255,255,.05) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,.03) 100%);
}

/* Modo duas páginas: dobra central (lombada) */
.is-landscape .page.--left .sheet::after {
  background:
    linear-gradient(to left, rgba(0,0,0,.20) 0%, rgba(0,0,0,.07) 2.5%, rgba(0,0,0,0) 9%),
    linear-gradient(to right, rgba(0,0,0,.05) 0%, rgba(0,0,0,0) 3%);
}
.is-landscape .page.--right .sheet::after {
  background:
    linear-gradient(to right, rgba(0,0,0,.20) 0%, rgba(0,0,0,.07) 2.5%, rgba(0,0,0,0) 9%),
    linear-gradient(to left, rgba(0,0,0,.05) 0%, rgba(0,0,0,0) 3%);
}
/* Capa e contracapa isoladas não têm lombada */
.is-landscape .page.is-cover.--right .sheet::after,
.is-landscape .page.is-back.--left .sheet::after {
  background: linear-gradient(to right, rgba(0,0,0,.06) 0%, rgba(0,0,0,0) 3%, rgba(0,0,0,0) 97%, rgba(0,0,0,.06) 100%);
}

/* ---------- Áreas clicáveis (transparentes) ---------- */
.hotspot {
  position: absolute;
  z-index: 5;
  display: block;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .2s ease, box-shadow .2s ease;
}
.hotspot:focus-visible { box-shadow: 0 0 0 2px rgba(80, 90, 50, .65); }
@media (hover: hover) {
  .hotspot:hover { background: rgba(255, 255, 255, .08); box-shadow: 0 0 0 1px rgba(60, 60, 40, .18); }
}
.hotspot:active { background: rgba(0, 0, 0, .06); }
.debug .hotspot { background: rgba(255, 0, 0, .25); box-shadow: 0 0 0 1px red; }
.debug .cd { background: rgba(255, 220, 0, .35); }

/* ---------- Contagem regressiva ao vivo (sobre os números estáticos) ---------- */
.countdown { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.cd {
  position: absolute;
  top: 17.2%;
  height: 4.5%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e8e7e3;
  color: #121110;
  font-family: "Tinos", "Times New Roman", Times, serif;
  font-weight: 400;
  font-size: calc(var(--fh, 600px) * .0500);
  letter-spacing: -.035em;
  -webkit-text-stroke: .014em currentColor;
  line-height: 1;
  font-variant-numeric: lining-nums;
  white-space: nowrap;
}

/* ---------- Botão flutuante da música ---------- */
.music-fab {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(232, 226, 214, .3);
  background: rgba(20, 18, 15, .55);
  color: #e8e2d6;
  cursor: pointer;
  display: grid;
  place-items: center;
  z-index: 20;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.music-fab[hidden] { display: none; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 14px; }
.bars i { width: 3px; height: 100%; background: currentColor; border-radius: 1px; transform-origin: bottom; animation: eq 1s ease-in-out infinite; }
.bars i:nth-child(2) { animation-delay: -.35s; }
.bars i:nth-child(3) { animation-delay: -.7s; }
.music-fab.is-paused .bars i { animation: none; transform: scaleY(.3); }
@keyframes eq { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }

/* ---------- Aviso discreto ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 16px);
  transform: translate(-50%, 10px);
  background: rgba(20, 18, 15, .88);
  color: #efe9dd;
  font-size: 15px;
  font-style: italic;
  letter-spacing: .02em;
  padding: 9px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
  z-index: 30;
  white-space: nowrap;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .book-holder, .book-shadow, .intro, .intro-card { transition: none; }
  .bars i { animation: none; }
}
