/* ─────────────────────────────────────────────────────────────────────────
   psc_drawers.css — Phase 1.5 click-to-expand drawer rail
   Pills are buttons; clicking expands a body pane below the rail. One
   drawer open at a time. Click again, click ×, or press Escape to close.
   Reference: docs/psc-v2/PSC_Drawers_Spec.md
   Hydration: static/workflow/js/psc_drawers.js
   ───────────────────────────────────────────────────────────────────────── */

/* ── Section + rail ───────────────────────────────────────────────────── */
.psc-drawers-section {
  /* Sits between the PSC body/common-sections and the footer. */
}

.psc-drawers-rail {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #f8f8fa;
  border-top: 1px solid #e2e4e8;
  border-bottom: 1px solid #e2e4e8;
  overflow-x: auto;
  scrollbar-width: thin;
}

.psc-drawers-rail:empty { display: none; }

.psc-drawers-pills {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* ── Pill button ──────────────────────────────────────────────────────── */
.psc-drawer-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  background: #ffffff;
  border: 1px solid #d1d1d9;
  border-radius: 999px;
  font: inherit;
  font-size: 0.8125rem;
  line-height: 1;
  color: #2d2d3a;
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease, box-shadow 160ms ease;
}

.psc-drawer-pill:hover {
  background: #f2f4fa;
  border-color: #b8c5d6;
  transform: translateY(-1px);
}

.psc-drawer-pill:focus-visible {
  outline: none;
  border-color: #1a1a2e;
  box-shadow: 0 0 0 2px rgba(26, 26, 46, 0.18);
}

.psc-drawer-pill:active {
  transform: translateY(0);
}

.psc-drawer-pill[aria-expanded="true"] {
  background: #1a1a2e;
  border-color: #1a1a2e;
  color: #ffffff;
}

