/* Officer hub: team section (officer cards, one officer's page, the Edit my page dialog), plus the
   workload bar (.load-meter) that the dashboard uses too. Tokens come from app.css. */

/* ---------- the workload bar ---------- */

.load-meter { display: grid; gap: 6px; min-width: 0; }
.load-bar {
  display: block; height: 8px; overflow: hidden;
  border-radius: 999px; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.load-fill { display: block; height: 100%; border-radius: inherit; background: var(--ok); }
.load-meter.level-near .load-fill { background: var(--warn); }
.load-meter.level-over .load-fill { background: var(--danger); }
.load-meter.level-none .load-fill { background: transparent; }
.load-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: 14px; }
.load-main { font-weight: 650; font-variant-numeric: tabular-nums; }
.load-extra { color: var(--muted); }
.load-meter.level-over .load-extra { color: var(--danger); font-weight: 600; }
.load-meter.level-near .load-extra { color: var(--warn); font-weight: 600; }
.load-meter.is-compact { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.load-meter.is-compact .load-text { font-size: 13px; color: var(--muted); white-space: nowrap; }
.load-meter.is-compact .load-main { font-weight: 600; }
.load-meter.is-compact .load-extra { display: none; }
.load-meter.is-compact.level-over .load-main { color: var(--danger); }

/* "You" next to your own name. */
.team-you {
  display: inline-block; margin-left: 8px; vertical-align: 0.12em;
  font-size: 11px; font-weight: 750; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent-ink); background: var(--accent); border-radius: 5px; padding: 1px 6px;
}

/* ---------- the grid of officers ---------- */

.team-summary { display: flex; flex-wrap: wrap; gap: 2px 14px; margin: -8px 0 22px; color: var(--muted); font-size: 14px; }
.team-summary-warn { color: var(--danger); font-weight: 650; }

.team-group + .team-group { margin-top: 28px; }
.team-group-title {
  display: flex; align-items: center; gap: 8px; margin: 0 0 10px;
  font-size: 12px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.team-group-count {
  font-size: 11px; letter-spacing: 0; padding: 0 7px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.team-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(262px, 1fr)); gap: 12px;
}

