/* ========================================
   ARTICLE.CSS - MOBILE RESPONSIVE STYLES
   ======================================== */

/* Responsive design for popular articles */
@media (max-width: 768px) {
  .popular-articles-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0 0.5rem;
  }

  .section-title {
    font-size: 2rem;
  }

  .popular-article {
    height: 200px;
    min-height: 200px;
  }

  .popular-article-content {
    padding: 1rem;
  }

  .popular-article-content h3 {
    font-size: 1rem;
  }

  .popular-preview {
    font-size: 0.8rem;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }
}

/* ========================================
   RESPONSIVE STYLES
   ======================================== */

/* Small devices (phones, 600px and down) */
@media only screen and (max-width: 600px) {
  * {
    box-sizing: border-box;
  }

  .home-articles {
    display: flex;
    flex-direction: column;
    height: auto;
    gap: 50px;
    justify-content: space-between;
    padding: 0;
  }

  .articleList {
    border-style: double;
    border-radius: 8px;
    order: 2;
    width: 100%;
    height: auto;
    text-align: center;
    margin-top: -15px;
  }

  .articleList li {
    margin-bottom: 10px;
  }

  .article-section-latest {
    order: 1;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
    padding: 0 1rem;
  }

  /* Make Latest Articles look like Most Liked grid layout on mobile */
  .latest-content {
    display: grid !important;
    grid-template-columns: 1fr;
    grid-template-rows: 300px auto;
    gap: 10px;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
  }

  /* Main article spans full width */
  .latest-article-main {
    grid-column: 1;
    grid-row: 1;
    width: 100% !important;
    max-width: 100% !important;
    height: 300px !important;
    min-height: 300px !important;
    margin: 0 !important;
  }

  /* Grid container for smaller articles */
  .latest-grid {
    grid-column: 1;
    grid-row: 2;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 200px;
    gap: 10px;
    flex-direction: unset;
    width: 100%;
  }

  /* Smaller articles side by side */
  .latest-article-small {
    width: 100% !important;
    height: 200px !important;
    min-height: 200px !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  .article-section-side {
    order: 4;
    width: 100%;
    margin: 0;
    height: auto;
    justify-content: center;
  }
  .popular-articles-section {
    order: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .article-section-like,
  .article-section-comment {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 0 1rem;
  }

  /* Overridden by grid layout above - keeping for fallback */
  .latest-article-main {
    height: 300px !important;
    width: 100% !important;
    max-width: 500px !important;
  }

  .latest-article-small {
    height: 200px !important;
    width: 100% !important;
  }

  .popular-articles-grid {
    grid-template-columns: 1fr;
  }

  /* Removed - now using grid layout above */

  .article-section-like,
  .article-section-comment {
    margin-bottom: 20px; /* Add spacing between sections */
  }

  .articleList {
    max-height: 300px; /* Limit the height of the article list */
    overflow-y: auto;
  }

  .articleList li {
    margin-bottom: 10px; /* Adjust spacing between articles */
  }
}

/* Adjustments for Most Liked and Most Commented sections */
@media only screen and (max-width: 600px) {
  .article-section-like,
  .article-section-comment {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px; /* Add spacing between articles */
  }

  .article-section-like .article:nth-child(4),
  .article-section-comment .article:nth-child(4) {
    display: none;
  }

  .popular-articles-section {
    margin-top: 1px; /* Add spacing below Most Liked and Most Commented */
    align-items: center;
  }
}

/* Center align articles for Most Popular section */
@media only screen and (max-width: 600px) {
  .popular-articles-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px; /* Add spacing between articles */
  }

  .popular-article {
    width: 100%;
    max-width: 300px; /* Ensure consistent width */
  }
}

/* Compatibility fix for line-clamp */
.article-section-like .article:nth-child(n + 3) .preview,
.article-section-comment .article:nth-child(n + 3) .preview {
  line-clamp: 2;
}

.article-body {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
  max-width: 100%;
  margin: 0 auto;
  padding: 1rem;
}

@media screen and (max-width: 1023px) {
  .article-body {
    grid-template-columns: 1fr;
    gap: clamp(1rem, 3vw, 2rem);
    padding: clamp(0.5rem, 2vw, 1.5rem);
  }

  .article {
    height: clamp(180px, 30vw, 250px);
  }

  .article-container {
    width: 100%;
    max-width: 100%;
    padding: clamp(0.8rem, 3vw, 2rem);
    box-sizing: border-box;
  }

  .article-article-section-side {
    margin-top: clamp(0.8rem, 2vw, 1.5rem);
    width: 100%;
  }

  .article-article-section-side h2 {
    font-size: clamp(0.95rem, 3vw, 1.2rem);
  }

  .article-meta {
    flex-direction: column;
    align-items: center;
    gap: clamp(0.4rem, 1.5vw, 0.8rem);
    width: 100%;
  }

  .article-image {
    max-width: 100%;
    height: auto;
    border-radius: clamp(6px, 1.5vw, 10px);
  }

  .article-desc {
    font-size: clamp(0.85rem, 2.5vw, 1.1rem);
    text-indent: clamp(20px, 5vw, 40px);
    line-height: 1.6;
  }

  .comment-section {
    font-size: clamp(0.8rem, 2.3vw, 1rem);
  }

  .articleList {
    margin-top: clamp(1rem, 3vw, 1.8rem);
  }

  .article-sidebar {
    width: 100%;
    position: static;
    margin-top: clamp(1rem, 3vw, 2rem);
  }
}

@media screen and (max-width: 1023px) {
  .article-container h1 {
    font-size: clamp(1.3rem, 5vw, 2rem);
    line-height: 1.3;
    margin-bottom: clamp(0.8rem, 2vw, 1.2rem);
  }

  .comment {
    padding: clamp(0.6rem, 2vw, 1.2rem);
    margin-bottom: clamp(0.8rem, 2vw, 1.2rem);
  }

  .article.popular-articles-grid {
    grid-template-columns: 1fr;
  }

  .article-list-item {
    padding: clamp(0.6rem, 2vw, 1rem);
  }

  .article-article-section-side h2 {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    justify-self: center;
    text-align: center;
  }

  /* Improve article grid responsiveness */
  .article-popular-articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(200px, 40vw, 280px), 1fr));
    gap: clamp(0.8rem, 2vw, 1.5rem);
  }

  /* Make images responsive */
  .article-image {
    max-width: 100%;
    height: auto;
    display: block;
    margin: clamp(0.8rem, 2vw, 1.5rem) 0;
    border-radius: clamp(6px, 1.5vw, 10px);
  }

  /* Improve form responsiveness */
  .comment-form {
    display: flex;
    flex-direction: column;
    gap: clamp(0.8rem, 2vw, 1.2rem);
    padding: clamp(0.8rem, 2vw, 1.2rem);
  }

  .comment-form button {
    align-self: flex-start;
    padding: clamp(0.6rem, 2vw, 0.9rem) clamp(1rem, 3vw, 1.5rem);
    font-size: clamp(0.9rem, 2.5vw, 1.05rem);
  }

  .comment-form textarea {
    padding: clamp(0.7rem, 2vw, 1rem);
    font-size: clamp(0.9rem, 2.5vw, 1.05rem);
    min-height: clamp(80px, 15vw, 120px);
  }

  /* Improve comment section responsiveness */
  .comment {
    margin-bottom: clamp(0.8rem, 2vw, 1.5rem);
    word-break: break-word;
  }

  .comment-actions {
    display: flex;
    gap: clamp(0.4rem, 1.5vw, 0.8rem);
    flex-wrap: wrap;
  }

  .comment-actions button {
    padding: clamp(0.4rem, 1.5vw, 0.7rem) clamp(0.7rem, 2vw, 1rem);
    font-size: clamp(0.8rem, 2vw, 0.95rem);
  }

  /* Improve article meta responsiveness */
  .article-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: clamp(0.8rem, 2vw, 1.5rem);
    margin: clamp(0.8rem, 2vw, 1.5rem) 0;
  }

  .article-meta p {
    font-size: clamp(0.8rem, 2vw, 0.95rem);
  }
}
