/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 56px;
  padding: 0 var(--space-5);
  border: none;
  border-radius: var(--radius-lg);
  font-weight: 600;
  font-size: 17px;
  line-height: 1;
  text-decoration: none;
  transition: transform var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out),
              opacity var(--duration-fast) var(--ease-out);
  user-select: none;
}
.btn--block { width: 100%; }

.btn--primary { background: var(--color-red); color: var(--color-white); }
.btn--primary:active { transform: scale(0.98); background: var(--color-red-dark); }

.btn--secondary {
  background: transparent;
  border: 1.5px solid var(--color-red);
  color: var(--color-red-dark);
}
.btn--secondary:active { transform: scale(0.98); background: rgba(224,49,49,0.06); }

.btn--ghost {
  height: auto;
  padding: var(--space-2) var(--space-3);
  background: none;
  border: none;
  color: var(--color-red-dark);
  text-decoration: underline;
  font-size: 16px;
  font-weight: 500;
}
.btn--ghost:active { opacity: 0.7; }

.btn--dark { background: var(--color-ink); color: var(--color-white); }
.btn--dark:active { transform: scale(0.98); background: #000; }

.btn--on-red { background: var(--color-white); color: var(--color-red-dark); }
.btn--on-red:active { transform: scale(0.98); background: #f3f3f3; }

/* Emergency call action — strongest red, for the real tel:911 button. */
.btn--danger { background: var(--color-red); color: var(--color-white); font-weight: 700; }
.btn--danger:active { transform: scale(0.98); background: var(--color-red-dark); }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.4;
  pointer-events: none;
}

.btn .icon { width: 20px; height: 20px; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
}
.card--elevated { box-shadow: var(--shadow-elevated); }
.card--flush { padding: 0; overflow: hidden; }

/* ============================================================
   Badges & pills
   ============================================================ */
.badge-glass {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: rgba(0,0,0,0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--color-white);
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  animation: badge-in 220ms var(--ease-out);
}
@keyframes badge-in {
  from { opacity: 0; transform: translateY(4px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .badge-glass { animation: none; }
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  background: var(--color-gray-bg);
  color: var(--color-gray-text);
}
.pill--green { background: rgba(47,158,68,0.12); color: var(--color-green); }

/* ============================================================
   Segmented control (Recognize mode toggle)
   ============================================================ */
.segmented {
  display: inline-flex;
  padding: 4px;
  background: rgba(0,0,0,0.45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-pill);
}
.segmented button {
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.85);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  transition: background-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}
.segmented button[aria-selected="true"] {
  background: var(--color-white);
  color: var(--color-ink);
}

/* Light variant: the camera overlay is dark, the checklist is not. */
.segmented--light {
  display: flex;
  width: 100%;
  background: rgba(0,0,0,0.05);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.segmented--light button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  color: var(--color-ink);
  opacity: 0.55;
  padding: 8px 10px;
}
.segmented--light button[aria-selected="true"] {
  background: var(--color-white);
  opacity: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.segmented__sub {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.6;
}

/* ============================================================
   Checkbox
   ============================================================ */
.check-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  padding: var(--space-3) 0;
  cursor: pointer;
}
.check-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.check-box {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--color-gray-divider);
  background: transparent;
  display: grid;
  place-items: center;
  transition: background-color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}
.check-box svg { width: 14px; height: 14px; stroke: var(--color-white); opacity: 0; transition: opacity var(--duration-fast); }
.check-row input:checked + .check-box {
  background: var(--color-red);
  border-color: var(--color-red);
}
.check-row input:checked + .check-box svg { opacity: 1; }
.check-row input:focus-visible + .check-box { outline: 2px solid var(--color-blue); outline-offset: 2px; }
.check-label { font-size: 16px; line-height: 1.4; }

/* ============================================================
   Progress bar (Guide)
   ============================================================ */
.progress {
  display: flex;
  gap: 4px;
  width: 100%;
}
.progress__seg {
  flex: 1;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--color-gray-divider);
  overflow: hidden;
}
.progress__seg::after {
  content: "";
  display: block;
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left;
  background: var(--color-red);
  border-radius: var(--radius-pill);
  transition: transform var(--duration-base) var(--ease-out);
}
.progress__seg--filled::after { transform: scaleX(1); }

