/* ==========================================================================
   Swim Page - Horizontal Lane View
   ========================================================================== */

/* Override body max-width so swim lanes can use full viewport */
body:has(.swim-page) {
  max-width: none;
  overflow-x: auto;
}

.swim-page {
  padding: 0.75rem var(--space-3) var(--space-5);
}

/* ==========================================================================
   Settings Panel
   ========================================================================== */

.swim-settings-panel {
  margin-bottom: var(--space-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-muted);
}

.swim-settings-toggle {
  display: block;
  width: 100%;
  padding: var(--space-2) 0.75rem;
  border: none;
  background: none;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
  color: var(--fg-dim);
  cursor: pointer;
  text-align: left;
  transition: color 0.15s;
}

.swim-settings-toggle:hover {
  color: var(--fg);
}

.swim-settings-body {
  padding: 0 0.75rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem var(--space-4);
}

.swim-settings-body.hidden {
  display: none;
}

.swim-setting {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.swim-setting-label {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 11px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.swim-setting-select {
  padding: var(--space-1) var(--space-2);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
}

.swim-setting-range {
  width: 100px;
  cursor: pointer;
}

.swim-setting-checkbox {
  cursor: pointer;
}

.swim-max-lanes-value {
  font-weight: 600;
  color: var(--fg);
  min-width: 1.2em;
  display: inline-block;
}

/* ==========================================================================
   Lanes Container
   ========================================================================== */

.swim-container {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--space-2);
  cursor: grab;
}

.swim-container:active {
  cursor: grabbing;
}

.swim-lanes {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: min-content;
  /* Small breathing room at the very top. The headroom that group decoration
     labels need (~20px above the topmost card, see drawGroupDecorations in
     swim.js) is reserved per-lane on .swim-lane-items below — a single
     container padding only protected the first lane, leaving every other
     lane's group label to bleed up into the lane above it (LIN-303). */
  padding-top: 4px;
}

.swim-lane {
  display: flex;
  align-items: stretch;
  min-height: 52px;
  position: relative;
  z-index: var(--z-base);
}

.swim-lane-label {
  flex-shrink: 0;
  width: 130px;
  padding: 0.4rem 0.6rem;
  font-family: var(--font-content);
  font-size: 11px;
  color: var(--fg-dim);
  border-right: 2px solid var(--border);
  display: flex;
  align-items: center;
  word-break: break-word;
  background: var(--bg-muted);
  border-radius: 4px 0 0 4px;
}

.swim-lane-items {
  display: flex;
  align-items: center;
  gap: 8px;
  /* Top padding reserves per-lane headroom for group decoration labels drawn
     ~18px above the topmost card (see drawGroupDecorations in swim.js). Without
     it, a group whose parent sits below the first lane has its label and rect
     spill upward into the lane above (LIN-303). The extra margin over the label
     offset keeps the label clear of the lane above even with tall (wrapped)
     cards on mobile. Mirrors the per-lane headroom in vertical mode. */
  padding: 26px 0.5rem 0.35rem;
  flex-wrap: nowrap;
  min-width: 0;
}

/* Segment containers for global alignment */
.swim-lane-segment {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: nowrap;
  padding-right: var(--space-4);
  border-right: none;
  margin-right: var(--space-2);
}

.swim-lane-segment:last-child {
  border-right: none;
  padding-right: 0;
  margin-right: 0;
}



/* ==========================================================================
   Task Boxes
   ========================================================================== */

.swim-box {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.2rem 0.35rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  cursor: pointer;
  max-width: 200px;
  overflow: hidden;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  font-family: var(--font-structural);
  font-size: 12px;
}

.swim-box:hover {
  background: var(--bg-muted);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

/* Status accent — left border */
.swim-box.state-started { border-left: 3px solid var(--yellow); }
.swim-box.state-completed { border-left: 3px solid var(--green); }
.swim-box.state-canceled { border-left: 3px solid var(--green); }
.swim-box.state-unstarted { border-left: 3px solid var(--fg-mid); }
.swim-box.state-backlog { border-left: 3px solid var(--border); }

/* State indicator in box — colors come from the canonical
   .status-pill--<state> modifiers (public/style.css), mirroring ship.js. */
.swim-box-state {
  flex-shrink: 0;
  font-size: 13px;
}

.swim-box-title {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--fg);
  font-family: var(--font-content);
  font-size: 12px;
}

.swim-box-id {
  width: 100%;
  text-align: right;
  color: var(--fg-dim);
  font-family: var(--font-structural);
  font-size: 9px;
  flex-shrink: 0;
}

/* Blocked accent — overrides status border */
.swim-box.blocked {
  border-left: 3px solid var(--amber);
}

.swim-box-blocked-label {
  width: 100%;
  font-size: 9px;
  color: var(--amber);
  opacity: 0.8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Column slot containers for cross-lane alignment */
.swim-column-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-height: 32px;
}

.swim-column-slot:empty {
  /* Empty slots keep their min-width for gap alignment */
}

/* Compact mode */
.swim-box.compact {
  padding: var(--space-1) 0.4rem;
  max-width: 120px;
  gap: var(--space-1);
}

.swim-box.compact .swim-box-title {
  display: none;
}

.swim-box.compact .swim-box-id {
  width: auto;
  text-align: left;
  font-size: 11px;
  color: var(--fg);
}

/* ==========================================================================
   Subtask Groups (post-layout SVG decoration)

   Groups are drawn as a shaded rect behind parent+child cards. The SVG layer
   sits beneath connectors and cards so it doesn't interfere with clicks or
   line routing. Works in both column-slot and packed rendering paths.
   ========================================================================== */

.swim-group-decorations {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}

.swim-group-rect {
  fill: color-mix(in srgb, var(--blue) 5%, transparent);
  stroke: color-mix(in srgb, var(--blue) 35%, transparent);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}

/* Nested groups: a touch more fill + solid border so the layering reads as
   "inside" rather than "another box beside". */
.swim-group-rect.nested {
  fill: color-mix(in srgb, var(--blue) 8%, transparent);
  stroke: color-mix(in srgb, var(--blue) 45%, transparent);
  stroke-dasharray: none;
}

/* Opaque pill behind each label so the dashed border never strikes through
   the text (keeps the title readable). */
.swim-group-label-bg {
  fill: var(--bg);
}

.swim-group-label-bg.nested {
  fill: var(--card);
}

.swim-group-label-text {
  font-family: var(--font-structural);
  font-size: 9px;
  fill: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

/* Slight emphasis for the parent card within a group */
.swim-box[data-group-role="parent"] {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--blue) 25%, transparent);
}

