/* Touch FAB (Floating Action Button) */
.touch-fab {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 3rem;
  height: 3rem;
  background: var(--border);
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--fg);
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgb(0 0 0 / 15%);
  z-index: 1000;
  transition:
    transform 0.15s,
    border-color 0.15s;
  align-items: center;
  justify-content: center;
}

.touch-fab:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

.touch-fab:active {
  transform: scale(0.95);
}

.touch-fab.open {
  border-color: var(--accent);
}

.fab-icon {
  line-height: 1;
}

/* FAB menu flyout */
.touch-fab-menu {
  display: none;
  position: fixed;
  bottom: 6rem;
  right: 1.5rem;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 0.2s,
    transform 0.2s,
    visibility 0.2s;
}

.touch-fab-menu.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.fab-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 2rem;
  padding: 0.75rem 1.25rem;
  color: var(--fg);
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 8px rgb(0 0 0 / 15%);
  transition:
    background 0.15s,
    border-color 0.15s;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.fab-menu-item:hover {
  border-color: var(--accent);
}

.fab-menu-item:active {
  background: var(--border);
}

.fab-menu-icon {
  font-family: ui-monospace, monospace;
  font-weight: bold;
  color: var(--accent);
  min-width: 1.5rem;
  text-align: center;
}

/* Show FAB only on touch devices when vi mode is enabled */
body.vi-mode-touch .touch-fab {
  display: flex;
}

body.vi-mode-touch .touch-fab-menu {
  display: flex;
}

/* Debug button - hidden by default, shown only when eruda is loaded */
.fab-debug-btn {
  display: none !important;
}

body.eruda-ready .fab-debug-btn {
  display: flex !important;
}

/* Hide FAB when command mode or other modals are open */
body:has(#command-mode.open) .touch-fab,
body:has(#command-mode.open) .touch-fab-menu,
body:has(.chatbot.open) .touch-fab,
body:has(.chatbot.open) .touch-fab-menu {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Adjust FAB position on mobile to avoid conflicts */
@media (width <= 600px) {
  .touch-fab {
    bottom: 1rem;
    right: 1rem;
  }

  .touch-fab-menu {
    bottom: 5rem;
    right: 1rem;
  }
}
