/* globe-view.css — 3D spinning person-globe for Prinda
   "Football" metaphor: each person card is a patch on a spinning ball.
   All classes prefixed gv- to avoid collisions with the rest of the app.
   ─────────────────────────────────────────────────────────────────────── */

/* ══════════════════════════════════════════════════════
   OUTER WRAP
   ══════════════════════════════════════════════════════ */
.gv-wrap {
  /* Avatar size token — overridden per-mount by JS based on people count.
     CSS calc() scales patch dimensions proportionally. */
  --gv-av: 56px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 12px 0 16px;
  position: relative;
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Ambient background glow behind the ball */
.gv-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 55% at 50% 38%,
      rgba(108, 60, 225, 0.13) 0%,
      rgba(255, 93, 108, 0.04) 55%,
      transparent 75%);
  pointer-events: none;
  z-index: 0;
}

/* ══════════════════════════════════════════════════════
   PERSPECTIVE STAGE
   ══════════════════════════════════════════════════════ */
.gv-stage {
  /* perspective set here — all 3D magic happens inside */
  perspective: 680px;
  perspective-origin: 50% 44%;
  position: relative;
  width: 100%;
  /* height driven by JS: radius * 2 + 80 */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  overflow: visible;
  cursor: grab;           /* drag anywhere in the stage to spin */
  touch-action: none;     /* prevent browser scroll-hijacking during sphere drag */
}
.gv-stage.gv-dragging {
  cursor: grabbing;
}

/* ── The static sphere "ball" — does NOT rotate ──────
   This is what makes it look like a real ball:
   Gradient sphere body + specular highlight + edge vignette.
   Sits behind the rotating patches via z-index: 0.           */
.gv-ball {
  position: absolute;
  border-radius: 50%;
  /* Size set via JS: width = height = radius * 2 */
  pointer-events: none;
  z-index: 0;
  background:
    /* specular highlight: top-left white catch-light */
    radial-gradient(ellipse 48% 42% at 32% 27%,
      rgba(255, 255, 255, 0.20) 0%,
      transparent 58%),
    /* soft secondary fill — warm lavender tint */
    radial-gradient(ellipse 90% 85% at 50% 45%,
      rgba(108, 60, 225, 0.10) 0%,
      rgba(75, 35, 176, 0.06) 40%,
      transparent 75%),
    /* edge vignette — makes it feel spherical */
    radial-gradient(ellipse 100% 100% at 50% 50%,
      transparent 42%,
      rgba(20, 10, 40, 0.18) 70%,
      rgba(10, 5, 25, 0.42) 100%);
  box-shadow:
    /* outer glow — ambient light */
    0 0 60px rgba(108, 60, 225, 0.14),
    /* ground shadow */
    0 18px 50px rgba(0, 0, 0, 0.18),
    /* inset highlight ring */
    inset 0 0 0 1px rgba(108, 60, 225, 0.12),
    inset 0 -6px 24px rgba(0, 0, 0, 0.18);
}

/* Football seam lines on the ball (::before = vertical curve, ::after = horizontal) */
.gv-ball::before,
.gv-ball::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.055);
  pointer-events: none;
}
/* Vertical seam — runs pole to pole at an angle */
.gv-ball::before {
  width: 58%;
  height: 118%;
  top: -9%;
  left: 21%;
  transform: rotateZ(28deg);
}
/* Horizontal seam — girdles the ball */
.gv-ball::after {
  width: 120%;
  height: 56%;
  top: 22%;
  left: -10%;
  transform: rotateZ(-22deg);
}

/* ── Lighting shade overlay — also does NOT rotate ──
   Stacks ABOVE the rotating patches (z-index: 30).
   Creates the illusion of real directional lighting
   on a sphere — dark bottom-right, light top-left.     */
.gv-shade {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 30;
  background:
    /* top-left rim specular */
    radial-gradient(ellipse 46% 40% at 28% 22%,
      rgba(255, 255, 255, 0.14) 0%,
      transparent 52%),
    /* bottom-right deep shadow */
    radial-gradient(ellipse 52% 48% at 72% 76%,
      rgba(0, 0, 0, 0.36) 0%,
      transparent 55%),
    /* edge vignette (matches gv-ball) */
    radial-gradient(ellipse 100% 100% at 50% 50%,
      transparent 40%,
      rgba(10, 5, 25, 0.22) 68%,
      rgba(5, 2, 14, 0.50) 100%);
}

