/*
 * Steady Hand theme shared components over the r005 class vocabulary.
 * Tokens only; see tokens.css and design/themes/steady-hand/DESIGN.md.
 */

html,
body,
.wf-page,
.verify-page { background: var(--sh-canvas); }

body {
  color: var(--sh-text);
  font-family: var(--sh-font);
  font-size: var(--sh-text-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  scrollbar-color: var(--sh-border-hover) transparent;
}

::selection { background: var(--sh-accent-tint-strong); color: var(--sh-text); }
input, textarea { caret-color: var(--sh-accent); }
a { color: var(--sh-accent); text-underline-offset: 2px; }
a:hover { color: var(--sh-accent-hover); }
h1, h2, h3, h4 { color: var(--sh-text); text-wrap: balance; }
p { text-wrap: pretty; }

:focus-visible {
  outline: 2px solid var(--sh-accent);
  outline-offset: 2px;
}

.fact dd,
.summary-list dd,
.request-meta,
.request-side,
.progress-label,
.result-count,
.timeline-item time,
.comment-body small,
.detail-meta,
.stat strong,
.badge { font-variant-numeric: tabular-nums; }

/* Buttons. */
.button {
  min-height: 36px;
  gap: 6px;
  padding: 0 14px;
  border: 1px solid var(--sh-accent);
  border-radius: var(--sh-radius);
  background: var(--sh-accent);
  color: var(--sh-on-accent);
  font-family: var(--sh-font);
  font-size: var(--sh-text-md);
  font-weight: 600;
  box-shadow: var(--sh-shadow-1);
  transition: background-color 150ms var(--sh-ease), border-color 150ms var(--sh-ease), box-shadow 150ms var(--sh-ease), color 150ms var(--sh-ease);
}

.button:hover { border-color: var(--sh-accent-hover); background: var(--sh-accent-hover); }
.button:active:not(:disabled) { border-color: var(--sh-accent-press); background: var(--sh-accent-press); }
.button .icon { width: 16px; height: 16px; }

.button--secondary {
  border-color: var(--sh-control-border);
  background: var(--sh-surface);
  color: var(--sh-text);
}

.button--secondary:hover { border-color: var(--sh-border-hover); background: var(--sh-hover); }
.button--secondary:active:not(:disabled) { border-color: var(--sh-border-hover); background: var(--sh-surface-sunken); }

.button--ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--sh-text-2);
}

.button--ghost:hover { border-color: transparent; background: var(--sh-hover); color: var(--sh-text); }

.button--danger {
  border-color: var(--sh-control-border);
  background: var(--sh-surface);
  color: var(--sh-rejected-text);
}

