/**
 * Leadership Addons — Blog Archive Grid Styles
 *
 * Replicates the exact layout and design from the reference HTML.
 * Uses CSS custom properties (set from admin settings) for brand colors.
 * Elementor style controls override these via higher-specificity selectors.
 *
 * @package LeadershipAddons
 * @since   1.0.0
 */

/* ══════════════════════════════════════════════════════════════════
 *  CSS CUSTOM PROPERTIES (Design Tokens)
 *  Defaults match the reference HTML. Overridden inline by Plugin.php
 *  from admin settings.
 * ══════════════════════════════════════════════════════════════════ */

.lael-blog-archive {
  --lael-brand-navy: #162345;
  --lael-brand-purple: #5e439b;
  --lael-brand-light-bg: #f8f9fa;
  --lael-brand-active-bg: #efeaf5;
  --lael-brand-border: #e5e7eb;
  --lael-text-primary: #111827;
  --lael-text-secondary: #4b5563;
  --lael-text-muted: #6b7280;
  --lael-text-light: #9ca3af;
  --lael-border-light: #f3f4f6;
  --lael-white: #ffffff;
  --lael-font-serif:
    ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --lael-font-sans:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ══════════════════════════════════════════════════════════════════
 *  RESET — Scoped to widget only, prevents theme interference
 * ══════════════════════════════════════════════════════════════════ */

.lael-blog-archive *,
.lael-blog-archive *::before,
.lael-blog-archive *::after {
  box-sizing: border-box;
}

.lael-blog-archive img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ══════════════════════════════════════════════════════════════════
 *  MAIN CONTAINER
 * ══════════════════════════════════════════════════════════════════ */

.lael-blog-archive {
  width: 100%;
  font-family: var(--lael-font-sans);
  color: #1f2937;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ══════════════════════════════════════════════════════════════════
 *  PAGE HEADER
 * ══════════════════════════════════════════════════════════════════ */

.lael-blog-archive__header {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
}

@media (min-width: 640px) {
  .lael-blog-archive__header {
    flex-direction: row;
    align-items: flex-end;
  }
}

.lael-header__subtitle {
  display: block;
}

.lael-header__title {
  margin: 0;
  padding: 0;
}

.lael-header__page-count {
  margin-top: 1rem;
}

@media (min-width: 640px) {
  .lael-header__page-count {
    margin-top: 0;
  }
}

/* ══════════════════════════════════════════════════════════════════
 *  CONTENT LAYOUT (Grid + Sidebar)
 * ══════════════════════════════════════════════════════════════════ */

.lael-blog-archive__layout {
  display: flex;
  flex-direction: column;
  gap: 2rem; /* gap-8 */
}

@media (min-width: 1024px) {
  .lael-blog-archive__layout {
    flex-direction: row;
    gap: 3rem; /* lg:gap-12 */
  }
}

/* Sidebar-left layout reversal */
.lael-blog-archive__layout--sidebar-left {
  flex-direction: column;
}

@media (min-width: 1024px) {
  .lael-blog-archive__layout--sidebar-left {
    flex-direction: row-reverse;
  }
}

/* ── Main Content Area ── */

.lael-blog-archive__main {
  width: 100%;
  order: 2 !important; /* Show main content after sidebar on mobile/tablet */
}

@media (min-width: 1024px) {
  .lael-blog-archive__main {
    order: 0 !important; /* Reset order on desktop */
  }

  .lael-blog-archive__main--with-sidebar {
    width: 66.6667%; /* lg:w-2/3 */
  }
}

@media (min-width: 1280px) {
  .lael-blog-archive__main--with-sidebar {
    width: 75%; /* xl:w-3/4 */
  }
}

/* ══════════════════════════════════════════════════════════════════
 *  ARTICLES GRID
 * ══════════════════════════════════════════════════════════════════ */

.lael-blog-archive__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem; /* gap-8 */
}

@media (min-width: 768px) {
  .lael-blog-archive__grid--cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  .lael-blog-archive__grid--cols-3 {
    grid-template-columns: repeat(3, 1fr);
  }
  .lael-blog-archive__grid--cols-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ══════════════════════════════════════════════════════════════════
 *  ARTICLE CARD
 * ══════════════════════════════════════════════════════════════════ */

.lael-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.2s ease;
}

/* ── Card Image ── */

.lael-card__image {
  width: 100%;
  object-fit: cover;
  display: block;
}

.lael-card__image--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Card Body ── */

.lael-card__body {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

/* ── Category Label ── */

.lael-card__category {
  display: block;
  text-decoration: none;
  transition: color 0.2s ease;
}

.lael-card__category:hover {
  text-decoration: none;
}

/* ── Card Title ── */

.lael-card__title {
  margin: 0;
  transition: color 0.2s ease;
}

.lael-card__title a {
  color: inherit;
  text-decoration: none;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  letter-spacing: inherit;
}

/* ── Excerpt ── */

.lael-card__excerpt {
  margin: 0;
  flex-grow: 1;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lael-card__excerpt--clamp-2 {
  -webkit-line-clamp: 2;
}
.lael-card__excerpt--clamp-3 {
  -webkit-line-clamp: 3;
}
.lael-card__excerpt--clamp-4 {
  -webkit-line-clamp: 4;
}
.lael-card__excerpt--clamp-5 {
  -webkit-line-clamp: 5;
}

/* ── Read More Link ── */

.lael-card__read-more {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  transition: all 0.2s ease;
}

.lael-card__read-more-arrow {
  margin-left: 0.25rem;
}

/* ── Meta / Author Area ── */

.lael-card__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

/* Hide separator when disabled */
.lael-card__meta--no-separator {
  border-top: none !important;
  padding-top: 0 !important;
}

.lael-card__avatar {
  border-radius: 9999px;
  object-fit: cover;
}

.lael-card__author-name {
  /* Spacing controlled by Elementor */
}

.lael-card__meta-sep {
  /* Spacing controlled by Elementor */
}

.lael-card__date {
  /* Spacing controlled by Elementor */
}

/* ══════════════════════════════════════════════════════════════════
 *  SIDEBAR
 * ══════════════════════════════════════════════════════════════════ */

.lael-sidebar {
  width: 100%;
  order: 1; /* Show sidebar before main content on mobile/tablet */
  display: flex;
  flex-direction: column;
  gap: 1.5rem; /* 24px gap between cards */
}

@media (min-width: 1024px) {
  .lael-sidebar {
    width: 33.3333%;
    order: 0;
    gap: 2rem; /* 32px gap on desktop */
    /* Make entire sidebar sticky on desktop */
    position: sticky;
    top: 1.5rem;
    align-self: flex-start;
  }
}

@media (min-width: 1280px) {
  .lael-sidebar {
    width: 25%;
  }
}

/* ── Individual Sidebar Cards ── */

.lael-sidebar__card {
  background-color: var(--lael-brand-light-bg);
  border-radius: 12px;
  border: 1px solid var(--lael-border-light);
  position: relative; /* Ensure cards don't have sticky positioning */
  padding: 24px; /* Default padding - can be overridden by Elementor */
}

.lael-sidebar__card--categories {
  padding: 24px; /* Specific padding for categories card */
}

.lael-sidebar__title {
  margin: 0 0 1rem 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--lael-brand-purple);
  display: none;
}

@media (min-width: 1024px) {
  .lael-sidebar__title {
    display: block;
  }
}

.lael-sidebar__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.lael-sidebar__list::-webkit-scrollbar {
  display: none;
}

@media (min-width: 1024px) {
  .lael-sidebar__list {
    flex-direction: column;
    overflow-x: visible;
  }
}

/* ── Sidebar Items ── */

.lael-sidebar__item {
  display: flex;
  flex: 0 0 auto;
  justify-content: center;
  align-items: center;
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
  white-space: nowrap; /* Prevent text wrapping on mobile */
}

@media (min-width: 1024px) {
  .lael-sidebar__item {
    justify-content: space-between;
    white-space: normal; /* Allow wrapping on desktop if needed */
  }
}

.lael-sidebar__item:hover {
  text-decoration: none;
}

/* ── Show All Button ── */

.lael-sidebar__show-all {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: transparent !important;
  border: none !important;
  border-radius: 8px;
  color: var(--lael-brand-purple);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  box-shadow: none !important;
  outline: none !important;
}

.lael-sidebar__show-all:hover {
  background: #f3f4f6 !important;
  color: var(--lael-brand-purple);
  box-shadow: none !important;
}

.lael-sidebar__show-all:focus {
  outline: none !important;
  box-shadow: none !important;
}

.lael-sidebar__show-all-text {
  display: inline-block;
}

.lael-sidebar__show-all-count {
  display: inline-block;
  font-weight: 500;
  color: #6b7280;
}

/* Hide categories initially - only on desktop */
.lael-sidebar__category-item--hidden {
  display: none !important;
}

/* Show all button - hidden on mobile, visible on desktop */
.lael-sidebar__show-all {
  display: none;
}

/* Mobile: Show all categories and hide button */
@media (max-width: 1023px) {
  .lael-sidebar__category-item--hidden {
    display: flex !important;
  }

  .lael-sidebar__show-all {
    display: none !important;
  }
}

/* Desktop: Show button and hide extra categories */
@media (min-width: 1024px) {
  .lael-sidebar__show-all {
    display: flex;
  }
}

/* ══════════════════════════════════════════════════════════════════
 *  PAGINATION
 * ══════════════════════════════════════════════════════════════════ */

.lael-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem; /* 8px */
  padding: 0 1rem;
  flex-wrap: wrap;
}

.lael-pagination__pages {
  display: flex;
  gap: 0.5rem; /* 8px */
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-wrap: nowrap;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.lael-pagination__pages::-webkit-scrollbar {
  display: none;
}

/* ── Prev / Next Buttons ── */

button.lael-pagination__prev,
button.lael-pagination__next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: #374151;
  flex-shrink: 0;
  padding: 10px 12px;
  min-width: 44px;
  min-height: 44px;
}

button.lael-pagination__prev:hover:not(:disabled),
button.lael-pagination__next:hover:not(:disabled) {
  background: #f9fafb;
  border-color: #d1d5db;
  color: var(--lael-brand-purple);
}

button.lael-pagination__prev:disabled,
button.lael-pagination__next:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  background: #f9fafb;
}

