/* ==========================================================================
   Конкурсы - Стили
   ========================================================================== */

/* --- Добавлено для решения проблемы с шапкой/подвалом --- */

/* 1. Сброс стилей (как в style.css) */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 2. Базовые стили для body (как в style.css) */
body {
  font-family: 'Inter', sans-serif; /* Устанавливает шрифт 'Inter' по умолчанию */
  background-color: #ffffff;
  color: #333;
  overflow-x: hidden; /* Убирает горизонтальные полосы прокрутки */
}

/* 3. CSS переменные (как в competitions.css, перемещены в начало) */
:root {
  /* Шрифты */
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-heading: 'Playfair Display', Georgia, serif;

  /* Цвета */
  --color-bg: #ffffff;
  --color-text: #333333;
  --color-accent: #1e88e5;
  --color-light: #eaeff4;
  --color-success: #28a745;
  --color-warning: #ffc107;
  --color-danger: #dc3545;
  --card-bg: #ffffff;

  /* Дополнительные цвета для уникального оформления */
  --competition-solfeggio: #6a11cb;
  --competition-piano: #11998e;
  --competition-instruments: #ff416c;

  /* Размеры и отступы */
  --radius: 12px;
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* Тени */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 6px 20px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* Темная тема */
.dark-mode {
  --color-bg: #121212;
  --color-text: #f5f5f5;
  --color-accent: #64b5f6;
  --color-light: #1e1e1e;
  --card-bg: #1e1e1e;
  --shadow-sm: 0 2px 8px rgba(255, 255, 255, 0.05);
  --shadow-md: 0 4px 12px rgba(255, 255, 255, 0.06);
  --shadow-lg: 0 6px 20px rgba(255, 255, 255, 0.08);
  --shadow-xl: 0 8px 30px rgba(255, 255, 255, 0.12);
}

/* ==========================================================================
   Основные стили для страницы конкурсов
   ========================================================================== */

.page-header {
  text-align: center;
  margin-bottom: var(--spacing-xl);
  padding: var(--spacing-lg) 0;
}

.page-title {
  font-size: 2.5rem;
  font-weight: 600;
  color: var(--color-accent);
  margin-bottom: var(--spacing-sm);
}

.page-description {
  font-size: 1.1rem;
  color: var(--color-text);
  opacity: 0.8;
  max-width: 700px;
  margin: 0 auto;
}

.dark-mode .page-description {
  opacity: 0.9;
}

/* ==========================================================================
   Сетка конкурсов
   ========================================================================== */

.competitions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
}

/* ==========================================================================
   Карточка конкурса (жесткая фиксация всех размеров)
   ========================================================================== */

.competition-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.competition-card-link:hover {
  transform: translateY(-8px);
}

.competition-card {
  background-color: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
  position: relative;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  grid-template-areas: 
    "image"
    "title-first"
    "title-second"
    "description";
  min-height: 500px; /* Жесткая фиксация общей высоты карточки */
  border: 1px solid var(--color-light); /* Тонкие контуры-границы карточек */
}

.competition-card:hover {
  box-shadow: var(--shadow-xl);
  transform: translateY(-8px) scale(1.02); /* Увеличение карточки при наведении */
}

/* Анимация акцента при наведении */
.competition-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--competition-solfeggio), var(--competition-piano), var(--competition-instruments));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
  z-index: 3;
}

.competition-card:hover::before {
  transform: scaleX(1);
}

/* ==========================================================================
   Контейнер изображения (первая ячейка)
   ========================================================================== */

.competition-image-container {
  grid-area: image;
  position: relative;
  overflow: hidden;
  aspect-ratio: 16/9;
  background-color: var(--color-light);
  height: 200px; /* Жесткая фиксация высоты изображения */
  border-radius: var(--radius) var(--radius) 0 0; /* Скругление только сверху */
}

.competition-slideshow {
  position: relative;
  width: 100%;
  height: 100%;
}

.slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slide.active {
  opacity: 1;
}

.slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
  border-radius: var(--radius) var(--radius) 0 0; /* Скругление только сверху */
  margin: 0; /* Убираем центрирование */
}

.competition-card-link:hover .slide img {
  transform: scale(1.05);
}

/* Индикаторы слайдов */
.slide-indicators {
  position: absolute;
  bottom: var(--spacing-sm);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: var(--spacing-xs);
  z-index: 2;
}

.indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: all 0.3s ease;
}

.indicator:hover,
.indicator.active {
  background-color: white;
  transform: scale(1.2);
}

/* ==========================================================================
   Статус конкурса (перемещен в правый нижний угол)
   ========================================================================== */

.competition-status {
  position: absolute;
  bottom: var(--spacing-sm);
  right: var(--spacing-sm);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 2;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
}

