/**
 * Keyboard Navigation Styles
 * Command palette, keyboard hints, focus indicators
 */

.command-palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  z-index: 9999;
  animation: fadeIn 0.15s ease-out;
}

.command-palette {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: 
    0 25px 50px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  overflow: hidden;
  animation: slideDown 0.2s ease-out;
}

.command-palette-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--glass-border);
}

.command-palette-header .material-symbols-outlined {
  color: var(--text-muted);
  font-size: 1.25rem;
}

.command-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1rem;
  outline: none;
}

.command-input::placeholder {
  color: var(--text-muted);
}

.esc-hint {
  padding: 0.25rem 0.5rem;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.command-palette-content {
  max-height: 400px;
  overflow-y: auto;
  padding: 0.5rem;
}

.command-section {
  margin-bottom: 0.5rem;
}

.command-section:last-child {
  margin-bottom: 0;
}

.command-section-title {
  padding: 0.5rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.command-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.command-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--text-main);
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all var(--transition-fast);
}

.command-item:hover,
.command-item:focus {
  background: var(--glass);
  outline: none;
}

.command-item:focus {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.command-item .material-symbols-outlined {
  font-size: 1.25rem;
  color: var(--text-muted);
}

.command-item span:nth-child(2) {
  flex: 1;
}

.command-item kbd {
  padding: 0.25rem 0.5rem;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.shortcuts-help {
  text-align: left;
}

.shortcuts-help h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
  color: var(--text-main);
}

.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.shortcut-item kbd {
  min-width: 100px;
  padding: 0.375rem 0.75rem;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  font-size: 0.8rem;
  color: var(--text-main);
  font-family: var(--font-mono);
  text-align: center;
}

.shortcut-item span {
  color: var(--text-muted);
  font-size: 0.875rem;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

body.keyboard-nav *:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.keyboard-nav .command-item:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent);
}

body.keyboard-nav button:focus:not(.command-item) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.5rem;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  box-shadow: 
    0 1px 0 var(--glass-border),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

.kbd-sm {
  padding: 0.125rem 0.375rem;
  font-size: 0.65rem;
}

.kbd-lg {
  padding: 0.375rem 0.75rem;
  font-size: 0.85rem;
}

.focus-indicator {
  position: relative;
}

.focus-indicator::after {
  content: '';
  position: absolute;
  inset: -4px;
  border: 2px solid var(--accent);
  border-radius: inherit;
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

body.keyboard-nav .focus-indicator:focus-within::after {
  opacity: 1;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent);
  color: white;
  padding: 0.5rem 1rem;
  z-index: 10000;
  text-decoration: none;
  border-radius: 0 0 var(--radius) 0;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[aria-live] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.keyboard-toast {
  animation: toastIn 0.3s ease-out;
}

@keyframes toastIn {
  from { transform: translate(-50%, -50%) scale(0.9); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@media (max-width: 640px) {
  .command-palette-overlay {
    padding-top: 1rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .command-palette {
    max-width: 100%;
  }
  
  .command-item kbd {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .command-palette-overlay,
  .command-palette,
  .keyboard-toast {
    animation: none;
  }
}
