/* VetConnect — 3D Anatomy Viewer (Three.js)
   Premium medical-visualization aesthetic inspired by Vetflow / 3D Bovine Anatomy.
*/

.anatomy-3d {
  position: relative;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  aspect-ratio: 4 / 3;
  background:
    radial-gradient(ellipse at 50% 30%, #F7F8FA 0%, #EBEDF2 60%, #DDE0E8 100%);
  border-radius: var(--radius-2xl);
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(15, 23, 33, 0.06),
    var(--shadow-lg);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
[data-theme="dark"] .anatomy-3d {
  background:
    radial-gradient(ellipse at 50% 30%, #1A2029 0%, #11161E 60%, #0A0E15 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    var(--shadow-xl);
}

.anatomy-3d canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  outline: none;
  cursor: grab;
}
.anatomy-3d canvas:active { cursor: grabbing; }

/* ─── Top-left: species switcher ─────────────────────────────── */
.anatomy-3d-species {
  position: absolute;
  top: var(--space-4);
  left: var(--space-4);
  z-index: 4;
  display: flex;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--color-surface-tint);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md);
  max-width: calc(100% - var(--space-8));
  overflow-x: auto;
  scrollbar-width: none;
}
.anatomy-3d-species::-webkit-scrollbar { display: none; }

.anatomy-3d-species button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 22px;
  color: var(--color-text-secondary);
  transition: all var(--duration-fast) var(--ease-out-quart);
}
.anatomy-3d-species button:hover {
  background: rgba(255, 255, 255, 0.6);
}
.anatomy-3d-species button.active {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  box-shadow: 0 2px 8px -2px rgba(23, 106, 68, 0.5);
  transform: scale(1.05);
}

/* ─── Top-right: layer toggle ────────────────────────────────── */
.anatomy-3d-layers {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 4;
  display: flex;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--color-surface-tint);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md);
}
.anatomy-3d-layers button {
  padding: var(--space-2) var(--space-4);
  min-height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--duration-fast) var(--ease-out-quart);
}
.anatomy-3d-layers button:hover { color: var(--color-text-strong); }
.anatomy-3d-layers button.active {
  background: var(--color-surface);
  color: var(--color-text-strong);
  box-shadow: var(--shadow-xs);
}

/* ─── Bottom-left: camera controls ───────────────────────────── */
.anatomy-3d-controls {
  position: absolute;
  bottom: var(--space-4);
  left: var(--space-4);
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2);
  background: var(--color-surface-tint);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}
.anatomy-3d-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: all var(--duration-fast) var(--ease-out-quart);
}
.anatomy-3d-controls button:hover {
  background: rgba(255, 255, 255, 0.7);
  color: var(--color-text-strong);
}

/* ─── Bottom-right: instructions hint ────────────────────────── */
.anatomy-3d-hint {
  position: absolute;
  bottom: var(--space-4);
  right: var(--space-4);
  z-index: 4;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-tint);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1_5);
  pointer-events: none;
  opacity: 0.9;
}

/* ─── Hotspot label (HTML overlay over 3D scene) ─────────────── */
.anatomy-3d-tooltip {
  position: absolute;
  z-index: 5;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-text-strong);
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px));
  transition:
    transform var(--duration-base) var(--ease-spring),
    opacity   var(--duration-base) var(--ease-out-expo);
  letter-spacing: var(--tracking-normal);
}
.anatomy-3d-tooltip::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border-subtle);
  border-bottom: 1px solid var(--color-border-subtle);
}
.anatomy-3d-tooltip[hidden] { display: none; }

/* ─── Loading overlay for the 3D scene ───────────────────────── */
.anatomy-3d-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  z-index: 3;
  background: var(--color-surface-tint);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  animation: vc-page-in var(--duration-base) var(--ease-out-expo);
}
.anatomy-3d-loading .spinner {
  width: 32px;
  height: 32px;
}
.anatomy-3d-loading .label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
  letter-spacing: var(--tracking-normal);
}

/* ─── Selected zones summary chips (below viewer) ────────────── */
.anatomy-3d-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding: 0 var(--space-1);
}
.anatomy-3d-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1px solid rgba(196, 50, 43, 0.18);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  animation: vc-toast-in var(--duration-base) var(--ease-spring);
}
.anatomy-3d-chip .remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-circle);
  background: rgba(196, 50, 43, 0.15);
  color: var(--color-error);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

