/**
 * Church Small Groups Widget – Main Stylesheet
 * Refactored from Duda HTML widget. All Duda template syntax removed.
 *
 * Table of Contents
 * ─────────────────────────────────────────────────────────────────────────────
 *  1.  CSS Custom Properties
 *  2.  Root / font setup
 *  3.  Shell container
 *  4.  Filters (toggle, dropdown row, active pills)
 *  5.  Search bar
 *  6.  Groups grid
 *  7.  Group card
 *      7a. Hero image + day badge + share button
 *      7b. Card body
 *      7c. Card footer + buttons
 *  8.  Single-group detail view
 *  9.  Return link
 * 10.  Empty state
 * 11.  Gutenberg alignment (wide / full)
 * 12.  Responsive overrides
 */

/* ─────────────────────────────────────────────────────────────────────────────
   1. CSS Custom Properties
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  --r-md:   16px;
  --r-pill: 999px;
  --bd:     #e2e8f0;
  --bg:     #ffffff;
  --bg-soft:#f8fafc;
  --txt:    #0f172a;
  --muted:  #64748b;
  --sh:     0 12px 30px rgba(15,23,42,.12);
  --accent: #2563eb;
}

/* ─────────────────────────────────────────────────────────────────────────────
   2. Root / font setup
   ───────────────────────────────────────────────────────────────────────────── */
.church-groups-widget {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  color: var(--txt);
  box-sizing: border-box;
}

.church-groups-widget *,
.church-groups-widget *::before,
.church-groups-widget *::after {
  box-sizing: inherit;
}

/* ─────────────────────────────────────────────────────────────────────────────
   3. Shell container
   ───────────────────────────────────────────────────────────────────────────── */
.groups-shell {
  max-width: 1200px;
  margin: 1.75rem auto 2.5rem;
  padding: 20px 1.15rem;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(15,23,42,.12), 0 1px 2px rgba(15,23,42,.06);
}

.groups-shell.is-flat {
  background:    transparent !important;
  box-shadow:    none !important;
  border-radius: 0 !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   4. Filters
   ───────────────────────────────────────────────────────────────────────────── */
.groups-filters-bar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: .5rem;
}

.groups-filters-toggle {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  padding: .4rem .9rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--bd);
  background: var(--bg-soft);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 0;
}

.groups-filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: .9rem;
  width: 100%;
}

.groups-filters-row.is-hidden {
  display: none;
}

/* Dropdown filter component */
.groups-dropdown-wrapper {
  position: relative;
  min-width: 200px;
}

.groups-dropdown-header {
  height: 52px;
  border: 2px solid #d1d5db;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 1rem;
  font-weight: 600;
  background: #fff;
  cursor: pointer;
}

.groups-dropdown-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 2px solid #d1d5db;
  border-top: none;
  max-height: 260px;
  overflow: auto;
  display: none;
  z-index: 1000;
}

.groups-dropdown-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: .9rem;
}

.groups-dropdown-item:hover {
  background: #f4f4f4;
}

/* Active filter pills */
.groups-active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .4rem;
}

.filter-pill {
  padding: .35rem .75rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--bd);
  background: var(--bg-soft);
  font-size: .75rem;
  cursor: pointer;
  white-space: nowrap;
}

.filter-pill.active {
  background: #000;
  color: #fff;
  border-color: #000;
}

/* ─────────────────────────────────────────────────────────────────────────────
   5. Search bar
   ───────────────────────────────────────────────────────────────────────────── */
.groups-search-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
  margin-top: .25rem;
}

.groups-search-row label {
  font-size: .8rem;
  color: var(--muted);
}

.groups-search-input {
  flex: 1 1 220px;
  min-width: 0;
  max-width: 280px;
  padding: .45rem .7rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--bd);
  background: var(--bg-soft);
  font-size: .85rem;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.groups-search-input:focus {
  border-color: #2563eb;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(37,99,235,.25);
}

/* ─────────────────────────────────────────────────────────────────────────────
   6. Groups grid
   ───────────────────────────────────────────────────────────────────────────── */
.groups-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.groups-list.is-single {
  grid-template-columns: 1fr !important;
  max-width: 900px;
  margin: 0 auto;
}

/* ─────────────────────────────────────────────────────────────────────────────
   7. Group card
   ───────────────────────────────────────────────────────────────────────────── */
.group-card {
  min-height: 360px;
  height: auto;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--bd);
  border-radius: var(--r-md);
  box-shadow: var(--sh);
  overflow: hidden;
}

/* ── 7a. Hero image + day badge + share button ── */
.group-img-wrap {
  position: relative;
  padding-top: 56.25%; /* 16:9 */
  background: #e5e7eb;
}

.group-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Day-of-week badge overlaid on the image */
.group-day {
  position: absolute;
  top: .45rem;
  left: .45rem;
  background: #fff;
  padding: .25rem .5rem;
  border-radius: var(--r-pill);
  font-size: .65rem;
  font-weight: 800;
  text-transform: uppercase;
  z-index: 2;
}

/* Circular share / link button */
.group-link {
  position: absolute;
  top: .45rem;
  right: .45rem;
  background: #fff;
  border: 1px solid var(--bd);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,.12);
  text-decoration: none;
  color: #111;
  z-index: 2;
}

