/*
 * Components.
 *
 * Each block here replaces one React component from the build this site was converted from,
 * and keeps its name: .card is ui/card.tsx, .btn is ui/button.tsx, .badge is ui/badge.tsx.
 * Hover and focus states are written out because there is no variant engine to generate them.
 */

/* ── Card (ui/card.tsx) ───────────────────────────────────────────────────── */
.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card-hover {
  transition: border-color 150ms ease;
}

.card-hover:hover {
  border-color: var(--border-strong);
}

.card-header {
  padding: 1.25rem 1.25rem 0.75rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.017em;
}

.card-desc {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.card-content {
  padding: 0 1.25rem 1.25rem;
}

.card-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* ── Button (ui/button.tsx) ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease,
    opacity 150ms ease;
  /* 44px minimum: this is used one-handed on a gym floor. */
  height: 2.75rem;
  padding: 0 1rem;
  font-size: 0.875rem;
}

.btn:disabled {
  pointer-events: none;
  opacity: 0.5;
}

.btn-primary {
  background-color: var(--accent);
  color: var(--accent-foreground);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

.btn-secondary {
  background-color: var(--surface-raised);
  color: var(--foreground);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--border-strong);
}

.btn-ghost {
  color: var(--muted);
}

.btn-ghost:hover {
  background-color: var(--surface-raised);
  color: var(--foreground);
}

.btn-danger {
  background-color: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  opacity: 0.9;
}

.btn-outline {
  border: 1px solid var(--border-strong);
  color: var(--foreground);
}

.btn-outline:hover {
  background-color: var(--surface-raised);
}

/*
 * A button whose label sits above a line of explanatory text.
 *
 * Needs `white-space: normal`: `.btn` sets nowrap so a label never breaks mid-word, but that
 * also stops the description wrapping, and an unwrappable sentence inside a button widens the
 * page on a phone.
 */
.btn-stack {
  height: auto;
  padding: 0.75rem 1rem;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.125rem;
  white-space: normal;
  text-align: left;
}

.btn-sm { height: 2.25rem; padding: 0 0.75rem; }
.btn-md { height: 2.5rem; padding: 0 1rem; }
.btn-lg { height: 3rem; padding: 0 1.5rem; font-size: 1rem; font-weight: 600; }
.btn-full { width: 100%; }

.link-accent {
  color: var(--accent);
  font-weight: 500;
}

.link-accent:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.hover-underline:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hover-text-foreground:hover { color: var(--foreground); }
.hover-bg-raised:hover { background-color: var(--surface-raised); }
.hover-bg-surface:hover { background-color: var(--surface); }

/* ── Badge (ui/badge.tsx) ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border-radius: 9999px;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge-dot {
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 9999px;
  background-color: currentColor;
  flex-shrink: 0;
}

.badge-success { background-color: var(--success-soft); color: var(--success); }
.badge-warning { background-color: var(--warning-soft); color: var(--warning); }
.badge-danger { background-color: var(--danger-soft); color: var(--danger); }
.badge-info { background-color: var(--info-soft); color: var(--info); }
.badge-neutral { background-color: var(--surface-raised); color: var(--muted); }
.badge-accent { background-color: var(--accent); color: var(--accent-foreground); }

/* ── Input (ui/input.tsx) ─────────────────────────────────────────────────── */
.input {
  /* 16px on mobile: anything smaller makes iOS Safari zoom on focus. */
  height: 2.75rem;
  width: 100%;
  border-radius: 0.75rem;
  background-color: var(--surface);
  padding: 0 0.875rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.input::placeholder {
  color: var(--faint);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--ring);
}

.input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.input[aria-invalid='true'] {
  border-color: var(--danger);
}

/* The compact field used inside admin action forms (admin/action-form.tsx FIELD_CLASS). */
.field-input {
  height: 2.5rem;
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background-color: var(--surface);
  padding: 0 0.75rem;
  font-size: 1rem;
}

