/* ==========================================================================
   APEX components — SPA primitives (ls-button/badge/field/select/lead-card …)
   Class names + badge variants are preserved verbatim for the e2e suite.
   ========================================================================== */

/* --- Form controls --- */
input,
select,
textarea {
  font: inherit;
  font-family: var(--font-body);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 12px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
/* --text-4 (#cbd5e1) is 1.35:1 on the --panel-2 field fill — placeholder text
   is text, and in an empty field it is the only affordance. --text-3 is 4.95:1.
   See design/leadsurface/artifacts/README.md, finding G2. */
input::placeholder,
textarea::placeholder {
  color: var(--text-3);
}

/* --- Field (ls-field): label stacked above a full-width input --- */
ls-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
ls-field label {
  font-weight: 500;
}
ls-field input {
  width: 100%;
}

/* ls-auth-view: full-width submit + a link to the other auth page. */
.auth-wrap [data-action='submit'] button {
  width: 100%;
}
.auth-alt {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}
.auth-alt a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
  /* An inline <a> at 13px gives an 18px tappable line. "Forgot password?" and
     the magic-link toggle are the whole recovery path for someone locked out
     on a phone, so pad the line out rather than making a thumb hit 18px. */
  display: inline-block;
  padding: 4px 2px;
}
.auth-alt a:hover {
  text-decoration: underline;
}

/* --- Buttons --- */
button {
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 9px 16px;
  transition:
    transform 0.15s,
    box-shadow 0.18s,
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}
button:hover {
  box-shadow: var(--shadow-accent);
  transform: translateY(-1px);
}
button:active {
  transform: translateY(0);
}
button.ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--muted);
  box-shadow: none;
}
button.ghost:hover {
  border-color: var(--accent);
  color: var(--text-hi);
  transform: translateY(-1px);
  box-shadow: none;
}

/* 9px of padding on 13px type renders a 36px control, under the 44px WCAG
   2.5.5 minimum. Below the nav breakpoint every button is a touch target, so
   give them all the floor rather than patching it per screen — the header nav
   in base.css already carried its own copy of this rule, and the feed cards,
   Settings, and the billing lock each needed one next. */
@media (max-width: 640px) {
  button {
    min-height: 44px;
  }
}

/* --- Cards --- */
.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 18px 16px;
  margin-bottom: 14px;
  transition:
    border-color 0.18s,
    box-shadow 0.18s,
    transform 0.18s;
}
.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}
/* Intent accent rail — driven by ls-lead-card's data-signal on the .card. */
.card[data-signal]::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  background: var(--border-strong);
}
.card[data-signal='switching']::before {
  background: var(--switching);
}
.card[data-signal='comparison']::before {
  background: var(--comparison);
}
.card[data-signal='complaint']::before {
  background: var(--complaint);
}
.card[data-signal='praise']::before {
  background: var(--praise);
}
.card h3 {
  margin: 10px 0 6px;
  font-size: 16px;
  line-height: 1.35;
}
.card a {
  color: var(--text-hi);
  text-decoration: none;
}
.card a:hover {
  color: var(--accent);
}
.card p {
  margin: 6px 0;
  color: var(--text);
  font-size: 14px;
}

.meta {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
}
.evidence {
  border-left: 2px solid var(--border-accent);
  padding: 6px 0 6px 12px;
  margin: 10px 0;
  color: var(--muted);
  font-style: italic;
  font-size: 13px;
}

/* --- Badges --- */
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel-3);
  color: var(--text);
  border: 1px solid var(--border);
}
.badge.switching {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.25);
}
.badge.comparison {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.28);
}
.badge.complaint {
  background: rgba(234, 179, 8, 0.12);
  color: #a16207;
  border-color: rgba(234, 179, 8, 0.28);
}
.badge.praise {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.28);
}

.error {
  color: var(--switching);
  font-size: 13px;
  min-height: 18px;
}

/* Feedback buttons: lineart icon + label inline. */
ls-lead-card button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.fb-ic {
  flex-shrink: 0;
}

