/**
 * COTEC — Posts
 *
 * Grelha editorial. As variáveis podem ser substituídas pelo tema.
 */

.cotec-posts {
  --cotec-posts-accent: var(--cotec-color-red);
  --cotec-posts-accent-hover: var(--cotec-color-salmon);
  --cotec-posts-button-color: var(--cotec-color-white);
  --cotec-posts-text: inherit;
  --cotec-posts-text-muted: var(--cotec-color-muted);
  --cotec-posts-column-gap: clamp(24px, 3vw, 42px);
  --cotec-posts-row-gap: clamp(40px, 5vw, 64px);
  --cotec-posts-image-ratio: 3 / 2;
  margin: 0 auto;
  color: var(--cotec-posts-text);
}

.cotec-posts__grid {
  display: grid;
  grid-template-columns: repeat(var(--cotec-posts-columns, 3), minmax(0, 1fr));
  column-gap: var(--cotec-posts-column-gap);
  row-gap: var(--cotec-posts-row-gap);
}

.cotec-posts--columns-1 {
  --cotec-posts-columns: 1;
  --cotec-posts-image-ratio: 2 / 1;
}

.cotec-posts--columns-1 .cotec-posts__grid {
  max-width: 960px;
  margin-inline: auto;
}

.cotec-posts--columns-2 {
  --cotec-posts-columns: 2;
  --cotec-posts-image-ratio: 16 / 9;
}

.cotec-posts--columns-3 {
  --cotec-posts-columns: 3;
  --cotec-posts-image-ratio: 3 / 2;
}

.cotec-posts--columns-4 {
  --cotec-posts-columns: 4;
  --cotec-posts-image-ratio: 4 / 3;
  --cotec-posts-column-gap: clamp(18px, 2vw, 30px);
}

.cotec-posts__card {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.cotec-posts__thumbnail {
  display: block;
  overflow: hidden;
}

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

.cotec-posts__thumbnail:hover img {
  transform: scale(1.02);
}

.cotec-posts__thumbnail:focus-visible {
  outline: 3px solid var(--cotec-posts-accent);
  outline-offset: 3px;
}

.cotec-posts__body {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  padding-top: clamp(16px, 2vw, 22px);
}

.cotec-posts__date {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  color: var(--cotec-posts-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.3;
}

.cotec-posts__date::before {
  width: 24px;
  height: 2px;
  flex: 0 0 24px;
  background: var(--cotec-posts-accent);
  content: "";
}

.cotec-posts__title {
  margin: 0 0 12px;
  padding: 0;
  font-size: clamp(1.2rem, 1.7vw, 1.55rem);
  font-weight: 700;
  line-height: 1.22;
  text-wrap: balance;
}

.cotec-posts--columns-1 .cotec-posts__title {
  font-size: clamp(1.5rem, 2.4vw, 2rem);
}

.cotec-posts--columns-4 .cotec-posts__title {
  font-size: clamp(1.05rem, 1.35vw, 1.25rem);
}

.cotec-posts__title a {
  color: inherit;
  text-decoration: none;
}

.cotec-posts__title a:hover,
.cotec-posts__title a:focus-visible {
  color: var(--cotec-posts-accent);
  text-decoration: none;
}

.cotec-posts__title a:focus-visible {
  outline: 2px solid var(--cotec-posts-accent);
  outline-offset: 3px;
}

.cotec-posts__excerpt {
  flex: 1;
  margin: 0 0 20px;
  color: var(--cotec-posts-text-muted);
  font-size: clamp(0.98rem, 1.2vw, 1.08rem);
  line-height: 1.55;
}

.cotec-posts--columns-4 .cotec-posts__excerpt {
  font-size: 0.95rem;
}

.cotec-posts__card-button {
  display: inline-flex;
  width: fit-content;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  margin-top: auto;
  padding: 10px 18px;
  border-radius: 2px;
  background: var(--cotec-posts-accent);
  color: var(--cotec-posts-button-color) !important;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.cotec-posts__card-button:hover,
.cotec-posts__card-button:focus-visible {
  background: var(--cotec-posts-accent-hover);
  color: var(--cotec-posts-button-color) !important;
  text-decoration: none;
  transform: translateY(-1px);
}

.cotec-posts__card-button:focus-visible {
  outline: 3px solid var(--cotec-posts-accent);
  outline-offset: 3px;
}

.cotec-posts__archive-button {
  display: flex;
  width: fit-content;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  margin: clamp(32px, 4vw, 52px) auto 0;
  padding: 8px 0 5px;
  border-bottom: 2px solid currentColor;
  color: inherit;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  transition: color 0.2s ease;
}

.cotec-posts__archive-button:hover,
.cotec-posts__archive-button:focus-visible {
  color: var(--cotec-posts-accent);
  text-decoration: none;
}

.cotec-posts__archive-button:focus-visible {
  outline: 2px solid var(--cotec-posts-accent);
  outline-offset: 4px;
}

@media (max-width: 1024px) {
  .cotec-posts--columns-3,
  .cotec-posts--columns-4 {
    --cotec-posts-columns: 2;
    --cotec-posts-image-ratio: 16 / 9;
  }
}

@media (max-width: 768px) {
  .cotec-posts {
    --cotec-posts-columns: 1;
    --cotec-posts-image-ratio: 16 / 10;
    --cotec-posts-row-gap: 42px;
  }

  .cotec-posts__title,
  .cotec-posts--columns-1 .cotec-posts__title,
  .cotec-posts--columns-4 .cotec-posts__title {
    font-size: clamp(1.25rem, 5.5vw, 1.6rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cotec-posts__thumbnail img,
  .cotec-posts__card-button,
  .cotec-posts__archive-button {
    transition: none;
  }

  .cotec-posts__card-button:hover,
  .cotec-posts__card-button:focus-visible {
    transform: none;
  }
}
