/* Sunday school check-in. Two families: Lexend (headings, numbers) + Atkinson Hyperlegible (reading). */
:root {
  --font-base: 18px;
  --display: "Lexend", "Segoe UI", system-ui, sans-serif;
  --read: "Atkinson Hyperlegible", "Verdana", system-ui, sans-serif;
  --r-sm: 10px; --r-md: 16px; --r-lg: 28px; --r-pill: 999px;
  --tap: 56px;
}
[data-theme="dark"] {
  --bg: #0D1326; --bg-glow: #1A2550; --surface: #161F3A; --surface-2: #1E2A4D; --line: #2E3C66;
  --text: #F2F5FF; --muted: #AAB6D8; --field: #0F1730;
  --here: #4ADE9B; --here-ink: #062A1A; --here-tint: rgba(74, 222, 155, .14);
  --wait: #FFC857; --wait-ink: #2E2000; --wait-tint: rgba(255, 200, 87, .14);
  --danger: #FF8A8A; --danger-tint: rgba(255, 138, 138, .12);
  --focus: #FFFFFF;
}
[data-theme="light"] {
  --bg: #F3F5FB; --bg-glow: #DCE4FA; --surface: #FFFFFF; --surface-2: #EEF2FA; --line: #CED6E8;
  --text: #0E1630; --muted: #475372; --field: #FFFFFF;
  --here: #0E7A4A; --here-ink: #FFFFFF; --here-tint: #E2F5EB;
  --wait: #8A5A00; --wait-ink: #FFFFFF; --wait-tint: #FFF2D6;
  --danger: #B42318; --danger-tint: #FDECEA;
  --focus: #0E1630;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--font-base); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; font-family: var(--read); line-height: 1.55; color: var(--text);
  background: radial-gradient(1200px 520px at 50% -180px, var(--bg-glow), transparent 70%), var(--bg);
  background-attachment: fixed;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; font-weight: 600; }
