/* ─────────────────────────────────────────────────────────────────────────
   PLACE HEADER — what the page is about, above its tabs (METIS-pub#826)

   One component on every page: a place, a holon gone into, a holon or a
   person opened as a card, Home, All. ONE height for all of them (the owner:
   the tabs must never move from one kind of page to another), so:
   the picture slot is one size, the eyebrow and meta lines are always drawn
   (empty, they keep their line), the title is one line cut with "…", and
   nothing wraps — the status and the actions shrink the title, never add a
   line. Three lines beside the picture, top to bottom: the parent, the
   name (with the public page's icon), the kind and the status.

     .place-header             inside the band, above .place-band__row
     .place-header__logo       the picture: a logo, an initial, a face
                               (--face, round), an icon (All, Home)
     .place-header__text       eyebrow, title row, meta
     .place-header__eyebrow    the parent's name, linked, small
     .place-header__title-row  the name, then the public page's icon
     .place-header__name       the name in the display face: the page's <h1>
     .place-header__public     "Open public page", an icon beside the name
     .place-header__unpublished "Not published", in the same spot when there
                               is no public page to open
     .place-header__meta       the kind and stage chip (stage-menu.css), a
                               person's login marker
     .place-header__actions    at the row's end: History, Go in, Log out

   No overflow clip on the header: the stage chip's menu opens out of it.
   Drawn by crm/partials/_place_header.html; built by place_header.py.
   Tokens only.
   ───────────────────────────────────────────────────────────────────────── */

@layer components {
  .place-header {
    --place-header-pic: var(--space-16);
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: var(--space-3);
    height: calc(var(--place-header-pic) + var(--space-3) + var(--space-1));
    padding-top: var(--space-3);
    min-width: 0;
  }

  .place-header__logo {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: var(--place-header-pic);
    height: var(--place-header-pic);
  }

  /* The picture, never the class badge inside a badged logo
     (holon-chip.css .holon-logo-badged__badge sizes its own). */
  .place-header__logo img:not(.holon-logo-badged__badge img),
  .place-header__logo .holon-logo,
  .place-header__logo .holon-logo-placeholder {
    width: var(--place-header-pic);
    height: var(--place-header-pic);
    max-width: var(--place-header-pic);
    object-fit: contain;
    border-radius: var(--radius-md);
  }

  /* The editable logo and photo fields draw their own row padding; in the
     header the picture alone shows. */
  .place-header__logo .field-display,
  .place-header__logo .holon-logo-editable { padding: 0; margin: 0; }
  .place-header__logo .field-label { display: none; }
  .place-header__logo .holon-logo-badged,
  .place-header__logo .holon-logo-editable { display: inline-flex; }

  /* A face: the shared face (person-face.css) or the photo's editor
     (detail.css .person-photo), at the header's one picture size. */
  .place-header__logo--face .person-face { --person-face-size: var(--place-header-pic); }
  .place-header__logo--face .person-photo {
    width: var(--place-header-pic);
    height: var(--place-header-pic);
  }
  /* A person's face is round, never the logo's rounded square (#826, the
     owner: "a circle that looks good, not the square one"): the logo rule
     above is the more specific one, so this names the same images. */
  .place-header__logo--face img:not(.holon-logo-badged__badge img),
  .place-header__logo--face .person-face__pic {
    object-fit: cover;
    border-radius: var(--radius-full);
  }

  /* Changing the picture (its editor's form, opened by a click) is the one
     moment the header grows: the form needs its room, and the fixed height
     comes back with the picture. */
  .place-header:has(.place-header__logo form) {
    height: auto;
    align-items: flex-start;
  }
  .place-header__logo:has(form) {
    width: auto;
    height: auto;
  }

  .place-header__initial {
    display: inline-grid;
    place-items: center;
    width: var(--place-header-pic);
    height: var(--place-header-pic);
    border-radius: var(--radius-md);
    background: var(--color-accent-soft);
    color: var(--color-text-strong);
    font-family: var(--font-display);
    font-size: var(--text-xl);
  }

  .place-header__initial--icon svg {
    width: var(--space-6);
    height: var(--space-6);
    fill: none;
    stroke: currentColor;
  }

  .place-header__text {
    display: flex;
    flex: 0 1 auto;
    flex-direction: column;
    min-width: 0;
  }

  /* Always drawn, one line high even when empty. */
  .place-header__eyebrow {
    display: flex;
    flex-wrap: nowrap;
    align-items: baseline;
    height: var(--space-4);
    margin: 0;
    overflow: hidden;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    line-height: var(--space-4);
    white-space: nowrap;
  }

  .place-header__parent {
    min-width: 0;
    overflow: hidden;
    color: inherit;
    font-weight: 600;
    text-decoration: none;
    text-overflow: ellipsis;
  }

  .place-header__parent:hover { color: var(--color-text); text-decoration: underline; }

  .place-header__title-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
  }

  .place-header__name,
  .place-header__name .page-header__title,
  .place-header__name.page-header__title {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 400;
    line-height: 1.15;
    color: var(--color-text-strong);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* The rename box (always there for an editor, autosaved) stands exactly
     where the name does, no taller: the header's height is fixed, and the
     box's own gap and padding pushed the three lines past it, the status
     chip onto the tabs (#826). */
  .place-header__name .page-header__title-edit { margin-top: 0; }
  .place-header__name .page-header__title-input {
    padding-block: 0;
    font-size: var(--text-2xl);
    font-weight: 400;
    line-height: 1.15;
  }

  /* Under the name: the kind, then the status. Always drawn, one line
     high; no overflow clip, so the stage chip's menu opens out of it. */
  .place-header__meta {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: var(--space-2);
    height: var(--space-6);
    min-width: 0;
    white-space: nowrap;
  }

  .place-header__kind {
    min-width: 0;
    overflow: hidden;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-overflow: ellipsis;
    text-transform: uppercase;
  }

  /* The kind-and-status chip may shrink (its kind ellipses, stage-menu.css)
     so a phone's one line never pushes the page wider; what follows it
     ("Not published", the login marker) keeps its size. */
  .place-header__stage { flex: 0 1 auto; min-width: 0; }
  .place-header__meta > :not(.place-header__stage, .place-header__kind) { flex: none; }

  /* The public page: an icon right beside the name, no words. */
  .place-header__unpublished { flex: none; align-self: center; }

  .place-header__public {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
  }

  .place-header__public svg {
    width: calc(var(--space-4) + var(--space-1));
    height: calc(var(--space-4) + var(--space-1));
  }

  .place-header__public:hover,
  .place-header__public:focus-visible { color: var(--color-text-strong); }

  .place-header__actions {
    display: flex;
    flex: none;
    align-items: center;
    gap: var(--space-2);
    margin-left: auto;
  }

  .place-header__actions .btn[aria-current="page"] {
    color: var(--color-text-strong);
    text-decoration: underline;
    text-underline-offset: var(--space-1);
  }

  .place-header__logout { margin: 0; }

  /* A phone: the same three lines, smaller; the title giving way first. */
  @media (max-width: 767px) {
    .place-header {
      --place-header-pic: var(--space-12);
      gap: var(--space-2);
      height: calc(var(--space-16) + var(--space-2));
      padding-top: var(--space-2);
    }
    .place-header__initial { font-size: var(--text-md); }
    .place-header__name,
    .place-header__name .page-header__title,
    .place-header__name.page-header__title,
    .place-header__name .page-header__title-input { font-size: var(--text-xl); }
  }
}
