/* ── View stage ───────────────────────────────── */
/* Both views share the area left of the sidebar. The timeline stays laid out
   (visibility, not display) while hidden, so its label measurements and
   "Go to Today" centring stay correct when switching back. */
.view-stage {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100vh;
  container-type: inline-size;
}

[data-view="teams"] .timeline-container {
  visibility: hidden;
}

/* Zoom and "today" only make sense on the timeline */
[data-view="teams"] .ctrl-nav {
  display: none;
}

[data-view="teams"] .ctrl-trend {
  border-left: none;
}

/* ── View switch ──────────────────────────────── */
.view-switch {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 1000;
  display: flex;
  gap: 2px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(6px);
}

/* .view-switch prefix so these beat the global button styles */
.view-switch .view-switch-btn {
  padding: 6px 14px;
  border-radius: 999px;
  background: transparent;
  color: #888;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.view-switch .view-switch-btn:hover {
  background: transparent;
  color: #444;
}

.view-switch .view-switch-btn[aria-selected="true"] {
  background: var(--switch-on, #fff);
  color: var(--switch-on-ink, #222);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.view-switch .view-switch-btn:focus-visible {
  outline: 2px solid #4f86c6;
  outline-offset: 1px;
}

/* ── Team view ────────────────────────────────── */
.team-view {
  --tv-page: var(--page);
  --tv-ink: var(--ink);
  --tv-muted: var(--muted);
  --tv-outline: var(--outline);

  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--tv-page);
  color: var(--tv-ink);
  font-family: var(--font);
}

[data-view="timeline"] .team-view {
  display: none;
}

/* Clear of the view switch (top) and the controls bar (bottom) */
.team-canvas {
  position: absolute;
  inset: 64px 24px 96px 24px;
}

.team-canvas svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.team-view-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  color: var(--tv-muted);
  font-size: 13px;
}

/* ── Bubbles ── */
.tv-outline {
  fill: none;
  stroke: var(--tv-outline);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 0.5 7;
  opacity: 0.8;
}

.tv-bubble {
  cursor: pointer;
  outline: none;
}

.tv-halo {
  opacity: 0.7;
  transition: opacity 0.25s ease;
}

.tv-bubble:hover .tv-halo,
.tv-bubble:focus-visible .tv-halo {
  opacity: 1;
}

.tv-ring {
  fill-opacity: 0.2;
  stroke-opacity: 0.35;
  stroke-width: 0.8;
}

.tv-ring.unknown {
  fill-opacity: 0.07;
  stroke-opacity: 0.6;
  stroke-dasharray: 3 3;
}

.tv-ring.empty {
  fill: none;
  stroke-opacity: 0.5;
  stroke-dasharray: 3 3;
}

.tv-focus {
  fill: none;
  stroke: transparent;
  stroke-width: 1.5;
}

.tv-bubble:focus-visible .tv-focus {
  stroke: var(--tv-ink);
}

.tv-label {
  pointer-events: none;
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--tv-page);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.tv-label-name {
  font-size: 12px;
  font-weight: 600;
  fill: var(--tv-ink);
}

.tv-label-meta {
  font-size: 11px;
  font-weight: 400;
  fill: var(--tv-muted);
  font-variant-numeric: tabular-nums;
}

.tv-alumnus {
  fill: var(--tv-page);
  stroke-width: 1.2;
  opacity: 0.55;
  transition: opacity 0.2s ease;
}

.tv-alumnus:hover {
  opacity: 1;
}

/* ── Legend ── */
/* Bottom left, beside the centred controls strip; lifted above it when the
   stage is too narrow for both side by side */
@container (max-width: 900px) {
  .team-view .team-legend {
    bottom: 100px;
  }

  .team-view .team-canvas {
    bottom: 168px;
  }
}

.team-legend {
  position: absolute;
  left: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--tv-muted);
  font-size: 11px;
}

.team-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.team-legend svg {
  width: 14px;
  height: 14px;
  fill: rgba(111, 122, 148, 0.18);
  stroke: rgba(111, 122, 148, 0.6);
  stroke-width: 1;
}

.team-legend .legend-unknown {
  fill: rgba(111, 122, 148, 0.06);
  stroke-dasharray: 2.5 2;
}

.team-legend .legend-alumni {
  fill: var(--tv-page);
  stroke-width: 1.4;
}

@media (prefers-reduced-motion: reduce) {
  .view-switch .view-switch-btn,
  .tv-halo,
  .tv-alumnus {
    transition: none;
  }
}

/* ── Open team (zoom) ─────────────────────────── */
.team-view [hidden],
.people-sidebar [hidden] {
  display: none !important;
}