.team-card {
  position: relative;
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
  padding: 16px 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: border-color 0.15s;
}
.team-card:hover { border-color: var(--line-strong); }
.team-card:has(.team-card-name:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.team-card.is-me { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.team-card.is-open { background: transparent; border-style: dashed; border-color: var(--line-strong); box-shadow: none; }

.team-card-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.team-card-who { min-width: 0; }
.team-card-name { font-weight: 750; font-size: 16px; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
/* The name is the card's link; this stretches it over the whole card. */
.team-card-name::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.team-card-name:focus-visible { outline: none; }
.team-card:hover .team-card-name { color: var(--accent); }
.team-card-role { margin: 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

.team-card-focus {
  margin: 0; font-size: 14px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere;
}
.team-card-focus.is-empty { color: var(--muted); }
.team-card-note {
  display: flex; gap: 8px; margin: 0; padding: 6px 10px;
  border-radius: 8px; background: var(--surface-2); border-left: 3px solid var(--warn);
  font-size: 13px; overflow-wrap: anywhere;
}
.team-note-label { flex: none; font-weight: 750; color: var(--muted); }
.team-card-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.team-stat { font-size: 13px; font-weight: 650; }
.team-stat-late { color: var(--danger); }
/* Links inside a card sit above the stretched card link. */
.team-card-action { position: relative; z-index: 1; font-size: 13px; font-weight: 650; justify-self: start; }

/* ---------- one officer ---------- */

.team-back {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; margin: -6px 0 8px;
  font-weight: 650; font-size: 14px; text-decoration: none;
}
.team-back::before { content: "\2190"; font-size: 16px; }
.team-back:hover { text-decoration: underline; text-underline-offset: 3px; }

.team-person-head { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 20px; }
.team-person-who { flex: 1 1 260px; min-width: 0; }
.team-person-name { margin: 0; font-size: 26px; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.team-person-name:focus { outline: none; }
.team-person-role { margin: 3px 0 0; color: var(--muted); font-weight: 600; }
.team-person-updated { margin: 2px 0 0; font-size: 13px; }
.team-person-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.team-person { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.team-person-main, .team-person-side { display: grid; gap: 16px; min-width: 0; }
.team-block { padding: 18px 20px; min-width: 0; }
.team-block-title {
  margin: 0 0 10px;
  font-size: 12px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.team-block-title:focus { outline: none; }
.team-block-foot { margin-top: 12px; }
.team-handover { margin: 0; border-left-color: var(--accent); }

.team-focus { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
.team-notes { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
/* Long notes open folded: about 14 lines, fading out above "Show all notes". */
.team-notes.is-folded {
  max-height: 22.4em; overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent);
  mask-image: linear-gradient(to bottom, #000 70%, transparent);
}
.team-quiet p { margin: 0 0 10px; color: var(--muted); }
.team-quiet p:last-child { margin: 0; }

.team-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.team-links a {
  display: flex; align-items: baseline; justify-content: space-between; gap: 4px 12px; flex-wrap: wrap;
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  text-decoration: none; color: var(--text);
}
.team-links a:hover { border-color: var(--accent); }
.team-link-label { font-weight: 650; overflow-wrap: anywhere; }
.team-link-label::after { content: " \2197"; color: var(--accent); font-weight: 500; }
.team-link-host { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }

.team-tasks { list-style: none; margin: 0; padding: 0; }
.team-task {
  position: relative;
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.team-task:first-child { border-top: 0; padding-top: 0; }
.team-task:last-child { padding-bottom: 0; }
.team-task-title { flex: 1 1 220px; min-width: 0; font-weight: 650; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
a.team-task-title:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
/* An open assignment's title stretches over its whole row, so the row is the tap target. */
a.team-task-title::after { content: ""; position: absolute; inset: 0; }
a.team-task-title:focus-visible { outline: none; }
.team-task:has(a.team-task-title:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.team-tasks.is-finished .team-task-title { font-weight: 550; }
.team-task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 13px; color: var(--muted); }
.team-due { font-weight: 650; }
.team-due.tone-late { color: var(--danger); }
.team-due.tone-soon { color: var(--warn); }
.team-hours { font-variant-numeric: tabular-nums; }
.team-more { font-weight: 650; font-size: 14px; }

.team-week-note {
  margin: 12px 0 0; padding: 8px 12px; border-radius: 8px;
  background: var(--surface-2); border-left: 3px solid var(--warn); overflow-wrap: anywhere;
}
.team-week-empty { margin: 12px 0 0; }
.team-facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 14px 0 0; font-size: 14px; }
.team-facts dt { color: var(--muted); }
.team-facts dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.team-facts dd.team-late { color: var(--danger); }
.team-contact { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.team-avail { margin: 0 0 2px; font-weight: 600; }
.team-open-about { margin: 0; }

/* ---------- the Edit my page dialog ---------- */

.tp-editor .hub-field { margin-bottom: 18px; }
.tp-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tp-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tp-count.is-near { color: var(--warn); font-weight: 650; }
.tp-hint { margin: 6px 0 0; font-size: 13px; }
.tp-field-error { margin: 6px 0 0; font-size: 14px; }
.tp-editor [aria-invalid="true"] { border-color: var(--danger); }
.tp-editor textarea[name="focus"] { min-height: 76px; }
.tp-editor textarea[name="notes"] { min-height: 160px; }
.tp-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 14px; }
.tp-links-field legend { margin-bottom: 0; padding: 0; }
.tp-links-field > .tp-hint { margin: 0 0 8px; }
.tp-links { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.tp-links:empty { display: none; }
.tp-link { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.7fr) auto; gap: 8px; align-items: center; }
.tp-link .btn { min-height: 46px; }
.tp-add-link { justify-self: start; }
.tp-links-field .tp-field-error { margin: 0 0 10px; }

/* ---------- narrower screens ---------- */

@media (max-width: 899px) {
  /* One column. The week and how to reach someone move up, right under the focus. */
  .team-person { grid-template-columns: minmax(0, 1fr); }
  .team-person-main, .team-person-side { display: contents; }
  .team-handover { order: 0; }
  .team-block.is-focus { order: 1; }
  .team-block.is-week { order: 2; }
  .team-block.is-contact { order: 3; }
  .team-block.is-notes { order: 4; }
  .team-block.is-links { order: 5; }
  .team-block.is-open { order: 6; }
  .team-block.is-finished { order: 7; }
  .team-block.is-avail { order: 8; }
}

@media (max-width: 759px) {
  .team-summary { margin: -6px 0 18px; }
  .team-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .team-card { padding: 14px 16px; }
  .team-back { min-height: 44px; margin-top: -10px; }
  .team-person-name { font-size: 22px; }
  .team-person-actions { width: 100%; }
  .team-person-actions .btn { flex: 1 1 auto; min-height: 44px; }
  .team-block { padding: 14px 16px; }
  .team-block .btn { min-height: 44px; }
  .team-more, .team-card-action { display: inline-flex; align-items: center; min-height: 44px; }
  .team-links a { min-height: 44px; align-items: center; }
  .team-task-title { flex-basis: 100%; }

  .tp-grid { grid-template-columns: minmax(0, 1fr); }
  .tp-link { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label remove" "url url"; }
  .tp-link .tp-link-label { grid-area: label; }
  .tp-link .tp-link-url { grid-area: url; }
  .tp-link .tp-link-remove { grid-area: remove; min-height: 46px; }
  .tp-links { gap: 14px; }
  .tp-add-link { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .team-card { transition: none; }
}
