/*
 * Steady Hand theme request workspace: a divided list panel beside a detail panel on flat paper,
 * status pills, approver avatars with status badges, and a pinned decision footer.
 */

.queue-layout {
  min-height: 0;
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

/* List panel. */
.queue-list {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-radius-lg);
  background: var(--sh-surface);
  box-shadow: var(--sh-shadow-1);
}

.queue-list-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--sh-border);
  background: var(--sh-surface);
}

.queue-list-header strong { color: var(--sh-text); font-size: var(--sh-text-sm); font-weight: 600; }
.result-count { color: var(--sh-text-3); font-size: var(--sh-text-sm); }
nav.queue-list-header { border-top: 1px solid var(--sh-border); border-bottom: 0; }

.request-list li + li { border-top: 1px solid var(--sh-border); }

.request-row {
  position: relative;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px 16px 12px 28px;
  border: 0;
  background: var(--sh-surface);
  cursor: pointer;
  transition: background-color 120ms var(--sh-ease);
}

.request-row:hover { background: var(--sh-hover); }
/* The selected record: a mist field plus an Ink Blue edge, so selection is never tint alone. */
.request-row.is-selected { background: var(--sh-accent-tint); box-shadow: inset 3px 0 0 var(--sh-accent); }
.request-row.is-selected:hover { background: var(--sh-accent-tint-strong); }
/* Muted Sage falls under 4.5:1 on the mist field, so the selected row's sub-meta steps up to Sage Ink. */
.request-row.is-selected .request-submeta { color: var(--sh-text-2); }
.request-row:focus-visible { outline-offset: -2px; }
.request-row:disabled { cursor: progress; opacity: .7; }
.request-row > .request-icon { display: none; }

.request-title {
  margin: 0 0 2px;
  color: var(--sh-text);
  font-size: var(--sh-text-md);
  font-weight: 500;
  line-height: 1.35;
}

/* Rows that wait on the viewer read like unread mail: a dot and a bolder title. */
.request-row:has(.sign-flag) .request-title { font-weight: 700; }

.sign-flag {
  position: absolute;
  top: 18px;
  left: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sh-accent);
}

.request-meta { color: var(--sh-text); font-size: var(--sh-text-sm); font-weight: 600; }
.request-submeta { margin-top: 1px; color: var(--sh-text-3); font-size: var(--sh-text-xs); }

.request-duty { display: block; margin: 1px 0 3px; color: var(--sh-text-2); font-size: var(--sh-text-xs); font-weight: 600; }
.request-duty.is-actionable { color: var(--sh-accent-press); }

.request-side {
  gap: 6px;
  color: var(--sh-text-2);
  font-size: var(--sh-text-xs);
}

.request-progress { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.request-progress .tick-strip { display: none; }

/* Detail panel. */
.queue-preview {
  min-width: 0;
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-radius-lg);
  background: var(--sh-surface);
  box-shadow: var(--sh-shadow-1);
}

.queue-preview[aria-label="Selected request"] { animation: sh-panel-in 180ms var(--sh-ease); }
.preview-return { display: none; }

.preview-header {
  gap: 16px;
  padding: 20px 24px 18px;
  border-bottom: 0;
}

.preview-header .wf-row { margin-bottom: 10px; }
.preview-header .badge,
.record-header .badge { min-height: 22px; padding: 0 8px; font-size: 11.5px; }

.preview-title {
  max-width: 40ch;
  margin: 0 0 4px;
  color: var(--sh-text);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.012em;
}

.preview-header .wf-copy { color: var(--sh-text-2); font-size: var(--sh-text-sm); }
.preview-header .wf-copy span:not(.meta-join, .meta-dot) { color: var(--sh-text); font-weight: 500; }
.meta-join { white-space: nowrap; }

.preview-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; max-width: none; margin-top: 14px; }
.progress-strip { display: flex; }
.preview-progress .progress-label { margin: 0; color: var(--sh-text-2); font-size: var(--sh-text-sm); }

/* Approvers as avatars with a status badge. */
.signoff { display: flex; flex-wrap: wrap; gap: 6px; }

.signoff-line {
  position: relative;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--sh-accent-tint-strong);
  color: var(--sh-accent-press);
}