h2 { font-size: 1.3rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 1em; max-width: 68ch; }
a { color: inherit; text-underline-offset: 3px; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.inline { display: inline; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.spread { display: flex; gap: 1rem; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: .5rem; background: var(--surface); color: var(--text); padding: .6rem 1rem; z-index: 50; border-radius: var(--r-sm); }
.skip:focus { left: .5rem; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .75rem clamp(1rem, 4vw, 2rem); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20; }
.brandmark { display: flex; align-items: center; gap: .65rem; text-decoration: none; font-family: var(--display); font-weight: 600; font-size: 1.05rem; }
.brandmark img { width: 40px; height: 40px; object-fit: contain; border-radius: 10px; background: #fff; padding: 3px; }
.brandmark-dot { width: 34px; height: 34px; border-radius: 50%; background: conic-gradient(from 200deg, var(--brand), var(--here), var(--brand)); box-shadow: 0 0 18px color-mix(in srgb, var(--brand) 60%, transparent); }
.mainnav { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
.mainnav a, .linkbtn { padding: .5rem .8rem; border-radius: var(--r-pill); text-decoration: none; color: var(--muted); font-size: .95rem; min-height: 44px; display: inline-flex; align-items: center; }
.mainnav a:hover, .linkbtn:hover { color: var(--text); background: var(--surface-2); }
.mainnav a[aria-current="page"] { color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.linkbtn { background: none; border: 0; font: inherit; cursor: pointer; }
.navtoggle { display: none; }
@media (max-width: 900px) {
  .navtoggle { display: inline-flex; min-height: 44px; padding: 0 1rem; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; }
  .mainnav { display: none; width: 100%; flex-direction: column; align-items: stretch; }
  .mainnav.open { display: flex; }
}

/* ---------- page shells ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 1.5rem clamp(1rem, 4vw, 2rem) 4rem; }
.narrow { max-width: 600px; margin: 0 auto; padding: 1.25rem 1rem 5rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 1.25rem; }
.panel + .panel { margin-top: 1rem; }
.panel h2 { margin-bottom: .75rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

/* ---------- alerts ---------- */
.alert { padding: .9rem 1.1rem; border-radius: var(--r-md); margin-bottom: 1rem; border: 1px solid; font-weight: 700; }
.alert-success { background: var(--here-tint); border-color: var(--here); }
.alert-error { background: var(--danger-tint); border-color: var(--danger); }
.alert-warn { background: var(--wait-tint); border-color: var(--wait); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 48px; padding: .65rem 1.25rem;
  border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font-family: var(--display); font-weight: 500; font-size: 1rem; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--brand); color: var(--on-brand); border-color: transparent; box-shadow: 0 8px 28px -10px var(--brand); }
.btn-primary:hover { filter: brightness(1.08); border-color: transparent; }
.btn-here { background: var(--here); color: var(--here-ink); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-quiet { background: transparent; }
.btn-block { width: 100%; }
.btn-huge { min-height: 72px; font-size: 1.2rem; font-weight: 600; border-radius: var(--r-lg); width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- forms ---------- */
label { display: block; font-weight: 700; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.hint { font-size: .875rem; color: var(--muted); margin-top: .25rem; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=url], input[type=date],
input[type=time], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 48px; padding: .6rem .85rem; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--field); color: var(--text); font: inherit; }
textarea { min-height: 96px; resize: vertical; }
input[type=color] { width: 72px; height: 48px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--field); padding: 4px; }
.check { display: flex; gap: .65rem; align-items: center; font-weight: 400; min-height: 44px; cursor: pointer; }
.check input { width: 24px; height: 24px; accent-color: var(--brand); flex: none; }
fieldset { border: 1px solid var(--line); border-radius: var(--r-md); padding: 1rem 1.1rem; margin: 0 0 1rem; }
legend { font-family: var(--display); font-weight: 600; padding: 0 .4rem; }
.form-grid { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* ---------- family page ---------- */
.family-head { text-align: center; padding: 1.25rem 0 .5rem; }
.family-head .logo { width: 84px; height: 84px; object-fit: contain; border-radius: 22px; background: #fff; padding: 6px; margin-bottom: .75rem; box-shadow: 0 10px 40px -12px var(--brand); }
.family-head .date { font-family: var(--display); color: var(--muted); font-size: 1rem; margin: 0; }
.family-head h1 { font-size: 1.9rem; margin: .2rem 0 0; }
.closed { text-align: center; padding: 1.25rem; border-radius: var(--r-md); border: 1px dashed var(--line); color: var(--muted); margin: 1rem 0; }
.everyone { margin: 1.25rem 0 1rem; }

.kids { list-style: none; margin: 0; padding: 0; display: grid; gap: .9rem; }
.kid { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1rem 1rem 1.1rem; }
.kid[data-status="in"] { border-color: color-mix(in srgb, var(--here) 55%, var(--line)); }
.kid[data-status="pickup"] { border-color: var(--wait); }
.kid-top { display: flex; align-items: center; gap: 1rem; }
.kid-name { font-family: var(--display); font-weight: 600; font-size: 1.3rem; line-height: 1.2; }
.kid-sub { color: var(--muted); font-size: .95rem; }
.kid-actions { margin-top: .9rem; }

/* The signature moment: the ring lights up when a child is checked in. */
.ring { --p: 0; flex: none; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--ring, var(--line)) calc(var(--p) * 1turn), var(--surface-2) 0); position: relative; }
.ring::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--surface); }
.ring span { position: relative; z-index: 1; font-family: var(--display); font-weight: 600; font-size: 1.35rem; }
.kid[data-status="in"] .ring { --p: 1; --ring: var(--here); box-shadow: 0 0 26px -6px var(--here); }
.kid[data-status="pickup"] .ring { --p: 1; --ring: var(--wait); box-shadow: 0 0 26px -6px var(--wait); }
.kid[data-status="out"] .ring { --p: 1; --ring: var(--muted); }
@property --p { syntax: "<number>"; inherits: true; initial-value: 0; }
.kid.just-now .ring { animation: fill 1.1s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes fill { from { --p: 0; box-shadow: none; } }
@media (prefers-reduced-motion: reduce) { .kid.just-now .ring { animation: none; } }

.status { display: inline-flex; align-items: center; gap: .4rem; font-weight: 700; font-size: .95rem; }
.status::before { content: ""; width: .65rem; height: .65rem; border-radius: 50%; background: currentColor; }
.status-in { color: var(--here); }
.status-pickup { color: var(--wait); }
.status-out { color: var(--muted); }

details.pick { border-radius: var(--r-md); }
details.pick > summary { list-style: none; }
details.pick > summary::-webkit-details-marker { display: none; }
.pick-list { display: grid; gap: .5rem; margin-top: .75rem; }
.pick-list .btn { justify-content: flex-start; }

.code-card { margin-top: .9rem; border-radius: var(--r-md); background: var(--wait-tint); border: 1px solid var(--wait); padding: .9rem 1rem; text-align: center; }
.code-card .code { font-family: var(--display); font-weight: 700; font-size: 2.6rem; letter-spacing: .18em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.family-foot { margin-top: 2rem; display: grid; gap: .75rem; }
.prefbar { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-pill); overflow: hidden; }
.seg button { min-height: 44px; min-width: 48px; padding: 0 .8rem; border: 0; background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); font-weight: 700; }

/* ---------- staff ---------- */
.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin: 1rem 0 1.5rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 1rem 1.1rem; }
.stat b { display: block; font-family: var(--display); font-size: 2rem; font-weight: 600; line-height: 1.1; }
.stat span { color: var(--muted); }
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.tabs a { padding: .5rem 1rem; border-radius: var(--r-pill); border: 1px solid var(--line); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.tabs a[aria-current="true"] { background: var(--brand); color: var(--on-brand); border-color: transparent; }

.board-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .65rem; }
.board-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: .9rem 1rem; display: grid; gap: .6rem; }
.board-item.wait { border-color: var(--wait); background: linear-gradient(90deg, var(--wait-tint), var(--surface) 60%); }
.board-item .who { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: baseline; }
.board-item .who strong { font-family: var(--display); font-size: 1.15rem; }
.care { background: var(--danger-tint); border-left: 4px solid var(--danger); padding: .4rem .7rem; border-radius: 6px; font-size: .95rem; }
.codeform { display: flex; gap: .5rem; flex-wrap: wrap; }
.codeform input { max-width: 9rem; font-family: var(--display); font-size: 1.3rem; letter-spacing: .15em; text-align: center; }

