/* Гадание на картах Москвы - Стили */

/* ==========================================================================
   Базовые стили и сброс
   ========================================================================== */

* {
  box-sizing: border-box;
}

:root{
  --script: "Caveat", "Marck Script", cursive;
}

html {
  font-size: 20px;
  line-height: 1.6;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--script);
  background: #8B4513 url('../assets/woodtexture.jpg') repeat;
  color: #2F2F2F;
  min-height: 100vh;
}

/* ==========================================================================
   Контейнеры и сетка
   ========================================================================== */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* ==========================================================================
   Стадии (экраны)
   ========================================================================== */

.stage {
  display: none;
  min-height: 100vh;
  padding: 40px 0;
}

.stage.active {
  display: block;
}

/* ==========================================================================
   Заголовки и текст
   ========================================================================== */

.main-header {
  text-align: center;
  margin-bottom: 60px;
}

.main-header h1 {
  font-size: 2.5rem;
  color: #F5F5DC;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
  margin: 0 0 20px 0;
  font-weight: 700;
}

.slogan {
  font-size: 1.2rem;
  color: #F5F5DC;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.5;
}

/* ==========================================================================
   Сетка карт
   ========================================================================== */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 600px;
  margin: 0 auto;
  perspective: 1000px;
}

.card {
  aspect-ratio: 2/3;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(.22,.61,.36,1);
  transform-style: preserve-3d;
  position: relative;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 8px 16px rgba(0,0,0,0.4);
}

.card:active {
  transform: translateY(-2px) scale(0.98);
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 10px;
  overflow: hidden;
}

.card-back {
  background: #2F4F4F;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-front {
  transform: rotateY(180deg);
  background: #F5F5DC;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-front img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Показываем изображение полностью без обрезки */
}

.card.flipped {
  transform: rotateY(180deg);
}

/* ==========================================================================
   Стадия увеличенной карты с блюром
   ========================================================================== */

.blur-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('../assets/woodtexture.jpg') repeat;
  filter: blur(10px);
  z-index: 1;
}

.enlarged-card-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

/* Контейнер для обеих карт */
.cards-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  position: relative;
}

/* Плавная анимация для левой карты при появлении правой */
.cards-pair .enlarged-card.with-overlay {
  animation: slideLeftSmooth 0.6s ease-out forwards;
}

@keyframes slideLeftSmooth {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-10px); /* Небольшой сдвиг влево */
  }
}

