/* Emissary, Batch P3.
   Mobile first: every rule here is the 390px rule, and the one media query at
   the bottom widens it. Nothing is hidden at small sizes that is shown at
   large, since a source chip that disappears on a phone would defeat D6. */

:root {
  --ink: #1a1a18;
  --ink-soft: #55534d;
  --ink-faint: #86837a;
  --paper: #f7f6f2;
  --card: #fffffe;
  --rule: #ddd9cf;
  --stamp: #9a3412;
  --ok: #3f6212;
  --focus: #1d4ed8;
  --radius: 6px;
  --col: 100%;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 1rem 4rem;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* No horizontal scroll at any width. Long URLs are the usual culprit and are
     handled at the .src-url rule rather than by hiding overflow here. */
  overflow-x: hidden;
}

/* ---------- layout ---------- */

.masthead, .panel { max-width: 46rem; margin-inline: auto; }

.masthead { padding: 2rem 0 1.25rem; }

.masthead h1 {
  margin: 0 0 .35rem;
  font-size: 1.6rem;
  letter-spacing: -.015em;
}

.tagline { margin: 0; color: var(--ink-soft); font-size: .95rem; max-width: 34rem; }

.panel { padding-bottom: 1rem; }

.lede { margin: 0 0 1rem; color: var(--ink-soft); }

.note { margin: .85rem 0 0; color: var(--ink-faint); font-size: .82rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- form ---------- */

.field { margin-bottom: .9rem; }

label {
  display: block;
  margin-bottom: .3rem;
  font-size: .88rem;
  font-weight: 600;
}

.optional { font-weight: 400; color: var(--ink-faint); }

input[type="text"] {
  width: 100%;
  padding: .7rem .75rem;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

input[type="text"]::placeholder { color: #b3afa4; }

button {
  font: inherit;
  border-radius: var(--radius);
  cursor: pointer;
  /* 44px minimum touch target. */
  min-height: 2.75rem;
  padding: .6rem 1.1rem;
}

button.primary {
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  font-weight: 600;
  width: 100%;
}

button.secondary {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
}

button[disabled] { opacity: .55; cursor: default; }

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

/* ---------- candidates ---------- */

.candidates { list-style: none; margin: 0 0 1rem; padding: 0; }

.candidates li { margin-bottom: .7rem; }

/* The whole card is the button, so the tap target on a phone is the card and
   not a link buried in it. */
.candidate {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: .85rem .9rem;
}

.candidate:hover { border-color: var(--ink-faint); }

.candidate .cand-name { font-weight: 650; }

.candidate .cand-role { color: var(--ink-soft); font-size: .9rem; }

.candidate .cand-desc { margin: .4rem 0 .5rem; font-size: .92rem; color: var(--ink-soft); }

/* Its own line, below the source chip. Inline it collides with the chip and
   wraps into it, which reads as one run-on string rather than as an action. */
.candidate .cand-pick {
  display: block;
  margin-top: .5rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--stamp);
}

/* ---------- source chips ---------- */

/* One chip per claim, always. The claim and its chip are one unit so a chip can
   never drift away from what it tags (D6). */
.claim {
  display: block;
  padding: .55rem 0;
  border-top: 1px solid var(--rule);
  font-size: .92rem;
}

.claim:first-child { border-top: 0; }

.claim-text { display: block; }

.src {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  margin-top: .3rem;
  padding: .12rem .45rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper);
  font-size: .72rem;
  letter-spacing: .02em;
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
  max-width: 100%;
}

a.src:hover { border-color: var(--ink-faint); color: var(--ink); }

/* inference and industry_norm are allowed but must look different from a fact
   with a retrieved URL behind it (D6). */
.src[data-src="inference"], .src[data-src="industry_norm"] {
  border-style: dashed;
  color: var(--stamp);
}

.src-url { overflow: hidden; text-overflow: ellipsis; }

/* ---------- results ---------- */

.res-head { margin: 0 0 .3rem; font-size: 1.35rem; letter-spacing: -.01em; }

.res-sub { margin: 0 0 1.25rem; color: var(--ink-soft); }

.section-title {
  margin: 1.75rem 0 .2rem;
  font-size: 1.05rem;
}

.section-note { margin: 0 0 .85rem; color: var(--ink-faint); font-size: .84rem; }

.opp {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: .95rem;
  margin-bottom: .85rem;
}

.opp-rank {
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--stamp);
}

.opp-title { margin: .2rem 0 .6rem; font-size: 1.05rem; line-height: 1.35; }

.opp-row { margin: 0 0 .6rem; font-size: .92rem; }

.opp-row .k {
  display: block;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: .1rem;
}

.est { font-weight: 650; }

