/*
  Registration webapp styling.

  Mobile-first and deliberately plain. The palette is the trainer app's
  (ColorScheme seed #176B87, secondary #F26B5B) so the two read as one product,
  but nothing here is shared with it - this app must stay loadable on a bad
  connection, and that rules out importing anything.

  Touch targets are 48px minimum throughout: this is filled in standing up, in
  a queue, often on someone else's phone.
*/

:root {
  --ink: #153449;
  --ink-soft: #5b7183;
  --line: #d9e1e7;
  --line-soft: #e4e9ee;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --primary: #176b87;
  --primary-dark: #12586f;
  --accent: #f26b5b;
  --gold: #e9a23b;
  --danger: #c0392b;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(21, 52, 73, .06), 0 8px 24px rgba(21, 52, 73, .06);
}

*, *::before, *::after { box-sizing: border-box; }

/*
  The `hidden` attribute must always win.

  Browsers style [hidden] as `display: none` from the UA stylesheet only, so
  ANY author rule that sets `display` on a class beats it on specificity. This
  app drives its entire six-step flow by toggling `.hidden`, and three rules
  below set `display` on elements that get toggled — `.blocker` (flex),
  `.linkbtn.block` (block) and `.field` (block).

  Shipped without this, `busy(false)` set the attribute but left the
  full-screen blocker rendering: a spinner over a dimmed page, swallowing every
  click, on the sign-in step. It looked exactly like a page that never finished
  loading. Declaring it once here is what keeps `el.hidden = true` meaning what
  it says, whatever is added to the stylesheet later.
*/
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  /* Keeps the last field clear of the on-screen keyboard and home indicator. */
  padding-bottom: env(safe-area-inset-bottom);
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  font-weight: 650;
  font-size: 16px;
  letter-spacing: -.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 20px 48px;
}

.step.wide { max-width: 100%; }

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow);
}

.h1 {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -.02em;
  font-weight: 650;
}

.muted { color: var(--ink-soft); margin: 0 0 16px; }
.muted.small { font-size: 14px; margin-top: 16px; margin-bottom: 0; }
.muted strong { color: var(--ink); }

code {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: .9em;
  word-break: break-all;
}

/* ------------------------------------------------------------------ fields */

.field { display: block; margin: 0 0 16px; }

.field > span {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field .hint {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 400;
  margin-top: 6px;
}

input[type="text"], input[type="email"], input:not([type]), select {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 16px; /* Anything below 16px makes iOS Safari zoom on focus. */
  font-family: inherit;
  appearance: none;
}

select {
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%235b7183' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

.row { display: flex; gap: 12px; }
.row .field { flex: 1; min-width: 0; }

.mobile { display: flex; gap: 8px; }
.mobile .dial { width: 78px; flex: none; text-align: center; }
.mobile input:not(.dial) { flex: 1; min-width: 0; }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -4px 0 20px;
  font-size: 15px;
  color: var(--ink-soft);
  min-height: 44px;
  cursor: pointer;
}

.check input {
  width: 20px;
  height: 20px;
  min-height: 0;
  flex: none;
  accent-color: var(--primary);
}

/* --------------------------------------------------------- participant type */

.group {
  border: 0;
  padding: 0;
  margin: 0 0 20px;
}

.group legend {
  padding: 0;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.chips { display: flex; gap: 10px; flex-wrap: wrap; }

.chip {
  flex: 1 1 auto;
  min-height: 50px;
  padding: 12px 18px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  border-color: var(--primary);
  background: #edf5f8;
  color: var(--primary);
}

/* ----------------------------------------------------------------- buttons */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  padding: 15px 22px;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}

.btn[disabled] { opacity: .55; cursor: default; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:not([disabled]):active { background: #12586f; }

.btn-google {
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--line);
}

.linkbtn {
  background: none;
  border: 0;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 4px;
  min-height: 44px;
}

.linkbtn.block {
  display: block;
  width: 100%;
  margin-top: 14px;
  text-align: center;
}

/* ------------------------------------------------------------------ errors */

.error {
  background: #fdf0ee;
  border: 1px solid #f3cdc6;
  color: var(--danger);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 0 0 16px;
  font-size: 15px;
}

/* ------------------------------------------------------------- event banner */

.event-banner {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.event-banner .name { font-weight: 650; font-size: 17px; }

.event-banner .meta {
  font-size: 14px;
  opacity: .85;
  margin-top: 4px;
}

.event-banner .code {
  display: inline-block;
  margin-top: 10px;
  background: rgba(255, 255, 255, .16);
  border-radius: 8px;
  padding: 3px 10px;
  font-size: 13px;
  letter-spacing: .12em;
  font-weight: 600;
}

/* ---------------------------------------------------------------- passcode */

.passcode {
  width: 100%;
  min-height: 68px;
  text-align: center;
  font-size: 30px !important;
  letter-spacing: .3em;
  font-weight: 650;
  text-indent: .3em; /* Re-centres text that letter-spacing pushes left. */
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-family: inherit;
  appearance: none;
}

.passcode::placeholder { color: #c3cdd6; }

/* -------------------------------------------------------------------- quiz */

.progress {
  height: 5px;
  background: var(--line-soft);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 0 24px;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--primary);
  border-radius: 3px;
  transition: width .25s ease;
}

.question { margin-bottom: 28px; }

.question .cat {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--primary);
  background: #edf5f8;
  border-radius: 6px;
  padding: 4px 9px;
  margin-bottom: 10px;
}

.question .qtext {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 14px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  min-height: 52px;
}

.option input {
  width: 20px;
  height: 20px;
  min-height: 0;
  flex: none;
  margin-top: 1px;
  accent-color: var(--primary);
}

.option.selected { border-color: var(--primary); background: #edf5f8; }

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

.result { text-align: center; padding: 32px 20px; }

.result-name { font-size: 18px; font-weight: 650; margin: 0 0 20px; }

.result-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 4px;
}

.result-group {
  font-size: 76px;
  line-height: 1;
  font-weight: 750;
  color: var(--primary);
  margin: 0 0 20px;
  letter-spacing: -.03em;
}

#registerAnotherBtn { margin-top: 16px; }

/* -------------------------------------------------------------- card list */

.list-head { margin-bottom: 16px; }

#listCards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.regcard {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.regcard .who { flex: 1; min-width: 0; }

.regcard .name {
  font-weight: 650;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.regcard .event {
  font-size: 14px;
  color: var(--ink-soft);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.regcard .code {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  letter-spacing: .1em;
  font-weight: 650;
  color: var(--ink-soft);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 8px;
}

.regcard .grp {
  flex: none;
  width: 62px;
  text-align: center;
  border-left: 1px solid var(--line-soft);
  padding-left: 16px;
}

.regcard .grp .n {
  font-size: 30px;
  font-weight: 750;
  line-height: 1;
  color: var(--primary);
}

.regcard .grp .l {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 3px;
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--ink-soft);
  padding: 40px 20px;
}

/* ----------------------------------------------------------- busy states */

.spinner {
  width: 34px;
  height: 34px;
  margin: 60px auto;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.spinner.light {
  margin: 0;
  border-color: rgba(255, 255, 255, .3);
  border-top-color: #fff;
}

@keyframes spin { to { transform: rotate(360deg); } }

.blocker {
  position: fixed;
  inset: 0;
  background: rgba(21, 52, 73, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .progress-bar { transition: none; }
}
