/* This file is part of Beekeeper (AGPL-3.0-or-later). */

/* The colour profile: GET /config's colors, which src/lib/colors.ts sets on
   the root element through the CSSOM (they then take precedence over these),
   and until then GNU Taler's colours, the server's defaults
   (conformance/colors.json; the web tests compare the two). */
:root {
  --light-primary: #0042b3;
  --light-on-primary: #ffffff;
  --light-primary-container: #d3deff;
  --light-on-primary-container: #00134a;
  --light-secondary: #586a88;
  --light-on-secondary: #ffffff;
  --light-secondary-container: #d9e3f9;
  --light-on-secondary-container: #111c2b;
  --light-error: #b3261e;
  --light-on-error: #ffffff;
  --light-success: #337a40;
  --light-on-success: #ffffff;
  --light-warning: #875200;
  --light-on-warning: #ffffff;
  --light-background: #fdfdff;
  --light-on-background: #1a1c1f;
  --light-surface: #f0f0f4;
  --light-on-surface: #1c1b1f;
  --light-on-surface-variant: #45474f;
  --light-outline: #767880;
  --light-outline-variant: #c4c6d0;
  --dark-primary: #b4c5ff;
  --dark-on-primary: #002a78;
  --dark-primary-container: #0042b3;
  --dark-on-primary-container: #e5ebff;
  --dark-secondary: #a4c9ff;
  --dark-on-secondary: #00315d;
  --dark-secondary-container: #414659;
  --dark-on-secondary-container: #e3e2e9;
  --dark-error: #ffb4aa;
  --dark-on-error: #690003;
  --dark-success: #81c784;
  --dark-on-success: #003912;
  --dark-warning: #f99c06;
  --dark-on-warning: #000000;
  --dark-background: #11131a;
  --dark-on-background: #e2e2eb;
  --dark-surface: #202226;
  --dark-on-surface: #e5e2e1;
  --dark-on-surface-variant: #a7adb7;
  --dark-outline: #8f9199;
  --dark-outline-variant: #45474f;
}

/* The roles drawn with, in the scheme that the browser asks for.  Only the
   recording dot and the hints over the camera picture keep colours of their
   own, as they are drawn on the picture. */
:root {
  --bg: var(--light-background);
  --fg: var(--light-on-background);
  --card: var(--light-surface);
  --card-fg: var(--light-on-surface);
  --muted: var(--light-on-surface-variant);
  --line: var(--light-outline-variant);
  --outline: var(--light-outline);
  --accent: var(--light-primary);
  --accent-fg: var(--light-on-primary);
  --secondary: var(--light-secondary);
  --secondary-container: var(--light-secondary-container);
  --secondary-container-fg: var(--light-on-secondary-container);
  --error: var(--light-error);
  --ok: var(--light-success);
  --warn: var(--light-warning);
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--dark-background);
    --fg: var(--dark-on-background);
    --card: var(--dark-surface);
    --card-fg: var(--dark-on-surface);
    --muted: var(--dark-on-surface-variant);
    --line: var(--dark-outline-variant);
    --outline: var(--dark-outline);
    --accent: var(--dark-primary);
    --accent-fg: var(--dark-on-primary);
    --secondary: var(--dark-secondary);
    --secondary-container: var(--dark-secondary-container);
    --secondary-container-fg: var(--dark-on-secondary-container);
    --error: var(--dark-error);
    --ok: var(--dark-success);
    --warn: var(--dark-warning);
  }
}

/* A little darker (lighter, in the dark) than a card: boxes and hovered rows
   on one. */
:root { --tint: var(--bg); }
@supports (color: color-mix(in srgb, red, blue)) {
  :root { --tint: color-mix(in srgb, var(--card) 94%, var(--card-fg)); }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.app { max-width: 46rem; margin: 0 auto; padding: 0 1rem 4rem; }
.app.admin { max-width: 72rem; }

header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 0; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--fg); text-decoration: none; display: inline-flex; align-items: center; gap: 0.75rem; }
/* The server's logo (GET /config), 40 pixels high at most, in its own
   proportions. */