/* ls-lead-card dims after feedback (parent sets data-state="dismissed"). */
ls-lead-card[data-state='dismissed'] .card {
  opacity: 0.45;
  filter: saturate(0.6);
}

/* --- Feed view --- */
.feed-header {
  justify-content: space-between;
  margin-bottom: 8px;
}
.feed-header h2 {
  margin: 0;
  font-size: 22px;
}
/* Filter / sort bar under the feed header. */
.feed-filters {
  gap: 8px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.feed-filters select {
  font-size: 13px;
  padding: 7px 10px;
}
.feed-more {
  justify-content: center;
  margin-top: 16px;
}

/* --- Lead detail view --- */
.lead-detail {
  max-width: 720px;
}
.lead-detail .ld-back {
  margin-bottom: 18px;
}
.lead-detail .ld-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 26px 22px;
  overflow: hidden;
}
.lead-detail .ld-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--border-strong);
}
.lead-detail .ld-card[data-signal='switching']::before {
  background: var(--switching);
}
.lead-detail .ld-card[data-signal='comparison']::before {
  background: var(--comparison);
}
.lead-detail .ld-card[data-signal='complaint']::before {
  background: var(--complaint);
}
.lead-detail .ld-card[data-signal='praise']::before {
  background: var(--praise);
}
.lead-detail h2 {
  margin: 12px 0 6px;
  font-size: 24px;
  line-height: 1.25;
}
.lead-detail .ld-link {
  display: inline-block;
  margin-bottom: 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}
.lead-detail .ld-link:hover {
  text-decoration: underline;
}
.lead-detail .ld-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.lead-detail .ld-section h4 {
  margin: 0 0 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
}
.lead-detail .ld-quote {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 16px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
/* Classification key/value grid. */
.ld-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 18px;
  font-size: 14px;
}
.ld-grid dt {
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  align-self: center;
}
.ld-grid dd {
  margin: 0;
  color: var(--text);
}
.ld-score {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: -0.02em;
}

/* Settings sections (Workspace / Account / Billing). A hairline between
   sections rather than a box around each — the panels inside already carry
   .card, and DESIGN.md's rule is that `rule` does the structural work heavier
   borders would. */
.settings-section {
  padding-top: 22px;
  margin-top: 22px;
  border-top: 1px solid var(--border);
}
.settings-section:first-of-type {
  padding-top: 0;
  margin-top: 14px;
  border-top: none;
}
.settings-section:focus {
  outline: none;
}
.settings-section > h3 {
  margin: 0 0 4px;
  font-size: 18px;
}
.settings-section > .hint {
  margin: 0 0 12px;
}

/* Sources screen (#24 part 7) — the discovery proposal checklist. Each row is
   a proposed location the tenant can drop before accepting; reuses .meta for
   the lift/why-you're-seeing-this copy rather than inventing a new style. */
.source-proposal-list {
  list-style: none;
  margin: 0 0 var(--space-sm);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}
.source-proposal-list li {
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.source-proposal-list label {
  display: flex;
  align-items: baseline;
  gap: var(--space-2xs);
  flex-wrap: wrap;
  cursor: pointer;
}
/* WCAG 2.5.8 target size (24x24 CSS px minimum) — the native checkbox
   defaults to ~13-16px otherwise. */
.source-proposal-list input[type='checkbox'] {
  min-width: 24px;
  min-height: 24px;
}

/* Plan badge in the Settings header. Only rendered for the hidden Founder tier
   (ls-config-view keeps it [hidden] for every public plan), so it doubles as
   the in-app "you're a founder" indicator. Gold mirrors admin .plan.founder. */
.plan {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  vertical-align: middle;
  /* It sits inside the Workspace card's .stack (flex column) — without this it
     would stretch to the full card width instead of hugging its label. */
  align-self: flex-start;
}
.plan.founder {
  color: #fcd34d;
  background: rgba(252, 211, 77, 0.08);
  border-color: rgba(252, 211, 77, 0.3);
}
