/* SAQ Technical Officials Portal
   All styling lives here rather than in the document, because the CSP is
   style-src 'self' with no 'unsafe-inline' — an inline <style> block or a style=
   attribute would simply not apply. */

:root {
  --navy: #0b3d6b;
  --navy-600: #0f4d86;
  --navy-300: #6fa8d6;
  --red: #c8102e;

  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --line: #d9e1ea;
  --ink: #10202f;
  --ink-2: #4a5c6d;
  --ink-3: #7b8b9a;
  --accent: var(--navy);
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 32, 47, 0.06), 0 8px 24px rgba(16, 32, 47, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1219;
    --surface: #131c26;
    --surface-2: #1a2532;
    --line: #263341;
    --ink: #e8eef4;
    --ink-2: #a3b3c2;
    --ink-3: #718697;
    --accent: #5ea3e0;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* Long names and long course titles must never force a sideways scroll. */
  overflow-x: hidden;
}

.view[hidden], [hidden] { display: none !important; }

/* ── Boot spinner ──────────────────────────────────────────────────────── */
.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 50;
}
.boot[hidden] { display: none; }
.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* ── Scan view ─────────────────────────────────────────────────────────── */
#scan-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
}
.scan-inner {
  width: 100%;
  max-width: 420px;
  text-align: center;
}
.logo { width: 168px; max-width: 60%; height: auto; margin-bottom: 20px; }
#scan-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
.lede { color: var(--ink-2); margin: 0 0 24px; }

.fineprint {
  color: var(--ink-3);
  font-size: 12.5px;
  line-height: 1.55;
  margin: 28px auto 0;
  max-width: 34em;
}

.msg { min-height: 1.4em; margin: 14px 0 0; font-size: 14.5px; }
.msg.err { color: var(--red); }
@media (prefers-color-scheme: dark) { .msg.err { color: #ff8296; } }
.msg.ok { color: var(--accent); }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 13px 24px;
  cursor: pointer;
  /* 44px is the smallest reliably tappable target; these get used one-handed,
     poolside, sometimes with wet fingers. */
  min-height: 48px;
  transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--navy); color: #fff; font-weight: 600; width: 100%; }
.btn-primary:hover { background: var(--navy-600); }
@media (prefers-color-scheme: dark) {
  .btn-primary { background: var(--accent); color: #08131d; }
  .btn-primary:hover { background: #7bb6e8; }
}
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 8px 14px; min-height: 38px; font-size: 14px; }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Scanner ───────────────────────────────────────────────────────────── */
.scanner { margin-top: 18px; }
.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}
#video { width: 100%; height: 100%; object-fit: cover; display: block; }
.reticle {
  position: absolute;
  inset: 14%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.35);
  transition: border-color 0.12s;
  pointer-events: none;
}
.video-wrap.hit .reticle { border-color: #2ecc71; }
.scan-actions { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }

/* ── Portal ────────────────────────────────────────────────────────────── */
#portal-view { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-logo { height: 30px; width: auto; flex: none; }
.topbar-id { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.hdr-name { font-weight: 650; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hdr-sub { font-size: 12px; color: var(--ink-3); }

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 55px;
  z-index: 9;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  font: inherit;
  font-size: 14.5px;
  font-weight: 550;
  flex: 1 0 auto;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  min-height: 40px;
}
.tab[aria-selected="true"] { background: var(--surface-2); color: var(--accent); }
.tab:focus-visible { outline: 3px solid var(--accent); outline-offset: -2px; }

.panel {
  flex: 1;
  padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}
.panel:focus { outline: none; }

/* ── Detail rows ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.row {
  display: flex;
  gap: 14px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}
.row:last-child { border-bottom: 0; }
.row dt {
  flex: 0 0 40%;
  max-width: 170px;
  color: var(--ink-3);
  font-size: 13.5px;
  margin: 0;
}
.row dd {
  flex: 1;
  margin: 0;
  /* Emails and long names must wrap rather than widen the card. */
  overflow-wrap: anywhere;
}
.row dd.empty { color: var(--ink-3); font-style: italic; }
dl { margin: 0; }

.chip {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--accent);
  border-radius: 999px;
  padding: 2px 11px;
  font-size: 13px;
  font-weight: 600;
}

a.link { color: var(--accent); text-decoration: none; }
a.link:hover { text-decoration: underline; }

/* ── Lists (trainings / experiences) ───────────────────────────────────── */
.item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.item-year {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 4px 9px;
  min-width: 54px;
  text-align: center;
}
.item-body { min-width: 0; }
.item-title { font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.item-sub { color: var(--ink-3); font-size: 13.5px; margin-top: 2px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 2px 12px;
}
.section-head h2 { font-size: 15px; margin: 0; font-weight: 650; }
.count { color: var(--ink-3); font-size: 13.5px; font-variant-numeric: tabular-nums; }

.empty-state {
  text-align: center;
  color: var(--ink-3);
  padding: 44px 20px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty-state strong { display: block; color: var(--ink-2); margin-bottom: 4px; font-weight: 600; }
.empty-state span { font-size: 14px; }
