/* Основные стили для контейнера */
.articles-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 30px 20px;
}

/* Основная структура заголовка */
.articles-header {
  display: grid;
  grid-template-columns: auto minmax(200px, 1fr) auto;
  grid-template-areas: "title search button";
  grid-gap: 20px;
  align-items: center;
  margin-bottom: 30px;
  width: 100%;
}

.articles-actions {
  display: contents; /* Это важно - элемент не будет создавать свою собственную сетку */
}

.articles-title {
  grid-area: title;
  color: #fff;
  font-size: 2.5rem;
  margin: 0;
  text-shadow: 0 2px 10px rgba(255, 0, 0, 0.3);
  position: relative;
  display: inline-block;
}

.articles-title::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 0;
  width: 60%;
  height: 3px;
  background: linear-gradient(90deg, #ff0000, transparent);
  border-radius: 2px;
}

.articles-search {
  grid-area: search;
  position: relative;
  width: 100%;
}

.articles-search input {
  display: block;
  width: 100%;
  box-sizing: border-box; /* Критически важно */
  padding: 12px 40px 12px 20px; /* Учитываем место для иконки справа */
  background-color: rgba(40, 44, 52, 0.7);
  border: 1px solid #444;
  border-radius: 30px;
  color: #fff;
  font-size: 16px;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
  margin: 0; /* Обнуляем возможные маргины */
}

.articles-search input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.5);
  background-color: rgba(50, 54, 62, 0.8);
}

.search-icon {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: #888;
  pointer-events: none;
}

/* Стиль для кнопки создания статьи */
.create-article-btn {
  grid-area: button;
  background-color: #dc3545;
  color: white;
  padding: 10px 20px;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  justify-content: center;
  min-width: 150px;
  transition: all 0.3s ease;
}

.create-article-btn:hover {
  background-color: #c82333;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}

.create-article-btn:active {
  transform: translateY(0);
}

/* Добавляем иконку "+" перед текстом (опционально) */
.create-article-btn::before {
  content: "+";
  font-size: 1.2em;
  margin-right: 6px;
  font-weight: bold;
}

/* Сетка статей */
.articles-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 30px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s ease, transform 0.8s ease, visibility 0.8s ease;
  visibility: hidden;
}

.articles-list.loaded {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

/* Карточка статьи */
.article-preview {
  opacity: 0;
  transform: translateY(30px);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              opacity 0.4s ease,
              box-shadow 0.3s ease;
  perspective: 1000px;
}

.article-preview.visible {
  opacity: 1;
  transform: translateY(0);
}

.article-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: rgba(32, 35, 42, 0.8);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
  transition: transform 0.4s ease;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.article-preview:hover .article-inner {
  transform: translateY(-10px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.25),
              0 0 15px rgba(0, 123, 255, 0.2);
}

/* Изображение статьи */
.article-header {
  position: relative;
  overflow: hidden;
}

.image-container {
  position: relative;
  width: 100%;
  padding-top: 100%; /* Квадратный контейнер (1:1) */
  overflow: hidden;
  background-color: #1a1d23; /* Фон для областей без изображения */
}

.article-header img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain; /* Показывает всё изображение без обрезки */
  object-position: center; /* Центрирует изображение */
  background-color: #1a1d23; /* Фон вокруг изображения, если есть пустое пространство */
  padding: 0; /* Убираем отступы */
  transition: filter 0.4s ease; /* Анимация только для эффектов фильтра */
}

.article-preview:hover .article-header img {
  filter: brightness(1.1) contrast(1.05); /* Слегка увеличиваем яркость и контраст */
  transform: none; /* Убираем масштабирование */
}

.image-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 2;
  pointer-events: none;
}

.image-container::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 30%; /* Высота градиента */
  background: linear-gradient(to top,
                rgba(26, 29, 35, 0.8) 0%,
                rgba(26, 29, 35, 0) 100%);
  z-index: 1;
}

