/**
 * Module: Category Grid Styles
 */

/* ===================================
   CATEGORY GRID MODULE
   =================================== */

.mod-category-grid,
.category-grid {
  margin: var(--tcp-space-12) 0;
}

/* Dual Layout (2 categories side by side) */
.category-grid-dual {
  display: flex;
  gap: var(--tcp-space-8);
}

.category-grid-dual .category-section {
  flex: 1;
  min-width: 0; /* Prevent overflow */
}

/* Single Layout (1 category full width) */
.category-grid-single {
  display: block;
}

/* Category Section */
.category-section {
  display: flex;
  flex-direction: column;
  gap: 0 var(--tcp-space-4);
}

/* Category Posts Container */
.category-posts {
  display: grid;
  gap: var(--tcp-space-8);
}

.category-posts > *,
.category-grid-dual > * {
  position: relative;
}

.category-posts > *:not(:last-child)::after,
.category-grid-dual > *:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 0;
  right: calc(var(--tcp-space-8) / -2);
  width: 1px;
  height: 100%;
  background-color: var(--tcp-gray-200);
}

.category-grid-dual > *:not(:last-child)::after {
  height: calc(100% - 24px - var(--tcp-space-6));
  top: calc(var(--tcp-space-6) + 24px);
}

/* Default: 1 column (for 1 post per section) */
.category-section.posts-1 .category-posts {
  grid-template-columns: 1fr;
}

/* 2 columns (for 2 posts per section in dual mode) */
.category-grid-dual .category-section.posts-2 .category-posts {
  grid-template-columns: repeat(2, 1fr);
}

/* For single category with 3 or 4 posts, show them in a grid */
.category-grid-single .category-posts {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* Grid Item */
.grid-item {
  display: flex;
  flex-direction: column;
  background: var(--tcp-white);
}

/* Grid Item Image */
.grid-item-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--tcp-gray-200);
  margin-bottom: var(--tcp-space-4);
}

.grid-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.grid-item-image a:hover img {
  transform: scale(1.05);
}

/* Grid Item Content */
.grid-item-content {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.grid-item-title {
  font-family: var(--tcp-font-display);
  font-size: var(--tcp-text-base);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: var(--tcp-space-1);
  margin-top: 0;
}

.posts-1 .grid-item-title,
.posts-2 .grid-item-title {
  font-size: var(--tcp-text-xl);
}

.grid-item-title a {
  color: var(--tcp-dark);
  text-decoration: none;
  transition: color 0.3s ease;
}

.grid-item-title a:hover {
  color: var(--tcp-primary);
}

.grid-item-date {
  font-family: var(--tcp-font-primary);
  font-size: var(--tcp-text-sm);
  color: var(--tcp-gray-500);
  font-style: italic;
  display: block;
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

@media (max-width: 1024px) {
  .category-grid-dual {
    flex-direction: column;
  }

  /* En tablet, mantener 2 columnas para posts-2 */
  .category-grid-dual .category-section.posts-2 .category-posts {
    grid-template-columns: repeat(2, 1fr);
  }

  .category-grid-single .category-posts {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .mod-category-grid {
    margin: var(--tcp-space-8) 0;
  }

  /* En mobile, todo a 1 columna */
  .category-grid-dual,
  .category-grid-single .category-posts,
  .category-grid-dual .category-section.posts-2 .category-posts {
    grid-template-columns: 1fr;
  }

  .category-title {
    font-size: var(--tcp-text-xl);
  }

  .grid-item-title {
    font-size: var(--tcp-text-lg);
  }

  .grid-item-excerpt {
    font-size: var(--tcp-text-sm);
  }
}

@media (max-width: 480px) {
  .mod-category-grid {
    margin: var(--tcp-space-6) 0;
  }

  .category-posts {
    gap: var(--tcp-space-4);
  }

  .category-section {
    gap: var(--tcp-space-3);
  }

  .category-title {
    font-size: var(--tcp-text-lg);
  }

  .grid-item-title {
    font-size: var(--tcp-text-base);
  }

  .grid-item-image {
    margin-bottom: var(--tcp-space-3);
  }
}
