/*
 * PORTAL MEDIA (public/portal-media.js): avatars, organisation marks, the accent, and the upload control.
 * Uses the shell's tokens (portal-app.css); dark is the default, html[data-theme="light"] the light theme.
 * The accent touches ORG elements only (.pm-org, .pm-org-rule, .pm-org-chip); PTR chrome and buttons stay PTR.
 * The accent values come from portal-media.js applyAccent (already AA-checked against these surfaces).
 */

/* ---------------------------------------------------------------- avatars */
.pm-avatar,
.pm-org {
  --pm-size: 32px;
  width: var(--pm-size);
  height: var(--pm-size);
  flex: none;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  font-size: calc(var(--pm-size) * 0.4);
  font-weight: 600;
  line-height: 1;
  user-select: none;
}
.pm-avatar {
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ptr-cyan, #80edef), var(--ptr-indigo, #6d57ff));
  color: #061012;
}
.pm-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* The shell's own avatar slot (#avatar, .avatar) holding a picture. */
.avatar.pm-has-img,
.pm-avatar.pm-has-img { background: var(--surface-3, #1d2030); }
.avatar .pm-img { border-radius: 50%; }

/* ------------------------------------------------------- organisation mark */
.pm-org {
  border-radius: calc(var(--pm-size) * 0.22);
  background: var(--pm-accent, linear-gradient(135deg, var(--ptr-cyan, #80edef), var(--ptr-indigo, #6d57ff)));
  color: var(--pm-accent-ink, #061012);
}
/* A logo sits on a white plate in both themes: logos are drawn for light paper, and a dark logo on the dark theme
   would disappear. Transparency is kept; the plate is the paper. */
.pm-org.pm-has-img {
  background: #ffffff;
  border: 1px solid var(--hair, rgba(255, 255, 255, .12));
}
.pm-org .pm-img { object-fit: contain; }
/* A wide logo gets a 3:1 plate instead of a square one, so it is not shrunk to a sliver; it is contained, never
   stretched or cropped. */
.pm-org.pm-has-img.pm-wide { width: calc(var(--pm-size) * 3); padding: 0 4px; }

/* Accent text and rules, per theme (the AA-safe renderings). Default = the PTR accent. */
.pm-org-chip,
.pm-org-rule { --pm-accent-text: var(--pm-accent-dark, var(--ptr-cyan, #80edef)); }
html[data-theme="light"] .pm-org-chip,
html[data-theme="light"] .pm-org-rule { --pm-accent-text: var(--pm-accent-light, #0a62a0); }
.pm-org-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  max-width: 100%;
  color: var(--pm-accent-text);
}
.pm-org-chip .pm-org-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}
.pm-org-rule {
  border: 0;
  height: 3px;
  margin: 12px 0 0;
  border-radius: 2px;
  background: var(--pm-accent-text);
}

/* ------------------------------------------------------------- the field */
.pm-field {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "preview actions" "preview status";
  align-items: center;
  column-gap: 16px;
  row-gap: 6px;
  min-width: 0;
}
.pm-preview { grid-area: preview; display: grid; place-items: center; }
.pm-preview.pm-pending .pm-avatar { outline: 2px solid var(--ptr-cyan, #80edef); outline-offset: 2px; }
.pm-actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.pm-actions .btn { min-height: 44px; }
.pm-status { grid-area: status; margin: 0; min-height: 1.2em; font-size: 14px; color: var(--ink-2, inherit); }
/* The file input is reached through the visible button; it stays in the DOM for the picker. */
.pm-file {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 480px) {
  .pm-field {
    grid-template-columns: 1fr;
    grid-template-areas: "preview" "actions" "status";
    justify-items: start;
  }
  .pm-actions { width: 100%; }
  .pm-actions .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: no-preference) {
  .pm-img { animation: pm-in .18s ease-out; }
  @keyframes pm-in { from { opacity: 0; } to { opacity: 1; } }
}

/* ------------------------------------------------------- shell placements */
/* Profile menu header: picture, name, address. */
.menu .who-card { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; }
.menu .who-card .who { padding: 0; }
.menu .who-text { display: flex; flex-direction: column; min-width: 0; }
.menu .who-text b { color: var(--ink, inherit); font-size: 15px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.menu .who-text span { overflow-wrap: anywhere; }
/* People rows: picture beside the address. */
.person { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.person > span:last-child { overflow-wrap: anywhere; }
/* The desktop rail: the organisation mark on top, a 44 px target, ringed when the organisation page is open. */
.pm-rail-org { display: grid; place-items: center; min-width: 52px; min-height: 52px; max-width: 88px; margin: 2px auto 8px; padding: 4px; border-radius: 16px; text-decoration: none; }
/* In the slim rail a wide logo fits the rail's width. */
.pm-rail-org .pm-org.pm-has-img.pm-wide { width: 80px; height: 40px; }
.pm-rail-org:hover { background: var(--surface-2, transparent); }
.pm-rail-org[aria-current="page"] { box-shadow: 0 0 0 2px var(--accent, #80edef); }
/* The drawer: the organisation chip above the navigation. */
.drawer-org { width: 100%; padding: 6px 10px; border-radius: 12px; text-decoration: none; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.drawer-org:hover { background: var(--surface-2, transparent); }
/* The drawer's .nav a colour rule is more specific than .pm-org-chip: the accent wins here explicitly. */
.nav a.pm-org-chip.drawer-org, .nav a.pm-org-chip.drawer-org:hover, .nav a.pm-org-chip.drawer-org[aria-current="page"] { color: var(--pm-accent-text); }
/* The organisation page header: mark, name and role, then the accent rule. */
.org-title { display: flex; align-items: center; gap: 16px; min-width: 0; }
.org-title h1 { overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .org-title { gap: 12px; flex-wrap: wrap; }
  .org-title .pm-org { width: 44px; height: 44px; font-size: 18px; }
  .org-title .pm-org.pm-has-img.pm-wide { width: 132px; }
}
/* Brand colour: picker, code, and a light and a dark preview of what is rendered. */
.pm-sub { font-size: 15px; font-weight: 600; margin: 18px 0 4px; }
.pm-color-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pm-color { width: 52px; height: 44px; padding: 2px; border-radius: 12px; border: 1px solid var(--hair-2, #444); background: transparent; cursor: pointer; }
.pm-hex { max-width: 140px; }
.pm-swatches { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.pm-swatch { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 10px 12px; border-radius: 12px; min-width: 0; }
.pm-swatch[data-theme-preview="light"] { background: #ffffff; border: 1px solid #e3e5ee; color: var(--pv-text, #0a62a0); }
.pm-swatch[data-theme-preview="dark"] { background: #0e0f16; border: 1px solid #262a3a; color: var(--pv-text, #80edef); }
.pm-swatch-mark { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 8px; font-size: 13px; font-weight: 700; background: var(--pv-fill, linear-gradient(135deg, #80edef, #6d57ff)); color: var(--pv-ink, #061012); }
.pm-swatch-name { font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; flex: 1; }
.pm-swatch-theme { font-size: 12px; opacity: .8; }
.pm-swatch[data-theme-preview="light"] .pm-swatch-theme { color: #4a4f63; opacity: 1; }
.pm-swatch[data-theme-preview="dark"] .pm-swatch-theme { color: #b9bdcc; opacity: 1; }
