/*
 * Copyright (c) 2026 Edward Boggis-Rolfe. All rights reserved.
 *
 * Lokorium demo styles, from the Lokorium identity specification v1.0 (August 2026).
 * The identity defines the ground, wordmark, signal green and dimmed red; the surface
 * and text greys below are derived from them for product UI.
 */

:root {
  /* Identity colours */
  --ground: #0e110f;
  --wordmark: #f2f4f2;
  --signal: #7fe0a8;
  --signal-light: #1b8f55;
  --refusal: #e0806f;
  --refusal-light: #b4503c;
  --divider: #313834;

  /* Derived UI colours */
  --surface: #151916;
  --surface-raised: #1b201c;
  --surface-sunken: #0a0c0b;
  --ink: var(--wordmark);
  --muted: #9aa39d;
  --faint: #66706a;
  --signal-tint: rgba(127, 224, 168, 0.1);
  --refusal-tint: rgba(224, 128, 111, 0.1);

  --sans: Archivo, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 4px;
  --gap: 16px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--signal);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  font-weight: 500;
  line-height: 1.2;
  margin: 0 0 12px;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

p {
  margin: 0 0 12px;
}

/* ---- Wordmark: canonical construction from the identity specification ---- */

.lkr-logo {
  font-family: Archivo, sans-serif;
  font-weight: 500;
  font-size: 18px; /* 14px minimum */
  letter-spacing: 0.22em;
  line-height: 1;
  white-space: nowrap;
  color: var(--wordmark);
}

.lkr-stop {
  letter-spacing: 0;
  margin-left: -0.08em;
  font-size: 1.35em;
  color: var(--signal);
}

.lkr-lockup {
  display: flex;
  align-items: center;
}

.lkr-descriptor {
  margin-left: 18px;
  padding-left: 18px;
  border-left: 1px solid var(--divider);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.lkr-strapline {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 12px;
}

/* ---- Page frame ---- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 18px 24px;
  border-bottom: 1px solid var(--divider);
}

.topbar nav {
  display: flex;
  gap: 20px;
  font-size: 13px;
  margin-left: auto;
}

.topbar nav a {
  color: var(--muted);
}

.topbar nav a[aria-current="page"] {
  color: var(--ink);
}

.demo-banner {
  padding: 6px 24px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--divider);
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--signal);
  margin-bottom: 8px;
}

.lede {
  color: var(--muted);
  max-width: 64ch;
}

.mono {
  font-family: var(--mono);
}

.muted {
  color: var(--muted);
}

/* ---- Layout ---- */

.grid {
  display: grid;
  gap: var(--gap);
}

.grid.two {
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .grid.two,
  .grid.three {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar {
    flex-wrap: wrap;
  }

  .lkr-descriptor {
    display: none;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 20px;
}

.panel + .panel {
  margin-top: var(--gap);
}

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title h2 {
  margin: 0;
}

/* ---- Forms ---- */

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.field label {
  font-size: 13px;
  color: var(--muted);
}

.field .hint {
  font-size: 12px;
  color: var(--faint);
}

input,
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface-sunken);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 10px 12px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--signal);
}

input.numeric {
  font-family: var(--mono);
  text-align: right;
}

input[type="date"] {
  color-scheme: dark;
}

textarea {
  min-height: 140px;
  resize: vertical;
}

.field.invalid input,
.field.invalid textarea {
  border-color: var(--refusal);
}

.field .error {
  font-size: 12px;
  color: var(--refusal);
}

.fieldrow {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
}

@media (max-width: 600px) {
  .fieldrow {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---- Buttons ---- */

.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--divider);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}

.button:hover {
  border-color: var(--muted);
  text-decoration: none;
}

.button.primary {
  background: var(--signal);
  border-color: var(--signal);
  color: var(--ground);
}

.button.primary:hover {
  filter: brightness(1.08);
}

.button.refuse {
  color: var(--refusal);
  border-color: var(--refusal);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

/* ---- Status tags ---- */

.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 2px;
  border: 1px solid var(--divider);
  color: var(--muted);
  white-space: nowrap;
  align-self: start;
}

.tag.permitted {
  color: var(--signal);
  border-color: var(--signal);
  background: var(--signal-tint);
}

.tag.blocked {
  color: var(--refusal);
  border-color: var(--refusal);
  background: var(--refusal-tint);
}

.tag.referred {
  color: var(--ink);
  border-color: var(--muted);
}

