/* Teams index / overview & global search styles — owned by the teams slice.
   Index card + toolbar geometry/type comes from Paper artboard 04 · Teams.
   Reuses shared primitives from design.css (.page-head, .btn, .avatar, .card,
   .field, .empty-state). Only net-new rules live here. */

/* ============ Teams index — page head (artboard 04 overrides) ============ */
.teams-page .page-head{ border-bottom:0; padding:32px 28px 22px; }
.teams-page .page-sub{ margin-top:6px; }

/* ============ Teams index — card grid ============ */
.teams-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:22px 24px;
  padding:0 28px 48px;
}
@media (max-width:860px){ .teams-grid{ grid-template-columns:1fr; padding:0 16px 32px; } }

/* Border-only card — no shadow (shadows are reserved for popovers). */
.team-card{
  display:flex; flex-direction:column; gap:14px;
  padding:20px 22px;
  background:var(--surface);
  border:1px solid var(--rule-2);
  border-radius:12px;
  position:relative;
  transition:transform .12s;
}
.team-card:hover{
  border-color:var(--rule-3);
  transform:translateY(-1px);
}
.team-card:focus-visible{ outline:2px solid var(--accent-edge); outline-offset:2px; }

/* Header: status dot · name · "8 METRICS" caps right. */
.team-card .tc-head{ display:flex; align-items:center; gap:10px; min-width:0; }
.team-card .tc-dot{ width:9px; height:9px; border-radius:50%; flex-shrink:0; }
.team-card .tc-dot.ok{ background:var(--ok); }
.team-card .tc-dot.warn{ background:var(--warn); }
.team-card .tc-dot.bad{ background:var(--bad); }
.team-card .tc-name{
  flex:1; min-width:0;
  font-size:16px; font-weight:600; line-height:20px; letter-spacing:-0.01em; color:var(--ink);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.team-card .tc-count{
  font-family:var(--mono); font-size:10.5px; line-height:14px;
  letter-spacing:0.1em; text-transform:uppercase; color:var(--ink-4);
  flex-shrink:0;
}

/* One-line description (briefing blurb / fallback). */
.team-card .tc-desc{
  margin:0; font-size:13px; line-height:19px; color:var(--ink-3);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0;
}

/* Three mini stats: caps label over mono value. */
.team-card .tc-stats{ display:flex; gap:18px; min-width:0; }
.team-card .tc-stat{ display:flex; flex-direction:column; gap:2px; min-width:0; }
.team-card .tc-stat-lbl{
  font-family:var(--mono); font-size:9.5px; line-height:12px;
  letter-spacing:0.1em; text-transform:uppercase; color:var(--ink-4);
  white-space:nowrap;
}
.team-card .tc-stat-val{
  font-family:var(--mono); font-size:14px; font-weight:500; line-height:18px;
  color:var(--ink); font-variant-numeric:tabular-nums; white-space:nowrap;
}

/* Footer: metric-owner avatars left, status caps pill right. */
.team-card .tc-foot{ display:flex; align-items:center; gap:8px; padding-top:2px; margin-top:auto; }
.team-card .tc-owners{ display:flex; align-items:center; gap:8px; }
.team-card .tc-pill{
  margin-left:auto; flex-shrink:0;
  display:inline-flex; align-items:center; gap:6px;
  height:22px; padding:0 9px; border-radius:11px;
  font-family:var(--mono); font-size:10px; font-weight:500; line-height:12px;
  text-transform:uppercase;
}
.team-card .tc-pill.ok{ background:var(--ok-soft); color:var(--ok-ink); }
.team-card .tc-pill.warn{ background:var(--warn-soft); color:var(--warn-ink); }
.team-card .tc-pill.bad{ background:var(--bad-soft); color:var(--bad-ink); }
.team-card .tc-pill.none{ background:var(--surface-2); color:var(--ink-4); }

/* ============ Centered form pages (team / scorecard create + edit) ============ */
.form-page{ max-width:560px; margin:24px auto 48px; padding:0 16px; }
.form-page .card{ margin-bottom:18px; }
.form-actions{
  display:flex; align-items:center; justify-content:flex-end; gap:10px;
  margin-top:20px; padding-top:16px; border-top:1px solid var(--rule);
}

.color-swatches{ display:flex; gap:6px; margin-top:10px; }
.color-swatches .cs-dot{ width:18px; height:18px; border-radius:5px; box-shadow:inset 0 0 0 1px rgba(21,36,47,0.06); }

/* Danger zone */
.danger-card{ border-color:var(--bad-soft); }
.danger-card .card-head h3{ color:var(--bad-ink); }
.danger-row{ display:flex; align-items:center; justify-content:space-between; gap:16px; }
.danger-row .dr-title{ font-size:13.5px; font-weight:500; color:var(--ink); }
.danger-row .dr-sub{ font-size:12px; color:var(--ink-3); margin-top:3px; max-width:340px; line-height:1.45; }

/* ============ Global search ============ */
.search-page{ max-width:760px; margin:24px auto 60px; padding:0 16px; }

.search-form{ display:flex; gap:10px; margin-bottom:8px; }
.search-input-wrap{
  flex:1; display:flex; align-items:center; gap:10px;
  height:40px; padding:0 14px;
  background:var(--surface); border:1px solid var(--rule-2); border-radius:8px;
  box-shadow:var(--shadow-1);
  color:var(--ink-3);
}
.search-input-wrap:focus-within{ border-color:var(--accent-edge); box-shadow:0 0 0 3px var(--accent-soft); }
.search-field{
  flex:1; border:none; outline:none; background:transparent;
  font:inherit; font-size:14px; color:var(--ink);
}
.search-form .btn.primary{ height:40px; padding:0 18px; border-radius:8px; }

.search-summary{ font-size:12.5px; color:var(--ink-3); margin:14px 2px 16px; }
.search-summary strong{ color:var(--ink); font-weight:500; }

.search-group{ margin-bottom:16px; }

.search-row{
  display:flex; align-items:center; gap:12px;
  padding:11px 16px;
  border-bottom:1px solid var(--rule);
  position:relative;
}
.search-row:last-child{ border-bottom:none; }
/* Hover tint via opacity crossfade (compositor) instead of background (paint). */
.search-row::after{
  content:""; position:absolute; inset:0; background:var(--hover);
  opacity:0; transition:opacity .12s ease; pointer-events:none; z-index:-1;
}
.search-row:hover::after{ opacity:1; }
.search-row .sr-mark{ width:28px; height:28px; border-radius:7px; font-size:10.5px; flex-shrink:0; }
.search-row .sr-body{ flex:1; min-width:0; }
.search-row .sr-title{
  font-size:13.5px; font-weight:500; color:var(--ink);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.search-row .sr-title.sr-comment{ font-weight:450; color:var(--ink-2); }
.search-row .sr-title mark{ background:var(--accent-soft); color:var(--accent-ink); border-radius:2px; padding:0 1px; }
.search-row .sr-sub{ font-size:11.5px; color:var(--ink-3); margin-top:2px; font-family:var(--mono); }
.search-row .sr-tag{
  font-family:var(--mono); font-size:10px; color:var(--ink-4);
  text-transform:uppercase; letter-spacing:0.05em; flex-shrink:0;
  padding:2px 7px; border:1px solid var(--rule-2); border-radius:10px;
}
.search-row .sr-tag.flag{ color:var(--bad-ink); border-color:var(--bad-soft); background:var(--bad-soft); }

/* Base rules the prototype kept in its Direction-A styles (ported here so the
   Teams index + Search render team marks and RAG count pills correctly). */
.team-mark{
  display:grid; place-items:center; color:white;
  font-family:var(--mono); font-weight:500; flex-shrink:0; border-radius:7px;
}
.rag-count{
  display:inline-flex; align-items:center; gap:4px;
  font-family:var(--mono); font-size:11.5px; font-weight:500;
  padding:0 7px; height:20px; border-radius:10px;
}
.rag-count.ok{ color:var(--ok-ink); background:var(--ok-soft); }
.rag-count.warn{ color:var(--warn-ink); background:var(--warn-soft); }
.rag-count.bad{ color:var(--bad-ink); background:var(--bad-soft); }
.rag-count.zero{ color:var(--ink-4); background:var(--surface-2); }

/* ============ Teams index — filter / sort toolbar ============ */
.teams-toolbar{
  display:flex; align-items:center; justify-content:space-between;
  flex-wrap:wrap; gap:12px;
  padding:0 28px 22px;
}
@media (max-width:720px){ .teams-toolbar{ padding:0 16px 14px; } }

/* One grouped segmented control on a recessed track; active = white chip.
   Counts render inline ("All · 4") — no colored dots. */
.tt-seg{
  display:flex; align-items:center; flex-wrap:wrap;
  padding:3px; background:var(--surface-2); border-radius:8px;
}
.tt-chip{
  display:inline-flex; align-items:center; gap:5px;
  height:26px; padding:0 13px;
  font:inherit; font-size:12px; font-weight:500; line-height:1; color:var(--ink-3);
  background:transparent; border:0; border-radius:6px;
  cursor:pointer; user-select:none; white-space:nowrap;
  transition:color .12s ease;
}
.tt-chip:hover{ color:var(--ink); }
.tt-chip:focus-visible{ outline:2px solid var(--accent-edge); outline-offset:1px; }
.tt-chip.is-active{
  color:var(--ink); background:var(--surface);
  box-shadow:0 1px 2px rgba(21,36,47,0.08);
}
/* Inline count, same type as the label ("All · 4" reads as one phrase). */
.tt-chip-count{ font-variant-numeric:tabular-nums; color:inherit; }
.tt-chip-count::before{ content:"· "; white-space:pre; color:var(--ink-4); }
.tt-chip-count:empty{ display:none; }

.tt-controls{ display:flex; align-items:center; gap:10px; }

.tt-search{
  display:inline-flex; align-items:center; gap:8px;
  height:32px; width:220px; padding:0 12px;
  background:var(--surface); border:1px solid var(--rule-3); border-radius:7px;
  color:var(--ink-4);
}
.tt-search:focus-within{ border-color:var(--accent-edge); box-shadow:0 0 0 3px var(--accent-soft); color:var(--ink-3); }
.tt-search input{
  border:none; outline:none; background:transparent;
  font:inherit; font-size:12.5px; color:var(--ink); flex:1; min-width:0;
}
.tt-search input::placeholder{ color:var(--ink-4); }
.tt-search input::-webkit-search-cancel-button{ -webkit-appearance:none; }

/* Dropdown-style sort button reading "Sort · Status ⌄". */
.tt-sort{
  display:inline-flex; align-items:center; gap:4px;
  height:32px; padding:0 12px;
  background:var(--surface); border:1px solid var(--rule-3); border-radius:7px;
  cursor:pointer;
}
.tt-sort:hover{ border-color:var(--ink-5); }
.tt-sort:focus-within{ border-color:var(--accent-edge); box-shadow:0 0 0 3px var(--accent-soft); }
.tt-sort .tt-sort-lbl{ font-size:12.5px; font-weight:500; color:var(--ink); }
.tt-sort select{
  height:100%; padding:0 14px 0 4px;
  font:inherit; font-size:12.5px; font-weight:500; color:var(--ink);
  background:transparent
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='6' viewBox='0 0 9 6' fill='none'%3E%3Cpath d='M1 1l3.5 3.5L8 1' stroke='%235B6B78' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    no-repeat right center;
  border:0; -webkit-appearance:none; appearance:none; cursor:pointer;
}
.tt-sort select:focus-visible{ outline:none; }

@media (max-width:720px){
  .tt-controls{ width:100%; }
  .tt-search{ flex:1; width:auto; }
}

/* ============ Teams index — filter show/hide + staggered entrance ============ */
/* Hidden cards leave grid flow entirely so the grid never shows holes. */
.teams-grid .team-card.is-hidden{ display:none; }

/* The JS-toggled "no matches" panel hides via the [hidden] attr — but .empty-state
   sets display:flex, which would otherwise win over the UA [hidden] rule and leave
   the panel showing on every load. This higher-specificity rule honors hidden. */
.teams-grid .empty-state[hidden]{ display:none; }

/* Compositor-only (transform + opacity) staggered entrance, replayed after a
   filter change or sort so the reorder reads as intentional. --tf-delay is set
   per-card by teams_filter_controller (capped, so a big grid never drags). */
@keyframes tf-card-in{
  from{ opacity:0; transform:translateY(6px) scale(0.985); }
  to{   opacity:1; transform:none; }
}
.teams-grid .team-card.tf-enter{
  animation:tf-card-in .34s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay:var(--tf-delay, 0ms);
  will-change:transform, opacity;
}

@media (prefers-reduced-motion: reduce){
  .teams-grid .team-card.tf-enter{ animation-duration:.01ms; animation-delay:0ms; }
  .team-card{ transition:none; }
}