/* ==========================================================================
   Popover
   ========================================================================== */

.swim-popover {
  position: fixed;
  z-index: var(--z-sticky);
  width: 320px;
  max-width: 90vw;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

.swim-popover.hidden {
  display: none;
}

.swim-popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

.swim-popover-id {
  font-size: 11px;
  color: var(--fg-dim);
  text-decoration: none;
}

.swim-popover-id:hover {
  color: var(--fg);
  text-decoration: underline;
}

.swim-popover-close {
  border: none;
  background: none;
  font-size: 18px;
  color: var(--fg-dim);
  cursor: pointer;
  padding: 0 var(--space-1);
  line-height: 1;
}

.swim-popover-close:hover {
  color: var(--fg);
}

.swim-popover-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: var(--space-2);
  word-break: break-word;
}

.swim-popover-meta {
  font-size: 11px;
  color: var(--fg-dim);
  margin-bottom: var(--space-2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) 0.75rem;
}

.swim-popover-desc {
  font-size: 13px;
  color: var(--fg);
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  margin-bottom: var(--space-2);
  word-break: break-word;
}

.swim-popover-link {
  font-size: 11px;
  color: var(--fg-dim);
  text-decoration: none;
  transition: color 0.15s;
}

.swim-popover-link:hover {
  color: var(--blue);
}

/* ==========================================================================
   SVG Connector Lines
   ========================================================================== */

.swim-connectors {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 2;
}

.swim-connector-path {
  fill: none;
  stroke: var(--amber);
  stroke-width: 2;
  stroke-dasharray: 5 3;
  opacity: 0.65;
}

/* Sequential (non-blocking) connectors — grey, subtler */
.swim-sequential-path {
  stroke: var(--fg-mid);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  opacity: 0.4;
}

/* ==========================================================================
   Chain Highlighting (hover)
   ========================================================================== */

/* When chain is active, dim everything that isn't in the chain */
.swim-lanes.swim-chain-active .swim-box {
  opacity: 0.35;
  transition: opacity 0.15s;
}

.swim-lanes.swim-chain-active .swim-connector-path {
  opacity: 0.08;
}

/* Chain nodes stay fully visible with a subtle highlight */
.swim-lanes.swim-chain-active .swim-box.swim-chain-node {
  opacity: 1;
  box-shadow: 0 0 0 2px var(--amber);
}

