/* ============================================================
   cx-expand — Expandable card with FLIP morph
   Vanilla port of expandable-card.tsx (Aceternity / framer-motion layoutId)
   Hooks into any element marked .cx-review-trigger or .cx-expand-trigger
   ============================================================ */

/* ---------- Overlay (backdrop) ---------- */

.cx-expand-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, .50);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 9000;
  display: grid;
  place-items: center;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  opacity: 0;
  pointer-events: none;
  transition: opacity .45s cubic-bezier(.32, .72, 0, 1);
}

.cx-expand-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

html[data-theme="dark"] .cx-expand-overlay {
  background: rgba(0, 0, 0, .55);
}

/* ---------- Card wrapper (FLIP target) ---------- */

.cx-expand-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 850px;
  max-height: 92vh;
  overflow: hidden;
  background: var(--cx-bg-soft, #f9fbfc);
  border-radius: 22px;
  box-shadow:
    0 1px 2px rgba(2,21,33, .04),
    0 24px 60px -20px rgba(2,21,33, .35),
    0 40px 90px -30px rgba(2,21,33, .25);
  will-change: transform, opacity;
  transform-origin: center center;
}

@media (min-width: 640px) {
  .cx-expand-card {
    margin-top: 32px;
    border-radius: 24px 24px 12px 12px;
  }
}

