/* ══════════════════════════════════════════════════════════════════════════════
   ShiftHR: Workspace
   ──────────────────────────────────────────────────────────────────────────────
   The Workspace Control landing (the summary, #503), the workspace pages' content
   wrapper, profile form, org chart tree, cascade matrix, and group membership panel
   (renamed from organisation.css by #1417, LXF-1 (a)).
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Workspace Control landing (#503) ─────────────────────────────────────────────── */
/* The at-a-glance slot: the dashboard content lands inside it (a placeholder during beta). */
.adm-dash-slot { margin-bottom: var(--space-7); }
.adm-dash-area { margin-bottom: var(--space-7); }
.adm-dash-area-title {
    font-size: var(--text-xs); font-weight: var(--font-bold); text-transform: uppercase;
    letter-spacing: var(--tracking-wide); color: var(--color-neutral-500);
    margin: 0 0 var(--space-3);
}
.adm-dash-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-4);
}
/* Each area card is the kit Card with Href (phase 3); this is its inner row only. */
.adm-dash-card { color: var(--color-neutral-900); text-decoration: none; }
.adm-dash-card-row { display: flex; align-items: flex-start; gap: var(--space-3); }
.adm-dash-card-icon { flex-shrink: 0; font-size: var(--text-lg); line-height: 1; opacity: .8; margin-top: 2px; }
.adm-dash-card-body { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.adm-dash-card-title {
    display: inline-flex; align-items: center; gap: var(--space-2);
    font-size: var(--text-base); font-weight: var(--font-semibold); color: var(--color-neutral-900);
}
.adm-dash-card-desc { font-size: var(--text-sm); color: var(--color-neutral-500); line-height: 1.4; }

/* #952 - the attention items inside the at-a-glance slot: one row per item, the action at the end */
.adm-attn-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.adm-attn-item {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-border); border-radius: var(--radius-md);
    background: var(--color-surface-raised);
}
.adm-attn-body { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.adm-attn-title { font-weight: 600; color: var(--color-neutral-900); }
.adm-attn-sentence { margin: 0; font-size: var(--text-sm); color: var(--color-neutral-700); line-height: 1.4; }
.adm-attn-action { flex-shrink: 0; white-space: nowrap; }

/* ── Organisation page content ─────────────────────────────────────────────── */
/* The discrete Workspace Control pages' content wrapper (the tab strip retired with #503). */
.org-tab-content {
    min-height: 200px;
}

.org-section {
    max-width: 900px;
}
/* #796: table-bearing org sections (Departments, Values & Behaviours) opt out of the 900px
   readable-form cap so their data tables use the full content width instead of side-scrolling
   inside it, matching the full-width Cascade (.cascade-section) and Profile (.admin-settings)
   pattern. Form-style sections (Profile, Goals) keep the narrower .org-section cap. */
.org-section--wide {
    max-width: 100%;
}

/* ════════════════════════════════════════════════════════════════════════════
   Org chart ("Groups" view) — Pass C rebuild.
   Connector geometry derives from the children container (no fixed px margins): each
   child draws a full-width top rail (+ half the flex gap each side); the outer half is
   trimmed on the first/last child, so the rail spans first-centre -> last-centre at any
   card width or gap. Collapse animates an always-rendered .oc-subtree via height auto<->0
   where interpolate-size is supported, instant otherwise (function never depends on it).
   #661: name + title show to everyone; role + employment-type badges (.oc-admin-badges)
   are RENDERED server-side only for authorised viewers (OrgTreeNode), never CSS-hidden.
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Toolbar ───────────────────────────────────────────────────────────────── */
.oc-toolbar {
    display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
    margin-bottom: var(--space-5); scroll-margin-top: 80px;
}
.oc-toolbar-summary {
    margin-left: auto; font-size: var(--text-sm); color: var(--color-neutral-500); font-weight: var(--font-medium);
}

/* ── Viewport: native 2D scroll = the zero-JS pan (trackpad / scrollbars / touch-drag) ── */
.oc-viewport {
    overflow: auto; max-height: 72vh;
    padding: var(--space-4) var(--space-2) var(--space-8);
    scrollbar-width: thin; overscroll-behavior: contain;
}
.oc-chart {
    display: inline-flex; justify-content: center; gap: var(--space-8); min-width: 100%;
    /* Chromium: animates the height auto<->0 collapse below; ignored (instant) elsewhere. */
    interpolate-size: allow-keywords;
}

/* ── Node + recursive connector geometry ──────────────────────────────────────── */
.oc-node { display: flex; flex-direction: column; align-items: center; position: relative; }
.oc-node[id] { scroll-margin-top: 120px; }

/* parent -> rail drop */
.oc-connector-down { width: 2px; height: 22px; background: var(--color-border); flex-shrink: 0; }

/* always-rendered subtree; collapse via height (Blazor toggles .is-collapsed on the node) */
.oc-subtree { overflow: hidden; height: auto; width: 100%; transition: height var(--duration-normal) var(--ease-out); }
/* A collapsed subtree reserves no width either (#1035): only its height collapsed before, so a
   collapsed card still took the width of every report under it, pushing its siblings apart until a
   third child sat off-screen at 1,539px with three cards showing. inline-size containment drops its
   intrinsic width; width: 100% then resolves to the card's own, and the hidden row stays clipped. */
.oc-node.is-collapsed > .oc-subtree { height: 0; contain: inline-size; }
.oc-subtree-inner { display: flex; flex-direction: column; align-items: center; width: 100%; }

.oc-children { display: flex; justify-content: center; align-items: flex-start; gap: var(--space-8); }
.oc-children > .oc-node { padding-top: 22px; position: relative; }
.oc-children > .oc-node::before {        /* horizontal rail (bridges the flex gap) */
    content: ""; position: absolute; top: 0; height: 0;
    left: calc(var(--space-8) / -2); right: calc(var(--space-8) / -2);
    border-top: 2px solid var(--color-border);
}
.oc-children > .oc-node:first-child::before { left: 50%; }
.oc-children > .oc-node:last-child::before  { right: 50%; }
.oc-children > .oc-node:only-child::before  { content: none; }
.oc-children > .oc-node::after {         /* vertical stub: rail -> card centre */
    content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 2px; height: 22px; background: var(--color-border);
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
/* Each card is the kit Card (phase 3); these rules are its width in the chart and its text alignment. */
.oc-card {
    position: relative; width: 212px;
    text-align: center;
    -webkit-user-select: none; user-select: none;
}
.oc-card-main { display: block; color: inherit; }

.oc-avatar {
    width: 56px; height: 56px; border-radius: var(--radius-full);
    background: var(--color-brand-light); color: var(--color-brand);
    display: flex; align-items: center; justify-content: center;
    font-weight: var(--font-bold); font-size: var(--text-lg); margin: 0 auto var(--space-3);
    border: 2px solid var(--color-border-brand);
}
.oc-name {
    font-size: var(--text-md); font-weight: var(--font-semibold); line-height: 1.25; color: var(--color-neutral-900);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.oc-title {
    font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--color-neutral-500);
    line-height: 1.3; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Department — organisational info, shown to everyone (the structural "Group"). */
.oc-dept {
    display: inline-flex; align-items: center; gap: 5px; max-width: 100%; margin-top: var(--space-3);
    padding: 3px 10px; border-radius: var(--radius-pill);
    background: var(--color-neutral-100); color: var(--color-neutral-700);
    font-size: var(--text-xs); font-weight: var(--font-medium);
}
.oc-dept span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* #718: shown when a cyclic reporting edge (A → B → A) is detected and the looping branch is
   truncated so the recursive chart can't StackOverflow. Token-backed, presentation only. */
.oc-cycle-note {
    display: inline-flex; align-items: center; gap: 5px; max-width: 100%; margin-top: var(--space-3);
    padding: 3px 10px; border-radius: var(--radius-pill);
    background: var(--color-warning-light); color: var(--color-warning-text);
    font-size: var(--text-xs); font-weight: var(--font-medium);
}
.oc-cycle-note span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* #661 seat detail — server-gated render (admins, or the viewer's downward line). */
.oc-admin-badges { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; margin-top: var(--space-3); }

/* Expand / collapse affordance */
/* Expand / collapse: the kit's ghost button (phase 3); this is its spacing under the card's text. */
.oc-expand { gap: 6px; margin-top: var(--space-3); }
.oc-chevron {
    display: inline-block; width: 7px; height: 7px;
    border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
    transform: rotate(45deg); transition: transform var(--duration-fast) var(--ease-out);
}
.oc-node.is-collapsed > .oc-card .oc-chevron { transform: rotate(-45deg); }

/* Highlight (directory -> card) */
.oc-card-highlight {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px rgba(var(--color-brand-rgb), .28), var(--shadow-md);
    animation: oc-pulse 2.2s var(--ease-out) forwards;
}
@keyframes oc-pulse {
    0%   { box-shadow: 0 0 0 5px rgba(var(--color-brand-rgb), .42), var(--shadow-md); }
    70%  { box-shadow: 0 0 0 3px rgba(var(--color-brand-rgb), .16), var(--shadow-md); }
    100% { box-shadow: var(--shadow-sm); border-color: var(--color-border); }
}
@media (prefers-reduced-motion: reduce) { .oc-card-highlight { animation: none; } }

/* ── Org Chart — Deactivated State ─────────────────────────────────────────── */
.oc-node-deactivated > .oc-card { opacity: .45; }

/* ── Org Chart — Focused Root Wrapper ──────────────────────────────────────── */
.oc-focused-root-wrapper {
    display: flex; flex-direction: column; align-items: center;
}

/* Upward connector line (sits between the nav buttons and the card) */
.oc-connector-up {
    width: 2px; height: 20px;
    background: var(--color-neutral-200);
    flex-shrink: 0;
}

/* Container for expand-up / collapse-down buttons — side by side */
.oc-navigate-up-down {
    display: flex; align-items: center; gap: 6px;
    flex-shrink: 0;
}

/* The up and down controls are the kit's icon button (btn-icon, #1040). */

/* ── Org Chart — Helper Text ───────────────────────────────────────────────── */
.manager-link { font-size: .8rem; color: var(--color-brand); font-weight: 500; }

/* ── Org Chart — Responsive ────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .oc-chart { gap: var(--space-5); }
    .oc-children { gap: var(--space-5); }
    .oc-card { width: 168px; }
    .oc-avatar { width: 44px; height: 44px; font-size: var(--text-base); }
}

/* ════════════════════════════════════════════════════════════════════════════
   Cascade coverage grid (#660) — "the Wall, in the matrix".
   ──────────────────────────────────────────────────────────────────────────────
   Replaces the old illegible bare-checkbox table. Source KIND carries colour
   (anti-conflation): strategic Goals = neutral graphite, cultural Values =
   Culture-green, in SEPARATE banded column groups so the two never blur. Structure
   (Groups) stays neutral. Cells are coverage TILES — an inherited cell fills with
   its band hue so coverage reads as colour clusters; row meters + column counts +
   the gap flag make completeness legible. Tiles are REAL checkboxes toggled purely
   by CSS :checked (production control, zero-JS — @onchange→ToggleLocal in Blazor).
   Band hues = the --cascade-* aliases (tokens.css :root,[data-theme]); the --csc-*
   geometry constants are component layout (tokens.css :root). The Save (#443)
   dirty/disabled/saved state is Blazor @code — NOT a data-attribute CSS shim — and
   the success/error banner is the real kit <Banner>, so no .shui-banner mirror here.
   ════════════════════════════════════════════════════════════════════════════ */
.cascade-section { max-width: 100%; }

/* ── Summary + legend strip ──────────────────────────────────────────────────── */
.csc-intro {
    font-size: var(--text-md); color: var(--color-neutral-600);
    line-height: var(--leading-normal); max-width: 72ch; margin-bottom: var(--space-5);
}
.csc-summary {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4) var(--space-6);
    margin-bottom: var(--space-5); padding: var(--space-4) var(--space-5);
    border: 1px solid var(--color-border); border-radius: var(--radius-lg);
    background: var(--color-surface-raised);
}
.csc-summary-cov { display: flex; align-items: baseline; gap: var(--space-2); }
.csc-summary-num {
    font-family: var(--font-mono); font-size: var(--text-3xl); font-weight: var(--font-semibold);
    color: var(--color-neutral-900); letter-spacing: var(--tracking-tight); line-height: 1;
}
.csc-summary-den { color: var(--color-neutral-400); font-size: var(--text-xl); font-weight: var(--font-normal); }
.csc-summary-lbl { font-size: var(--text-sm); color: var(--color-neutral-500); line-height: var(--leading-snug); }
.csc-summary-flag {
    display: inline-flex; align-items: center; gap: var(--space-2);
    padding: 5px 12px; border-radius: var(--radius-pill);
    background: var(--color-warning-light); color: var(--color-warning-text);
    border: 1px solid var(--color-warning-border);
    font-size: var(--text-sm); font-weight: var(--font-medium);
}
.csc-summary-flag svg { width: 15px; height: 15px; }
.csc-legend { display: flex; flex-wrap: wrap; gap: var(--space-4); margin-left: auto; }
.csc-legend-item { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--color-neutral-700); }
.csc-legend-sub { font-family: var(--font-mono); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); color: var(--color-neutral-400); }
.csc-swatch { width: 14px; height: 14px; border-radius: var(--radius-sm); border: 1.5px solid; flex-shrink: 0; }
.csc-swatch--goal  { background: var(--cascade-goal-fill);  border-color: var(--cascade-goal-accent); }
.csc-swatch--value { background: var(--cascade-value-fill); border-color: var(--cascade-value-accent); }

