/* ID CHECK — instrument-grade dark UI */

@font-face {
  font-family: 'Barlow Condensed';
  font-style: normal; font-weight: 500; font-display: swap;
  src: url('fonts/barlow-condensed-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow Condensed';
  font-style: normal; font-weight: 600; font-display: swap;
  src: url('fonts/barlow-condensed-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow Condensed';
  font-style: normal; font-weight: 700; font-display: swap;
  src: url('fonts/barlow-condensed-700.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/plex-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal; font-weight: 600; font-display: swap;
  src: url('fonts/plex-mono-600.woff2') format('woff2');
}

:root {
  --bg: #0a0e0c;
  --bg-raise: #101613;
  --bg-panel: #131a16;
  --line: #223027;
  --line-bright: #35493c;
  --ink: #e8f2ea;
  --ink-dim: #93a89a;
  --ink-faint: #5c6f63;
  --green: #46e08b;
  --green-deep: #114a2c;
  --amber: #ffb454;
  --red: #ff5d5d;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(70, 224, 139, 0.05), transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(255,255,255,0.008) 3px 4px),
    var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  -webkit-tap-highlight-color: transparent;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(70,224,139,0.04), transparent);
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 12px; height: 12px;
  background: var(--green);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 35% 100%, 0 65%);
  box-shadow: 0 0 12px rgba(70, 224, 139, 0.7);
}

.brand h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.14em;
  line-height: 1;
}

.statusgroup { display: flex; gap: 6px; }

.pill {
  font-size: 10px;
  letter-spacing: 0.12em;
  padding: 4px 8px 3px;
  border: 1px solid var(--line-bright);
  border-radius: 2px;
  color: var(--ink-dim);
  white-space: nowrap;
}
.pill-net.online  { color: var(--green); border-color: var(--green-deep); }
.pill-net.offline { color: var(--amber); border-color: #4a3814; }

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

#main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- scanner ---------- */

.viewport {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line-bright);
  border-radius: 6px;
  background: #060907;
  overflow: hidden;
}

#video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: none;
}
.scanner.live #video { display: block; }

/* reticle corners + moving scanline, only while live */
.reticle { position: absolute; inset: 0; display: none; pointer-events: none; }
.scanner.live .reticle { display: block; }

.corner {
  position: absolute;
  width: 26px; height: 26px;
  border: 3px solid var(--green);
  filter: drop-shadow(0 0 6px rgba(70,224,139,0.6));
}
/* Deliberately smaller than the frame: a card "filling" a big reticle sits
   inside the lens's minimum focus distance and captures blurry. This guides
   users to hold it farther away; 4K capture keeps enough pixels per module. */
.corner.tl { top: 27%; left: 13%; border-right: 0; border-bottom: 0; }
.corner.tr { top: 27%; right: 13%; border-left: 0; border-bottom: 0; }
.corner.bl { bottom: 27%; left: 13%; border-right: 0; border-top: 0; }
.corner.br { bottom: 27%; right: 13%; border-left: 0; border-top: 0; }

.scanline {
  position: absolute;
  left: 15%; right: 15%;
  top: 29%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--green) 20%, var(--green) 80%, transparent);
  box-shadow: 0 0 14px 2px rgba(70,224,139,0.55);
  animation: sweep 2.2s ease-in-out infinite alternate;
}
@keyframes sweep { from { top: 29%; } to { top: 69%; } }

@media (prefers-reduced-motion: reduce) {
  .scanline { animation: none; top: 49%; }
}

.viewport-idle {
  position: absolute; inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  color: var(--ink-faint);
  padding: 20px;
}
.scanner.live .viewport-idle { display: none; }

.idle-glyph { width: 110px; color: var(--line-bright); }
.viewport-idle p { font-size: 12px; line-height: 1.7; letter-spacing: 0.04em; }
.viewport-idle strong { color: var(--ink-dim); font-weight: 600; }

.hud-hint {
  position: absolute;
  left: 0; right: 0; bottom: 8px;
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: rgba(232, 242, 234, 0.75);
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}

/* ---------- quick verdict (throughput mode) ---------- */

.quick {
  margin-top: 12px;
  border: 1px solid var(--line-bright);
  border-left-width: 6px;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--bg-panel), var(--bg-raise));
  padding: 12px 14px 8px;
}
.quick.ok   { border-left-color: var(--green); }
.quick.warn { border-left-color: var(--amber); }
.quick.bad  { border-left-color: var(--red); }

.quick.flash { animation: quickflash 0.5s ease-out; }
@keyframes quickflash {
  0%   { background: rgba(70, 224, 139, 0.22); }
  100% { background: transparent; }
}
.quick.warn.flash { animation-name: quickflash-warn; }
@keyframes quickflash-warn {
  0%   { background: rgba(255, 180, 84, 0.25); }
  100% { background: transparent; }
}
.quick.bad.flash { animation-name: quickflash-bad; }
@keyframes quickflash-bad {
  0%   { background: rgba(255, 93, 93, 0.28); }
  100% { background: transparent; }
}

.quick-main {
  display: flex;
  align-items: center;
  gap: 14px;
}
.quick-verdict {
  font-family: var(--display);
  font-weight: 700;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.quick.ok   .quick-verdict { color: var(--green); text-shadow: 0 0 14px rgba(70,224,139,0.4); }
.quick.warn .quick-verdict { color: var(--amber); text-shadow: 0 0 14px rgba(255,180,84,0.4); }
.quick.bad  .quick-verdict { color: var(--red); text-shadow: 0 0 14px rgba(255,93,93,0.4); }

.quick-info { flex: 1; min-width: 0; }
.quick-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 19px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.quick-sub {
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--ink-dim);
  letter-spacing: 0.03em;
}
.quick-age {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.quick-age-num {
  font-family: var(--display);
  font-weight: 700;
  font-size: 40px;
  line-height: 1;
}
.quick.ok   .quick-age-num { color: var(--green); }
.quick.warn .quick-age-num { color: var(--amber); }
.quick.bad  .quick-age-num { color: var(--red); }
.quick-age-cap {
  font-size: 8px;
  letter-spacing: 0.22em;
  color: var(--ink-faint);
}
.quick-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}
.quick-count {
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.14em;
}

