/* ============================================================
   GR INSIGHTS SECTION — gr-insights-section.css
   Flexbox-only grid | WordPress-safe | Prefixed: gr-
   ============================================================ */

/* ── CSS Custom Properties ── */
:root {
  --gr-bg: #f0ede8;
  --gr-card-bg: #f4f4f0;
  --gr-border: #b9b990;
  --gr-text-dark: #191919;
  --gr-text-mid: #191919;
  --gr-text-muted: #191919;
  --gr-accent: #191919;
  --gr-font-display: "Poppins", sans-serif;
  --gr-font-body: "Poppins", sans-serif;
  --gr-radius: 4px;
  --gr-gap: 30px; /* gap between cards */
  --gr-card-cols: 3; /* columns on desktop */
  --gr-transition: 0.55s cubic-bezier(0.77, 0, 0.175, 1);
  --gr-section-px: 2.5rem; /* horizontal padding */
  --gr-f-13: 13px;
  --gr-f-14: 14px;
  --gr-f-20: 20px;
  --gr-w-400: 400;
  --gr-w-500: 500;
  --gr-lh-25: 25px;
  --gr-l-space-1: 1%;
}

/* ── Reset scoped to section ── */
.gr-section *,
.gr-section *::before,
.gr-section *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ============================================================
   SECTION WRAPPER
   ============================================================ */
.gr-section {
  font-family: var(--gr-font-body);
  color: var(--gr-text-dark);
  overflow: hidden; /* safety net — viewport handles clipping */
}

/* ============================================================
   FILTER NAVIGATION
   ============================================================ */
.gr-filters {
  margin-bottom: 4.063rem;
}

.gr-filters__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0;
  list-style: none;
}

/* ── Each filter button ── */
.gr-filters__btn {
  background: none !important;
  border: none;
  cursor: pointer;
  font-family: var(--gr-font-body);
  font-size: 14px;
  font-weight: 400;
  color: var(--gr-text-muted);
  padding: 0.1rem 0;
  margin-right: 2rem;
  position: relative;
  transition: color 0.2s ease;
  border-radius: 0px !important;
  /* Underline indicator */
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; /* overlap the nav border-bottom */
}

.gr-filters__btn:hover,
.gr-filters__btn:active,
.gr-filters__btn:focus {
  color: var(--gr-text-dark);
  background: none !important;
  outline: none !important;
}

/* Active state */
.gr-filters__btn--active {
  color: var(--gr-text-dark);
  border-bottom-color: var(--gr-border);
}

/* Separator em-dash between items */
.gr-filters__list li:not(:last-child) .gr-filters__btn::after {
  content: "—";
  position: absolute;
  right: -1.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gr-text-dark);
  font-weight: 300;
  pointer-events: none;
}

/* ============================================================
   VIEWPORT — Clips the sliding track
   ============================================================ */
.gr-viewport {
  overflow: hidden; /* THIS is what hides off-screen panels */
  width: 100%;
}

/* ============================================================
   TRACK — All panels sit side by side inside here
   ============================================================ */
.gr-track {
  display: flex; /* panels in a horizontal row */
  flex-wrap: nowrap; /* never wrap — they must stay in one line */
  width: 100%; /* track is 100% wide; panels each take 100% too */
  align-items: flex-start; /* panels don't stretch the track implicitly */
  /* translateX & height set via JS */
  transition: transform var(--gr-transition), height var(--gr-transition);
  will-change: transform, height;
}

/* ============================================================
   PANEL — One per filter category
   ============================================================ */
.gr-panel {
  flex: 0 0 100%; /* each panel = full viewport width */
  min-width: 0; /* prevent flex blowout */
}

/* ============================================================
   CARD GRID — Flexbox 3-column layout
   ============================================================ */
.gr-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gr-gap);
  align-items: stretch; /* equal-height cards */
}

/* ── Each card takes up 1/3 of the row, minus gaps ── */
.gr-card {
  position: relative; /* Required for stretched link */
  flex: 0 0
    calc(
      (100% - (var(--gr-card-cols) - 1) * var(--gr-gap)) / var(--gr-card-cols)
    );
  min-width: 0; /* prevent overflow */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-color: var(--gr-card-bg);
  padding: 33px 32px;
  min-height: 361px;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
  cursor: pointer; /* Visual hint that the card is clickable */
}

