/* ════════════════════════════════════════════════════════════════════════════
   CARD INTRO  ·  cardIntro.css
   Append this file at the bottom of main.css  — OR  @import it.
   All classes are namespaced ci-* so nothing conflicts with existing styles.
════════════════════════════════════════════════════════════════════════════ */

/* ── Wrap: full-screen overlay ─────────────────────────────────────────────── */
.ci-wrap {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* Entry: starts invisible + dropped */
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.35s var(--ease-out-expo, cubic-bezier(.16,1,.3,1));
}
.ci-wrap.ci-visible {
  opacity: 1;
  pointer-events: all;
}
/* Final fade-out after flip completes */
.ci-wrap.ci-done {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

/* ── Backdrop blur layer ───────────────────────────────────────────────────── */
.ci-backdrop {
  position: absolute;
  inset: 0;
  background: var(--ci-backdrop-bg);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  transition: opacity 0.5s ease;
}
.ci-backdrop.ci-backdrop-fade {
  opacity: 0;
}

/* ── 3-D perspective scene ─────────────────────────────────────────────────── */
.ci-scene {
  perspective: 1200px;
  perspective-origin: 50% 45%;
  position: relative;
  z-index: 1;
  width: min(420px, calc(100vw - 32px));
}

/* ── Flipper — the rotating element ───────────────────────────────────────── */
.ci-flipper {
  position: relative;
  width: 100%;
  /* Card ratio 1.586 (credit-card) */
  aspect-ratio: 1.586 / 1;
  transform-style: preserve-3d;
  /* Entry animation */
  transform: translateY(56px) scale(0.88) rotateX(6deg);
  transition:
    transform 0.65s var(--ease-spring, cubic-bezier(.34,1.56,.64,1)),
    opacity   0.5s  var(--ease-out-expo, cubic-bezier(.16,1,.3,1));
  opacity: 0;
  will-change: transform;
}
.ci-visible .ci-flipper {
  transform: translateY(0) scale(1) rotateX(0deg);
  opacity: 1;
  transition-delay: 80ms;
}
/* The flip itself */
.ci-flipper.ci-flipped {
  transform: rotateY(-180deg) scale(0.94);
  transition:
    transform 0.48s cubic-bezier(.55, 0, .45, 1),
    opacity   0.48s ease;
  opacity: 0;
}

/* ── Shared face styles ────────────────────────────────────────────────────── */
.ci-face {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* ── FRONT face ────────────────────────────────────────────────────────────── */
.ci-front {
  cursor: pointer;
  overflow: hidden;
}
.ci-front:focus-visible {
  outline: 2px solid var(--primary, #2BBDEE);
  outline-offset: 4px;
}

/* ── BACK face ─────────────────────────────────────────────────────────────── */
.ci-back {
  transform: rotateY(180deg);
  background: transparent;
}
.ci-back-reveal {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ci-back-glow {
  width: 60%;
  height: 60%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--primary-shadow, rgba(43,189,238,0.3)), transparent 70%);
  filter: blur(32px);
}

/* ════════════════════════════════════════════════════════════════════════════
   THE CARD  (ci-card)
════════════════════════════════════════════════════════════════════════════ */
.ci-card {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px var(--ci-border),
    0 12px 40px rgba(0,0,0,0.55),
    0 32px 80px rgba(0,0,0,0.35),
    0 0 60px var(--ci-glow-shadow);
  /* hover lift */
  transition: transform 0.25s var(--ease-spring, cubic-bezier(.34,1.56,.64,1)),
              box-shadow 0.25s ease;
}
.ci-front:hover .ci-card {
  transform: translateY(-4px) scale(1.008);
  box-shadow:
    0 0 0 1px var(--ci-border),
    0 20px 60px rgba(0,0,0,0.6),
    0 40px 100px rgba(0,0,0,0.4),
    0 0 80px var(--ci-glow-shadow);
}
.ci-front:active .ci-card {
  transform: scale(0.97);
  transition-duration: 0.1s;
}

/* Card gradient background */
.ci-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--ci-bg1), var(--ci-bg2));
  z-index: 0;
}

