/* T487 (doc 57/65): the docked-agents column REBUILT as a genuine grid
   participant — the operator's structural rejection of the T483 visual-only
   pass ("must PUSH EVERYTHING — including the header/topbar and navigation
   ... the whole shell shifts to make room; the dock never overlays").

   Root cause: #agent-dock-rail was `position:fixed`, floating over the
   viewport's right edge from --agent-dock-top (below the topbar) down to
   the bottom — it never participated in the body grid, so only .tab-panel
   (via a margin-right approximation) ever made room for it; the topbar and
   the .tab-bar sidebar never moved, and the rail never spanned the full
   viewport height (it started below the topbar, not at the top of the
   screen).

   The prototype's own model (mf.css: `.shell { display:grid;
   grid-template-columns: 232px 1fr }`, `.dock-col` appended to `.shell` as
   a THIRD grid child, `body.dock-open .shell { grid-template-columns: 232px
   minmax(0,1fr) var(--dock-w,400px) }`) makes the dock a true sibling grid
   track beside the rail: full height because the whole shell's single row
   stretches to it, pushing because the columns genuinely resize.

   This board's own desktop shell (chrome-visual.css, `@media (min-width:
   821px)`, shipped 17 Aug as the shell restructure) already matches that
   same rail+content model: `grid-template-areas: "navigation topbar"
   "navigation workspace"` — .tab-bar spans both rows exactly like the
   prototype's full-height .rail; .topbar lives only inside the content
   column, exactly like the prototype's .topline living inside .main. This
   file extends that SAME grid with a third "dock" track/area that also
   spans both rows, so the rail sits genuinely full height — flush with the
   top of the topbar and the bottom of the workspace — beside the pushed
   shell, never over it.

   Desktop only (>=821px): matches this board's own established phone/
   desktop split rather than the prototype's separate 980px literal — the
   same call T484 made for the launch drawer, for shell-wide breakpoint
   consistency (one "is this narrow" answer for topbar/nav/dock/launch,
   not two). Below 821px, multi-dock-phone.css's existing sheet (position:
   fixed, full-viewport-width overlay) is untouched, matching the
   prototype's own <980px .dock-col override in spirit.

   JS supplies --agent-pane-width (multi-dock.js updateShell())
   already tracks the real, resizable, persisted rail width live, reading
   the sidebar's actual rendered width via getBoundingClientRect() — this
   file only lets the grid track and the rail element consume that same
   variable instead of a fixed-position + margin-right approximation. */
