/* Manual resumido de marca CUC
Rojo #A3161A · Amarillo #FCD116 · Dorado #C9A227 · Verde #078930 · Gris #595959
*/
:root {
  --cuc-red: #A3161A;
  --cuc-red-deep: #841014;
  --cuc-red-light: #bf252a;
  --cuc-yellow: #FCD116;
  --cuc-gold: #C9A227;
  --cuc-green: #078930;
  --cuc-gray: #595959;
  --cuc-gray-mid: #A5A5A5;
  --cuc-gray-light: #CCCCCC;
  --paper: #fffdf8;
  --bg: #f5f5f4;
  --white: #ffffff;
  --shadow-soft: 0 18px 45px rgba(89, 89, 89, 0.12);
  --shadow-envelope: 0 22px 40px rgba(89, 89, 89, 0.18);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  overflow-y: auto;
}

body {
  font-family: "Red Hat Display", system-ui, sans-serif;
  background:
    radial-gradient(circle at 15% 20%, rgba(252, 209, 22, 0.16), transparent 22%),
    radial-gradient(circle at 85% 85%, rgba(163, 22, 26, 0.1), transparent 24%),
    linear-gradient(180deg, #fbfbfb 0%, #f2f2f2 100%);
  color: var(--cuc-gray);
  overflow-x: hidden;
}

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

.scene {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 460px) minmax(320px, 520px);
  gap: clamp(72px, 8vw, 120px);
  align-items: center;
  justify-content: center;
  padding: 32px 32px 48px;
  position: relative;
  z-index: 2;
}

.intro-kicker {
  margin: 0 0 14px;
  color: var(--cuc-gray-mid);
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-weight: 800;
  font-size: 0.82rem;
}

.intro h1 {
  margin: 0;
  color: var(--cuc-red);
  font-size: clamp(2.4rem, 3.7vw, 4.1rem);
  line-height: 0.96;
  letter-spacing: -0.04em;
}

.intro-text {
  margin: 22px 0 0;
  max-width: 34rem;
  font-size: 1.1rem;
  line-height: 1.85;
}

.experience {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-height: 0;
}

.envelope-stage {
  position: relative;
  width: min(100%, 520px);
  height: clamp(420px, 72vh, 650px);
  perspective: 1800px;
  transform-style: preserve-3d;
  transition: width 600ms ease, height 600ms ease;
  min-height: 0;
}

.envelope-stage:not(.is-open) {
  cursor: pointer;
}

.shadow-base {
  position: absolute;
  left: 50%;
  bottom: 12px;
  width: 74%;
  height: 36px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(89,89,89,0.28) 0%, rgba(89,89,89,0.05) 65%, rgba(89,89,89,0) 100%);
  filter: blur(8px);
  transition: transform 700ms ease, opacity 700ms ease;
  will-change: transform, opacity;
}

.letter {
  position: absolute;
  left: 50%;
  bottom: 78px;
  width: 78%;
  height: 50%;
  transform: translateX(-50%) translateY(40px) scale(0.94);
  background: linear-gradient(180deg, #fffefb 0%, #fffaf0 100%);
  border-radius: 18px;
  box-shadow: 0 26px 40px rgba(89, 89, 89, 0.16);
  border: 1px solid rgba(201, 162, 39, 0.18);
  overflow: hidden;
  opacity: 0;
  transition:
    width 900ms cubic-bezier(.2,.8,.18,1),
    height 900ms cubic-bezier(.2,.8,.18,1),
    bottom 900ms cubic-bezier(.2,.8,.18,1),
    transform 900ms cubic-bezier(.2,.8,.18,1),
    box-shadow 800ms ease,
    opacity 500ms ease,
    z-index 0ms linear 250ms;
  z-index: 1;
  will-change: transform, width, height, opacity;
  min-height: 0;
}

.letter-topbar {
  height: 8px;
  background: linear-gradient(90deg, var(--cuc-red), var(--cuc-gold), var(--cuc-yellow));
  cursor: pointer;
}

.letter-body {
  height: calc(100% - 8px);
  max-height: calc(100% - 8px);
  min-height: 0;
  padding: clamp(20px, 4.5vw, 34px) clamp(20px, 5vw, 42px) clamp(22px, 4.5vw, 36px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(163, 22, 26, 0.45) rgba(0, 0, 0, 0.06);
}

.letter-body::-webkit-scrollbar {
  width: 8px;
}

.letter-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 999px;
}

.letter-body::-webkit-scrollbar-thumb {
  background: rgba(163, 22, 26, 0.42);
  border-radius: 999px;
}

.letter-body::-webkit-scrollbar-thumb:hover {
  background: rgba(163, 22, 26, 0.58);
}

.letter-logo {
  width: clamp(136px, 34%, 190px);
  height: auto;
  object-fit: contain;
  margin-top: 4px;
}

.letter-kicker {
  margin: clamp(14px, 3vh, 24px) 0 8px;
  font-size: 0.75rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--cuc-gray-mid);
  font-weight: 800;
}