.field-area {
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background-color: var(--surface);
  padding: 0.75rem;
  font-size: 1rem;
  resize: vertical;
}

.field-input:focus,
.field-area:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--ring);
}

@media (min-width: 768px) {
  .input,
  .field-input,
  .field-area {
    font-size: 0.875rem;
  }
}

.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground);
  margin-bottom: 0.375rem;
}

.hint {
  display: block;
  margin-top: 0.375rem;
  font-size: 0.75rem;
  color: var(--faint);
}

.error-text {
  margin-top: 0.375rem;
  font-size: 0.75rem;
  color: var(--danger);
}

/* A search field with a leading icon. */
.search-wrap { position: relative; }

.search-wrap .search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: var(--muted);
  pointer-events: none;
}

.search-wrap .input { padding-left: 2.25rem; }

/* ── Filter chips ─────────────────────────────────────────────────────────── */
.chip {
  border-radius: 9999px;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  background-color: var(--surface-raised);
  color: var(--muted);
  transition: color 150ms ease, background-color 150ms ease;
  cursor: pointer;
}

.chip:hover { color: var(--foreground); }

.chip-active {
  background-color: var(--accent);
  color: var(--accent-foreground);
}

.chip-quiet {
  background: none;
  padding: 0.25rem 0.625rem;
}

.chip-quiet.chip-active {
  background-color: var(--surface-raised);
  color: var(--foreground);
}

/* ── Icon tile ────────────────────────────────────────────────────────────── */
.icon-tile {
  display: grid;
  place-items: center;
  border-radius: 0.75rem;
  background-color: var(--surface-raised);
  color: var(--muted);
  flex-shrink: 0;
}

.icon-tile-accent {
  background-color: var(--accent);
  color: var(--accent-foreground);
}

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progress {
  height: 0.5rem;
  overflow: hidden;
  border-radius: 9999px;
  background-color: var(--surface-raised);
}

.progress-thin { height: 0.375rem; }

.progress-fill {
  height: 100%;
  border-radius: 9999px;
  background-color: var(--accent);
  transition: width 300ms ease;
}

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table {
  width: 100%;
  font-size: 0.875rem;
}

.table thead {
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.75rem;
  color: var(--muted);
}

.table th {
  font-weight: 500;
  padding: 0.75rem 1rem;
}

.table td {
  padding: 0.75rem 1rem;
}

.table tbody tr {
  border-bottom: 1px solid var(--border);
}

.table tbody tr:last-child {
  border-bottom: 0;
}

.table tbody tr:hover {
  background-color: var(--surface-raised);
}

/* A compact variant for reports, where column count matters more than air. */
.table-compact th,
.table-compact td {
  padding: 0.5rem 0.75rem;
  white-space: nowrap;
}

/* ── Row list (the repeated "Card > ul > li" register pattern) ───────────── */
.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.row:last-child { border-bottom: 0; }

a.row:hover,
.row-hover:hover { background-color: var(--surface-raised); }

.row-wrap { flex-wrap: wrap; }

/* ── Disclosure (admin/action-form.tsx Disclosure) ───────────────────────── */
.disclosure {
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background-color: var(--surface);
}

.disclosure > summary {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.disclosure > summary:hover { background-color: var(--surface-raised); }

.disclosure-body {
  border-top: 1px solid var(--border);
  padding: 1rem;
}

.caret {
  color: var(--muted);
  transition: transform 150ms ease;
}

details[open] > summary .caret { transform: rotate(90deg); }

/* ── Shells ───────────────────────────────────────────────────────────────── */
.shell { display: flex; min-height: 100dvh; }

.sidebar {
  display: none;
  width: 15rem;
  flex-shrink: 0;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background-color: var(--surface);
}

@media (min-width: 1024px) {
  .sidebar { display: flex; }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.017em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 0.75rem 1rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
  transition: background-color 150ms ease, color 150ms ease;
}

.sidebar-link:hover {
  background-color: var(--surface-raised);
  color: var(--foreground);
}

.sidebar-link-active {
  background-color: var(--surface-raised);
  color: var(--foreground);
  font-weight: 500;
}

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
}

