/* Integra — team page (team.html). The operations lead's view of the
   employees: logging tiles, the staff roster, the activity feed. Single
   column, 1100px max, compact register — the same chrome as the admin board,
   so staff moving between the two never feel the page change under them.
   Hairlines and whitespace are the only structure: no cards, no shadows.

   js/team.js renders every row into the contracted containers (#team-tiles,
   #team-count, #team-list, #team-foot, #activity-list), so the classes below
   are the contract between the two files.

   --row-hover and --blurple-wash live in tokens.css so both washes follow
   the theme; redeclaring either here would pin this page to light values. */

::selection { background: var(--blurple); color: var(--accent-ink); }

/* Subtle page-load fade — opacity only, gated on motion preference. */
@media (prefers-reduced-motion: no-preference) {
  body { animation: team-page-in 150ms var(--ease); }
  @keyframes team-page-in { from { opacity: 0; } }
}

.team-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Header ---- */
/* The same 1100px / 41px-row bar the admin, setup and tracker pages carry. */

.team-header {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}

.team-header .header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--s4) var(--s5);
  min-height: calc(41px + var(--s4) * 2);
  display: flex;
  align-items: center;
  gap: var(--s2) var(--s3);
  flex-wrap: wrap;
}

.lockup-link { display: inline-flex; align-items: center; }
.lockup { height: 28px; width: auto; display: block; }

.header-divider {
  width: 1px;
  height: 18px;
  background: var(--rule);
  flex: none;
}

.header-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.team-header .theme-toggle { margin-left: var(--s2); }

/* Compact button size — same values as the app shell's .btn-sm
   (app.css is not loaded on this page). */
.btn-sm { padding: 13px 16px; font-size: 13px; }

/* ---- Main column ---- */

.team-main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--s6) var(--s5) var(--s8);
}

@media (min-width: 600px) {
  .team-main { padding-top: var(--s7); }
}

.page-title {
  font-weight: 500;
  font-size: 24px;
  letter-spacing: -0.005em;
  line-height: 1.25;
  margin: 0 0 var(--s2);
}

.page-sub {
  font-size: 14px;
  margin: 0 0 var(--s6);
}

/* Page-level notes — demo mode, non-admin access, load failures. While
   #team-note carries content the sections stay out of the flow: the note
   replaces the page per the access contract. */
#team-note {
  color: var(--graphite);
  font-size: 15px;
  max-width: var(--measure);
}

.note-prose { margin: 0; }

.note-action {
  margin: var(--s4) 0 0;
  font-size: 15px;
}

.team-error {
  color: var(--fault-text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

#team-note:not(:empty) { margin-bottom: var(--s5); }

#team-note:not(:empty) ~ section { display: none; }

/* ---- Sections ---- */

.team-section {
  border-top: 1px solid var(--rule);
  padding: var(--s5) 0;
}

.section-label { display: block; margin: 0 0 var(--s3); }

.team-empty {
  color: var(--graphite);
  font-size: 14px;
  margin: var(--s3) 0 0;
}

.team-foot {
  font-size: 12px;
  color: var(--graphite);
  margin: var(--s3) 0 0;
  max-width: none;
}

.team-foot:empty { margin: 0; }

/* ---- Logging tiles ---- */
/* Same visual language as the dashboard stat tiles: hairline-separated
   columns, no boxes. app.css is not loaded here, so the values live locally. */

#team-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  min-height: 96px; /* label + 24px figure + sub line, reserved pre-render */
}

.stat-tile {
  min-width: 0;
  padding: var(--s3) var(--s3) var(--s3) 0;
}

.stat-tile + .stat-tile {
  border-left: 1px solid var(--rule);
  padding-left: var(--s3);
}

.stat-value {
  font-weight: 500;
  font-size: 24px;
  line-height: 1.2;
  margin-top: var(--s2);
  overflow-wrap: anywhere;
}

.stat-sub {
  font-size: 13px;
  color: var(--graphite);
  margin-top: var(--s1);
}

/* ---- Employee roster ---- */

.team-count {
  font-size: 12px;
  color: var(--graphite);
  margin: 0 0 var(--s3);
  max-width: none;
}

.team-count:empty { margin: 0; }

.team-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* One grid template for the head and every row, so the columns line up. */
.team-head,
.team-row {
  display: grid;
  grid-template-columns:
    minmax(140px, 1.4fr) 56px minmax(130px, 1fr)
    56px 64px 96px;
  align-items: center;
  column-gap: var(--s4);
}

.team-head {
  padding: 0 0 var(--s2);
  border-bottom: 1px solid var(--rule);
}

.team-row {
  position: relative;
  z-index: 0;
  padding: var(--s3) 0;
  font-size: 15px;
}

.team-row + .team-row { border-top: 1px solid var(--rule); }

/* Hover wash — rows are records, not buttons, so the cursor stays default.
   The wash bleeds var(--s3) past the text edge on a non-interactive pseudo
   layer, so the hairlines above and below keep exactly to the content column. */
.team-row::before {
  content: '';
  position: absolute;
  inset: 0 calc(-1 * var(--s3));
  z-index: -1;
  border-radius: var(--radius);
  pointer-events: none;
  transition: background-color var(--t-fast) var(--ease);
}

.team-row:hover::before { background: var(--row-hover); }

.team-name {
  font-weight: 600;
  font-size: 15px;
  min-width: 0;
  overflow-wrap: anywhere;
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
}

/* Initials chip — the one sanctioned circle beside the status dots. Fill and
   text colour both come from tokens, so it holds up in dark. */
.team-chip {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--blurple-text);
  background: var(--blurple-wash);
}

