/* ==========================================================================
   CSS: Мобильный сайт-подарок (Черно-белый стиль / Handcrafted Aesthetic)
   ========================================================================== */

:root {
  --bg-color: #ffffff;
  --text-main: #111111;
  --text-muted: #555555;
  --border-color: #111111;
  --dot-inactive: #d1d1d1;
  --accent-color: #000000;
  --font-hand: 'Neucha', 'Caveat', cursive, sans-serif;
  --app-height: 100dvh;
}

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

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Container
   -------------------------------------------------------------------------- */
.phone-frame {
  position: relative;
  width: 100%;
  max-width: 500px;
  height: 100%;
  height: 100dvh;
  background-color: var(--bg-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Header / Progress Dots
   -------------------------------------------------------------------------- */
.story-header {
  padding: 18px 20px 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  flex-shrink: 0;
}

.progress-bar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--dot-inactive);
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
}

.progress-dot.active {
  background-color: var(--text-main);
  transform: scale(1.3);
}

.progress-dot.finale-dot {
  width: auto;
  height: auto;
  border-radius: 0;
  background: transparent;
  font-size: 14px;
  line-height: 1;
  color: var(--dot-inactive);
}

.progress-dot.finale-dot.active {
  color: var(--text-main);
  transform: scale(1.4);
}

/* --------------------------------------------------------------------------
   Viewport & Slides
   -------------------------------------------------------------------------- */
.story-viewport {
  position: relative;
  flex: 1;
  width: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.96);
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.45s ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 16px 20px;
}

.slide.active {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  z-index: 2;
}

.slide.prev-slide {
  transform: scale(1.04);
  opacity: 0;
}

/* Image Presentation */
.image-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  touch-action: none; /* Запрещает нативный зум страницы, отдавая жест зуму картинки */
}

.image-wrapper img {
  max-width: 96%;
  max-height: 94%;
  object-fit: contain;
  filter: contrast(106%) grayscale(100%);
  transform-origin: center center;
  will-change: transform;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.image-wrapper.zoomed img {
  cursor: grab;
}

.image-wrapper.zoomed.panning img {
  cursor: grabbing;
}

/* --------------------------------------------------------------------------
   Slide 5: Finale Experience
   -------------------------------------------------------------------------- */
.finale-slide {
  background-color: #ffffff;
  padding: 24px 20px;
  position: relative;
  overflow: hidden;
}

.finale-content {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 360px;
  width: 100%;
}

/* Mixed Typography Banner */
.bday-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  width: 100%;
}

.bday-word {
  display: flex;
  justify-content: center;
  align-items: baseline;
  flex-wrap: nowrap;
}

.bday-letter {
  display: inline-block;
  color: #111111;
  opacity: 0;
  transform: translateY(24px) scale(0.2) rotate(var(--rot, 0deg));
  transition: opacity 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 0 1px;
  text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.05);
}

.bday-letter.visible {
  opacity: 1;
  transform: translateY(0) scale(1) rotate(var(--rot, 0deg));
}

/* Decorative Divider */
.doodle-divider {
  margin: 4px 0 20px;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.6s ease 3.4s, transform 0.6s ease 3.4s;
}

.finale-slide.active .doodle-divider {
  opacity: 1;
  transform: scale(1);
}

/* Sincere Message */
.sincere-text {
  font-family: var(--font-hand);
  font-size: 1.45rem;
  line-height: 1.45;
  color: #1a1a1a;
  letter-spacing: 0.3px;
  margin-bottom: 34px;
  min-height: 4.8em;
  padding: 0 10px;
}

.sincere-cursor {
  display: inline-block;
  font-weight: 300;
  color: #111111;
  animation: blinkCursor 0.7s infinite;
  margin-left: 2px;
}

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

/* --------------------------------------------------------------------------
   Monochrome Floating Confetti / Sparkles
   -------------------------------------------------------------------------- */
.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.confetti-particle {
  position: absolute;
  color: #111111;
  font-size: 16px;
  user-select: none;
  animation: floatUpward 4.5s cubic-bezier(0.2, 0.8, 0.4, 1) infinite;
  opacity: 0;
}

@keyframes floatUpward {
  0% {
    transform: translateY(100%) scale(0.6) rotate(0deg);
    opacity: 0;
  }
  15% {
    opacity: 0.85;
  }
  85% {
    opacity: 0.85;
  }
  100% {
    transform: translateY(-110vh) scale(1.1) rotate(360deg);
    opacity: 0;
  }
}

/* --------------------------------------------------------------------------
   Footer Navigation Controls
   -------------------------------------------------------------------------- */
.story-footer {
  padding: 14px 24px calc(52px + env(safe-area-inset-bottom, 28px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
  flex-shrink: 0;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.6));
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-width: 96px;
}

.btn-prev {
  background-color: transparent;
  color: #111111;
  border: 1.5px solid #111111;
}

.btn-prev:disabled {
  opacity: 0.2;
  border-color: #cccccc;
  color: #cccccc;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-prev:not(:disabled):active {
  background-color: #f0f0f0;
  transform: scale(0.95);
}

.btn-next {
  background-color: #111111;
  color: #ffffff;
  border: 1.5px solid #111111;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.btn-next:active {
  transform: scale(0.95);
  background-color: #333333;
}

.btn-next.pulse-highlight {
  animation: pulseButton 2s infinite ease-in-out;
}

@keyframes pulseButton {
  0%, 100% {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  }
  50% {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    transform: translateY(-1px);
  }
}

.page-counter {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* --------------------------------------------------------------------------
   Adaptive Tweaks for Small Mobile Screens (< 380px)
   -------------------------------------------------------------------------- */
@media (max-width: 375px) {
  .story-header {
    padding: 12px 16px 6px;
  }
  .story-footer {
    padding: 10px 18px calc(44px + env(safe-area-inset-bottom, 22px));
  }
  .nav-btn {
    padding: 10px 16px;
    font-size: 0.85rem;
    min-width: 86px;
  }
  .sincere-text {
    font-size: 1.25rem;
    margin-bottom: 24px;
  }
}