.signoff-name { font-size: 11px; font-weight: 700; line-height: 1; }
.signoff-day { display: none; }

.signoff-line.is-open { border: 1.5px dashed var(--sh-border-strong); background: var(--sh-surface); color: var(--sh-text-2); }

.signoff-mark {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 16px;
  height: 16px;
  display: none;
  place-items: center;
  border: 2px solid var(--sh-surface);
  border-radius: 50%;
}

.signoff-line.is-signed .signoff-mark { display: grid; background: var(--sh-approved); }
.signoff-line.is-rejected .signoff-mark { display: grid; background: var(--sh-rejected); }
.signoff-mark svg { width: 10px; height: 10px; }
.signoff-mark path { fill: none; stroke: #ffffff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* Fallback when approvers are not in hand: a segmented progress bar. */
.tick-strip { display: inline-flex; gap: 3px; }
.tick { width: 18px; height: 6px; border-radius: 999px; background: var(--sh-track); }
.tick.is-signed { background: var(--sh-approved); }
.tick svg { display: none; }

.preview-actions .button--icon { box-shadow: none; }

.preview-body { padding: 0 24px 24px; }
.tab-panel { padding-top: 18px; }
.preview-body .copy-block:first-child { margin-top: 0; }
.copy-block { margin-top: 22px; }
.copy-block h3 { margin-bottom: 6px; }
.copy-block p { max-width: 60ch; color: var(--sh-text); font-size: var(--sh-text-md); line-height: 1.6; white-space: pre-line; }

.preview-body .facts { margin-top: 18px; border-top: 1px solid var(--sh-border); }
.copy-block .facts { margin-top: 0; }
.preview-body .fact,
.record-section .fact { grid-template-columns: minmax(120px, 170px) minmax(0, 1fr); gap: 12px; padding: 9px 0; }

/* People, comments and files. */
.preview-body .people-list,
.record-section .people-list { gap: 0; }

.preview-body .person-row,
.record-section .person-row {
  align-items: center;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--sh-border);
  border-radius: 0;
  background: transparent;
}

.person-row strong { font-size: var(--sh-text-md); font-weight: 600; }
.person-row small { color: var(--sh-text-2); font-size: var(--sh-text-sm); }
.people-list + .help { margin-top: 12px; }

.comment-list, .file-list { gap: 0; }

.preview-body .comment,
.record-section .comment {
  padding: 12px 0;
  border: 0;
  border-bottom: 1px solid var(--sh-border);
  border-radius: 0;
  background: transparent;
}

.comment-body strong { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: var(--sh-text-md); font-weight: 600; }
.comment-body small { color: var(--sh-text-3); font-size: var(--sh-text-xs); }
.comment-body p { max-width: 60ch; margin-top: 4px; color: var(--sh-text); line-height: 1.55; white-space: pre-line; }

.preview-body .file-row,
.record-section .file-row { align-items: center; padding: 10px 12px; border-radius: var(--sh-radius-lg); }
.preview-body .file-row + .file-row,
.record-section .file-row + .file-row { margin-top: 8px; }
.file-row > [data-icon] { color: var(--sh-text-2); }

.preview-body .form-grid { gap: 10px; }

/* Decision and cancel panels: a white footer section under a top rule, never a nested card. */
.owner-actions {
  margin: 0;
  padding: 16px 24px;
  border: 0;
  border-top: 1px solid var(--sh-border);
  border-radius: 0 0 var(--sh-radius-lg) var(--sh-radius-lg);
  background: var(--sh-surface);
  box-shadow: none;
}

.owner-actions h3 { margin-bottom: 2px; font-size: var(--sh-text-md); font-weight: 600; }
.owner-actions .wf-copy { max-width: 60ch; color: var(--sh-text-2); font-size: var(--sh-text-sm); }
.owner-actions--decision .button { min-width: 108px; }

/* The decision footer stays in view at every width while its request is on screen. */
.queue-preview > .owner-actions--decision {
  position: sticky;
  z-index: 2;
  bottom: 0;
  box-shadow: var(--sh-shadow-4);
}

/* Role is already written in each person's detail line; lozenges are for status only. */
.person-row > .badge:not(.badge--dot, .badge--soft, .badge--striped) { display: none; }