.status-active {
  background-color: rgba(40, 167, 69, 0.9);
}

.status-upcoming {
  background-color: rgba(30, 136, 229, 0.9);
}

.status-finished {
  background-color: rgba(220, 53, 69, 0.9);
}

/* ==========================================================================
   Начало названия конкурса (вторая ячейка)
   ========================================================================== */

.competition-title-first {
  grid-area: title-first;
  padding: var(--spacing-sm) var(--spacing-md) var(--spacing-xs);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 6rem;
  height: 6rem; /* Жесткая фиксация высоты */
}

.title-first-part {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text);
  line-height: 1.5;
  opacity: 0.7;
  display: block;
  width: 100%;
  text-align: center;
  /* Используем CSS Grid для создания 3 строк с фиксированной высотой */
  display: grid;
  grid-template-rows: 1fr 1fr 1fr;
  align-items: center;
  justify-items: center;
  height: 100%; /* Жесткая фиксация высоты */
}

.title-first-part span {
  display: block;
  word-wrap: break-word;
  overflow-wrap: break-word;
  text-align: center;
  line-height: 1.5;
  font-size: 0.95rem;
  font-weight: 500;
  opacity: 0.7;
  align-self: center; /* Центрируем по вертикали */
  justify-self: center; /* Центрируем по горизонтали */
}

/* ==========================================================================
   Название конкурса (третья ячейка)
   ========================================================================== */

.competition-title-second {
  grid-area: title-second;
  padding: var(--spacing-xs) var(--spacing-md) var(--spacing-sm);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.5rem;
  height: 3.5rem; /* Жесткая фиксация высоты */
  margin-top: var(--spacing-xs); /* Жестко зафиксированный отступ сверху */
  margin-bottom: var(--spacing-xs); /* Жестко зафиксированный отступ снизу */
}

.title-second-part {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.4;
  font-style: italic;
  display: block;
  width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
  text-align: center;
  height: 100%; /* Жесткая фиксация высоты */
  display: flex;
  align-items: center;
  justify-content: center;
}

.dark-mode .title-second-part {
  opacity: 1;
}

/* ==========================================================================
   Описание конкурса (четвертая ячейка)
   ========================================================================== */

.competition-description-container {
  grid-area: description;
  padding: 0 var(--spacing-md) var(--spacing-md); /* Увеличили отступы по бокам и снизу */
  display: flex;
  align-items: flex-start;
  min-height: 100px; /* Минимальная высота для описания */
  transition: all 0.3s ease; /* Добавляем плавный переход */
}

.competition-description {
  color: var(--color-text);
  opacity: 0.85;
  line-height: 1.65;
  flex-grow: 1;
  display: -webkit-box;
  -webkit-line-clamp: 6; /* Увеличили количество строк для описания */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.95rem;
  height: 100%; /* Жесткая фиксация высоты */
  width: 100%; /* Сделаем по ширине карточки */
  text-align: left; /* Выравнивание текста по левому краю */
}

/* Раскрытие описания при наведении */
.competition-card:hover .competition-description {
  -webkit-line-clamp: unset; /* Отменяем ограничение строк при наведении */
  overflow: visible; /* Показываем весь текст */
  text-overflow: clip; /* Убираем многоточие */
}

.competition-card:hover .competition-description-container {
  min-height: 150px; /* Увеличиваем высоту области описания при наведении */
}

.dark-mode .competition-description {
  opacity: 0.9;
}

/* ==========================================================================
   Стили для акцентных цветов по категории
   ========================================================================== */

