/* ── User profile ─────────────────────────────────────────────────────────────
   Redeveloped page (approved mockup: v12). Rules the layout follows and that a
   later edit must not break:

   * **Two left edges only** — shapes (avatar, section icons) sit in the gutter at
     `--p-gutter`, every title, row, label and verb starts at the text edge.
   * **A section header's height depends on its title only** — the `+ Add` control
     is absolutely positioned, so a section that has one is not 4px taller than its
     neighbour and the two columns' rules line up.
   * **One marker per section** — the icon at the gutter replaced the decorative
     accent bar; it is `aria-hidden` and the heading carries the meaning.
   * **No colour code** — `--p-accent` marks structure and interaction only; the
     "Preferred" state is a word, the status is a word, and nothing else is tinted.
   * **Fluid type** — `clamp()` everywhere, no per-breakpoint font sizes.
     Spaces around `+`/`-` inside `clamp()` are required or the declaration is
     dropped (that trap cost a 24px avatar once). */

.eca-profile {
  --p-ink: var(--color-ink, #15201e);
  --p-body: #2b3835;
  --p-muted: #66756f;
  --p-hair: var(--color-line, #e5eae8);
  --p-accent: var(--color-primary, #0f766e);
  --p-tint: #eef6f4;
  --p-warn-bg: #fdf7ec;
  --p-warn-ink: #6b4a12;

  --p-name: clamp(1.55rem, 1.15rem + 1.30vw, 2.20rem);
  --p-body-size: clamp(0.950rem, 0.910rem + 0.16vw, 1.030rem);
  --p-head: clamp(1.14rem, 1.04rem + 0.44vw, 1.45rem);
  --p-label: clamp(0.720rem, 0.700rem + 0.09vw, 0.780rem);
  --p-small: clamp(0.800rem, 0.780rem + 0.10vw, 0.870rem);
  --p-s1: clamp(0.22rem, 0.18rem + 0.22vw, 0.35rem);
  --p-s2: clamp(0.50rem, 0.45rem + 0.28vw, 0.70rem);
  --p-s3: clamp(0.95rem, 0.85rem + 0.55vw, 1.35rem);
  --p-s4: clamp(1.60rem, 1.30rem + 1.20vw, 2.60rem);
  --p-gutter: 1.05rem;

  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--p-s4) clamp(0.75rem, 0.4rem + 1.6vw, 1.35rem);
  color: var(--p-body);
  /* the approved mockup's stack — admin.css sets a different one on body */
  font-family: system-ui, ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Liberation Sans", "DejaVu Sans", Arial, sans-serif;
  font-size: var(--p-body-size);
  line-height: 1.55;
}

.eca-profile h1,
.eca-profile h2,
.eca-profile h3 { margin: 0; line-height: 1.2; color: var(--p-ink); }
/* admin.css targets bare `h1` with a bottom border and bare `table` with a white
   background — both are chrome for the legacy cards, not for a sectioned page. */
.eca-profile h1 { border-bottom: 0; padding-bottom: 0; }

/* `ui-alias.css` forces `font-size` on BARE h1/h2 with `!important` (a fix for the
   legacy pages, which emit bare headings and took a fixed 26px). Importance beats
   specificity, so this page must escalate its own sizes scoped to the page — without
   this the section titles render at the legacy ramp (21px) instead of the approved one
   (22.98px) and the whole page reads a size small. */
.eca-profile h1 { font-size: var(--p-name) !important; }
.eca-profile h2 { font-size: var(--p-head) !important; }
.eca-profile p { margin: 0; }

/* ── the person ── */
.eca-profile__who { display: flex; align-items: center; gap: var(--p-s3); flex-wrap: wrap; }
.eca-profile__avatar {
  flex: 0 0 auto;
  width: clamp(4.2rem, 3.6rem + 1.9vw, 5.2rem);
  height: clamp(4.2rem, 3.6rem + 1.9vw, 5.2rem);
}
.eca-profile__avatar .eca-avatar { width: 100%; height: 100%;
  font-size: clamp(1.05rem, 0.98rem + 0.34vw, 1.25rem); }
.eca-profile__name { font-size: var(--p-name); letter-spacing: -.02em; font-weight: 700; }
.eca-profile__sub { display: flex; flex-wrap: wrap; gap: var(--p-s2); align-items: center;
  margin-top: var(--p-s1); color: var(--p-muted); font-size: var(--p-small); }
.eca-profile__sub .eca-profile__sep { opacity: .4; }
.eca-profile__status { display: inline-block; font-size: var(--p-label); font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--p-accent);
  background: var(--p-tint); border-radius: 999px; padding: .08em .55em; }

/* pending invitation summary: the one actionable line, and it shrinks as the page fills */
.eca-profile__notice { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--p-s2);
  margin-top: var(--p-s3); padding: var(--p-s2) var(--p-s3); border-radius: 10px;
  background: var(--p-warn-bg); color: var(--p-warn-ink); font-size: var(--p-small); }
