/* ─────────────────────────────────────────────────────────────────────────
   THE PLACE STRIP — the dark row across the top of every signed-in page
   (METIS-pub#793; shell/_place_strip.html). It replaced the side rail and
   #667's phone bar: the place switcher on the left, search, the extension
   notice (#813), Report a bug and your picture's menu on the right.

   Dark, with inverted text on it, and ONE colour in every app (METIS-pub#826
   m2): it used to take each app's ink (--color-text), so it turned olive in
   one app and teal in another, and the frame looked like a different product per
   app. --place-strip-bg is its component token (tokens/components.css); until
   that lands the platform ink is the fallback. Its shape is pinned to the
   platform's in tokens/apps.css, so it is the same row in every app.

   Lifted from the round 4 prototype (METIS-specs future/navigation/source/
   place-band.css). The band under it is place-band.css's.
   ───────────────────────────────────────────────────────────────────────── */

@layer components {
  .place-strip {
    /* Above <main> and whatever it stacks: the switcher's list and the user
       menu open out of this row over the page. */
    position: relative;
    z-index: 600;
    flex: none;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    /* Its height is a token: the side panel starts at its foot. */
    min-height: var(--place-strip-h);
    padding: 0 var(--space-md);
    background: var(--place-strip-bg, var(--color-text));
    color: var(--color-text-invert);
  }

  /* The environment marker the rail carried as its left edge. */
  .place-strip--env-dev { border-bottom: 3px solid var(--nav-env-dev); }
  .place-strip--env-dev-prod-db { border-bottom: 3px solid var(--nav-env-dev-prod-db); }

  .place-strip__spacer { flex: 1; }

  /* Still icons are dark artwork; on the dark ground they are drawn light. */
  .place-strip__icon {
    filter: invert(1);
    opacity: 0.8;
  }

  /* ── The switcher (crm/partials/focus_dropdown.html) ──────────────── */
  .place-strip .toggle-focus { min-width: 0; }

  .place-strip .toggle-btn--focus {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    min-height: 36px;
    padding: var(--space-1) var(--space-3) var(--space-1) var(--space-1);
    border: 1px solid color-mix(in oklab, var(--color-text-invert) 25%, transparent);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-text-invert);
    font-size: var(--text-md);
    font-weight: 600;
  }

  .place-strip .toggle-btn--focus:hover,
  .place-strip .toggle-focus.open .toggle-btn--focus {
    background: color-mix(in oklab, var(--color-text-invert) 10%, transparent);
  }

  .place-strip .toggle-focus__avatar,
  .place-strip .toggle-focus__avatar img,
  .place-strip .toggle-focus__avatar .toggle-focus__badge {
    width: 26px;
    height: 26px;
  }

  /* The eye before the place's mark: the chip is where you focus
     (METIS-pub#826), the filter's own icon. */
  .place-strip .toggle-focus__eye {
    flex: none;
    margin-inline-start: var(--space-1);
    color: color-mix(in oklab, var(--color-text-invert) 70%, transparent);
  }

  .place-strip .toggle-focus__label {
    max-width: 420px;
    color: var(--color-text-invert);
  }

  /* Home: a house, drawn in the strip's ink (#810). */
  /* Home's house and All's globe: drawn light on the dark row (All's was
     the page ink on it, so the chip showed nothing: #826). */
  .place-strip .toggle-focus__avatar--home,
  .place-strip .toggle-focus__avatar--all {
    display: inline-grid;
    place-items: center;
    color: var(--color-text-invert);
  }

  /* Inside a holon gone into (#821): the place it is in, quieter, then it. */
  .toggle-focus__parent {
    opacity: 0.65;
    font-weight: 500;
  }

  .toggle-focus__item-logo--home {
    display: inline-grid;
    place-items: center;
    color: var(--color-text-muted);
  }

  .place-strip .toggle-focus__chevron {
    color: color-mix(in oklab, var(--color-text-invert) 60%, transparent);
    opacity: 1;
  }

  /* The list is a light surface under the dark row; it is fixed-positioned by
     the switcher's own script, under the chip. */
  .place-strip .toggle-focus__menu {
    min-width: 280px;
    max-width: calc(100vw - 2 * var(--space-3));
    /* Room for your places and Everywhere's ten under them (#826). */
    max-height: min(70vh, 560px);
    color: var(--color-text);
  }

  /* The filter box, "Focus on…" with the eye, leading the list (#826 m6;
     always there since the owner's review). It stays on top while the list
     under it scrolls; the eye sits inside the box, at its left. */
  .toggle-focus__filter {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: var(--space-1) var(--space-2) var(--space-2);
    background: var(--color-surface);
  }

  .toggle-focus__filter-icon {
    position: absolute;
    /* The input's middle: the padding above it plus half its 32px. */
    top: calc(var(--space-1) + 16px);
    left: calc(var(--space-2) + var(--space-2));
    transform: translateY(-50%);
    color: var(--color-text-muted);
    pointer-events: none;
  }

  .toggle-focus__filter-input {
    width: 100%;
    min-height: 32px;
    padding: var(--space-1) var(--space-2) var(--space-1) calc(var(--space-2) + 16px + var(--space-2));
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: var(--text-md);
  }

  /* A Past place (core.focus.place_is_past): listed under its own label,
     quieter than the Active ones. */
  .toggle-focus__item--past { color: var(--color-text-muted); }
  .toggle-focus__item--past .toggle-focus__item-logo { opacity: 0.6; }

  /* The item the arrow keys (or the pointer) are on. */
  .toggle-focus__item--key { background: var(--color-accent-soft); }

  /* Everywhere's rows mark the typed text in the name, as the strip's
     search does. */
  .toggle-focus__item-name mark {
    background: none;
    color: inherit;
    font-weight: 700;
  }

  .toggle-focus__empty {
    padding: var(--space-2) var(--space-3);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
  }

  /* ── Search: a box that is a link to the search page ──────────────── */
  .place-strip__search {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    width: 260px;
    min-width: 0;
    min-height: 32px;
    padding: var(--space-1) var(--space-3);
    border: 1px solid color-mix(in oklab, var(--color-text-invert) 25%, transparent);
    border-radius: var(--radius-md);
    background: color-mix(in oklab, var(--color-text-invert) 8%, transparent);
    color: color-mix(in oklab, var(--color-text-invert) 70%, transparent);
    font-size: var(--text-md);
  }

  .place-strip__search:hover,
  .place-strip__search:focus-within {
    color: var(--color-text-invert);
    background: color-mix(in oklab, var(--color-text-invert) 14%, transparent);
  }

  .place-strip__search-go {
    display: inline-flex;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
  }

  .place-strip__search-text {
    flex: 1;
    min-width: 0;
    border: 0;
    background: none;
    color: var(--color-text-invert);
    font: inherit;
    outline: none;
  }

  .place-strip__search-text::placeholder {
    color: color-mix(in oklab, var(--color-text-invert) 70%, transparent);
  }

  /* Report a bug and the extension notice: the same 36px square. */
  .place-strip__notice,
  .place-strip__bug {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
  }

  /* ── The extension notice (#813): an icon with a dot, shown only by
     crm/js/extension_version_banner.js when the extension is out of date.
     [hidden] is restated: the display above would otherwise beat it. ───── */
  .place-strip__notice {
    position: relative;
    color: color-mix(in oklab, var(--color-text-invert) 80%, transparent);
  }

  .place-strip__notice[hidden] { display: none; }

  .place-strip__notice:hover { color: var(--color-text-invert); }

  .place-strip__notice-icon { flex: none; }

  .place-strip__notice-dot {
    position: absolute;
    top: var(--space-1);
    right: var(--space-1);
    width: var(--space-2);
    height: var(--space-2);
    border-radius: var(--radius-full);
    background: var(--color-danger);
    border: 2px solid var(--color-text);
  }

  /* ── A person's round picture (crm/partials/_person_avatar.html) ──── */
  .person-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    object-fit: cover;
    flex-shrink: 0;
  }

  .person-avatar--initial {
    background: var(--color-accent-soft);
    color: var(--color-accent);
    font-size: var(--text-sm);
    font-weight: 700;
  }

  .person-avatar--generic {
    background: color-mix(in oklab, var(--color-text-invert) 15%, transparent);
    color: var(--color-text-muted);
  }

  /* ── Settings and Admin, as icons beside Report a bug (#826: the menu under
     your picture went), and your picture, a plain link Home. ────────── */
  .place-strip__tool,
  .place-strip__home {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    color: inherit;
  }

  .place-strip__tool[aria-current="page"] .place-strip__icon { opacity: 1; }

  .place-strip__avatar {
    display: inline-flex;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
  }

  /* ── Phone (below 768px, Design 9): the switcher, the search icon and the
     picture. The name truncates rather than pushing the row wider than the
     screen. ─────────────────────────────────────────────────────────── */
  @media (max-width: 768px) {
    .place-strip {
      gap: var(--space-2);
      padding: 0 var(--space-3);
    }

    .place-strip .toggle-focus { flex: 0 1 auto; }
    .place-strip .toggle-btn--focus { max-width: 100%; }
    .place-strip .toggle-focus__label { max-width: none; min-width: 0; }
    /* Inside a holon gone into, the holon is where you are: the place it is
       in gives way first on a narrow screen. */
    .toggle-focus__parent { display: none; }

    .place-strip__search {
      width: auto;
      min-width: 36px;
      min-height: 36px;
      justify-content: center;
      padding: 0;
      border: 0;
      background: none;
    }

    .place-strip__search-text,
    .place-strip__bug { display: none; }
  }
}
