/* Volunteer app. Tokens and the reset live in tokens.css, which the admin
   screen loads too — one palette, defined once. */

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  /* System stack: zero download, instant offline, and reliable coverage of the
     diacritics in the roster across Android versions. */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

.sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

#app { max-width: 560px; margin: 0 auto; }

.screen { display: none; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
html[data-screen="unlock"]   .screen[data-name="unlock"],
html[data-screen="patient"]  .screen[data-name="patient"],
html[data-screen="activity"] .screen[data-name="activity"],
html[data-screen="note"]     .screen[data-name="note"],
html[data-screen="done"]     .screen[data-name="done"] {
  display: block;
  animation: step var(--t-step) var(--ease);
}
@keyframes step { from { opacity: 0; transform: translateY(6px); } }

/* ─────────────────────────────────────────── buttons */

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: var(--tap);
  padding: 0 20px;
  border-radius: var(--r-card);
  border: 1px solid transparent;
  font: inherit; font-weight: 600;
  cursor: pointer;
  position: relative; overflow: hidden;
  transition: transform var(--t-press) var(--ease), background var(--t-press) var(--ease);
}
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--border); }
.btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

:where(button, input, textarea, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─────────────────────────────────────────── unlock */

.unlock-wrap { min-height: 100dvh; display: flex; flex-direction: column;
  justify-content: center; gap: 12px; max-width: 380px; margin: 0 auto; }
.unlock-title { font-size: 28px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.unlock-sub { color: var(--ink-muted); margin: 0 0 12px; }
.label { display: block; font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.pin-input {
  width: 100%; min-height: var(--tap);
  padding: 0 16px; margin-bottom: 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--r-card);
  font: inherit; font-size: 22px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
}
.pin-input::placeholder { color: var(--ink-muted); }
.field-err { color: var(--danger); font-size: 15px; margin: -6px 0 12px; }
.unlock-note { color: var(--ink-muted); font-size: 15px; margin-top: 16px; }
.shake { animation: shake 180ms var(--ease); }
@keyframes shake { 25% { transform: translateX(-4px);} 75% { transform: translateX(4px);} }

/* ─────────────────────────────────────────── top bar */

.bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 12px;
  min-height: 64px; padding: 8px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.badge {
  background: var(--accent); color: var(--on-accent);
  border-radius: var(--r-pill);
  padding: 6px 14px;
  font-size: 13px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap;
}
.chip {
  margin-left: auto;
  min-height: 44px; padding: 0 16px;
  background: var(--sunk); color: var(--ink);
  border: 1px solid transparent; border-radius: var(--r-pill);
  font: inherit; font-weight: 600; cursor: pointer;
}
/* A date that is not today must look different. A wrong date left unnoticed is
   the quiet failure mode of this whole app. */
.chip[data-backdated="true"] { color: var(--warn); border-color: var(--warn); background: transparent; }
.date-native { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }

.back {
  display: grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  background: none; border: 0; border-radius: var(--r-pill);
  color: var(--ink); cursor: pointer;
}
.back svg { width: 24px; height: 24px; fill: currentColor; }
.bar-title { font-size: 20px; font-weight: 600; margin: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }

/* ─────────────────────────────────────────── search + list */

.search-wrap { position: relative; margin: 12px 0; }
.search {
  width: 100%; min-height: var(--tap);
  padding: 0 48px 0 16px;
  background: var(--sunk); color: var(--ink);
  border: 1px solid transparent; border-radius: var(--r-card);
  font: inherit; font-size: 17px;
}
.search::placeholder { color: var(--ink-muted); }
.search::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px;
  background: none; border: 0; border-radius: var(--r-pill);
  color: var(--ink-muted); font-size: 26px; line-height: 1; cursor: pointer;
}

.stale { color: var(--warn); font-size: 15px; margin: 0 0 8px; }

.list { list-style: none; margin: 0; padding: 0; content-visibility: auto; }
.row {
  display: flex; align-items: center;
  width: 100%; min-height: 64px;
  padding: 8px 12px;
  background: none; border: 0; border-bottom: 1px solid var(--border);
  color: var(--ink); font: inherit; font-size: 20px; font-weight: 600;
  text-align: left; cursor: pointer;
  transition: background var(--t-press) var(--ease);
}
.row:active { background: var(--sunk); }
.row mark { background: none; color: var(--accent); font-weight: 700; }
.row-other { margin-top: 12px; border-top: 1px solid var(--border); color: var(--ink-muted); }

.empty { padding: 32px 0; text-align: center; }
.empty-msg { color: var(--ink-muted); margin: 0 0 16px; }
.empty-term { color: var(--ink); font-weight: 600; }

/* ─────────────────────────────────────────── activity grid */

.groups { padding-top: 8px; }
.group-head {
  margin: 24px 0 8px;
  color: var(--ink-muted);
  font-size: 13px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
}
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 600px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile {
  display: flex; align-items: center;
  min-height: 72px; padding: 12px 14px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--r-card);
  box-shadow: var(--shadow-1);
  font: inherit; font-size: 16px; font-weight: 600; line-height: 1.25;
  text-align: left; cursor: pointer;
  transition: background var(--t-press) var(--ease), transform var(--t-press) var(--ease);
}
.tile:active { transform: scale(.98); background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* ─────────────────────────────────────────── note */

.note-wrap { padding-top: 24px; }
.note-input {
  width: 100%; padding: 12px 16px; margin-bottom: 8px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--r-card);
  font: inherit; resize: vertical;
}
.note-count { color: var(--ink-muted); font-size: 15px; margin: 0 0 16px; text-align: right; }

/* ─────────────────────────────────────────── confirmation */

.done-wrap { min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; text-align: center; }
.tick { width: 72px; height: 72px; margin-bottom: 8px; }
.tick-ring, .tick-path { stroke: var(--success); stroke-width: 3; stroke-linecap: round; }
.tick-path { stroke-width: 4; stroke-linejoin: round;
  stroke-dasharray: 44; stroke-dashoffset: 44;
  animation: draw 320ms var(--ease) 80ms forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.done-line { font-size: 24px; margin: 0; letter-spacing: -.01em; }
.done-line b { display: block; }
.done-sep { display: none; }
.done-date { color: var(--ink-muted); margin: 0 0 24px; }
.done-actions { display: grid; gap: 8px; width: 100%; max-width: 380px; }

/* The Undo window is the whole safety net. Entries are held locally for five
   seconds, so undo means the entry never leaves the phone at all. */
.undo-bar {
  position: absolute; left: 0; bottom: 0; height: 3px;
  width: 100%; background: var(--ink-muted); transform-origin: left;
  animation: drain 5s linear forwards;
}
@keyframes drain { to { transform: scaleX(0); } }

.foot { padding: 32px 0 40px; text-align: center; }
.linkbtn {
  min-height: var(--tap); padding: 0 16px;
  background: none; border: 0; color: var(--ink-muted);
  font: inherit; font-size: 15px; text-decoration: underline;
  text-underline-offset: 3px; cursor: pointer;
}
.linkbtn:active { color: var(--ink); }

/* ─────────────────────────────────────────── outbox status */

.pending {
  position: fixed; left: 0; right: 0;
  bottom: env(safe-area-inset-bottom);
  min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  padding: 10px 16px;
  background: var(--surface); color: var(--warn);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-2);
  font-size: 15px; font-weight: 600;
}
.pending[data-state="sent"] { color: var(--success); }

/* ─────────────────────────────────────────── reduced motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  /* The drain bar carries meaning, so it degrades to a static full bar and the
     button label shows a numeric countdown instead. */
  .undo-bar { animation: none; }
}
