/* ==========================================================================
   ICCA Team Members — Styles
   Section 1: .icca-team-map  (bubble map)
   Section 2: .icca-team-grid (filterable member cards)
   ========================================================================== */

/* ── Shared tokens ────────────────────────────────────────────────────────── */
:root {
  --icca-bg: #f7f9fb;
  --icca-navy: #18304d;
  --icca-green: #61bb46;
  --icca-card-bg: #e8f1f1;
  --icca-pill-idle: #d7f0f2;
  --icca-radius-lg: 8px;
  --icca-radius-xl: 24px;
  --icca-font: "Montserrat", MontserratFallback, sans-serif;
}

/* ── Header override: applied only on pages with the team shortcodes ─────── */

body.icca-team-page #header-outer {
  background-color: #f7f9fb !important;
  box-shadow: none !important;
}

@media (max-width: 1024px) {
  body.icca-team-page #ajax-content-wrap .container.main-content {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
}

/* ── Section 1: Category Bubble Map ────────────────────────────────────────── */

.icca-team-map {
  background: var(--icca-bg);
  padding: 64px 96px 0;
  overflow: visible; /* allow circles to extend past bottom edge */
}

.icca-team-map__heading {
  font-family: var(--icca-font);
  font-weight: 700;
  font-size: clamp(36px, 6.67vw, 96px);
  color: var(--icca-navy);
  text-align: center;
  line-height: 1;
  margin: 0 0 40px;
}

.icca-team-map__heading.is-map-pending {
  opacity: 0;
  transform: translateY(28px);
}

.icca-team-map__heading.is-map-visible {
  animation: icca-map-heading-enter 0.75s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: var(--icca-map-enter-delay, 0s);
}

/* Stage: relative container holding all absolute-positioned bubbles.
   aspect-ratio locks width+height together (1248x650 desktop canvas — a bit
   taller than Figma's raw 560 to give the PHP-side collision resolver room
   to spread bubbles apart) so left/top/size percentages stay proportionally
   correct at ANY container width instead of only lining up at exactly 1248px. */
.icca-team-map__stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1248 / 650;
  overflow: visible;
}

/* ── Float animation — uses CSS translate individual property ─────────────── */

@keyframes icca-float {
  0%,
  100% {
    translate: 0 0px;
  }
  50% {
    translate: 0 -10px;
  }
}

