:root {
  --noite: #24160e;
  --cacau: #3b2618;
  --creme: #f6ecdb;
  --areia: #e8d6b6;
  --dourado: #d0a566;
  --dourado-claro: #e7c98f;
  --terracota: #b8694a;
  --serif: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: "Avenir Next", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--noite);
  color: var(--creme);
  font-family: var(--serif);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--dourado-claro); outline-offset: 3px; }

/* ---------- Palco e cenas ---------- */
.stage { position: fixed; inset: 0; }
.scene {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  opacity: 0;
  animation: sceneIn 1.1s var(--ease) forwards;
}
.scene.leave { animation: sceneOut .7s var(--ease) forwards; pointer-events: none; }
@keyframes sceneIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes sceneOut { from { opacity: 1; } to { opacity: 0; } }

.backdrop {
  position: absolute; inset: -6%;
  background-size: cover; background-position: center;
  filter: blur(34px) brightness(.5) saturate(1.1);
}
.veil {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 20% 15%, rgba(231,201,143,.16), transparent 55%),
    radial-gradient(ellipse at 85% 90%, rgba(184,105,74,.18), transparent 55%),
    linear-gradient(180deg, rgba(36,22,14,.25), rgba(36,22,14,.55));
}

/* Foto vertical */
.photo {
  position: relative; z-index: 2;
  height: min(88vh, calc(46vw / var(--ar)));
  aspect-ratio: var(--ar);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(231,201,143,.45), 0 30px 70px rgba(0,0,0,.55), 0 0 90px rgba(208,165,102,.14);
}
.photo img {
  width: 100%; height: 100%; display: block;
  object-fit: cover; object-position: var(--pos, 50% 50%);
  animation: drift 14s ease-out forwards;
}
.photo.zoom img { transform: scale(1.35); transform-origin: var(--pos, 50% 50%); animation: none; }
.photo::after { /* luz dourada sobre a foto */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(135deg, rgba(231,201,143,.16), transparent 40%, rgba(184,105,74,.12));
  mix-blend-mode: soft-light;
}
@keyframes drift { from { transform: scale(1.06); } to { transform: scale(1); } }

.copy {
  position: relative; z-index: 3;
  width: min(36vw, 36rem);
}
.layout-left  { gap: 7vw; padding: 0 7vw; }
.layout-right { gap: 7vw; padding: 0 7vw; flex-direction: row-reverse; }

.phrase {
  font-size: clamp(1.35rem, 2.15vw, 2.3rem);
  line-height: 1.5;
  font-weight: 400;
  color: var(--creme);
  text-wrap: pretty;
  text-shadow: 0 2px 24px rgba(0,0,0,.5);
}
.word {
  display: inline-block; white-space: pre;
  opacity: 0; transform: translateY(.4em);
  animation: wordIn .9s var(--ease) forwards;
  animation-delay: calc(var(--i) * 55ms + .5s);
}
@keyframes wordIn { to { opacity: 1; transform: none; } }

.rule { /* filete dourado que se desenha depois das palavras */
  display: block; height: 1px; width: 4.5rem; margin-top: 1.8rem;
  background: linear-gradient(90deg, var(--dourado), transparent);
  transform-origin: left; transform: scaleX(0);
  animation: rule 1.2s var(--ease) forwards;
  animation-delay: var(--rule-delay, 2s);
}
@keyframes rule { to { transform: scaleX(1); } }