.team-row .team-role { font-size: 11px; }

.team-num,
.team-last {
  text-align: right;
  white-space: nowrap;
}

.team-row .team-num,
.team-row .team-last { font-size: 13px; }

.team-row .team-last { color: var(--graphite); }

/* The member's client list — the assignment map, read-only. A full-width
   quiet line under the figures; row-gap only bites when the line exists. */
.team-row { row-gap: var(--s1); }

.team-row .team-clients {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--graphite);
}

/* Per-figure unit label. The column head carries it for sighted users on wide
   screens, so here it is hidden the accessible way (base.css .visually-hidden
   values) and returns as visible copy when the head drops out under 760px. */
.team-unit {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--graphite);
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  clip: rect(0 0 0 0);
  overflow: hidden;
  white-space: nowrap;
}

.team-spark {
  justify-self: end;
  min-height: 28px;
}
.team-spark svg { display: block; }

/* ---- Activity feed ---- */

#activity-list { margin-top: var(--s1); }

.act-row {
  display: grid;
  grid-template-columns: max-content max-content minmax(0, 1fr) max-content;
  align-items: center;
  column-gap: var(--s4);
  padding: var(--s3) 0;
  position: relative;
  z-index: 0;
}

.act-row + .act-row { border-top: 1px solid var(--rule); }

.act-row::before {
  content: '';
  position: absolute;
  inset: 0 calc(-1 * var(--s3));
  z-index: -1;
  border-radius: var(--radius);
  pointer-events: none;
  transition: background-color var(--t-fast) var(--ease);
}

.act-row:hover::before { background: var(--row-hover); }

.act-stamp {
  font-size: 13px;
  color: var(--graphite);
  white-space: nowrap;
}

.act-who {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}

/* A row nobody hand-logged: the collector's own insert, or a profile
   deleted since. Quiet, not hidden. */
.act-who.act-auto {
  font-weight: 400;
  font-size: 13px;
  color: var(--graphite);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.act-what {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--s2);
  overflow: hidden;
}

.act-glyph {
  flex: none;
  display: inline-flex;
  width: 16px;
  height: 16px;
  color: var(--ink);
}
.act-glyph svg { width: 16px; height: 16px; display: block; }

.act-handle { flex: none; font-size: 13px; }

.act-caption {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.act-view {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.activity-actions { margin-top: var(--s4); }
.activity-actions .team-foot { margin: 0; }

/* ---- Footer ---- */

.team-footer { border-top: 1px solid var(--rule); }

.team-footer .footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--s5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
}

.team-footer .tagline { margin: 0; }
.team-footer img { display: block; width: 16px; height: 16px; }

/* ---- Responsive ---- */

@media (max-width: 760px) {
  #team-tiles { grid-template-columns: 1fr 1fr; min-height: 0; }

  .stat-tile:nth-child(odd) { border-left: 0; padding-left: 0; }
  .stat-tile:nth-child(n+3) { border-top: 1px solid var(--rule); }

  /* The head drops out; each figure's own unit label becomes visible copy. */
  .team-head { display: none; }

  .team-row {
    grid-template-columns: minmax(0, 1fr) max-content;
    grid-template-areas:
      "name    c30"
      "role    c7"
      "last    last"
      "spark   spark"
      "clients clients";
    row-gap: var(--s1);
  }

  .team-row .team-name { grid-area: name; }
  .team-row .team-role { grid-area: role; }
  .team-row .team-last { grid-area: last; text-align: left; }
  .team-row .team-c7 { grid-area: c7; }
  .team-row .team-c30 { grid-area: c30; }
  .team-row .team-spark { grid-area: spark; justify-self: start; margin-top: var(--s1); }
  .team-row .team-clients { grid-area: clients; }

  .team-unit {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    clip: auto;
    overflow: visible;
  }
}

@media (max-width: 640px) {
  .act-row {
    grid-template-columns: minmax(0, 1fr) max-content;
    grid-template-areas:
      "who  stamp"
      "what view";
    row-gap: var(--s1);
  }

  .act-row .act-who { grid-area: who; }
  .act-row .act-stamp { grid-area: stamp; }
  .act-row .act-what { grid-area: what; }
  .act-row .act-view { grid-area: view; }
}