/* ── The coverage grid (the kit's DataGrid, #1040, BF-C (c)) ────────────────────
   The frame, the scroll within 72vh, the two sticky header rows and the sticky row heads are the
   kit's (HeaderRows, FixedHeader, FixedFirstColumn), and so are the cells' padding, borders and row
   hover. This page keeps the matrix's own marks: the column and row-head widths, the band's colour
   mark, the goal names and their counts, each Group's identity and coverage meter, and the tiles.
   The kit's header cells are upper case on one line: the names under them are not. */
.csc-config { position: relative; }

.csc-band { vertical-align: middle; }
.csc-band span {
    display: inline-flex; align-items: center; gap: var(--space-2);
    font-size: var(--text-xs); font-weight: var(--font-bold);
    text-transform: uppercase; letter-spacing: var(--tracking-wide);
}
.csc-band span::before { content: ""; width: 10px; height: 10px; border-radius: var(--radius-sm); border: 1.5px solid; }
.csc-band--goal span { color: var(--cascade-goal-mark); }
.csc-band--goal span::before { background: var(--cascade-goal-fill); border-color: var(--cascade-goal-accent); }

.csc-src { width: var(--csc-col-w); min-width: var(--csc-col-w); max-width: 132px; vertical-align: bottom; }
.csc-src-name {
    display: block; font-size: var(--text-sm); font-weight: var(--font-semibold);
    color: var(--color-neutral-800); line-height: var(--leading-snug); text-wrap: pretty;
    text-transform: none; letter-spacing: normal; white-space: normal;
}
.csc-src-count {
    display: block; margin-top: var(--space-2);
    font-family: var(--font-mono); font-size: var(--text-2xs); font-weight: var(--font-normal);
    text-transform: none; color: var(--color-neutral-600);
}

