/* Container Switcher — TailwindPlus "flyout" aesthetic: strictly neutral (no
   accent color), rows of icon-square + title + description, a card with a subtle
   border/shadow, and a two-action footer. The global menu only switches
   containers; deep page nav lives in each container's own nav. */
@layer components {
  .switcher {
    position: fixed;
    inset: auto;
    top: 3.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: min(26rem, 94vw);
    max-height: calc(100vh - 2em);
    margin: 0;
    padding: 0;
    /* Popovers ship a UA-stylesheet `border: solid` — must be zeroed explicitly,
       not merely omitted, or it shows through. */
    border: 0;
    /* Raised surface: white in light mode, a step lighter than the dark canvas
       in dark mode — so the flyout reads as elevated without a border (a plain
       --canvas panel would vanish against the dark canvas behind it). */
    --surface: var(--canvas);
    background: var(--surface);
    color: var(--ink);
    border-radius: var(--radius-card);
    box-shadow:
      0 18px 44px -12px rgb(0 0 0 / 0.38),
      0 4px 12px -4px rgb(0 0 0 / 0.22);
    overflow: hidden auto;
  }
  /* A flyout, not a modal — no dimming scrim behind it (click-outside still
     light-dismisses via the native popover). */
  .switcher::backdrop { background: transparent; }

  /* Dark mode: lift the surface a step so the flyout is visible without a border. */
  [data-theme="dark"] .switcher { --surface: var(--color-mountain-mist-700); }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .switcher { --surface: var(--color-mountain-mist-700); }
  }

  .switcher__head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--size-2);
    padding: var(--u-pad);
    background: var(--canvas);
  }
  .switcher__whoami { display: inline-flex; align-items: center; gap: var(--size-2); min-width: 0; }
  .switcher__name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .switcher__close {
    display: inline-flex;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ink-muted);
    cursor: pointer;
  }
  .switcher__close:hover { color: var(--ink); }

  .switcher__cols { display: flex; flex-direction: column; }
  .switcher__col { padding: var(--size-2) var(--u-pad); }
  .switcher__col-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--size-2);
  }
  .switcher__label { margin: 0 0 var(--size-1); color: var(--ink-muted); }

  /* Flyout row: icon square + title + description. No border; neutral hover. */
  .switcher__card {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: var(--size-3);
    padding: var(--size-2);
    border-radius: var(--radius-ui);
    color: var(--ink);
    text-decoration: none;
  }
  .switcher__card:hover { background: color-mix(in oklab, var(--ink) 4%, transparent); }
  .switcher__card-icon {
    display: inline-grid;
    place-items: center;
    inline-size: var(--size-8);
    block-size: var(--size-8);
    border-radius: var(--radius-ui);
    background: color-mix(in oklab, var(--ink) 5%, var(--surface));
    color: var(--ink-muted);
  }
  .switcher__card:hover .switcher__card-icon { background: var(--surface); color: var(--ink); }
  .switcher__card-body { display: flex; flex-direction: column; min-width: 0; }
  .switcher__card-name {
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .switcher__card-meta {
    font-size: 0.85rem;
    color: var(--ink-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .switcher__empty { padding-block: var(--size-2); color: var(--ink-muted); }

  .switcher__invite {
    display: flex;
    flex-direction: column;
    gap: var(--size-1);
    padding: var(--u-pad);
    border: var(--border-size-1) dashed var(--line);
    border-radius: var(--radius-ui);
    color: var(--ink);
    text-decoration: none;
  }
  .switcher__invite:hover { background: var(--fill-subtle); }

  .switcher__switch {
    margin-block-start: var(--size-2);
    padding-block-start: var(--size-2);
    border-block-start: var(--border-size-1) solid var(--line);
    color: var(--ink-muted);
  }
  .switcher__switch a {
    display: block;
    padding: var(--size-1) var(--size-2);
    border-radius: var(--radius-ui);
    color: var(--ink);
    text-decoration: none;
  }
  .switcher__switch a:hover { background: color-mix(in oklab, var(--ink) 4%, transparent); }

  /* Footer — two actions, separated by tone alone (barely-there tint, theme-aware). */
  .switcher__footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: color-mix(in oklab, var(--ink) 4%, var(--surface));
  }
  .switcher__foot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--size-1);
    padding: var(--size-3);
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
  }
  .switcher__foot + .switcher__foot { border-inline-start: var(--border-size-1) solid color-mix(in oklab, var(--ink) 8%, transparent); }
  .switcher__foot:hover { background: color-mix(in oklab, var(--ink) 6%, transparent); }
  .switcher__foot--soon { color: var(--ink-muted); cursor: default; }
  .switcher__foot--soon:hover { background: transparent; }

  /* Phone: full-screen sheet (already single column). */
  @media (max-width: 40rem) {
    .switcher {
      inset: 0;
      top: 0;
      left: 0;
      transform: none;
      width: 100vw;
      max-width: 100vw;
      height: 100dvh;
      max-height: 100dvh;
      border: 0;
      border-radius: 0;
    }
  }
}
