/* ============================================================
   ПЕРЕМЕННЫЕ
   ============================================================ */
:root {
  /* Фон */
  --c-bg1: #fef3f0;
  --c-bg2: #fff0f7;
  --c-bg3: #f5f0fe;

  /* Карточка */
  --c-card:        rgba(255, 255, 255, 0.80);
  --c-card-border: rgba(244, 114, 182, 0.18);

  /* Акцентная палитра */
  --c-rose:        #e8629a;
  --c-rose-deep:   #c94d82;
  --c-rose-light:  #fbbede;
  --c-peach:       #fba985;
  --c-lavender:    #c4b5fd;

  /* Текст */
  --c-text:      #7a2d56;
  --c-text-soft: #b07898;
  --c-text-hint: #d4a8c0;

  /* Тени */
  --shadow-card:
    0 24px 72px rgba(200, 70, 140, 0.11),
    0  6px 20px rgba(200, 70, 140, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.94);

  /* Шрифты */
  --ff-hand: 'Caveat', cursive;
  --ff-body: 'Nunito', sans-serif;

  /* Кривые анимации */
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-o: cubic-bezier(0.16, 1.00, 0.30, 1);
}

/* ============================================================
   СБРОС
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }

body {
  height: 100%;
  overflow: hidden;
  font-family: var(--ff-body);
  background: linear-gradient(148deg, var(--c-bg1) 0%, var(--c-bg2) 55%, var(--c-bg3) 100%);
  color: var(--c-text);
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

/* ============================================================
   ФОНОВЫЕ BLOBS
   ============================================================ */
.blob {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(72px);
  opacity: 0.72;
  z-index: 0;
  will-change: transform;
}

.blob--a {
  width: 440px; height: 440px;
  top: -110px; left: -95px;
  background: radial-gradient(circle, #fbd5e9 0%, transparent 70%);
  animation: blobDrift1 20s ease-in-out infinite alternate;
}

.blob--b {
  width: 380px; height: 380px;
  bottom: -85px; right: -80px;
  background: radial-gradient(circle, #fddec8 0%, transparent 70%);
  animation: blobDrift2 24s ease-in-out infinite alternate;
}

.blob--c {
  width: 320px; height: 320px;
  top: 44%; left: 56%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, #ddd6fe 0%, transparent 70%);
  animation: blobDrift3 18s ease-in-out infinite alternate;
}

.bg-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

/* ============================================================
   ЭКРАНЫ
   ============================================================ */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  z-index: 10;

  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.97);
  transition: opacity .44s var(--ease-o), transform .44s var(--ease-o);
}

.screen.is-active  { opacity: 1; pointer-events: all; transform: translateY(0) scale(1); }
.screen.is-exit    {
  opacity: 0;
  transform: translateY(-18px) scale(0.95);
  pointer-events: none;
  transition: opacity .30s ease-in, transform .30s ease-in;
}

/* ============================================================
   КАРТОЧКА (light glass)
   ============================================================ */
.card {
  position: relative;
  width: 100%;
  max-width: 375px;
  padding: 42px 32px 48px;
  background: var(--c-card);
  border: 1px solid var(--c-card-border);
  border-radius: 30px;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: var(--shadow-card);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  z-index: 1;
  overflow: visible; /* кнопка «нет» может слегка выходить за края */
}

/* Блик сверху */
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 18%; right: 18%;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.96), transparent);
  border-radius: 50%;
}

.card--final { padding-bottom: 52px; gap: 28px; }

/* ============================================================
   ТИПОГРАФИКА
   ============================================================ */
.title {
  font-family: var(--ff-hand);
  font-size: clamp(2.5rem, 11vw, 3.4rem);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: .01em;
  color: var(--c-text);
}

.title--playful {
  font-size: clamp(2rem, 9.5vw, 2.9rem);
  color: var(--c-rose-deep);
  text-shadow: 0 0 24px rgba(232, 98, 154, 0.18);
}

.title--sans {
  font-family: var(--ff-body);
  font-size: clamp(1.55rem, 7vw, 2.1rem);
  font-weight: 700;
}

.subtitle {
  font-size: 1.02rem;
  font-weight: 400;
  color: var(--c-text-soft);
  letter-spacing: .03em;
}

.subtitle--hero {
  font-family: var(--ff-hand);
  font-size: 1.65rem;
  font-weight: 600;
  color: var(--c-text);
}

/* Пульсирующие сердечки в заголовке */
.heart-pulse {
  display: inline-block;
  color: var(--c-rose);
  font-size: .84em;
  animation: heartBeat 2.3s ease-in-out infinite;
}

/* ============================================================
   ДЕКОРАТИВНАЯ ИКОНКА (верх карточки)
   ============================================================ */