/* Hide text, show only arrows */
.lael-pagination__prev .lael-pagination__text,
.lael-pagination__next .lael-pagination__text {
  display: none;
}

/* Arrow styling */
.lael-pagination__arrow {
  display: inline-block;
  font-size: 18px;
  line-height: 1;
}

/* ── Page Number Buttons ── */

button.lael-pagination__page,
button.lael-pagination__current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  flex-shrink: 0;
}

button.lael-pagination__page:hover {
  background: #f9fafb;
  border-color: #d1d5db;
  color: var(--lael-brand-purple);
}

button.lael-pagination__current {
  cursor: default;
  background: var(--lael-brand-purple);
  border-color: var(--lael-brand-purple);
  color: #ffffff;
  font-weight: 600;
}

button.lael-pagination__current:hover {
  background: var(--lael-brand-purple);
  border-color: var(--lael-brand-purple);
  color: #ffffff;
}

/* ══════════════════════════════════════════════════════════════════
 *  NO POSTS MESSAGE
 * ══════════════════════════════════════════════════════════════════ */

.lael-no-posts {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2.5rem 1.25rem;
}

.lael-no-posts p {
  color: var(--lael-text-muted);
  font-size: 1rem;
  margin: 0;
}

/* ══════════════════════════════════════════════════════════════════
 *  LOADING STATE (AJAX)
 * ══════════════════════════════════════════════════════════════════ */