/* ── Mesh glow ─────────────────────────────────────────────────────────────── */
.ci-mesh {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: radial-gradient(
    ellipse 90% 70% at -10% -10%,
    var(--ci-mesh-color) 0%,
    transparent 65%
  );
  pointer-events: none;
}

/* ── Sheen diagonal ────────────────────────────────────────────────────────── */
.ci-sheen {
  position: absolute;
  inset: -50%;
  z-index: 2;
  transform: rotate(-25deg);
  background: linear-gradient(
    to right,
    transparent 0%,
    var(--ci-sheen-color) 43%,
    var(--ci-sheen-peak)  50%,
    var(--ci-sheen-color) 57%,
    transparent 100%
  );
  pointer-events: none;
  animation: ci-sheen-drift 8s ease-in-out infinite;
}
@keyframes ci-sheen-drift {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* ── Avatar background ─────────────────────────────────────────────────────── */
.ci-avatar-bg {
  position: absolute;
  inset: 0;
  z-index: 3;
}
.ci-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center right;
  opacity: 0.80;
  display: block;
}
.ci-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 130% 110% at 75% -20%,
    transparent 0%,
    var(--ci-vignette-mid) 50%,
    var(--ci-bg2) 100%
  );
}
/* No avatar case */
.ci-vignette-solid {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: linear-gradient(135deg, var(--ci-bg1), var(--ci-bg2));
}

/* ── Content layer ─────────────────────────────────────────────────────────── */
.ci-content {
  position: absolute;
  inset: 0;
  z-index: 10;
  padding: 18px 18px 0 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* ── TOP ROW ───────────────────────────────────────────────────────────────── */
.ci-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.ci-top-left {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: calc(100% - 100px); /* leave room for QR */
}

/* Logo box */
.ci-logo-wrap {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  border: 1.5px solid var(--ci-accent-35);
  background: rgba(0,0,0,0.3);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
  box-shadow:
    0 4px 12px rgba(0,0,0,0.3),
    0 0 8px var(--ci-glow-shadow);
  flex-shrink: 0;
}
.ci-logo-img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 6px;
}

/* Tier badge */
.ci-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 7px;
  background: var(--ci-accent);
  color: var(--ci-badge-text);
  font-family: 'DM Sans', 'Plus Jakarta Sans', sans-serif;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  width: fit-content;
}
.ci-badge svg { flex-shrink: 0; }

/* Name */
.ci-name {
  font-family: 'Sora', 'Plus Jakarta Sans', sans-serif;
  font-size: clamp(16px, 4.2vw, 22px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ci-text-primary);
  word-break: break-word;
}

/* Member ID */
.ci-member-id {
  font-family: 'DM Sans', 'Plus Jakarta Sans', sans-serif;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ci-text-secondary);
}

/* ── QR — flush top-right corner ───────────────────────────────────────────── */
.ci-qr-corner {
  position: absolute;
  top: 0; right: 0;
  width: 92px; height: 92px;
  /* Only bottom-left corner rounded — matching Flutter _CornerClipper.bottomLeft */
  clip-path: polygon(
    0 0,
    100% 0,
    100% 100%,
    18px 100%,
    0 calc(100% - 18px)
  );
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ci-qr-canvas {
  width: 92px; height: 92px;
  display: block;
}

/* ── BOTTOM ROW ────────────────────────────────────────────────────────────── */
.ci-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 0;
}
.ci-bottom-left {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-bottom: 16px;
  max-width: calc(100% - 68px); /* leave room for NFC */
}