/* The record's one filled action is none: Share and Print are both utilities. */
.record-actions .button:not(.button--secondary, .button--danger) {
  border-color: var(--sh-control-border);
  background: var(--sh-surface);
  color: var(--sh-text);
}

.record-actions .button:not(.button--secondary, .button--danger):hover { border-color: var(--sh-border-hover); background: var(--sh-hover); }

/* Print while its sections load, or after a load stops, wears the disabled recipe (Sunken Grey, hairline, Muted Slate). */
.record-actions .button:disabled,
.record-actions .button:disabled:hover { border-color: var(--sh-border); background: var(--sh-surface-sunken); color: var(--sh-text-3); box-shadow: none; cursor: not-allowed; }

/* Expanded record: an issue-style page. */
.record-page > .back-link { margin-bottom: 12px; }
.record-header { margin-bottom: 16px; }
.record-header .detail-title-row > div:first-child { flex: 1; min-width: 0; }
.record-page .detail-title-row h1 { max-width: 40ch; margin-bottom: 4px; font-size: var(--sh-text-route); font-weight: 600; letter-spacing: -.015em; line-height: 1.25; }
.record-header .wf-row { margin-bottom: 10px; }
.detail-meta { color: var(--sh-text-2); }

.record-body { gap: 0; overflow: hidden; border: 1px solid var(--sh-border); border-radius: var(--sh-radius-lg); background: var(--sh-surface); box-shadow: var(--sh-shadow-1); }
.record-section.surface { border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.record-section + .record-section { border-top: 1px solid var(--sh-border); }
.record-section { padding: 18px 24px 20px; }
.record-section h2 { margin-bottom: 10px; color: var(--sh-text); font-size: var(--sh-text-lg); font-weight: 600; }
.record-section > p { max-width: 60ch; line-height: 1.6; white-space: pre-line; }
.record-section .facts { border-top: 1px solid var(--sh-border); }
.record-status { margin: 0 0 16px; }
.record-status h2 { margin-bottom: 2px; font-size: var(--sh-text-md); font-weight: 600; }
.record-provenance { color: var(--sh-text-2); font-size: 12px; }
/* Three chips do not earn a full section's rhythm. */
.record-section--tags { padding: 14px 24px 16px; }
.record-section--tags h2 { margin-bottom: 8px; }
/* A rejecting approver's reason sits under their row as plain copy. */
.person-row .person-reason { color: var(--sh-text-2); font-size: var(--sh-text-sm); line-height: 1.5; white-space: pre-line; }
/* Comment authors carry their role as text, not a lozenge (The Status Only Rule). */
.comment-role { color: var(--sh-text-3); font-size: var(--sh-text-xs); }
.avatar--unknown { background: var(--sh-surface-sunken); color: var(--sh-text-3); }
/* Thumb targets that keep the desktop rhythm: the back link and reference links get a 36px line box. */
.record-page > .back-link { min-height: 36px; margin: -6px 0 6px -4px; padding: 6px 4px; }
.record-section .fact dd a { display: inline-block; min-height: 36px; margin-block: -7px; padding-block: 7px; line-height: 22px; }

@keyframes sh-panel-in {
  from { opacity: .6; }
  to { opacity: 1; }
}

.toolbar .search { width: 320px; }

@media (min-width: 1181px) {
  .queue-preview {
    /* Keyboard focus scrolled into the panel stops above the pinned decision footer (WCAG 2.4.11). */
    scroll-padding-bottom: 150px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 185px);
    min-height: 420px;
    overflow-y: auto;
    scrollbar-width: thin;
  }

}

/* Focus never lands under the sticky top bar or the pinned decision footer on narrow screens. */
@media (max-width: 1180px) {
  html:has(.queue-preview > .owner-actions--decision) { scroll-padding-bottom: 190px; }
  html { scroll-padding-top: calc(var(--wf-mobile-bar-height) + 12px); }
  .queue-layout { display: block; }
  .queue-layout.is-preview-open .queue-preview { margin-top: 16px; }
  .queue-preview { scroll-margin-top: calc(var(--wf-mobile-bar-height) + 12px); }
  .preview-return { display: inline-flex; margin: 10px 14px 0; }
  .owner-actions { padding: 14px 20px; }
}

