/* CSS Custom Properties */
:root {
  --article-spacing-xs: 4px;
  --article-spacing-sm: 6px;
  --article-spacing-md: 12px;
  --article-spacing-lg: 16px;
  --article-spacing-xl: 24px;
  --article-spacing-2xl: 32px;
  --article-border-radius: 10px;
  --article-border-radius-sm: 6px;
  --article-border-radius-xs: 4px;
  --article-font-size-sm: 11px;
  --article-font-size-md: 12px;
  --article-font-size-lg: 14px;
  --article-font-size-xl: 1.1rem;
  --article-font-size-2xl: 1.2rem;
  --article-font-size-3xl: 1.3rem;
  --article-font-size-4xl: 1.35rem;
  --article-font-size-5xl: 2.25rem;
  --article-transition: all 0.3s ease;
  --article-transform-hover: translateY(-3px);
  --article-transform-active: translateY(0);
  --article-color-muted: #b5b5b5;
  --article-color-error: #c00;
  --article-color-error-bg: #fff0f0;
  --article-color-empty: #666;
  --article-color-empty-bg: #f9f9f9;
  --article-color-dark: rgb(47 47 47);
  --grid-container-width: 1200px;
  --bg-color-1: #191b22;
  --bg-color-2: #272b36;
  --card-background-color: var(--bg-color-1);
}

/* Base Container */
.article-feed-container {
  h1 {
    font-size: var(--article-font-size-5xl);
    font-weight: 600;
    margin-bottom: 2em;
    text-align: center;
    letter-spacing: -1px;
  }

  h1 a {
    text-decoration: none;
    color: var(--text-color);
  }

  h1 a:hover {
    text-decoration: none;
    color: var(--text-color);
  }

  h2 {
    font-size: var(--article-font-size-5xl);
    font-weight: 600;
    letter-spacing: -1px;
  }
}

