.bfb-grid {
  font-family: var(--bfb-font-family, inherit);
  display: grid;
  gap: 28px;
  justify-items: center;
  align-items: stretch;
  margin: 24px auto;
}
.bfb-columns-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.bfb-columns-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bfb-columns-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.bfb-columns-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.bfb-card {
  width: min(100%, var(--bfb-card-width, 320px));
  height: var(--bfb-card-height, 430px);
  perspective: 1100px;
  outline: none;
}
.bfb-card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform var(--bfb-speed, .6s) ease;
}
.bfb-card.bfb-is-flipped .bfb-card-inner {
  transform: rotateY(180deg);
}
.bfb-flip-click .bfb-card,
.bfb-flip-both .bfb-card,
.bfb-flip-hover .bfb-card { cursor: pointer; }

.bfb-card-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: var(--bfb-radius, 14px);
  backface-visibility: hidden;
  box-shadow: 0 12px 28px rgba(0,0,0,.16);
}
.bfb-card-front { background: var(--bfb-main-tile-bg-color, var(--bfb-bottom-box-color, #fff)); display: flex; flex-direction: column; }
.bfb-photo-wrap { position: relative; height: var(--bfb-photo-height, 68%); background: rgba(0,0,0,.06); overflow: hidden; }
.bfb-photo { width: 100%; height: 100% !important; object-fit: cover; display: block; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.bfb-photo-placeholder { width: 100%; height: 100%; background: linear-gradient(135deg, #d9e3ea, #f5f7fa); }
/* Helps prevent browser image-hover tools, such as Edge Visual Search, from attaching to the displayed image area. */
.bfb-photo-wrap::after,
.bfb-modal-photo-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: transparent;
}

.bfb-spin-arrow {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--bfb-arrow-bg-color, #fff);
  color: var(--bfb-arrow-icon-color, #0073CF);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
  transition: transform .45s ease;
  z-index: 2;
}
.bfb-card:hover .bfb-spin-arrow,
.bfb-card:focus-within .bfb-spin-arrow { transform: rotate(360deg); }

.bfb-front-content {
  flex: 1;
  text-align: center;
  padding: 24px 18px;
  background: var(--bfb-main-tile-bg-color, var(--bfb-bottom-box-color, #fff));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.bfb-front-content h3 {
  color: var(--bfb-main-tile-name-color, var(--bfb-front-name-color, #0073CF)) !important;
  margin: 0 0 var(--bfb-name-title-spacing, 8px);
  font-size: var(--bfb-front-name-font-size, 1.25rem);
  line-height: 1.2;
  font-weight: var(--bfb-front-name-font-weight, 800);
}
.bfb-front-content .bfb-role {
  color: var(--bfb-main-tile-title-color, var(--bfb-front-title-color, #555)) !important;
  margin: 0 0 14px;
  font-size: var(--bfb-front-title-font-size, .95rem);
  line-height: 1.35;
  font-weight: var(--bfb-front-title-font-weight, 400);
}
.bfb-button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 10px 16px;
  font-size: var(--bfb-button-font-size, .95rem);
  font-weight: var(--bfb-button-font-weight, 800);
  text-decoration: none !important;
  transition: transform .2s ease, opacity .2s ease;
}
.bfb-button:hover,
.bfb-button:focus { transform: translateY(-1px); opacity: .92; }
.bfb-view-bio { background: var(--bfb-view-button-color, #0073CF); color: var(--bfb-view-button-text-color, #fff); }

.bfb-card-back {
  background: var(--bfb-back-color, #014D72);
  color: var(--bfb-back-text-color, #fff);
  transform: rotateY(180deg);
  display: flex;
}
.bfb-back-content {
  width: 100%;
  padding: 26px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-gutter: stable;
  position: relative;
}
.bfb-back-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  color: var(--bfb-back-text-color, #fff);
  cursor: pointer;
  font-size: 18px;
}
.bfb-back-content h3 {
  color: var(--bfb-back-text-color, #fff) !important;
  margin: 10px 0 var(--bfb-name-title-spacing, 6px);
  font-size: var(--bfb-back-name-font-size, 1.25rem);
  font-weight: var(--bfb-back-name-font-weight, 800);
}
.bfb-back-content .bfb-role {
  color: var(--bfb-back-text-color, #fff) !important;
  opacity: .92;
  margin: 0 0 14px;
  font-size: var(--bfb-back-title-font-size, .95rem);
  font-weight: var(--bfb-back-title-font-weight, 700);
}
.bfb-bio-text { color: var(--bfb-back-text-color, #fff); font-size: var(--bfb-short-bio-font-size, .96rem); line-height: var(--bfb-short-bio-line-height, 1.55); }
.bfb-bio-text p { margin: 0 0 14px; }
.bfb-full-bio { background: var(--bfb-full-button-color, #CA5010); color: var(--bfb-full-button-text-color, #fff); margin-top: 8px; }

/* True modal popup. The JavaScript moves each modal to <body> so Divi rows/sections cannot trap it. */
.bfb-modal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483000 !important;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(14px, 3vw, 32px);
  box-sizing: border-box;
}
.bfb-modal.bfb-modal-open { display: flex !important; }
.bfb-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.72);
  cursor: pointer;
}
.bfb-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(94vw, 980px);
  max-height: min(90vh, 900px);
  max-height: min(90dvh, 900px);
  display: grid;
  grid-template-columns: minmax(260px, 34%) minmax(0, 1fr);
  background: var(--bfb-popup-bg-color, #fff);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.45);
  pointer-events: auto;
}
.bfb-modal-close {
  position: absolute;
  top: 10px;
  right: 28px;
  z-index: 3;
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  color: var(--bfb-popup-close-color, #888);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.bfb-modal-close:hover,
.bfb-modal-close:focus { outline: 2px solid currentColor; outline-offset: 2px; }
.bfb-modal-photo-wrap {
  position: relative;
  background: #eef2f5;
  min-height: 420px;
  max-height: min(90vh, 900px);
  max-height: min(90dvh, 900px);
}
.bfb-popup-photo { width: 100%; height: 100% !important; object-fit: cover; display: block; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.bfb-modal-content {
  padding: 34px 58px 34px 34px;
  overflow-y: auto;
  overscroll-behavior: contain;
  max-height: min(90vh, 900px);
  max-height: min(90dvh, 900px);
  box-sizing: border-box;
}
.bfb-modal-content h2 { color: var(--bfb-popup-name-color, #0073CF) !important; margin: 0 0 var(--bfb-name-title-spacing, 4px); font-size: var(--bfb-popup-name-font-size, 1.55rem); line-height: 1.2; font-weight: var(--bfb-popup-name-font-weight, 800); }
.bfb-modal-role { color: var(--bfb-popup-title-color, #444); margin: 0 0 26px; font-size: var(--bfb-popup-title-font-size, 1rem); font-weight: var(--bfb-popup-title-font-weight, 700); }
.bfb-modal-bio { color: var(--bfb-popup-text-color, #333); font-size: var(--bfb-popup-bio-font-size, 1rem); line-height: var(--bfb-popup-bio-line-height, 1.65); }
.bfb-modal-bio p { margin: 0 0 18px; }
html.bfb-modal-lock,
body.bfb-modal-lock { overflow: hidden !important; }
body.bfb-modal-lock { touch-action: none; }

@media (max-width: 980px) {
  .bfb-columns-3,
  .bfb-columns-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .bfb-columns-1,
  .bfb-columns-2,
  .bfb-columns-3,
  .bfb-columns-4 { grid-template-columns: 1fr; }
  .bfb-card { width: min(100%, 360px); }
  .bfb-modal { padding: 12px; align-items: flex-start; overflow-y: auto; }
  .bfb-modal-dialog { grid-template-columns: 1fr; width: min(96vw, 560px); max-height: none; }
  .bfb-modal-photo-wrap { min-height: 260px; max-height: 360px; }
  .bfb-modal-close { right: 24px; top: 10px; }
  .bfb-modal-content { padding: 30px 28px 26px; max-height: 58vh; max-height: 58dvh; }
}
@media (prefers-reduced-motion: reduce) {
  .bfb-card-inner, .bfb-spin-arrow, .bfb-button { transition: none; }
}

/* Keep scrolling selectable and draggable on the flipped face. */
.bfb-card.bfb-is-flipped .bfb-card-back,
.bfb-card.bfb-is-flipped .bfb-back-content { cursor: auto; }
.bfb-card.bfb-is-flipped .bfb-back-content { user-select: text; -webkit-user-select: text; }

/* Only the active 3D face receives pointer input; back controls remain clickable. */
.bfb-card .bfb-card-front { pointer-events: auto; }
.bfb-card .bfb-card-back { pointer-events: none; }
.bfb-card.bfb-is-flipped .bfb-card-front { pointer-events: none; }
.bfb-card.bfb-is-flipped .bfb-card-back,
.bfb-card.bfb-is-flipped .bfb-back-content,
.bfb-card.bfb-is-flipped .bfb-back-toggle { pointer-events: auto; }
.bfb-back-toggle { z-index: 3; }