.letter h2 {
  margin: 2px 0 clamp(10px, 2vh, 16px);
  color: var(--cuc-red);
  font-size: clamp(2rem, 4vw, 3.15rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.letter-message {
  margin: 0;
  font-size: clamp(1rem, 1.55vw, 1.24rem);
  line-height: 1.75;
  color: var(--cuc-gray);
}

.divider {
  width: 72px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cuc-yellow), var(--cuc-gold));
  margin: 18px 0 16px;
}

.video-invite {
  position: relative;
  width: min(100%, 220px);
  display: block;
  margin: 0 0 12px;
  padding: 7px;
  border: 1px solid rgba(201, 162, 39, 0.3);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96) 0%, rgba(252, 248, 237, 0.96) 100%);
  box-shadow: 0 14px 28px rgba(89, 89, 89, 0.1);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.video-invite:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 32px rgba(89, 89, 89, 0.14);
  border-color: rgba(163, 22, 26, 0.26);
}

.video-invite-preview {
  width: 100%;
  aspect-ratio: 16 / 8.5;
  display: block;
  border-radius: 12px;
  background: linear-gradient(135deg, #d9d9d9 0%, #f3f3f3 100%);
  object-fit: cover;
}

.video-play-badge {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(163, 22, 26, 0.92);
  color: var(--white);
  font-size: 0.78rem;
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(163, 22, 26, 0.24);
  pointer-events: none;
}

.letter-closing {
  margin: 0;
  font-size: clamp(0.92rem, 1.25vw, 1.02rem);
  line-height: 1.55;
  color: var(--cuc-gray);
}

.signature-block {
  margin-top: auto;
  padding-top: 10px;
  width: 100%;
}

.signature-line {
  width: 120px;
  height: 2px;
  background: rgba(89,89,89,0.26);
  margin: 0 auto 7px;
}

.signature {
  margin: 0;
  font-family: "Great Vibes", cursive;
  font-size: clamp(1.85rem, 3.6vw, 2.45rem);
  color: var(--cuc-red);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 600ms ease 350ms, transform 600ms ease 350ms;
}

.signature-role {
  margin: 0;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--cuc-gray-mid);
  font-weight: 700;
}

.envelope-back,
.envelope-front {
  position: absolute;
  left: 50%;
  bottom: 34px;
  width: 100%;
  height: min(315px, 50%);
  transform: translateX(-50%);
  border-radius: 0 0 28px 28px;
}

.envelope-back {
  background:
    linear-gradient(180deg, var(--cuc-red-light) 0%, var(--cuc-red) 100%);
  box-shadow: var(--shadow-envelope);
  z-index: 0;
}

.flap-button {
  position: absolute;
  left: 50%;
  top: calc(100% - 34px - min(315px, 50%));
  width: 100%;
  height: min(210px, 34%);
  transform: translateX(-50%);
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  z-index: 6;
  perspective: 1400px;
  transition: transform 850ms cubic-bezier(.2,.8,.18,1), opacity 550ms ease;
  will-change: transform, opacity;
}

.flap-button::after {
  content: "Abrir";
  position: absolute;
  left: 50%;
  bottom: 24%;
  transform: translateX(-50%);
  min-width: 74px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.92);
  color: var(--cuc-red);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 8px 18px rgba(0,0,0,0.14);
  animation: cuePulse 1500ms ease-in-out infinite;
  z-index: 8;
}

.flap {
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 50% 100%, 100% 0);
  transition: transform 850ms cubic-bezier(.2,.8,.18,1), filter 800ms ease;
  transform-origin: top center;
  backface-visibility: hidden;
  will-change: transform;
}

