/* Technocore Worker — core interface
   Dark, compact, instrument-like. Presentation only; all behaviour lives in app.js / wallet-ui.js. */

:root {
  --bg: #0a0d12;
  --bg-raise: #10151e;
  --inset: #0c1017;
  --line: #1d2532;
  --line-2: #2a3441;
  --fg: #e8edf4;
  --fg-muted: #97a2b1;
  --fg-faint: #626d7c;
  --accent: #5cd0e6;
  --action: #6a80ec;
  --action-hi: #8194f2;
  --ok: #5fd39d;
  --warn: #e3b567;
  --err: #f0788b;
  --radius: 12px;
  --radius-sm: 8px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* , *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .82em; }
button { font: inherit; color: inherit; }
::selection { background: rgba(92, 208, 230, .26); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.noscript { background: #4a2530; color: #ffeef0; padding: 11px 16px; text-align: center; font-size: .82rem; }

.shell { width: min(100% - 44px, 640px); margin-inline: auto; }
@media (max-width: 560px) { .shell { width: min(100% - 30px, 640px); } }
@media (max-width: 360px) { .shell { width: calc(100% - 20px); } }

/* ---------- header ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  height: 58px; border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--fg); font-weight: 600; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand img { display: block; width: 26px; height: 26px; }
.brand span { font-size: .92rem; }
.header-meta { display: flex; align-items: center; gap: 16px; font-size: .78rem; }
.header-meta a { color: var(--fg-muted); }
.header-meta a:hover { color: var(--fg); }
.live {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--fg-faint); font: 600 .64rem/1 var(--mono); letter-spacing: .16em; text-transform: uppercase;
}
.live i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ok);
  animation: pulse 2.6s var(--ease) infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(95, 211, 157, .45); }
  70% { box-shadow: 0 0 0 7px rgba(95, 211, 157, 0); }
  100% { box-shadow: 0 0 0 0 rgba(95, 211, 157, 0); }
}

/* ---------- layout + progress stepper ---------- */
.layout { display: block; padding: 30px 0 8px; }
@media (min-width: 720px) { .layout { padding: 40px 0 16px; } }
.rail { margin-bottom: 24px; }
@media (min-width: 720px) { .rail { margin-bottom: 30px; } }

.flow { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; }
.flow li {
  display: flex; align-items: center; gap: 9px; flex: none;
  color: var(--fg-faint); font-size: .74rem; white-space: nowrap;
}
.flow li::before {
  content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%;
  border: 1.5px solid var(--line-2); background: var(--bg);
  transition: border-color .25s var(--ease), background .25s var(--ease), box-shadow .25s var(--ease);
}
.flow li:not(:last-child)::after {
  content: ""; flex: 1 1 auto; min-width: 14px; height: 1.5px; border-radius: 1px;
  background: var(--line-2); margin: 0 11px; transition: background .25s var(--ease);
}
.flow li.current { color: var(--fg); }
.flow li.current::before { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(92, 208, 230, .14); }
.flow li.completed { color: var(--fg-muted); }
.flow li.completed::before { border-color: var(--ok); background: var(--ok); }
.flow li.completed:not(:last-child)::after { background: rgba(95, 211, 157, .42); }

@media (max-width: 560px) {
  .flow li:not(.current) span {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .flow li:not(:last-child)::after { margin: 0 9px; }
}

/* ---------- intro ---------- */
.intro { margin-bottom: 22px; }
.intro h1 { font-size: 1.02rem; font-weight: 600; letter-spacing: -.015em; line-height: 1.38; }
.intro p { margin-top: 7px; color: var(--fg-muted); font-size: .83rem; max-width: 52ch; }
/* The hero only belongs on the first screen; once an identity exists the rail carries context. */
body.job-active .intro,
.content:has(#identity-ready:not([hidden])) .intro { display: none; }
@media (min-width: 720px) { .intro { margin-bottom: 26px; } }

/* ---------- workspace flow (no outer box; sub-states are the surfaces) ---------- */
.workspace { display: block; }
.workspace.job-active #identity-stage,
.workspace.job-active #control-stage { display: none; }
/* Once DID control is demonstrated the progress rail carries that state — drop the panel. */
#control-stage.completed { display: none; }
#github-stage:not([hidden]) { margin-top: 18px; }
#control-stage:not([hidden]) + #github-stage:not([hidden]) { margin-top: 16px; }

.stage-head { margin-bottom: 16px; }
.eyebrow { color: var(--accent); font: 700 .63rem/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; }
.stage-head h2 { margin-top: 9px; font-size: 1.12rem; font-weight: 600; letter-spacing: -.02em; }

#identity-ready:not([hidden]),
#control-stage:not([hidden]),
#github-stage:not([hidden]),
#result-stage:not([hidden]),
#checking:not([hidden]) { animation: rise .28s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* ---------- segmented identity tabs ---------- */
.seg { display: flex; align-items: flex-end; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.seg-btn {
  border: 0; background: none; color: var(--fg-faint); cursor: pointer;
  padding: 8px 2px; margin-right: 20px; margin-bottom: -1px;
  font-size: .82rem; border-bottom: 2px solid transparent; transition: color .15s;
}
.seg-btn:hover { color: var(--fg-muted); }
.seg-btn.active { color: var(--fg); border-bottom-color: var(--accent); }

/* ---------- fields ---------- */
.panel { margin: 0; }
.panel > .btn { margin-top: 16px; }
.field { display: block; }
.field + .field { margin-top: 14px; }
.field-label {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 7px;
  font: 700 .655rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--fg-muted);
}
.field-label small { font: 400 .68rem/1 var(--font); letter-spacing: 0; text-transform: none; color: var(--fg-faint); }
.field input {
  width: 100%; max-width: 460px; height: 40px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--inset); color: var(--fg); font: inherit; font-size: .88rem;
  outline: 0; transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder { color: var(--fg-faint); }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(92, 208, 230, .14); }
.field input[aria-invalid="true"] { border-color: var(--err); }
.field input[type="file"] {
  height: auto; min-height: 40px; padding: 8px 10px; font-size: .8rem; color: var(--fg-muted);
}
.field input[type="file"]::file-selector-button {
  margin-right: 10px; padding: 6px 11px; border: 1px solid var(--line-2); border-radius: 6px;
  background: var(--bg-raise); color: var(--fg); font: inherit; font-size: .78rem; cursor: pointer;
}
.field-grid { display: grid; gap: 14px; }
.field-row { display: grid; gap: 14px; }
@media (min-width: 560px) { .field-row { grid-template-columns: 1fr 1fr; } }
.field-optional .field-label { color: var(--fg-faint); }

.field-hint, .note { margin-top: 8px; font-size: .76rem; color: var(--fg-faint); line-height: 1.5; }
.note.warn { color: var(--warn); }
.field-error { margin-top: 7px; font-size: .76rem; color: var(--err); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 600; letter-spacing: .005em; cursor: pointer; white-space: nowrap;
  text-decoration: none;
  transition: background .14s, border-color .14s, color .14s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn-primary { background: var(--action); color: #fff; box-shadow: 0 1px 0 rgba(255, 255, 255, .13) inset; }
.btn-primary:hover:not(:disabled) { background: var(--action-hi); }
.btn-outline { background: var(--bg-raise); border-color: var(--line-2); color: var(--fg); }
.btn-outline:hover:not(:disabled) { border-color: var(--fg-faint); }
.btn-ghost { background: none; color: var(--accent); padding: 0 8px; min-height: 36px; }
.btn-ghost:hover:not(:disabled) { color: #8fe3f2; text-decoration: underline; }
.btn-quiet { background: none; color: var(--fg-muted); padding: 0 8px; min-height: 36px; font-weight: 500; }
.btn-quiet:hover:not(:disabled) { color: var(--fg); }
.btn-lg { min-height: 46px; padding: 0 22px; font-size: .9rem; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: .78rem; }
.actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- disclosure ---------- */
.disclose { margin-top: 16px; }
.disclose summary {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  color: var(--fg-muted); font-size: .78rem; list-style: none;
}
.disclose summary::-webkit-details-marker { display: none; }
.disclose summary::before {
  content: ""; flex: none; width: 5px; height: 5px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); transition: transform .18s var(--ease);
}
.disclose[open] summary::before { transform: rotate(45deg); }
.disclose summary:hover { color: var(--fg); }
.disclose:not(.provenance) > p { margin-top: 11px; color: var(--fg-muted); font-size: .8rem; line-height: 1.55; max-width: 64ch; }

/* ---------- identity ready / DID control (raised inset artifacts) ---------- */
.ready-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 13px; align-items: start;
  padding: 15px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--inset);
}
.tick {
  grid-row: span 2; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(95, 211, 157, .14); color: var(--ok);
  display: grid; place-items: center; font-size: .78rem; font-weight: 700;
}
.ready-main { min-width: 0; }
.ready-main strong { display: block; font-size: .9rem; }
.ready-main code {
  display: block; margin-top: 5px; color: var(--fg-muted); font-size: .78rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ready-main .hint { margin-top: 7px; font-size: .75rem; color: var(--fg-faint); }
.ready-actions { grid-column: 2; display: flex; gap: 10px; flex-wrap: wrap; margin-top: 9px; }
@media (max-width: 520px) {
  .ready-actions { grid-column: 1 / -1; }
  .ready-actions .btn { flex: 1; }
}

.proc-row {
  display: flex; align-items: center; gap: 13px; margin-top: 14px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--inset);
}
.proc-main { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.proc-main strong { font-size: .82rem; font-weight: 650; }
.proc-main p { margin: 0; color: var(--fg-muted); font-size: .8rem; }
.spinner {
  flex: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#control-stage.completed .spinner {
  border: 0; animation: none; background: rgba(95, 211, 157, .16); position: relative;
}
#control-stage.completed .spinner::after {
  content: "\2713"; position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--ok); font-size: .74rem; font-weight: 700;
}

/* ---------- checking / execution ---------- */
.job { margin-top: 4px; }
.job-target h2 { font-size: 1.05rem; font-weight: 600; letter-spacing: -.015em; overflow-wrap: anywhere; }
.job-target code { display: block; margin-top: 7px; color: var(--fg-muted); font-size: .8rem; overflow-wrap: anywhere; }
.execution { list-style: none; margin: 18px 0 0; padding: 0; display: grid; }
.execution li {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 11px 2px; color: var(--fg-faint); font-size: .83rem; border-top: 1px solid var(--line);
}
.execution li:first-child { border-top: 0; }
.execution li::before {
  content: ""; flex: none; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line-2);
  transition: background .2s, border-color .2s;
}
.execution li.done { color: var(--fg-muted); }
.execution li.done::before { border-color: var(--ok); background: var(--ok); }
.execution li.active { color: var(--fg); }
.execution li.active::before { border-color: var(--accent); }
.execution li[data-step="waiting"] { display: grid; grid-template-columns: 18px 1fr auto; align-items: center; overflow: hidden; }
.execution li[data-step="waiting"]::before { display: none; }
.execution li[data-step="waiting"]::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 1.5px; width: 38%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: indeterminate 1.7s var(--ease) infinite;
}
@keyframes indeterminate { 0% { transform: translateX(-110%); } 100% { transform: translateX(330%); } }
.execution time { color: var(--fg-faint); font: .78rem var(--mono); }
.activity { display: inline-flex; align-items: center; gap: 3px; width: 16px; }
.activity i {
  width: 4px; height: 4px; border-radius: 50%; background: var(--accent);
  animation: bob 1.1s var(--ease) infinite;
}
.activity i:nth-child(2) { animation-delay: .14s; }
.activity i:nth-child(3) { animation-delay: .28s; }
@keyframes bob {
  0%, 72%, 100% { opacity: .25; transform: translateY(0); }
  36% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- result footer + neutral result ---------- */
.result-foot {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  margin-top: 16px; flex-wrap: wrap;
}
.result-foot .btn-ghost { padding-left: 0; }
.result-foot .disclose { margin-top: 0; }
.neutral-result .stage-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.neutral-result .stage-head h2 { margin-top: 0; }
.muted-time { margin-left: auto; color: var(--fg-faint); font: .76rem var(--mono); }
.neutral-result .micro { margin-top: 14px; }
.neutral { color: var(--fg-faint); }

/* ---------- shared small text ---------- */
.micro { color: var(--fg-faint); font-size: .72rem; line-height: 1.55; }
.muted { color: var(--fg-muted); }
.feedback { min-height: 1.1em; margin-top: 10px; color: var(--ok); font-size: .76rem; }
.feedback:empty { display: none; }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line); margin-top: 34px; padding: 20px 0 44px;
  color: var(--fg-faint); font-size: .72rem; display: grid; gap: 9px;
}
.foot-line { display: flex; flex-wrap: wrap; gap: 6px 24px; }
.foot-line span { display: inline-flex; align-items: baseline; gap: 6px; min-width: 0; max-width: 100%; }
.foot-line code { color: var(--fg-muted); overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .foot-line { gap: 5px; }
  .foot-line span { display: block; }
}
.foot-line a { color: var(--fg-muted); }
.foot-line a:hover { color: var(--fg); }
.foot-fine { line-height: 1.55; }
.foot-fine a { color: var(--fg-muted); }
.foot-fine a:hover { color: var(--fg); }

/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .activity i, .spinner, .live i,
  .execution li.active::after,
  .execution li[data-step="waiting"]::after { animation: none !important; }
  .execution li[data-step="waiting"]::after { width: 100%; opacity: .3; }
}