@media (max-width: 700px) {
  .queue-layout { margin-inline: 0; }
  .toolbar-group .search { flex: 1 1 220px; width: auto; }
  .toolbar-group .search-action { flex: 0 0 auto; }
  .request-row { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 12px 14px 12px 26px; }
  .request-side { grid-column: 1; display: flex; align-items: center; justify-content: space-between; }
  .sign-flag { left: 11px; }
  .preview-header { position: relative; display: block; padding: 16px; }
  .preview-header .wf-row { min-height: 30px; margin-bottom: 8px; padding-right: 76px; }
  .preview-actions { position: absolute; top: 16px; right: 16px; gap: 6px; }
  .preview-actions .button--icon { width: 32px; min-height: 32px; }
  .preview-title { max-width: none; font-size: var(--sh-text-xl); }
  .meta-join { display: block; white-space: normal; }
  .meta-dot { display: none; }
  .preview-body { padding: 0 16px 20px; }
  .tabs { gap: 16px; }
  .preview-body .fact,
  .record-section .fact { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .owner-actions { padding: 12px 16px; }
  .owner-actions h3 { font-size: var(--sh-text-sm); }
  .owner-actions .wf-copy { font-size: var(--sh-text-xs); }
  .owner-actions > .wf-row,
  .owner-actions > .button { width: 100%; }
  .owner-actions > .wf-row .button { flex: 1; min-width: 0; }
  .record-section { padding: 16px; }
  .record-section--tags { padding: 12px 16px 14px; }
  .record-page .detail-title-row h1 { font-size: var(--sh-text-xl); }
  .detail-meta { flex-direction: column; gap: 2px; }
  .detail-meta > span:nth-child(2) { display: none; }
  /* File rows: Open becomes a full-width 36px row under the name so it is tappable. */
  .record-section .file-row { flex-wrap: wrap; }
  .record-section .file-row > .button { flex: 0 0 auto; width: calc(100% - 30px); min-height: 36px; margin-left: 30px; }
}

@media print {
  .queue-preview { position: static; max-height: none; }
  .record-page { max-width: 720px; margin: 0; }
  .record-body { border: 0; box-shadow: none; }
  /* Paper: black underlined links and flat file rows, as the r005 print sheet intends. */
  .record-page a { color: #000; text-decoration: underline; }
  .record-section .file-row { padding: 6px 0; border: 0; border-radius: 0; }
  .record-section .file-row + .file-row { margin-top: 0; }
  .record-provenance, .record-page .detail-meta { color: #000; }
}

@media (hover: none) {
  .request-row:hover { background: var(--sh-surface); }
  .request-row.is-selected:hover { background: var(--sh-accent-tint); }
}

/* Loading skeleton: the preview's shape in quiet placeholders while a selected round loads. */
.skeleton {
  display: block;
  height: 12px;
  border-radius: var(--sh-radius-sm);
  background: linear-gradient(90deg, var(--sh-surface-sunken) 0%, var(--sh-border) 50%, var(--sh-surface-sunken) 100%) 0 0 / 200% 100%;
  animation: sh-skeleton 1.4s ease-in-out infinite;
}

.skeleton--pill { height: 22px; }
.skeleton--title { height: 24px; margin-top: 4px; }
.skeleton--text { height: 12px; }
.skeleton--avatar { width: 32px; height: 32px; border-radius: 50%; }
.skeleton-stack { display: grid; gap: 12px; }
.skeleton-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.skeleton-tabs { display: flex; gap: 22px; overflow: hidden; padding: 15px 0; border-bottom: 1px solid var(--sh-border); }
.skeleton-copy { margin-top: 22px; }
.skeleton-facts { margin-top: 22px; border-top: 1px solid var(--sh-border); }
.skeleton-fact { display: grid; grid-template-columns: minmax(120px, 170px) minmax(0, 1fr); gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--sh-border); }
.preview-skeleton .preview-header { display: block; }

@keyframes sh-skeleton {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; background: var(--sh-surface-sunken); }
}

@media (max-width: 700px) {
  .skeleton-fact { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .skeleton-tabs { gap: 16px; }
}