.est-basis { color: var(--ink-soft); font-size: .86rem; }

.evidence { margin-top: .7rem; border-top: 1px solid var(--rule); padding-top: .2rem; }

.evidence-label {
  font-size: .74rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-faint);
  padding-top: .4rem; display: block;
}

/* ---------- disclosures (D50: collapsed, never removed) ---------- */

details {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-bottom: .6rem;
}

summary {
  padding: .8rem .9rem;
  cursor: pointer;
  font-weight: 600;
  font-size: .95rem;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

summary .count { font-weight: 400; color: var(--ink-faint); font-size: .86rem; }

.details-body { padding: 0 .9rem .9rem; }

.details-body p { margin: 0 0 .7rem; font-size: .93rem; }

.workflow { margin: .2rem 0 .8rem; padding-left: 1.1rem; font-size: .92rem; color: var(--ink-soft); }

.workflow li { margin-bottom: .3rem; }

.source-item { padding: .5rem 0; border-top: 1px solid var(--rule); font-size: .88rem; }

.source-item:first-child { border-top: 0; }

.source-item a { color: var(--ink); word-break: break-word; }

.source-when { display: block; color: var(--ink-faint); font-size: .78rem; }

/* ---------- the mailto ---------- */

.draft {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: .95rem;
}

/* pre-wrap so the draft's own paragraph breaks survive, in the body font
   rather than monospace: this is prose the user is about to send, not code, and
   the engine writes unwrapped paragraphs that a mail client will re-wrap. */
.draft-body {
  white-space: pre-wrap;
  font-size: .93rem;
  line-height: 1.6;
  margin: 0 0 .9rem;
  overflow-wrap: break-word;
}

.mailto-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2.75rem;
  padding: .7rem 1.1rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
}

.mailto-btn:hover { background: #000; }

.addr-note {
  margin: .7rem 0 0;
  font-size: .84rem;
  color: var(--ink-soft);
}

/* A Hunter.io suggested address (D53): a broker guess, not a public record, so
   it is set apart with a dashed border, the same visual language the soft
   source chips use to say "not a retrieved document". It is text, never a
   button, because the human confirms it before it addresses anything. */
.addr-suggestion {
  margin: .85rem 0 0;
  padding: .7rem .8rem;
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
}

.suggest-email {
  font-weight: 600;
  overflow-wrap: break-word;
  margin-right: .5rem;
}

/* ---------- progress ---------- */

.stages { list-style: none; margin: 0; padding: 0; counter-reset: stage; }

.stage {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  padding: .6rem 0;
  border-top: 1px solid var(--rule);
  font-size: .95rem;
}

.stage:first-child { border-top: 0; }

.stage-mark {
  flex: none;
  width: 1.35rem;
  text-align: center;
  color: var(--ink-faint);
}

.stage[data-state="running"] .stage-mark { color: var(--stamp); }
.stage[data-state="running"] .stage-label { font-weight: 650; }
.stage[data-state="done"] .stage-mark { color: var(--ok); }
.stage[data-state="skipped"] .stage-label,
.stage[data-state="pending"] .stage-label { color: var(--ink-faint); }

.stage-label { flex: 1; }

.stage-when { flex: none; color: var(--ink-faint); font-size: .78rem; font-variant-numeric: tabular-nums; }

.stage-reason { display: block; color: var(--ink-faint); font-size: .8rem; }

@keyframes pulse { 50% { opacity: .35; } }

.stage[data-state="running"] .stage-mark { animation: pulse 1.4s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  .stage[data-state="running"] .stage-mark { animation: none; }
}

/* The run recap on the results view. It reuses the .stage rows the progress
   panel uses, so the two surfaces cannot drift apart, and adds only a frame
   that marks it as a finished record rather than something still moving. */
.recap {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: .35rem .95rem .5rem;
  margin-bottom: 1.4rem;
}

.recap .section-title { margin-top: .75rem; }

.recap-stages .stage { font-size: .88rem; padding: .45rem 0; }

/* ---------- error ---------- */

.error .panel, .panel.error { border-color: var(--stamp); }

#error-message {
  background: var(--card);
  border: 1px solid var(--stamp);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: .8rem .9rem;
  margin: 0 0 1rem;
}

/* ---------- 1280px ---------- */

@media (min-width: 48rem) {
  body { padding-inline: 2rem; }
  .masthead { padding-top: 3rem; }
  .masthead h1 { font-size: 2rem; }
  button.primary { width: auto; min-width: 12rem; }
  .mailto-btn { width: auto; min-width: 18rem; }
  .res-head { font-size: 1.7rem; }
  /* Two of the three form fields sit side by side, since name and company are
     always filled together. */
  .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
}
