/* ==========================================================================
   Engine — the few components Soft Glass does not have.
   Every value here comes from a kit token; there are no colours of our own.
   Load after wh/css/app.css. Keep this file small: anything the kit already
   does belongs in the kit, not here.
   ========================================================================== */

/* --------------------------------------------------------------- utilities */
.eng-block { display: block; }
.eng-mono { font-variant-numeric: tabular-nums; }
.eng-dim { opacity: .55; }
.eng-wrap { white-space: pre-wrap; }

/* ----------------------------------------------------- automation heartbeat
   The one piece of state on every screen: is the clock being held, and is work
   going out. A dot that pulses while automation is actually running. */
.eng-pulse { width: 10px; height: 10px; border-radius: 50%; flex: none; position: relative; background: var(--faint); }
.eng-pulse--run { background: var(--brand); }
.eng-pulse--wait { background: var(--warn); }
.eng-pulse--off { background: var(--faint); }
.eng-pulse--run::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--brand); animation: eng-ping 2s var(--ease) infinite;
}
@keyframes eng-ping { 0% { transform: scale(.7); opacity: .9 } 100% { transform: scale(1.5); opacity: 0 } }
@media (prefers-reduced-motion: reduce) { .eng-pulse--run::after { animation: none; opacity: .4 } }

.eng-state { display: flex; gap: 10px; align-items: center; min-width: 0; }
.eng-state__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.eng-state__text strong { font-size: 13px; }
.eng-state__text span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------- console log
   Job output and restore drills: fixed width, scrollable, never wrapped mid-token. */
.eng-log {
  background: var(--ink); color: var(--toast-fg);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; line-height: 1.55;
  padding: 14px 16px; border-radius: var(--r-md); white-space: pre-wrap; word-break: break-word;
  max-height: 380px; overflow: auto; margin: 0;
}

/* --------------------------------------------------------- playbook editor
   A JSON editor. Monospace, tall, and it keeps the kit's field styling. */
.eng-editor {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px; line-height: 1.55; tab-size: 2; min-height: 420px; resize: vertical;
}
.eng-problems { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 13px; }
.eng-problems li { color: var(--error); }
.eng-problems li.is-ok { color: var(--accent-text); }

/* ---------------------------------------------------------- pairing code */
.eng-paircode {
  font-size: 42px; font-weight: var(--display-weight); letter-spacing: .14em;
  font-variant-numeric: tabular-nums; margin: 0; color: var(--fg);
}

/* --------------------------------------------------------- evidence lists
   Short reasons under a claim: a dot, then one line. */
.eng-facts { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 7px; font-size: 14px; }
.eng-facts li { position: relative; padding-left: 20px; color: var(--muted); }
.eng-facts li::before { content: ""; position: absolute; left: 3px; top: .62em; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.eng-facts li.is-warn::before { background: var(--warn); }
.eng-facts li.is-bad::before { background: var(--error-solid); }

/* ------------------------------------------------------------ provider chain
   The ordered list of AI services a job tries. */
.eng-chain { margin: 0; padding: 0 0 0 18px; display: flex; flex-direction: column; gap: 10px; }
.eng-chain li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.eng-chain li > .wh-affix, .eng-chain li > .wh-input { flex: 1 1 180px; min-width: 0; }

/* --------------------------------------------------------------- quoted text
   Somebody else's words: a prospect's reply, a post being reviewed. */
.eng-quote {
  margin: 0; padding: 10px 14px; border-left: 3px solid var(--line-strong);
  background: var(--surface); border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--fg); font-size: 14px; white-space: pre-wrap;
}

/* ------------------------------------------------------------- map / frames */
.eng-frame { width: 100%; height: 640px; border: 1px solid var(--card-line); border-radius: var(--r-lg); background: var(--surface-solid); }

