/* Redesigned Blogs Page Styles - With Absolute Namespace Protection */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Orbitron:wght@700&family=Rajdhani:wght@600&display=swap');

/* Baseline configuration */
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #fafbfc;
  color: #1e293b;
  overflow-x: hidden;
}

.blogs-section {
  padding: 4rem 2rem;
  max-width: 1300px;
  margin: auto;
}

/* Header style inspired by Specify */
.blogs-header {
  text-align: center;
  max-width: 700px;
  margin: 0 auto 4rem auto;
}

.blogs-header h1 {
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: 3rem;
  color: #0f172a;
  margin-bottom: 1rem;
  letter-spacing: -0.04em;
}

.blogs-header p {
  font-size: 1.125rem;
  color: #64748b;
  line-height: 1.625;
}

/* Featured Article Section - Perfectly Aligned Layout */
.featured-section {
  margin-bottom: 5rem;
}

.featured-card {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  background: #ffffff;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.02);
  transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  border: 1px solid rgba(226, 232, 240, 0.8);
  cursor: pointer;
  align-items: stretch; /* Both columns stretch to match height */
}

.featured-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08), 0 1px 5px rgba(15, 23, 42, 0.03);
}

.featured-img-wrapper {
  position: relative;
  overflow: hidden;
  height: 100%; /* Fill left column entirely */
  min-height: 420px;
}

/* Specific selector for cover image - avoids matching author-avatar */
.featured-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
  display: block;
}

.featured-card:hover .featured-img-wrapper img {
  transform: scale(1.04);
}

.featured-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3.5rem 3rem;
}

/* Baseline aligned category tagging meta */
.blog-category-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  line-height: 1; /* Aligns contents on exact same line */
}

.blog-category-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 4px;
  background-color: rgba(15, 23, 42, 0.04);
  line-height: 1;
}

/* Colors for specific categories */
.tag-agri { color: #16a34a; background-color: rgba(22, 163, 74, 0.08); }
.tag-training { color: #db0000; background-color: rgba(219, 0, 0, 0.08); }
.tag-toy { color: #0284c7; background-color: rgba(2, 132, 199, 0.08); }
.tag-tech { color: #7c3aed; background-color: rgba(124, 58, 237, 0.08); }
.tag-news { color: #ea580c; background-color: rgba(234, 88, 12, 0.08); }

.blog-read-time {
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.featured-info h2 {
  font-size: 2.25rem;
  color: #0f172a;
  margin: 0 0 1.25rem 0;
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.featured-info p {
  color: #475569;
  font-size: 1.025rem;
  line-height: 1.6;
  margin: 0 0 2rem 0;
}

.featured-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  border-top: 1px solid #f1f5f9;
  padding-top: 1.5rem;
}

/* Isolated author structures avoiding global conflicts */
.blog-author-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.blog-author-avatar {
  width: 44px !important;
  height: 44px !important;
  max-width: 44px !important;
  max-height: 44px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  flex-shrink: 0 !important;
  border: none !important;
  display: block !important;
}

.blog-author-name {
  font-size: 0.875rem !important;
  font-weight: 600 !important;
  color: #1e293b !important;
  line-height: 1.2 !important;
}

.blog-post-date {
  font-size: 0.825rem !important;
  color: #64748b !important;
  font-weight: 500 !important;
}

/* Filter Section */
.filter-section {
  margin-bottom: 3rem;
  border-bottom: 1.5px solid #e2e8f0;
  padding-bottom: 1.5rem;
}

.filter-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

.filter-pills {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 0.625rem 1.25rem;
  border-radius: 50px;
  background-color: transparent;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.filter-pill:hover {
  background-color: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.filter-pill.active {
  background-color: #0f172a;
  border-color: #0f172a;
  color: #ffffff;
}

/* Grid Layout */
.blogs-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2.5rem 2rem;
}

/* Advanced Blog Card */
.blog-card {
  background: #ffffff;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(226, 232, 240, 0.7);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.02);
  transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  position: relative;
  cursor: pointer;
}

.blog-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 30px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.02);
  border-color: rgba(203, 213, 225, 0.8);
}

.blog-card-img-container {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16/10;
  background-color: #f1f5f9;
}

.blog-card-img-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.blog-card:hover .blog-card-img-container img {
  transform: scale(1.06);
}

/* Advanced Overlay Effect matching User request */
.blog-card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  z-index: 2;
}

.blog-card:hover .blog-card-overlay {
  opacity: 1;
}

.blog-card-overlay-btn {
  background: #ffffff;
  color: #0f172a;
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  font-weight: 700;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  transform: translateY(15px);
  transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.blog-card:hover .blog-card-overlay-btn {
  transform: translateY(0);
}

.blog-card-overlay-btn:hover {
  background-color: #db0000;
  color: #ffffff;
}

.blog-card-content {
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Precise card header alignment */
.blog-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  line-height: 1; /* Force perfect text baseline */
}

.blog-card-content h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.4;
  letter-spacing: -0.015em;
  transition: color 0.2s;
}

.blog-card:hover .blog-card-content h3 {
  color: #db0000;
}

.blog-card-content p {
  font-size: 0.95rem;
  color: #475569;
  line-height: 1.55;
  margin: 0 0 1.5rem 0;
  flex-grow: 1;
}

.blog-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid #f1f5f9;
  padding-top: 1.25rem;
  margin-top: auto;
}

.blog-card-footer .blog-post-date {
  font-size: 0.8rem !important;
}

.card-readmore-link {
  font-size: 0.85rem;
  font-weight: 700;
  color: #db0000;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: gap 0.2s;
}

.blog-card:hover .card-readmore-link {
  gap: 0.6rem;
}

/* Premium Popup Modal Styles */
.popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1.5rem;
}

.popup-content {
  background: #ffffff;
  border-radius: 24px;
  width: 100%;
  max-width: 840px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  display: flex;
  flex-direction: column;
}

.popup-content::-webkit-scrollbar {
  width: 6px;
}

.popup-content::-webkit-scrollbar-track {
  background: transparent;
}

.popup-content::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 10px;
}

/* Animated popup scales */
.popup.active {
  display: flex;
  animation: bgFadeIn 0.3s forwards;
}

.popup.active .popup-content {
  animation: modalSpring 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Floating glassmorphic close btn */
.close-btn {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.1);
  color: #0f172a;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 15;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.close-btn:hover {
  background: #db0000;
  color: #ffffff;
  transform: rotate(90deg);
}

/* Media/Photo/Video Containers */
.popup-media-container {
  width: 100%;
  aspect-ratio: 16/9;
  position: relative;
  background-color: #000;
  border-top-left-radius: 23px;
  border-top-right-radius: 23px;
  overflow: hidden;
}

.popup-media-container img,
.popup-media-container iframe,
.popup-media-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: none;
}

