/* SICPA navy #033b5a and blue #0087c8, from the Certus web client.
   Mobile first: single column, large targets, no hover-dependent affordances. */
:root {
  --navy: #033b5a;
  --blue: #0087c8;
  --blue-dark: #006ca0;
  --blue-tint: #e5f3fb;

  --page: #eef1f4;
  --surface: #fff;
  --surface-2: #f5f8fa;
  --line: #dbe3ea;
  --line-soft: #eaeff4;

  --ink: #172732;
  --ink-soft: #566875;
  --ink-faint: #8695a2;

  --good: #2c7a4b;
  --good-tint: #e6f3ec;
  --bad: #c0392b;
  --bad-tint: #fbecea;
  --warn: #9a6206;
  --warn-tint: #fcf2e1;

  --mono: "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
}

/* ------------------------------- header ------------------------------- */

header {
  background: var(--navy);
  color: #fff;
  padding: .8rem 1rem;
  padding-top: max(.8rem, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: .75rem;
}
.brand { display: flex; align-items: center; gap: .6rem; }
.mark {
  width: 2rem; height: 2rem; border-radius: 5px; flex: none;
  background: var(--blue); display: grid; place-items: center;
  font: 700 1rem var(--sans);
}
.title { font: 600 .95rem var(--sans); }
.sub { font-size: .72rem; color: #9dc4dc; }
.mode {
  margin-left: auto; font: 600 .62rem var(--mono); letter-spacing: .08em;
  background: rgba(255,255,255,.12); padding: .25rem .5rem; border-radius: 3px;
}
.mode.mocked { color: #ffd9a0; }

/* -------------------------------- rail -------------------------------- */

.rail {
  display: flex; margin: 0; padding: .6rem .5rem; list-style: none;
  background: var(--navy); gap: .15rem; overflow-x: auto;
}
.rail li {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: .35rem;
  font: 600 .68rem var(--sans); color: #7ba6c1; white-space: nowrap;
  padding: .3rem .2rem; border-bottom: 2px solid transparent;
}
.rail li .dot {
  width: 1.2rem; height: 1.2rem; border-radius: 50%; flex: none;
  border: 1px solid currentColor; display: grid; place-items: center; font-size: .62rem;
}
.rail li.active { color: #fff; border-bottom-color: var(--blue); }
.rail li.done { color: #7fd6a4; }
.rail li.done .dot { background: #7fd6a4; color: var(--navy); border-color: #7fd6a4; }

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

main {
  padding: 1rem;
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
  max-width: 34rem;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.1rem 1rem 1.2rem;
}
.card + .card { margin-top: .9rem; }
.card h2 { margin: 0 0 .35rem; font: 600 1.15rem var(--sans); color: var(--navy); }
.lede { margin: 0 0 1rem; color: var(--ink-soft); font-size: .88rem; }
.note { margin: .7rem 0 0; font-size: .82rem; color: var(--ink-soft); min-height: 1.2em; }
.note.bad { color: var(--bad); }
.note.good { color: var(--good); }
.caveat {
  margin: .8rem 0 0; padding: .6rem .7rem; border-left: 3px solid var(--warn);
  background: var(--warn-tint); font-size: .78rem; color: #6d4704; border-radius: 0 4px 4px 0;
}

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

.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.btn {
  background: var(--blue); color: #fff; border: 1px solid var(--blue);
  border-radius: 7px; font: 600 .92rem var(--sans);
  padding: .7rem 1.1rem; min-height: 2.9rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none;
}
.btn:active:not(:disabled) { background: var(--blue-dark); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--navy); border-color: var(--line); }
.btn.wide { width: 100%; }
.btn:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }

.pill {
  font: 600 .68rem var(--mono); letter-spacing: .04em; text-transform: uppercase;
  padding: .3rem .55rem; border-radius: 4px;
}
.pill.idle    { background: var(--surface-2); color: var(--ink-faint); }
.pill.pending { background: var(--warn-tint); color: var(--warn); }
.pill.ok      { background: var(--good-tint); color: var(--good); }
.pill.bad     { background: var(--bad-tint);  color: var(--bad); }

textarea {
  width: 100%; margin-top: .7rem; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 7px; color: var(--ink);
  font: .78rem/1.5 var(--mono); padding: .6rem; resize: vertical;
}
textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-tint); }

/* ------------------------------- camera ------------------------------- */

#cam-wrap {
  position: relative; margin-bottom: .8rem; border-radius: 9px;
  overflow: hidden; background: #000; aspect-ratio: 4 / 3;
}
#cam { width: 100%; height: 100%; object-fit: cover; display: block; }
.reticle {
  position: absolute; inset: 14%; border: 2px solid rgba(255,255,255,.85);
  border-radius: 10px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.28);
}