#detailsWrap { margin-top: 10px; }

/* ---------- zoom ---------- */

.zoomrow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-raise);
}
.zoomrow label {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
}
.zoom-val {
  font-size: 11px;
  color: var(--green);
  min-width: 34px;
  text-align: right;
}
.zoomrow input[type=range] {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 3px;
  border-radius: 2px;
  background: var(--line-bright);
  outline: none;
}
.zoomrow input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--green);
  border: 3px solid var(--bg);
  box-shadow: 0 0 8px rgba(70,224,139,0.5);
  cursor: pointer;
}
.zoomrow input[type=range]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--green);
  border: 3px solid var(--bg);
  cursor: pointer;
}

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

.controls {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn {
  font-family: var(--display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.12em;
  border-radius: 4px;
  padding: 14px 18px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.06s ease, background 0.15s ease;
}
.btn:active { transform: translateY(1px) scale(0.99); }

.btn-primary {
  flex: 1;
  border: 1px solid var(--green);
  background: linear-gradient(180deg, rgba(70,224,139,0.16), rgba(70,224,139,0.05));
  color: var(--green);
  text-shadow: 0 0 10px rgba(70,224,139,0.4);
}
.btn-primary:disabled { opacity: 0.4; cursor: default; }

.btn-led {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(70,224,139,0.9);
  animation: blink 1.6s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

.btn-ghost {
  border: 1px solid var(--line-bright);
  background: transparent;
  color: var(--ink-dim);
  font-size: 15px;
}
.btn-ghost.on { color: var(--amber); border-color: var(--amber); }

.scan-error {
  margin-top: 10px;
  color: var(--red);
  font-size: 12px;
  line-height: 1.6;
}

/* ---------- result ---------- */

.result { animation: rise 0.35s cubic-bezier(0.2, 0.9, 0.3, 1); }
@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

.verdict {
  border: 1px solid var(--line-bright);
  border-left: 4px solid var(--green);
  border-radius: 6px;
  background: linear-gradient(180deg, var(--bg-panel), var(--bg-raise));
  padding: 14px 16px 16px;
}
.verdict.bad     { border-left-color: var(--red); }
.verdict.caution { border-left-color: var(--amber); }

.verdict-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.verdict-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
}
.verdict-state {
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.14em;
  color: var(--green);
}
.verdict.bad .verdict-state     { color: var(--red); }
.verdict.caution .verdict-state { color: var(--amber); }

.person-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(28px, 8vw, 40px);
  line-height: 1.05;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 14px;
}

.bigstats {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 8px 18px;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}
.stat { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.stat-num {
  font-family: var(--display);
  font-weight: 600;
  font-size: 26px;
  line-height: 1;
  white-space: nowrap;
}
.stat:first-child .stat-num { font-size: 34px; color: var(--green); }
.verdict.bad .stat:first-child .stat-num { color: var(--red); }
.stat-cap {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
}

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.badge {
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 4px 8px 3px;
  border-radius: 2px;
  border: 1px solid var(--line-bright);
  color: var(--ink-dim);
}
.badge.ok   { color: var(--green); border-color: var(--green-deep); background: rgba(70,224,139,0.07); }
.badge.warn { color: var(--amber); border-color: #4a3814; background: rgba(255,180,84,0.07); }
.badge.bad  { color: var(--red);   border-color: #4a1919; background: rgba(255,93,93,0.07); }

/* ---------- datasheet ---------- */

.datasheet {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.datasheet .row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-raise);
}
.datasheet .row:nth-child(even) { background: var(--bg-panel); }
.datasheet .row:last-child { border-bottom: 0; }
.datasheet dt {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-top: 2px;
}
.datasheet dd {
  font-weight: 600;
  font-size: 13px;
  overflow-wrap: anywhere;
}

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

.rawwrap summary {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 6px 2px;
}
.rawwrap pre {
  margin-top: 6px;
  padding: 12px;
  border: 1px dashed var(--line-bright);
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--ink-dim);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 260px;
  overflow-y: auto;
}

/* ---------- debug ---------- */

.debug {
  margin-top: 14px;
  border: 1px dashed var(--line-bright);
  border-radius: 6px;
  padding: 12px 14px;
  background: var(--bg-raise);
}
.debug-head {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--amber);
  margin-bottom: 8px;
}
.debug pre {
  font-size: 11px;
  line-height: 1.7;
  color: var(--ink-dim);
  white-space: pre-wrap;
}
.debug-actions { display: flex; gap: 10px; margin-top: 10px; }
.debug-actions .btn { font-size: 13px; padding: 10px 14px; text-decoration: none; }
.snap-info {
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-dim);
}

.linkbtn {
  background: none;
  border: none;
  color: var(--ink-faint);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.pill-ver { color: var(--ink); border-color: var(--line-bright); }

/* ---------- footer ---------- */

.foot {
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  text-align: center;
  color: var(--ink-faint);
  font-size: 10px;
  letter-spacing: 0.06em;
}

/* wider screens: give the scanner some breathing room */
@media (min-width: 700px) {
  #main { padding-top: 28px; }
  .viewport { aspect-ratio: 16 / 10; }
}