/* Modal text and structural layout */
.popup-body {
  padding: 3rem;
}

.popup-category-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  line-height: 1; /* Center tag and readtime text vertically */
}

.popup-body h2 {
  font-size: 2.5rem;
  color: #0f172a;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin: 0 0 1.5rem 0;
}

/* Formatted body contents */
.popup-post-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1.5px solid #f1f5f9;
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
}

/* Dynamic Inline Article Image Styles */
.popup-article-image-container {
  width: 100%;
  max-height: 380px;
  overflow: hidden;
  border-radius: 16px;
  margin-bottom: 2.25rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(226, 232, 240, 0.6);
}

.popup-article-img {
  width: 100%;
  height: 100%;
  max-height: 380px;
  object-fit: cover;
  display: block;
  transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.popup-article-image-container:hover .popup-article-img {
  transform: scale(1.03);
}

.popup-article-text {
  font-size: 1.1rem;
  color: #334155;
  line-height: 1.8;
}

.popup-article-text p {
  margin-bottom: 1.5rem;
}

.popup-article-text h4 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #0f172a;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.popup-article-text ul, .popup-article-text ol {
  margin-left: 1.5rem;
  margin-bottom: 1.5rem;
}

.popup-article-text li {
  margin-bottom: 0.5rem;
}

.popup-article-text blockquote {
  border-left: 4px solid #db0000;
  background-color: #f8fafc;
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  font-style: italic;
  color: #475569;
  border-radius: 4px;
}

/* Animations definition */
@keyframes bgFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalSpring {
  from {
    transform: scale(0.9) translateY(20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* Responsive queries */
@media (max-width: 1024px) {
  .blogs-container {
    grid-template-columns: repeat(2, 1fr);
  }
  .featured-card {
    grid-template-columns: 1fr;
    gap: 0;
    align-items: flex-start;
  }
  .featured-img-wrapper {
    height: 320px;
    min-height: auto;
  }
  .featured-info {
    padding: 2.5rem 2rem;
  }
}

@media (max-width: 768px) {
  .blogs-section {
    padding: 3rem 1.25rem;
  }
  .blogs-header h1 {
    font-size: 2.25rem;
  }
  .blogs-container {
    grid-template-columns: 1fr;
  }
  .popup-body {
    padding: 2rem 1.5rem;
  }
  .popup-body h2 {
    font-size: 1.85rem;
  }
  .popup-post-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.25rem;
  }
}