.flap-outer {
  background: linear-gradient(180deg, #d2ac33 0%, var(--cuc-gold) 100%);
  box-shadow: inset 0 -1px 0 rgba(255,255,255,0.25);
}

.flap-inner {
  background: linear-gradient(180deg, #7b1013 0%, var(--cuc-red-deep) 100%);
  transform: rotateX(180deg);
}

.envelope-front {
  z-index: 4;
  overflow: hidden;
  background: transparent;
  transition:
    transform 850ms cubic-bezier(.2,.8,.18,1),
    opacity 650ms ease,
    filter 650ms ease;
  will-change: transform, opacity;
}

.front-left,
.front-right,
.front-center {
  position: absolute;
  inset: 0;
}

.front-center {
  background: linear-gradient(180deg, #c11f25 0%, var(--cuc-red) 100%);
  clip-path: polygon(0 0, 50% 58%, 100% 0, 100% 100%, 0 100%);
}

.front-left {
  background: linear-gradient(180deg, #8d1115 0%, #a3161a 100%);
  clip-path: polygon(0 0, 0 100%, 50% 58%);
}

.front-right {
  background: linear-gradient(180deg, #cf2a2f 0%, #b51d22 100%);
  clip-path: polygon(100% 0, 100% 100%, 50% 58%);
}

.seal-ring,
.seal {
  position: absolute;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}

.seal-ring {
  width: 76px;
  height: 76px;
  background: rgba(255,255,255,0.22);
  z-index: 5;
}

.seal {
  width: 60px;
  height: 60px;
  background: radial-gradient(circle at 30% 30%, #ffe174 0%, var(--cuc-yellow) 45%, var(--cuc-gold) 100%);
  color: var(--cuc-red);
  display: grid;
  place-items: center;
  font-weight: 900;
  letter-spacing: 0.06em;
  box-shadow: 0 8px 18px rgba(0,0,0,0.14);
  z-index: 6;
}

.helper-text {
  margin: 14px 0 0;
  font-size: 0.95rem;
  color: var(--cuc-gray);
  text-align: center;
}

.video-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 24px;
}

.video-modal[hidden] {
  display: none;
}

.video-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(35, 28, 24, 0.68);
  backdrop-filter: blur(6px);
}

.video-modal-panel {
  position: relative;
  width: min(100%, 860px);
  padding: 22px 22px 18px;
  border-radius: 24px;
  background: linear-gradient(180deg, #fffdfa 0%, #fff7e7 100%);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.24);
  z-index: 1;
}

.video-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(163, 22, 26, 0.1);
  color: var(--cuc-red);
  font: inherit;
  font-size: 1.5rem;
  cursor: pointer;
}

.video-modal-kicker {
  margin: 0 48px 14px 0;
  color: var(--cuc-red);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.82rem;
}

.video-modal-player {
  width: 100%;
  max-height: min(74vh, 620px);
  display: block;
  border-radius: 18px;
  background: #000;
}

.is-open .letter {
  bottom: 10px;
  width: min(96%, 500px);
  height: calc(100% - 20px);
  transform: translateX(-50%) translateY(0) scale(1);
  opacity: 1;
  z-index: 9;
  box-shadow: 0 38px 70px rgba(89, 89, 89, 0.24);
  transition:
    width 900ms cubic-bezier(.2,.8,.18,1),
    height 900ms cubic-bezier(.2,.8,.18,1),
    bottom 900ms cubic-bezier(.2,.8,.18,1),
    transform 900ms cubic-bezier(.2,.8,.18,1),
    box-shadow 800ms ease,
    opacity 500ms ease,
    z-index 0ms;
}

.is-open .signature {
  opacity: 1;
  transform: translateY(0);
}

.is-open .shadow-base {
  transform: translateX(-50%) scaleX(0.86);
  opacity: 0.55;
}

.is-open .envelope-front {
  transform: translateX(-50%) translateY(34px) scaleY(0.94);
  opacity: 0.62;
  filter: saturate(0.92);
}

.is-open .seal,
.is-open .seal-ring {
  opacity: 0;
  pointer-events: none;
}

.is-open .flap-button {
  transform: translateX(-50%) translateY(28px);
  opacity: 0;
  pointer-events: none;
}

.is-open .flap-button::after {
  animation: none;
}

.is-open .flap-outer {
  transform: rotateX(180deg);
  filter: brightness(0.96);
}

.is-open .flap-inner {
  transform: rotateX(0deg);
}

@keyframes cuePulse {
  0%, 100% {
    transform: translateX(-50%) translateY(0);
  }

  50% {
    transform: translateX(-50%) translateY(-6px);
  }
}

@media (max-width: 1024px) {
  .scene {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 24px 18px 40px;
  }

  .intro {
    text-align: center;
    max-width: 760px;
    margin: 0 auto;
  }

  .intro-text {
    margin-left: auto;
    margin-right: auto;
  }

  .envelope-stage {
    width: min(100%, 500px);
    height: clamp(430px, 68vh, 600px);
  }
}

@media (max-height: 860px) and (min-width: 1025px) {
  .scene {
    gap: clamp(36px, 4vw, 64px);
    padding: 18px 24px 32px;
  }

  .intro h1 {
    font-size: clamp(2.1rem, 3vw, 3.3rem);
  }

  .intro-text {
    margin-top: 16px;
    font-size: 1rem;
    line-height: 1.65;
  }

  .envelope-stage {
    width: min(100%, 490px);
    height: clamp(390px, 68vh, 560px);
  }

  .helper-text {
    margin-top: 12px;
    font-size: 0.9rem;
  }
}

@media (max-height: 740px) and (min-width: 1025px) {
  .scene {
    min-height: auto;
    align-items: start;
    padding: 16px 20px 24px;
  }

  .intro-kicker {
    margin-bottom: 10px;
  }

  .intro h1 {
    font-size: clamp(1.9rem, 2.7vw, 2.8rem);
  }

  .intro-text {
    margin-top: 12px;
    font-size: 0.95rem;
    line-height: 1.55;
  }

  .envelope-stage {
    width: min(100%, 460px);
    height: clamp(350px, 64vh, 500px);
  }

  .letter-body {
    padding: 16px 18px 20px;
  }

  .letter-logo {
    width: 124px;
  }

  .letter-kicker {
    margin-top: 10px;
  }

  .letter h2 {
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    margin-bottom: 10px;
  }

  .letter-message,
  .letter-closing {
    font-size: 0.92rem;
    line-height: 1.5;
  }

  .video-invite {
    max-width: 200px;
    margin-bottom: 10px;
  }

  .signature {
    font-size: 1.95rem;
  }

  .signature-role {
    font-size: 0.72rem;
  }

  .helper-text {
    font-size: 0.86rem;
  }
}

@media (max-height: 900px) {
  .scene {
    min-height: auto;
  }
}

@media (max-width: 560px) {
  .intro h1 {
    font-size: 2.4rem;
  }

  .intro-text {
    font-size: 1rem;
    line-height: 1.7;
  }

  .envelope-stage {
    width: min(100%, 360px);
    height: min(620px, 72vh);
  }

  .letter {
    width: 82%;
    height: 48%;
    bottom: 72px;
    transform: translateX(-50%) translateY(34px) scale(0.94);
    transition:
      width 520ms cubic-bezier(.2,.8,.18,1),
      height 520ms cubic-bezier(.2,.8,.18,1),
      bottom 520ms cubic-bezier(.2,.8,.18,1),
      transform 520ms cubic-bezier(.2,.8,.18,1),
      box-shadow 420ms ease,
      opacity 260ms ease,
      z-index 0ms linear 180ms;
  }

  .letter-body {
    padding: 18px 18px 20px;
  }

  .letter-logo {
    width: 128px;
  }

  .letter-message,
  .letter-closing {
    font-size: 0.9rem;
    line-height: 1.54;
  }

  .signature {
    font-size: 1.65rem;
  }

  .signature-block {
    margin-top: 12px;
    padding-top: 8px;
  }

  .envelope-back,
  .envelope-front {
    height: min(250px, 48%);
  }

  .flap-button {
    top: calc(100% - 34px - min(250px, 48%));
    height: min(170px, 32%);
    transition: transform 480ms cubic-bezier(.2,.8,.18,1), opacity 220ms ease;
  }

  .flap {
    transition: transform 480ms cubic-bezier(.2,.8,.18,1), filter 360ms ease;
  }

  .envelope-front {
    transition:
      transform 480ms cubic-bezier(.2,.8,.18,1),
      opacity 320ms ease,
      filter 320ms ease;
  }

  .shadow-base {
    transition: transform 420ms ease, opacity 320ms ease;
    filter: blur(6px);
  }

  .seal-ring {
    width: 68px;
    height: 68px;
  }

  .seal {
    width: 54px;
    height: 54px;
    font-size: 0.92rem;
  }

  .is-open .letter {
    width: 96%;
    height: calc(100% - 18px);
    bottom: 8px;
    transform: translateX(-50%) translateY(0) scale(1);
    transition:
      width 520ms cubic-bezier(.2,.8,.18,1),
      height 520ms cubic-bezier(.2,.8,.18,1),
      bottom 520ms cubic-bezier(.2,.8,.18,1),
      transform 520ms cubic-bezier(.2,.8,.18,1),
      box-shadow 420ms ease,
      opacity 260ms ease,
      z-index 0ms;
  }

  .video-invite {
    width: 100%;
    max-width: 210px;
    margin-bottom: 10px;
    padding: 6px;
  }

  .video-play-badge {
    right: 14px;
    bottom: 14px;
    width: 34px;
    height: 34px;
  }

  .video-modal {
    padding: 14px;
  }

  .video-modal-panel {
    padding: 18px 18px 14px;
    border-radius: 20px;
  }
}
