/* --------------------------------------------------------------------------
   Components. Every pressable thing is at least --tap tall and says in words
   what it does -- there are no icon-only controls anywhere in this app.
   -------------------------------------------------------------------------- */

/* ---- Top bar ---------------------------------------------------------- */

.topbar {
  background: var(--card);
  border-bottom: 2px solid var(--line);
  padding: 0.6rem 0;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}
.brand svg { flex: none; }

.textsize {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.textsize .label {
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.textsize button {
  min-width: 2.75rem;
  min-height: 2.75rem;
  border: 2px solid var(--line);
  background: var(--card);
  border-radius: 0.6rem;
  font-weight: 700;
  cursor: pointer;
}
.textsize button:hover { background: var(--accent-soft); }

/* ---- Bottom navigation ------------------------------------------------ */

/* Fixed and always visible. Hiding navigation behind a hamburger is the single
   most common way apps become unusable for someone who does not already know
   the app is there. */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-top: 2px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 30;
}
.tabbar ul {
  display: flex;
  margin: 0 auto;
  padding: 0;
  list-style: none;
  max-width: 46rem;
}
.tabbar li { flex: 1; }
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: var(--tap);
  padding: 0.4rem 0.15rem;
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  border-top: 4px solid transparent;
}
.tabbar a[aria-current='page'] {
  color: var(--accent);
  border-top-color: var(--accent);
  background: var(--accent-soft);
}
.tabbar svg { flex: none; }

/* ---- Cards ------------------------------------------------------------ */

.card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem;
  margin-bottom: var(--gap);
}
.card > :last-child { margin-bottom: 0; }
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.card.accent { border-color: var(--accent); border-width: 3px; }
.card.go { background: var(--go-soft); border-color: var(--go); }
.card.alert { background: var(--alert-soft); border-color: var(--alert); }
.card.info { background: var(--info-soft); border-color: var(--info); }

.stack > * + * { margin-top: var(--gap); }
.row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}
.grow { flex: 1 1 12rem; }

/* ---- Buttons ---------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--tap);
  padding: 0.6rem 1.35rem;
  border-radius: 0.75rem;
  border: 2px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}
.btn:hover { background: var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #9c3b23; }
.btn.done { background: var(--go); border-color: var(--go); color: #fff; }
.btn.done:hover { background: #255738; }
.btn.danger { background: var(--alert); border-color: var(--alert); color: #fff; }
.btn.wide { width: 100%; }
.btn.big { min-height: 5rem; font-size: 1.2rem; }
.btn.quiet { border-color: var(--line); font-weight: 600; }

/* ---- Chips and badges -------------------------------------------------- */

.chips { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chip {
  min-height: 2.9rem;
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.9rem;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.chip[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 2px solid currentColor;
}
.badge.go { color: var(--go); background: var(--go-soft); }
.badge.info { color: var(--info); background: var(--info-soft); }
.badge.alert { color: var(--alert); background: var(--alert-soft); }
.badge.plain { color: var(--ink-soft); background: var(--paper); }

/* ---- Forms ------------------------------------------------------------ */

.field { margin-bottom: var(--gap); }
.field label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.35rem;
}
.field .hint {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0 0 0.35rem;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0.6rem 0.75rem;
  border: 2px solid var(--ink-soft);
  border-radius: 0.6rem;
  background: var(--card);
}
.field textarea { min-height: 7rem; resize: vertical; }

/* ---- Person and event bits --------------------------------------------- */

.avatar {
  flex: none;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.15rem;
  border: 2px solid var(--line);
  background: var(--accent-soft);
  color: var(--accent);
}
.avatar.lg { width: 4.5rem; height: 4.5rem; font-size: 1.5rem; }

.meta {
  color: var(--ink-soft);
  font-size: 0.92rem;
  margin: 0 0 0.4rem;
}
.meta strong { color: var(--ink); }

.when {
  font-weight: 700;
  color: var(--accent);
}

.empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--ink-soft);
}

.list-plain { list-style: none; margin: 0; padding: 0; }

/* ---- Disclosure -------------------------------------------------------- */

/* A native <details>, but the summary is the size of a button and says what
   opening it will do. The default triangle is far too small to aim at. */
.disclose {
  border: 2px solid var(--line);
  border-radius: 0.75rem;
  background: var(--card);
  margin-bottom: var(--gap);
}
.disclose > summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: var(--tap);
  padding: 0.6rem 1rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.disclose > summary::-webkit-details-marker { display: none; }
.disclose > summary::before {
  content: '▸';
  font-size: 1.3rem;
  color: var(--accent);
}
.disclose[open] > summary::before { content: '▾'; }
.disclose > *:not(summary) { padding: 0 1rem 1rem; margin-bottom: 0; }

/* ---- Toast ------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(6.5rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 0.9rem 1.4rem;
  border-radius: 0.75rem;
  font-weight: 700;
  max-width: 90vw;
  text-align: center;
  z-index: 40;
}
.toast[hidden] { display: none !important; }

/* ---- Dialog ------------------------------------------------------------ */

dialog {
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 34rem;
  width: calc(100% - 2rem);
  background: var(--card);
  color: var(--ink);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }

/* ---- Small screens ----------------------------------------------------- */

@media (max-width: 30rem) {
  .tabbar a { font-size: 0.72rem; }
  .card { padding: 1rem; }

  /* On a phone the header must not cost half the screen before the reader has
     seen anything. The controls stay finger-sized; only the chrome shrinks. */
  .topbar { padding: 0.35rem 0; }
  .topbar .wrap { flex-wrap: nowrap; }
  .brand { font-size: 1rem; }
  .brand svg { width: 22px; height: 22px; }
  .textsize .label { display: none; }
}
