/* =====================================================
   HOME PAGE STYLES - TECH BLOGGERS
   =====================================================
   Home page specific components:
   - Hero Section
   - Search Bar
   - Recent Posts Grid
   - Recommended Section
===================================================== */

/* ==========================
   HERO SECTION
========================== */

.hero {
  text-align: center;
  padding: 3rem 1rem 2rem;
  background: #0d1117;
}

.hero-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.hero-header {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.hero h1 {
  font-size: 2.5rem;
  color: #fff;
  margin: 0;
  transition: text-shadow 0.3s ease;
}

.hero h1:hover {
  text-shadow: 0 0 12px #58a6ff;
}

.hero p {
  margin-bottom: 2rem;
  color: #8b949e;
  font-size: 1.3rem;
}

/* Empty State Styles */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  margin: 2rem auto;
  max-width: 600px;
}

.empty-state h3 {
  color: #fff;
  font-size: 1.8rem;
  margin-bottom: 1rem;
}

.empty-state p {
  color: #8b949e;
  font-size: 1.2rem;
  margin: 0;
}

/* ==========================
   SEARCH BAR
========================== */

.search-container {
  display: flex;
  justify-content: center;
}

.search-form-fa {
  position: relative;
  width: 300px;
  display: flex;
  align-items: center;
}