.group-link:hover {
  background: #000;
  color: #fff;
}

.group-share-icon {
  width: 16px;
  height: 16px;
  display: block;
}

/* ── 7b. Card body ── */
.group-body {
  padding: .75rem .9rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  flex: 1; /* allows footer to push down */
}

.group-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

.group-campus,
.group-time {
  font-size: .8rem;
  color: var(--muted);
}

/* Snippet (clamped) description */
.group-desc {
  font-size: .8rem;
  color: #475569;
  line-height: 1.3;
  margin-top: .15rem;
  overflow: hidden;
  margin-bottom: 0;
}

.group-desc.is-collapsed {
  display: -webkit-box;
  -webkit-box-orient: vertical;
}

.group-desc.is-expanded {
  display: block;
}

/* Full description (expanded / detail view) */
.group-desc-full {
  font-size: .8rem;
  color: #475569;
  line-height: 1.3;
}

.group-desc-full p          { margin: 0 0 .4rem; }
.group-desc-full p:last-child { margin-bottom: 0; }
.group-desc-full ul,
.group-desc-full ol         { margin: .35rem 0 .35rem 1rem; padding: 0; }
.group-desc-full li         { margin-bottom: .2rem; }
.group-desc-full a          { color: #2563eb; text-decoration: underline; }

.group-desc-wrap {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

/* ── 7c. Card footer + buttons ── */
.group-footer {
  margin-top: auto;
  padding: .6rem .9rem;
  border-top: 1px solid var(--bd);
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: nowrap;
}

.group-footer-actions {
  display: flex;
  gap: .4rem;
  align-items: center;
  flex-wrap: nowrap;
}

/* Normalise all group action buttons */
.group-btn,
.group-btn--ghost,
.group-readmore {
  height: 36px;
  padding: 0 .85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  line-height: 1;
}

.group-btn {
  border-radius: var(--r-pill);
  border: 1px solid #d1d5db;
  background: #fff;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: #111827;
}

.group-btn--ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  border-radius: var(--r-pill);
  border: 1px solid #e5e7eb;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  background: #f9fafb;
  color: #111827;
  text-decoration: none;
  transition: background .15s ease, box-shadow .15s ease, transform .08s ease;
}

.group-btn--ghost:hover {
  background: var(--bg-soft);
  box-shadow: 0 1px 2px rgba(15,23,42,.08);
  transform: translateY(-1px);
}

.group-btn--ghost:active {
  transform: translateY(0);
  box-shadow: none;
}

.group-readmore {
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
  border: 1px solid #d1d5db;
  background: #fff;
  font-size: .75rem;
  font-weight: 600;
  color: #2563eb;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15,23,42,.06);
  align-self: center;
  margin-top: .2rem;
}

.group-readmore:hover { background: var(--bg-soft); }
.group-readmore:focus { outline: none; }

/* ─────────────────────────────────────────────────────────────────────────────
   8. Single-group detail view
   ───────────────────────────────────────────────────────────────────────────── */
.groups-list.is-single .group-card {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  grid-template-areas:
    "image body"
    "image footer";
  column-gap: 1.75rem;
  row-gap: .35rem;
  padding: 1.5rem;
  align-items: start;
}

.groups-list.is-single .group-img-wrap {
  grid-area: image;
  padding-top: 0;
}

.groups-list.is-single .group-img {
  position: relative;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 14px;
}

.groups-list.is-single .group-body {
  grid-area: body;
  padding: 0;
}

.groups-list.is-single .group-footer {
  grid-area: footer;
  border-top: none;
  padding: .75rem 0 0;
  margin: 0;
}

/* Hide Read More toggle in detail view */
.groups-list.is-single [data-toggle] {
  display: none !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   9. Return link
   ───────────────────────────────────────────────────────────────────────────── */
.groups-return {
  display: flex;
  margin-bottom: 20px;
}

.groups-return a,
.groups-return-link {
  font-size: .72rem;
  color: var(--accent);
  text-decoration: none;
}

.groups-return a:hover,
.groups-return-link:hover {
  text-decoration: underline;
}

/* ─────────────────────────────────────────────────────────────────────────────
   10. Empty state
   ───────────────────────────────────────────────────────────────────────────── */
.groups-empty {
  margin-top: 1.4rem;
  font-size: .9rem;
  color: var(--muted);
  text-align: center;
}

/* ─────────────────────────────────────────────────────────────────────────────
   11. Gutenberg alignment (wide / full)
   ───────────────────────────────────────────────────────────────────────────── */
.alignwide  .groups-shell,
.alignfull  .groups-shell {
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  border-radius: 0;
}

.alignfull .groups-shell {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

/* ─────────────────────────────────────────────────────────────────────────────
   12. Responsive overrides
   ───────────────────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .groups-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .groups-list { grid-template-columns: 1fr; }
  .groups-shell { padding: 1.3rem 1rem 1.6rem; }
}

@media (max-width: 900px) {
  .groups-list.is-single .group-card {
    grid-template-columns: 1fr;
    grid-template-areas: "image" "body" "footer";
    padding: 1.1rem;
  }
}
