/* ========================================================
   🎨 ЦВЕТОВАЯ ПАЛИТРА И БАЗОВЫЕ ПЕРЕМЕННЫЕ
   ======================================================== */
:root {
  --color-gold: #d6ae65;
  --color-terracotta: #cf6b44;
  --color-rose: #db8f8f;
  --color-ruby: #b84444;
  --color-blush: #d6bcbc;

  /* Фоновые и нейтральные оттенки */
  --bg-cream: #faf5ee;
  --bg-cream-card: rgba(255, 255, 255, 0.88);
  --text-main: #3d2b24;
  --text-muted: #826c63;
  --border-warm: rgba(207, 107, 68, 0.2);
  --border-gold: rgba(214, 174, 101, 0.35);

  /* Тени */
  --shadow-soft: 0 10px 30px rgba(184, 68, 68, 0.08), 0 4px 12px rgba(61, 43, 36, 0.05);
  --shadow-elevated: 0 18px 45px rgba(207, 107, 68, 0.16), 0 6px 18px rgba(61, 43, 36, 0.08);
  --shadow-glow: 0 0 25px rgba(214, 174, 101, 0.4);

  /* Шрифты */
  --font-main: 'Montserrat', system-ui, -apple-system, sans-serif;
  --font-script: 'Caveat', cursive;
  --font-hand: 'Marck Script', cursive;

  /* Скругления */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
}

/* ========================================================
   СБРОС И БАЗОВЫЕ СТИЛИ
   ======================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg-cream);
  color: var(--text-main);
  font-family: var(--font-main);
  overflow-x: hidden;
  position: relative;
  line-height: 1.6;
}

/* ========================================================
   ДЕКОРАТИВНЫЙ ТЁПЛЫЙ ФОН
   ======================================================== */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
  animation: pulseGlow 12s ease-in-out infinite alternate;
}

.glow-1 {
  width: 480px;
  height: 480px;
  top: -100px;
  right: -80px;
  background: radial-gradient(circle, var(--color-gold) 0%, transparent 70%);
}

.glow-2 {
  width: 520px;
  height: 520px;
  bottom: -120px;
  left: -100px;
  background: radial-gradient(circle, var(--color-rose) 0%, transparent 70%);
  animation-delay: -4s;
}

.glow-3 {
  width: 360px;
  height: 360px;
  top: 45%;
  left: 55%;
  background: radial-gradient(circle, var(--color-blush) 0%, transparent 70%);
  animation-delay: -7s;
}

@keyframes pulseGlow {
  0% { transform: scale(1) translate(0, 0); opacity: 0.45; }
  50% { transform: scale(1.12) translate(15px, -20px); opacity: 0.65; }
  100% { transform: scale(0.95) translate(-10px, 15px); opacity: 0.45; }
}

/* Холст конфетти */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
}

/* ========================================================
   ОСНОВНОЙ КОНТЕЙНЕР ПРИЛОЖЕНИЯ
   ======================================================== */
.app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px 16px;
}

/* ========================================================
   ПЕРЕКЛЮЧЕНИЕ ЭКРАНОВ
   ======================================================== */
.screen {
  display: none;
  width: 100%;
  max-width: 680px;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 1;
  transform: translateY(0);
}

/* Специальные размеры для колоды и альбома */
#screen-deck.active {
  max-width: 500px;
}

#screen-album.active {
  max-width: 1080px;
  align-items: stretch;
  padding-bottom: 40px;
}

/* ========================================================
   ЭЛЕМЕНТЫ: СТЕКЛО, КНОПКИ, ПОЛЯ ВВОДА
   ======================================================== */
.glass-panel {
  width: 100%;
  background: var(--bg-cream-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid var(--border-gold);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-elevated);
  padding: 36px 28px;
  position: relative;
  overflow: hidden;
}

/* Скругленные прямоугольные кнопки */
.app-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 28px;
  font-family: var(--font-main);
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: var(--shadow-soft);
  text-decoration: none;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-terracotta), var(--color-ruby));
  color: #ffffff;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #da764f, #c74848);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(207, 107, 68, 0.32);
}

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.95);
  color: var(--color-terracotta);
  border: 1.5px solid var(--border-gold);
}

.btn-secondary:hover {
  background: #ffffff;
  color: var(--color-ruby);
  border-color: var(--color-terracotta);
  transform: translateY(-2px);
}

.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border-gold);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-soft);
}

.icon-btn:hover {
  background: #ffffff;
  color: var(--color-terracotta);
  transform: scale(1.08);
}

.icon-btn:active {
  transform: scale(0.95);
}

/* ========================================================
   ЭКРАН 1: ВВОД КОД-ФРАЗЫ
   ======================================================== */
.passcode-card {
  text-align: center;
  max-width: 440px;
}

.card-icon {
  font-size: 48px;
  margin-bottom: 14px;
  animation: floatIcon 3.5s ease-in-out infinite alternate;
}

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

.passcode-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--color-ruby);
  margin-bottom: 8px;
}

.passcode-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 26px;
}