.deco-icon {
  display: block;
  font-size: 2.9rem;
  line-height: 1;
  filter: drop-shadow(0 4px 12px rgba(244, 114, 182, 0.28));
  animation: iconFloat 4s ease-in-out infinite;
  will-change: transform;
}

/* ============================================================
   КНОПКИ
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 36px;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .22s var(--spring), box-shadow .22s ease;
  will-change: transform;
}

.btn--yes {
  background: linear-gradient(135deg, var(--c-rose) 0%, var(--c-rose-deep) 50%, #f472b6 100%);
  color: #fff;
  letter-spacing: .02em;
  box-shadow:
    0  6px 22px rgba(232, 98, 154, 0.40),
    0  2px  8px rgba(200, 70, 130, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.btn--yes:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow:
    0 12px 34px rgba(232, 98, 154, 0.54),
    0  4px 12px rgba(200, 70, 130, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.btn--yes:active { transform: scale(0.96); }

.btn--no {
  background: rgba(255, 255, 255, 0.74);
  color: var(--c-text-soft);
  border: 1.5px solid rgba(244, 114, 182, 0.28);
  font-size: .9rem;
  padding: 12px 28px;
  box-shadow: 0 2px 10px rgba(200, 70, 130, 0.08);
  /* transform управляется из JS через inline style */
  transition: background .2s ease, box-shadow .2s ease, transform .38s var(--spring);
}

.btn--no:hover {
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 4px 16px rgba(200, 70, 130, 0.12);
}

.btn-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  overflow: visible;
}

/* ============================================================
   БОЛЬШИЕ ЭМОДЗИ
   ============================================================ */
.big-emoji {
  display: block;
  font-size: 5.2rem;
  line-height: 1;
  filter: drop-shadow(0 8px 22px rgba(244, 114, 182, 0.20));
  will-change: transform;
}

.big-emoji--float  { animation: iconFloat 3.2s ease-in-out infinite; }
.big-emoji--bounce { animation: idleBounce 2.8s ease-in-out infinite; }

/* ============================================================
   КНОПКА-ЦВЕТОЧЕК (Экран 3)
   ============================================================ */
.flower-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding: 10px 24px;
  background: transparent;
  border: none;
  border-radius: 20px;
  cursor: pointer;
}

.flower-btn__icon {
  display: block;
  font-size: 3.6rem;
  filter: drop-shadow(0 4px 14px rgba(244, 114, 182, 0.36));
  transition: transform .26s var(--spring), filter .26s ease;
  animation: iconFloat 4.5s ease-in-out .4s infinite;
  will-change: transform;
}

.flower-btn:hover .flower-btn__icon,
.flower-btn:focus-visible .flower-btn__icon {
  transform: scale(1.22) rotate(12deg);
  filter: drop-shadow(0 6px 24px rgba(244, 114, 182, 0.58));
}

.flower-btn:active .flower-btn__icon { transform: scale(0.88); }

.flower-btn__hint {
  font-size: .78rem;
  font-weight: 500;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--c-text-hint);
  animation: pulseOpacity 2.8s ease-in-out infinite;
}

/* ============================================================
   КОНВЕРТ (Экран 4)
   ============================================================ */
.env-scene {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  transition: opacity .36s ease, transform .36s ease;
}

.env-scene.is-hiding {
  opacity: 0;
  transform: scale(0.9) translateY(6px);
  pointer-events: none;
}

.envelope {
  position: relative;
  width: 210px;
  height: 144px;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  transition: transform .28s var(--spring);
  will-change: transform;
}

.envelope:hover  { transform: translateY(-6px) scale(1.04); }
.envelope:active { transform: scale(0.96); }