.article-category {
  position: absolute;
  top: 15px;
  right: 15px;
  background: linear-gradient(135deg, #007bff, #0056b3);
  color: white;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  z-index: 3;
}

/* Контент статьи */
.article-content {
  padding: 20px;
  flex-grow: 1;
}

.article-title {
  margin: 0 0 15px 0;
  font-size: 1.3rem;
  color: #fff;
  line-height: 1.4;
  transition: color 0.3s ease;
}

.article-preview:hover .article-title {
  color: #007bff;
}

.article-description {
  color: #b6b5b5;
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* Футер статьи */
.article-footer {
  background-color: rgba(40, 44, 52, 0.7);
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.article-meta {
  font-size: 0.85rem;
  color: #8f9095;
}

.article-author {
  font-weight: 500;
  color: #a0a0a5;
}

.article-btn {
  display: inline-block;
  background: linear-gradient(135deg, #007bff, #0056b3);
  color: white;
  border: none;
  padding: 8px 20px;
  border-radius: 30px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 123, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.article-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.7s ease;
}

.article-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 123, 255, 0.4);
}

.article-btn:hover::before {
  left: 100%;
}

/* Сообщение об отсутствии статей */
.no-articles {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: #8f9095;
  background: rgba(40, 44, 52, 0.6);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.no-articles p:first-child {
  font-size: 1.5rem;
  margin-bottom: 15px;
  color: #b6b5b5;
}

/* === АДАПТИВНЫЕ СТИЛИ === */

@media (max-width: 1200px) {
  .articles-list {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
}

@media (max-width: 992px) {
  .articles-container {
    padding: 25px 15px;
  }
  
  .articles-header {
    grid-template-columns: 1fr;
    grid-template-areas: 
      "title"
      "search"
      "button";
    grid-gap: 15px;
    text-align: center;
  }
  
  .articles-title {
    font-size: 2.2rem;
    justify-self: center;
  }
  
  .articles-search {
    justify-self: stretch;
  }
  
  .create-article-btn {
    justify-self: center;
    min-width: 200px;
    padding: 12px 24px;
  }
  
  .articles-list {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 25px;
  }
}

@media (max-width: 768px) {
  .articles-container {
    padding: 20px 12px;
  }
  
  .articles-header {
    margin-bottom: 25px;
  }
  
  .articles-title {
    font-size: 1.8rem;
  }
  
  .articles-title::after {
    width: 50%;
    bottom: -8px;
  }
  
  .articles-search input {
    padding: 14px 40px 14px 16px;
    font-size: 16px; /* Предотвращает zoom на iOS */
  }
  
  .create-article-btn {
    width: 100%;
    max-width: 300px;
    padding: 14px 20px;
    font-size: 1rem;
  }
  
  .articles-list {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
  }
  
  .article-content {
    padding: 16px;
  }
  
  .article-title {
    font-size: 1.2rem;
    margin-bottom: 12px;
  }
  
  .article-description {
    font-size: 0.9rem;
    -webkit-line-clamp: 2;
  }
  
  .article-footer {
    padding: 12px 16px;
  }
  
  .article-category {
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    font-size: 0.75rem;
  }
  
  .no-articles {
    padding: 40px 15px;
  }
  
  .no-articles p:first-child {
    font-size: 1.3rem;
  }
}

@media (max-width: 480px) {
  .articles-container {
    padding: 15px 8px;
  }
  
  .articles-title {
    font-size: 1.5rem;
  }
  
  .articles-search input {
    padding: 12px 35px 12px 14px;
    border-radius: 25px;
  }
  
  .search-icon {
    right: 12px;
  }
  
  .create-article-btn {
    padding: 12px 18px;
    min-width: auto;
    width: 100%;
  }
  
  .articles-list {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .article-content {
    padding: 14px;
  }
  
  .article-title {
    font-size: 1.1rem;
    line-height: 1.3;
  }
  
  .article-description {
    font-size: 0.85rem;
    line-height: 1.5;
  }
  
  .article-footer {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    padding: 14px;
  }
  
  .article-meta {
    align-self: center;
    font-size: 0.8rem;
  }
  
  .article-btn {
    align-self: stretch;
    text-align: center;
    padding: 12px 20px;
    border-radius: 25px;
  }
  
  .article-category {
    top: 10px;
    right: 10px;
    padding: 3px 8px;
    font-size: 0.7rem;
  }
  
  .image-container {
    padding-top: 75%; /* Менее квадратный на мобильных */
  }
}

@media (max-width: 360px) {
  .articles-container {
    padding: 12px 6px;
  }
  
  .articles-title {
    font-size: 1.3rem;
  }
  
  .articles-search input {
    padding: 10px 32px 10px 12px;
    font-size: 14px;
  }
  
  .create-article-btn {
    padding: 10px 15px;
    font-size: 0.9rem;
  }
  
  .article-content {
    padding: 12px;
  }
  
  .article-title {
    font-size: 1rem;
    margin-bottom: 10px;
  }
  
  .article-description {
    font-size: 0.8rem;
  }
  
  .article-footer {
    padding: 12px;
  }
  
  .article-btn {
    padding: 10px 16px;
    font-size: 0.85rem;
  }
  
  .no-articles {
    padding: 30px 10px;
  }
  
  .no-articles p:first-child {
    font-size: 1.1rem;
  }
}

/* =====================================================
   STYLE OVERRIDE — align articles with site palette
   accent: #dc3545 | replace all #007bff / #ff0000 blues
   ===================================================== */

.articles-title {
  text-shadow: 0 2px 10px rgba(220, 53, 69, 0.3);
}

.articles-title::after {
  background: linear-gradient(90deg, #dc3545, transparent);
}

.articles-search input:focus {
  box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.4);
  background-color: rgba(20, 22, 30, 0.9);
  border-color: rgba(220, 53, 69, 0.4);
}

.article-inner {
  background-color: rgba(12, 14, 20, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  backdrop-filter: none;
}

.article-preview:hover .article-inner {
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4),
              0 0 15px rgba(220, 53, 69, 0.15);
}

.image-container {
  background-color: rgba(10, 12, 18, 0.95);
}

.article-header img {
  background-color: rgba(10, 12, 18, 0.95);
}

.image-container::after {
  background: linear-gradient(to top,
                rgba(12, 14, 20, 0.85) 0%,
                rgba(12, 14, 20, 0) 100%);
}

.article-category {
  background: linear-gradient(135deg, #dc3545, #b91c2c);
  box-shadow: 0 2px 10px rgba(220, 53, 69, 0.25);
}

.article-preview:hover .article-title {
  color: #f87171;
}

.article-footer {
  background-color: rgba(10, 12, 18, 0.7);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.article-btn {
  background: linear-gradient(135deg, #dc3545, #b91c2c);
  box-shadow: 0 4px 15px rgba(220, 53, 69, 0.25);
  color: white;
}

.article-btn:hover {
  box-shadow: 0 8px 20px rgba(220, 53, 69, 0.4);
  color: white;
}

.no-articles {
  background: rgba(12, 14, 20, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.07);
  backdrop-filter: none;
}

.articles-search input {
  background-color: rgba(12, 14, 20, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e8e8e8;
}

/* Touch-устройства */
@media (hover: none) and (pointer: coarse) {
  .article-btn,
  .create-article-btn {
    min-height: 44px;
    min-width: 44px;
  }
  
  .articles-search input {
    min-height: 44px;
  }
  
  /* Отключаем hover эффекты */
  .article-preview:hover .article-inner,
  .article-preview:hover .article-title,
  .article-preview:hover .article-header img,
  .article-btn:hover,
  .create-article-btn:hover {
    transform: none;
    filter: none;
    color: inherit;
    background: inherit;
    box-shadow: inherit;
  }
}