/* Strokes keep their width while the camera scales the world */
.tv-ring,
.tv-outline,
.tv-focus {
  vector-effect: non-scaling-stroke;
}

.tv-bubble,
.tv-outline,
.tv-alumni {
  transition: opacity 0.45s ease, filter 0.45s ease;
}

.tv-label {
  transition: opacity 0.25s ease;
}

.tv-bubble.is-dimmed {
  opacity: 0.25;
}

.tv-bubble.is-hover .tv-halo {
  opacity: 1;
}

.is-zoomed .tv-outline,
.is-zoomed .tv-alumni {
  opacity: 0;
  pointer-events: none;
}

.is-zoomed .tv-label {
  opacity: 0;
}

.is-zoomed .tv-bubble:not(.is-open) {
  opacity: 0.3;
  filter: blur(2px);
}

.is-zoomed .tv-bubble:not(.is-open).is-hover,
.is-zoomed .tv-bubble:not(.is-open):focus-visible {
  opacity: 0.6;
  filter: none;
}

.is-zoomed .tv-bubble.is-open {
  cursor: default;
}

.is-zoomed .tv-bubble.is-open .tv-halo {
  opacity: 0.35;
}

/* Detail layer: fades in once the camera has mostly arrived */
.tv-detail {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.is-zoomed .tv-detail {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.35s ease 0.35s;
}

.tv-ring-line {
  fill: none;
  stroke-opacity: 0.3;
  stroke-width: 1;
}

.tv-ring-line.unknown {
  stroke-dasharray: 4 4;
}

.tv-ring-label {
  pointer-events: none;
  text-anchor: middle;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  fill: var(--tv-muted);
  paint-order: stroke;
  stroke: var(--tv-page);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.tv-member {
  outline: none;
  transition: opacity 0.2s ease;
}

.tv-member-bg {
  stroke: #fff;
  stroke-width: 2;
  transition: stroke 0.15s ease;
}

.tv-member-initials {
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: central;
  font-weight: 600;
  fill: #fff;
}

.tv-member-photo {
  pointer-events: none;
}

.tv-member-halo {
  fill: none;
  stroke: transparent;
  stroke-width: 3;
}

/* Joined in the selected period */
.tv-member.is-new .tv-member-halo {
  stroke: #7fb069;
}

.tv-member:hover .tv-member-bg,
.tv-member:focus-visible .tv-member-bg,
.tv-member.is-highlighted .tv-member-bg {
  stroke: var(--tv-ink);
}

.tv-detail.has-highlight .tv-member:not(.is-highlighted),
.tv-detail.has-highlight .tv-detail-alumnus:not(.is-highlighted) {
  opacity: 0.3;
}

.tv-detail-alumnus {
  outline: none;
  opacity: 0.7;
  filter: grayscale(1);
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.tv-detail-alumnus .tv-member-bg {
  stroke-width: 1.5;
}

.tv-alumnus-ring {
  fill: none;
  stroke-width: 1.2;
  stroke-dasharray: 2 2.5;
}

/* Left in the selected period */
.tv-detail-alumnus.is-recent {
  opacity: 0.9;
}

.tv-detail-alumnus.is-recent .tv-alumnus-ring {
  stroke: #f08aa6;
  stroke-width: 2;
  stroke-dasharray: none;
}

.tv-detail-alumnus:hover,
.tv-detail-alumnus:focus-visible,
.tv-detail-alumnus.is-highlighted {
  opacity: 1;
  filter: none;
}

/* Open team's header, at the top of the cards panel */
.tv-header {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--surface-line);
}

.team-view .tv-back {
  margin: -4px 0 0 -6px;
  padding: 3px 8px 3px 6px;
  border-radius: 999px;
  background: transparent;
  color: var(--surface-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  transition: color 0.15s ease, background 0.15s ease;
}

.team-view .tv-back:hover,
.team-view .tv-back:focus-visible {
  background: var(--tab-hover);
  color: var(--surface-ink);
  outline: none;
}

.tv-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 2px;
  overflow: hidden;
  font-size: 22px;
  font-weight: 300;
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tv-title::before {
  content: "";
  flex-shrink: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--team-color, #999);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--team-color, #999) 25%, transparent);
}

.tv-subtitle {
  margin: 0 0 0 21px;
  color: var(--surface-muted);
  font-size: 11.5px;
}

/* With a team open, the subject line only shows while previewing another team */
.tv-cards.has-open .tv-cards-head:not(.is-preview) .tv-cards-subject {
  visibility: hidden;
}

.tv-cards.has-open .tv-cards-head:not(.is-preview) {
  height: 0;
  margin: 0;
  overflow: hidden;
}

.tv-cards-head.is-preview .tv-cards-subject::after {
  content: "preview";
  margin-left: 2px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--tv-muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Tooltip */
.tv-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 240px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(43, 43, 43, 0.92);
  color: #fff;
  font-size: 11px;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.tv-tooltip strong {
  font-size: 12px;
  font-weight: 600;
}

.tv-tooltip span {
  color: rgba(255, 255, 255, 0.75);
}

/* ── Sidebar in the teams view ────────────────── */
[data-view="timeline"] [data-sidebar="teams"],
[data-view="teams"] [data-sidebar="timeline"] {
  display: none;
}

.team-sidebar-back {
  margin: -6px 0 6px -6px;
  padding: 3px 6px;
  border-radius: 4px;
  background: transparent;
  color: #888;
  font-size: 11px;
  font-weight: 600;
}

.people-sidebar .team-sidebar-back:hover {
  background: #f4f4f4;
  color: #333;
}

.team-tabs {
  margin-bottom: 0;
}

/* Same look as the timeline sidebar's tabs (.tab-btn) */
.people-sidebar .team-tab-btn {
  flex: 1;
  padding: 5px 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: #888;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.people-sidebar .team-tab-btn[aria-selected="true"] {
  background: #ffffff;
  color: #222;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.people-sidebar .team-tab-btn:hover:not([aria-selected="true"]) {
  background: transparent;
  color: #444;
}

.team-row {
  cursor: pointer;
  outline: none;
}

.team-row:focus-visible {
  background: #f7f7f7;
  box-shadow: inset 3px 0 0 var(--team-color);
}

.team-row-dot {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  margin: 0 11px;
  border-radius: 50%;
  background: var(--team-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--team-color) 22%, transparent);
}

.team-row-tenure {
  display: flex;
  gap: 1px;
  height: 3px;
  margin-top: 6px;
  border-radius: 2px;
  overflow: hidden;
}

.team-row-tenure span {
  background: var(--team-color);
}

.team-row-tenure span.unknown {
  background: repeating-linear-gradient(90deg, var(--team-color) 0 2px, transparent 2px 4px);
  opacity: 0.6 !important;
}

.team-row-net {
  flex-shrink: 0;
  min-width: 26px;
  padding: 2px 6px;
  border-radius: 10px;
  background: #f4f4f4;
  color: #999;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.team-row-net.growing {
  background: rgba(76, 175, 80, 0.14);
  color: #3d7a57;
}

.team-row-net.shrinking {
  background: rgba(244, 67, 54, 0.12);
  color: #b5523f;
}

.member-chip {
  flex-shrink: 0;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.member-chip.new {
  background: rgba(127, 176, 105, 0.18);
  color: #3d7a57;
}

.member-chip.left {
  background: rgba(240, 138, 166, 0.2);
  color: #b5523f;
}

@media (prefers-reduced-motion: reduce) {
  .tv-bubble,
  .tv-outline,
  .tv-alumni,
  .tv-label,
  .tv-detail,
  .is-zoomed .tv-detail,
  .tv-member,
  .tv-detail-alumnus {
    transition: none;
  }
}

/* ── Cards: Now / History / Tenure / Retention ── */
/* Room for the cards beside the canvas when the stage is wide enough */
@container (min-width: 861px) {
  .team-view .team-canvas {
    right: 340px;
  }
}

.tv-cards {
  --card-color: #6f7a94;
  --card-ink: var(--surface-ink);
  --card-muted: var(--surface-muted);
  --card-accent: var(--accent);
  --card-tile: var(--tile);

  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 6;
  width: 300px;
  padding: 14px 16px 12px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--surface-shadow);
  backdrop-filter: blur(8px);
  color: var(--card-ink);
  box-sizing: border-box;
}

.tv-cards-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.tv-cards-subject {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tv-cards-subject::before {
  content: "";
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--team-color, #6f7a94);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--team-color, #6f7a94) 25%, transparent);
  transition: background 0.2s ease;
}

/* Only on narrow stages, where the cards overlay the canvas */
.team-view .tv-cards-toggle {
  display: none;
}

/* Chip tabs (Ember week-day chips) */
.tv-card-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.team-view .tv-card-tab {
  flex: 1;
  padding: 5px 0;
  border-radius: 999px;
  background: transparent;
  color: var(--card-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.team-view .tv-card-tab:hover {
  background: var(--tab-hover);
  color: var(--card-ink);
}

.team-view .tv-card-tab[aria-selected="true"] {
  background: var(--select);
  color: var(--select-ink);
}

.team-view .tv-card-tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Fixed height: switching tabs or teams never changes the card's size */
.tv-card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 214px;
}

.tv-card-body.is-entering {
  animation: tv-card-in 0.25s ease;
}

@keyframes tv-card-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
}

.tv-hero {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.tv-hero-number {
  font-size: 46px;
  font-family: var(--display-font);
  font-weight: var(--display-weight);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.tv-hero-unit {
  color: var(--card-muted);
  font-size: 12px;
}

.tv-chip {
  margin-left: auto;
  align-self: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--card-muted);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tv-chip.growing {
  background: color-mix(in srgb, var(--pos) 16%, transparent);
  color: var(--pos);
}

.tv-chip.shrinking {
  background: color-mix(in srgb, var(--neg) 16%, transparent);
  color: var(--neg);
}

.tv-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.tv-tile {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--card-tile);
}

.tv-tile-caption {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--card-muted);
  white-space: nowrap;
}

.tv-tile-value {
  font-size: 19px;
  font-weight: 400;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.tv-tile-extra {
  overflow: hidden;
  color: var(--card-muted);
  font-size: 10px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Too little data to trust: muted numbers */
.tv-tiles.is-thin .tv-tile-value {
  color: var(--card-muted);
}

.tv-card-note {
  margin: auto 0 0;
  color: var(--card-muted);
  font-size: 10.5px;
  line-height: 1.35;
}

.tv-empty {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  color: var(--card-muted);
  font-size: 12px;
  text-align: center;
}

/* Charts (History, Retention) */
.tv-chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.tv-chart-axis,
.tv-chart-grid {
  stroke: var(--grid);
  stroke-width: 1;
}

.tv-chart-grid {
  stroke-dasharray: 2 3;
}

.tv-chart-period {
  fill: var(--accent-wash);
}

.tv-chart-area {
  opacity: 0.12;
}

.tv-chart-line {
  fill: none;
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.tv-chart-line.reference {
  stroke: var(--card-muted);
  stroke-width: 1.2;
  stroke-dasharray: 3 3;
  opacity: 0.7;
}

.tv-chart-line.is-thin {
  stroke-dasharray: 1 3;
  stroke-linecap: round;
}

.tv-chart-point {
  fill: var(--surface-solid);
  stroke-width: 1.5;
}

.tv-chart-value {
  font-size: 10px;
  font-weight: 600;
  fill: var(--card-ink);
  font-variant-numeric: tabular-nums;
}

.tv-chart-tick {
  font-size: 9px;
  fill: var(--card-muted);
  font-variant-numeric: tabular-nums;
}

/* Tenure rods (Braun) */
.tv-rods {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  flex: 1;
  min-height: 0;
  gap: 4px;
}

.tv-rod {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 0;
}

.tv-rod-count {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tv-rod-track {
  display: flex;
  flex: 1;
  align-items: flex-end;
  width: 8px;
  border-radius: 4px;
  background: var(--grid-soft);
}

.tv-rod-bar {
  width: 100%;
  border-radius: 4px;
  background: var(--card-color);
  transition: height 0.3s ease;
}

.tv-rod.unknown .tv-rod-bar {
  background: repeating-linear-gradient(180deg, var(--card-color) 0 3px, transparent 3px 6px);
  opacity: 0.6;
}

.tv-rod-label {
  color: var(--card-muted);
  font-size: 9.5px;
  white-space: nowrap;
}

/* Narrow stages: the cards collapse to a "Details" button over the canvas */
@container (max-width: 860px) {
  .team-view .tv-cards {
    width: auto;
    max-width: 300px;
    padding: 8px 10px 8px 14px;
  }

  .team-view .tv-cards-head {
    gap: 10px;
    margin-bottom: 0;
  }

  .team-view .tv-cards-toggle {
    display: block;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--card-accent);
    color: var(--accent-ink);
    font: inherit;
    font-size: 11px;
    font-weight: 500;
  }

  .team-view .tv-cards:not(.is-expanded) .tv-cards-panel {
    display: none;
  }

  .team-view .tv-cards.is-expanded {
    width: 300px;
    padding: 14px 16px 12px;
  }

  .team-view .tv-cards.is-expanded .tv-cards-head {
    margin-bottom: 10px;
  }

  /* The Details button lives in this row, so it never collapses here */
  .team-view .tv-cards.has-open .tv-cards-head:not(.is-preview) {
    height: auto;
    overflow: visible;
  }

  .team-view .tv-cards:not(.is-expanded) .tv-header {
    margin-bottom: 6px;
    padding-bottom: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tv-card-body.is-entering {
    animation: none;
  }

  .tv-rod-bar,
  .tv-cards-subject::before {
    transition: none;
  }
}
