/* =========================================================================
   IFAT Onboarding — styles
   Mobile-first. Low-end-Android-friendly (system fonts, no web-font fetch).
   -------------------------------------------------------------------------
   BRAND TOKENS — swap these for IFAT's real brand when assets arrive.
   The ✊ emoji logo in markup is a placeholder; drop the real logo and set
   --logo-url below, or replace the .brand-mark__logo / .id-card__logo nodes.
   ========================================================================= */
:root {
  --ifat-red:      #E8112D;   /* IFAT brand red (from logo) */
  --ifat-red-dark: #B80C22;
  --ifat-ink:      #141414;
  --ifat-paper:    #ffffff;
  --ifat-bg:       #f4f2ef;
  --ifat-muted:    #6b6b6b;
  --ifat-line:     #e3e0db;
  --wa-green:      #25D366;
  --wa-green-dark: #1da851;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(20,20,20,.12);
  --shadow-card: 0 18px 50px rgba(20,20,20,.28);
  --maxw: 460px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans",
          "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ifat-ink);
  background: var(--ifat-bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  min-height: 100dvh;
}

/* ---------- Language bar ---------- */
.lang-bar {
  position: fixed; top: 10px; right: 10px; z-index: 30;
  background: #fff; border: 1px solid var(--ifat-line);
  border-radius: 999px; box-shadow: var(--shadow);
}
.lang-select {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: 600 13px/1 var(--font); color: var(--ifat-ink);
  padding: 9px 30px 9px 15px; border-radius: 999px; max-width: 160px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23141414' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.lang-select:focus { outline: none; box-shadow: 0 0 0 3px rgba(232,17,45,.18); }

/* ---------- App shell / screens ---------- */
.app { max-width: var(--maxw); margin: 0 auto; padding: 16px; min-height: 100dvh; }
.screen { display: none; animation: fade .25s ease; }
.screen.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.screen__title { font-size: 24px; font-weight: 800; margin: 4px 0 6px; letter-spacing: -.01em; }
.screen__title--center { text-align: center; }
.screen__sub { color: var(--ifat-muted); margin: 0 0 20px; }
.screen__sub--center { text-align: center; }

/* ---------- Landing ---------- */
.landing { padding: 56px 8px 32px; text-align: center; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; margin-bottom: 28px; min-height: 76px; }
.logo-img { height: 76px; width: auto; display: none; }          /* shown once logo.png loads */
/* Boxed "IFAT" fallback — mirrors the logo (black box, white fill, red A) */
.logo-mark {
  display: inline-flex; align-items: center;
  border: 4px solid var(--ifat-ink); border-radius: 14px; background: #fff;
  padding: 7px 18px; font-weight: 900; font-size: 42px; line-height: 1;
  letter-spacing: .01em; color: var(--ifat-ink);
}
.logo-mark__a { color: var(--ifat-red); }
.landing__title { font-size: 30px; line-height: 1.15; font-weight: 800; margin: 0 0 12px; letter-spacing: -.02em; }
.landing__sub { color: var(--ifat-muted); font-size: 16px; margin: 0 auto 26px; max-width: 34ch; }
.landing__points {
  list-style: none; padding: 0; margin: 0 auto 30px; max-width: 30ch; text-align: left;
  display: inline-block;
}
.landing__points li {
  position: relative; padding: 7px 0 7px 28px; font-size: 15px;
}
.landing__points li::before {
  content: "✓"; position: absolute; left: 0; top: 7px;
  color: var(--ifat-red); font-weight: 900;
}
.landing__count { margin-top: 18px; color: var(--ifat-muted); font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: var(--radius-sm); cursor: pointer;
  font: 700 16px/1 var(--font); padding: 15px 22px; width: 100%;
  transition: transform .06s ease, background .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.985); }
.btn--xl { padding: 17px 22px; font-size: 17px; }
.btn--primary { background: var(--ifat-red); color: #fff; box-shadow: 0 6px 16px rgba(200,16,46,.28); }
.btn--primary:hover { background: var(--ifat-red-dark); }
.btn--ghost { background: #fff; color: var(--ifat-ink); border: 1.5px solid var(--ifat-line); }
.btn--ghost:hover { border-color: var(--ifat-ink); }
.btn--whatsapp { background: var(--wa-green); color: #fff; box-shadow: 0 6px 16px rgba(37,211,102,.3); }
.btn--whatsapp:hover { background: var(--wa-green-dark); }

.back-link {
  background: none; border: 0; color: var(--ifat-muted); cursor: pointer;
  font: 600 14px/1 var(--font); padding: 8px 0; margin-bottom: 10px;
}
.back-link--center { display: block; margin: 22px auto 0; }
.back-link:hover { color: var(--ifat-ink); }

/* ---------- Form ---------- */
.form-wrap { padding: 10px 2px 40px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 14px; font-weight: 700; margin-bottom: 7px; }
.field input, .field select {
  width: 100%; font: 400 16px/1.2 var(--font); color: var(--ifat-ink);
  padding: 14px 14px; border: 1.5px solid var(--ifat-line); border-radius: var(--radius-sm);
  background: #fff; appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23141414' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--ifat-red); box-shadow: 0 0 0 3px rgba(200,16,46,.14);
}
.field select:disabled { background-color: #f3f3f3; color: var(--ifat-muted); cursor: not-allowed; }
.field--age { max-width: 140px; }

.phone-input { display: flex; align-items: stretch; }
.phone-input__cc {
  display: flex; align-items: center; padding: 0 12px; font-weight: 700; font-size: 16px;
  background: #f3f3f3; border: 1.5px solid var(--ifat-line); border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm); color: var(--ifat-ink);
}
.phone-input input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.field.has-error input, .field.has-error select { border-color: var(--ifat-red); }
.err { display: none; color: var(--ifat-red); font-size: 13px; font-weight: 600; margin-top: 6px; }
.field.has-error .err { display: block; }

#submitBtn { margin-top: 8px; }

/* Multi-select app chips */
.field-hint { margin: -2px 0 10px; font-size: 13px; color: var(--ifat-muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips__empty { color: var(--ifat-muted); font-size: 14px; padding: 4px 0; }
.chip {
  border: 1.5px solid var(--ifat-line); background: #fff; color: var(--ifat-ink);
  font: 600 14px/1 var(--font); padding: 11px 15px; border-radius: 999px; cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.chip:hover { border-color: var(--ifat-ink); }
.chip.is-selected {
  background: var(--ifat-red); border-color: var(--ifat-red); color: #fff;
  box-shadow: 0 3px 10px rgba(232,17,45,.28);
}
.chip.is-selected::before { content: "✓ "; font-weight: 900; }
.field.has-error .chips { outline: 2px solid rgba(232,17,45,.25); outline-offset: 6px; border-radius: 10px; }

/* Photo picker */
.field--photo .photo-pick { display: flex; align-items: center; gap: 14px; }
.photo-pick__preview {
  width: 66px; height: 66px; flex: 0 0 66px; border-radius: 50%; overflow: hidden;
  background: #fff; border: 2px dashed var(--ifat-line);
  display: flex; align-items: center; justify-content: center;
  color: var(--ifat-muted); font-size: 30px; font-weight: 300;
}
.photo-pick__preview img { width: 100%; height: 100%; object-fit: cover; display: none; }
.photo-pick__preview.has-photo { border-style: solid; border-color: var(--ifat-red); }
.photo-pick__preview.has-photo img { display: block; }
.photo-pick__preview.has-photo #photoPreviewPlus { display: none; }
.photo-pick__side { flex: 1; }
.photo-pick__hint { margin: 7px 0 0; font-size: 12px; color: var(--ifat-muted); line-height: 1.35; }
.photo-pick__remove { background: none; border: 0; color: var(--ifat-red); font: 600 13px/1 var(--font); cursor: pointer; padding: 7px 0 0; }
.btn--sm { width: auto; padding: 9px 15px; font-size: 14px; }

/* ---------- Success / card ---------- */
.success-wrap { padding: 16px 2px 40px; }
.card-stage { display: flex; justify-content: center; margin: 8px 0 24px; }

/* The ID card — portrait membership card (photo, QR, dates, signature) */
.id-card {
  width: 100%; max-width: 340px; aspect-ratio: 54 / 86;
  background: #fff; color: var(--ifat-ink);
  border-radius: 18px; overflow: hidden; position: relative;
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; padding-left: 26px; /* room for the stripe */
}

/* Vertical ID stripe down the left edge */
.id-card__stripe {
  position: absolute; left: 0; top: 0; bottom: 0; width: 26px;
  background: linear-gradient(var(--ifat-red), var(--ifat-red-dark));
  color: rgba(255,255,255,.95);
  writing-mode: vertical-rl; transform: rotate(180deg);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; letter-spacing: .22em; font-variant-numeric: tabular-nums;
}

/* Header band */
.id-card__header {
  background: linear-gradient(135deg, var(--ifat-red), var(--ifat-red-dark));
  color: #fff; padding: 13px 15px;
  display: flex; align-items: center; justify-content: space-between;
}
.id-card__brand { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.id-card__logo-img { height: 30px; width: auto; display: block; }
.id-card__org-sub {
  display: block; font-size: 7.5px; opacity: .92; line-height: 1.25; max-width: 24ch;
  text-transform: uppercase; letter-spacing: .03em;
}
.id-card__badge {
  font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.4);
  padding: 4px 8px; border-radius: 999px; white-space: nowrap;
}

/* Body */
.id-card__body { flex: 1; padding: 14px 16px 16px; display: flex; flex-direction: column; }
.id-card__main { display: flex; gap: 12px; justify-content: space-between; }
.id-card__info { flex: 1; min-width: 0; }
.id-card__name { font-size: 19px; font-weight: 800; line-height: 1.12; color: var(--ifat-ink); }
.id-card__role {
  font-size: 11px; font-weight: 600; color: var(--ifat-muted); margin-top: 3px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.id-card__fields { margin: 13px 0 0; display: grid; gap: 9px; }
.id-card__fields dt { font-size: 8px; text-transform: uppercase; letter-spacing: .08em; color: var(--ifat-muted); }
.id-card__fields dd { margin: 0; font-size: 12px; font-weight: 700; color: var(--ifat-ink); font-variant-numeric: tabular-nums; }

/* Photo (falls back to initial) */
.id-card__photo {
  width: 76px; height: 94px; flex: 0 0 76px; border-radius: 8px; overflow: hidden;
  background: linear-gradient(145deg, var(--ifat-red), var(--ifat-red-dark)); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 900;
  border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.id-card__photo img { width: 100%; height: 100%; object-fit: cover; display: none; }
.id-card__photo.has-photo img { display: block; }
.id-card__photo.has-photo span { display: none; }

/* Signature */
.id-card__sign { margin-top: 14px; }
.id-card__sign-name { display: block; font-family: 'Caveat', cursive; font-size: 30px; line-height: .9; color: var(--ifat-ink); }
.id-card__sign-line {
  display: block; border-top: 1px solid var(--ifat-line); margin-top: 3px; padding-top: 3px;
  font-size: 8px; text-transform: uppercase; letter-spacing: .08em; color: var(--ifat-muted);
}

/* Footer: QR + caption */
.id-card__footer { margin-top: auto; padding-top: 14px; display: flex; align-items: center; gap: 12px; }
.id-card__qr { width: 84px; height: 84px; flex: 0 0 84px; }
.id-card__qr img, .id-card__qr canvas { width: 84px !important; height: 84px !important; display: block; }
.id-card__qr-cap strong { display: block; font-size: 12px; font-weight: 800; color: var(--ifat-red); }
.id-card__qr-cap span { display: block; font-size: 10px; color: var(--ifat-muted); margin-top: 2px; line-height: 1.3; }

/* ---------- Actions / WhatsApp block ---------- */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.whatsapp-cta {
  background: #fff; border: 1px solid var(--ifat-line); border-radius: var(--radius);
  padding: 18px; text-align: center; box-shadow: var(--shadow);
}
.whatsapp-cta p { margin: 0 0 14px; font-size: 14px; color: var(--ifat-muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ifat-ink); color: #fff; padding: 12px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 50; max-width: 90vw;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 360px) {
  .landing { padding-top: 40px; }
  .landing__title { font-size: 26px; }
  .id-card { padding: 15px 16px; }
}
