/* SolsticioUI — SolCommandPalette (skin-aware, direction-neutral by construction). */
@layer solsticio-components {
  .sol-command-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--sol-overlay);
  }

  .sol-command-palette {
    position: fixed;
    /* Anchored above centre: the eye lands here, and a centred panel jumps as the
       result list grows and shrinks under the cursor. */
    top: 12vh;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: min(640px, calc(100vw - 32px));
    max-height: min(60vh, 560px);
    overflow: hidden;
    background: var(--sol-bg-elevated);
    border: 1px solid var(--sol-border);
    border-radius: var(--sol-radius-card);
    box-shadow: var(--sol-elev-overlay);
    font-family: var(--sol-font-family);
    color: var(--sol-text-primary);
  }

  /* === Search === */
  .sol-command-search {
    display: flex;
    align-items: center;
    gap: var(--sol-space-2, 8px);
    padding: var(--sol-space-3, 12px) var(--sol-space-4, 16px);
    border-bottom: 1px solid var(--sol-border);
    flex-shrink: 0;
  }

  .sol-command-search__icon {
    display: flex;
    color: var(--sol-text-muted);
  }

  .sol-command-search__input {
    flex: 1;
    min-width: 0;
    border: none;
    background: none;
    color: inherit;
    font-family: inherit;
    font-size: max(var(--sol-font-size-md, 14px), var(--sol-font-size-field-min, 0px));
    outline: none;
  }

  .sol-command-search__input::placeholder {
    color: var(--sol-text-muted);
  }

  .sol-command-search__spinner {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    border: 2px solid var(--sol-border);
    border-top-color: var(--sol-accent);
    border-radius: var(--sol-radius-full);
    animation: sol-command-spin 700ms linear infinite;
  }

  @media (prefers-reduced-motion: reduce) {
    .sol-command-search__spinner {
      animation: none;
      /* Still legible as "busy" without motion: a solid ring in the accent. */
      border-color: var(--sol-accent);
      opacity: 0.5;
    }
  }

  @keyframes sol-command-spin {
    to { transform: rotate(360deg); }
  }

  .sol-command-search__hint,
  .sol-command-option__shortcut,
  .sol-command-footer kbd {
    padding: 1px 5px;
    border: 1px solid var(--sol-border);
    border-radius: var(--sol-radius-action);
    background: var(--sol-bg-sunken);
    color: var(--sol-text-muted);
    font-family: var(--sol-font-family-mono, monospace);
    font-size: var(--sol-font-size-xs, 11px);
    line-height: 1.5;
  }

  /* === Results === */
  .sol-command-results {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--sol-space-1, 4px);
  }

  .sol-command-group__label {
    padding: var(--sol-space-2, 8px) var(--sol-space-3, 12px) var(--sol-space-1, 4px);
    color: var(--sol-text-muted);
    font-size: var(--sol-font-size-xs, 11px);
    font-weight: var(--sol-font-weight-semibold, 600);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .sol-command-option {
    display: flex;
    align-items: center;
    gap: var(--sol-space-3, 12px);
    padding: var(--sol-space-2, 8px) var(--sol-space-3, 12px);
    border-radius: var(--sol-radius-action);
    cursor: pointer;
  }

  /* Driven by the active INDEX, not :hover — the keyboard is the primary input
     here, and a mouse resting over a different row must not look selected too. */
  .sol-command-option--active {
    background: var(--sol-bg-muted);
  }

  .sol-command-option__icon {
    display: flex;
    flex-shrink: 0;
    width: 16px;
    color: var(--sol-text-muted);
  }

  .sol-command-option__body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
  }

  .sol-command-option__title {
    font-size: var(--sol-font-size-sm, 13px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sol-command-option__match {
    background: none;
    color: var(--sol-accent);
    font-weight: var(--sol-font-weight-semibold, 600);
  }

  .sol-command-option__description {
    color: var(--sol-text-muted);
    font-size: var(--sol-font-size-xs, 11px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sol-command-option__shortcut {
    flex-shrink: 0;
  }

  /* Touch: the field and every option reach the 44px target; the search row
     trades its padding for the field's height. */
  @media (pointer: coarse) {
    .sol-command-search {
      padding-block: var(--sol-space-1, 4px);
    }

    .sol-command-search__input,
    .sol-command-option {
      box-sizing: border-box;
      min-height: var(--sol-touch-target-min);
    }
  }

  /* Forced touch (data-sol-touch on <html>): the block above, whatever the pointer. */
  :where([data-sol-touch]) .sol-command-search {
    padding-block: var(--sol-space-1, 4px);
  }
  :where([data-sol-touch]) .sol-command-search__input,
  :where([data-sol-touch]) .sol-command-option {
    box-sizing: border-box;
    min-height: var(--sol-touch-target-min);
  }

  /* === Empty and footer === */
  .sol-command-empty {
    padding: var(--sol-space-6, 24px) var(--sol-space-4, 16px);
    color: var(--sol-text-muted);
    font-size: var(--sol-font-size-sm, 13px);
    text-align: center;
  }

  .sol-command-footer {
    display: flex;
    gap: var(--sol-space-4, 16px);
    padding: var(--sol-space-2, 8px) var(--sol-space-4, 16px);
    border-top: 1px solid var(--sol-border);
    background: var(--sol-bg-sunken);
    color: var(--sol-text-muted);
    font-size: var(--sol-font-size-xs, 11px);
    flex-shrink: 0;
  }

  .sol-command-footer kbd {
    margin-inline-end: 4px;
  }

  @media (prefers-reduced-motion: no-preference) {
    .sol-command-palette {
      animation: sol-command-enter 120ms ease-out;
    }
  }

  @keyframes sol-command-enter {
    from {
      opacity: 0;
      transform: translateX(-50%) translateY(-6px);
    }
  }
}