.psc-drawer-pill[aria-expanded="true"] .psc-drawer-count {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.psc-drawer-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.psc-drawer-label {
  font-weight: 500;
}

.psc-drawer-count {
  font-size: 0.7rem;
  font-weight: 600;
  color: #72727e;
  padding: 0 0.35rem;
  background: #eef0f4;
  border-radius: 999px;
  min-width: 1.2rem;
  text-align: center;
}

/* Kind-family accents (subtle inset bar) — kept on the IDLE pill only;
   when expanded the pill is filled with brand navy so the accent retires. */
.psc-drawer-pill[aria-expanded="false"][data-drawer-kind="docs"]       { box-shadow: inset 3px 0 0 #4a90d9; }
.psc-drawer-pill[aria-expanded="false"][data-drawer-kind="references"] { box-shadow: inset 3px 0 0 #c29954; }
.psc-drawer-pill[aria-expanded="false"][data-drawer-kind="history"]    { box-shadow: inset 3px 0 0 #72727e; }
.psc-drawer-pill[aria-expanded="false"][data-drawer-kind="comments"]   { box-shadow: inset 3px 0 0 #6a5acd; }
.psc-drawer-pill[aria-expanded="false"][data-drawer-kind="specs"]      { box-shadow: inset 3px 0 0 #1a1a2e; }
.psc-drawer-pill[aria-expanded="false"][data-drawer-kind="clients"]    { box-shadow: inset 3px 0 0 #2e75b6; }
.psc-drawer-pill[aria-expanded="false"][data-drawer-kind="products"]   { box-shadow: inset 3px 0 0 #9bbb59; }
.psc-drawer-pill[aria-expanded="false"][data-drawer-kind="materials"]  { box-shadow: inset 3px 0 0 #c0504d; }
.psc-drawer-pill[aria-expanded="false"][data-drawer-kind="suppliers"]  { box-shadow: inset 3px 0 0 #8064a2; }
.psc-drawer-pill[aria-expanded="false"][data-drawer-kind="custom"]     { box-shadow: inset 3px 0 0 #4bacc6; }

/* RTL — inset bar moves to the inline-end edge. */
[dir="rtl"] .psc-drawer-pill[aria-expanded="false"][data-drawer-kind="docs"]       { box-shadow: inset -3px 0 0 #4a90d9; }
[dir="rtl"] .psc-drawer-pill[aria-expanded="false"][data-drawer-kind="references"] { box-shadow: inset -3px 0 0 #c29954; }
[dir="rtl"] .psc-drawer-pill[aria-expanded="false"][data-drawer-kind="history"]    { box-shadow: inset -3px 0 0 #72727e; }
[dir="rtl"] .psc-drawer-pill[aria-expanded="false"][data-drawer-kind="comments"]   { box-shadow: inset -3px 0 0 #6a5acd; }
[dir="rtl"] .psc-drawer-pill[aria-expanded="false"][data-drawer-kind="specs"]      { box-shadow: inset -3px 0 0 #1a1a2e; }
[dir="rtl"] .psc-drawer-pill[aria-expanded="false"][data-drawer-kind="clients"]    { box-shadow: inset -3px 0 0 #2e75b6; }
[dir="rtl"] .psc-drawer-pill[aria-expanded="false"][data-drawer-kind="products"]   { box-shadow: inset -3px 0 0 #9bbb59; }
[dir="rtl"] .psc-drawer-pill[aria-expanded="false"][data-drawer-kind="materials"]  { box-shadow: inset -3px 0 0 #c0504d; }
[dir="rtl"] .psc-drawer-pill[aria-expanded="false"][data-drawer-kind="suppliers"]  { box-shadow: inset -3px 0 0 #8064a2; }
[dir="rtl"] .psc-drawer-pill[aria-expanded="false"][data-drawer-kind="custom"]     { box-shadow: inset -3px 0 0 #4bacc6; }

/* ── Expanded body pane ───────────────────────────────────────────────── */
.psc-drawer-bodies {
  /* Container is empty visually; only the active body shows. */
}

.psc-drawer-body[hidden] { display: none; }

.psc-drawer-body {
  background: #ffffff;
  border-bottom: 1px solid #e2e4e8;
  animation: psc-drawer-slide-in 220ms cubic-bezier(.5, 1.5, .35, 1);
}

@keyframes psc-drawer-slide-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

.psc-drawer-body-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  background: #f8f8fa;
  border-bottom: 1px solid #e2e4e8;
  font-size: 0.8125rem;
}

.psc-drawer-body-icon {
  font-size: 1rem;
  line-height: 1;
}

.psc-drawer-body-title {
  font-weight: 600;
  color: #1a1a2e;
}

.psc-drawer-body-slug {
  margin-inline-start: 0.4rem;
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  font-size: 0.7rem;
  color: #72727e;
  background: #ffffff;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  border: 1px solid #e2e4e8;
}

.psc-drawer-body-close {
  margin-inline-start: auto;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  font-size: 1.1rem;
  line-height: 1;
  color: #72727e;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.psc-drawer-body-close:hover {
  background: #ffffff;
  color: #1a1a2e;
  border-color: #d1d1d9;
}

.psc-drawer-body-close:focus-visible {
  outline: none;
  border-color: #1a1a2e;
  box-shadow: 0 0 0 2px rgba(26, 26, 46, 0.18);
}

.psc-drawer-body-content {
  padding: 0.7rem 0.9rem 0.9rem;
  font-size: 0.875rem;
  color: #2d2d3a;
  line-height: 1.5;
  /* Bound the drawer height so a 100+-item list (e.g. PO 108's 107
     PODocument rows) doesn't push the rest of the PSC body off-screen.
     Scrolls vertically inside the drawer instead. */
  max-height: 360px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.psc-drawer-body-content::-webkit-scrollbar { width: 8px; }
.psc-drawer-body-content::-webkit-scrollbar-thumb {
  background: #d1d1d9;
  border-radius: 4px;
}
.psc-drawer-body-content::-webkit-scrollbar-track { background: transparent; }

/* Item count badge in the body header — e.g. "107" next to "Documents". */
.psc-drawer-body-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 6px;
  margin-inline-start: 0.25rem;
  background: #1a1a2e;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 9999px;
  line-height: 1;
}

/* ── Phase 2 — per-shape body content ─────────────────────────────────── */

.psc-drawer-empty {
  margin: 0;
  padding: 0.7rem 0.85rem;
  font-size: 0.82rem;
  color: #72727e;
  font-style: italic;
  text-align: center;
  background: #f8f9fb;
  border: 1px dashed #d1d1d9;
  border-radius: 6px;
}

/* — shape: list — compact single-row layout
   Each item: label · subtitle (inline, truncated) · meta (right).
   Was a 2-row grid pushing subtitle below; with 100+ docs that filled
   the screen. Now ~30px tall per row → ~12 rows visible in the bounded
   360px body. */
.psc-drawer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}
.psc-drawer-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 0.5rem;
  row-gap: 0.1rem;
  padding: 0.35rem 0.55rem;
  background: #f8f9fb;
  border: 1px solid #e2e4e8;
  border-radius: 5px;
  font-size: 0.82rem;
  transition: background 120ms ease, border-color 120ms ease;
}
.psc-drawer-list-item:hover {
  background: #ffffff;
  border-color: #c29954;
}
.psc-drawer-list-link {
  color: #1a1a2e;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px dashed #c29954;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.psc-drawer-list-link:hover {
  border-bottom-style: solid;
}
.psc-drawer-list-label {
  font-weight: 500;
  color: #1a1a2e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
/* Subtitle now sits on a second row, but tightly — small font, single
   line ellipsis. Keeps the row compact even with rich subtitles. */
.psc-drawer-list-sub {
  grid-column: 1 / -1;
  font-size: 0.72rem;
  color: #72727e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.psc-drawer-list-meta {
  font-size: 0.68rem;
  color: #72727e;
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  justify-self: end;
  white-space: nowrap;
}

/* — shape: thread (comments) — */
.psc-drawer-thread {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.psc-drawer-comment {
  padding: 0.55rem 0.7rem;
  background: #f8f9fb;
  border-left: 3px solid #6a5acd;   /* comments kind-color */
  border-radius: 4px;
  font-size: 0.85rem;
}
[dir="rtl"] .psc-drawer-comment {
  border-left: none;
  border-right: 3px solid #6a5acd;
}
.psc-drawer-comment-head {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  margin-bottom: 0.3rem;
}
.psc-drawer-comment-author {
  font-weight: 600;
  color: #1a1a2e;
  font-size: 0.83rem;
}
.psc-drawer-comment-at {
  font-size: 0.72rem;
  color: #72727e;
}
.psc-drawer-comment-text {
  margin: 0;
  color: #2d2d3a;
  line-height: 1.5;
}

/* — shape: kv (key/value table) — */
.psc-drawer-kv {
  display: grid;
  grid-template-columns: minmax(120px, max-content) 1fr;
  gap: 0.3rem 0.75rem;
  margin: 0;
  font-size: 0.85rem;
}
.psc-drawer-kv-key {
  font-weight: 600;
  color: #72727e;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}
.psc-drawer-kv-val {
  margin: 0;
  color: #2d2d3a;
  word-break: break-word;
}

/* — shape: timeline (history) — */
.psc-drawer-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.psc-drawer-timeline-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 0.55rem;
  align-items: start;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
}
.psc-drawer-timeline-dot {
  width: 10px;
  height: 10px;
  margin-top: 0.35rem;
  border-radius: 50%;
  background: #72727e;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 3px #d1d1d9;
}
.psc-drawer-timeline-item[data-state="success"] .psc-drawer-timeline-dot {
  background: #9bbb59;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 3px #9bbb59;
}
.psc-drawer-timeline-item[data-state="warning"] .psc-drawer-timeline-dot {
  background: #c0504d;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 3px #c0504d;
}
.psc-drawer-timeline-content {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}
.psc-drawer-timeline-label {
  font-weight: 500;
  color: #1a1a2e;
}
.psc-drawer-timeline-at {
  font-size: 0.72rem;
  color: #72727e;
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
}
.psc-drawer-timeline-by {
  font-size: 0.72rem;
  color: #72727e;
  font-style: italic;
}

/* ── Reduced motion ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .psc-drawer-body { animation: none; }
  .psc-drawer-pill { transition: none; }
  .psc-drawer-pill:hover { transform: none; }
}