/* Foto em tela cheia */
.layout-wide .full, .layout-wide-right .full {
  position: absolute; inset: 0; z-index: 1;
}
.full img {
  width: 100%; height: 100%; object-fit: cover; object-position: var(--pos, 50% 50%);
  animation: drift 16s ease-out forwards;
}
.full::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 45%, rgba(36,22,14,.78) 100%);
}
.layout-wide { align-items: flex-end; }
.layout-wide .copy {
  width: min(70vw, 62rem); margin-bottom: 9vh; text-align: center;
  padding: 1.6rem 2.4rem;
  background: rgba(36,22,14,.42);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 8px;
  border: 1px solid rgba(231,201,143,.28);
}
.layout-wide .rule { margin-inline: auto; background: linear-gradient(90deg, transparent, var(--dourado), transparent); }
.layout-wide-right { justify-content: flex-end; padding: 0 6vw; }
.layout-wide-right .full {
  right: auto; width: 70vw;
  -webkit-mask-image: linear-gradient(90deg, #000 82%, transparent);
          mask-image: linear-gradient(90deg, #000 82%, transparent);
}
.layout-wide-right .full::after { background: linear-gradient(180deg, transparent 65%, rgba(36,22,14,.45) 100%); }
.layout-wide-right .copy { width: min(25vw, 28rem); margin-right: 1vw; }

/* Colagem de fotografias */
.collage {
  position: relative; z-index: 2;
  width: min(44vw, 54vh * 1.5 + 8vw); height: 80vh;
}
.collage figure {
  position: absolute; width: 38%; background: var(--creme); padding: 1.1% 1.1% 4.5%;
  box-shadow: 0 20px 45px rgba(0,0,0,.5);
  opacity: 0; animation: pop 1s var(--ease) forwards;
}
.collage figure img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; }
.collage figure:nth-child(1) { left: 4%;  top: 4%;  transform: rotate(-4deg); animation-delay: .3s; }
.collage figure:nth-child(2) { left: 50%; top: 0;   transform: rotate(3deg);  animation-delay: .7s; }
.collage figure:nth-child(3) { left: 8%;  top: 47%; transform: rotate(2.5deg);animation-delay: 1.1s; }
.collage figure:nth-child(4) { left: 52%; top: 46%; transform: rotate(-3deg); animation-delay: 1.5s; width: 42%; }
.collage figure:nth-child(4) img { aspect-ratio: 16 / 10; }
@keyframes pop { from { opacity: 0; translate: 0 18px; } to { opacity: 1; translate: 0 0; } }

/* ---------- Abertura ---------- */
.opening .full { position: absolute; inset: 0; }
.opening .full::after {
  background:
    radial-gradient(ellipse at 50% 100%, rgba(36,22,14,.85), transparent 60%),
    linear-gradient(180deg, rgba(36,22,14,.15), rgba(36,22,14,.35));
}
.opening { align-items: flex-end; }
.opening .box {
  position: relative; z-index: 3; text-align: center;
  padding-bottom: 8vh; max-width: 44rem; margin-inline: 1.5rem;
  animation: boxIn 2s var(--ease) .6s both;
}
@keyframes boxIn { from { opacity: 0; translate: 0 20px; } to { opacity: 1; translate: 0 0; } }
.opening h1 {
  font-size: clamp(2.4rem, 5.2vw, 5rem); font-weight: 500; letter-spacing: .01em;
  text-shadow: 0 3px 30px rgba(0,0,0,.6);
}
.opening p {
  margin: .8rem 0 2rem; font-size: clamp(1.15rem, 1.8vw, 1.7rem); font-style: italic;
  color: var(--areia); text-shadow: 0 2px 20px rgba(0,0,0,.6);
}
.btn-start {
  font-family: var(--sans); font-size: .95rem; letter-spacing: .08em;
  padding: .95rem 2.6rem; border-radius: 999px;
  color: var(--noite); background: linear-gradient(135deg, var(--dourado-claro), var(--dourado));
  box-shadow: 0 10px 40px rgba(208,165,102,.35);
  transition: transform .4s var(--ease), box-shadow .4s var(--ease);
}
.btn-start:hover { transform: translateY(-2px); box-shadow: 0 14px 50px rgba(208,165,102,.5); }

/* ---------- Pausas ---------- */
.pause .backdrop { filter: blur(5px) brightness(.5) saturate(1.1); inset: -2%; }
.pause .veil { background: radial-gradient(ellipse at center, rgba(36,22,14,.35), rgba(36,22,14,.75)); }
.pause .center {
  position: relative; z-index: 3; text-align: center;
  max-width: 52rem; padding: 0 2rem;
}
.pause .phase {
  font-size: clamp(1rem, 1.4vw, 1.4rem); font-style: italic; color: var(--dourado-claro);
  margin-bottom: 1.4rem; letter-spacing: .04em;
  opacity: 0; animation: wordIn 1.2s var(--ease) .2s forwards;
}
.pause .phrase { font-size: clamp(1.7rem, 3.4vw, 3.4rem); font-style: italic; line-height: 1.4; }
.pause .rule { margin-inline: auto; background: linear-gradient(90deg, transparent, var(--dourado), transparent); }

/* ---------- Carta ---------- */
.letter-wrap { position: relative; z-index: 3; display: flex; align-items: center; gap: 5vw; padding: 0 6vw; width: 100%; justify-content: center; }
.letter-wrap .photo { height: min(82vh, calc(34vw / var(--ar))); min-height: 14rem; }
.paper {
  width: min(48vw, 46rem); max-height: 82vh; overflow-y: auto;
  padding: 3rem 3.2rem;
  color: var(--cacau);
  background:
    radial-gradient(ellipse at top left, rgba(255,255,255,.55), transparent 60%),
    linear-gradient(180deg, #f8efdf, #ecdcbc);
  border-radius: 4px;
  box-shadow: 0 30px 80px rgba(0,0,0,.55), inset 0 0 60px rgba(184,105,74,.12);
  scrollbar-width: thin; scrollbar-color: var(--dourado) transparent;
}
.paper p { font-size: clamp(1.05rem, 1.35vw, 1.4rem); line-height: 1.7; margin-bottom: 1.15em; }
.paper p:first-child { font-size: 1.5em; }
.paper strong { font-weight: 600; color: #7a3d24; }
.paper p { opacity: 0; animation: wordIn 1.2s var(--ease) forwards; animation-delay: calc(var(--i) * 450ms + .6s); }

/* ---------- Final ---------- */
.final .center { position: relative; z-index: 3; text-align: center; max-width: 52rem; padding: 0 2rem; }
.final .phrase { font-size: clamp(1.8rem, 3.6vw, 3.6rem); font-style: italic; line-height: 1.4; }
.final .photo { height: min(46vh, calc(34vw / var(--ar))); margin: 0 auto 2.5rem; }
.btn-replay {
  margin-top: 2.4rem; font-family: var(--sans); font-size: .9rem; letter-spacing: .08em;
  padding: .8rem 2rem; border-radius: 999px;
  border: 1px solid rgba(231,201,143,.6); color: var(--dourado-claro);
  transition: background .4s var(--ease), color .4s var(--ease);
  opacity: 0; animation: wordIn 1.2s var(--ease) 5s forwards;
}
.btn-replay:hover { background: var(--dourado); color: var(--noite); }

/* ---------- Controles ---------- */
.controls {
  position: fixed; z-index: 20; bottom: 2.4vh; left: 50%; translate: -50% 0;
  display: flex; align-items: center; gap: 1rem;
  padding: .3rem .5rem; border-radius: 999px;
  background: rgba(36,22,14,.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(231,201,143,.25);
}
.controls[hidden], .progress[hidden], .music[hidden] { display: none; }
.nav-btn { width: 2.6rem; height: 2.6rem; border-radius: 50%; display: grid; place-items: center; color: var(--dourado-claro); transition: background .3s; }
.nav-btn:hover:not(:disabled) { background: rgba(231,201,143,.18); }
.nav-btn:disabled { opacity: .3; cursor: default; }
.counter { font-family: var(--sans); font-size: .8rem; letter-spacing: .06em; color: var(--areia); min-width: 4.6rem; text-align: center; }

.progress { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(231,201,143,.12); }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--terracota), var(--dourado-claro)); transition: width .9s var(--ease); }

.music {
  position: fixed; z-index: 20; top: 2.4vh; right: 2vw;
  display: flex; align-items: center; gap: .5rem;
  padding: .25rem .8rem .25rem .3rem; border-radius: 999px;
  background: rgba(36,22,14,.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(231,201,143,.25);
}
.music-btn { width: 2.3rem; height: 2.3rem; border-radius: 50%; display: grid; place-items: center; color: var(--dourado-claro); }
.music-btn:hover { background: rgba(231,201,143,.18); }
.volume { width: 5.5rem; accent-color: var(--dourado); cursor: pointer; }

/* ---------- Textura de filme e poeira de luz ---------- */
.grain {
  position: fixed; inset: 0; z-index: 10; pointer-events: none; opacity: .09; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
.dust { position: fixed; inset: 0; z-index: 9; pointer-events: none; overflow: hidden; }
.dust i {
  position: absolute; bottom: -10px; width: 3px; height: 3px; border-radius: 50%;
  background: var(--dourado-claro); opacity: 0; filter: blur(.5px);
  animation: rise linear infinite;
}
@keyframes rise {
  0% { transform: translateY(0); opacity: 0; }
  15% { opacity: .55; }
  100% { transform: translateY(-105vh) translateX(30px); opacity: 0; }
}

/* ---------- Celulares e tablets ---------- */
@media (max-width: 860px), (max-aspect-ratio: 1/1) {
  .scene { align-items: flex-start; }
  .layout-left, .layout-right { flex-direction: column; justify-content: flex-start; gap: 1.6rem; padding: 4.5rem 1.4rem 6rem; align-items: center; }
  .photo { height: min(44vh, calc(86vw / var(--ar))); }
  .copy { width: 100%; max-width: 34rem; overflow-y: auto; max-height: 38vh; }
  .phrase { font-size: clamp(1.1rem, 4.6vw, 1.5rem); }

  .layout-wide { align-items: flex-end; }
  .layout-wide .copy { width: calc(100% - 2rem); margin-bottom: 6rem; padding: 1.1rem 1.2rem; max-height: 44vh; }
  .layout-wide .full, .layout-wide-right .full { bottom: auto; height: 38vh; top: 4.2rem; }
  .layout-wide .full img, .layout-wide-right .full img { object-fit: contain; border-radius: 6px; }
  .layout-wide .full::after, .layout-wide-right .full::after { display: none; }
  .scene.pause { align-items: center; }
  .pause .center { padding: 4rem 1.5rem; }
  .layout-wide-right { justify-content: center; align-items: flex-end; padding: 0 1rem; }
  .layout-wide-right .copy { width: 100%; margin-bottom: 6rem; padding: 1.1rem 1.2rem; background: rgba(36,22,14,.55); border-radius: 8px; max-height: 44vh; }
  .layout-wide-right .full { width: 100%; -webkit-mask-image: none; mask-image: none; }

  .collage { width: 92vw; height: 46vh; margin-top: 0; }
  .scene.collage-scene { flex-direction: column; }

  .letter-wrap { flex-direction: column; padding: 4.2rem 1rem 5rem; gap: 1rem; height: 100%; }
  .letter-wrap .photo { display: none; }
  .paper { width: 100%; max-height: 100%; padding: 1.8rem 1.4rem; }
  .paper p { font-size: 1.05rem; }

  .final .photo { height: 32vh; }
  .music { top: .8rem; right: .8rem; }
  .volume { width: 4rem; }
  .controls { bottom: 1rem; }
}

/* ---------- Movimento reduzido ---------- */
@media (prefers-reduced-motion: reduce) {
  .scene, .scene.leave { animation-duration: .01s; }
  .photo img, .full img { animation: none; }
  .word, .rule, .paper p, .collage figure, .pause .phase, .opening .box, .btn-replay {
    animation: none; opacity: 1; transform: none; translate: none;
  }
  .rule { transform: none; }
  .collage figure:nth-child(1) { transform: rotate(-4deg); }
  .collage figure:nth-child(2) { transform: rotate(3deg); }
  .collage figure:nth-child(3) { transform: rotate(2.5deg); }
  .collage figure:nth-child(4) { transform: rotate(-3deg); }
  .dust { display: none; }
  .progress span { transition: none; }
}

[hidden] { display: none !important; }