@keyframes icca-map-heading-enter {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes icca-bubble-enter {
  from {
    opacity: 0;
    scale: 0.88;
    filter: saturate(0.82) blur(6px);
  }
  to {
    opacity: 1;
    scale: 1;
    filter: saturate(0.96) blur(0);
  }
}

/* ── Bubbles ──────────────────────────────────────────────────────────────── */

.icca-bubble {
  position: absolute;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  cursor: pointer;
  border: none;
  font-family: var(--icca-font);
  color: #333232;
  text-align: center;
  background-color: transparent;
  opacity: 1;
  filter: saturate(0.96) brightness(1);
  transform: translate3d(0, 0, 0);
  box-shadow: 0 0 0 rgba(24, 48, 77, 0);

  /* Positions/size are percentages set inline by PHP (of the stage's own
     width/height) — width drives the diameter, height is derived from it via
     aspect-ratio so the bubble always stays a perfect circle at any width. */
  left: var(--dl, 0);
  top: var(--dt, 0);
  width: var(--ds, 13.62%);
  height: auto;
  aspect-ratio: 1 / 1;

  /* Continuous float (own per-bubble delay/duration set via data-term-slug
     rules below, so bubbles never move in sync) + smooth hover transitions */
  animation: icca-float var(--icca-float-duration, 4s) ease-in-out infinite;
  animation-delay: var(--icca-float-delay, 0s);
  transition: all 3s ease-out;
  will-change: transform, filter, box-shadow, opacity;
}

.icca-bubble.is-map-pending:not(.is-map-visible) {
  opacity: 0;
}

.icca-bubble.is-map-visible {
  animation:
    icca-bubble-enter 0.7s cubic-bezier(0.22, 1, 0.36, 1) both,
    icca-float 4s ease-in-out infinite;
  animation-delay: var(--icca-map-enter-delay, 0s), var(--icca-float-delay, 0s);
  animation-duration: 0.7s, var(--icca-float-duration, 4s);
}

@media (prefers-reduced-motion: reduce) {
  .icca-team-map__heading.is-map-pending,
  .icca-bubble.is-map-pending:not(.is-map-visible) {
    opacity: 1;
    transform: none;
    scale: 1;
    filter: saturate(0.96) brightness(1);
  }

  .icca-team-map__heading.is-map-visible,
  .icca-bubble.is-map-visible {
    animation: none;
  }
}

/* Scale uses CSS individual 'scale' property so it stacks with the float translate */
.icca-bubble:hover:not(.icca-bubble--deco),
.icca-bubble--active {
  scale: 1.08;
  transform: translate3d(0, -4px, 0);
  box-shadow: 0 18px 34px rgba(24, 48, 77, 0.18);
  filter: saturate(1.05) brightness(1.02);
  z-index: 2;
}

/* Desaturate all siblings when any interactive bubble is hovered */
.icca-team-map__stage:has(.icca-bubble:not(.icca-bubble--deco):hover)
  .icca-bubble:not(:hover):not(.icca-bubble--deco) {
  filter: saturate(0.28) brightness(1.04);
}

/* Staggered animation delays per region */
.icca-bubble[data-term-slug="head-office"] {
  --icca-float-delay: 0s;
  --icca-float-duration: 4.2s;
}
.icca-bubble[data-term-slug="icca-association-advisory-council"] {
  --icca-float-delay: 0.7s;
  --icca-float-duration: 3.8s;
}
.icca-bubble[data-term-slug="icca-board"] {
  --icca-float-delay: 1.4s;
  --icca-float-duration: 4.6s;
}
.icca-bubble[data-term-slug="icca-future-leaders-council"] {
  --icca-float-delay: 2.1s;
  --icca-float-duration: 3.6s;
}
.icca-bubble[data-term-slug="global-research-centre"] {
  --icca-float-delay: 2.8s;
  --icca-float-duration: 4.4s;
}
.icca-bubble[data-term-slug="icca-chapter-chairs-deputy-chairs"] {
  --icca-float-delay: 0.35s;
  --icca-float-duration: 5s;
}
.icca-bubble[data-term-slug="icca-regional-teams"] {
  --icca-float-delay: 1.05s;
  --icca-float-duration: 4s;
}

.icca-bubble__name {
  font-size: 16px;
  font-style: normal;
  font-weight: 700;
  line-height: 24px; /* 150% */
  display: block;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
  max-width: 100%;
}

.icca-bubble__arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  opacity: 0.9;
  margin-top: 6px;
  transition: all 3s ease-out;
}

.icca-bubble__arrow img {
  display: block;
  width: 24px !important;
  height: 24px !important;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(24, 48, 77, 0.08));
  transition: all 3s ease-out;
}

.icca-bubble:hover:not(.icca-bubble--deco) .icca-bubble__arrow,
.icca-bubble--active .icca-bubble__arrow {
  transform: translate(3px, -3px);
  opacity: 1;
}

.icca-bubble:hover:not(.icca-bubble--deco) .icca-bubble__arrow img,
.icca-bubble--active .icca-bubble__arrow img {
  transform: translate(3px, -3px);
}

/* ── Decorative circles (non-interactive, desktop-only) ──────────────────── */

.icca-bubble--deco {
  cursor: default;
  pointer-events: none;
  background: var(--icca-card-bg) !important;
  scale: 1 !important; /* never scale */
  filter: none !important; /* never desaturate */
  animation: none !important; /* only the interactive category bubbles float */
}

/* Figma-accurate decorative positions — all % of the 1248x650 stage canvas
   so they scale in lockstep with the interactive bubbles (aspect-ratio 1/1
   via height:auto keeps them perfectly circular at any container width). */