#passcode-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-wrapper {
  position: relative;
  width: 100%;
}

/* Прямоугольное поле со скруглёнными углами */
#passcode-input {
  width: 100%;
  padding: 16px 20px;
  font-size: 17px;
  font-family: var(--font-main);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-gold);
  background: #ffffff;
  color: var(--text-main);
  text-align: center;
  outline: none;
  transition: all 0.25s ease;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.03);
}

#passcode-input:focus {
  border-color: var(--color-terracotta);
  box-shadow: 0 0 0 4px rgba(207, 107, 68, 0.15);
}

#passcode-btn {
  width: 100%;
}

.error-message {
  margin-top: 14px;
  font-size: 14px;
  color: var(--color-ruby);
  font-weight: 500;
  min-height: 20px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.error-message.visible {
  opacity: 1;
}

.shake {
  animation: shakeAnim 0.4s ease;
}

@keyframes shakeAnim {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* ========================================================
   ЭКРАНЫ 2 И 4: ПЕЧАТНАЯ МАШИНКА (ИНТРО И АУТРО)
   ======================================================== */
.typewriter-card {
  max-width: 580px;
  min-height: 380px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stamp-badge {
  display: inline-block;
  align-self: flex-start;
  padding: 6px 14px;
  background: rgba(214, 174, 101, 0.18);
  color: var(--color-ruby);
  border: 1px dashed var(--color-gold);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 22px;
}

.typewriter-content {
  flex-grow: 1;
  font-size: 19px;
  line-height: 1.75;
  color: var(--text-main);
  min-height: 180px;
  position: relative;
  user-select: text;
}

.typewriter-content p {
  margin-bottom: 14px;
}

.typewriter-cursor {
  display: inline-block;
  font-weight: 300;
  color: var(--color-terracotta);
  animation: blinkCursor 0.75s infinite;
  margin-left: 2px;
}

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

.action-footer {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.hidden-btn {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.hidden-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.skip-hint {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.skip-hint:hover {
  opacity: 1;
}

/* ========================================================
   ЭКРАН 3: ИНТЕРАКТИВНАЯ КОЛОДА КАРТОЧЕК (3D SWIPE)
   ======================================================== */
.deck-header {
  text-align: center;
  margin-bottom: 20px;
  width: 100%;
}

.deck-counter-badge {
  display: inline-block;
  padding: 5px 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border-gold);
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-terracotta);
  box-shadow: var(--shadow-soft);
  margin-bottom: 8px;
}

.deck-instructions {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  justify-content: center;
  gap: 8px;
}

.deck-instructions .divider {
  color: var(--color-gold);
}

.deck-viewport {
  position: relative;
  width: 100%;
  height: 480px;
  perspective: 1200px;
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: pan-y;
  user-select: none;
}

.deck-cards-stack {
  position: relative;
  width: 320px;
  height: 440px;
}

/* Отдельная карточка */
.deck-card {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-lg);
  cursor: grab;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.45s ease;
  will-change: transform, opacity;
}

.deck-card:active {
  cursor: grabbing;
}

/* Состояния в колоде (эффект глубины стопки) */
.deck-card[data-depth="0"] {
  z-index: 5;
  transform: translateY(0) scale(1);
  box-shadow: var(--shadow-elevated);
  cursor: pointer;
  touch-action: none;
}

.deck-card[data-depth="1"] {
  z-index: 4;
  transform: translateY(8px) scale(0.97);
  opacity: 0.98;
  box-shadow: var(--shadow-soft);
  pointer-events: none;
}

.deck-card[data-depth="2"] {
  z-index: 3;
  transform: translateY(16px) scale(0.94);
  opacity: 0.85;
  box-shadow: var(--shadow-soft);
  pointer-events: none;
}

.deck-card[data-depth="3"],
.deck-card[data-depth="4"],
.deck-card[data-depth="5"] {
  z-index: 2;
  transform: translateY(24px) scale(0.9);
  opacity: 0.6;
  pointer-events: none;
}

/* 3D Переворот (Flip) */
.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-lg);
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform: translate3d(0, 0, 0);
  -webkit-transform: translate3d(0, 0, 0);
}

.deck-card.is-flipped .card-inner,
.album-card.is-flipped .card-inner {
  transform: rotateY(180deg) translate3d(0, 0, 0);
  -webkit-transform: rotateY(180deg) translate3d(0, 0, 0);
}

/* Лицевая и оборотная стороны */
.card-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-lg);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
}

/* ЛИЦЕВАЯ СТОРОНА: ТОЛЬКО СКРУГЛЁННОЕ ФОТО БЕЗ НАДПИСЕЙ */
.card-front {
  transform: rotateY(0deg) translateZ(2px);
  -webkit-transform: rotateY(0deg) translateZ(2px);
  padding: 0;
  background: #faf7f2;
  border: 2.5px solid rgba(255, 255, 255, 0.95);
  box-shadow: inset 0 0 0 1px rgba(207, 107, 68, 0.15);
  border-radius: var(--radius-lg);
  z-index: 2;
}