/* Chain links stay fully visible and get bolder */
.swim-lanes.swim-chain-active .swim-connector-path.swim-chain-link {
  opacity: 0.85;
  stroke-width: 2.5;
}

/* Sequential chain links — visible but lighter than blocking */
.swim-lanes.swim-chain-active .swim-sequential-path.swim-chain-link {
  opacity: 0.55;
  stroke-width: 2;
}

/* ==========================================================================
   Label Filter — Goal Markers
   ========================================================================== */

.swim-box.swim-goal {
  box-shadow: 0 0 0 2px var(--blue);
  border-color: var(--blue);
}

/* ==========================================================================
   Critical Path Filter
   ========================================================================== */

.swim-cp-hidden {
  display: none !important;
}

.swim-cp-hidden-lane {
  display: none !important;
}

.swim-cp-hidden-segment {
  display: none !important;
}

/* Target task gets a distinct highlight */
.swim-cp-active .swim-box.swim-cp-target {
  box-shadow: 0 0 0 2px var(--blue);
  border-color: var(--blue);
}

/* Clear filter pill */
.swim-cp-clear-pill {
  display: inline-block;
  margin-bottom: var(--space-2);
  padding: 0.3rem 0.75rem;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 11px;
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--blue) 30%, transparent);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.swim-cp-clear-pill:hover {
  background: color-mix(in srgb, var(--blue) 18%, transparent);
  color: var(--blue);
}

/* Popover critical path button */
.swim-popover-critical-path {
  display: block;
  margin-top: var(--space-2);
  padding: 0.3rem 0;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 11px;
  color: var(--blue);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s;
}