.eca-profile__notice-pill { border-radius: 999px; padding: .1em .55em; font-weight: 700;
  background: #f3e2c4; }
.eca-profile__notice a { color: var(--p-warn-ink); font-weight: 650; }

/* ── rail | sections ── */
.eca-profile__cols { display: grid; gap: var(--p-s4); grid-template-columns: minmax(0, 1fr);
  margin-top: var(--p-s4); }
@media (min-width: 980px) {
  .eca-profile__cols { grid-template-columns: minmax(230px, 290px) minmax(0, 1fr); }
}
/* on a phone the reader came for Contact, so the body comes first and About last.
   `minmax(0, 1fr)` and `min-width: 0` are both load-bearing: this is a grid ITEM whose
   `min-width` is `auto` by default, and its own implicit column is sized `auto` — so the
   column sized itself to max-content (519px of permissions table) inside a 308px box and
   the page panned to 553px at 390 (measured on leave-system 2026-11-07). */
.eca-profile__main { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--p-s4);
  order: 1; min-width: 0; }
.eca-profile__rail { order: 2; position: relative; min-width: 0;
  padding-left: calc(var(--p-gutter) + var(--p-s2)); }
@media (min-width: 980px) {
  .eca-profile__rail { order: 0; position: sticky; top: calc(var(--p-s4) + 2.4rem); align-self: start; }
}

/* ── a section ── */
.eca-profile__section { position: relative; padding-left: calc(var(--p-gutter) + var(--p-s2)); }
.eca-profile__section-head { display: flex; align-items: baseline; gap: var(--p-s1);
  padding-bottom: var(--p-s1); border-bottom: 1px solid var(--p-hair); }
.eca-profile__icon { position: absolute; left: 0; top: .1em;
  width: 1.15rem; height: 1.15rem; color: var(--p-muted); display: block; }
.eca-profile__title { font-size: var(--p-head); letter-spacing: -.01em; font-weight: 650; }
.eca-profile__count { color: var(--p-muted); font-size: var(--p-small);
  font-variant-numeric: tabular-nums; margin-left: var(--p-s1); }

/* the action is OUT of the flow: the header's height must depend on its title only */
.eca-profile__add { position: absolute; right: 0; top: .15em; }
.eca-profile__add > summary { list-style: none; cursor: pointer; font-size: var(--p-small);
  font-weight: 600; color: var(--p-accent); padding: .2em .55em; border-radius: 8px; }
.eca-profile__add > summary::-webkit-details-marker { display: none; }
.eca-profile__add > summary:hover { background: var(--p-tint); }
.eca-profile__add-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  display: grid; min-width: 12rem; padding: .3rem; background: #fff;
  border: 1px solid var(--p-hair); border-radius: 10px;
  box-shadow: 0 10px 30px rgb(21 32 30 / 10%); }
.eca-profile__add-item { padding: .45em .6em; border-radius: 7px; font-size: var(--p-small);
  color: var(--p-ink); text-decoration: none; }
.eca-profile__add-item:hover { background: var(--p-tint); }

/* a KIND is a sub-label inside a group, never a heading with its own rule */
.eca-profile__kind { display: flex; align-items: baseline; gap: var(--p-s2); margin-top: var(--p-s2); }
.eca-profile__kind-label { font-size: var(--p-label); letter-spacing: .07em;
  text-transform: uppercase; color: var(--p-muted); font-weight: 650; }
.eca-profile__kind-count { color: var(--p-muted); font-size: var(--p-label);
  font-variant-numeric: tabular-nums; }
.eca-profile__kind-link { margin-left: auto; font-size: var(--p-small); font-weight: 600;
  color: var(--p-accent); text-decoration: none; }
.eca-profile__kind-link:hover { text-decoration: underline; }

/* ── a record ── */
.eca-profile__records { display: grid; }
.eca-profile__record { display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--p-s2); align-items: baseline; padding: var(--p-s1) 0;
  border-bottom: 1px solid var(--p-hair); }
.eca-profile__records > .eca-profile__record:last-child { border-bottom: 0; }
.eca-profile__value { font-weight: 600; color: var(--p-ink); overflow-wrap: anywhere; }
.eca-profile__value a { color: var(--p-ink); text-decoration: none; }
.eca-profile__value a:hover { text-decoration: underline; }
.eca-profile__meta { color: var(--p-muted); font-size: var(--p-small); margin-top: 2px; }
.eca-profile__tag { color: var(--p-muted); font-size: var(--p-small); }
.eca-profile__tag + .eca-profile__tag::before { content: "·"; margin-right: .45em; opacity: .6; }
.eca-profile__pref { color: var(--p-accent); font-size: var(--p-small); font-weight: 600; }
.eca-profile__pref::before { content: "·"; margin-right: .45em; opacity: .5; }
.eca-profile__do { display: flex; gap: var(--p-s1); align-items: baseline; }
.eca-profile__do form { display: inline; margin: 0; }

/* verbs are text, not boxes: the page's borders belong to the section rules */
.eca-profile__verb { padding: .1em .45em; border: 0; border-radius: 7px; background: none;
  font: inherit; font-size: var(--p-small); font-weight: 600; color: var(--p-accent);
  text-decoration: none; cursor: pointer; white-space: nowrap; }
.eca-profile__verb:hover { background: var(--p-tint); }