/* Фотография аккуратно заполняет всю карточку без искажений */
.card-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: calc(var(--radius-lg) - 2px);
  transition: transform 0.4s ease;
  pointer-events: none;
}

.deck-card:hover .card-photo,
.album-card:hover .card-photo {
  transform: scale(1.025);
}

/* ========================================================
   ВИДЕО В КАРТОЧКАХ
   ======================================================== */
.card-front-video {
  position: relative;
  background: #1a1614;
}

.card-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: calc(var(--radius-lg) - 2px);
  pointer-events: none;
  background: #1a1614;
}

/* Серая полупрозрачная кнопка воспроизведения / паузы */
.video-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(30, 26, 24, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 255, 255, 0.45);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: transform 0.25s ease, background 0.25s ease, opacity 0.6s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  opacity: 1;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.video-play-btn:hover {
  background: rgba(30, 26, 24, 0.85);
  transform: translate(-50%, -50%) scale(1.08);
  border-color: rgba(255, 255, 255, 0.75);
}

.video-play-btn:active {
  transform: translate(-50%, -50%) scale(0.94);
}

.video-play-btn .icon-play {
  margin-left: 3px; /* оптическое центрирование треугольника */
  display: block;
}

.video-play-btn .icon-pause {
  display: none;
}

/* Состояние при воспроизведении */
.video-play-btn.is-playing .icon-play {
  display: none;
}

.video-play-btn.is-playing .icon-pause {
  display: block;
}

/* Бейдж видео в углу карточки */
.video-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(30, 26, 24, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  pointer-events: none;
  z-index: 5;
  transition: opacity 0.5s ease;
  opacity: 1;
}

/* Спустя 2 секунды воспроизведения кнопка паузы И надпись "ВИДЕО" в углу полностью скрываются */
.card-front-video.is-dimmed .video-play-btn,
.card-front-video.is-dimmed .video-badge {
  opacity: 0.1;
}

/* На компьютерах при наведении курсора элементы плавно проявляются */
@media (hover: hover) {
  .card-front-video:hover .video-play-btn,
  .card-front-video:hover .video-badge {
    opacity: 1;
  }
}

/* ОБОРОТНАЯ СТОРОНА (Текст при нажатии) */
.card-back {
  transform: rotateY(180deg) translateZ(2px);
  -webkit-transform: rotateY(180deg) translateZ(2px);
  background: #fffdfa;
  padding: 28px 24px;
  justify-content: space-between;
  border: 2px solid var(--color-rose);
  background-image: radial-gradient(var(--border-warm) 0.8px, transparent 0.8px);
  background-size: 16px 16px;
  border-radius: var(--radius-lg);
  z-index: 1;
}

/* Динамическое разделение слоев при перевороте */
.deck-card.is-flipped .card-front,
.album-card.is-flipped .card-front {
  z-index: 1;
}

.deck-card.is-flipped .card-back,
.album-card.is-flipped .card-back {
  z-index: 2;
}

.card-back-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px dashed var(--border-gold);
  padding-bottom: 12px;
}

.card-back-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-ruby);
}

.card-back-icon {
  font-size: 16px;
  color: var(--color-terracotta);
}

.card-back-body {
  font-family: var(--font-main);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-main);
  padding: 14px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex-grow: 1;
}

.card-back-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px dashed var(--border-gold);
  padding-top: 10px;
}

/* ========================================================
   ЭКРАН 5: АЛЬБОМ / КАТАЛОГ ВСЕХ КАРТОЧЕК
   ======================================================== */
.album-header {
  text-align: center;
  margin-bottom: 36px;
}

.album-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--color-ruby);
  margin: 10px 0 8px 0;
}

.album-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  max-width: 540px;
  margin: 0 auto;
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 28px;
  width: 100%;
}

.album-card {
  perspective: 1000px;
  -webkit-perspective: 1000px;
  height: 420px;
  cursor: pointer;
  transition: transform 0.3s ease;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}

.album-card:hover {
  transform: translateY(-6px);
}

.album-card .card-inner {
  height: 100%;
  box-shadow: var(--shadow-soft);
}

.album-card:hover .card-inner {
  box-shadow: var(--shadow-elevated);
}

.album-footer {
  margin-top: 48px;
  display: flex;
  justify-content: center;
}

/* ========================================================
   АДАПТИВНОСТЬ ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ
   ======================================================== */
@media (max-width: 480px) {
  .app-container {
    padding: 16px 12px;
  }

  .glass-panel {
    padding: 28px 18px;
    border-radius: var(--radius-md);
  }

  .passcode-title {
    font-size: 22px;
  }

  .typewriter-content {
    font-size: 17px;
    min-height: 220px;
  }

  .deck-cards-stack {
    width: 290px;
    height: 410px;
  }

  .deck-viewport {
    height: 440px;
  }

  .album-title {
    font-size: 26px;
  }

  .album-grid {
    grid-template-columns: 1fr;
    gap: 22px;
    max-width: 320px;
    margin: 0 auto;
  }
}