.tag.uncertain {
  color: var(--muted);
  border-style: dashed;
}

/* ---- Key-value lists ---- */

dl.kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 18px;
  margin: 0;
  font-size: 13px;
}

dl.kv dt {
  color: var(--muted);
}

dl.kv dd {
  margin: 0;
  font-family: var(--mono);
  overflow-wrap: anywhere;
}

/* ---- Tables ---- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 400;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--divider);
}

td {
  padding: 10px;
  border-bottom: 1px solid var(--divider);
  vertical-align: top;
}

td.amount {
  font-family: var(--mono);
  text-align: right;
  white-space: nowrap;
}

tr.new-row td {
  animation: row-in 1.2s ease-out;
}

@keyframes row-in {
  from {
    background: var(--signal-tint);
  }
  to {
    background: transparent;
  }
}

.table-scroll {
  overflow-x: auto;
}

/* ---- Processing pipeline ---- */

.pipeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pipeline li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
  color: var(--faint);
  transition: color 0.3s;
}

.pipeline li:last-child {
  border-bottom: 0;
}

.pipeline .dot {
  width: 10px;
  height: 10px;
  margin: 6px 6px 0;
  border-radius: 50%;
  border: 1px solid var(--faint);
}

.pipeline .step-name {
  font-weight: 500;
}

.pipeline .step-detail {
  font-size: 12px;
  font-family: var(--mono);
}

.pipeline li.active {
  color: var(--ink);
}

.pipeline li.active .dot {
  border-color: var(--signal);
  animation: pulse 1s ease-in-out infinite;
}

.pipeline li.done {
  color: var(--ink);
}

.pipeline li.done .dot {
  background: var(--signal);
  border-color: var(--signal);
}

.pipeline li.done .step-detail {
  color: var(--muted);
}

.pipeline li.refused .dot {
  background: var(--refusal);
  border-color: var(--refusal);
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(127, 224, 168, 0.5);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(127, 224, 168, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pipeline li.active .dot,
  tr.new-row td {
    animation: none;
  }
}

/* ---- Live log ---- */

.log {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-sunken);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 12px;
  height: 360px;
  overflow-y: auto;
}

.log-line {
  display: grid;
  grid-template-columns: 74px 120px minmax(0, 1fr);
  gap: 10px;
  padding: 3px 0;
  color: var(--muted);
}

.log-line .who {
  color: var(--ink);
}

.log-line.ok .what {
  color: var(--signal);
}

.log-line.refused .what {
  color: var(--refusal);
}

/* ---- Attestation certificate ---- */

.certificate {
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  background: var(--surface-sunken);
  padding: 20px;
}

.certificate header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--divider);
}

.certificate .backend-warning {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}

/* ---- Review screen ---- */

.quote {
  border-left: 2px solid var(--divider);
  padding: 4px 0 4px 14px;
  color: var(--ink);
  font-size: 15px;
}

.evidence-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.evidence-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
  font-size: 13px;
}

.evidence-list li:last-child {
  border-bottom: 0;
}

.proposed-action {
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.proposed-action .head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.confidence {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.confidence .bar {
  flex: 1;
  height: 4px;
  background: var(--divider);
  border-radius: 2px;
  position: relative;
}

.confidence .bar span {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--muted);
  border-radius: 2px;
}

.confidence .threshold {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 1px;
  background: var(--signal);
}

.conflict {
  border: 1px dashed var(--refusal);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13px;
}

/* Another open case on the account that changes a different record. */
.conflict.none {
  border-color: var(--divider);
  color: var(--muted);
}

/* ---- Sign-in ---- */

.signin {
  max-width: 420px;
  margin: 72px auto 0;
}

.signin .lkr-logo {
  font-size: 28px;
}

.role-links {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.role-links a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  color: var(--ink);
}

.role-links a:hover {
  border-color: var(--signal);
  text-decoration: none;
}

.role-links .muted {
  font-size: 13px;
}

/* ---- Case list ---- */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 14px;
}