.gr-card:hover {
  background-color: #f1f0ee;
}

/* ── Card label (e.g. "Insight") ── */
.gr-card__label {
  display: block;
  font-size: var(--gr-f-13);
  font-weight: var(--gr-w-400);
  letter-spacing: var(--gr-l-space-1);
  color: var(--gr-text-muted);
  margin-bottom: 5px;
  position: relative;
  z-index: 2; /* Ensure label stays above the stretched link if needed */
}

/* ── Card title ── */
.gr-card .gr-card__title {
  font-family: var(--gr-font-display);
  font-size: var(--gr-f-20);
  font-weight: var(--gr-w-400);
  line-height: var(--gr-lh-25);
  letter-spacing: var(--gr-l-space-1);
  color: var(--gr-text-dark);
  flex-grow: 1;
  margin-bottom: 1.5rem;
  width: 100%;
  max-width: 295px;
  position: relative;
  z-index: 2;
}

/* ── Read full article link ── */
.gr-card .gr-card__link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: var(--gr-f-14);
  font-weight: var(--gr-w-400);
  color: var(--gr-text-mid);
  line-height: calc(var(--gr-lh-25) + 1);
  text-decoration: none;
  transition:
    color 0.2s ease,
    gap 0.2s ease;
  margin-top: auto;
  position: static; /* Required for stretched link pseudo-element to find .gr-card */
}

/* Stretched link to make the whole card clickable */
.gr-card .gr-card__link::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
}

.gr-card .gr-card__link:hover {
  color: var(--gr-text-dark);
  gap: 0.5rem;
}

/* ── Arrow character ── */
.gr-card__arrow {
  display: inline-block;
  transition: transform 0.2s ease;
}

.gr-card__link:hover .gr-card__arrow {
  transform: translateX(5px);
}

/* ============================================================
   CTA — "View all ..." link below the grid
   ============================================================ */
.gr-cta-wrap {
  display: flex;
  justify-content: center;
  margin-top: 2.5rem;
}

.gr-cta-wrap .gr-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--gr-font-body);
  font-size: var(--gr-f-14);
  font-weight: var(--gr-w-500);
  line-height: calc(var(--gr-lh-25) + 1);
  color: var(--gr-text-mid);
  text-decoration: none;
}

.gr-cta-wrap .gr-cta:hover,
.gr-cta-wrap .gr-cta:active,
.gr-cta-wrap .gr-cta:focus {
  color: var(--gr-text-mid);
  background: none !important;
  outline: none !important;
}

.gr-cta:hover .gr-card__arrow {
  transform: translateX(5px);
}

/* ============================================================
   ACCESSIBILITY — Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .gr-track {
    transition: none;
  }

  .gr-card,
  .gr-card__link,
  .gr-card__arrow,
  .gr-filters__btn,
  .gr-cta {
    transition: none;
  }
}

/* ============================================================
   RESPONSIVE — Tablet (≤ 900px)
   ============================================================ */
@media (max-width: 900px) {
  :root {
    --gr-card-cols: 2;
    --gr-section-px: 1.75rem;
  }

  /* Hide the em-dash separators on small screens */
  .gr-filters__list li:not(:last-child) .gr-filters__btn::after {
    display: none;
  }

  .gr-filters__btn {
    margin-right: 1.25rem;
  }
  .gr-filters {
    margin-bottom: 3rem;
  }
}

/* ============================================================
   RESPONSIVE — Mobile (≤ 560px)
   ============================================================ */
@media (max-width: 560px) {
  :root {
    --gr-card-cols: 1;
    --gr-section-px: 1rem;
    --gr-gap: 1rem;
  }

  .gr-card {
    min-height: 250px;
  }

  .gr-filters__btn {
    font-size: 0.82rem;
    margin-right: 0.9rem;
  }

  .gr-card__title {
    font-size: 1rem;
  }
}