html[data-theme="dark"] .cx-expand-card {
  background: var(--cx-bg-mute, #18181c);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, .4),
    0 24px 60px -20px rgba(0, 0, 0, .6),
    0 40px 90px -30px rgba(0, 0, 0, .55);
}

/* ---------- Scrollable area ---------- */

.cx-expand-card__scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.cx-expand-card__scroll::-webkit-scrollbar { width: 8px; }
.cx-expand-card__scroll::-webkit-scrollbar-thumb {
  background: rgba(2,21,33, .15);
  border-radius: 99px;
}

/* ---------- Hero (always company logo, never cropped) ---------- */

.cx-expand-card__hero {
  position: relative;
  width: 100%;
  height: clamp(200px, 32vh, 280px);
  background:
    radial-gradient(circle at 30% 30%, rgba(28,164,175,.10), transparent 55%),
    radial-gradient(circle at 70% 70%, rgba(28,164,175,.10), transparent 55%),
    linear-gradient(135deg, rgba(28,164,175,.04), rgba(28,164,175,.02));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 48px;
  overflow: hidden;
}

.cx-expand-card__hero::after {
  content: "";
  position: absolute;
  inset-x: 0;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(to top, var(--cx-bg-soft, #f9fbfc), transparent);
  z-index: 2;
  pointer-events: none;
}

html[data-theme="dark"] .cx-expand-card__hero {
  background:
    radial-gradient(circle at 30% 30%, rgba(28,164,175,.14), transparent 55%),
    radial-gradient(circle at 70% 70%, rgba(28,164,175,.10), transparent 55%),
    linear-gradient(135deg, rgba(0,0,0,.20), rgba(0,0,0,.05));
}

html[data-theme="dark"] .cx-expand-card__hero::after {
  background: linear-gradient(to top, var(--cx-bg-mute, #18181c), transparent);
}

.cx-expand-card__hero img {
  max-width: 60%;
  max-height: 75%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 8px 24px rgba(2,21,33, .12));
}

/* Fallback when no logo (rare) — just a soft pattern */
.cx-expand-card__hero--empty {
  background:
    radial-gradient(circle at 30% 30%, rgba(28,164,175,.18), transparent 55%),
    radial-gradient(circle at 70% 70%, rgba(28,164,175,.14), transparent 55%);
}

/* ---------- Header (title row) ---------- */

.cx-expand-card__head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 22px 28px 6px;
}

.cx-expand-card__avatar {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--cx-card, #fff);
  border: 3px solid var(--cx-bg-soft, #f9fbfc);
  overflow: hidden;
  margin-top: 2px;
  box-shadow: 0 4px 12px rgba(2,21,33, .10);
  position: relative;
  z-index: 3;
}

.cx-expand-card__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

html[data-theme="dark"] .cx-expand-card__avatar {
  background: var(--cx-bg-mute, #18181c);
  border-color: var(--cx-bg-mute, #18181c);
}

/* Hide avatar if no person photo */
.cx-expand-card__avatar:empty,
.cx-expand-card__avatar img[src=""],
.cx-expand-card__avatar img:not([src]) { display: none; }

.cx-expand-card__avatar--missing { display: none; }

.cx-expand-card__head-text {
  flex: 1;
  min-width: 0;
}

.cx-expand-card__desc {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--cx-mute, #657078);
  line-height: 1.4;
}

.cx-expand-card__title {
  margin: 4px 0 0;
  font-size: clamp(1.6rem, 2.4vw + .5rem, 2.2rem);
  font-weight: 800;
  letter-spacing: -.015em;
  line-height: 1.15;
  color: var(--cx-ink, #021521);
}

html[data-theme="dark"] .cx-expand-card__title { color: var(--cx-ink, #f1f4f6); }
html[data-theme="dark"] .cx-expand-card__desc  { color: var(--cx-mute, #aab2b8); }

/* ---------- Close button ---------- */

.cx-expand-card__close {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(2,21,33, .12);
  background: var(--cx-card, #fff);
  color: var(--cx-ink, #021521);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .25s ease, transform .35s cubic-bezier(.34, 1.56, .64, 1), border-color .25s ease;
  padding: 0;
}

.cx-expand-card__close svg {
  width: 18px;
  height: 18px;
  transition: transform .4s cubic-bezier(.34, 1.56, .64, 1);
}

.cx-expand-card__close:hover {
  background: rgba(2,21,33, .06);
  border-color: rgba(2,21,33, .2);
  color: var(--cx-blue, #00828c);
}

.cx-expand-card__close:hover svg { transform: rotate(45deg); }

.cx-expand-card__close:focus-visible {
  outline: 2px solid var(--cx-blue, #00828c);
  outline-offset: 3px;
}

html[data-theme="dark"] .cx-expand-card__close {
  background: var(--cx-bg-soft, #0a1e2a);
  border-color: rgba(255, 255, 255, .12);
  color: var(--cx-ink, #f1f4f6);
}

html[data-theme="dark"] .cx-expand-card__close:hover {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .2);
}

/* ---------- Body (rich content) ---------- */

.cx-expand-card__body {
  padding: 14px 28px 32px;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--cx-mute, #47555d);
}

.cx-expand-card__body p {
  margin: 0 0 14px;
}

.cx-expand-card__body .cx-expand-card__quote {
  position: relative;
  margin: 0 0 22px;
  padding: 0;
  border-left: 3px solid var(--cx-blue, #00828c);
  padding-left: 18px;
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--cx-ink, #021521);
}

.cx-expand-card__quote::before {
  content: "\201C";
  position: absolute;
  top: -6px;
  left: -2px;
  font-size: 2.6rem;
  color: var(--cx-blue, #00828c);
  font-weight: 800;
  font-style: normal;
  line-height: 1;
  opacity: .25;
}

html[data-theme="dark"] .cx-expand-card__body { color: var(--cx-mute, #aab2b8); }
html[data-theme="dark"] .cx-expand-card__quote { color: var(--cx-ink, #f1f4f6); }

/* Cloned ce-card sections (Reto / Solución / KPIs / Web) */
.cx-expand-card__body .ce-card__block {
  margin: 0 0 18px;
}

.cx-expand-card__body .ce-card__label {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--cx-blue, #00828c);
  margin: 0 0 6px;
}

.cx-expand-card__body .ce-card__text {
  font-size: .96rem;
  line-height: 1.6;
  color: var(--cx-mute, #47555d);
  margin: 0;
}

.cx-expand-card__body .ce-card__kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 18px 0 6px;
}

.cx-expand-card__body .ce-card__kpi {
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  background: rgba(28,164,175, .05);
  border: 1px solid rgba(28,164,175, .14);
  border-radius: 12px;
}

.cx-expand-card__body .ce-card__kpi-val {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--cx-blue, #00828c);
  letter-spacing: -.01em;
  line-height: 1.1;
}

.cx-expand-card__body .ce-card__kpi-lbl {
  font-size: 12px;
  color: var(--cx-mute, #657078);
  margin-top: 4px;
  line-height: 1.3;
}

.cx-expand-card__body .ce-card__web {
  display: inline-block;
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--cx-blue, #00828c);
  text-decoration: none;
  font-weight: 600;
}

.cx-expand-card__body .ce-card__web:hover { text-decoration: underline; }

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .cx-expand-overlay,
  .cx-expand-card,
  .cx-expand-card__close svg { transition-duration: .2s !important; }
  .cx-expand-card { transform: none !important; }
}

/* ---------- Mobile ---------- */

@media (max-width: 640px) {
  .cx-expand-overlay { padding: 0; align-items: flex-end; }
  .cx-expand-card {
    max-height: 95vh;
    border-radius: 20px 20px 0 0;
  }
  .cx-expand-card__hero { height: clamp(180px, 32vh, 260px); }
  .cx-expand-card__head { padding: 20px 22px 4px; }
  .cx-expand-card__body { padding: 12px 22px 28px; }
}