/* ─── Empty state (no zone selected) ─────────────────────────── */
.anatomy-3d-empty {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border: 1px dashed var(--color-border-default);
  border-radius: var(--radius-xl);
  text-align: center;
  color: var(--color-text-tertiary);
  font-size: var(--text-sm);
  font-style: italic;
  background: var(--color-surface-sunken);
}

/* ─── Sketchfab embed overlay polish ─────────────────────────── */
.anatomy-3d .sf-iframe {
  pointer-events: auto;
  /* The embed shows a small Sketchfab badge in the bottom-right by default
     unless you pay for "Watermark Removal". Our gesture-hint chip is placed
     bottom-right and covers/disguises it. */
}

.anatomy-3d .sf-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  z-index: 6;
  background:
    radial-gradient(ellipse at 50% 30%, #F7F8FA 0%, #EBEDF2 60%, #DDE0E8 100%);
  animation: vc-page-in var(--duration-base) var(--ease-out-expo);
}
.anatomy-3d .sf-loading .spinner { width: 36px; height: 36px; }
.anatomy-3d .sf-loading .label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
}

/* Attribution chip — bottom center, replaces Sketchfab's branding */
.anatomy-3d .sf-credit {
  position: absolute;
  bottom: var(--space-2);
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  padding: 4px 10px;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: rgba(15, 23, 33, 0.45);
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  pointer-events: none;
  max-width: 60%;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tooltip flash for region-name announcement (Sketchfab path) */
.anatomy-3d .anatomy-3d-tooltip {
  z-index: 7;
  pointer-events: none;
}

/* ─── First-touch hint banner ────────────────────────────────── */
.sf-tap-hint {
  position: absolute;
  top: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px 6px 12px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.011em;
  color: var(--color-text-strong);
  background: var(--color-surface-tint);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  animation: sf-tap-hint-in 600ms 500ms cubic-bezier(0.34, 1.45, 0.5, 1) both;
}
.sf-tap-hint svg {
  color: var(--color-primary);
}
.sf-tap-hint.hide {
  animation: sf-tap-hint-out 300ms ease forwards;
}
@keyframes sf-tap-hint-in {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes sf-tap-hint-out {
  to { opacity: 0; transform: translate(-50%, -8px); }
}

/* ─── Selection PIN markers on the Sketchfab cow ─────────────── */
.sf-pin {
  animation: sf-pin-in 240ms cubic-bezier(0.34, 1.45, 0.5, 1);
}
.sf-pin.removing {
  animation: sf-pin-out 220ms ease forwards;
}
@keyframes sf-pin-in {
  from { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
@keyframes sf-pin-out {
  to { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
}

.sf-pin-dot {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #C4322B;
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.95),
    0 0 0 4px rgba(196, 50, 43, 0.6),
    0 2px 8px rgba(196, 50, 43, 0.5);
}

.sf-pin-pulse {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(196, 50, 43, 0.5);
  animation: sf-pin-pulse 1.6s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}
@keyframes sf-pin-pulse {
  0%   { transform: translate(-50%, -50%) scale(1);   opacity: 0.7; }
  100% { transform: translate(-50%, -50%) scale(3.5); opacity: 0; }
}

.sf-pin-label {
  position: absolute;
  left: 50%;
  bottom: calc(50% + 18px);
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 12px;
  background: #FFFFFF;
  border: 1px solid var(--color-border-subtle);
  border-radius: 999px;
  box-shadow:
    0 2px 4px rgba(15, 23, 33, 0.06),
    0 8px 24px rgba(15, 23, 33, 0.12);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-strong);
  white-space: nowrap;
  letter-spacing: -0.011em;
}
.sf-pin-label::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 7px;
  height: 7px;
  background: #FFFFFF;
  border-right: 1px solid var(--color-border-subtle);
  border-bottom: 1px solid var(--color-border-subtle);
}

.sf-pin-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(196, 50, 43, 0.12);
  color: #C4322B;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}
.sf-pin-remove:hover {
  background: rgba(196, 50, 43, 0.25);
}

/* ─── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .anatomy-3d { aspect-ratio: 1 / 1; border-radius: var(--radius-xl); }
  .anatomy-3d-species button { width: 36px; height: 36px; font-size: 20px; }
  .anatomy-3d-layers button {
    padding: var(--space-1_5) var(--space-3);
    font-size: var(--text-xs);
    min-height: 32px;
  }
  .anatomy-3d-hint { display: none; }
}