.lael-blog-archive__grid--loading {
  opacity: 0.5;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════════════════
 *  CTA CARDS (Authors & Promo)
 * ══════════════════════════════════════════════════════════════════ */

.lael-sidebar__cta-heading {
  margin: 0 0 1rem 0; /* 16px bottom */
  font-size: 1.125rem; /* 18px */
  font-weight: 600;
  color: var(--lael-brand-purple);
}

.lael-sidebar__cta-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem; /* 16px */
}

.lael-sidebar__cta-item {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--lael-text-primary);
  transition: color 0.15s ease;
}

.lael-sidebar__cta-item:hover {
  color: var(--lael-brand-purple);
  text-decoration: none;
}

.lael-sidebar__cta-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 0.75rem; /* 12px */
  flex-shrink: 0;
}

.lael-sidebar__cta-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem; /* 2px */
}

.lael-sidebar__cta-name {
  font-size: 0.9375rem; /* 15px */
  font-weight: 500;
  line-height: 1.4;
}

.lael-sidebar__cta-subtitle {
  font-size: 0.8125rem; /* 13px */
  font-weight: 400;
  color: var(--lael-text-muted);
  line-height: 1.4;
}

.lael-sidebar__cta-item:focus {
  outline: 2px solid var(--lael-brand-purple);
  outline-offset: 2px;
}

/* ── Promo Card (Develop Your Leaders) ── */

.lael-sidebar__card--promo {
  background: var(--lael-brand-purple);
  color: #ffffff;
  border: none;
}

.lael-sidebar__card--promo .lael-sidebar__cta-heading {
  color: #ffffff;
  margin-bottom: 0.75rem; /* 12px */
}

.lael-sidebar__cta-description {
  margin: 0 0 1.25rem 0; /* 20px bottom */
  font-size: 0.9375rem; /* 15px */
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.95);
}

.lael-sidebar__cta-button {
  display: inline-block;
  width: 100%;
  padding: 0.75rem 1.25rem; /* 12px 20px */
  background: #ffffff;
  color: var(--lael-brand-purple);
  text-align: center;
  text-decoration: none;
  font-size: 0.9375rem; /* 15px */
  font-weight: 600;
  border-radius: 0.5rem; /* 8px */
  transition: all 0.2s ease;
}

.lael-sidebar__cta-button:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  text-decoration: none;
}

.lael-sidebar__cta-button:focus {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}
