/* ═══════════════════════════════════════════════════════════════
   buttons-sections.css — Buttons, section heads, stats grid, empty state, overview panel
   Split out of cards-panels.css; load order: briefs → buttons-sections → cards-panels.
   ═══════════════════════════════════════════════════════════════ */

/* ─── §5 Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-8);
  min-height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font: 500 var(--fz-ui)/1.2 var(--font-sans);
  letter-spacing: 0;
  cursor: pointer;
  transition: background var(--duration) var(--ease),
              border-color var(--duration) var(--ease),
              color var(--duration) var(--ease),
              transform var(--duration-fast) var(--ease);
  user-select: none;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring-alpha); }
.btn:disabled { opacity: 0.5; pointer-events: none; }

/* Sizes */
.btn--sm { min-height: 30px; padding: var(--space-3) var(--space-6); font-size: var(--fz-small); }
.btn--lg { min-height: 44px; padding: var(--space-6) var(--space-10); font-size: var(--fz-body); }
.btn--icon-only { padding: 0; width: 36px; }

/* Variants — new BEM */
.btn--primary {
  background: var(--ink);
  color: var(--text-on-dark);
  font-family: var(--font-mono);
  font-size: var(--fz-xs);
  letter-spacing: var(--ls-mono-strong);
  text-transform: uppercase;
  padding: var(--space-5) var(--space-10);
}
.btn--primary:hover { background: var(--accent); color: var(--text-on-dark); }

.btn--secondary {
  background: var(--paper);
  border-color: var(--rule-2);
  color: var(--text);
}
.btn--secondary:hover { border-color: var(--ink-2); background: var(--paper-2); }

.btn--ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn--ghost:hover { background: var(--paper-2); color: var(--text); }

.btn--danger {
  background: var(--danger);
  color: var(--text-on-dark);
  border-color: transparent;
}
.btn--danger:hover { background: var(--red-tint); color: var(--danger); border-color: var(--danger); }

.btn--brand {
  background: var(--accent-pop);
  color: var(--text-on-dark);
}
.btn--brand:hover { background: var(--accent); }

/* ─── Legacy button aliases — keep working in existing templates ─ */
/* .submit = old primary */
.submit {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  padding: var(--space-5) var(--space-10);
  background: var(--ink);
  color: var(--paper);
  border: none;
  font-family: var(--font-mono);
  font-size: var(--fz-xs);
  letter-spacing: var(--ls-mono-strong);
  text-transform: uppercase;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background var(--duration) var(--ease), transform var(--duration-fast) var(--ease);
  min-height: 36px;
  text-decoration: none;
  user-select: none;
}
.submit:hover { background: var(--accent); }
.submit:active { transform: translateY(1px); }
.submit:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring-alpha); }
.submit .arrow { font-family: var(--font-sans); font-weight: 700; text-transform: none; letter-spacing: 0; font-size: 18px; }

.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  display: inline-grid; place-items: center;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  font-size: var(--fz-small);
}
.btn-icon:hover { color: var(--text); border-color: var(--ink-2); background: var(--paper); }

/* ─── §12 Section heads ──────────────────────────────────────── */
.section-head {
  display: grid;
  /* Three slots: title (auto), rule filler (1fr), trailing meta/actions
     (auto). The previous 4-column layout assumed a leading .num cell which
     we no longer render — leaving it caused the actions to land in the 1fr
     column and drift left. */
  grid-template-columns: auto 1fr auto;
  gap: var(--space-8);
  align-items: baseline;
  margin: var(--space-20) 0 var(--space-10);
}
.section-head .num {
  font-family: var(--font-mono);
  font-size: var(--fz-xs);
  letter-spacing: var(--ls-mono-strong);
  color: var(--text-muted);
  font-weight: 700;
}
.section-head .title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: var(--ls-tight);
  color: var(--text);
}
.section-head .title em {
  font-style: normal;
  font-weight: 600;
  color: var(--accent);
}
.section-head .rule { display: none; }
.section-head .meta {
  font-family: var(--font-mono);
  font-size: var(--fz-micro);
  letter-spacing: var(--ls-mono-strong);
  color: var(--text-muted);
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  text-decoration: none;
  transition: color var(--duration) var(--ease);
  margin-left: auto;
}
.section-head .meta:hover { color: var(--text); }
.section-head__actions { margin-left: auto; display: inline-flex; align-items: baseline; gap: var(--space-8); }
.section-head .meta--action { color: var(--accent); font-weight: 700; }
.section-head .meta--action:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.dashboard-page .section-head { margin: var(--space-16) 0 var(--space-8); }

