/* Organizational view (src/org/entry.tsx): the reporting tree on a pannable canvas. A card's colour is --c (the person's), its
   team band's --tc (the team's); no colour is grey. Connectors are borders, so they follow the theme's --oc-line. */

#view-org { --oc-line: color-mix(in oklab, var(--text-2) 32%, transparent); --oc-card-w: 236px; }

.oc-head { margin-bottom: 10px; display: flex; align-items: center; gap: 12px; }
.oc-head h2 { display: inline-flex; align-items: center; }
#oc-everyone { font-weight: 600; }
body[data-view="org"] #app-nav, body[data-view="org-react"] #app-nav { display: none; }
body[data-view="org"] #views, body[data-view="org-react"] #views { display: flex; flex-direction: column; min-height: calc(100vh - var(--mast-h)); }
body[data-view="org"] #view-org, body[data-view="org"] #app-org { display: flex; flex-direction: column; flex: 1; }
body[data-view="org"] .oc-viewport { flex: 1; height: auto; min-height: 0; }
.oc-partial { margin-left: 10px; font-size: 12.5px; color: var(--muted); }
.oc-partial[hidden] { display: none; }

.oc-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin-bottom: 12px; }
.oc-bar .segmented .lbl { align-self: center; padding: 0 8px 0 6px; color: var(--muted); font-size: 12px; }
.oc-bar .segmented button { border: 0; background: transparent; color: var(--text-2); padding: 5px 12px; border-radius: 7px; cursor: pointer; font-size: 13px; }

.oc-legend { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.oc-legend-end, .oc-legend-grey { white-space: nowrap; }
.oc-legend-bar { width: 132px; height: 8px; border-radius: 999px; box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--text) 8%, transparent); }
.oc-legend-grey { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; padding-left: 12px; border-left: 1px solid var(--border); color: var(--muted); }
.oc-swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--surface-2); border: 1px dashed var(--muted); }

.oc-tools[hidden] { display: none; }
.oc-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.oc-search { display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; height: 32px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--muted); }
.oc-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent); }
.oc-search input { border: 0; outline: 0; background: transparent; color: var(--text); width: 170px; font-size: 13px; }
/* Two button groups: what is folded, and the zoom. */
.oc-zoom, .oc-fold { display: inline-flex; align-items: stretch; height: 32px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.oc-zoom .icon-btn, .oc-fold .icon-btn { width: auto; height: auto; min-width: 32px; border: 0; border-radius: 0; box-shadow: none; background: transparent; color: var(--text); cursor: pointer; font-size: 15px; }
.oc-zoom > * + *, .oc-fold > * + * { border-left: 1px solid var(--border); }
.oc-zoom .oc-word, .oc-fold .oc-word { font-size: 12px; padding: 0 10px; white-space: nowrap; }
.oc-zoom .icon-btn:hover, .oc-fold .icon-btn:hover { background: var(--surface-2); }
.oc-pct { display: inline-grid; place-items: center; min-width: 46px; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-2); }
.oc-level { display: inline-flex; align-items: center; gap: 6px; padding: 0 4px 0 10px; font-size: 12px; color: var(--muted); }
.oc-level[hidden], .oc-fold [hidden] { display: none; }
.oc-level select { border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 12px; height: 100%; cursor: pointer; }
.oc-level:focus-within { box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--accent) 35%, transparent); }

/* The canvas: a dotted board, dragged with the pointer. */
.oc-viewport {
  position: relative; overflow: hidden; height: max(460px, calc(100vh - 262px));
  border: 1px solid var(--border); border-radius: var(--radius);
  background-color: var(--surface);
  background-image: radial-gradient(color-mix(in oklab, var(--text-2) 22%, transparent) 1px, transparent 1.2px);
  background-size: 22px 22px;
  cursor: grab; touch-action: none; outline: none;
}
.oc-viewport:focus-visible { box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 25%, transparent); }
.oc-viewport.dragging { cursor: grabbing; }
.oc-viewport.dragging .oc-card { pointer-events: none; }
.oc-canvas { position: absolute; top: 0; left: 0; transform-origin: 0 0; display: flex; gap: 48px; align-items: flex-start; padding: 8px; width: max-content; }
.oc-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--muted); }
.oc-empty[hidden] { display: none; }

/* The tree: a row of subtrees under each manager, joined by elbows. */
.oc-tree, .oc-tree ul { list-style: none; margin: 0; padding: 0; }
/* The React stylesheet makes pseudo-elements border-box; the connectors are sized as content-box. */
.oc-tree ::before, .oc-tree ::after { box-sizing: content-box; }
.oc-tree li { position: relative; display: flex; flex-direction: column; align-items: center; }
.oc-row { display: flex; justify-content: center; position: relative; padding-top: 22px; }
.oc-row::before { content: ''; position: absolute; top: 0; left: 50%; height: 22px; border-left: 2px solid var(--oc-line); }
.oc-row > li { padding: 22px 10px 0; }
.oc-row > li::before, .oc-row > li::after { content: ''; position: absolute; top: 0; width: 50%; height: 22px; border-top: 2px solid var(--oc-line); }
.oc-row > li::before { right: 50%; }
.oc-row > li::after { left: 50%; border-left: 2px solid var(--oc-line); }
.oc-row > li:first-child::before, .oc-row > li:last-child::after { border-top-color: transparent; }
.oc-row > li:first-child::after { border-top-left-radius: 10px; }
.oc-row > li:last-child::before { border-right: 2px solid var(--oc-line); border-top-right-radius: 10px; }
.oc-row > li:only-child::before { display: none; }
.oc-row > li:only-child::after { border-top: 0; border-radius: 0; }

