/* ============================================================
   Services Grid – Frontend Styles
   ============================================================ */

/* ── CSS custom properties ─────────────────────────────── */
.sg-section {
  --sg-navy:       #0d1f45;
  --sg-gold:       #f59e0b;
  --sg-gray:       #6b7280;
  --sg-card-bg:    #ffffff;
  --sg-border:     #e5e7eb;
  --sg-badge-size: 72px;
  --sg-badge-half: calc(var(--sg-badge-size) / 2);
  --sg-radius:     14px;
  --sg-cols:       4;
  --sg-card-min:   270px;      /* cards never get narrower than this before wrapping */
  --sg-img-ratio:  16 / 10;    /* landscape banner image (matches the reference design) */
  --sg-gap:        clamp(16px, 2vw, 24px);

  padding-block: clamp(48px, 7vw, 76px);
  padding-inline: clamp(16px, 4vw, 20px);
  font-family: inherit;
  box-sizing: border-box;
}

/* The shortcode adds the `alignfull` class so the band spans full width.
   We self-centre to the viewport (width:100vw + symmetric negative margins)
   so it works on ANY theme — block or classic — regardless of whether the
   theme provides its own full-width handling. The inner .sg-grid is capped
   and centred, so cards never touch the edges or get clipped.            */
.sg-section.alignfull {
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

*, *::before, *::after { box-sizing: inherit; }

/* ── Section header ─────────────────────────────────────── */
.sg-section-header {
  display: flex;
  flex-direction: column;   /* lock order: eyebrow → title → underline → desc */
  align-items: center;
  text-align: center;
  margin-bottom: clamp(32px, 5vw, 56px);
  gap: 0;
}

.sg-eyebrow {
  display: block;
  color: var(--sg-gold);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 10px;
  order: 1;
}

.sg-title {
  display: block;
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  font-weight: 800;
  color: var(--sg-navy);
  margin: 0;
  line-height: 1.15;
  order: 2;
}

.sg-title-underline {
  display: block;
  width: 56px;
  height: 3px;
  background: var(--sg-gold);
  border-radius: 2px;
  margin: 10px 0 20px;
  order: 3;
}

.sg-subtitle {
  color: var(--sg-gray);
  font-size: clamp(0.9rem, 2.2vw, 1rem);
  line-height: 1.65;
  max-width: 620px;
  margin: 0;
  order: 4;
}

/* ── Grid ───────────────────────────────────────────────── */
/* auto-fit adapts to the CONTAINER width (not the viewport), so the
   cards wrap correctly even inside a narrow theme content column.
   Each card is at least --sg-card-min wide, never skinnier.        */
.sg-grid {
  display: grid;
  /* Honour the exact column count chosen in Grid Settings (--sg-cols). */
  grid-template-columns: repeat(var(--sg-cols, 4), minmax(0, 1fr));
  gap: var(--sg-gap);
  /* Keep it centred and from getting too wide on large monitors. */
  max-width: min(100%, calc(var(--sg-cols, 4) * var(--sg-card-min) + (var(--sg-cols, 4) - 1) * var(--sg-gap)));
  margin-inline: auto;
}

/* Responsive fallback: collapse the chosen columns as the screen narrows. */
@media (max-width: 960px) {
  .sg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .sg-grid { grid-template-columns: 1fr; }
}

/* ── Service card ───────────────────────────────────────── */
.sg-card {
  background: var(--sg-card-bg);
  border: 1px solid var(--sg-border);
  border-radius: var(--sg-radius);
  overflow: visible;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.25s, transform 0.25s;
}

.sg-card:hover {
  box-shadow: 0 10px 36px rgba(13, 31, 69, 0.10);
  transform: translateY(-5px);
}

/* ── Card image + badge ─────────────────────────────────── */
/* The image takes the top portion of the square card; the body fills
   the rest, so the whole card stays a 1:1 square box.                 */
.sg-card-media {
  position: relative;
  flex-shrink: 0;
}

/* Landscape banner via aspect-ratio — rectangular at every card width. */
.sg-card-img-wrap {
  width: 100%;
  aspect-ratio: var(--sg-img-ratio, 16 / 10);
  overflow: hidden;
  border-radius: var(--sg-radius) var(--sg-radius) 0 0;
}

.sg-card-img,
.sg-card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

.sg-card-img-placeholder {
  width: 100%;
  height: 100%;
  background: #dbe4ee;
}

.sg-card-badge {
  position: absolute;
  bottom: calc(-1 * var(--sg-badge-half));
  left: 50%;
  transform: translateX(-50%);
  width: var(--sg-badge-size);
  height: var(--sg-badge-size);
  background: var(--sg-navy);
  border-radius: 50%;
  border: 3px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 4px 14px rgba(13, 31, 69, 0.25);
}

.sg-card-badge svg {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

/* ── Card body ──────────────────────────────────────────── */
.sg-card-body {
  padding: calc(var(--sg-badge-half) + 6px) 20px 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.sg-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--sg-navy);
  margin: 0 0 6px;
  line-height: 1.3;
  min-height: 1.3em;           /* one line; grows naturally for 2-line titles */
  display: flex;
  align-items: center;
  justify-content: center;
}

.sg-card-desc {
  font-size: 0.875rem;
  color: var(--sg-gray);
  line-height: 1.55;
  margin: 0 0 14px;
  flex: 1;                     /* pushes the Learn More link to the bottom; full text always shown */
}

.sg-card-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--sg-navy);
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: gap 0.2s, color 0.2s;
}

.sg-card-link:hover {
  gap: 10px;
  color: #1d4ed8;
}

/* ── CTA card ───────────────────────────────────────────── */
.sg-cta-card {
  background: var(--sg-navy);
  border-color: var(--sg-navy);
  border-radius: var(--sg-radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 26px;
  text-align: center;
  gap: 12px;
  transition: box-shadow 0.25s, transform 0.25s;
}

.sg-cta-card:hover {
  box-shadow: 0 12px 40px rgba(13, 31, 69, 0.30);
  transform: translateY(-5px);
}

.sg-cta-icon {
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sg-cta-icon svg {
  width: 100%;
  height: 100%;
  stroke: var(--sg-gold);
  stroke-width: 1.2;
}

.sg-cta-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  line-height: 1.3;
}

.sg-cta-text {
  font-size: 0.875rem;
  color: #94a3b8;
  line-height: 1.6;
  margin: 0;
}

.sg-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--sg-gold);
  color: var(--sg-navy);
  padding: 11px 26px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.875rem;
  text-decoration: none;
  margin-top: 6px;
  transition: background 0.2s, gap 0.2s;
}

.sg-cta-btn:hover {
  background: #d97706;
  color: var(--sg-navy);
  gap: 12px;
}

/* ── Small-screen polish ────────────────────────────────── */
@media (max-width: 520px) {
  .sg-cta-card   { padding: 28px 22px; }
  .sg-card-title { min-height: 0; }   /* one card per row — no need to reserve 2 lines */
}