/* Тело конверта */
.envelope__body {
  position: absolute;
  inset: 0;
  background: linear-gradient(155deg, #ffd8ec, #ffc0de);
  border-radius: 10px;
  border: 1.5px solid rgba(244, 114, 182, 0.32);
  box-shadow:
    0 12px 38px rgba(244, 114, 182, 0.20),
    0  4px 12px rgba(244, 114, 182, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
  overflow: hidden;
}

/* Линии сгиба */
.envelope__fold {
  position: absolute;
  bottom: 0;
  width: 50%;
  height: 55%;
}

.envelope__fold--l {
  left: 0;
  background: rgba(255, 255, 255, 0.20);
  clip-path: polygon(0 100%, 100% 100%, 0 0);
  border-right: 1.5px solid rgba(255, 150, 190, 0.22);
}

.envelope__fold--r {
  right: 0;
  background: rgba(255, 255, 255, 0.20);
  clip-path: polygon(100% 100%, 0 100%, 100% 0);
  border-left: 1.5px solid rgba(255, 150, 190, 0.22);
}

/* Клапан-треугольник сверху */
.envelope__flap {
  position: absolute;
  top: -1px; left: -1px; right: -1px;
  height: 75px;
  background: linear-gradient(168deg, #ffe0ee, #ffcce2);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 10px 10px 0 0;
  border: 1.5px solid rgba(244, 114, 182, 0.28);
  z-index: 2;
  transform-origin: 50% 0%;
  transition: transform .50s ease, opacity .50s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

/* Сургучная печать */
.envelope__seal {
  position: absolute;
  top: calc(75px - 22px);
  left: 50%;
  transform: translateX(-50%);
  width: 44px; height: 44px;
  background: linear-gradient(135deg, #f472b6, #e0258c);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #fff;
  z-index: 3;
  box-shadow:
    0 0 18px rgba(244, 114, 182, 0.44),
    0 4px 12px rgba(200, 70, 130, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.30);
  transition: transform .28s ease, opacity .28s ease;
  animation: sealGlow 2s ease-in-out infinite;
}

/* Открытый конверт */
.envelope.is-open .envelope__flap {
  transform: translateY(-22px);
  opacity: 0;
}

.envelope.is-open .envelope__seal {
  animation: none;
  transform: translateX(-50%) scale(0) rotate(45deg);
  opacity: 0;
}

.hint-label {
  font-size: .82rem;
  font-weight: 500;
  color: var(--c-text-hint);
  letter-spacing: .04em;
  animation: pulseOpacity 3s ease-in-out infinite;
  transition: opacity .3s ease;
}

/* ============================================================
   ПИСЬМО (показывается после открытия конверта)
   ============================================================ */
.letter {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  width: 100%;
  padding: 28px 24px 24px;
  background: linear-gradient(135deg, #fffaf5 0%, #fff5f9 100%);
  border: 1.5px solid rgba(244, 114, 182, 0.22);
  border-radius: 22px;
  box-shadow:
    0 10px 36px rgba(200, 70, 140, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
  animation: letterReveal .65s var(--spring) both;
}

.letter.is-visible { display: flex; }

.letter__icon {
  font-size: 2.2rem;
  filter: drop-shadow(0 2px 8px rgba(244, 114, 182, 0.28));
}

.letter__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
  text-align: center;
}

.letter__line {
  font-family: var(--ff-hand);
  font-size: 1.38rem;
  font-weight: 400;
  color: var(--c-text);
  line-height: 1.55;
}

.letter__line--soft {
  font-size: 1.2rem;
  color: var(--c-text-soft);
}

.letter__sig {
  font-family: var(--ff-hand);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--c-rose);
  margin-top: 6px;
}

/* ============================================================
   ФОТО-РАМКА — СТРОГО КРУГЛАЯ (Экран 5)
   ============================================================ */
.photo-wrap {
  position: relative;
  width: 280px;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Декоративные пульсирующие кольца */
.photo-ring {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px dashed;
  pointer-events: none;
}

.photo-ring--1 {
  width: 252px; height: 252px;
  border-color: rgba(244, 114, 182, 0.28);
  animation: ringPulse 4s ease-in-out infinite;
}

.photo-ring--2 {
  width: 276px; height: 276px;
  border-color: rgba(244, 114, 182, 0.14);
  animation: ringPulse 4s .6s ease-in-out infinite;
}

/*
  ╔══════════════════════════════════════════╗
  ║  КРУГЛОЕ ФОТО — ключевые свойства       ║
  ╚══════════════════════════════════════════╝
*/
.photo-circle {
  position: relative;
  z-index: 1;
  width: 220px;
  height: 220px;          /* равно width → квадрат */
  aspect-ratio: 1 / 1;   /* дополнительная гарантия */
  border-radius: 50%;     /* делает квадрат кругом  */
  overflow: hidden;       /* обрезает картинку по кругу */
  flex-shrink: 0;
  border: 4px solid rgba(255, 255, 255, 0.96);
  box-shadow:
    0 0 0  3px rgba(244, 114, 182, 0.38),
    0 0 0  8px rgba(244, 114, 182, 0.16),
    0 0 0 14px rgba(244, 114, 182, 0.07),
    0 24px 60px rgba(200, 70, 140, 0.26);
  animation: photoReveal .88s .18s var(--spring) both;
}

.photo-circle img {
  position: absolute;  /* гарантированно заполняет круг */
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 15%;  /* сдвигаем чуть вверх — показывает лицо у портретных фото */
  display: block;
}

/* Заглушка при отсутствии фото */
.photo-placeholder {
  position: absolute;  /* поверх img, не двигает круг */
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, #ffe0f0, #ffd0e8);
  text-align: center;
  padding: 20px;
  color: var(--c-text-soft);
  font-size: .84rem;
}

.photo-placeholder span { font-size: 2.6rem; }

.photo-placeholder code {
  display: block;
  font-size: .76rem;
  padding: 3px 10px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  color: var(--c-rose);
  margin-top: 4px;
}

/* Финальные сердечки */
.final-hearts {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  overflow: hidden;
}

/* ============================================================
   КЕЙФРЕЙМЫ
   ============================================================ */

/* Фоновые блобы */
@keyframes blobDrift1 {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-32px, 46px) scale(1.10); }
}
@keyframes blobDrift2 {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(42px, -36px) scale(1.12); }
}
@keyframes blobDrift3 {
  from { transform: translate(-50%, -50%) scale(1); }
  to   { transform: translate(calc(-50% + 28px), calc(-50% - 20px)) scale(1.08); }
}

/* Парение */
@keyframes iconFloat {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-11px); }
}

/* Ленивый баунс */
@keyframes idleBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  40%       { transform: translateY(-14px) scale(1.06); }
  58%       { transform: translateY(-14px) scale(1.06); }
  78%       { transform: translateY(0) scale(0.97); }
}

