/*
 * pinned-items.css — the Pinned section, as its own component
 *
 * Promoted from css/apps/chat-pinned.css when the pinned feature stopped being
 * Chat's. Named for the COMPONENT, not for the sidebar (D-12): the surface it
 * mounts on is not part of its identity, and a later card mounts it somewhere
 * with no Recent list in sight.
 *
 * Loaded by the component itself (controls/pinned-items/index.js) and linked
 * statically in index.html, so it is present however the section is reached.
 * Tokens come from shell.css, typography.css and controls/spaces-tree.css —
 * all three statically linked, all three defining on :root. Never core.css,
 * which index.html does not link (see .claude/rules/ui-design-scope.md).
 *
 * Not promoted: Chat's scroll-fade suppression rule
 * (.sidebar-chat-list.is-scrolled.chat-sb-has-pinned). It changes an existing
 * Chat behaviour by specificity and names Chat's own list class, so it belongs
 * with Chat. Phase 4a relocates it when chat-pinned.css is deleted.
 */

/* ── The section ──────────────────────────────────────
   Sits above whatever the host drew and STAYS at the top while the rest scrolls
   under it, separated by a rule so pinned rows read as their own place rather
   than as the host's first group. */
.lp-pinned {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 4px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);

    /* THE FILL IS THE SIDEBAR'S OWN, and it is opaque on purpose: this section
       is sticky, so rows scroll UNDER it, and a transparent one would have them
       showing through. "Same background as the list" therefore means painting
       what the list paints, not painting nothing.

       It used to be --bg-panel, on the strength of a Chat-only
       `.sidebar:has(.chat-sb-newchat-slot)` override that repainted that one
       sidebar. That rule is GONE — the shared frame (controls/sidebar-layout.css)
       took over painting and declares --sidebar-bg, and .sidebar in shell.css
       declares the same token so the two cannot disagree. So the reason for the
       difference outlived the difference: the section kept the panel fill and
       read as a tinted band above a sidebar that had moved to another colour.

       Reading the token the surface under it reads is what keeps them equal
       through a skin, where two literals or two tokens would drift apart again.
       The --lp-pinned-bg hook is gone with it: it existed for a host divergence
       that no longer exists, nothing ever set it, and leaving it would invite
       the divergence back. */
    background: var(--sidebar-bg);
}

/* ── The header ───────────────────────────────────────
   The same caption role every sidebar section header in this Shell uses. The
   three tokens are defined once on :root in controls/spaces-tree.css precisely
   so Chat's and Chaos's headers cannot disagree about it; this is a third
   consumer, not a third copy. */
.lp-pinned-header {
    display: flex;
    align-items: center;
    /* THE SAME TOKENS THE HEADING AND THE ROWS READ. The left indent was a
       literal 12px that happened to equal --lp-sidebar-caption-indent, and the
       gap a 6px that matched nothing — so the glyph-to-word spacing read
       differently from every icon-to-name below it. Equal by construction now
       rather than by coincidence, which is the difference that survives a
       skin retinting or respacing the sidebar. */
    gap: var(--lp-sidebar-row-gap, 7px);
    padding: 8px var(--lp-sidebar-edge-pad, 7px) 2px var(--lp-sidebar-caption-indent, 12px);
    cursor: pointer;
    user-select: none;
    font-size: var(--lp-sidebar-caption-size);
    font-weight: var(--lp-sidebar-caption-weight);
    letter-spacing: var(--lp-sidebar-caption-tracking);
    text-transform: uppercase;
    color: var(--text-muted);
}
.lp-pinned-header:hover { color: var(--text-secondary); }
.lp-pinned-header:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.lp-pinned-chevron,
.lp-pinned-glyph {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}
/* Glyph geometry, not a reading size: these set the drawn size of an icon, so
   they stay literal by the typography rule's own carve-out. */
.lp-pinned-chevron svg,
.lp-pinned-glyph svg { width: 14px; height: 14px; }

.lp-pinned-title { flex: 1 1 auto; }

/* Tabular so the count does not shift the header as it changes. */
.lp-pinned-count {
    margin-left: auto;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

/* ── The body and list ───────────────────────────────
   A long pinned list must never swallow the panel — cap it and let the section
   scroll internally, so the host's own list is always reachable below it. */
.lp-pinned-body { display: flex; flex-direction: column; }
.lp-pinned-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 40vh;
    overflow-y: auto;
}
.lp-pinned-list::-webkit-scrollbar { width: 6px; }
.lp-pinned-list::-webkit-scrollbar-track { background: transparent; }
.lp-pinned-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* The component's own row wrapper. It carries data-pin-id and nothing visual of
   its own — the host's row inside it keeps whatever the host gives it, so a
   pinned row looks exactly like the same row elsewhere in that app. */
.lp-pinned-row { position: relative; display: block; }

/* ── Drag-to-reorder ─────────────────────────────────
   The insertion line shows exactly where the row will land; the dragged row
   dims so the line reads as its destination rather than its current place. */
.lp-pinned-row.dragging { opacity: 0.4; }
.lp-pinned-row.drop-before::before,
.lp-pinned-row.drop-after::after {
    content: '';
    position: absolute;
    left: 8px;
    right: 8px;
    height: 2px;
    border-radius: 1px;
    background: var(--accent);
    pointer-events: none;
}
.lp-pinned-row.drop-before::before { top: -2px; }
.lp-pinned-row.drop-after::after { bottom: -2px; }