.swim-popover-critical-path:hover {
  color: var(--blue);
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.swim-empty {
  text-align: center;
  color: var(--fg-dim);
  padding: 3rem var(--space-3);
  font-style: italic;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 13px;
}

/* ==========================================================================
   Responsive - Desktop
   ========================================================================== */

@media (min-width: 641px) {
  .swim-page {
    padding: var(--space-3) var(--space-5) 3rem;
  }

  .swim-lane-label {
    width: 160px;
    font-size: 12px;
  }
}

/* ==========================================================================
   Vertical Orientation

   Mirror of the horizontal layout: lanes become columns laid out left-to-right,
   items within a lane stack top-to-bottom, labels sit on top of each lane.
   The swim algorithm is unchanged — only the visual axes are swapped.
   ========================================================================== */

.swim-page[data-orientation="vertical"] .swim-container {
  overflow-x: auto;
  overflow-y: auto;
  /* Re-derive the viewport-minus-chrome cap from real chrome instead of the
     stale pre-S2 `140px` literal (LIN-1226). The old constant was exactly
     nav 6rem + page top padding 0.75rem + page bottom --space-5 (96+12+32=140);
     routing the nav portion through --nav-sticky-h keeps desktop identical while
     tracking the S2 two-row nav's ≤640px bump (7.75rem) the frozen literal missed. */
  max-height: calc(100vh - var(--nav-sticky-h) - 0.75rem - var(--space-5));
}

/* .swim-lanes padding-top is for horizontal mode (first row's group label
   escaping above). In vertical mode, every lane starts below its own lane
   label, so the headroom belongs on .swim-lane-items instead. */
.swim-page[data-orientation="vertical"] .swim-lanes {
  padding-top: 0;
}

.swim-page[data-orientation="vertical"] .swim-lanes {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
}

.swim-page[data-orientation="vertical"] .swim-lane {
  flex-direction: column;
  align-items: stretch;
  min-height: 0;
  width: 160px;
  flex-shrink: 0;
}

.swim-page[data-orientation="vertical"] .swim-lane-label {
  width: auto;
  padding: 0.35rem var(--space-2);
  font-size: 10px;
  line-height: 1.3;
  border-right: none;
  border-bottom: 2px solid var(--border);
  border-radius: 4px 4px 0 0;
  justify-content: center;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.swim-page[data-orientation="vertical"] .swim-lane-items {
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  /* Top padding reserves headroom for group decoration labels drawn ~18px above
     the topmost card. Without it, the group label would overlap the lane-label
     directly above. */
  padding: 26px 0.35rem 0.4rem;
}

.swim-page[data-orientation="vertical"] .swim-lane-segment {
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  padding-right: 0;
  margin-right: 0;
  padding-bottom: 0.75rem;
  margin-bottom: var(--space-1);
}

.swim-page[data-orientation="vertical"] .swim-lane-segment:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
}

.swim-page[data-orientation="vertical"] .swim-column-slot {
  min-height: 28px;
  flex-direction: row;
  justify-content: center;
}

/* Tight cards: fill the lane, compact padding, 3-line title clamp */
.swim-page[data-orientation="vertical"] .swim-box {
  max-width: none;
  width: 100%;
  box-sizing: border-box;
  padding: 0.3rem 0.45rem;
  gap: 0.15rem 0.3rem;
  border-left: 1px solid var(--border);
}

.swim-page[data-orientation="vertical"] .swim-box-title {
  -webkit-line-clamp: 3;
  line-height: 1.3;
  font-size: 11px;
}

.swim-page[data-orientation="vertical"] .swim-box-id {
  font-size: 9px;
}

/* Status accent — top border instead of left border in vertical mode */
.swim-page[data-orientation="vertical"] .swim-box.state-started { border-left: 1px solid var(--border); border-top: 3px solid var(--yellow); }
.swim-page[data-orientation="vertical"] .swim-box.state-completed { border-left: 1px solid var(--border); border-top: 3px solid var(--green); }
.swim-page[data-orientation="vertical"] .swim-box.state-canceled { border-left: 1px solid var(--border); border-top: 3px solid var(--green); }
.swim-page[data-orientation="vertical"] .swim-box.state-unstarted { border-left: 1px solid var(--border); border-top: 3px solid var(--fg-mid); }
.swim-page[data-orientation="vertical"] .swim-box.state-backlog { border-left: 1px solid var(--border); border-top: 3px solid var(--border); }
.swim-page[data-orientation="vertical"] .swim-box.blocked { border-left: 1px solid var(--border); border-top: 3px solid var(--amber); }

/* Compact mode in vertical: full-width chip, ID only (title hidden by base rule) */
.swim-page[data-orientation="vertical"] .swim-box.compact {
  max-width: none;
  width: 100%;
  padding: 0.2rem 0.4rem;
}

/* Desktop — slightly roomier lanes when there's real estate */
@media (min-width: 1280px) {
  .swim-page[data-orientation="vertical"] .swim-lane {
    width: 170px;
  }
}

/* Tablet / small laptop */
@media (max-width: 900px) {
  .swim-page[data-orientation="vertical"] .swim-lane {
    width: 150px;
  }
}

/* Phone */
@media (max-width: 640px) {
  .swim-page[data-orientation="vertical"] .swim-lane {
    width: 130px;
  }
  .swim-page[data-orientation="vertical"] .swim-lane-items {
    /* Keep the top headroom for group-decoration labels (LIN-303). */
    padding: 26px 0.3rem 0.35rem;
  }
}

/* Small phone */
@media (max-width: 400px) {
  .swim-page[data-orientation="vertical"] .swim-lane {
    width: 114px;
  }
  .swim-page[data-orientation="vertical"] .swim-box {
    padding: var(--space-1) 0.35rem;
  }
  .swim-page[data-orientation="vertical"] .swim-box-title {
    font-size: 10px;
    -webkit-line-clamp: 3;
  }
  .swim-page[data-orientation="vertical"] .swim-lane-label {
    font-size: 9px;
    padding: 0.3rem 0.4rem;
  }
}

/* ==========================================================================
   Responsive - Small Phones
   ========================================================================== */

@media (max-width: 400px) {
  .swim-page {
    padding: var(--space-2) var(--space-2) var(--space-4);
  }

  .swim-lane-label {
    width: 80px;
    font-size: 10px;
    padding: 0.3rem 0.4rem;
  }

  .swim-box {
    padding: var(--space-1) 0.4rem;
    font-size: 11px;
    max-width: 140px;
  }

  .swim-lane-items {
    gap: 5px;
    /* Keep the top headroom for group-decoration labels (LIN-303); only the
       horizontal padding shrinks on small phones. */
    padding: 26px 0.4rem 0.25rem;
  }

  .swim-settings-body {
    flex-direction: column;
    gap: var(--space-2);
  }
}

/* =============================================================================
   Flow (side-rail) view — vertical stack, nested subtask boxes, orange spines
   ============================================================================= */
.swim-page[data-orientation="flow"] .swim-container { overflow: visible; }

.swim-flow {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 920px;
  margin: 0 auto;
  padding: 12px 60px 48px 4px;
}
.swim-flow-edges { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 3; }
.swim-flow-sep { height: 14px; }

/* state bands (In Progress / Todo / Backlog) — the vertical segments */
.swim-fband { display: flex; flex-direction: column; gap: 8px; }
.swim-fband-label {
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--fg-dim);
  margin: 10px 2px 0;
}
.swim-fband[data-segment="0"] .swim-fband-label { color: var(--amber-dim); }
.swim-fband[data-segment="3"] .swim-fband-label { color: var(--green); }

