/* ==========================================================================
   Стили романтического веб-сайта-истории
   Палитра: Нежно-розовая, пудровая, кремовая, розовая роза
   ========================================================================== */

:root {
  --bg-gradient: linear-gradient(135deg, #fff0f5 0%, #ffe4e1 40%, #ffd1dc 100%);
  --accent-pink: #ff758f;
  --deep-rose: #c9184a;
  --soft-pink: #ffb3c6;
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(255, 255, 255, 0.8);
  --glass-shadow: 0 15px 35px rgba(255, 117, 143, 0.15);
  --text-primary: #4a2835;
  --text-secondary: #7a4f61;
  --font-heading: 'Cormorant Garamond', 'Playfair Display', serif;
  --font-body: 'Montserrat', sans-serif;
  --transition-smooth: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

html, body {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--bg-gradient);
  color: var(--text-primary);
  position: relative;
  touch-action: manipulation;
}

/* Канвас плавающих сердечек */
#hearts-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* Кнопка переключения звука */
.sound-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: var(--transition-smooth);
}

.sound-toggle:hover {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.9);
}

/* Общие стили для экранов */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

/* Стеклянные карточки (Glassmorphism) */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  box-shadow: var(--glass-shadow);
  padding: 36px 28px;
  text-align: center;
  max-width: 480px;
  width: 100%;
  position: relative;
  z-index: 5;
  animation: floatCard 6s ease-in-out infinite;
}

@keyframes floatCard {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
}

/* --------------------------------------------------------------------------
   ЭКРАН 1: ВЕЛКАМ
   -------------------------------------------------------------------------- */
.heart-pulse-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
  animation: pulseHeart 1.8s ease-in-out infinite;
}

@keyframes pulseHeart {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

.romantic-title {
  font-family: var(--font-heading);
  font-size: 2.3rem;
  font-weight: 700;
  color: var(--deep-rose);
  margin-bottom: 16px;
}

.welcome-text {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.question-box {
  background: rgba(255, 255, 255, 0.6);
  padding: 12px 18px;
  border-radius: 16px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 28px;
  border: 1px solid rgba(255, 180, 200, 0.4);
}

.sparkle {
  display: inline-block;
  animation: spinSparkle 3s linear infinite;
}

@keyframes spinSparkle {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Романтическая кнопка */
.btn-romantic {
  position: relative;
  background: linear-gradient(135deg, #ff758f 0%, #ff4d6d 100%);
  color: #fff;
  border: none;
  padding: 16px 36px;
  font-size: 1.1rem;
  font-weight: 600;
  font-family: var(--font-body);
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(255, 77, 109, 0.35);
  transition: var(--transition-smooth);
  overflow: hidden;
}

.btn-romantic:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 14px 30px rgba(255, 77, 109, 0.45);
}

.btn-romantic:active {
  transform: translateY(1px) scale(0.98);
}

/* --------------------------------------------------------------------------
   ЭКРАН 2: СЛАЙД-ШОУ СТОРИС
   -------------------------------------------------------------------------- */
#slideshow-screen {
  padding: 10px;
}

.story-container {
  width: 100%;
  max-width: 440px;
  height: 100%;
  max-height: 840px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 20px 45px rgba(255, 117, 143, 0.2);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Прогресс бары Stories */
.progress-bar-wrapper {
  display: flex;
  gap: 3px;
  padding: 14px 14px 8px 14px;
  width: 100%;
  z-index: 20;
}

.progress-segment {
  flex: 1;
  height: 3px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--accent-pink);
  transition: width 0.1s linear;
}

.progress-segment.completed .progress-fill {
  width: 100%;
}

/* Верхняя шапка сторис */
.story-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px 12px 16px;
  z-index: 20;
}

.story-author {
  display: flex;
  align-items: center;
  gap: 10px;
}

.author-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--soft-pink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.author-info {
  display: flex;
  flex-direction: column;
}

.author-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.story-tag {
  font-size: 0.72rem;
  color: var(--deep-rose);
  font-weight: 500;
}

.story-counter {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.6);
  padding: 4px 10px;
  border-radius: 12px;
}