/* --------------------------------------------------------------- activity */
.eng-feed { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.eng-feed li { display: grid; grid-template-columns: 84px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.eng-feed li:last-child { border-bottom: 0; }
.eng-feed time { color: var(--faint); font-size: 12px; white-space: nowrap; padding-top: 2px; }
@media (max-width: 560px) { .eng-feed li { grid-template-columns: 1fr; gap: 2px } }

/* ------------------------------------------------------------ volume slider */
.eng-slider-readout { font-size: 28px; font-weight: var(--display-weight); letter-spacing: var(--display-tracking); }

/* ------------------------------------------------------------ signing in
   One card on the aurora, as docs/05-app-patterns.md specifies for sign-in. */
.eng-auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.eng-auth__card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 16px; }
.eng-auth__card .wh-logo { margin-bottom: 2px; }
.eng-secret {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 18px; letter-spacing: .08em;
  background: var(--field-bg); border: 1px solid var(--field-line); border-radius: var(--r-field);
  padding: 12px 14px; margin: 0; word-break: break-all;
}

/* ------------------------------------------- the band above a stopped system */
.eng-band { padding: 0 clamp(16px, 3vw, 28px); margin-top: 12px; }
.eng-band__act { margin-left: auto; padding-left: 12px; }
.eng-band .wh-alert { align-items: center; }
.eng-band .wh-alert > span:last-child { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; width: 100%; }

/* The heartbeat line sits at the bottom of the sidebar, above the fold on every screen. */
.wh-side-foot .eng-state { padding: 10px 12px; border: 1px solid var(--card-line); border-radius: var(--r-md); background: var(--card-bg); }
.wh-side-foot .eng-state .wh-btn { margin-left: auto; }

/* A drafted reply waiting for approval: their words, then ours, then the choice. */
.eng-draft { padding: 14px 0; border-top: 1px solid var(--line); }
.eng-draft:first-of-type { border-top: 0; padding-top: 4px; }
.eng-draft textarea { min-height: 140px; }

/* A compact label → figure list for narrow columns, where .wh-set-row would wrap. */
.eng-kv { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; align-items: baseline; }
.eng-kv dt { font-weight: 600; }
.eng-kv dd { margin: 0; font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; }
.eng-kv .eng-kv__note { grid-column: 1 / -1; font-size: 13px; color: var(--faint); padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.eng-kv > :nth-last-child(1).eng-kv__note { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }

/* The recommendation beside an AI job: a full-width alert whose body is a stack. */
.eng-advice { align-items: flex-start; }
.eng-advice p { margin: 0; }
.eng-suggests { display: grid; gap: 4px; margin-top: 8px; }
.eng-suggest { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; padding: 5px 0; border-bottom: 1px solid var(--line); }
.eng-suggest:last-child { border-bottom: 0; }
.eng-suggest code { font-size: 12px; }

/* The actions cell of a table row. The kit's .wh-row-actions is sized for a single
   icon button; Engine's rows carry two or three short text buttons. */
.eng-actions { text-align: right; white-space: nowrap; width: 1%; }
.eng-actions > div { display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }

/* Rows that open a detail page. */
.eng-clickable { cursor: pointer; }
.eng-clickable:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

/* A feed whose entries carry a paragraph rather than one line. */
.eng-feed--wide li { grid-template-columns: 120px 1fr; align-items: start; padding: 12px 0; }
.eng-feed--wide p { margin: 6px 0 0; }
.eng-feed--wide .eng-quote { margin-top: 8px; }
@media (max-width: 640px) { .eng-feed--wide li { grid-template-columns: 1fr } }

/* A reviewed post, or a draft waiting to go out. */
.eng-post { display: flex; flex-direction: column; gap: 10px; padding: 16px 0; border-top: 1px solid var(--line); }
.eng-post:first-of-type { border-top: 0; }
.eng-post p { margin: 0; }
.eng-post mark { background: var(--chip); color: var(--fg); border-radius: 4px; padding: 0 3px; }

/* The connected X accounts, as a row of pickable cards. */
.eng-accts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.eng-acct { text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; cursor: pointer; font: inherit; color: var(--fg); }
.eng-acct.is-selected { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring), var(--card-shadow); }
.eng-acct p { margin: 0; }

/* A disclosure of secondary controls. */
.wh-tools > summary { cursor: pointer; color: var(--accent-text); font-weight: 600; margin: 8px 0; }

/* ------------------------------------------------------------- the installer */
.eng-install { width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 16px; }
.eng-checks { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 14px; }
.eng-checks li { position: relative; padding-left: 26px; }
.eng-checks li::before {
  content: "\2713"; position: absolute; left: 0; top: 0; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
  background: var(--brand-fill); color: var(--on-brand);
}
.eng-checks li.is-bad { color: var(--error); }
.eng-checks li.is-bad::before { content: "\2715"; background: var(--error-solid); color: var(--on-error); }

/* --------------------------------------------- pages a prospect sees, no login */
.eng-public { width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 14px; }
.eng-public h1 { margin: 0; }
.eng-public p { margin: 0; }
.eng-decide { display: flex; gap: 10px; margin-top: 6px; }
.eng-decide .wh-btn { flex: 1; }

/* Group headings inside the installer's fieldsets, so they read above their fields. */
.eng-install .wh-fieldset { display: flex; flex-direction: column; gap: 14px; }
.eng-install .wh-fieldset > legend {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); padding: 0; margin-bottom: 2px;
}