.search-input-fa {
  width: 100%;
  padding: 12px 60px 12px 20px; /* more right padding */
  border: 1px solid #ddd;
  border-radius: 50px;
  font-size: 16px;
  outline: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.search-input-fa:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

.search-button-fa {
  position: absolute;
  top: 28%;
  right: 6px;
  transform: translateY(-50%);
  width: 36px; /* circular button */
  height: 36px;
  border-radius: 50%; /* makes it round */
  background: #0d1117;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  transition: background 0.3s ease, transform 0.2s ease;
}

.search-button-fa:hover {
  background: #0056b3;
  transform: translateY(-50%) scale(1.05); /* small hover grow */
}

.search-button-fa .fa-search {
  pointer-events: none;
}

/* ==========================
   RECENT POSTS
========================== */

.h2,
.recent-posts h2,
.recommended h2 {
  margin: 1rem 0;
}

/* Add border-bottom to recommended posts heading */
.recommended h2 {
  border-bottom: 1px solid #30363d;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.grid-latest {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  margin-top: 1rem;
  align-items: stretch;
}

.recent-grid {
  display: grid;
  grid-template-columns: 2fr 1.3fr;
  gap: 1.5rem 5rem;
  margin-bottom: 3rem;
}

.recent-grid > h2:not(.side-post-title) {
  grid-column: 1 / 2;
}

/* Ensure the left latest grid sits in the left column and spans rows below the heading */
.recent-grid .grid-latest {
  grid-column: 1 / 2;
  grid-row: 2 / span 3;
}

.featured-post h3 {
  margin: 0 0 0.5rem 0;
}

.featured-post .meta,
.side-post .meta,
.recom-card .meta {
  font-size: 0.85rem;
  color: #8b949e;
}

/* Homepage-specific refinements - only for side posts, not latest posts */
.recent-grid .side-posts .card-body p {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.recent-grid .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Add margin-bottom to meta in Latest Posts cards for better spacing */
.grid-latest .card .meta {
  margin-bottom: 1rem;
  color: #58a6ff;
}

.grid-latest .card .meta span {
  color: #58a6ff;
}

/* Latest Posts paragraph styling */
.grid-latest .card-body p {
  line-height: 1.5;
  margin-bottom: 1rem;
  /* Text truncation for content paragraphs - limit to 4 lines */
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: calc(1.5em * 4); /* Fallback for browsers that don't support -webkit-line-clamp */
}

/* Most Liked Posts paragraph styling - consistent with Latest Posts */
.recommended .card-body p {
  line-height: 1.5;
  margin-bottom: 1rem;
  /* Text truncation for content paragraphs - limit to 4 lines */
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: calc(1.5em * 4); /* Fallback for browsers that don't support -webkit-line-clamp */
}

.grid-latest .card img {
  aspect-ratio: 16 / 9;
}

/* Default post image in cards - match real images exactly */
.card .default-post-image,
.recom-card .default-post-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  font-size: 1.5rem;
  flex-shrink: 0;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  border-bottom: 1px solid #30363d;
  background: #161b22;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.side-post .default-post-image {
  width: 100px;
  height: 70px;
  font-size: 0.8rem;
  flex-shrink: 0;
  border-radius: 6px;
  background: #161b22;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.side-post {
  align-items: flex-start;
}

.featured-post .meta {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

.recently-posted,
.most-commented {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.side-posts {
  grid-column: 2 / 3;
  grid-row: 2;
  align-self: start;
  display: grid;
  gap: 1rem;
  align-items: stretch;
}

.side-post {
  display: flex;
  column-gap: 2rem;
  margin-bottom: 1rem;
  align-items: stretch;
  height: 100%;
}

/* Ensure side-post link lays out image and text horizontally */
.side-post > a {
  display: flex;
  align-items: stretch;
  gap: 1rem;
  height: 100%;
}

.side-post > a .side-post-text {
  flex: 1 1 auto;
}

.side-post h4 {
  margin-bottom: 0.3rem;
  /* Text truncation for side post titles - limit to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
  max-height: calc(1.3em * 2); /* Fallback for browsers that don't support -webkit-line-clamp */
}

.side-post .meta {
  margin: 0.5rem 0;
}

.side-post-title {
  grid-column: 2 / 3;
  grid-row: 1;
  border-bottom: 1px solid #30363d;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

/* Space the second right column block so it doesn't overlap */
.recent-grid .side-posts.most {
  margin-top: -1.5rem; /* Negative margin to counteract grid gap */
  grid-column: 2 / 3;
  grid-row: 4;
}
.recent-grid .side-post-title.most {
  margin-top: -1.5rem; /* Negative margin to counteract grid gap */
  padding-bottom: 0.5rem; /* Match other headings spacing */
  grid-column: 2 / 3;
  grid-row: 3;
  align-self: start;
}

.side-post-text {
  margin-top: 0.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.5rem;
}

.card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 0 15px rgba(88, 166, 255, 0.3);
}

.recent-grid h2:not(.side-post-title.most) {
  border-bottom: 1px solid #30363d;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

/* Most Commented heading - consistent spacing with other headings */
.recent-grid h2.side-post-title.most {
  border-bottom: 1px solid #30363d;
  padding-bottom: 0.5rem;
  margin-bottom: 0; /* No margin to match Recently Posted spacing */
}

/* ==========================
   RECOMMENDED SECTION
========================== */

.grid-recommended {
  display: grid;
  /* grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); */
  grid-template-columns: repeat(3, 1fr);
  /* gap: 1.5rem; */
  gap: 2rem;
  margin-top: 2rem;
  align-items: stretch;
}

.recom-card {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.card-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Only use space-between for recommended cards */
.recom-card .card-body {
  justify-content: space-between;
}

/* Ensure card links take full height */
.card > a {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  text-decoration: none;
  color: inherit;
}

/* Ensure images and default images within cards take full width */
.card > a > img,
.card > a > .default-post-image {
  width: 100%;
  flex-shrink: 0;
}

.card-body h4 {
  margin-bottom: 0.5rem;
  /* Text truncation for post titles - limit to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
  max-height: calc(1.3em * 2); /* Fallback for browsers that don't support -webkit-line-clamp */
}

.recom-card .meta {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
  color: #58a6ff;
  gap: 1.2rem;
}

.recom-card .meta span {
  color: #58a6ff;
}

/* Card / Grid Images */

.card img,
.recom-card img,
.side-post img {
  width: 100%;
  object-fit: cover;
  display: block;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.recom-card img {
  aspect-ratio: 16 / 9;
  height: auto;
}

.side-post img {
  width: 100px;
  height: 70px;
  border-radius: 6px;
}

/* Limit text height in side lists to avoid overflow */
.side-post-text p {
  margin: 0; /* Remove all margins to prevent overlap */
  padding: 0; /* Remove any padding that might cause issues */
  line-height: 1.4; /* Ensure consistent line height */
  max-height: 4.2em; /* Allow for 3 lines (1.4 * 3) */
  overflow: hidden;
  /* No gradient overlay - clean text cutoff */
}

.featured-post img {
  width: 100%;
  height: auto;
  object-fit: cover;
}