/* Блок фото */
.story-media-box {
  flex: 1;
  position: relative;
  margin: 0 14px;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fdf5f7;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.03);
}

.photo-frame {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 20px;
}

.story-img-bg {
  position: absolute;
  top: -5%;
  left: -5%;
  width: 110%;
  height: 110%;
  object-fit: cover;
  filter: blur(25px) brightness(0.9);
  opacity: 0.7;
  z-index: 1;
  transform: scale(1.08);
}

#story-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 20px;
  position: relative;
  z-index: 2;
  transition: transform 0.5s ease, opacity 0.4s ease;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.15));
}

.story-img-fade {
  opacity: 0;
  transform: scale(0.97);
}

/* Зоны для тапа на половинки экрана (Лево 50% / Право 50%) */
.tap-zone {
  position: absolute;
  top: 0;
  height: 100%;
  width: 50%;
  z-index: 25;
  cursor: pointer;
}

.zone-left {
  left: 0;
}

.zone-right {
  right: 0;
}

.story-controls {
  z-index: 30; /* Кнопки остаются поверх для нажатия паузы */
}

/* Подпись */
.story-caption-box {
  padding: 12px 14px;
  z-index: 20;
}

.caption-card {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 182, 193, 0.4);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}

.caption-text {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-primary);
  text-align: center;
  font-weight: 500;
}

/* Кнопки управления */
.story-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 0 14px 14px 14px;
  z-index: 20;
}

.control-btn {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 117, 143, 0.3);
  color: var(--deep-rose);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.control-btn:hover {
  background: #fff;
  transform: scale(1.1);
}

.play-pause-btn {
  background: var(--soft-pink);
  color: #fff;
  border: none;
}

/* --------------------------------------------------------------------------
   ЭКРАН 3: ФИНАЛ
   -------------------------------------------------------------------------- */
.finale-card {
  max-width: 520px;
}

.envelope-icon {
  font-size: 3rem;
  margin-bottom: 10px;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-12px); }
  60% { transform: translateY(-6px); }
}

.romantic-heading {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  color: var(--deep-rose);
  margin-bottom: 20px;
}

.letter-box {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 20px;
  padding: 24px;
  border: 1px solid rgba(255, 182, 193, 0.5);
  min-height: 180px;
  margin-bottom: 26px;
  text-align: left;
  position: relative;
  box-shadow: inset 0 0 15px rgba(255, 117, 143, 0.05);
}

.typewriter-content {
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--text-primary);
  font-weight: 500;
  display: inline;
}

.cursor {
  display: inline-block;
  color: var(--accent-pink);
  font-weight: 700;
  animation: blink 0.8s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.finale-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.btn-secondary {
  background: transparent;
  border: 1.5px solid var(--accent-pink);
  color: var(--deep-rose);
  padding: 12px 28px;
  border-radius: 50px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-secondary:hover {
  background: rgba(255, 117, 143, 0.1);
  transform: scale(1.03);
}

/* Оптимизация под мобильные экраны (iOS & Android) */
@media (max-width: 480px) {
  .screen {
    padding: env(safe-area-inset-top, 10px) 10px env(safe-area-inset-bottom, 10px) 10px;
  }

  .glass-card {
    padding: 24px 18px;
    border-radius: 24px;
    max-width: 100%;
  }

  .romantic-title {
    font-size: 1.8rem;
  }

  .story-container {
    border-radius: 22px;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border: none;
  }

  .progress-bar-wrapper {
    gap: 1.5px;
    padding: 10px 10px 4px 10px;
  }

  .progress-segment {
    height: 2px;
  }

  .story-header {
    padding: 4px 12px 8px 12px;
  }

  .story-media-box {
    margin: 0 8px;
    border-radius: 18px;
  }

  #story-img {
    border-radius: 18px;
    object-fit: cover;
  }

  .caption-card {
    padding: 12px 14px;
  }

  .caption-text {
    font-size: 0.88rem;
    line-height: 1.4;
  }

  .sound-toggle {
    top: max(16px, env(safe-area-inset-top, 16px));
    right: 16px;
    width: 42px;
    height: 42px;
  }
}
