/*
 * Event capture styling.
 *
 * Designed for one hand, in a noisy hall, on a phone: large targets, high
 * contrast, no hover-dependent affordances. Status is never conveyed by colour
 * alone (§20.3) - every state carries a text label and a shape.
 */

:root {
  --bg: #14100c;
  --surface: #201a14;
  --surface-raised: #2b2219;
  --text: #f5efe6;
  --text-dim: #b9ab99;
  --accent: #d4693a;
  --accent-strong: #8c3b1a;
  --ok: #4c9a6a;
  --warn: #c9a227;
  --error: #c0553f;
  --radius: 12px;
  --tap: 48px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #faf6f0;
    --surface: #ffffff;
    --surface-raised: #f2ebe1;
    --text: #201a14;
    --text-dim: #6b5d4d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif;
  /* Respects the notch and the home indicator on iPhone. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--accent-strong);
  color: #fff;
}

.bar h1 { font-size: 1.1rem; margin: 0; }
.bar-right { display: flex; align-items: center; gap: 8px; }

main { padding: 16px; display: grid; gap: 16px; max-width: 640px; margin: 0 auto; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
}

.card h2 { margin: 0 0 8px; font-size: 1rem; }

.note { color: var(--text-dim); font-size: 0.875rem; margin: 0 0 12px; }

button {
  min-height: var(--tap);
  border-radius: var(--radius);
  border: 2px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.primary { background: var(--accent); color: #fff; width: 100%; }
.primary.large { min-height: 56px; font-size: 1.05rem; }
.ghost { background: transparent; color: inherit; border-color: currentColor; padding: 0 14px; }

/* Viewfinder ------------------------------------------------------------- */

.viewfinder { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; }
.viewfinder video { width: 100%; display: block; aspect-ratio: 3 / 4; object-fit: cover; }

/*
 * The guide frame uses the ISO/IEC 7810 ID-1 business card ratio (85.6 x 54),
 * so what the user lines up matches what gets cropped.
 */
.guide {
  position: absolute;
  inset: 8%;
  margin: auto;
  aspect-ratio: 85.6 / 54;
  max-height: 84%;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45);
}

/* Upload fallback -------------------------------------------------------- */

.upload { display: grid; gap: 6px; margin-top: 12px; }
.upload label { font-size: 0.875rem; color: var(--text-dim); }
.upload input[type='file'] {
  min-height: var(--tap);
  width: 100%;
  padding: 10px;
  border: 2px dashed var(--text-dim);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: inherit;
}

/* Quality ---------------------------------------------------------------- */

.quality { margin-top: 12px; }
.quality-bar { height: 8px; background: var(--surface-raised); border-radius: 4px; overflow: hidden; }
.quality-bar span { display: block; height: 100%; background: var(--ok); }
.quality ul { margin: 8px 0; padding-left: 20px; color: var(--warn); font-size: 0.875rem; }

/* Contact context -------------------------------------------------------- */

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }

.choice {
  min-height: var(--tap);
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 2px solid var(--surface-raised);
  background: var(--surface-raised);
  color: inherit;
  text-align: left;
}

/* Selection is shown by border, weight AND a check mark, never colour alone. */
.choice[aria-pressed='true'] {
  border-color: var(--accent);
  font-weight: 700;
}
.choice[aria-pressed='true']::before { content: '✓ '; }

/* Fields ----------------------------------------------------------------- */

.fields { display: grid; gap: 10px; }
.field label { display: block; font-size: 0.8125rem; color: var(--text-dim); }
.field input {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 2px solid var(--surface-raised);
  background: var(--surface-raised);
  color: inherit;
  font: inherit;
}

/* Low confidence is marked with a border, a badge AND text, not colour alone. */
.field.low-confidence input { border-color: var(--warn); border-style: dashed; }
.field .confidence { font-size: 0.75rem; color: var(--warn); }
.field .confidence::before { content: '⚠ '; }

/* Queue ------------------------------------------------------------------ */

.queue { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.queue li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface-raised);
  border-radius: var(--radius);
  border-left: 4px solid var(--text-dim);
}

.queue li[data-status='saved'] { border-left-color: var(--ok); }
.queue li[data-status='error'] { border-left-color: var(--error); }
.queue li[data-status='review_needed'] { border-left-color: var(--warn); }

.pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.15);
  white-space: nowrap;
}

.pill[data-state='offline'] { background: var(--error); color: #fff; }
.pill[data-state='offline']::before { content: '● '; }
.pill[data-state='online']::before { content: '● '; }

.actions { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 40%); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Storage warnings ------------------------------------------------------- */

dialog {
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  max-width: 30rem;
  padding: 20px;
}

dialog::backdrop { background: rgba(0, 0, 0, 0.65); }
dialog h2 { margin-top: 0; font-size: 1.05rem; }
dialog ol { padding-left: 22px; margin: 12px 0; }
dialog li { margin-bottom: 6px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.warning {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  background: var(--surface-raised);
  border-left: 4px solid var(--text-dim);
}

/* Severity is carried by a text prefix as well as the border (§20.3). */
.warning[data-severity='blocking'] { border-left-color: var(--error); }
.warning[data-severity='blocking'] .warning-title::before { content: 'Let op: '; }
.warning[data-severity='warning'] { border-left-color: var(--warn); }
.warning[data-severity='warning'] .warning-title::before { content: 'Waarschuwing: '; }
.warning[data-severity='info'] { border-left-color: var(--ok); }

.warning-title { font-weight: 700; display: block; margin-bottom: 4px; }
.warning ol { margin: 8px 0 0; padding-left: 20px; font-size: 0.875rem; }

.pill[data-urgent='true'] { background: var(--warn); color: #201a14; }