.icca-bubble--deco-a {
  left: 58.6%;
  top: 42.77%;
  width: 19.55%;
  height: auto;
  aspect-ratio: 1 / 1;
  animation-delay: 1.75s;
  animation-duration: 5.2s;
}
.icca-bubble--deco-b {
  left: 0.4%;
  top: 31.85%;
  width: 13.62%;
  height: auto;
  aspect-ratio: 1 / 1;
  animation-delay: 0.85s;
  animation-duration: 3.9s;
}
.icca-bubble--deco-c {
  left: -9.3%;
  top: 11.23%;
  width: 13.62%;
  height: auto;
  aspect-ratio: 1 / 1;
  animation-delay: 2.45s;
  animation-duration: 4.7s;
}
.icca-bubble--deco-d {
  left: 16%;
  top: 44.92%;
  width: 6.57%;
  height: auto;
  aspect-ratio: 1 / 1;
  animation-delay: 3.15s;
  animation-duration: 3.5s;
}

/* ── Section 2: Team Member Grid ────────────────────────────────────────── */

.icca-team-grid {
  background: var(--icca-bg);
  padding: 64px 0px;
}

.icca-team-grid__inner {
  max-width: 1440px;
  margin: 0 auto;
  position: relative; /* needed for loading overlay */
  display: flex;
  flex-direction: column;
  gap: 0;
}

.icca-team-grid__heading {
  font-family: var(--icca-font);
  font-weight: 700;
  font-size: clamp(28px, 3.33vw, 48px);
  color: var(--icca-navy);
  text-align: center;
  line-height: 1.1;
  margin: 0 0 24px;
}

/* ── Filter pills ──────────────────────────────────────────────────────────── */

.icca-team-grid__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  margin-bottom: 48px;
}

.icca-filter-btn {
  padding: 8px 20px;
  border-radius: 9999px;
  font-family: var(--icca-font);
  font-weight: 700;
  font-size: 14px;
  line-height: 24px;
  border: none;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
  background: var(--icca-pill-idle);
  color: var(--icca-navy);
}

.icca-filter-btn--active {
  background: var(--icca-navy);
  color: var(--icca-card-bg);
}

.icca-filter-btn:hover:not(.icca-filter-btn--active) {
  background: #c0e5e9;
}

/* ── Member cards grid ─────────────────────────────────────────────────────── */

.icca-team-grid__cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  min-height: 180px;
}

.icca-team-grid__empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--icca-navy);
  font-family: var(--icca-font);
  padding: 40px 0;
}

.icca-team-grid__pagination {
  display: flex;
  justify-content: center;
  margin-top: 40px;
}

.icca-pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.icca-team-grid__page-btn {
  min-width: 44px;
  padding: 10px 16px;
  border: none;
  border-radius: 9999px;
  background: var(--icca-pill-idle);
  color: var(--icca-navy);
  font-family: var(--icca-font);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    opacity 0.2s ease;
}

.icca-team-grid__page-btn:hover:not(:disabled):not(
    .icca-team-grid__page-btn--active
  ) {
  background: #c0e5e9;
}

.icca-team-grid__page-btn--active {
  background: var(--icca-navy);
  color: var(--icca-card-bg);
}

.icca-team-grid__page-btn:disabled {
  cursor: default;
  opacity: 0.45;
}

.icca-team-grid__page-btn--nav {
  min-width: 90px;
}

/* Cards stay idle until they actually enter the viewport */
.icca-team-grid__cards .icca-member-card.is-pending:not(.is-in-view) {
  opacity: 0;
  transform: translateY(18px) scale(0.985);
}

/* Staggered entrance is triggered only after JS marks the card in-view */
.icca-team-grid__cards .icca-member-card.is-in-view {
  animation: icca-card-enter 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: var(--icca-card-delay, 0s);
}

@keyframes icca-card-enter {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .icca-team-grid__cards .icca-member-card.is-pending:not(.is-in-view) {
    opacity: 1;
    transform: none;
  }

  .icca-team-grid__cards .icca-member-card.is-in-view {
    animation: none;
  }
}

/* ── Member card ─────────────────────────────────────────────────────────── */

.icca-member-card {
  background: #ffffff;
  border-radius: var(--icca-radius-lg);
  padding: 32px 32px 48px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: box-shadow 0.25s ease;
}

