/* Counter Intelligence web app -- house style (docs/UI_STYLE_GUIDE.md draft):
   iOS grouped background (#F2F2F7), white cards with a 16px radius, Title
   Case labels, one font family (Inter, bundled below -- the page's
   Content-Security-Policy allows no outside hosts, so the file is served by
   this app itself, with its SIL OFL licence beside it at
   /static/INTER-LICENSE.txt).

   Accessibility floor (UI council, 2026-09-24): every control is at least
   44px tall, inputs are 16px (so iPhone Safari never zooms in), input
   borders and the focus ring are at least 3:1 against white, and nothing
   may scroll sideways at a 390px phone width. */
@font-face {
  font-family: "Inter";
  src: url("/static/inter-subset.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
:root {
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, "Roboto Mono", monospace;
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --ink: #1C1C1E;
  --ink-2: #3A3A3C;
  --muted: #636366;
  --field-line: #8A8A8E;   /* 3.4:1 on white */
  --sep: rgba(60, 60, 67, 0.18);
  --fill: rgba(118, 118, 128, 0.12);
  --navy: #0D376A;
  --navy-hover: #0A2B54;
  --teal-ink: #007A87;
  --navy-soft: #E6EDF5;
  --ok-bg: #E7F4EC;
  --ok-ink: #1E5E36;
  --warn-bg: #FFF4D6;
  --warn-ink: #6B4800;
  --bad-bg: #FDECEC;
  --bad-ink: #A1161B;
  --radius: 16px;
  --radius-ctl: 12px;
  --ring: #0D376A;         /* solid focus ring, 12:1 on white */
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
}

/* --- Header --------------------------------------------------------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 6px 20px; background: var(--card); border-bottom: 0.5px solid var(--sep);
  flex-wrap: wrap;
}
.brand {
  display: inline-flex; align-items: center; min-height: 44px;
  font-weight: 700; font-size: 17px; color: var(--navy); letter-spacing: -0.01em;
  text-decoration: none;
}
.top nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.top nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
  color: var(--teal-ink); text-decoration: none; font-weight: 600; font-size: 15px;
  border-radius: var(--radius-ctl);
}
.top nav a:hover { background: var(--fill); }
.top nav a[aria-current="page"] { color: var(--ink); background: var(--fill); }
.top .who { color: var(--muted); font-size: 14px; padding: 0 8px 0 12px; }
.top .inline .btn { margin: 0; }

/* --- Page ----------------------------------------------------------- */
main { max-width: 800px; margin: 0 auto; padding: 24px 16px 56px; }
main.narrow { max-width: 440px; }
main.wide { max-width: 1040px; }
h1 { font-size: 30px; font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; margin: 12px 0 18px; }
h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 20px;
  margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.card > :last-child { margin-bottom: 0; }
.lead { color: var(--ink-2); }
.muted { color: var(--muted); font-size: 14px; }
.after { margin-top: 4px; }

/* --- Form controls -------------------------------------------------- */
label, .label { display: block; font-weight: 600; font-size: 15px; margin: 14px 0 6px; }
form > label:first-of-type, .card > form > label:first-child { margin-top: 0; }
input[type=text], input[type=password], input[type=file], select {
  width: 100%; font: inherit; font-size: 16px; padding: 10px 12px;
  border: 1px solid var(--field-line); border-radius: var(--radius-ctl);
  background: #fff; color: var(--ink); min-height: 44px;
}
input[type=file] { padding: 8px 10px; }
input[aria-invalid="true"], select[aria-invalid="true"] { border: 2px solid var(--bad-ink); }
.code-input {
  font-family: var(--mono); font-size: 20px !important; letter-spacing: 0.08em;
  text-transform: uppercase;
}
.hint { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
a:focus-visible, input:focus-visible, select:focus-visible, button:focus-visible,
summary:focus-visible, .msg:focus-visible {
  outline: 3px solid var(--ring); outline-offset: 2px;
}
.msg:focus { outline: none; }
.msg:focus-visible { outline: 3px solid var(--ring); }

/* --- Buttons -------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 16px; min-height: 44px;
  padding: 10px 18px; border-radius: var(--radius-ctl); border: 0; cursor: pointer;
  background: var(--navy); color: #fff; margin-top: 16px; text-decoration: none;
  text-align: center; line-height: 1.2;
}
.btn:hover { background: var(--navy-hover); }
.btn.quiet { background: var(--fill); color: var(--navy); }
.btn.quiet:hover { background: rgba(118, 118, 128, 0.2); }
.btn.danger { background: var(--bad-ink); color: #fff; }
.btn.danger:hover { background: #86121A; }
.btn.small { font-size: 15px; padding: 8px 14px; margin: 0; }
.btn.block { display: flex; width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.btn-row .btn { margin: 0; }
.inline { display: inline; margin: 0; }

/* --- Notices -------------------------------------------------------- */
.msg { border-radius: var(--radius-ctl); padding: 12px 14px; margin-bottom: 16px; font-size: 15px; }
.msg.bad { background: var(--bad-bg); color: var(--bad-ink); }
.msg.warn { background: var(--warn-bg); color: var(--warn-ink); }
.msg.ok { background: var(--ok-bg); color: var(--ok-ink); }
.card .msg:last-child { margin-bottom: 0; }

/* --- Two-factor pieces --------------------------------------------- */
.examples { display: grid; gap: 8px; margin: 14px 0 0; padding: 12px 14px;
  background: var(--fill); border-radius: var(--radius-ctl); }
.examples div { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.examples dt { color: var(--ink-2); font-size: 14px; }
.examples dd { margin: 0; font-family: var(--mono); font-size: 15px; letter-spacing: 0.04em; }
.qr-row { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.qr { width: 200px; height: 200px; border-radius: 8px; background: #fff;
  border: 1px solid var(--sep); flex: none; }
.qr-row .qr-text { flex: 1 1 200px; min-width: 0; }
/* The setup key: each group of four is one word, so a line can only ever
   break BETWEEN groups, never inside one. */
.key {
  font-family: var(--mono); font-size: 18px; letter-spacing: 0.06em; word-spacing: 0.3em;
  background: var(--fill); padding: 12px 14px; border-radius: var(--radius-ctl);
  word-break: normal; overflow-wrap: normal; white-space: normal; margin: 0;
}
.codes {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px;
  font-family: var(--mono); font-size: 16px; letter-spacing: 0.04em;
  padding: 14px 16px; background: var(--fill); border-radius: var(--radius-ctl);
  margin: 14px 0 0;
}
.codes div { white-space: nowrap; }
.copy-status { color: var(--ok-ink); font-size: 14px; font-weight: 600; }

/* A two-step confirm with no script: the first button opens the warning,
   the real action sits inside it, and the first button becomes Cancel. */
details.confirm { margin-top: 16px; }
details.confirm > summary { list-style: none; display: inline-flex; margin: 0; }
details.confirm > summary::-webkit-details-marker { display: none; }
details.confirm .when-open { display: none; }
details.confirm[open] .when-open { display: inline; }
details.confirm[open] .when-closed { display: none; }
details.confirm .confirm-body {
  margin-top: 12px; padding: 14px; border-radius: var(--radius-ctl);
  background: var(--warn-bg); color: var(--warn-ink);
}
details.confirm .confirm-body p { margin: 0 0 12px; }
details.confirm .confirm-body .btn { margin: 0; }
details.confirm.compact { margin-top: 0; }

/* --- Tables (become stacked cards on a phone) ----------------------- */
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td {
  text-align: left; padding: 10px 8px; border-bottom: 0.5px solid var(--sep);
  vertical-align: top; overflow-wrap: break-word;
}
.person { min-width: 150px; width: 26%; }
td.person strong, td.person .muted { overflow-wrap: normal; word-break: normal; }
th { font-size: 13px; font-weight: 600; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.nowrap { white-space: nowrap; }
.person strong { display: block; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-block; font-size: 13px; font-weight: 600; padding: 3px 10px;
  border-radius: 999px; background: var(--fill); color: var(--ink-2); white-space: nowrap;
}
.chip.on { background: var(--navy-soft); color: var(--navy); }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); }
.chip.bad { background: var(--bad-bg); color: var(--bad-ink); }
.actions { display: grid; gap: 10px; }
.actions .btn-row { margin-top: 0; }
.action-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.action-form label { grid-column: 1 / -1; margin: 0; font-size: 14px; }
.action-form .btn { margin: 0; }

@media (max-width: 480px) {
  .top { flex-direction: column; align-items: stretch; padding: 6px 12px 8px; gap: 2px; }
  .top nav { gap: 2px; margin-left: -10px; }
  .top nav a { padding: 0 10px; }
  .top .who { flex-basis: 100%; padding: 4px 12px 0; }
  main { padding: 16px 16px 48px; }
  h1 { font-size: 28px; }
  .card { padding: 16px; }
  .codes { grid-template-columns: minmax(0, 1fr); }
  .qr { width: 180px; height: 180px; }
  /* Tables turn into one card per row: each cell carries its own label. */
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr.head { display: none; }
  table.stack tr { padding: 12px 0; border-bottom: 0.5px solid var(--sep); }
  table.stack tr:last-child { border-bottom: 0; padding-bottom: 0; }
  table.stack tr:nth-child(2) { padding-top: 0; }
  table.stack td { border: 0; padding: 4px 0; overflow-wrap: anywhere; }
  .person { width: auto; min-width: 0; }
  table.stack td[data-label]::before {
    content: attr(data-label); display: block; font-size: 13px; font-weight: 600;
    color: var(--muted); margin-bottom: 2px;
  }
  table.stack td.nowrap { white-space: normal; }
  .btn-row .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