/* Сердцебиение (для inline ♡) */
@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  20%       { transform: scale(1.32); }
  40%       { transform: scale(1); }
  60%       { transform: scale(1.15); }
}

/* Свечение печати конверта */
@keyframes sealGlow {
  0%, 100% {
    box-shadow:
      0 0 18px rgba(244, 114, 182, 0.44),
      0 4px 12px rgba(200, 70, 130, 0.22),
      inset 0 1px 0 rgba(255, 255, 255, 0.30);
  }
  50% {
    box-shadow:
      0 0 30px rgba(244, 114, 182, 0.66),
      0 5px 18px rgba(200, 70, 130, 0.36),
      inset 0 1px 0 rgba(255, 255, 255, 0.30);
  }
}

/* Покачивание (кнопка «нет», 3-й клик) */
@keyframes wiggle {
  0%,  100% { transform: rotate(0deg); }
  12%        { transform: rotate(-8deg) scale(1.04); }
  25%        { transform: rotate(8deg)  scale(1.04); }
  37%        { transform: rotate(-6deg); }
  50%        { transform: rotate(6deg); }
  62%        { transform: rotate(-4deg); }
  75%        { transform: rotate(4deg); }
  87%        { transform: rotate(-2deg); }
}

/* Появление иконки на экране 2 */
@keyframes bounceIn {
  0%   { opacity: 0; transform: scale(.40) rotate(-18deg); }
  55%  { transform: scale(1.26) rotate(6deg); }
  78%  { transform: scale(.92)  rotate(-2deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

/* Пульс прозрачности */
@keyframes pulseOpacity {
  0%, 100% { opacity: .38; }
  50%       { opacity: .88; }
}

/* Появление письма */
@keyframes letterReveal {
  from { opacity: 0; transform: translateY(18px) scale(.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Появление круглого фото */
@keyframes photoReveal {
  from { opacity: 0; transform: scale(.80) translateY(22px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* Пульс колец вокруг фото */
@keyframes ringPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1);    opacity: 1; }
  50%       { transform: translate(-50%, -50%) scale(1.05); opacity: .52; }
}

/* Частицы фона */
@keyframes particleFloat {
  0%, 100% {
    transform: translateY(0) rotate(var(--rs));
    opacity: var(--op);
  }
  50% {
    transform: translateY(calc(var(--dy) * -1px)) rotate(var(--re));
    opacity: calc(var(--op) * .40);
  }
}

/* Финальные сердечки — подъём вверх */
@keyframes heartRise {
  0%  { transform: translateY(0) scale(1) rotate(var(--tw)); opacity: .92; }
  78% { opacity: .55; }
  100%{ transform: translateY(-115vh) scale(.38) rotate(calc(var(--tw) + 24deg)); opacity: 0; }
}

/* ============================================================
   АДАПТИВНОСТЬ
   ============================================================ */
@media (max-width: 360px) {
  .card { padding: 32px 22px 38px; border-radius: 24px; }
  .title { font-size: 2.2rem; }
  .envelope { width: 184px; height: 124px; }
  .envelope__flap { height: 64px; }
  .envelope__seal { top: calc(64px - 22px); }
  .photo-wrap { width: 240px; height: 240px; }
  .photo-circle { width: 188px; height: 188px; }
  .photo-ring--1 { width: 214px; height: 214px; }
  .photo-ring--2 { width: 236px; height: 236px; }
}

@media (min-height: 780px) {
  .card { padding: 50px 36px 54px; }
  .deco-icon { font-size: 3.2rem; }
  .big-emoji { font-size: 5.8rem; }
}

@media (min-width: 600px) {
  .card { max-width: 410px; }
}