/* project = a top-level group box */
.swim-fproject { margin: 0; }
.swim-fgroup-label {
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 2px;
}

/* nested subtask "blue boxes" — compose the shared `.surface --inset` contract
   (LIN-977 workstream 4). The bespoke translucent brand-alpha depth ladder was
   theme-broken (a fixed #2563eb tint that did not flip on dark); the group now
   rides `.surface.surface--inset` (opaque, token-driven `--inset`) so nesting
   compounds a dark-safe depth naturally, and keeps only a thin swim-specific
   brand-tinted border for the "blue box" identity (theme-aware via color-mix on
   --blue, which flips). Padding/radius/position stay swim-specific modifiers. */
.swim-fgroup {
  position: relative;
  border: 1px solid color-mix(in srgb, var(--blue) 28%, var(--line));
  border-radius: 9px;
  padding: 10px 9px 11px 11px;
}
.swim-fgroup-kids { display: flex; flex-direction: column; gap: 11px; margin-top: 9px; }

/* cards (full width, one per row) */
.swim-flow .swim-fcard {
  position: relative;
  z-index: var(--z-base);
  display: block;
  max-width: none;
  margin: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--fg-mid);
  border-radius: 7px;
  padding: 11px 13px 12px;
  cursor: pointer;
}
.swim-flow .swim-fcard.state-started { border-top-color: var(--yellow); }
.swim-flow .swim-fcard.state-unstarted { border-top-color: var(--fg-mid); }
.swim-flow .swim-fcard.state-backlog { border-top-color: var(--border); }
.swim-flow .swim-fcard.state-completed,
.swim-flow .swim-fcard.state-canceled { border-top-color: var(--green); }
/* Parent/header card in a group — a token-driven raised tint (was a
   rgba(255,255,255,0.85) white wash that read as a near-white card on dark). */
.swim-flow .swim-fcard-header { background: var(--card); }
.swim-flow .swim-fcard.swim-goal { box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 40%, transparent); }
/* neutralise lane-mode accents that don't fit the flow card */
.swim-flow .swim-fcard.state-started,
.swim-flow .swim-fcard.state-unstarted,
.swim-flow .swim-fcard.state-backlog,
.swim-flow .swim-fcard.state-completed,
.swim-flow .swim-fcard.state-canceled,
.swim-flow .swim-fcard.blocked { border-left: 1px solid var(--border); }

.swim-fc-row { display: flex; align-items: baseline; gap: 7px; flex-wrap: nowrap; }
.swim-flow .swim-box-id {
  width: auto;
  text-align: left;
  font-weight: 700;
  font-size: 11px;
  color: var(--fg);
  white-space: nowrap;
  flex: 0 0 auto;
}
.swim-flow .swim-box-title {
  flex: 1 1 auto;
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  font-size: 13px;
  line-height: 1.35;
}

/* one-or-two line description preview, aligned under the title */
.swim-fc-desc {
  margin-top: 5px;
  padding-left: 22px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--fg-dim);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.swim-fc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 9px;
  margin-top: 8px;
  padding-left: 22px;
  font-size: 11px;
  color: var(--fg-dim);
}
.swim-fc-who { color: var(--slate-dim); }
.swim-fc-prio { font-weight: 700; }
/* Priority hue heat ordering: urgent → red, high → amber, medium → yellow,
   low → muted. All theme-aware tokens (no distinct orange token exists, so
   medium uses yellow to stay distinct from high without colliding with urgent). */
.swim-fc-prio.p1 { color: var(--red-dim); }
.swim-fc-prio.p2 { color: var(--amber-dim); }
.swim-fc-prio.p3 { color: var(--yellow); }
.swim-fc-prio.p4 { color: var(--muted); }
.swim-fc-due { color: var(--slate-dim); }
.swim-fc-lbl { color: var(--slate-dim); background: var(--card); border-radius: var(--radius-sm); padding: 1px 6px; }
.swim-fc-blocked { color: var(--amber-dim); font-weight: 600; }

