:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-dark: #1d4ed8;
  --primary-bg: #eff6ff;
  --secondary: #f8fafc;
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --dark: #0f172a;
  --gray: #64748b;
  --light-gray: #e2e8f0;
  --card-bg: rgba(255, 255, 255, 0.9);
  --card-shadow: 0 8px 32px rgba(15, 23, 42, 0.08);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-lg: 24px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --text-color: #333333;
  --meta-color: #888888;
}

/* Ensure no body margins interfere with full width */
body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* Mobile: Force remove all margins/padding that could create white space */
@media (max-width: 768px) {
  body {
    margin: 0 !important;
    padding: 0 !important;
  }
  
  .container, .main-content, main, header, nav {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
  
  /* Remove any potential spacing from elements before hero */
  * {
    margin-top: 0 !important;
  }
  
  .all-posts-hero:first-child {
    margin-top: 0 !important;
  }
}

/* All Posts Hero Section - Matching Author Hero */
.all-posts-hero {
  width: 100vw;
  min-height: 200px;
  position: relative;
  left: 50%;
  margin-left: -50vw;
  text-align: center;
  margin-top: 0 !important;
  margin-bottom: 4rem;
  padding: 6rem 4rem;
  background: #2563eb;
  border-bottom: none;
  box-sizing: border-box;
  overflow-x: hidden;
}

.all-posts-hero h1 {
  font-size: clamp(1.8rem, 5vw, 4rem);
  font-weight: 400;
  line-height: 1.3;
  margin: 0 0 1.5rem 0;
  color: white;
  letter-spacing: -0.02em;
  word-break: break-word;
  word-wrap: break-word;
  hyphens: auto;
  max-width: 100%;
  width: 100%;
  overflow-wrap: break-word;
  white-space: normal;
  display: block;
}

.all-posts-hero p {
  margin: 1.5rem 0 0.3rem 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  text-align: center;
  font-style: italic;
}

/* MOBILE RESPONSIVE FOR HERO SECTION */
@media (max-width: 768px) {
  .all-posts-hero {
    margin-top: 0 !important; /* Remove white space above */
    margin-bottom: 3rem !important; /* Add bottom margin for mobile */
    padding: 7rem 1rem 1.5rem 1rem !important; /* Fine-tuned top padding */
  }

  .all-posts-hero h1 {
    font-size: clamp(1.4rem, 5vw, 1.8rem);
    line-height: 1.3;
    margin-bottom: 1.2rem;
    color: white;
    display: block;
    visibility: visible;
    opacity: 1;
    word-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    font-weight: 500;
    text-align: center;
  }

  .all-posts-hero p {
    font-size: 0.85rem;
    margin: 0 0 0.3rem 0;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    font-style: italic;
  }
}

@media (max-width: 480px) {
  .all-posts-hero {
    margin-top: 0 !important; /* Remove white space above */
    margin-bottom: 2.5rem !important; /* Add bottom margin for mobile */
    padding: 6.5rem 0.8rem 1.2rem 0.8rem !important; /* Fine-tuned top padding */
  }

  .all-posts-hero h1 {
    font-size: clamp(1.2rem, 4vw, 1.6rem);
    line-height: 1.4;
    margin-bottom: 1rem;
    color: white;
    display: block;
    visibility: visible;
    opacity: 1;
    word-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    font-weight: 600;
    text-align: center;
  }

  .all-posts-hero p {
    font-size: 0.8rem;
    margin: 0 0 0.3rem 0;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    font-style: italic;
  }
}

@media (max-width: 360px) {
  .all-posts-hero {
    margin-top: 0 !important; /* Remove white space above */
    margin-bottom: 2rem !important; /* Add bottom margin for mobile */
    padding: 6rem 0.6rem 1rem 0.6rem !important; /* Fine-tuned top padding */
  }

  .all-posts-hero h1 {
    font-size: clamp(1.2rem, 8vw, 1.8rem);
    line-height: 1.3;
    margin-bottom: 1rem;
    color: white;
    display: block;
    visibility: visible;
    opacity: 1;
    word-wrap: break-word;
    font-weight: 600;
    text-align: center;
  }

  .all-posts-hero p {
    font-size: 0.75rem;
    margin: 0 0 0.3rem 0;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    font-style: italic;
  }
}

/* Base styles - Updated to account for hero section */
#all-posts {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
}

