/* Jybek Referrals
   Built for older eyes and hands: Atkinson Hyperlegible (drawn for low-vision
   readers), 18px base, 56px touch targets, navy on white at AAA contrast.
   Gold is only ever a fill behind navy text, never text on white. */

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-latin-400-normal.f1f8a8210104.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-latin-700-normal.13a58e05dfd2.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --navy: #1A3A6B;
  --navy-deep: #102848;
  --gold: #C9A84C;
  --gold-pale: #F6EED6;
  --mist: #EEF2F8;
  --line: #B9C4D9;
  --ink: #14213A;
  --soft: #45536F;
  --alert: #A3261B;
  --paper: #FFFFFF;
  --tap: 3.5rem;
  --radius: 0.75rem;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Atkinson Hyperlegible", Verdana, "Segoe UI", sans-serif;
  line-height: 1.5;
}

:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
h1:focus { outline: none; }

a { color: var(--navy); text-underline-offset: 0.2em; }

h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 0.5rem; color: var(--navy-deep); }
h2 { font-size: 1.2rem; line-height: 1.3; margin: 2rem 0 0.5rem; color: var(--navy-deep); }
p { margin: 0 0 1rem; }
.lead { font-size: 1.1rem; color: var(--soft); margin-bottom: 1.5rem; }
.hint { font-size: 0.9rem; color: var(--soft); margin: 0 0 0.4rem; }
.boot { padding: 4rem 1.25rem; text-align: center; color: var(--soft); }

/* ---- frame ---- */
.bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 0.6rem;
  padding: calc(0.6rem + env(safe-area-inset-top)) 1.25rem 0.6rem;
  background: var(--navy); color: #fff; font-weight: 700;
}
.bar img { border-radius: 0.4rem; }
.pill { margin-left: auto; padding: 0.15rem 0.7rem; border-radius: 2rem; background: var(--gold); color: var(--navy-deep); font-size: 0.85rem; }

.page { max-width: 34rem; margin: 0 auto; padding: 1.5rem 1.25rem calc(7rem + env(safe-area-inset-bottom)); }
.page.solo { padding-bottom: 3rem; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; background: var(--paper); border-top: 2px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; min-height: 4.25rem; padding: 0.5rem 0.2rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1rem;
  color: var(--soft); text-decoration: none; font-size: 0.85rem; text-align: center; line-height: 1.2;
  border-top: 4px solid transparent; margin-top: -2px;
}
.tabs a[aria-current] { color: var(--navy-deep); font-weight: 700; border-top-color: var(--gold); }

/* ---- buttons ---- */
.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: var(--tap); padding: 0.6rem 1.25rem;
  border: 2px solid transparent; border-radius: var(--radius);
  font: inherit; font-weight: 700; text-align: center; text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:active { background: var(--navy-deep); }
.btn-gold { background: var(--gold); color: var(--navy-deep); }
.btn-quiet { background: var(--mist); color: var(--navy-deep); border-color: var(--line); }
.btn-plain { background: none; color: var(--navy); text-decoration: underline; text-underline-offset: 0.2em; font-weight: 400; }
.btn[disabled] { opacity: 0.6; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.75rem; }
.row .btn { width: auto; flex: 1 1 9rem; }