/* ══════════════════════════════════════════════════════
   THE ROTATING ORB
   ══════════════════════════════════════════════════════ */
.gv-orb {
  position: relative;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  cursor: grab;
  /* JS applies: transform: rotateX(Xdeg) rotateY(Ydeg) */
}
.gv-orb.gv-dragging {
  cursor: grabbing;
}

/* ══════════════════════════════════════════════════════
   INDIVIDUAL PATCH (card on sphere surface)
   ══════════════════════════════════════════════════════ */
.gv-patch {
  position: absolute;
  /* JS applies: transform: rotateY(Y) rotateX(X) translateZ(R) */
  /* Size driven by --gv-av token (set by JS based on people count) */
  width:  calc(var(--gv-av) + 20px);
  height: calc(var(--gv-av) + 28px);
  /* Centre the patch on its point */
  margin: calc(-0.5 * (var(--gv-av) + 28px)) 0 0 calc(-0.5 * (var(--gv-av) + 20px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  will-change: opacity, filter;
}
.gv-patch.gv-near-front {
  pointer-events: auto;
}

/* ── Inner card wrapper — scaled per-frame by JS for depth effect ─── */
.gv-card-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  /* transform: scale() applied by JS — no CSS transition so it tracks at 60fps */
  will-change: transform;
}

/* ── Avatar circle ───────────────────────────────── */
.gv-avatar {
  width:  var(--gv-av);
  height: var(--gv-av);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Initials font scales with avatar — clamp keeps it readable at all sizes */
  font-size: clamp(0.85rem, calc(var(--gv-av) * 0.28), 1.9rem);
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  /* Glass-like: inset highlight at top, dark rim at bottom */
  border: 2px solid rgba(255, 255, 255, 0.20);
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.40),
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -2px 0 rgba(0, 0, 0, 0.25);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}
.gv-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* Front card: glowing violet ring.
   No transform: scale() here — JS _updateDepths() already drives a smooth
   depth-based scale on .gv-card-inner. Adding scale(1.15) here would compound
   that and cause a visible pop when a card arrives at front-centre. */