.enlarged-card {
  width: 300px;
  height: 450px;
  border-radius: 15px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.enlarged-card.with-overlay {
  animation: none; /* Убираем анимацию когда появляется описание */
}

.enlarged-card:not(.with-overlay) {
  animation: cardEnlarge 0.8s cubic-bezier(.22,.61,.36,1) forwards;
}

@keyframes cardEnlarge {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.enlarged-card img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Показываем изображение полностью без обрезки */
}

/* ==========================================================================
   Стадия описания поверх карты
   ========================================================================== */

/* Карта с описанием - такого же размера как основная карта */
.overlay-description {
  width: 300px;
  height: 450px;
  background: url('../assets/background.png') no-repeat center;
  background-size: cover;
  border-radius: 15px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 30px 25px;
  text-align: left;
  animation: slideInRight 0.6s ease-out forwards;
  z-index: 3;
  flex-shrink: 0;
  position: relative;
}

@keyframes slideInRight {
  0% {
    transform: translateX(100%);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

.overlay-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.overlay-content h2 {
  color: #8B4513;
  font-size: 1.4rem;
  margin: 0 0 15px 0;
  font-weight: 700;
  text-align: center;
}

.overlay-content p {
  color: #2F2F2F;
  font-size: 0.95rem;
  line-height: 1.3;
  margin: 8px 0;
}

.overlay-share {
  margin-top: auto;
  text-align: center;
}

.overlay-share p {
  font-size: 0.85rem;
  color: #8B4513;
  font-weight: 600;
  margin-bottom: 15px;
}

/* Кнопка CTA вне карты */
.cta-button-outside {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  padding: 15px 30px;
  border: none;
  border-radius: 15px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  background: linear-gradient(135deg, #573721, #ECDBC4);
  color: white;
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
  min-width: 250px;
}

.cta-button-outside:hover {
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
}

/* ==========================================================================
   Описание карты
   ========================================================================== */

.description-container {
  max-width: 800px;
  margin: 0 auto;
  background: url('../assets/background.png') no-repeat center;
  background-size: cover;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  overflow: hidden;
  animation: slideInUp 0.6s ease-out forwards;
  min-height: 600px;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-image-container {
  text-align: center;
  padding: 30px 30px 0;
}

.description-card-image {
  width: 200px;
  height: 300px;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  object-fit: contain; /* Показываем изображение полностью без обрезки */
}

.description-content {
  padding: 30px;
  color: #2F2F2F;
  background: rgba(245, 245, 220, 0.9);
  margin: 20px;
  border-radius: 10px;
  backdrop-filter: blur(2px);
}

.description-content h2 {
  font-size: 2rem;
  color: #8B4513;
  text-align: center;
  margin: 0 0 20px 0;
  font-weight: 700;
}

.description-content p {
  margin: 0 0 15px 0;
  line-height: 1.6;
}

.description-content strong {
  color: #8B4513;
  font-weight: 600;
}

.card-footer {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #D2B48C;
  font-style: italic;
  color: #8B4513;
  text-align: center;
}

/* ==========================================================================
   Кнопки
   ========================================================================== */

.action-buttons {
  padding: 0 30px 20px;
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
  background: rgba(245, 245, 220, 0.9);
  margin: 20px;
  border-radius: 10px;
  backdrop-filter: blur(2px);
}

.cta-button, .secondary-button {
  padding: 15px 30px;
  border: none;
  border-radius: 25px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  min-width: 200px;
}

.cta-button {
  background: linear-gradient(135deg, #FF6B6B, #FF8E53);
  color: white;
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.cta-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
}

.secondary-button {
  background: #8B4513;
  color: #F5F5DC;
  box-shadow: 0 4px 15px rgba(139, 69, 19, 0.4);
}

.secondary-button:hover {
  transform: translateY(-2px);
  background: #A0522D;
  box-shadow: 0 6px 20px rgba(139, 69, 19, 0.6);
}

/* ==========================================================================
   Блок шаринга
   ========================================================================== */

.share-block {
  padding: 30px;
  background: rgba(230, 211, 183, 0.9);
  border-top: 1px solid #D2B48C;
  text-align: center;
  margin: 20px;
  border-radius: 10px;
  backdrop-filter: blur(2px);
}

.share-block h3 {
  color: #8B4513;
  margin: 0 0 20px 0;
  font-size: 1.3rem;
}

.share-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 15px;
}

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  background: transparent;
  box-shadow: 0 3px 6px rgba(0,0,0,0.2);
  margin: 0 3px;
}

.share-btn img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.vk-btn {
  background: transparent;
}

.telegram-btn {
  background: transparent;
}

.whatsapp-btn {
  background: transparent;
}

.copy-btn, .native-btn {
  background: #6C757D;
}

.share-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.3);
  border-color: #A0522D;
}

.copy-success {
  color: #28A745;
  font-weight: 600;
  margin-top: 10px;
  animation: fadeInOut 2s ease-in-out;
}

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

.share-block.highlighted {
  animation: highlight 1s ease-in-out;
}

@keyframes highlight {
  0%, 100% { background: #E6D3B7; }
  50% { background: #FFE4B5; }
}

/* ==========================================================================
   Финальная стадия для шаринга
   ========================================================================== */

.final-share-container {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
  padding: 40px 20px;
  animation: slideInUp 0.6s ease-out forwards;
}

.final-card-container {
  margin-bottom: 30px;
}

.final-card-image {
  width: 250px;
  height: 375px;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  object-fit: contain; /* Показываем изображение полностью без обрезки */
}

.final-text {
  background: rgba(245, 245, 220, 0.9);
  border-radius: 15px;
  padding: 30px;
  margin: 30px 0;
  backdrop-filter: blur(2px);
}

.final-text p {
  color: #2F2F2F;
  font-size: 1.2rem;
  line-height: 1.5;
  margin: 0 0 15px 0;
}

.final-cta {
  color: #8B4513 !important;
  font-weight: 600;
  font-size: 1.1rem !important;
}

/* ==========================================================================
   Адаптивность
   ========================================================================== */

@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .main-header h1 {
    font-size: 2rem;
  }

  .slogan {
    font-size: 1.1rem;
  }

  .cards-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: 350px;
  }

  .cards-pair {
    gap: 10px;
  }

  .enlarged-card,
  .overlay-description {
    width: 280px;
    height: 420px;
  }

  .overlay-description {
    padding: 25px 20px;
  }

  .overlay-content h2 {
    font-size: 1.5rem;
  }

  .overlay-content p {
    font-size: 1rem;
  }

  .final-card-image {
    width: 200px;
    height: 300px;
  }

  .action-buttons {
    flex-direction: column;
    align-items: center;
  }

  .cta-button, .secondary-button {
    min-width: 250px;
  }

  .share-buttons {
    flex-direction: row;
    justify-content: center;
    gap: 8px;
  }

  .share-btn {
    width: 55px;
    height: 55px;
    min-width: unset;
  }
}

@media (max-width: 480px) {
  .stage {
    padding: 20px 0;
  }

  .main-header {
    margin-bottom: 40px;
  }

  .main-header h1 {
    font-size: 1.8rem;
  }

  .slogan {
    font-size: 1rem;
  }

  .cards-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 320px;
  }

  .cards-pair {
    position: relative;
    justify-content: flex-start;
    gap: 0;
  }

  .enlarged-card,
  .overlay-description {
    width: 250px;
    height: 375px;
  }

  .enlarged-card {
    position: relative;
    z-index: 3;
  }

  .overlay-description {
    position: absolute;
    top: 0;
    right: -15%;
    padding: 20px 15px;
    font-size: 0.85rem;
    z-index: 4;
    animation: slideInFromRight 0.6s ease-out forwards;
  }

  @keyframes slideInFromRight {
    0% {
      transform: translateX(100%);
      opacity: 0;
    }
    100% {
      transform: translateX(0);
      opacity: 1;
    }
  }

  .cta-button-outside {
    bottom: 20px;
    min-width: 200px;
    padding: 12px 25px;
    font-size: 1rem;
  }

  .overlay-content h2 {
    font-size: 1.3rem;
  }

  .overlay-content p {
    font-size: 0.9rem;
  }

  .final-card-image {
    width: 180px;
    height: 270px;
  }

  .final-text {
    margin: 20px 0;
    padding: 20px;
  }

  .share-buttons {
    gap: 6px;
  }

  .share-btn {
    width: 50px;
    height: 50px;
  }

  .share-btn img {
    width: 64px;
    height: 63px;
  }
}

/* ==========================================================================
   Доступность
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Фокус для клавиатурной навигации */
.card:focus,
.cta-button:focus,
.secondary-button:focus,
.share-btn:focus {
  outline: 3px solid #FF6B6B;
  outline-offset: 2px;
}

/* Высокий контраст */
@media (prefers-contrast: high) {
  .slogan,
  .reveal-text {
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
  }

  .card {
    border: 2px solid #000;
  }

  .description-content {
    border: 1px solid #8B4513;
  }
}