/* URL pill */
.ci-url-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 20px;
  background: var(--ci-pill-bg);
  border: 1px solid var(--ci-pill-border);
  font-family: 'DM Sans', sans-serif;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--ci-text-secondary);
  max-width: 100%;
  overflow: hidden;
}
.ci-url-pill svg { flex-shrink: 0; color: var(--ci-accent); }
.ci-url-pill span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Masked number */
.ci-masked-num {
  font-family: 'DM Sans', 'Plus Jakarta Sans', sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  color: var(--ci-masked-color);
}

/* ── NFC — flush bottom-right corner ──────────────────────────────────────── */
.ci-nfc-corner {
  position: absolute;
  bottom: 0; right: 0;
  width: 60px; height: 60px;
  /* Only top-left corner rounded — matching Flutter _CornerClipper.topLeft */
  clip-path: polygon(
    16px 0,
    100% 0,
    100% 100%,
    0 100%,
    0 16px
  );
  background: var(--ci-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ci-badge-text);
  animation: ci-nfc-pulse 1.4s ease-in-out infinite;
}
@keyframes ci-nfc-pulse {
  0%, 100% { opacity: 1;    }
  50%       { opacity: 0.72; }
}

/* ── Click-here hint with arrow ───────────────────────────────────────────── */
.ci-hint {
  position: absolute;
  bottom: -52px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  opacity: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ci-hint-color);
  white-space: nowrap;
  pointer-events: none;
  /* Smooth fade-in on page load */
  transition: opacity 0.5s cubic-bezier(.16,1,.3,1),
              transform 0.5s cubic-bezier(.16,1,.3,1);
  will-change: opacity, transform;
}

/* Visible state — fade in + subtle float */
.ci-hint.ci-hint-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  animation: ci-hint-float 2.4s ease-in-out infinite 0.6s;
}

/* Smooth exit — fade out before card flips */
.ci-hint.ci-hint-exit {
  opacity: 0 !important;
  transform: translateX(-50%) translateY(-6px) !important;
  transition: opacity 0.3s ease, transform 0.3s ease !important;
  animation: none !important;
}

@keyframes ci-hint-float {
  0%, 100% { transform: translateX(-50%) translateY(0);   }
  50%       { transform: translateX(-50%) translateY(-5px); }
}

/* Pulsing dot */
.ci-hint-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ci-accent);
  animation: ci-dot-pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes ci-dot-pulse {
  0%, 100% { transform: scale(1);   opacity: 1;    }
  50%       { transform: scale(1.8); opacity: 0.45; }
}

/* Arrow pointing UP toward the card */
.ci-hint-arrow {
  flex-shrink: 0;
  color: var(--ci-accent);
  animation: ci-arrow-bounce 1.2s ease-in-out infinite;
  will-change: transform;
}
@keyframes ci-arrow-bounce {
  0%, 100% { transform: translateY(0);   }
  50%       { transform: translateY(-5px); }
}

/* ════════════════════════════════════════════════════════════════════════════
   THEME TOKENS  — applied via [data-theme] on .ci-card
   These map to your existing Flutter palette exactly.
════════════════════════════════════════════════════════════════════════════ */

/* ── DARK theme (default) ──────────────────────────────────────────────────── */
.ci-card[data-theme="dark"],
.ci-card:not([data-theme]) {
  --ci-bg1:           #1A2C33;
  --ci-bg2:           #0F171A;
  --ci-accent:        #2BBDEE;
  --ci-accent-35:     rgba(43,189,238,0.35);
  --ci-badge-text:    #FFFFFF;
  --ci-text-primary:  #FFFFFF;
  --ci-text-secondary:rgba(255,255,255,0.5);
  --ci-pill-bg:       rgba(0,0,0,0.25);
  --ci-pill-border:   rgba(255,255,255,0.08);
  --ci-masked-color:  rgba(255,255,255,0.22);
  --ci-mesh-color:    rgba(43,189,238,0.09);
  --ci-sheen-color:   rgba(43,189,238,0.04);
  --ci-sheen-peak:    rgba(43,189,238,0.10);
  --ci-vignette-mid:  rgba(15,23,26,0.4);
  --ci-border:        rgba(43,189,238,0.25);
  --ci-glow-shadow:   rgba(43,189,238,0.18);
  --ci-hint-color:    rgba(255,255,255,0.55);
}
/* Backdrop for dark */
.ci-wrap:has(.ci-card[data-theme="dark"]) .ci-backdrop,
.ci-wrap:has(.ci-card:not([data-theme])) .ci-backdrop {
  --ci-backdrop-bg: rgba(10,16,18,0.85);
}