.gv-patch.gv-is-front .gv-avatar {
  box-shadow:
    0 0 0 3px #fff,
    0 0 0 5px rgba(108, 60, 225, 0.55),
    0 8px 36px rgba(108, 60, 225, 0.60),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
/* Me card: gold ring when front */
.gv-patch.gv-is-me.gv-is-front .gv-avatar {
  box-shadow:
    0 0 0 3px #fff,
    0 0 0 5px rgba(255, 184, 48, 0.65),
    0 8px 36px rgba(255, 184, 48, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
/* Registered (connected friend): sky-blue ring */
.gv-patch.gv-is-registered.gv-is-front .gv-avatar {
  box-shadow:
    0 0 0 3px #fff,
    0 0 0 5px rgba(135, 206, 235, 0.65),
    0 8px 36px rgba(135, 206, 235, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* ── Name label below avatar ─────────────────────── */
.gv-name {
  font-size: clamp(0.60rem, calc(var(--gv-av) * 0.135), 0.88rem);
  font-weight: 700;
  color: #fff;
  text-align: center;
  max-width: calc(var(--gv-av) + 28px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* Legible over any sphere colour */
  text-shadow:
    0 1px 8px rgba(0, 0, 0, 0.95),
    0 0 20px rgba(0, 0, 0, 0.7);
  line-height: 1.2;
  /* Shown only when near-front */
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.gv-patch.gv-near-front .gv-name {
  opacity: 1;
  transform: translateY(0);
}

/* ── Gift count badge on avatar ──────────────────── */
.gv-gift-badge {
  position: absolute;
  bottom: -2px;
  right: -3px;
  background: var(--accent, #FF5D6C);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 800;
  border-radius: 999px;
  min-width: 17px;
  height: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 2px solid rgba(255, 255, 255, 0.88);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  line-height: 1;
}

/* ══════════════════════════════════════════════════════
   FOCUS PANEL — info card for the front-most person
   Sits BELOW the stage as a flex sibling in gv-wrap.
   ══════════════════════════════════════════════════════ */
.gv-focus {
  width: calc(100% - 16px);
  max-width: 290px;
  background: var(--card-bg, #FDFAF6);
  border: 2px solid var(--blue, #6C3CE1);
  border-radius: 18px;
  padding: 13px 15px 11px;
  box-shadow:
    0 12px 44px rgba(108, 60, 225, 0.18),
    0 4px 14px rgba(0, 0, 0, 0.07);
  display: none;
  flex-direction: column;
  gap: 8px;
  animation: gvFocusIn 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 40;
  margin-top: -8px; /* slight overlap with stage for visual connection */
}
.gv-focus.gv-focus-visible {
  display: flex;
}
@keyframes gvFocusIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Header row: avatar + name + badges */
.gv-focus-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
}
.gv-focus-av {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
}
.gv-focus-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.gv-focus-info {
  flex: 1;
  min-width: 0;
}
.gv-focus-name {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gv-focus-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
  align-items: center;
}
.gv-focus-badge {
  font-size: 0.62rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 6px;
  line-height: 1.4;
  white-space: nowrap;
}
.gv-focus-rel {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Budget area */
.gv-focus-budget-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.71rem;
  color: var(--muted);
  margin-bottom: 3px;
}
.gv-focus-bar {
  height: 5px;
  border-radius: 5px;
  background: var(--bg4, #dcd0fa);
  overflow: hidden;
}
.gv-focus-bar-fill {
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--accent, #FF5D6C), var(--gold, #FFB830));
  transition: width 0.4s ease;
}

/* Gifts count line (when no budget set) */
.gv-focus-gifts {
  font-size: 0.78rem;
  color: var(--muted);
}

/* Action buttons */
.gv-focus-actions {
  display: flex;
  gap: 5px;
}
.gv-focus-btn {
  flex: 1;
  padding: 7px 4px;
  border-radius: 10px;
  border: 1.5px solid var(--border, #d4c6f8);
  background: var(--bg2, #f2ecff);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.14s, border-color 0.14s;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gv-focus-btn:hover {
  background: var(--bg3, #e8dffe);
  border-color: var(--blue, #6C3CE1);
  color: var(--blue, #6C3CE1);
}
.gv-focus-btn-primary {
  background: linear-gradient(135deg, #FF5D6C, #e04a58);
  border-color: transparent;
  color: #fff;
}
.gv-focus-btn-primary:hover {
  opacity: 0.88;
  color: #fff;
}

/* ══════════════════════════════════════════════════════
   HINT TEXT
   ══════════════════════════════════════════════════════ */
.gv-hint {
  font-size: 0.68rem;
  color: rgba(100, 80, 140, 0.7);
  text-align: center;
  padding: 4px 0 0;
  pointer-events: none;
  z-index: 1;
  letter-spacing: 0.01em;
}

/* ══════════════════════════════════════════════════════
   VIEW TOGGLE STRIP — 🔲 Grid / 🌐 Globe
   Injected next to the search bar in #sidebar-search-add
   ══════════════════════════════════════════════════════ */
.gv-toggle-strip {
  display: inline-flex;
  border-radius: 10px;
  border: 1.5px solid var(--border, #d4c6f8);
  overflow: hidden;
  flex-shrink: 0;
}
.gv-toggle-btn {
  padding: 5px 10px;
  background: var(--card-bg, #FDFAF6);
  border: none;
  color: var(--muted, #4a3968);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1;
}
.gv-toggle-btn + .gv-toggle-btn {
  border-left: 1.5px solid var(--border, #d4c6f8);
}
/* Active state */
.gv-toggle-btn.gv-active {
  background: var(--blue, #6C3CE1);
  color: #fff;
}
.gv-toggle-btn:hover:not(.gv-active) {
  background: var(--bg3, #e8dffe);
  color: var(--text);
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .gv-avatar { width: 50px; height: 50px; font-size: 0.88rem; }
  .gv-patch  { width: 70px; height: 82px; margin: -41px 0 0 -35px; }
  .gv-name   { font-size: 0.63rem; max-width: 70px; }
  .gv-focus  { max-width: calc(100% - 16px); }
}
@media (max-width: 340px) {
  .gv-avatar { width: 44px; height: 44px; }
  .gv-focus  { padding: 10px 12px; }
}

/* ══════════════════════════════════════════════════════
   REDUCED MOTION
   ══════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .gv-avatar,
  .gv-name,
  .gv-focus,
  .gv-focus-bar-fill {
    transition: none;
    animation: none;
  }
  /* Still show the globe, but snap instantly */
}
