/* ── Reset & tokens ──────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
:root {
  --brand: #f97316;
  --brand-dk: #c2410c;
  --brand-light: #fed7aa;
  --bg: #fafaf9;
  --card-bg: #ffffff;
  --text: #1c1917;
  --muted: #78716c;
  --border: #e7e5e4;
  --radius: 16px;
  --radius-sm: 12px;
  --sh: 0 2px 12px rgba(0, 0, 0, 0.08);
  --sh-lg: 0 8px 28px rgba(0, 0, 0, 0.14);
}
html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}
button,
input,
select {
  font: inherit;
}
img {
  -webkit-user-drag: none;
  user-drag: none;
}

/* ── Access gate ─────────────────────────────────── */
.gate {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
}
.gate[hidden] {
  display: none;
}
.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  border-radius: 22px;
  box-shadow: var(--sh-lg);
  padding: 32px 26px;
  text-align: center;
}
.gate-card.shake {
  animation: shake 0.4s;
}
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
.gate-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 10px;
}
.gate-card h1 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 8px;
}
.gate-card p {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 20px;
  line-height: 1.5;
}
.gate-input-wrap {
  position: relative;
  margin-bottom: 14px;
}
#gate-input {
  width: 100%;
  padding: 15px 50px 15px 16px;
  border: 2px solid var(--border);
  border-radius: 14px;
  font-size: 1.1rem;
  min-height: 54px;
  outline: none;
  text-align: center;
  letter-spacing: 0.5px;
}
#gate-input:focus {
  border-color: var(--brand);
}
#gate-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1.2rem;
  padding: 10px;
  cursor: pointer;
  opacity: 0.6;
}
.gate-error {
  color: #b91c1c;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 14px;
}
.gate-submit {
  width: 100%;
  min-height: 54px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.2s;
}
.gate-submit:hover {
  background: var(--brand-dk);
}
.gate-submit:active {
  transform: scale(0.98);
}

/* ── Header ──────────────────────────────────────── */
header {
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: #fff;
  padding: 28px 20px 22px;
  text-align: center;
}
header h1 {
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.4px;
}
header p {
  margin-top: 5px;
  font-size: clamp(1rem, 2.5vw, 1.1rem);
  opacity: 0.92;
}
#member-count {
  display: inline-block;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 20px;
  padding: 5px 16px;
  font-weight: 700;
  margin-top: 10px;
  font-size: 1rem;
}

/* ── Controls ────────────────────────────────────── */
.controls {
  max-width: 1100px;
  margin: 20px auto 0;
  padding: 0 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tip-box {
  background: #fff7ed;
  border: 1.5px solid var(--brand-light);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 1rem;
  color: #7c2d12;
  line-height: 1.6;
}
.tip-box strong {
  color: var(--brand-dk);
}

.search-wrap {
  position: relative;
}
.search-wrap .si {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
  pointer-events: none;
}
#search-input {
  width: 100%;
  padding: 15px 16px 15px 46px;
  border: 2px solid var(--border);
  border-radius: 14px;
  font-size: 1.1rem;
  background: var(--card-bg);
  color: var(--text);
  outline: none;
  min-height: 52px;
  transition: border-color 0.2s;
}
#search-input:focus {
  border-color: var(--brand);
}

.filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-row .field {
  flex: 1 1 200px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.filter-row .field[hidden] {
  display: none;
}
.filter-row label {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--muted);
}
.filter-row select {
  width: 100%;
  padding: 13px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  background: var(--card-bg);
  color: var(--text);
  outline: none;
  cursor: pointer;
  min-height: 50px;
  transition: border-color 0.2s;
}
.filter-row select:focus {
  border-color: var(--brand);
}
.clear-btn {
  flex: 0 0 auto;
  padding: 13px 20px;
  min-height: 50px;
  background: #fee2e2;
  color: #b91c1c;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
.clear-btn:hover {
  background: #fecaca;
}

/* ── Stats bar ───────────────────────────────────── */
.stats-bar {
  max-width: 1100px;
  margin: 14px auto 0;
  padding: 0 14px;
  font-size: 1rem;
  color: var(--muted);
  font-weight: 600;
}

/* ── Grid & cards (large photos) ─────────────────── */
.grid {
  max-width: 1100px;
  margin: 14px auto 20px;
  padding: 0 14px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
@media (min-width: 640px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (min-width: 1024px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--sh);
  overflow: hidden;
  cursor: pointer;
  border: 1.5px solid var(--border);
  transition: transform 0.18s, box-shadow 0.18s;
  display: flex;
  flex-direction: column;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-lg);
}
.card:active {
  transform: scale(0.98);
}
.card:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

.card-photo-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--border);
  overflow: hidden;
}
.card-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  opacity: 0;
  transition: opacity 0.3s;
  -webkit-user-select: none;
  user-select: none;
}
.card-photo.loaded {
  opacity: 1;
}
.card-photo-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand-light), #fde68a);
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--brand-dk);
  transition: opacity 0.3s;
}
.card-photo-placeholder.hidden {
  opacity: 0;
  pointer-events: none;
}