/* pending relationships: a block, because "not yet confirmed" is not the same list */
.eca-profile__pending { margin-top: var(--p-s2); padding: var(--p-s2) var(--p-s3);
  border-radius: 10px; background: var(--p-warn-bg); }

/* ── the person card (rail) ── */
.eca-profile__facts { display: grid; gap: var(--p-s1); margin: var(--p-s3) 0 0; }
.eca-profile__facts > div { display: grid; grid-template-columns: auto minmax(0, 1fr);
  gap: var(--p-s2); align-items: baseline; }
.eca-profile__facts dt { font-size: var(--p-label); letter-spacing: .06em;
  text-transform: uppercase; color: var(--p-muted); }
.eca-profile__facts dd { margin: 0; font-weight: 600; color: var(--p-ink);
  text-align: right; overflow-wrap: anywhere; }
.eca-profile__acts { display: grid; gap: var(--p-s1); margin-top: var(--p-s3);
  padding-top: var(--p-s3); border-top: 1px solid var(--p-hair); }
.eca-profile__act { display: flex; align-items: center; justify-content: center;
  padding: .5em .95em; border: 1px solid var(--p-hair); border-radius: 999px;
  background: #fff; font-size: var(--p-small); font-weight: 600; color: var(--p-ink);
  text-decoration: none; text-align: center; }
.eca-profile__act:hover { border-color: #cfd9d5; }
.eca-profile__act--primary { background: var(--p-accent); border-color: var(--p-accent); color: #fff; }
.eca-profile__act--primary:hover { background: var(--color-primary, #0b5751); }
.eca-profile__act--link { border-color: transparent; background: none; color: var(--p-accent);
  justify-content: flex-start; padding-inline: .3em; }
.eca-profile__act--link:hover { background: var(--p-tint); }

/* ── tables (roles, collated permissions) ── */
.eca-profile__table { width: 100%; border-collapse: collapse; background: transparent; }
.eca-profile__table th { padding: var(--p-s2) 0 var(--p-s1); text-align: left; background: transparent;
  font-size: var(--p-label); letter-spacing: .07em; text-transform: uppercase;
  color: var(--p-muted); font-weight: 600; }
.eca-profile__table td { padding: var(--p-s1) 0; border-top: 1px solid var(--p-hair); }
/* Only the actions column is right-aligned; a data column reads left to right.
   A collated permission list is one long comma-separated run ("AssignRole, AssignSpace,
   Delete, Disable…"). With `overflow-wrap: normal` the table's **minimum** width is that
   run's width — 494px — so the section could not shrink below it and the page panned to
   553px at 390. `anywhere` lets only THIS cell break, so the resource column keeps its
   natural width (109px measured) instead of being squeezed to two characters. */
.eca-profile__table--actions td:last-child { text-align: right; overflow-wrap: anywhere; }

/* an empty group states the fact in the page's own words; no placeholder box */
.eca-profile__quiet { padding: var(--p-s2) 0; color: var(--p-muted); font-size: var(--p-small); }

.eca-profile__back { display: inline-block; margin-top: var(--p-s4); padding-top: var(--p-s3);
  border-top: 1px solid var(--p-hair); width: 100%; font-size: var(--p-small);
  color: var(--p-muted); text-decoration: none; }
.eca-profile__back:hover { color: var(--p-accent); }

/* below the width at which a value and its two verbs share a line, let the value
   keep the full width instead of being squeezed into three lines */
@media (max-width: 640px) {
  .eca-profile__record { grid-template-columns: minmax(0, 1fr); }
  .eca-profile__do { grid-column: 1 / -1; justify-content: flex-end; }

  /* Targets. Measured on `/user/profile/1` at 390 before this block: 27 controls under 44 px, five
   * under 24 (`Edit` 36x23, `Remove` 61x23, a kind-link 147x20). The row is the control's owner, so
   * the sizes are stated once per class instead of per link. */
  .eca-profile__add > summary,
  .eca-profile__add-item,
  .eca-profile__verb,
  .eca-profile__kind-link,
  .eca-profile__act,
  .eca-profile__back {
    display: inline-flex;
    align-items: center;
    min-height: var(--control-h-touch);
  }
  .eca-profile__verb { min-width: 44px; justify-content: center; }
}

/* A pointer still needs 24 px: the two text verbs are set at 23 px and 20 px by their font only.
   SCOPED, and this is the whole fix for `/user/profile/:id` at 390: written unscoped and AFTER the
   `max-width: 640px` block above, this rule outranked the 44 px touch floor at EVERY width (equal
   specificity, later wins) — so `Edit` measured 44x24, `Remove` 61x24 and `Relationship network →`
   147x24 on a phone. 24 px is exactly the WCAG 2.2 2.5.8 floor (not under it, which is why the audit
   never called them `tap<24`), but the design system's own aim on touch is 44. Mobile-first: the base
   above is the thumb, this block refines it for a pointer. */
.eca-profile__verb { display: inline-flex; }
@media (min-width: 641px) {
  .eca-profile__verb, .eca-profile__kind-link { min-height: 1.5rem; align-items: center; }
}