/* ============================================================
   Icon button (replay, back)
   ============================================================ */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  color: var(--color-gray-text);
}
.icon-btn:active { background: var(--color-gray-bg); }
.icon-btn svg { width: 22px; height: 22px; }

/* ============================================================
   Bottom tab nav
   ============================================================ */
/* Floating pill, inset from the edges (iOS-style). Present on every screen,
   including full-screen modals — nothing hides it. */
.tabbar {
  position: absolute;
  /* Respect side insets too — in landscape on a notched phone the safe area
     moves to the left/right edges, and a fixed inset would tuck the bar under
     the sensor housing or the rounded corner. */
  left: max(var(--tabbar-inset), env(safe-area-inset-left));
  right: max(var(--tabbar-inset), env(safe-area-inset-right));
  bottom: max(var(--space-4), env(safe-area-inset-bottom));
  z-index: 40;
  display: none;
  gap: var(--space-1);
  padding: 6px;
  /* Rounded rectangle that tracks the bezel — see --tabbar-radius for why this
     is a scaled radius rather than the naive "device radius minus inset". */
  border-radius: var(--tabbar-radius);
  /* Translucent material rather than flat white, so content scrolling beneath
     shows through the way UITabBar does. */
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 0.5px solid rgba(17, 24, 39, 0.10);   /* iOS hairline */
  /* Two layers: a tight contact shadow plus a soft ambient one. */
  box-shadow:
    0 1px 2px rgba(17, 24, 39, 0.06),
    0 8px 28px rgba(17, 24, 39, 0.14);
}

/* Safari/WKWebView drops the element behind an un-blurred backdrop if the
   filter is unsupported — fall back to opaque so the bar never goes muddy. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .tabbar { background: var(--color-white); }
}
.tabbar--visible { display: flex; }
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: none;
  background: none;
  color: var(--color-gray-text);
  font-size: 11px;
  font-weight: 600;
  padding: 7px 0 6px;
  border-radius: var(--radius-pill);
  transition: background var(--duration-base) var(--ease-out);
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-selected="true"] { color: var(--color-red-dark); background: rgba(224, 49, 49, 0.10); }
/* iOS-style press feedback: a brief inward scale, skipped under reduced motion. */
.tab:active { transform: scale(0.94); }
@media (prefers-reduced-motion: reduce) { .tab:active { transform: none; } }

/* ============================================================
   List row (Medic handoff summary)
   ============================================================ */
.summary-row {
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-gray-divider);
}
.summary-row:last-child { border-bottom: none; }
.summary-row .label { display: block; margin-bottom: 4px; }
.summary-row .value { font-weight: 700; font-size: 16px; color: var(--color-ink); }

/* Generic icon sizing */
.icon { width: 24px; height: 24px; stroke-width: 2; }

/* ============================================================
   Debug panel (hidden ?debug reveal — pitch/QA only)
   Self-contained dark "console" card so it reads the same over the
   checklist's light background and the camera sheet's dark one.
   ============================================================ */
.debug-panel {
  margin-top: var(--space-3);
  background: #14151a;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  color: rgba(255,255,255,0.92);
  font-size: 12px;
}
.debug-panel__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-3);
}
.debug-panel__tag {
  font-weight: 700; letter-spacing: 0.1em;
  color: #74c0fc;
}
.debug-panel__prob {
  font-variant-numeric: tabular-nums;
  font-weight: 700; font-size: 14px;
}
.debug-panel__flag {
  color: #ffd43b; font-weight: 600;
  margin-bottom: var(--space-3);
}
.debug-panel__bars { display: flex; flex-direction: column; gap: 6px; max-height: 180px; overflow-y: auto; }
.debug-bar { display: grid; grid-template-columns: 40% 1fr auto; align-items: center; gap: var(--space-2); }
.debug-bar__label { color: rgba(255,255,255,0.8); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.debug-bar__track { height: 8px; background: rgba(255,255,255,0.1); border-radius: var(--radius-pill); overflow: hidden; }
.debug-bar__fill { height: 100%; background: linear-gradient(90deg, #4dabf7, #74c0fc); border-radius: var(--radius-pill); }
.debug-bar__weight { font-variant-numeric: tabular-nums; color: #8ce99a; }
.debug-panel__empty { color: rgba(255,255,255,0.6); }
.debug-panel__note {
  margin-top: var(--space-3);
  color: rgba(255,255,255,0.55);
  font-style: italic;
}