/* People with no one under them: a column on one spine. The cards cover it; it shows in the gaps. */
.oc-stack { display: flex; flex-direction: column; align-items: center; gap: 10px; position: relative; padding-top: 22px; }
.oc-stack::before { content: ''; position: absolute; top: 0; bottom: 30px; left: 50%; border-left: 2px solid var(--oc-line); }
.oc-leaves > .oc-stack { padding-top: 0; }
.oc-leaves > .oc-stack::before { top: -2px; }

/* A card. */
.oc-card {
  --c: var(--muted); --tc: var(--muted);
  position: relative; z-index: 1; width: var(--oc-card-w);
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 6px 16px -10px rgba(16, 24, 40, 0.25);
  overflow: hidden; transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
}
.oc-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--c); }
.oc-card:hover { border-color: color-mix(in oklab, var(--c) 55%, var(--border)); box-shadow: 0 2px 4px rgba(16, 24, 40, 0.06), 0 12px 24px -12px rgba(16, 24, 40, 0.35); transform: translateY(-1px); }
.oc-main { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 14px; color: inherit; text-decoration: none; background: linear-gradient(90deg, color-mix(in oklab, var(--c) 12%, transparent), transparent 70%); }
a.oc-main:hover { text-decoration: none; }
.oc-avatar {
  flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em; color: var(--text);
  background: color-mix(in oklab, var(--c) 26%, var(--surface));
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--c);
}
.oc-who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.oc-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oc-sub { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1em; }
.oc-val { flex: none; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; padding: 3px 8px; border-radius: 999px; background: color-mix(in oklab, var(--c) 20%, transparent); }
.oc-val small, .oc-team-v small { font-weight: 500; font-size: 10.5px; color: var(--text-2); }

/* The team band: the manager's whole team, folded or open. */
.oc-team {
  display: flex; align-items: center; gap: 7px; width: 100%; padding: 6px 12px 6px 14px; border: 0; border-top: 1px solid var(--border);
  background: color-mix(in oklab, var(--tc) 14%, var(--surface-2)); color: var(--text); font-size: 12px; cursor: pointer; text-align: left;
}
.oc-team:hover { background: color-mix(in oklab, var(--tc) 22%, var(--surface-2)); }
.oc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tc); flex: none; }
.oc-team-l { color: var(--text-2); }
.oc-team-v { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.oc-chev { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; font-size: 10.5px; font-weight: 700; color: var(--text-2); background: color-mix(in oklab, var(--text) 7%, transparent); }
.oc-team[aria-expanded="false"] .oc-chev { background: var(--tc); color: oklch(0.22 0.02 260); min-width: 26px; }
.oc-team-grey .oc-team[aria-expanded="false"] .oc-chev { background: var(--muted); color: var(--surface); }
.oc-team:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* A folded team: its cards stacked behind the manager's, in the team's colour. */
.oc-card.oc-folded, .oc-card.oc-folded:hover {
  box-shadow:
    0 1px 2px rgba(16, 24, 40, 0.06),
    5px 5px 0 -1px var(--surface), 5px 5px 0 0 color-mix(in oklab, var(--tc) 60%, var(--border)),
    10px 10px 0 -1px var(--surface), 10px 10px 0 0 color-mix(in oklab, var(--tc) 35%, var(--border)),
    0 14px 22px -14px rgba(16, 24, 40, 0.35);
}

/* No number: grey and dashed. */
.oc-grey { border-style: dashed; }
.oc-grey .oc-main { background: none; }
.oc-grey .oc-avatar { background: var(--surface-2); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--border); color: var(--muted); }
.oc-grey .oc-val { background: var(--surface-2); color: var(--muted); }
.oc-grey::before { background: var(--border); }
.oc-team-grey .oc-team { background: var(--surface-2); }
.oc-team-grey .oc-dot { background: transparent; border: 1px dashed var(--muted); }
.oc-team-grey .oc-team-v { color: var(--muted); font-weight: 500; }

/* A group that is no one's team (people in no listed team, or a department). */
.oc-group { border-style: dashed; }
.oc-group::before { background: var(--tc); }
.oc-group .oc-main { background: none; }
.oc-group .oc-avatar { background: var(--surface-2); color: var(--text-2); box-shadow: none; }

/* Found by the search. */
.oc-focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 30%, transparent), 0 12px 24px -12px rgba(16, 24, 40, 0.35); animation: oc-pulse 1.4s ease-out 2; }
@keyframes oc-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 45%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
@media (prefers-reduced-motion: reduce) { .oc-focus { animation: none; } .oc-card { transition: none; } }

@media (max-width: 760px) {
  .oc-tools { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .oc-search { flex: 1 1 100%; }
  .oc-search input { width: 100%; }
  .oc-legend-bar { width: 90px; }
  .oc-pct { min-width: 40px; }
  .oc-zoom .icon-btn, .oc-fold .icon-btn { min-width: 36px; }
  .oc-viewport { height: 70vh; }
}

/* Level (levels.js): the legend is the levels, and one of them can be picked to dim everyone else. */
.oc-only { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.oc-only button { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font: inherit; font-size: 12px; cursor: pointer; }
.oc-only button i { width: 8px; height: 8px; border-radius: 50%; background: var(--lc); }
.oc-only button[aria-pressed="true"] { color: var(--text); font-weight: 600; border-color: var(--lc); background: color-mix(in oklab, var(--lc) 16%, var(--surface)); }
.oc-dim { opacity: 0.3; }
.oc-team-v .lvl-dist { width: 72px; }
.oc-only[hidden], .oc-legend [hidden] { display: none; }