.card-body {
  padding: 14px 16px 6px;
  flex: 1;
  -webkit-user-select: none;
  user-select: none;
}
.card-name {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 6px;
  word-break: break-word;
}
.card-camp {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--brand-dk);
  background: #fff7ed;
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}
.card-intro {
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-address {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-referral {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-referral span {
  font-weight: 700;
  color: #57534e;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 16px 16px;
}
.btn-call,
.btn-wa {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 8px;
  min-height: 48px;
  border-radius: 12px;
  font-size: 0.98rem;
  font-weight: 800;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.15s, transform 0.15s;
}
.btn-call:active,
.btn-wa:active {
  transform: scale(0.96);
}
.btn-call {
  background: #16a34a;
  color: #fff;
}
.btn-wa {
  background: #25d366;
  color: #fff;
}
.btn-call:hover,
.btn-wa:hover {
  filter: brightness(1.08);
}

/* ── Loader / infinite scroll states ─────────────── */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  color: var(--muted);
  font-weight: 600;
}
.loader[hidden] {
  display: none;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.end-msg {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}
#sentinel {
  height: 1px;
}

/* ── Empty / error states ────────────────────────── */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty .ei {
  font-size: 3rem;
  display: block;
  margin-bottom: 12px;
}
.empty p {
  font-size: 1.1rem;
  margin-bottom: 16px;
}
.retry-btn {
  padding: 12px 24px;
  min-height: 46px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}
.retry-btn:hover {
  background: var(--brand-dk);
}

/* ── Modal — desktop centre, mobile bottom-sheet ─── */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#modal-overlay.open {
  display: flex;
}
#modal {
  background: var(--card-bg);
  border-radius: 22px;
  width: 100%;
  max-width: 460px;
  max-height: 92vh;
  overflow-y: auto;
  position: relative;
  animation: popIn 0.22s cubic-bezier(0.34, 1.36, 0.64, 1);
  -webkit-overflow-scrolling: touch;
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}
@media (max-width: 540px) {
  #modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  #modal {
    max-width: 100%;
    max-height: 88vh;
    border-radius: 22px 22px 0 0;
    animation: slideUp 0.25s ease-out;
  }
  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}
.modal-handle {
  width: 44px;
  height: 5px;
  background: #d6d3d1;
  border-radius: 3px;
  margin: 12px auto 0;
}
@media (min-width: 541px) {
  .modal-handle {
    display: none;
  }
}
#modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  min-width: 40px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s;
}
#modal-close:hover {
  background: rgba(0, 0, 0, 0.65);
}
#modal-photo-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--border);
  overflow: hidden;
  border-radius: 22px 22px 0 0;
  position: relative;
}
#modal-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  opacity: 0;
  transition: opacity 0.3s;
}
#modal-photo.loaded {
  opacity: 1;
}
#modal-photo-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand-light), #fde68a);
  font-size: 4.5rem;
  font-weight: 800;
  color: var(--brand-dk);
  transition: opacity 0.3s;
}
#modal-photo-placeholder.hidden {
  opacity: 0;
  pointer-events: none;
}
#modal-body {
  padding: 18px 20px 26px;
}
#modal-name {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 8px;
  line-height: 1.3;
}
#modal-camp {
  display: inline-block;
  background: #fff7ed;
  color: var(--brand-dk);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 14px;
}
#modal-details {
  margin-bottom: 20px;
}
.modal-row {
  font-size: 1rem;
  color: var(--text);
  line-height: 1.6;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.modal-row:last-child {
  border-bottom: none;
}
.modal-row-label {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 2px;
}
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.modal-actions .btn-call,
.modal-actions .btn-wa {
  padding: 16px 10px;
  min-height: 56px;
  font-size: 1.1rem;
  border-radius: 16px;
}

/* ── Footer ──────────────────────────────────────── */
footer {
  text-align: center;
  padding: 18px;
  font-size: 0.88rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