.button--danger:hover { border-color: var(--sh-rejected); background: var(--sh-rejected); color: #ffffff; }
.button--danger:active:not(:disabled) { border-color: var(--sh-rejected-text); background: var(--sh-rejected-text); color: #ffffff; }

.button--small { min-height: 30px; padding-inline: 10px; font-size: var(--sh-text-sm); }
.button--icon { width: 36px; padding: 0; }
.button--small.button--icon { width: 30px; }

.button:disabled,
.button[aria-disabled="true"],
.button:disabled:hover {
  border-color: var(--sh-border);
  background: var(--sh-surface-sunken);
  box-shadow: none;
  color: var(--sh-text-disabled);
  cursor: not-allowed;
}

/* Status chips: a pill whose fill, border and text come from one hue. */
.badge {
  min-height: 20px;
  gap: 4px;
  padding: 0 8px;
  border: 1px solid var(--sh-neutral-border);
  border-radius: 999px;
  background: var(--sh-neutral-bg);
  color: var(--sh-neutral-text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1;
  text-transform: none;
}

.badge--solid { border-color: var(--sh-text); background: var(--sh-text); color: #ffffff; }
.badge--soft { border-color: var(--sh-approved-border); background: var(--sh-approved-bg); color: var(--sh-approved-text); }
.badge--striped { border-color: var(--sh-rejected-border); background: var(--sh-rejected-bg); color: var(--sh-rejected-text); }
.badge--dot { border-color: var(--sh-open-border); background: var(--sh-open-bg); color: var(--sh-open-text); }
.badge--dot::before { display: none; }

/* Fields. */
.label { color: var(--sh-text); font-size: var(--sh-text-sm); font-weight: 600; }

.input,
.select,
.textarea {
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--sh-border-strong);
  border-radius: var(--sh-radius);
  background: var(--sh-surface);
  color: var(--sh-text);
  font-family: var(--sh-font);
  font-size: var(--sh-text-md);
  transition: border-color 150ms var(--sh-ease), box-shadow 150ms var(--sh-ease);
}

/* Single-line fields hold 40px exactly (date inputs otherwise grow), and a button beside a field matches it. */
input.input, .select { height: 40px; }
.search-action, .verify-password-control .button { min-height: 40px; }

.input::placeholder,
.textarea::placeholder { color: var(--sh-text-3); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--sh-text-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--sh-accent); box-shadow: 0 0 0 3px var(--sh-focus-ring); outline: none; }
.input:disabled, .select:disabled, .textarea:disabled { border-color: var(--sh-border); background: var(--sh-surface-sunken); color: var(--sh-text-3); }
.help { color: var(--sh-text-2); font-size: var(--sh-text-sm); }
.error { color: var(--sh-rejected-text); font-size: var(--sh-text-sm); font-weight: 600; }
.field.is-invalid .input,
.field.is-invalid .textarea { border: 1px solid var(--sh-rejected); background: var(--sh-surface); box-shadow: 0 0 0 3px var(--sh-rejected-ring); }
.search .icon { left: 11px; width: 16px; height: 16px; color: var(--sh-text-3); }
.search .input { padding-left: 34px; }

/* Shell: a white paper rail under a one-pixel sage rule. */
.sidebar {
  padding: 14px 10px 12px;
  border-right: 1px solid var(--sh-border);
  background: var(--sh-nav);
  color: var(--sh-nav-text);
}

.brand {
  gap: 10px;
  min-height: 44px;
  padding: 0 8px;
  color: var(--sh-text);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--sh-radius);
  background: var(--sh-accent);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

/* The Accord symbol stands bare beside the name, as Gather does in Resourcing: no tile behind it. */
.brand-mark--logo { width: 32px; height: 32px; border-radius: 0; background: none; object-fit: contain; }

.nav-label {
  margin: 20px 10px 6px;
  color: var(--sh-nav-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .09em;
}

.nav { gap: 2px; }

.nav-link {
  min-height: 38px;
  gap: 10px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--sh-radius);
  color: var(--sh-nav-text);
  font-size: var(--sh-text-md);
  font-weight: 600;
  transition: background-color 120ms var(--sh-ease), border-color 120ms var(--sh-ease), color 120ms var(--sh-ease);
}

/* Hover is a quiet invitation; only the current route carries the Ink Blue edge and label. */
.nav-link:hover { background: var(--sh-nav-hover); color: var(--sh-text); }
.nav-link[aria-current="page"] { border-color: var(--sh-accent); background: var(--sh-nav-current); color: var(--sh-accent); font-weight: 700; }
.nav-link .icon { width: 17px; height: 17px; opacity: .9; }

.nav-count,
.nav-link .badge {
  min-width: 20px;
  min-height: 18px;
  justify-content: center;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: var(--sh-accent);
  color: var(--sh-on-accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

.nav-bottom { padding-top: 10px; border-top: 1px solid var(--sh-nav-rule); }
.nav-bottom .avatar { border: 0; background: var(--sh-accent); color: #ffffff; }

.avatar {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--sh-accent-tint-strong);
  color: var(--sh-accent-press);
  font-size: 11px;
  font-weight: 700;
}

.mobile-bar { border-bottom: 1px solid var(--sh-border); background: var(--sh-nav); color: var(--sh-text); }
.mobile-bar .button--ghost { color: var(--sh-text-2); }
.mobile-bar .button--ghost:hover { background: var(--sh-nav-hover); color: var(--sh-text); }
.mobile-bar .avatar { background: var(--sh-accent); color: #ffffff; }
.drawer-overlay { background: var(--sh-overlay); }

/* Page scaffolding. */
.page-header { margin-bottom: 20px; }
.page-title { margin-bottom: 4px; color: var(--sh-text); font-size: var(--sh-text-route); font-weight: 600; line-height: 1.2; letter-spacing: -.015em; }
.page-subtitle { max-width: 70ch; color: var(--sh-text-2); font-size: var(--sh-text-md); }

.surface {
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-radius-lg);
  background: var(--sh-surface);
  box-shadow: var(--sh-shadow-1);
}

.surface-header, .surface-footer { border-color: var(--sh-border); }

/* Filter button group. */
.segmented {
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-radius-lg);
  background: var(--sh-surface-sunken);
}

.segment {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--sh-text-2);
  font-size: var(--sh-text-sm);
  font-weight: 600;
  transition: background-color 120ms var(--sh-ease), color 120ms var(--sh-ease);
}

.segment:hover { color: var(--sh-text); }
.segment.is-active,
.segment[aria-selected="true"] { border-color: var(--sh-border); background: var(--sh-surface); color: var(--sh-text); }
.segment .badge { min-height: 18px; padding: 0 6px; border-radius: 999px; border: 0; background: var(--sh-border); color: var(--sh-text); font-size: 11px; letter-spacing: 0; text-transform: none; }
.segment.is-active .badge { background: var(--sh-accent-tint-strong); color: var(--sh-accent-press); }

/* Tabs. */
.tabs { gap: 20px; border-bottom: 1px solid var(--sh-border); scrollbar-width: none; }
.tab { min-height: 42px; border-bottom: 2px solid transparent; color: var(--sh-text-2); font-size: var(--sh-text-md); font-weight: 500; transition: color 120ms var(--sh-ease), border-color 120ms var(--sh-ease); }
.tab:hover { color: var(--sh-text); border-bottom-color: var(--sh-border-strong); }
.tab[aria-selected="true"] { border-bottom-color: var(--sh-accent); color: var(--sh-accent); font-weight: 600; }

/* Field list. */
.fact { border-bottom-color: var(--sh-border); }
.fact dt { color: var(--sh-text-2); font-size: var(--sh-text-md); }
.fact dd { color: var(--sh-text); font-size: var(--sh-text-md); font-weight: 500; overflow-wrap: anywhere; }

.copy-block h2,
.copy-block h3,
.summary-section h3 { color: var(--sh-text); font-size: var(--sh-text-md); font-weight: 600; }

.chip { padding: 2px 8px; border: 1px solid var(--sh-border); border-radius: 999px; background: var(--sh-surface-sunken); color: var(--sh-text); font-size: var(--sh-text-sm); }
.notice { border-color: var(--sh-border); border-radius: var(--sh-radius-lg); background: var(--sh-accent-tint); }

.collection-head { background: var(--sh-surface-sunken); color: var(--sh-text-2); letter-spacing: .03em; }
.collection-row:hover { background: var(--sh-hover); }

.template-card,
.workflow-card,
.file-row,
.person-row,
.comment,
.preference-card,
.participant-row,
.profile-choice { border-color: var(--sh-border); border-radius: var(--sh-radius-lg); }

.template-card:hover,
.workflow-card:hover { border-color: var(--sh-border-strong); background: var(--sh-surface); }
.template-icon { border-radius: var(--sh-radius-lg); background: var(--sh-accent-tint); color: var(--sh-accent); }
.profile-choice[aria-pressed="true"] { border-color: var(--sh-accent); background: var(--sh-accent-tint); }
.upload-zone, .blank-card, .compact-empty { border-color: var(--sh-border-hover); border-radius: var(--sh-radius-lg); background: var(--sh-surface); }

.step-number { border-color: var(--sh-border-strong); }
.step-button.is-complete .step-number { border-color: var(--sh-accent); background: var(--sh-accent); color: #ffffff; }
.step-button.is-active,
.category-button.is-active,
.section-button.is-active { background: var(--sh-accent-tint); color: var(--sh-accent-press); }

.progress-track { height: 6px; border-radius: 999px; background: var(--sh-track); }
.progress-value { border-radius: 999px; background: var(--sh-accent); }
.progress-label { color: var(--sh-text-2); font-size: var(--sh-text-sm); }

.empty-state .icon { color: var(--sh-text-3); }

/* Switch. */
.switch-track { border-color: var(--sh-border-strong); background: var(--sh-track); }
.switch-track::after { background: #ffffff; box-shadow: 0 1px 2px rgb(38 51 45 / 25%); }
.switch input:checked + .switch-track { border-color: var(--sh-accent); background: var(--sh-accent); }
.switch input:checked + .switch-track::after { background: #ffffff; }
.switch input:focus-visible + .switch-track { outline-color: var(--sh-accent); }

/* Dialogs and toast. */
.dialog {
  border: 0;
  border-radius: var(--sh-radius-xl);
  background: var(--sh-surface);
  color: var(--sh-text);
  box-shadow: var(--sh-shadow-3);
}

.dialog[open] { animation: sh-dialog-in 180ms var(--sh-ease); }
.dialog::backdrop { background: var(--sh-overlay); }
.dialog-header { padding: 18px 20px 6px; border-bottom: 0; }
.dialog-header h2 { font-size: var(--sh-text-lg); font-weight: 600; }
.dialog-body { padding: 10px 20px 18px; }
.dialog-footer { padding: 14px 20px; border-top: 1px solid var(--sh-border); background: var(--sh-surface-sunken); border-radius: 0 0 var(--sh-radius-xl) var(--sh-radius-xl); }

.toast {
  border: 0;
  border-radius: var(--sh-radius-lg);
  background: var(--sh-text);
  color: #ffffff;
  font-size: var(--sh-text-md);
  font-weight: 500;
  box-shadow: var(--sh-shadow-3);
  transition: opacity 160ms var(--sh-ease), transform 200ms var(--sh-ease);
}

/* Activity timeline. */
.timeline-item:not(:last-child)::before { background: var(--sh-border); }
.timeline-mark { border: 1px solid var(--sh-border); background: var(--sh-surface); color: var(--sh-text-2); }
.timeline-mark .icon { width: 15px; height: 15px; }
.timeline-item time { color: var(--sh-text-3); font-size: var(--sh-text-xs); }
.timeline-item p { font-size: var(--sh-text-md); line-height: 1.5; }
.timeline-item .wf-copy { max-width: 60ch; color: var(--sh-text-2); font-size: var(--sh-text-md); }

.verify-card { border-radius: var(--sh-radius-xl); box-shadow: none; }
.verify-mark { border: 0; border-radius: var(--sh-radius-xl); background: var(--sh-accent); color: #ffffff; }

.back-link { color: var(--sh-text-2); font-weight: 500; }
.back-link:hover { color: var(--sh-accent); }

@keyframes sh-dialog-in {
  from { opacity: 0; transform: translateY(4px) scale(.98); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 900px) {
  .sidebar { box-shadow: none; }
  .sidebar.is-open { box-shadow: var(--sh-shadow-3); }
}

@media (max-width: 700px) {
  .segmented { overflow-x: auto; }
  .segment { flex: 1 1 auto; justify-content: center; gap: 4px; padding: 0 8px; }
  .page-title { font-size: var(--sh-text-xl); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0ms !important; animation-iteration-count: 1 !important; }
}

/* Touch screens keep no hover: a tapped control returns to its resting look instead of
   staying in its hover colour (substrate hovers included). */
@media (hover: none) {
  a:hover { color: var(--sh-accent); }
  .brand:hover { color: var(--sh-text); }
  .back-link:hover { color: var(--sh-text-2); }
  .button:hover { border-color: var(--sh-accent); background: var(--sh-accent); color: var(--sh-on-accent); }
  .button--secondary:hover { border-color: var(--sh-control-border); background: var(--sh-surface); color: var(--sh-text); }
  .button--ghost:hover { border-color: transparent; background: transparent; color: var(--sh-text-2); }
  .mobile-bar .button--ghost:hover { background: transparent; color: var(--sh-text-2); }
  .button--danger:hover { border-color: var(--sh-control-border); background: var(--sh-surface); color: var(--sh-rejected-text); }
  .button:disabled:hover { border-color: var(--sh-border); background: var(--sh-surface-sunken); color: var(--sh-text-disabled); }
  .nav-link:hover { background: transparent; color: var(--sh-nav-text); }
  .nav-link[aria-current="page"]:hover { background: var(--sh-nav-current); color: var(--sh-accent); }
  .input:hover, .select:hover, .textarea:hover { border-color: var(--sh-border-strong); }
  .segment:hover { color: var(--sh-text-2); }
  .segment.is-active:hover { color: var(--sh-text); }
  .tab:hover { border-bottom-color: transparent; color: var(--sh-text-2); }
  .tab[aria-selected="true"]:hover { border-bottom-color: var(--sh-accent); color: var(--sh-accent); }
  .collection-row:hover { background: transparent; }
  .template-card:hover, .workflow-card:hover { border-color: var(--sh-border); }
}

/* Theme chooser in the sidebar's bottom section: a disclosure whose options open above it. */
.nav-bottom .nav { position: relative; }
.theme-menu { position: relative; }
.theme-summary { cursor: pointer; list-style: none; user-select: none; }
.theme-summary::-webkit-details-marker { display: none; }
.theme-current { margin-left: auto; color: var(--sh-nav-muted); font-size: var(--sh-text-xs); font-weight: 500; }
.theme-menu[open] > .theme-summary { background: var(--sh-nav-hover); color: var(--sh-text); }

.theme-options {
  /* Opens in line with the nav links so it never covers another target (WCAG 2.5.8). */
  position: relative;
  z-index: 1;
  display: grid;
  gap: 2px;
  margin: 6px 0 8px;
  padding: 6px;
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-radius-lg);
  background: var(--sh-surface);
  box-shadow: var(--sh-shadow-1);
  color: var(--sh-text);
  animation: sh-menu-in 140ms var(--sh-ease);
}

.theme-option {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--sh-radius);
  background: transparent;
  color: var(--sh-text);
  text-align: left;
  cursor: pointer;
}

.theme-option:hover { background: var(--sh-hover); }
.theme-option[aria-pressed="true"] { background: var(--sh-accent-tint); }
.theme-option:disabled { cursor: progress; opacity: .7; }
.theme-option-text strong { display: block; color: var(--sh-text); font-size: var(--sh-text-sm); font-weight: 600; }
.theme-option-text small { display: block; color: var(--sh-text-2); font-size: var(--sh-text-xs); }
.theme-option-check .icon { width: 16px; height: 16px; color: var(--sh-accent); }
.theme-error { margin: 4px 6px 2px; color: var(--sh-rejected-text); font-size: var(--sh-text-xs); }

.theme-swatch { width: 28px; height: 28px; border: 1px solid var(--sh-border); border-radius: var(--sh-radius); }
.theme-swatch--steady-hand { background: linear-gradient(135deg, #1f4e79 0 50%, #f6f7f4 50% 100%); }
.theme-swatch--standard { background: linear-gradient(135deg, #1e1b4b 0 50%, #ffffff 50% 100%); }
.theme-swatch--routing-slip { background: linear-gradient(135deg, #d9bd82 0 50%, #ffffff 50% 100%); }

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

@media (hover: none) {
  .theme-option:hover { background: transparent; }
  .theme-option[aria-pressed="true"]:hover { background: var(--sh-accent-tint); }
}
