/* ============================================================
   3D "office person" hero character overlay — reusable stage.
   Progressive enhancement: the markup is safe/static by default
   (fallback silhouette + all service cards visible, stacked).
   JS only escalates to the animated canvas + floating cards once
   it confirms WebGL works and the render loop actually started.
   ============================================================ */

.hero-character-stage {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 460px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0.02) 100%);
}

/* ---- Fallback silhouette (default-visible; JS fades it out) ---- */
.hero-character-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 32%, rgba(255, 255, 255, 0.20), transparent 62%);
  color: rgba(255, 255, 255, 0.55);
  opacity: 1;
  transition: opacity 0.6s var(--ease-out);
}
.hero-character-stage.js-ready .hero-character-fallback { opacity: 0; }
.hero-character-silhouette {
  filter: drop-shadow(0 12px 24px rgba(9, 25, 47, 0.35));
}

/* ---- Canvas mount (hidden until the render loop is actually running) ---- */
.hero-character-canvas,
.hero-character-canvas canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.hero-character-canvas {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s var(--ease-out);
}
.hero-character-stage.js-ready .hero-character-canvas {
  opacity: 1;
  pointer-events: auto;
}
.hero-character-stage.is-hoverable .hero-character-canvas {
  cursor: pointer;
}

/* ---- Service cards ---- */
.hero-service-cards {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  pointer-events: none;
}
.hero-service-card {
  pointer-events: auto;
  position: static;
  opacity: 1;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  max-width: 280px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  color: var(--brand-ink);
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out), opacity 0.4s var(--ease-out);
}
.hero-service-card:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: var(--shadow-glow);
}
.hero-service-card.is-pulse { animation: hero-card-pulse 0.5s var(--ease-out); }
@keyframes hero-card-pulse {
  0% { transform: scale(1); }
  45% { transform: scale(1.07); }
  100% { transform: scale(1); }
}

.hero-service-icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--brand-fill);
  color: var(--brand-primary);
}
.hero-service-copy { display: flex; flex-direction: column; gap: 2px; }
.hero-service-copy strong { font-size: 14px; color: var(--brand-ink); }
.hero-service-copy span { font-size: 12.5px; color: var(--brand-muted); }

/* ---- Once JS confirms the render loop is live, cards float + cycle ---- */
.hero-character-stage.js-cards-active .hero-service-cards {
  position: absolute;
  inset: 0;
  padding: 0;
}
.hero-character-stage.js-cards-active .hero-service-card {
  position: absolute;
  opacity: 0;
  transform: translateY(12px);
}
.hero-character-stage.js-cards-active .hero-service-card.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.hero-character-stage.js-cards-active .hero-service-card[data-index="0"] { top: 7%; left: 4%; }
.hero-character-stage.js-cards-active .hero-service-card[data-index="1"] { top: 7%; right: 4%; left: auto; }
.hero-character-stage.js-cards-active .hero-service-card[data-index="2"] { bottom: 7%; left: 4%; }
.hero-character-stage.js-cards-active .hero-service-card[data-index="3"] { bottom: 7%; right: 4%; left: auto; }

/* ---- Responsive ---- */
@media (max-width: 960px) {
  .hero-character-stage { min-height: 360px; }
}
@media (max-width: 640px) {
  .hero-character-stage { min-height: 300px; border-radius: var(--radius); }
  .hero-character-silhouette { width: 100px; height: 156px; }

  .hero-character-stage.js-cards-active .hero-service-cards {
    position: static;
    display: flex;
    flex-direction: row;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    gap: var(--space-3);
    padding: var(--space-4);
    -webkit-overflow-scrolling: touch;
  }
  .hero-character-stage.js-cards-active .hero-service-card {
    position: static;
    opacity: 1;
    transform: none;
    flex: none;
    width: 220px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-character-fallback,
  .hero-character-canvas,
  .hero-service-card {
    transition: none !important;
    animation: none !important;
  }
}