/* Keep the subtitle clear of the 60px bite the phone/email buttons cut into the corner */
.icca-member-card:has(.icca-card__email-shape) {
  padding-bottom: 72px;
}

.icca-member-card.is-hidden {
  display: none;
}

/* Photo wrapper — square, rounded corners, green stripe background */
.icca-card__photo-wrap {
  position: relative;
  width: 100%;
  flex-shrink: 0;
  aspect-ratio: 1 / 1;
  border-radius: var(--icca-radius-xl);
  overflow: hidden;
  /* Striped green fallback (visible behind transparent areas of photo) */
  background-color: #61bb46;
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 8px,
    rgba(0, 60, 20, 0.09) 8px,
    rgba(0, 60, 20, 0.09) 16px
  );
}

.icca-card__img {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  border-radius: var(--icca-radius-xl);
  display: block;
}

/* LinkedIn button — bottom-left of photo */
.icca-card__linkedin {
  position: absolute;
  bottom: 24px;
  left: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--icca-navy);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  z-index: 2;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.icca-card__linkedin:hover {
  opacity: 0.8;
}

.icca-card__linkedin svg {
  display: block;
  width: 20px !important;
  height: 20px !important;
  flex-shrink: 0;
}

/* Card text */
.icca-card__info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0; /* prevents flex child from overflowing its container */
  width: 100%;
}

.icca-card__name {
  font-family: "Montserrat", sans-serif !important;
  font-weight: 700 !important;
  font-size: 18px !important;
  line-height: 28px !important;
  color: var(--icca-navy) !important;
  margin: 0 !important;
  padding: 0 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  overflow-wrap: break-word;
}

.icca-card__subtitle {
  font-family: "Montserrat", sans-serif !important;
  font-weight: 400 !important;
  font-size: 16px !important;
  line-height: 24px !important;
  color: var(--icca-navy) !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow-wrap: break-word;
}

/* Email button — masking shape (same paint-over technique as ytc-post-slider carousel) */
.icca-card__email-shape {
  position: absolute;
  bottom: 0;
  right: 0;
  display: flex;
  height: 48px;
  z-index: 1;
}

/* Paints the page background over the card's bottom-right corner, creating the concave bite.
   Width follows the buttons, so the bite grows when a phone button sits beside the email. */
.icca-card__email-shape::before {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: calc(100% + 12px);
  height: 60px;
  background: var(--icca-bg);
  border-top-left-radius: 24px;
  z-index: -1;
}

/* Concave corner fills — smooth the gap between the masking square edges and the card */
.icca-card__email-corner::before {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  border-bottom-right-radius: 18px;
  box-shadow: 8px 8px 0 var(--icca-bg);
  right: 0;
  bottom: 60px;
}

.icca-card__email-corner::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  border-bottom-right-radius: 18px;
  box-shadow: 8px 8px 0 var(--icca-bg);
  right: calc(100% + 12px);
  bottom: 0;
}

/* The actual button circle */
.icca-card__email {
  position: relative;
  z-index: 1;
  display: flex;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #358526;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.icca-card__email:hover {
  background: #4aa832;
}

/* Phone button — same circle as email, sits to its left */
.icca-card__phone:not(:last-child) {
  margin-right: 8px;
}

.icca-card__phone img {
  display: block;
  width: 20px !important;
  height: 20px !important;
  margin: 0 !important;
}

/* ── Loading overlay ─────────────────────────────────────────────────────── */

.icca-team-grid__loading {
  position: absolute;
  inset: 0;
  background: rgba(247, 249, 251, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  border-radius: var(--icca-radius-lg);
  z-index: 10;
}

.icca-team-grid.is-loading .icca-team-grid__loading {
  opacity: 1;
  pointer-events: auto;
}

.icca-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--icca-pill-idle);
  border-top-color: var(--icca-navy);
  border-radius: 50%;
  animation: icca-spin 0.75s linear infinite;
}

@keyframes icca-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Responsive: Tablet bubble map (1025px – 1024px… kept for grid) ──────── */