/* -------------------------------- data -------------------------------- */

/* Keep the claim list from pushing the wallet link off screen on a phone. */
#offer-preview { max-height: 38vh; overflow-y: auto; }

dl.kv { margin: .6rem 0 0; display: grid; grid-template-columns: auto 1fr; gap: .25rem .8rem; font-size: .84rem; }
dl.kv dt { color: var(--ink-faint); font-family: var(--mono); font-size: .76rem; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }

details { margin-top: .9rem; }
summary { font-size: .84rem; color: var(--blue-dark); cursor: pointer; }

.summary-box {
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: 7px; padding: .7rem .8rem; margin-bottom: .9rem;
}
.summary-box .issuer { font: 600 .95rem var(--sans); color: var(--navy); }
.summary-box .meta { font: .74rem var(--mono); color: var(--ink-faint); margin-top: .2rem; overflow-wrap: anywhere; }

table.compare { width: 100%; border-collapse: collapse; margin-top: .8rem; font-size: .82rem; }
table.compare th {
  text-align: left; font: 600 .68rem var(--sans); text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-faint); padding: .3rem .4rem;
  border-bottom: 1px solid var(--line);
}
table.compare td { padding: .4rem .4rem; border-bottom: 1px solid var(--line-soft); }
table.compare td.match { color: var(--good); font-weight: 600; text-align: center; width: 1.6rem; }
table.compare td.miss  { color: var(--bad);  font-weight: 600; text-align: center; width: 1.6rem; }

.qr { background: #fff; padding: .7rem; border: 1px solid var(--line); border-radius: 8px; display: inline-block; line-height: 0; margin-top: .6rem; }
.qr svg { width: 190px; height: 190px; display: block; }
.txcode { margin: .7rem 0 0; font-size: .84rem; color: var(--ink-soft); }
.txcode b { font: 700 1.1rem var(--mono); color: var(--navy); letter-spacing: .1em; }

#offer-link { margin-top: .3rem; }

/* -------------------------------- done -------------------------------- */

.done { text-align: center; padding: 2rem 1rem; }
.done .tick {
  width: 3.5rem; height: 3.5rem; margin: 0 auto .8rem; border-radius: 50%;
  background: var(--good-tint); color: var(--good);
  display: grid; place-items: center; font-size: 1.8rem;
}
.done h2 { margin: 0 0 .3rem; color: var(--navy); }
.done .btn { margin-top: 1.2rem; }

@media (prefers-reduced-motion: no-preference) {
  .card[hidden="false"], section.card { animation: rise .22s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

pre.diag {
  margin: .7rem 0 0; padding: .6rem .7rem; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 6px;
  font: .72rem/1.5 var(--mono); color: var(--ink-soft);
  white-space: pre-wrap; overflow-wrap: anywhere;
}

#cam-canvas { display: none; }

label.toggle {
  display: flex; align-items: center; gap: .5rem;
  margin-top: .8rem; font-size: .84rem; color: var(--ink-soft); cursor: pointer;
}
label.toggle input { width: 1.1rem; height: 1.1rem; accent-color: var(--blue); }