@media (min-width: 821px) {
  /* Logical close is immediate; the visual slide may finish afterwards without
     intercepting a rapid follow-up click on the topbar action beneath it. */
  #agent-dock:not(.open) {
    pointer-events: none;
  }

  body.multi-dock-open:not(.standalone):not(.multi-agent-workspace) {
    /* OAS6: the navigation column retired with the sidebar — topbar and
       workspace span the full width beside the dock track. */
    grid-template-areas:
      "topbar dock"
      "workspace dock";
    grid-template-columns:
      minmax(0, 1fr) var(--agent-pane-width, 480px);
    /* AR32 (doc 65 round 5): the launch column now opens into this SAME
       "dock" track instead of sliding in as a position:fixed overlay
       (multi-dock.css) — this transition is what makes that push (and a
       real session's own dock/undock) animate instead of jumping.
       multi-dock.js seeds --agent-pane-width at 0px one frame before
       the real value when the rail was fully closed (MultiDockLaunchMotion,
       multi-dock-launch-motion.js) so there is always a "from" to animate;
       widening/narrowing alongside an already-open rail needs no seed, a
       plain var write between two style flushes transitions on its own. */
    transition: grid-template-columns 200ms ease;
  }

  /* OAS6: nav-collapsed retired with the sidebar; the base track rule
     above is the only docked layout. */

  /* Opening and closing the dock still animate, but a grabbed resize handle
     must map directly to the pointer. Retargeting the 200ms grid transition on
     every pointermove made the rendered track chase the requested width. */
  body.multi-dock-open.dock-region-resizing:not(.standalone):not(.multi-agent-workspace),
  body.multi-dock-open.agents-rail-initializing:not(.standalone):not(.multi-agent-workspace),
  body.multi-dock-open.nav-collapsed.dock-region-resizing:not(.standalone):not(.multi-agent-workspace) {
    transition: none;
  }

  @media (prefers-reduced-motion: reduce) {
    body.multi-dock-open:not(.standalone):not(.multi-agent-workspace),
    body.multi-dock-open.nav-collapsed:not(.standalone):not(.multi-agent-workspace) {
      transition: none;
    }
  }

  /* The rail becomes a real grid item filling the "dock" area (both grid
     rows, so it is flush with the top of the topbar row and the bottom of
     the workspace row — literal full height) instead of a fixed overlay
     that started below the topbar. */
  body.multi-dock-open:not(.standalone):not(.multi-agent-workspace) #agent-dock-rail {
    position: relative;
    grid-area: dock;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    width: 100%;
    min-width: 0;
    min-height: 0;
    max-height: none;
    height: 100%;
    box-shadow: none;
  }

  /* UIQ T2-R2: the Agents list consumes the dock's actual grid area and
     width variable. This replaces its old fixed pane plus page-padding /
     topbar-margin compensation, so every shell child shifts together. */
  body.multi-dock-open.agents-rail-present:not(.standalone):not(.multi-agent-workspace)
    #agents-rail:not(.is-yielded) {
    position: relative;
    grid-area: dock;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    width: 100%;
    min-width: 0;
    min-height: 0;
    max-height: none;
    height: 100%;
    box-shadow: none;
  }

  /* The old margin-right approximation is now redundant for this branch —
     the workspace grid track already shrank for real. Keeping both would
     shrink it twice. (multi-dock-phone.css's own margin-right:0 already
     covers the <821px sheet, which never enters this branch.) */
  body.multi-dock-open:not(.standalone):not(.multi-agent-workspace) .tab-panel {
    margin-right: 0;
  }

  /* The +Agent picker (#agent-dock, reused here as a slide-over) used to
     make room for itself by right-shifting and shrinking the old
     position:fixed rail (`right: min(...)`, multi-dock.css). A relatively
     positioned grid item cannot be right-shifted that way without visibly
     drifting off its track, so it now simply overlays the rail's own
     right edge while the picker is open — a transient, self-closing
     state — and needs to out-stack the rail explicitly rather than rely
     on DOM order (the rail is later in the DOM and would otherwise paint
     over the picker at equal z-index). */
  body.multi-dock-picker-open:not(.standalone):not(.multi-agent-workspace) #agent-dock-rail {
    right: auto;
    width: 100%;
  }
  body.multi-dock-picker-open:not(.multi-agent-workspace) #agent-dock.open {
    z-index: 19;
  }

  /* Doc 65 round 3 (operator): the picker "was never redesigned" — its
     geometry never followed T487's shell rebuild. It was still the
     PRE-rebuild overlay model: `top: var(--agent-dock-top)` (77px, below
     the topbar — literally "stops short" of the viewport top) and a fixed
     `width: var(--agent-dock-width)` (20rem) that never matched the real,
     resizable docked-column width it visually replaces. Root cause: this
     is the SAME class of bug T487 fixed for #agent-dock-rail itself
     (position:fixed + a below-topbar top offset instead of a real
     full-height participant) — #agent-dock was simply never carried along
     in that pass since it is a transient overlay, not a grid track. Fix,
     scoped to exactly the state where it visually replaces the rail
     (matching the block above): true full height (top:0, matching the
     launch drawer's own `.agent-launch-column { top:0 }` — T484) and a
     width that reads the SAME live variable the rail's own grid track
     reads (--agent-pane-width, multi-dock.js updateShell() keeps it
     current), so the picker is byte-identical in width to the column it
     is standing in for, not an approximation.

     AR-round6 (doc 65, operator item 2): broadened from
     `multi-dock-picker-open` (only true with a session ALSO docked) to
     `multi-dock-open` — multi-dock.js's auxiliary state now also sets
     multi-dock-open when the list is the SOLE occupant (nothing docked),
     so this same geometry rule covers that third-occupant case too, not
     just "list replacing an already-docked rail". Every prior match of
     multi-dock-picker-open already implied multi-dock-open (a session was
     docked), so this is additive, not a behavior change for that case. */
  body.multi-dock-open:not(.standalone):not(.multi-agent-workspace) #agent-dock.open {
    top: 0;
    bottom: 0;
    max-height: none;
    width: var(--agent-pane-width, 480px);
    min-width: 0;
  }

  /* Full view must hide the shell chrome in every state. When a dock is open, only
     the dock remains outside the overlay; the old conditional left the navigation rail
     and topbar visible because it treated full view as merely "content area" view. */
  body.multi-dock-open:not(.standalone):not(.multi-agent-workspace)
    #files-tab .fn-files-layout.fn-fullview .fn-preview-col {
    left: 0;
    top: 0;
    right: var(--agent-pane-width, 480px);
    width: auto;
    height: auto;
  }

  /* Coordinator addendum to item 1: full view's own #fn-fullview-agents button (files-new/
     tabs.js) exists so the operator can dock an agent while the topbar is unreachable (no dock
     open yet, full view still covers the whole viewport). Once a dock track IS open the block
     above leaves only the right-hand dock outside the document overlay, so the in-toolbar
     duplicate hides rather than showing two "Agents" controls doing the same thing. */
  body.multi-dock-open:not(.agents-rail-present):not(.standalone):not(.multi-agent-workspace)
    #fn-fullview-agents,
  body.agents-rail-open:not(.standalone):not(.multi-agent-workspace)
    #fn-fullview-agents {
    display: none;
  }
}