/* Сольфеджио */
.competition-card[data-category="Сольфеджио"]::before {
  background: linear-gradient(90deg, var(--competition-solfeggio), #2575fc);
}

/* Фортепиано */
.competition-card[data-category="Фортепиано"]::before {
  background: linear-gradient(90deg, var(--competition-piano), #38ef7d);
}

/* Инструменты */
.competition-card[data-category="Инструменты"]::before {
  background: linear-gradient(90deg, var(--competition-instruments), #ff416c);
}

/* ==========================================================================
   Пустое состояние
   ========================================================================== */

.no-competitions {
  text-align: center;
  padding: var(--spacing-xl) var(--spacing-lg);
  color: var(--color-text);
  opacity: 0.7;
}

.no-competitions .empty-icon {
  font-size: 4rem;
  margin-bottom: var(--spacing-md);
  color: var(--color-light);
}

.no-competitions h3 {
  font-size: 1.5rem;
  margin-bottom: var(--spacing-sm);
  color: var(--color-text);
}

.no-competitions p {
  font-size: 1.1rem;
  color: var(--color-text);
  opacity: 0.8;
}

/* ==========================================================================
   Адаптивный дизайн для мобильных устройств
   ========================================================================== */

/* --- Общие стили для мобильных --- */
@media (max-width: 768px) {
  /* Основной заголовок */
  .page-header {
    padding: var(--spacing-md) var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
  }

  .page-title {
    font-size: 1.8rem;
  }

  .page-description {
    font-size: 0.95rem;
    padding: 0 var(--spacing-xs);
  }

  /* Сетка конкурсов */
  .competitions-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
    padding: 0 var(--spacing-xs);
  }

  /* Карточка конкурса */
  .competition-card {
    min-height: auto;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas: 
      "image"
      "title-first"
      "title-second"
      "description";
  }

  .competition-card-link:hover {
    transform: none; /* Убираем hover-эффект на мобильных */
  }

  /* Изображение */
  .competition-image-container {
    aspect-ratio: 16/9;
    height: auto;
    max-height: 200px;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  .slide img {
    border-radius: var(--radius) var(--radius) 0 0;
  }

  .slide-indicators {
    bottom: var(--spacing-xs);
    left: 50%;
    transform: translateX(-50%);
  }

  .indicator {
    width: 8px;
    height: 8px;
  }

  .competition-status {
    font-size: 0.7rem;
    padding: var(--spacing-xs) var(--spacing-sm);
    bottom: var(--spacing-xs);
    right: var(--spacing-xs);
  }

  /* Заголовки */
  .competition-title-first {
    padding: var(--spacing-sm);
    min-height: auto;
    height: auto;
  }

  .title-first-part {
    font-size: 0.9rem;
    line-height: 1.4;
    opacity: 0.8;
    display: grid;
    grid-template-rows: 1fr 0fr 0fr; /* Изменённый параметр */
    align-items: center;
    justify-items: center;
    height: 100%;
  }

  .title-first-part span {
    display: block;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-align: center;
    line-height: 1.5;
    font-size: 0.95rem;
    font-weight: 500;
    opacity: 0.7;
    align-self: center; /* Центрируем по вертикали */
    justify-self: center; /* Центрируем по горизонтали */
  }

  .competition-title-second {
    padding: var(--spacing-xs) var(--spacing-sm) var(--spacing-sm);
    min-height: auto;
    height: auto;
    margin-top: var(--spacing-xs);
    margin-bottom: var(--spacing-xs);
  }

  .title-second-part {
    font-size: 1.2rem;
    line-height: 1.4;
  }

  /* Описание */
  .competition-description-container {
    padding: 0 var(--spacing-sm) var(--spacing-sm);
  }

  .competition-description {
    font-size: 0.9rem;
    line-height: 1.6;
    -webkit-line-clamp: 4; /* Уменьшено количество строк */
  }

  /* При hover (если поддерживается) */
  .competition-card:hover .competition-description {
    -webkit-line-clamp: unset;
  }

  .competition-card:hover .competition-description-container {
    min-height: auto;
  }
}

/* --- Дополнительная адаптация для очень узких экранов (до 320px) --- */
@media (max-width: 320px) {
  .page-title {
    font-size: 1.6rem;
  }

  .page-description {
    font-size: 0.9rem;
  }

  .competitions-grid {
    gap: var(--spacing-sm);
    padding: 0;
  }

  .competition-card {
    margin: 0 var(--spacing-xs);
  }

  .competition-image-container {
    max-height: 160px;
  }

  .title-first-part {
    font-size: 0.85rem;
    grid-template-rows: 1fr 0fr 0fr; /* Изменённый параметр */
  }

  .title-second-part {
    font-size: 1.1rem;
  }

  .competition-description {
    font-size: 0.85rem;
    -webkit-line-clamp: 3;
  }

  .competition-status {
    font-size: 0.65rem;
    padding: var(--spacing-xs) var(--spacing-xs);
  }

  .indicator {
    width: 7px;
    height: 7px;
  }
}

/* --- Дополнительные улучшения UX для мобильных --- */
@media (max-width: 768px) {
  /* Увеличиваем размер сенсорных элементов */
  .competition-card-link {
    touch-action: manipulation;
  }

  .indicator,
  .competition-status {
    min-height: 24px;
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Убираем лишние эффекты при наведении */
  .competition-card:hover {
    transform: none;
    box-shadow: var(--shadow-md);
  }

  .competition-card::before {
    display: none; /* Убираем градиентную линию на мобильных */
  }
}

/* ==========================================================================
   Анимации
   ========================================================================== */

.competition-card {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.6s ease-out forwards;
}

.competition-card:nth-child(1) { animation-delay: 0.1s; }
.competition-card:nth-child(2) { animation-delay: 0.2s; }
.competition-card:nth-child(3) { animation-delay: 0.3s; }

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}