/* Why a strategic goal's column cannot be ticked (the cultural chain rule, Feature GW). */
.csc-src-note {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.4;
    color: var(--color-neutral-700);
    white-space: normal;
}

.csc-corner { width: var(--csc-rowhead-w); min-width: var(--csc-rowhead-w); vertical-align: bottom; }
.csc-corner span { font-size: var(--text-xs); font-weight: var(--font-bold); text-transform: uppercase; letter-spacing: var(--tracking-wide); color: var(--color-neutral-600); }

/* Row head: the Group's identity and its coverage meter (the kit keeps it in view). */
.csc-rowhead { width: var(--csc-rowhead-w); min-width: var(--csc-rowhead-w); vertical-align: middle; }
.csc-grp { display: flex; flex-direction: column; gap: 1px; }
.csc-grp-name { font-size: var(--text-base); font-weight: var(--font-semibold); color: var(--color-neutral-900); }
.csc-grp-meta { font-size: var(--text-xs); font-weight: var(--font-normal); color: var(--color-neutral-600); }
.csc-cov { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
.csc-cov-bar { flex: 1; height: 5px; border-radius: var(--radius-pill); background: var(--color-neutral-100); overflow: hidden; }
.csc-cov-fill { display: block; height: 100%; border-radius: var(--radius-pill); background: var(--color-neutral-400); }
.csc-cov-num { font-family: var(--font-mono); font-size: var(--text-2xs); font-weight: var(--font-normal); color: var(--color-neutral-600); min-width: 26px; text-align: right; }

/* Flagged row: a Group that inherits nothing (gentle, not alarming). Its words say it; colour says the side, never a
   status (rule 9, C12), so the row carries no warning bar, rule or meter fill. */
.csc-rowhead.is-flag .csc-flag {
    display: inline-flex; align-items: center; gap: 4px; margin-top: 3px;
    font-size: var(--text-xs); font-weight: var(--font-medium); color: var(--cascade-flag);
}
.csc-rowhead.is-flag .csc-flag svg { width: 12px; height: 12px; }
.csc-rowhead.is-flag .csc-cov-num { color: var(--cascade-flag); }
.csc-flag { display: none; }

/* Cells: the coverage tile, centred, a column rule between goals. */
.csc-cell { text-align: center; vertical-align: middle; border-left: 1px solid var(--color-border-light); }

.csc-tilelabel {
    display: grid; place-items: center;
    width: 100%; min-height: 42px; cursor: pointer;
}
.csc-tin { position: absolute; width: 1px; height: 1px; opacity: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); }
.csc-tile {
    width: var(--csc-tile); height: var(--csc-tile);
    display: grid; place-items: center;
    border-radius: var(--radius-sm); border: 1.5px solid var(--cascade-grid-line);
    background: var(--cascade-cell-empty);
    transition: background var(--duration-fast), border-color var(--duration-fast), transform var(--duration-fast) var(--ease-spring);
}
.csc-tile::before {
    content: ""; width: 13px; height: 13px; transform: scale(0);
    background: currentColor;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);
    transition: transform var(--duration-fast) var(--ease-spring);
}
.csc-tilelabel:hover .csc-tile { transform: scale(1.08); }
/* empty-tile hover preview — hints which band the cell belongs to */
.csc-cell--goal  .csc-tilelabel:hover .csc-tin:not(:checked) + .csc-tile { border-color: var(--cascade-goal-accent);  background: var(--color-neutral-100); }
/* inherited (checked) — fills with the band hue */
.csc-cell--goal  .csc-tin:checked + .csc-tile { background: var(--cascade-goal-fill);  border-color: var(--cascade-goal-accent);  color: var(--cascade-goal-mark); }
.csc-tin:checked + .csc-tile::before { transform: scale(1); }
.csc-tin:focus-visible + .csc-tile { outline: none; box-shadow: var(--shadow-focus); }
.csc-tin:disabled + .csc-tile { cursor: default; opacity: .55; }