table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: .65rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-family: var(--display); font-weight: 500; color: var(--muted); font-size: .9rem; }
.tablewrap { overflow-x: auto; }
@media (max-width: 700px) {
  table.data.cards thead { display: none; }
  table.data.cards tr { display: block; border: 1px solid var(--line); border-radius: var(--r-md); padding: .5rem .75rem; margin-bottom: .6rem; background: var(--surface); }
  table.data.cards td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .35rem 0; }
  table.data.cards td::before { content: attr(data-label); color: var(--muted); font-weight: 700; }
}
.badge { display: inline-block; padding: .15rem .6rem; border-radius: var(--r-pill); font-size: .85rem; font-weight: 700; border: 1px solid var(--line); }
.badge-ok { color: var(--here); border-color: var(--here); }
.badge-warn { color: var(--wait); border-color: var(--wait); }
.badge-bad { color: var(--danger); border-color: var(--danger); }

.editlist { display: grid; gap: .75rem; }
.edititem { border: 1px solid var(--line); border-radius: var(--r-md); padding: 1rem; background: var(--surface-2); }
.linkbox { display: flex; gap: .5rem; }
.linkbox input { font-size: .85rem; }
.qr { width: 168px; height: 168px; background: #fff; border-radius: var(--r-sm); padding: 6px; }
.backup-codes { font-family: var(--display); font-size: 1.2rem; display: grid; grid-template-columns: repeat(2, minmax(0, 10rem)); gap: .4rem 1.5rem; padding: 1rem; background: var(--surface-2); border-radius: var(--r-md); }
.center { text-align: center; }
.auth-card { max-width: 440px; margin: 8vh auto 0; }

/* home */
.hero { text-align: center; padding: 10vh 1rem 2rem; max-width: 640px; margin: 0 auto; }
.hero .halo { width: 120px; height: 120px; margin: 0 auto 1.5rem; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(from 210deg, var(--brand), var(--here), var(--brand)); box-shadow: 0 0 80px -10px var(--brand); }
.hero .halo img, .hero .halo span { width: 104px; height: 104px; border-radius: 50%; background: var(--bg); object-fit: contain; padding: 14px; display: block; }

@media print { .topbar, .skip, .navtoggle { display: none; } body { background: #fff; color: #000; } }