/* Dashboard stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-6);
  margin-bottom: var(--space-12);
}
.stat-card {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  min-height: 130px;
  overflow: hidden;
  transition: border-color var(--duration) var(--ease),
              transform var(--duration-fast) var(--ease),
              box-shadow var(--duration) var(--ease);
}
.stat-card:hover {
  border-color: var(--ink-2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-pop);
}
.stat-card--accent:hover { border-color: var(--accent); }
.stat-card--green:hover  { border-color: var(--green); }
.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, color-mix(in srgb, var(--paper-2) 70%, transparent) 0%, transparent 60%);
  pointer-events: none;
}
.stat-card__label {
  position: relative;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-2);
  font-weight: 700;
}
.stat-card__value {
  position: relative;
  font-family: var(--font-sans);
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
  margin: 8px 0 2px;
}
.stat-card__sub {
  position: relative;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--ls-mono);
  margin-top: auto;
}
.stat-card--accent { border-color: color-mix(in srgb, var(--rule) 60%, var(--accent)); }
.stat-card--accent .stat-card__value { color: var(--accent); }
.stat-card--green { border-color: color-mix(in srgb, var(--rule) 60%, var(--green)); }
.stat-card--green .stat-card__value { color: var(--green); }
@media (max-width: 900px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

/* ─── Empty state (single pattern across pages) ──────────────── */
.empty-state {
  position: relative;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: var(--space-12) var(--space-12) var(--space-10);
  text-align: center;
  margin: 0;
}
.empty-state__tag {
  position: absolute;
  top: -1px;
  left: -1px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: var(--fz-micro);
  font-weight: 700;
  letter-spacing: var(--ls-mono-strong);
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--radius-md) 0 var(--radius-sm) 0;
}
.empty-state__text {
  margin: var(--space-3) 0 0;
  color: var(--text-2);
  font-size: var(--fz-body);
}
.empty-state__text a { color: var(--accent); }
.empty-state__sub { display: block; margin-top: var(--space-3); font-size: var(--fz-small); color: var(--text-muted); }
.backlog__sentinel {
  list-style: none;
  padding: var(--space-6);
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--fz-micro);
  letter-spacing: var(--ls-mono-strong);
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px dashed var(--rule);
  border-radius: var(--radius-sm);
  margin-top: var(--space-3);
}

/* ─── Overview panel (project show: Description + Attachments) ── */
.overview-panel {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: var(--space-16);
}
.overview-panel__head {
  padding: var(--space-12) var(--space-12) var(--space-6);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-8);
}
.overview-panel__title {
  margin: 0;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: var(--ls-tight);
  color: var(--text);
}
.overview-panel__body {
  padding: 0 var(--space-12) var(--space-12);
  color: var(--text-2);
  min-height: 32px;
}
.overview-panel__empty {
  font-style: italic;
  color: var(--text-muted);
}
.overview-panel__attach {
  border-top: 1px dashed var(--rule);
  padding: var(--space-10) var(--space-12) var(--space-12);
  background: var(--surface-soft);
}

/* Generic sub-section inside .overview-panel. Used to fold what used to be
   separate panels (Comments, Related tasks) into one continuous block,
   visually divided by the same dashed line .overview-panel__attach uses.
   Pure base = inherit panel bg (white in light), modifiers tint it. */
.overview-panel__section {
  border-top: 1px dashed var(--rule);
  padding: var(--space-12);
  background: var(--bg-elevated);
}
.overview-panel__section--gray { background: var(--surface-soft); }
.overview-panel__section--cream {
  background: color-mix(in srgb, var(--paper) 65%, var(--paper-2));
}
.overview-panel__attach-label {
  font-family: var(--font-mono);
  font-size: var(--fz-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-mono-strong);
  color: var(--text-muted);
  margin-bottom: var(--space-8);
}
.overview-panel--comments {
  padding: var(--space-12);
  background: color-mix(in srgb, var(--paper) 65%, var(--paper-2));
}
.overview-panel--links .overview-panel__body { padding-top: var(--space-6); }
.linked-tasks__list { display: flex; flex-direction: column; gap: 6px; }
.linked-task {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: var(--space-6);
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  text-decoration: none;
  color: inherit;
  transition: border-color .12s ease, background .12s ease;
}
.linked-task:hover { border-color: var(--ink-3); background: var(--paper-2); }
.linked-task__id {
  font: 500 var(--fz-micro)/1 var(--font-mono);
  color: var(--text-muted);
  letter-spacing: var(--ls-mono);
}
.linked-task__title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.linked-task__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}
.linked-task__status .col-dot { width: 8px; height: 8px; }
.linked-task__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
}
.linked-task__remove:hover { background: var(--paper-3, var(--paper-2)); color: var(--danger, #b94d3c); }
.linked-tasks__picker { margin-top: var(--space-6); }
.linked-tasks__search {
  position: relative;
  display: flex;
  align-items: center;
}
.linked-tasks__search i.fa-magnifying-glass {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  font-size: 12px;
  pointer-events: none;
}
.linked-tasks__search .input { padding-left: 30px; width: 100%; }
.linked-tasks__results {
  margin-top: 6px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  display: none;
}
.linked-tasks__results.is-open { display: block; }
.linked-tasks__results .linked-result {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-5);
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--rule);
}
.linked-tasks__results .linked-result:last-child { border-bottom: 0; }
.linked-tasks__results .linked-result:hover { background: var(--paper-2); }
.linked-tasks__results .linked-result__id {
  font: 500 var(--fz-micro)/1 var(--font-mono);
  color: var(--text-muted);
}
.linked-tasks__results .linked-result__title {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.linked-tasks__results .linked-result__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
}
.linked-tasks__results .linked-result__empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}
.overview-panel--comments .comment-thread > h3:first-child {
  margin: 0 0 var(--space-10);
}
.section-head .meta .count { color: var(--text); font-weight: 700; }
.section-head .meta .arr {
  font-family: var(--font-sans);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
  color: var(--accent);
}