/* ---- the referral card: the one thing people hand to each other ---- */
.card {
  margin: 0 0 1rem; padding: 1.5rem 1.25rem 1.25rem;
  background: var(--navy); color: #fff;
  border-radius: var(--radius); border-top: 0.5rem solid var(--gold);
}
.card-label { margin: 0; color: #D6DEED; }
.code {
  margin: 0.1rem 0 0.6rem;
  font-size: clamp(2.4rem, 13vw, 3.4rem); font-weight: 700; line-height: 1.1;
  letter-spacing: 0.16em; color: var(--gold);
  -webkit-user-select: all; user-select: all;
}
.card-note { color: #D6DEED; font-size: 0.95rem; }

.tally { margin: 1rem 0 0; padding: 0.75rem 1rem; background: var(--gold-pale); border-radius: var(--radius); color: var(--navy-deep); font-weight: 700; }

.steps { margin: 0 0 1rem; padding: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding: 0.35rem 0 0.9rem 3rem; min-height: 2.6rem; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0.2rem;
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--gold-pale); color: var(--navy-deep); font-weight: 700;
}

.rules { padding-left: 1.2rem; }
.rules li { margin-bottom: 0.8rem; }

.notice { margin-top: 2rem; padding: 1rem 1.25rem 1.25rem; background: var(--mist); border-radius: var(--radius); }
.notice h2 { margin-top: 0; }
.notice p:last-child { margin-bottom: 0; }
.notice-warn { margin-top: 0; background: var(--gold-pale); color: var(--navy-deep); }
.foot { margin-top: 2rem; }

/* ---- forms ---- */
.form { display: grid; gap: 1.1rem; }
.form.inset { margin-top: 1rem; padding: 1rem; background: var(--mist); border-radius: var(--radius); }
.field label { display: block; font-weight: 700; margin-bottom: 0.3rem; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%; min-height: var(--tap); padding: 0.6rem 0.9rem;
  border: 2px solid var(--soft); border-radius: var(--radius);
  background: var(--paper); color: var(--ink); font: inherit;
}
textarea { min-height: 6rem; }
[aria-invalid="true"] { border-color: var(--alert) !important; }
.err { margin: 0.35rem 0 0; color: var(--alert); font-weight: 700; }
.hp { position: absolute; left: -100rem; }

.check, .choice {
  display: flex; gap: 0.9rem; align-items: flex-start;
  padding: 0.9rem 1rem; border: 2px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.check input, .choice input { flex: none; width: 1.6rem; height: 1.6rem; margin: 0.1rem 0 0; accent-color: var(--navy); }
.choices { display: grid; gap: 0.6rem; }
fieldset.choices { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.choices legend { font-weight: 700; margin-bottom: 0.5rem; padding: 0; }
.choice small { display: block; color: var(--soft); font-size: 0.9rem; }
.choice:has(input:checked), .check:has(input:checked) { border-color: var(--navy); background: var(--mist); }

/* ---- referral lists ---- */
.refs { list-style: none; margin: 1rem 0 0; padding: 0; }
.ref { padding: 1.25rem 0; border-top: 2px solid var(--line); }
.ref:first-child { border-top: 0; padding-top: 0; }
.ref h2 { margin: 0 0 0.5rem; }
.ref p { margin-bottom: 0.4rem; }
.ref-waiting { padding: 1rem; border: 2px dashed var(--soft); border-radius: var(--radius); margin-bottom: 1rem; }
.ref-waiting:first-child { padding-top: 1rem; border-top: 2px dashed var(--soft); }
.ref-waiting .btn { width: auto; padding-left: 0; min-height: 2.75rem; }

.track { list-style: none; display: flex; margin: 0.6rem 0 0.8rem; padding: 0; }
.track li { flex: 1; position: relative; padding-top: 1.5rem; font-size: 0.8rem; line-height: 1.25; color: var(--soft); text-align: center; }
/* Each step draws the line into it (left half) and out of it (right half). */
.track li { --in: var(--line); --out: var(--line); }
.track li::before { content: ""; position: absolute; top: 0.4rem; left: 0; right: 0; height: 4px; background: linear-gradient(to right, var(--in) 50%, var(--out) 50%); }
.track li::after { content: ""; position: absolute; top: 0; left: 50%; width: 1rem; height: 1rem; margin-left: -0.5rem; border-radius: 50%; background: var(--paper); border: 3px solid var(--line); }
.track li.done { --in: var(--navy); --out: var(--navy); }
.track li.now { --in: var(--navy); color: var(--navy-deep); font-weight: 700; }
.track li:first-child { --in: transparent; }
.track li:last-child { --out: transparent; }
.track .done::after { background: var(--navy); border-color: var(--navy); }
.track .now::after { background: var(--gold); border-color: var(--navy); }

/* ---- program settings ---- */
.prog { margin: 0 0 1.5rem; padding: 1.1rem 1.25rem 1.25rem; border: 2px solid var(--line); border-radius: var(--radius); }
.prog h2 { margin: 0; }
.prog > .hint { margin: -0.6rem 0 0; }

.links { display: flex; flex-direction: column; gap: 0.6rem; }
.tag-role { background: var(--mist); color: var(--navy-deep); font-weight: 400; }

.linkbox { margin: 0 0 0.25rem; padding: 0.6rem 0.8rem; background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius); overflow-wrap: anywhere; -webkit-user-select: all; user-select: all; }

/* ---- counts ---- */
.count { margin: 0 0 1rem; font-weight: 700; color: var(--navy-deep); }
.sum { margin: 0 0 1.5rem; padding: 1.1rem 1.25rem 1.25rem; background: var(--mist); border-radius: var(--radius); }
.sum-total { margin: 0; font-size: 1.2rem; color: var(--navy-deep); }
.sum-total strong { font-size: 2.2rem; line-height: 1; margin-right: 0.15rem; }
.sum h2 { font-size: 1rem; margin: 1.1rem 0 0.3rem; }
.sum .hint { margin: 0.2rem 0 0; }
.counts { display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 1rem; margin: 0; }
.counts dt { color: var(--ink); }
.counts dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; margin: 0.6rem 0; font-size: 0.95rem; }
.facts dt { color: var(--soft); }
.facts dd { margin: 0; }
.tag { display: inline-block; padding: 0 0.5rem; border-radius: 0.4rem; font-size: 0.8rem; font-weight: 700; vertical-align: middle; }
.tag-warn { background: var(--gold-pale); color: var(--navy-deep); }

.seg { display: flex; border: 2px solid var(--navy); border-radius: var(--radius); overflow: hidden; margin-bottom: 1.25rem; }
.seg button { flex: 1; min-height: 3rem; border: 0; background: var(--paper); color: var(--navy); font: inherit; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--navy); color: #fff; font-weight: 700; }

.toast {
  position: fixed; left: 1rem; right: 1rem; bottom: calc(5.5rem + env(safe-area-inset-bottom)); z-index: 3;
  max-width: 32rem; margin: 0 auto; padding: 0.9rem 1.1rem;
  background: var(--navy-deep); color: #fff; border-radius: var(--radius);
  opacity: 0; transform: translateY(0.5rem); pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