.brand picture { display: contents; }
.brand .logo { height: 2.5rem; width: auto; max-width: min(14rem, 50vw); object-fit: contain; display: block; }
header nav { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
header nav a { color: var(--fg); text-decoration: none; padding: 0.2rem 0.4rem; border-radius: 6px; }
/* The current entry, as Material's navigation indicator. */
header nav a.active, .link.active { background: var(--secondary-container); color: var(--secondary-container-fg); }

h1 { font-size: 1.6rem; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.2rem; margin: 0.5rem 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
code, pre, .code { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0.25rem 0; }

.card {
  background: var(--card); color: var(--card-fg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.25rem; margin: 0 0 1rem;
}
.card.narrow { max-width: 28rem; margin: 2rem auto; }
ul.cards { list-style: none; padding: 0; }

label { display: block; margin: 0.5rem 0; }
label.option { display: flex; gap: 0.5rem; align-items: flex-start; margin: 0.35rem 0; }
.label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.help { color: var(--muted); margin: 0 0 0.4rem; }

input, select, textarea {
  font: inherit; color: var(--card-fg); background: var(--card);
  border: 1px solid var(--outline); border-radius: 8px; padding: 0.55rem 0.7rem; width: 100%;
}
input[type="checkbox"], input[type="radio"] { width: auto; margin-top: 0.3rem; accent-color: var(--accent); }
[aria-invalid="true"] { border-color: var(--error); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* A secondary action ("Back", "Cancel"): outlined, labelled in PRIMARY, as
   Material's outlined button and the Taler wallet's. */
button, .button {
  display: inline-block; font: inherit; cursor: pointer; text-decoration: none; text-align: center;
  border: 1px solid var(--outline); background: transparent; color: var(--accent);
  border-radius: 8px; padding: 0.55rem 1rem; min-height: 2.75rem;
}
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
button.danger { border-color: var(--error); color: var(--error); }
button.link { border: none; background: none; color: var(--accent); padding: 0.2rem 0.3rem; min-height: 0; }
button:disabled { opacity: 0.55; cursor: default; }

.actions { display: flex; gap: 0.75rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1.5rem; }

/* A question before going on (ConfirmDialog), over the inert page. */
dialog.confirm {
  background: var(--card); color: var(--card-fg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem 1.5rem; width: min(26rem, calc(100vw - 2rem)); max-width: none;
}
dialog.confirm::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog.confirm .dialog-message { font-size: 1.15rem; font-weight: 600; margin: 0; }
dialog.confirm .actions { margin-top: 1.25rem; }
.row { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; }
.filters { margin-bottom: 1rem; }

.field { margin: 1.25rem 0; }
.field.has-problem { border-left: 3px solid var(--error); padding-left: 0.75rem; }
.field.info h2 { margin-top: 1.5rem; }
.field-errors { color: var(--error); margin: 0.3rem 0 0; padding-left: 1.2rem; }
.flag { color: var(--warn); font-weight: 600; }
.verified { color: var(--ok); font-weight: 600; }
.options.buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
/* A choice shown as buttons: chips, the selected one filled as Material's
   filter chip. */
.options.buttons label.option { border: 1px solid var(--outline); border-radius: 8px; padding: 0.4rem 0.8rem; }
.options.buttons label.option:has(input:checked) {
  background: var(--secondary-container); color: var(--secondary-container-fg); border-color: var(--secondary);
}
.with-unit { display: flex; gap: 0.5rem; align-items: center; }
.with-unit input { max-width: 12rem; }
fieldset.address { border: none; padding: 0; margin: 0; }
.verify { margin-top: 0.5rem; }

.notice { border-radius: 8px; padding: 0.75rem 1rem; margin: 1rem 0; border: 1px solid; }
.notice.error { color: var(--error); border-color: var(--error); }
.notice.ok { color: var(--ok); border-color: var(--ok); }
.notice.warn { color: var(--warn); border-color: var(--warn); }
.notice.info { border-color: var(--line); }
/* Research mode: the notice of a capture whose recordings are preserved,
   held in view above the camera while it runs.  Theme colours only. */
.notice.research-notice { font-weight: 600; border-width: 2px; background: var(--card); }
.notice.research-notice.live { position: sticky; top: 0; z-index: 2; margin: 0 0 0.5rem; }
.badge { display: inline-block; border: 1px solid currentColor; border-radius: 999px; padding: 0 0.6rem; font-size: 0.85rem; text-decoration: none; color: var(--secondary); }
.badge.warn { color: var(--warn); }
/* Admin: research profiles, an original analysis beside its re-run. */
.analysis-outcome.passed, table.compare td.passed { color: var(--ok); }
.analysis-outcome.failed, table.compare td.failed { color: var(--error); }
.analysis-outcome.review, table.compare td.review, table.compare td.inconclusive { color: var(--warn); }

progress { width: 100%; height: 0.5rem; accent-color: var(--accent); }
.progress-text { color: var(--muted); margin: 0; font-size: 0.9rem; }
.summary li.todo a { font-weight: 600; }
.link-box { overflow-wrap: anywhere; background: var(--tint); padding: 0.5rem; border-radius: 6px; }
/* "Start in the app": the QR code stays dark on white in either scheme. */
svg.qr { display: block; width: min(18rem, 100%); height: auto; margin: 1rem auto; border-radius: 6px; }
.actions.start { justify-content: flex-start; margin-top: 1rem; }
.in-app-progress progress { width: 100%; }
.admin-link { margin-top: 2rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.state { font-size: 0.9rem; }

.video .stage { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; }
.video video, .media { width: 100%; max-height: 70vh; display: block; }
/* Thumbnails in the admin UI (review.tsx): each opens the file in full. */
.thumbs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.25rem 0; }
.thumb { padding: 0; border: 0; background: none; cursor: pointer; line-height: 0; }
.thumb img { max-width: 240px; max-height: 180px; border-radius: 6px; display: block; }
.video video.mirror { transform: scaleX(-1); }
.video .prompt {
  position: absolute; left: 0; right: 0; bottom: 1rem; text-align: center; font-size: 1.6rem; font-weight: 700;
  color: #fff; text-shadow: 0 2px 6px #000;
}
.stage { position: relative; }
.stage .caption {
  position: absolute; left: 0; right: 0; bottom: 1rem; text-align: center; font-size: 1.2rem; font-weight: 600;
  color: #fff; text-shadow: 0 2px 6px #000; white-space: pre-line; pointer-events: none;
}
.cues { font-size: 0.9rem; }
.cues td:first-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.video .hint { position: absolute; top: 0.75rem; left: 0; right: 0; text-align: center; color: #ffd24d; font-weight: 600; text-shadow: 0 1px 4px #000; }
.video .rec { position: absolute; top: 0.75rem; right: 0.75rem; width: 0.9rem; height: 0.9rem; border-radius: 50%; background: #e53935; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
@media (prefers-reduced-motion: reduce) { .video .rec { animation: none; } }
.photo img { max-width: 100%; max-height: 16rem; border-radius: 8px; display: block; margin: 0.5rem 0; }

table { width: 100%; border-collapse: collapse; background: var(--card); color: var(--card-fg); }
th, td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--tint); }
dl dt { font-weight: 600; margin-top: 0.75rem; }
dl dd { margin: 0.25rem 0 0; }
.analysis { border-left: 3px solid var(--line); padding-left: 0.75rem; margin-top: 0.5rem; }
.analysis.failed { border-color: var(--error); }
.analysis.passed { border-color: var(--ok); }
.analysis.review { border-color: var(--warn); }
.analysis li.failed { color: var(--error); }
.analysis li.inconclusive { color: var(--warn); }

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

/* Admin: a secret shown once, dimmed rows. */
code.secret { word-break: break-all; user-select: all; }
tr.muted td { opacity: 0.6; }
.scan { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; margin: 0 auto; }
.scan video { width: 100%; height: 100%; display: block; object-fit: cover; }
.scan .doc-frame { position: absolute; border: 3px solid rgba(255, 255, 255, 0.9); border-radius: 10px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45); }
.scan .mrz-band { position: absolute; left: 4%; right: 4%; bottom: 5%; height: 22%; border: 2px dashed #ffd24d; border-radius: 6px; }
.scan .hint { position: absolute; top: 0.5rem; left: 0.5rem; right: 0.5rem; text-align: center; color: #fff; font-weight: 600; text-shadow: 0 1px 4px #000; }
.mrz-fields dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 1rem; align-items: baseline; margin: 0.25rem 0 0.75rem; }
.mrz-fields dt { color: var(--muted); font-weight: normal; margin: 0; }
.mrz-fields dd { margin: 0; font-weight: 600; }
.photo .actions { align-items: center; margin-top: 0.75rem; }
.photo .actions > * { margin: 0; }

/* The record of a submitted assignment ("View"). */
.record { margin-top: 1.5rem; }
.record h2 { font-size: 1.15rem; }
.record-page { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 0.5rem; }
.record-page h3 { font-size: 1rem; margin: 0.25rem 0; }
.record-page > dl > dd p { margin: 0.25rem 0 0; }
.multiline { white-space: pre-wrap; }
.record-files { list-style: none; padding: 0; margin: 0; }
.record-files li + li { margin-top: 0.5rem; }
.record-photos { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.record-image { max-width: 100%; max-height: 14rem; border-radius: var(--radius); }
.record-video { width: 100%; border-radius: var(--radius); background: #000; }

/* Admin: the audit log.  Objects and details are long words (ids, JSON
   without spaces) that would otherwise widen the table past the page; the
   time, actor and action stay on one line. */
table.audit td { white-space: nowrap; }
table.audit td:nth-child(n+4) { white-space: normal; overflow-wrap: anywhere; }
table.audit td:last-child { width: 45%; }

/* Lookups (form-dsl.md, "Lookups"): the record a register confirmed, and
   where each proposed row came from. */
.lookup label, .lookup-search label { display: block; margin-top: 0.5rem; }
.lookup .hint { color: var(--warn); }
.record-card {
  margin-top: 0.75rem; padding: 0.5rem 0.9rem; border: 1px solid var(--line);
  border-left: 4px solid var(--ok); border-radius: var(--radius); background: var(--card);
}
.record-card p { margin: 0.25rem 0; }
.record-card .small { font-size: 0.875rem; }
ul.candidates { list-style: none; padding: 0; }
ul.candidates li { margin: 0.25rem 0; }
legend .origin { font-weight: normal; color: var(--muted); }
legend .origin.registered { color: var(--ok); }
.list-row.removed { padding: 0.5rem 0; color: var(--muted); }
.retrieve { margin-top: 0.5rem; }

/* The structure of a case (lib/structure.tsx): boxes for subjects, lines
   for links, coloured by what a link rests on. */
.structure-drawing { max-width: 100%; height: auto; display: block; margin: 0.5rem 0; }
.structure-drawing text { font-size: 13px; fill: var(--card-fg); }
.structure-drawing .subject rect { fill: var(--card); stroke: var(--outline); stroke-width: 1; }
.structure-drawing .subject.root rect { stroke-width: 2.5; }
.structure-drawing .subject.labelled rect { stroke: var(--ok); stroke-width: 2; }
.structure-drawing .subject .name { font-weight: 600; }
.structure-drawing .subject .label { fill: var(--muted); }
.structure-drawing .subject.clickable { cursor: pointer; }
.structure-drawing .link path { fill: none; stroke: var(--outline); stroke-width: 1.5; }
.structure-drawing .link.source_data path { stroke: var(--ok); }
.structure-drawing .link.cycle path { stroke-dasharray: 4 3; stroke: var(--warn); }
.structure-drawing .arrow-head { fill: var(--outline); }
.structure-drawing .link-label { fill: var(--muted); font-size: 12px; }
.structure-outline { list-style: none; padding: 0; }
.structure-outline li { margin: 0.2rem 0; }
.structure-outline .tag { color: var(--ok); font-weight: 600; }
.structure-outline .share { color: var(--muted); }
.declaration ul { padding-left: 1.2rem; }
.declaration .statement { font-style: italic; }
.declaration .tag { color: var(--ok); font-weight: 600; }
.declaration .ok { color: var(--ok); font-weight: 600; }

/* Documents (app/documents.tsx): page thumbnails, a page in full, the
   waiting stage. */
.page-thumbs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0; }
.page-thumbs .thumb { padding: 0; border: 1px solid var(--line); background: var(--card); }
.page-thumbs .thumb img { height: 96px; display: block; }
.page-view { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.75); display: flex; align-items: center; justify-content: center; z-index: 50; }
.page-view img { max-width: 95vw; max-height: 95vh; background: #fff; }
.document-status .research { color: var(--warn); }
.waiting progress { width: 100%; }

/* Where a proposed row was read (app/source.tsx): the page, the passage
   marked. */
.source-view .source-page { background: var(--card); padding: 0.8rem; max-width: min(95vw, 900px); max-height: 95vh; overflow: auto; }
.source-view .source-page p { display: flex; gap: 0.6rem; align-items: baseline; margin: 0 0 0.5rem; }
.source-view .source-page p .link { margin-left: auto; }
.source-view .marked { position: relative; display: inline-block; }
.source-view .marked img { display: block; max-width: 100%; max-height: none; }
.source-view .mark { position: absolute; background: rgba(255, 200, 0, 0.35); outline: 2px solid rgba(220, 140, 0, 0.9); }
.source-view blockquote { margin: 0.6rem 0 0; white-space: pre-wrap; color: var(--muted); }
.origin.machine { color: var(--warn); }
.analysis tr.unconfirmed td { color: var(--muted); }
.analysis .translation { margin: 0.2rem 0 0.4rem 1rem; }
.document-file .sealed { color: var(--ok); font-weight: 600; }
