/* First-visit OrbitControls coach mark — glass language, no purple. */
#gesture-hint {
  position: fixed;
  inset: 0;
  z-index: 18;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(5.5rem, 18vh) 1rem 0;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

#gesture-hint.is-visible {
  opacity: 1;
  visibility: visible;
}

#gesture-hint.is-leaving {
  opacity: 0;
}

.gesture-hint__card {
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  max-width: min(20.5rem, calc(100vw - 2rem));
  padding: 1rem 1.15rem 0.9rem;
  border-radius: 1.15rem;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
  color: #0f172a;
  text-align: center;
}

.dark-mode .gesture-hint__card {
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(51, 65, 85, 0.8);
  color: #f8fafc;
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.45);
}

.gesture-hint__stage {
  position: relative;
  width: 7.5rem;
  height: 5.25rem;
}

.gesture-hint__orbit {
  position: absolute;
  inset: 0.35rem 0.55rem;
  border: 1.5px dashed rgba(100, 116, 139, 0.45);
  border-radius: 9999px;
  opacity: 0.85;
}

.dark-mode .gesture-hint__orbit {
  border-color: rgba(148, 163, 184, 0.4);
}

.gesture-hint__arrow {
  position: absolute;
  top: 50%;
  width: 0.7rem;
  height: 0.7rem;
  border-top: 2px solid #334155;
  border-right: 2px solid #334155;
  opacity: 0.7;
  transform-origin: center;
}

.dark-mode .gesture-hint__arrow {
  border-color: #cbd5e1;
}

.gesture-hint__arrow--left {
  left: 0.15rem;
  transform: translateY(-50%) rotate(-135deg);
}

.gesture-hint__arrow--right {
  right: 0.15rem;
  transform: translateY(-50%) rotate(45deg);
}

.gesture-hint__hand {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 2.35rem;
  height: 2.35rem;
  margin: -1.15rem 0 0 -1.15rem;
  color: #0f172a;
  filter: drop-shadow(0 4px 8px rgba(15, 23, 42, 0.18));
}

.dark-mode .gesture-hint__hand {
  color: #f8fafc;
  filter: drop-shadow(0 4px 8px rgba(2, 6, 23, 0.5));
}

.gesture-hint__hand svg {
  width: 100%;
  height: 100%;
  display: block;
}

.gesture-hint__copy {
  display: grid;
  gap: 0.2rem;
}

.gesture-hint__title {
  margin: 0;
  font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.gesture-hint__detail {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: #64748b;
}

.dark-mode .gesture-hint__detail {
  color: #94a3b8;
}

.gesture-hint__dismiss {
  pointer-events: auto;
  min-height: 44px;
  min-width: 6.5rem;
  padding: 0.55rem 1rem;
  border: 0;
  border-radius: 9999px;
  background: #0f172a;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.22);
}

.gesture-hint__dismiss:hover {
  background: #1e293b;
}

.dark-mode .gesture-hint__dismiss {
  background: #f8fafc;
  color: #0f172a;
}

.dark-mode .gesture-hint__dismiss:hover {
  background: #e2e8f0;
}

#gesture-hint-help {
  position: fixed;
  z-index: 22;
  right: 0.75rem;
  bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #334155;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dark-mode #gesture-hint-help {
  background: rgba(15, 23, 42, 0.88);
  border-color: rgba(51, 65, 85, 0.75);
  color: #e2e8f0;
}

#gesture-hint-help:hover {
  color: #0f172a;
}

.dark-mode #gesture-hint-help:hover {
  color: #fff;
}

@media (max-width: 767px) {
  #gesture-hint {
    padding-top: max(4.75rem, 14vh);
  }

  /* Keep clear of the bottom directory drawer and top HUD. */
  body:not(.directory-collapsed) #gesture-hint-help {
    bottom: calc(54vh + 0.65rem);
  }

  body.has-selected-route #gesture-hint-help {
    bottom: calc(43dvh + 0.65rem);
  }

  body.directory-collapsed #gesture-hint-help {
    bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  }
}

@media (min-width: 768px) {
  #gesture-hint {
    padding-top: max(6.5rem, 22vh);
  }

  /* Sit clear of the left directory and the bottom-right minimap / D-pad. */
  #gesture-hint-help {
    right: auto;
    left: calc(360px + 1.35rem);
    bottom: 0.85rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .gesture-hint__orbit {
    animation: gesture-orbit-pulse 2.4s ease-in-out infinite;
  }

  .gesture-hint__arrow--left {
    animation: gesture-arrow-left 1.6s ease-in-out infinite;
  }

  .gesture-hint__arrow--right {
    animation: gesture-arrow-right 1.6s ease-in-out infinite;
  }

  .gesture-hint__hand {
    animation: gesture-hand-drag 1.6s ease-in-out infinite;
  }
}

@keyframes gesture-hand-drag {
  0%,
  100% {
    transform: translateX(-18px) rotate(-8deg);
  }
  50% {
    transform: translateX(18px) rotate(8deg);
  }
}

@keyframes gesture-arrow-left {
  0%,
  100% {
    opacity: 0.35;
    transform: translate(-2px, -50%) rotate(-135deg);
  }
  50% {
    opacity: 0.9;
    transform: translate(2px, -50%) rotate(-135deg);
  }
}

@keyframes gesture-arrow-right {
  0%,
  100% {
    opacity: 0.35;
    transform: translate(2px, -50%) rotate(45deg);
  }
  50% {
    opacity: 0.9;
    transform: translate(-2px, -50%) rotate(45deg);
  }
}

@keyframes gesture-orbit-pulse {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.98);
  }
  50% {
    opacity: 0.95;
    transform: scale(1.02);
  }
}