/* Main Article Feed */
.article-feed {
  h2 {
    font-weight: 400;
    font-size: 20px;
    line-height: 24px;
    padding: var(--article-spacing-2xl) 0 var(--article-spacing-lg);
    margin: 0;
  }

  .article-feed-list {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .article-feed-article {
    margin-bottom: var(--article-spacing-xl);
  }

  .article-feed-empty,
  .article-feed-error {
    padding: var(--article-spacing-xl);
    text-align: center;
    border-radius: var(--article-border-radius-xs);
    margin: var(--article-spacing-xl) 0;
  }

  .article-feed-empty {
    color: var(--article-color-empty);
    font-style: italic;
    background-color: var(--article-color-empty-bg);
  }

  .article-feed-error {
    color: var(--article-color-error);
    background-color: var(--article-color-error-bg);
  }

  &.grid {
    max-width: var(--grid-container-width);
    margin: 0 auto;

    .article-feed-list {
      display: grid;
      gap: var(--article-spacing-md);
    }
  }
}

/* Article Image */
.article-feed-article-image-link {
  display: block;
  position: relative;
  padding-bottom: 55.6%; /* 16:9 aspect ratio (800/1440 = 0.556) */
  background-color: var(--card-background-color); /* Apply card background color to image container */

  picture {
    position: absolute;
    inset: 0;
  }

  img {
    object-fit: cover;
    width: 100%;
    height: 100%;
    border-radius: var(--article-border-radius) var(--article-border-radius) 0 0;
    box-shadow: var(--shadow-lg);
  }
}

/* Content Container */
.article-feed-content-container {
  display: flex;
  padding: var(--article-spacing-lg) var(--article-spacing-sm);
}

/* Layout Columns */
.article-feed-left-column {
  flex: 0 0 80%;
  display: flex;
  flex-direction: column;
}

/* Author and Date Metadata */
.article-feed-metadata-container {
  margin-top: var(--article-spacing-sm);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.article-feed-author-container {
  display: flex;
  align-items: center;
  color: var(--article-color-muted);
  font-size: var(--article-font-size-md);
  justify-content: center;
  font-family: var(--heading-font-family);
}

.article-feed-date-container {
  display: flex;
  align-items: center;
  color: var(--article-color-muted);
  font-size: var(--article-font-size-md);
  font-family: var(--heading-font-family);
  justify-content: center;
}

.article-feed-article-author-wrapper {
  display: flex;
  align-items: center;
}

.article-feed-article-date {
  display: inline-block;
}

.article-feed-content-column {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.article-feed-right-column {
  flex: 0 0 20%;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

/* Card Variants Base Styles */
.article-feed.card-2 .article-feed-content-container,
.article-feed.card-3 .article-feed-content-container {
  padding: 28px 20px 32px;
  background-color: inherit;
}

.article-feed.card-4 .article-feed-content-container {
  padding: 16px 8px;
  background-color: inherit;
}

.article-feed.card-2 .article-feed-article,
.article-feed.card-3 .article-feed-article,
.article-feed.card-4 .article-feed-article {
  margin-bottom: 0;
  height: 100%;
}

@keyframes glowPulse {
  0% {
    box-shadow: 0 1px 3px rgb(0 0 0 / 12%), 0 1px 2px rgb(0 0 0 / 24%), 0 0 8px rgb(64 110 12 / 20%);
    border-color: rgb(64 110 12 / 20%);
    background: linear-gradient(to bottom, rgb(64 110 12 / 5%) 0%, rgb(64 110 12 / 0%) 100%);
  }

  50% {
    box-shadow: 0 1px 3px rgb(0 0 0 / 12%), 0 1px 2px rgb(0 0 0 / 24%), 0 0 12px rgb(64 110 12 / 50%);
    border-color: rgb(64 110 12 / 40%);
    background: linear-gradient(to bottom, rgb(64 110 12 / 10%) 0%, rgb(64 110 12 / 2%) 100%);
  }

  100% {
    box-shadow: 0 1px 3px rgb(0 0 0 / 12%), 0 1px 2px rgb(0 0 0 / 24%), 0 0 8px rgb(64 110 12 / 20%);
    border-color: rgb(64 110 12 / 20%);
    background: linear-gradient(to bottom, rgb(64 110 12 / 5%) 0%, rgb(64 110 12 / 0%) 100%);
  }
}

.article-feed.card-2 article,
.article-feed.card-3 article,
.article-feed.card-4 article {
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: var(--article-border-radius);
  overflow: hidden;
  transition: all 0.3s ease;
  background-color: var(--card-background-color);
  text-align: center;
  animation: glowPulse 3s infinite ease-in-out;
}

.article-feed.card-2 article:hover,
.article-feed.card-3 article:hover,
.article-feed.card-4 article:hover {
  transform: translateY(-5px);
  animation-play-state: paused;
  box-shadow: 0 4px 8px rgb(0 0 0 / 20%), 0 3px 6px rgb(0 0 0 / 15%), 0 0 15px rgb(64 110 12 / 70%);
  border-color: rgb(64 110 12 / 60%);
  background: linear-gradient(to bottom, rgb(64 110 12 / 15%) 0%, rgb(64 110 12 / 5%) 100%);
}

.article-feed.card-2 .article-feed-article-image-link,
.article-feed.card-3 .article-feed-article-image-link,
.article-feed.card-4 .article-feed-article-image-link {
  display: block;
  overflow: hidden;
  position: relative;
  padding-bottom: 55.6%; /* 16:9 aspect ratio (800/1440 = 0.556) */
}

.article-feed.card-2 .article-feed-article-image-link img,
.article-feed.card-3 .article-feed-article-image-link img,
.article-feed.card-4 .article-feed-article-image-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.article-feed.card-2 .article-feed-article-image-link:hover img,
.article-feed.card-3 .article-feed-article-image-link:hover img,
.article-feed.card-4 .article-feed-article-image-link:hover img {
  transform: scale(1.05);
}

.article-feed.card-2 .article-feed-content-container,
.article-feed.card-3 .article-feed-content-container,
.article-feed.card-4 .article-feed-content-container {
  background-color: var(--card-background-color);
  flex-grow: 1;
  display: flex;
  align-items: center;
}

.article-feed.card-2 .article-feed-content-column,
.article-feed.card-3 .article-feed-content-column,
.article-feed.card-4 .article-feed-content-column {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.article-feed.card-2 .article-feed-article-title-link,
.article-feed.card-3 .article-feed-article-title-link,
.article-feed.card-4 .article-feed-article-title-link {
  margin-bottom: var(--article-spacing-sm);
  text-decoration: none;
  color: var(--text-color);
}

.article-feed.card-2 .article-feed-article-title-link:hover,
.article-feed.card-3 .article-feed-article-title-link:hover,
.article-feed.card-4 .article-feed-article-title-link:hover {
  color: var(--link-hover-color);
}

.article-feed.card-2 .article-feed-author-date-container,
.article-feed.card-3 .article-feed-author-date-container,
.article-feed.card-4 .article-feed-author-date-container {
  justify-content: center;
}

/* Specific Card Variant Overrides */
.article-feed.card-3 .article-feed-article-title {
  font-size: var(--article-font-size-2xl);
}

.article-feed.card-3 .article-feed-author-date-container {
  font-size: 0.9rem;
}

.article-feed.card-3 .article-feed-tag {
  font-size: var(--article-font-size-sm);
  padding: 3px var(--article-spacing-sm) 2px var(--article-spacing-sm);
}

.article-feed.card-4 .article-feed-article-title {
  font-size: var(--article-font-size-xl);
}

.article-feed.card-4 .article-feed-author-date-container {
  font-size: 1rem;
  justify-content: center;
}

.article-feed.card-4 .article-feed-article-author {
  font-size: 1rem;
}

.article-feed.card-4 .article-feed-article-date {
  font-size: 1rem;
}

/* Smaller tags for card-4 variant */
.article-feed.card-4 .article-feed-tags {
  gap: 4px;
}

.article-feed.card-4 .article-feed-tag {
  font-size: 0.7rem;
  padding: 2px 6px;
}

/* Author and Date Container */
.article-feed-author-date-container {
  display: flex;
  align-items: center;
  margin: 0;
  gap: 10px;
  font-family: var(--heading-font-family);
}

/* Author Wrapper and Links */
.article-feed-article-author-wrapper {
  display: flex;
  gap: var(--article-spacing-sm);
  margin: 0;
}

.article-feed-article-author {
  font-weight: 400;
  font-size: var(--article-font-size-xl);
  letter-spacing: -1px;
  color: var(--text-color);
  text-decoration: none !important;

  &::after {
    margin-left: var(--article-spacing-sm);
    content: "|";
  }

  &:last-child::after {
    display: none;
  }
}

.article-feed-separator {
  margin: 0 5px;
  color: var(--article-color-muted);
  font-weight: 300;
}

.article-feed-article-date {
  font-size: var(--article-font-size-xl);
  color: var(--article-color-muted);
  letter-spacing: -1px;
  margin: 0;
}

/* Tags */
.article-feed-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  padding-top: var(--article-spacing-lg);
  gap: var(--article-spacing-sm);
  margin: 0;
}

.article-feed-tag {
  display: inline-block;
  background-color: rgb(64 110 12 / 15%);
  border-radius: var(--article-border-radius-sm);
  font-weight: 600;
  text-transform: uppercase;
  box-shadow: var(--shadow-sm);
  padding: 1px 6px;
  font-size: var(--article-font-size-md);
  color: var(--link-color);
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.article-feed-tag:hover {
  background-color: rgb(64 110 12 / 30%);
  color: #fff;
}

/* Article Title */
a.article-feed-article-title-link {
  display: block;
  margin: 0;
  color: var(--article-color-dark);
  text-decoration: none;

  &:hover {
    text-decoration: underline;
  }
}

.article-feed-article-title {
  font-weight: 600;
  margin: 0;
  font-size: var(--article-font-size-3xl);
  text-wrap: wrap;
  line-height: 1.3;
  color: var(--link-color);
  letter-spacing: -1px;
}

/* Grid Layouts */
.article-feed.grid .article-feed-list {
  display: grid;
  gap: 20px;
}

.article-feed.card-2 .article-feed-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 36px;
}

.article-feed.card-3 .article-feed-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
}

.article-feed.card-4 .article-feed-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}

/* Load More Button */
.article-feed-load-more-container {
  display: flex;
  justify-content: center;
  margin-top: var(--article-spacing-2xl);
  margin-bottom: var(--article-spacing-lg);
}

.article-feed-load-more-button {
  background-color: var(--link-hover-color);
  color: var(--text-color);
  border: none;
  border-radius: var(--article-border-radius-xs);
  padding: var(--article-spacing-sm) var(--article-spacing-md);
  font-size: var(--article-font-size-2xl);
  font-weight: 600;
  text-transform: uppercase;
  font-family: var(--heading-font-family);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  &:hover {
    background-color: var(--link-color);
    transform: translateY(-2px);
  }

  &:active {
    transform: var(--article-transform-active);
  }
}

/* bg color */
.article-feed.dark article {
  background-color: var(--background-color-2);
  box-shadow: var(--shadow-lg);

  .article-feed-tag {
    background-color: var(--link-color);
    color: var(--background-color);
  }
}

/* Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.article-feed-article.fade-in {
  opacity: 0;
  animation: fadeIn 0.6s ease-out forwards;
}

/* Responsive Design */

/* Force grid layout for all screen sizes */
.article-feed.card-2 .article-feed-list {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
}

.article-feed.card-3 .article-feed-list {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
}

.article-feed.card-4 .article-feed-list {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
}

/* Hide tags in 4-card variant */
.article-feed.card-4 .article-feed-tags {
  display: none;
}

/* Media queries for responsive adjustments */
@media (min-width: 600px) {
  .article-feed.grid .article-feed-list {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Split Template Overrides */
  .split-template .article-feed.grid .article-feed-list,
  .split-template .article-feed.card-2 .article-feed-list,
  .split-template .article-feed.card-3 .article-feed-list,
  .split-template .article-feed.card-4 .article-feed-list {
    grid-template-columns: repeat(1, 1fr);
  }

  .split-template .article-feed.grid .article-feed-article-title,
  .split-template .article-feed.card-2 .article-feed-article-title,
  .split-template .article-feed.card-3 .article-feed-article-title,
  .split-template .article-feed.card-4 .article-feed-article-title {
    font-size: 18px;
  }
}

@media (max-width: 1200px) and (min-width: 768px) {
  .article-feed.card-4 .article-feed-list {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

@media (max-width: 767px) and (min-width: 600px) {
  .article-feed.card-3 .article-feed-list {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .article-feed.card-4 .article-feed-list {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 599px) {
  .article-feed.card-2 .article-feed-list {
    grid-template-columns: repeat(1, 1fr) !important;
  }

  .article-feed.card-3 .article-feed-list {
    grid-template-columns: repeat(1, 1fr) !important;
  }

  .article-feed.card-4 .article-feed-list {
    grid-template-columns: repeat(1, 1fr) !important;
  }
}