#all-posts h2 {
  font-size: 2rem;
  margin-bottom: 2rem;
  margin-top: 0; /* Reduced since we have hero now */
  color: var(--dark);
  text-align: center;
  position: relative;
  padding-bottom: 1rem;
}

#all-posts h2::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 3px;
  background: var(--accent);
}

.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 2rem;
}

/* Individual post card */
.post {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: var(--transition);
  position: relative;
}

.post:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
}

.post a {
  text-decoration: none;
  color: inherit;
}

.post__image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.post__image-placeholder {
  width: 100%;
  height: 200px;
  background: var(--light-gray);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray);
  font-size: 2rem;
}

.post__content {
  padding: 1.5rem;
}

.post__title {
  font-size: 1.4rem;
  margin: 0 0 0.5rem 0;
  color: var(--dark);
  line-height: 1.3;
}

.post__excerpt {
  color: var(--gray);
  margin-bottom: 1rem;
  line-height: 1.6;
}

.post__meta {
  margin-top: 1rem;
  font-size: 0.9rem;
}

.post__author {
  font-weight: 500;
  color: var(--primary);
}

.post__date {
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--gray);
  font-style: italic;
}

.post__author a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

.post__author a:hover {
  text-decoration: underline;
}

.post__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.post__tag {
  background-color: var(--primary-bg);
  color: var(--primary-dark);
  padding: 0.3rem 0.8rem;
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 500;
  transition: var(--transition);
}

.post__tag:hover {
  background-color: var(--primary);
  color: white;
}

/* Post actions (save button) */
.post-actions {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 10;
}

.btn {
  display: -webkit-inline-flex;
  display: -ms-inline-flexbox;
  display: inline-flex;
  -webkit-align-items: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-justify-content: center;
  -ms-flex-pack: center;
  justify-content: center;
  gap: 0.3rem;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  -webkit-transition: var(--transition);
  -o-transition: var(--transition);
  transition: var(--transition);
  font-size: 0.75rem;
  border: 1px solid transparent;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  -webkit-box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  font-family: inherit;
  line-height: 1;
}

.btn-outline {
  color: var(--primary);
  border-color: rgba(37, 99, 235, 0.3);
}

.btn-outline:hover {
  background: var(--primary);
  color: white;
  -webkit-transform: translateY(-1px);
  -ms-transform: translateY(-1px);
  transform: translateY(-1px);
  -webkit-box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-outline.saved {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* No posts message */
.no-posts {
  text-align: center;
  color: var(--gray);
  font-style: italic;
  grid-column: 1 / -1;
  padding: 3rem;
  background: var(--secondary);
  border-radius: var(--radius);
  margin-top: 2rem;
}

/* Responsive adjustments - Updated */
@media (max-width: 768px) {
  #all-posts {
    margin-top: 0; /* Reduced since hero provides spacing */
    padding-top: 0;
  }
  
  #all-posts h2 {
    font-size: 2.5rem;
    margin-top: 1rem; /* Reduced */
    margin-bottom: 1.5rem;
    padding: 0 1rem;
  }
  
  .post-list {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    padding: 0 1rem;
  }
}

@media (max-width: 480px) {
  #all-posts {
    margin-top: 0;
    padding-top: 0;
  }
  
  #all-posts h2 {
    font-size: 1.8rem;
    margin-top: 0.5rem; /* Reduced */
    margin-bottom: 1rem;
    padding: 0 0.5rem;
  }
  
  .post-list {
    grid-template-columns: 1fr;
    padding: 0 0.5rem;
    gap: 1rem;
  }
  
  .post__image {
    height: 160px;
  }
}