@media (max-width: 1024px) {
  .icca-team-map {
    padding: 48px 0px 32px !important;
    overflow: visible;
  }

  /* Grid section */
  .icca-team-grid {
    padding: 48px 16px;
  }

  .icca-team-grid__cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .icca-team-grid__filters {
    flex-wrap: nowrap;
    overflow-x: scroll;
    overflow-y: hidden; /* prevents phantom vertical scrollbar gutter stealing width */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    justify-content: flex-start;
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    margin-bottom: 32px;
    padding: 0 0 0 24px;
    box-sizing: border-box;
    scrollbar-width: none;
    cursor: grab;
  }

  .icca-team-grid__filters.is-dragging {
    cursor: grabbing;
    user-select: none;
  }

  .icca-team-grid__filters::-webkit-scrollbar {
    display: none;
  }

  .icca-filter-btn {
    flex-shrink: 0;
  }

  .icca-team-grid__pagination {
    margin-top: 32px;
    padding: 0 24px;
  }

  .icca-pagination {
    gap: 8px;
  }

  .icca-card__photo-wrap {
    aspect-ratio: unset;
    height: 320px;
  }
}

/* ── Responsive: Mobile + tablet bubble map (≤1024px) ───────────────────── */
/* Absolute-positioned stacked bubbles, sized generously to fit each label on
   2 lines at a fixed 16px font. Stage height is set per-render via the
   --icca-mobile-stage-h custom prop (PHP shrinks it to hug the actual
   vertically-compacted content, falls back to 950 if unset) so there's no
   leftover empty gap below the last bubble — percentages still scale
   correctly at any actual rendered width because width+height are locked
   together. */

@media (max-width: 1024px) {
  .icca-team-map__stage {
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
    aspect-ratio: 393 / var(--icca-mobile-stage-h, 950);
    overflow: visible;
  }

  /* Switch all interactive bubbles to mobile CSS custom props */
  .icca-bubble:not(.icca-bubble--deco) {
    left: var(--ml, var(--dl));
    top: var(--mt, var(--dt));
    width: var(--ms, var(--ds));
    /* height: percentage of stage height ≠ width; use aspect-ratio to keep circles */
    height: auto;
    aspect-ratio: 1 / 1;
  }

  /* Hide decorative circles on mobile/tablet */
  .icca-bubble--deco {
    display: none;
  }
}

/* ── Responsive: Mobile (≤600px) ────────────────────────────────────────── */

@media (max-width: 600px) {
  .icca-team-map {
    padding: 40px 0 0;
  }

  .icca-team-map__stage {
    width: calc(100% - 12px);
  }

  .icca-team-map__heading {
    font-size: clamp(28px, 10vw, 48px);
  }

  .icca-team-grid {
    padding: 32px 16px;
  }

  .icca-team-grid__heading {
    font-size: 38px !important;
    line-height: 1.1 !important;
  }

  .icca-team-grid__filters {
    gap: 8px;
    padding-left: 16px;
  }

  .icca-team-grid__pagination {
    padding: 0 16px;
  }

  .icca-team-grid__page-btn {
    min-width: 40px;
    padding: 10px 14px;
  }

  .icca-team-grid__page-btn--nav {
    min-width: 78px;
  }

  .icca-team-grid__cards {
    grid-template-columns: 1fr;
  }

  .icca-card__photo-wrap {
    aspect-ratio: unset;
    height: 300px;
  }
}

/* ── Section 3: Team Category Grid (.icca-tcg) ──────────────────────────────
   Inner elements reuse the .icca-team-grid__* rules above; only the section
   wrapper + its loading state are defined here. Heading stays static.
   Vertical spacing is left to the WPBakery row so it can be set per page. */

.icca-tcg {
  background: var(--icca-bg);
  padding: 0;
}

.icca-tcg.is-loading .icca-team-grid__loading {
  opacity: 1;
  pointer-events: auto;
}

/* body.icca-team-page strips the container gutter at ≤1024px, so keep a side gutter here */
@media (max-width: 1024px) {
  .icca-tcg {
    padding: 0 16px;
  }
}