/* Mobile: the sidebar collapses to a scrolling strip rather than a hamburger —
   reception staff switch between two or three of these constantly. */
.sidebar-strip {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background-color: var(--surface);
  padding: 0.5rem 0.75rem;
}

.sidebar-strip a {
  white-space: nowrap;
  border-radius: 0.5rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.sidebar-strip a:hover { background-color: var(--surface-raised); color: var(--foreground); }
.sidebar-strip a.sidebar-link-active { background-color: var(--surface-raised); color: var(--foreground); }

/* Must come AFTER the block above: same specificity, so source order decides. Hiding the
   strip from inside the earlier `.sidebar` media query was silently undone by the
   `display: flex` below it, and the strip showed on desktop alongside the sidebar. */
@media (min-width: 1024px) {
  .sidebar-strip {
    display: none;
  }
}

/* Member portal: bottom navigation on mobile, within thumb reach rather than at the top of
   the screen — members use this one-handed on a gym floor. */
.tabbar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 20;
  border-top: 1px solid var(--border);
  background-color: var(--surface);
  backdrop-filter: blur(8px);
}

.tabbar ul {
  display: flex;
  margin: 0 auto;
  max-width: 48rem;
}

.tabbar li { flex: 1; }

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.625rem 0;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--muted);
  transition: color 150ms ease;
}

.tabbar a:hover { color: var(--foreground); }
.tabbar a.tab-active { color: var(--accent); }

/* Respects the iOS home indicator so the last row is not half-covered. */
.tabbar-safe { height: env(safe-area-inset-bottom); }

/* Public site header. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--border);
  background-color: var(--background);
  backdrop-filter: blur(8px);
}

/* ── Hero glow (the landing page's one decorative flourish) ──────────────── */
.hero-glow {
  pointer-events: none;
  position: absolute;
  top: -10rem;
  left: 50%;
  width: 38rem;
  height: 38rem;
  transform: translateX(-50%);
  border-radius: 9999px;
  background-color: var(--accent-wash);
  filter: blur(64px);
}

/* ── Theme toggle ─────────────────────────────────────────────────────────── */
.theme-toggle {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  color: var(--muted);
}

.theme-toggle:hover { background-color: var(--surface-raised); color: var(--foreground); }

/* Only the icon for the active theme is shown. */
.dark .icon-sun { display: none; }
html:not(.dark) .icon-moon { display: none; }

/* ── Scanner ──────────────────────────────────────────────────────────────── */
.scan-frame {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  overflow: hidden;
  border-radius: 1rem;
  background-color: var(--surface-raised);
  display: grid;
  place-items: center;
}

.scan-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-reticle {
  position: absolute;
  inset: 18%;
  border: 2px solid var(--accent);
  border-radius: 0.75rem;
  box-shadow: 0 0 0 9999px rgb(0 0 0 / 0.35);
}

/* The result panel. Amber is not red, on purpose (docs/qr-security.md §4). */
.result {
  border-radius: 1rem;
  padding: 1.5rem;
}

.result-granted { background-color: var(--success-soft); color: var(--success); }
.result-retry { background-color: var(--warning-soft); color: var(--warning); }
.result-refused { background-color: var(--danger-soft); color: var(--danger); }

.result-body {
  margin-top: 1.25rem;
  border-radius: 0.75rem;
  background-color: var(--surface);
  padding: 1rem;
  color: var(--foreground);
}

/* ── Feedback line on admin forms ────────────────────────────────────────── */
.feedback { font-size: 0.875rem; }
.feedback-success { color: var(--success); }
.feedback-error { color: var(--danger); }

/* ── Permission (role) tag ────────────────────────────────────────────────── */
.perm {
  border-radius: 0.375rem;
  background-color: var(--surface-raised);
  padding: 0.25rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--muted);
}