/* amber dashed blocking spines — token-driven so they stay visible on dark */
.swim-blk-spine { fill: none; stroke: var(--amber); stroke-width: 1.8; stroke-dasharray: 5 3; opacity: 0.95; stroke-linejoin: round; }
.swim-blk-tick { fill: none; stroke: var(--amber); stroke-width: 1.4; stroke-dasharray: 4 3; opacity: 0.85; }
.swim-blk-head { fill: var(--amber); }
.swim-blk-origin { fill: var(--amber); }
/* long-haul edges (would cross an intervening card) are hidden at rest and
   represented by endpoint nubs + a target tag; the full line shows on hover */
.swim-blk-long { opacity: 0; transition: opacity 0.12s; }
.swim-blk-stub { fill: none; stroke: var(--amber); stroke-width: 1.6; stroke-dasharray: 4 3; opacity: 0.5; stroke-linecap: round; }

/* hover-focus: dim spines not in the hovered card's chain */
.swim-flow-edges.swim-edges-dim path,
.swim-flow-edges.swim-edges-dim polygon,
.swim-flow-edges.swim-edges-dim circle { opacity: 0.1; transition: opacity 0.12s; }
.swim-flow-edges.swim-edges-dim .swim-edge-hl { opacity: 1; }
.swim-flow-edges.swim-edges-dim .swim-blk-spine.swim-edge-hl { stroke-width: 2.4; }
/* keep long-haul lines hidden while dimmed unless they are the hovered chain */
.swim-flow-edges.swim-edges-dim .swim-blk-long { opacity: 0; }
.swim-flow-edges.swim-edges-dim .swim-blk-long.swim-edge-hl { opacity: 1; }

/* 2D grid layout: state bands (rows) × project columns */
.swim-page[data-orientation="flow"] .swim-container { overflow-x: auto; }
.swim-flow.swim-grid {
  display: grid;
  position: relative;
  --swim-col-w: 264px;
  column-gap: 30px;
  row-gap: 8px;
  width: max-content;
  max-width: none;
  margin: 0;
  padding: 12px 14px 56px;
  align-items: start;
}
.swim-fcol-head {
  position: sticky;
  top: 0;
  z-index: 6;
  align-self: end;
  padding: 4px 2px 5px;
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--blue);
  background: var(--bg);
}
.swim-grid .swim-fband-label {
  grid-column: 1 / -1;
  margin: 12px 2px 2px;
  border-top: 1px solid var(--fg-vdim);
  padding-top: 8px;
}
.swim-fcell { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.swim-grid .swim-fcard,
.swim-grid .swim-fgroup { width: auto; }

@media (max-width: 640px) {
  .swim-flow.swim-grid { --swim-col-w: 240px; column-gap: 26px; padding: 10px 12px 44px; }
  .swim-fcell { gap: 10px; }
  .swim-fgroup { padding: 8px 8px 9px 9px; border-radius: 8px; }
  .swim-fgroup-kids { gap: 9px; margin-top: 8px; }
}

/* 390px flow-grid reflow (LIN-977 workstream 3). The default flow board is a
   fixed-width, one-column-per-project grid (`grid-template-columns` set inline
   in swim.js) that overflows to ~1000px+ and clips behind a horizontal scroller
   on a phone, with cross-column dependency connectors spanning off-screen. There
   was no responsive strategy for it (the other max-width:400px rules only cover
   the non-default vertical/horizontal orientations). Collapse to a single,
   band-ordered column so the board reads as a state-banded task list; the
   project header row and the now-meaningless connectors are dropped. The author
   `!important` on grid-template-columns is required to beat the inline style. */
@media (max-width: 400px) {
  .swim-flow.swim-grid {
    grid-template-columns: 1fr !important;
    column-gap: 0;
    width: 100%;
    max-width: 100%;
    padding: 10px 2px 40px;
  }
  /* Project column headers are meaningless once every project stacks in one
     column — drop them; the full-width state-band labels carry the grouping. */
  .swim-flow.swim-grid .swim-fcol-head { display: none; }
  /* Empty band×project cells would add dead vertical space when stacked. */
  .swim-flow.swim-grid .swim-fcell:empty { display: none; }
  /* Cross-column dashed dependency connectors span off-screen at this width and
     read as noise; band + depth ordering carries the sequence instead. */
  .swim-page[data-orientation="flow"] .swim-flow-edges { display: none; }
}
