/* Identity picker — three-tab UI for selecting initial / photo / icon
 * on /profile/edit. Tab visibility uses :has() — no JS.
 * The icon grid renders each option as an .avatar with currentColor
 * driving the SVG fill, so the user sees the actual silhouette they're
 * picking.
 *
 * Named .identity-picker (not .avatar-picker) to avoid collision with
 * the existing group-icon picker at onboarding/crews (see onboarding.css).
 */

@layer components {
  .identity-picker {
    display: grid;
    gap: var(--block-space);

    /* Hide the radio inputs themselves — labels carry the click target. */
    & input[type="radio"] {
      position: absolute;
      width: 1px;
      height: 1px;
      opacity: 0;
      pointer-events: none;
    }
  }

  .identity-picker__current {
    display: flex;
    justify-content: center;
    padding-block: var(--block-space-s);
  }

  /* ── Kind tabs ── */
  .identity-picker__tabs {
    display: flex;
    gap: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    padding: 3px;
    background: var(--color-canvas);
    margin: 0;
  }

  .identity-picker__tab {
    flex: 1;
    text-align: center;
    padding-block: 0.5rem;
    border-radius: var(--radius-pill);
    cursor: pointer;
    color: var(--color-ink-muted);
    font-weight: 500;
    transition: background 100ms ease, color 100ms ease;

    &:has(input:checked) {
      background: var(--color-surface);
      color: var(--color-ink);
      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    }

    &:has(input:focus-visible) {
      outline: 2px solid oklch(var(--lch-flare));
      outline-offset: 1px;
    }
  }

  /* ── Panels (shown via :has on the parent) ── */
  .identity-picker__panel {
    display: none;
  }

  .identity-picker:has(input[value="photo"]:checked) .identity-picker__panel--photo {
    display: block;
  }

  .identity-picker:has(input[value="icon"]:checked) .identity-picker__panel--icon {
    display: grid;
    gap: var(--block-space);
  }

  .identity-picker__photo-label {
    display: block;
    margin-block-end: 0.5rem;
    font-weight: 500;
  }

  /* ── Icon grid ── */
  .identity-picker__category {
    border: none;
    padding: 0;
    margin: 0;
  }

  .identity-picker__category-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-block-end: 0.5rem;
    padding: 0;
  }

  .identity-picker__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.75rem;
  }

  .identity-picker__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    padding: 4px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 100ms ease, transform 100ms ease;

    &:hover {
      transform: scale(1.05);
    }

    &:has(input:checked) {
      border-color: oklch(var(--lch-flare));
    }

    &:has(input:focus-visible) {
      outline: 2px solid oklch(var(--lch-flare));
      outline-offset: 2px;
    }
  }

  .identity-picker__icon-preview {
    /* Neutral preview — picker shows shape, not the user's crew colour.
     * The actual rendered avatar uses --avatar-color from membership. */
    --avatar-color: var(--color-surface);
    --avatar-ink: var(--color-ink);
    inline-size: 100%;
    block-size: 100%;
    border: 1px solid var(--color-border);
    font-size: 1.5rem;
  }
}