/* ── Save bar (#443) — sticky, always reachable below a tall grid ─────────────
   Disabled/dirty/saved are Blazor-driven: the button binds disabled, the hint is
   rendered with @if, and the kit <Banner> renders above the bar via @if. No CSS
   state shim, no .shui-banner mirror. */
/* The save bar follows the grid, never floats over it (Feature GS, #1364, need 13: the last row sat under it); the grid
   itself is at most the kit's fixed-header height, so Save is never far below it. */
.csc-savebar {
    display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap;
    margin-top: var(--space-4); padding: var(--space-4) var(--space-5);
    border: 1px solid var(--color-border); border-radius: var(--radius-lg);
    background: var(--color-surface-frosted); backdrop-filter: blur(8px);
    box-shadow: var(--shadow-md);
}
.csc-dirtyhint { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-neutral-600); }
/* The hint's words say the state; the dot is neutral (rule 9: a status is words or a badge, never a colour). */
.csc-dirtydot { width: 8px; height: 8px; border-radius: var(--radius-full); background: var(--color-neutral-500); }
.csc-savebar-end { margin-left: auto; }
.csc-save-message { margin-top: var(--space-4); }
.csc-held-list { margin: 0; padding-left: var(--space-5); }

/* Responsive — tighten the grid geometry on narrow viewports. */
@media (max-width: 860px) {
    .csc-config { --csc-rowhead-w: 168px; --csc-col-w: 84px; --csc-tile: 28px; }
    .csc-legend { margin-left: 0; width: 100%; }
}
/* A phone (need 11): the group column narrows so the goal columns are in view beside it. */
@media (max-width: 539.98px) {
    .csc-config { --csc-rowhead-w: 124px; --csc-col-w: 72px; }
    .csc-cov { display: none; }
}

/* ── Group rows (the nested structure, G4b T3): CSS-only indentation per depth ──────────── */
/* Tree indent is inline per row (depth * 1.25rem) - a layout value, not a theme token. */
.grp-row { display: flex; align-items: center; gap: 0.5rem; }

/* The add at the foot of the groups (Lane P5, #1226): a btn-outline with the plus icon, under the grid. */
.grp-add-act { margin-top: var(--space-3); }

/* ── Group Membership Panel ────────────────────────────────────────────────── */
.membership-panel-cell { padding: 0 !important; }
/* The panel is a sunken kit Card; its lists are kit ItemLists (their rows the kit's own). */
.grp-membership-inactive { margin-top: var(--space-4); }
/* F4 (#964): the one membership act is a move - a labelled field with its help, its act beside the select. */
.grp-membership-add { margin-top: var(--space-4); max-width: 560px; }
.grp-move-line { display: flex; align-items: center; gap: var(--space-2); }
.grp-move-line > select { flex: 1; min-width: 0; }