/* ── LIGHT theme ───────────────────────────────────────────────────────────── */
.ci-card[data-theme="light"] {
  --ci-bg1:           #FFFFFF;
  --ci-bg2:           #F4F7F9;
  --ci-accent:        #2BBDEE;
  --ci-accent-35:     rgba(43,189,238,0.35);
  --ci-badge-text:    #FFFFFF;
  --ci-text-primary:  #1F2937;
  --ci-text-secondary:#6B7280;
  --ci-pill-bg:       rgba(0,0,0,0.05);
  --ci-pill-border:   rgba(0,0,0,0.10);
  --ci-masked-color:  rgba(107,114,128,0.45);
  --ci-mesh-color:    rgba(43,189,238,0.07);
  --ci-sheen-color:   rgba(43,189,238,0.03);
  --ci-sheen-peak:    rgba(43,189,238,0.07);
  --ci-vignette-mid:  rgba(244,247,249,0.45);
  --ci-border:        rgba(43,189,238,0.22);
  --ci-glow-shadow:   rgba(43,189,238,0.14);
  --ci-hint-color:    rgba(107,114,128,0.8);
}
.ci-wrap:has(.ci-card[data-theme="light"]) .ci-backdrop {
  --ci-backdrop-bg: rgba(240,244,247,0.88);
}

/* ── GOLD / LUXURY theme ───────────────────────────────────────────────────── */
.ci-card[data-theme="luxury"],
.ci-card[data-theme="gold"] {
  --ci-bg1:           #1C1508;
  --ci-bg2:           #0B0B0B;
  --ci-accent:        #D4AF37;
  --ci-accent-35:     rgba(212,175,55,0.35);
  --ci-badge-text:    #0B0B0B;
  --ci-text-primary:  #F5EDD8;
  --ci-text-secondary:rgba(212,175,55,0.55);
  --ci-pill-bg:       rgba(212,175,55,0.08);
  --ci-pill-border:   rgba(212,175,55,0.18);
  --ci-masked-color:  rgba(212,175,55,0.22);
  --ci-mesh-color:    rgba(212,175,55,0.09);
  --ci-sheen-color:   rgba(212,175,55,0.05);
  --ci-sheen-peak:    rgba(255,215,0,0.14);
  --ci-vignette-mid:  rgba(11,11,11,0.5);
  --ci-border:        rgba(212,175,55,0.30);
  --ci-glow-shadow:   rgba(212,175,55,0.22);
  --ci-hint-color:    rgba(212,175,55,0.6);
}
.ci-wrap:has(.ci-card[data-theme="luxury"]) .ci-backdrop,
.ci-wrap:has(.ci-card[data-theme="gold"]) .ci-backdrop {
  --ci-backdrop-bg: rgba(8,6,2,0.90);
}

/* Gold card — richer box shadow */
.ci-card[data-theme="luxury"],
.ci-card[data-theme="gold"] {
  box-shadow:
    0 0 0 1px rgba(212,175,55,0.3),
    0 12px 40px rgba(0,0,0,0.7),
    0 32px 80px rgba(0,0,0,0.5),
    0 0 80px rgba(212,175,55,0.18);
}

/* ════════════════════════════════════════════════════════════════════════════
   Reduced motion
════════════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .ci-flipper,
  .ci-wrap,
  .ci-card,
  .ci-hint { transition: none !important; animation: none !important; }
  .ci-wrap.ci-visible .ci-flipper {
    transform: none;
    opacity: 1;
  }
}