.tabs button,
.chip {
  font: inherit;
  font-size: 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.tabs button {
  padding: 10px 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tabs button[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--signal);
}

.tabs span,
.chip span {
  font-family: var(--mono);
  font-size: 11px;
  margin-left: 8px;
  color: var(--faint);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  font-size: 13px;
  padding: 5px 12px;
  border: 1px solid var(--divider);
  border-radius: 999px;
}

.chip:hover:not(:disabled) {
  border-color: var(--muted);
  color: var(--ink);
}

.chip[aria-pressed="true"] {
  color: var(--ink);
  border-color: var(--signal);
  background: var(--signal-tint);
}

.chip:disabled {
  opacity: 0.4;
  cursor: default;
}

table.cases tbody tr {
  cursor: pointer;
}

table.cases tbody tr:hover td {
  background: var(--surface-raised);
}

table.cases td:first-child,
table.cases th:first-child {
  padding-left: 20px;
}

table.cases tr.overdue td:first-child {
  box-shadow: inset 2px 0 0 var(--refusal);
}

.overdue-flag {
  font-size: 11px;
  color: var(--refusal);
  margin-left: 6px;
}

/* ---- Disabled controls ---- */

input:disabled,
select:disabled,
textarea:disabled {
  color: var(--muted);
  background: transparent;
  border-style: dashed;
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

table.cases td.mono {
  white-space: nowrap;
}

/* ---- Attestation button and panel (attestation-panel.js) ---- */

.attestation-button {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 7px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.attestation-button:hover {
  color: var(--ink);
  border-color: var(--muted);
}

.attestation-button[data-attestation-state="simulated"] {
  border-style: dashed;
  color: var(--ink);
}

.attestation-button[data-attestation-state="accepted"] {
  color: var(--signal);
  border-color: var(--signal);
}

.attestation-button[data-attestation-state="rejected"] {
  color: var(--refusal);
  border-color: var(--refusal);
}

.attestation-button.floating {
  position: fixed;
  top: 40px;
  right: 24px;
  background: var(--ground);
}

.attestation-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 24px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
}

.attestation-dialog::backdrop {
  background: rgba(14, 17, 15, 0.75);
}

.attestation-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.attestation-heading h2 {
  margin: 0;
}

.attestation-dialog h3 {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 20px 0 10px;
}

.attestation-close {
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.attestation-status {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  padding: 10px 12px;
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  margin: 0 0 10px;
}

.attestation-status.simulated {
  border-style: dashed;
}

.attestation-status.accepted {
  color: var(--signal);
  border-color: var(--signal);
  background: var(--signal-tint);
}

.attestation-status.rejected {
  color: var(--refusal);
  border-color: var(--refusal);
  background: var(--refusal-tint);
}

.attestation-detail,
.attestation-boundary {
  font-size: 13px;
  color: var(--muted);
}

.attestation-dialog dl.kv code {
  font-family: var(--mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.attestation-boundary {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--divider);
}

/* ---- Live case permission and evidence ---- */

.evidence-help {
  padding: 0;
  border: 0;
  border-bottom: 1px dotted var(--muted);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: help;
}

.evidence-help:hover,
.evidence-help:focus-visible {
  color: var(--signal);
}

.evidence-help:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 4px;
}

.evidence-tooltip {
  position: fixed;
  z-index: 10;
  width: min(320px, calc(100vw - 24px));
  padding: 12px 14px;
  border: 1px solid var(--signal);
  border-radius: 8px;
  background: var(--surface-raised);
  box-shadow: 0 6px 24px #0008;
  color: var(--ink);
  font: 13px/1.5 var(--sans);
}

.case-records > .certificate {
  margin-bottom: var(--gap);
}

.permission-button {
  margin-top: 10px;
  font-size: 12px;
}

.permission-dialog {
  width: min(860px, calc(100vw - 32px));
}

.permission-signature {
  margin-top: 20px;
  padding: 0 16px 16px;
  border: 1px dashed var(--divider);
  border-radius: var(--radius);
  background: var(--surface-sunken);
}

.permission-evidence {
  margin-top: 20px;
  border: 1px solid var(--divider);
  border-radius: var(--radius);
}

.permission-evidence summary {
  padding: 14px 16px;
  cursor: pointer;
  color: var(--signal);
}

.permission-evidence summary span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.permission-evidence-body {
  padding: 16px;
  border-top: 1px solid var(--divider);
}

.decision-code {
  padding: 14px;
  background: var(--surface-sunken);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  font: 12px/1.6 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.permission-conclusion {
  margin: 16px 0 0;
  font-size: 13px;
}

@media (max-width: 540px) {
  .permission-dialog {
    padding: 16px;
  }

  .permission-dialog dl.kv {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .permission-dialog dl.kv dd {
    margin-bottom: 10px;
  }

  .permission-dialog .evidence-list li {
    grid-template-columns: minmax(0, 1fr);
    justify-items: start;
  }
}
