/*
 * EngajaPlay — estilos do app do usuário. Mobile-first; só usa as variáveis de tokens.css.
 * Sem framework e sem build: o que está aqui é o que vai para o navegador.
 */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; letter-spacing: -0.01em; }
a { color: var(--link, var(--primary)); }
button { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--reward); outline-offset: 2px; border-radius: 8px; }

/* ---------- shell ---------- */

.app {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(88px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar .who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700;
}
.who-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who { min-width: 0; }
.who-sub { font-size: 13px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.points-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--reward); color: var(--on-reward);
  border-radius: 999px; padding: 9px 14px 9px 10px;
  font-family: var(--font-display); font-weight: 800; font-size: 16px;
  text-decoration: none; min-height: 44px;
  position: relative;
}
.points-chip svg { width: 22px; height: 22px; flex: none; }
.points-chip.bump { animation: bump 0.5s cubic-bezier(.2, 1.6, .4, 1); }

.page-title { font-size: 26px; }
.page-sub { color: var(--muted); font-size: 15px; margin-top: 4px; }

/* ---------- tab bar ---------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner {
  max-width: 520px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(5, 1fr);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 64px; padding: 8px 2px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600;
  position: relative;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--text); font-weight: 800; }
.tab[aria-current="page"] svg { stroke: var(--reward); stroke-width: 2.2; }
.tab[aria-current="page"]::after {
  content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 4px 4px; background: var(--reward);
}
.tab .badge {
  position: absolute; top: 8px; left: calc(50% + 8px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--like); color: #fff; font-size: 11px; font-weight: 800;
  display: grid; place-items: center;
}

/* ---------- cards & blocks ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }
.card h2 { font-size: 18px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.num { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em; }
.reward { color: var(--reward-ink); }
.ok { color: var(--ok); }
.danger { color: var(--danger); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary-soft); color: var(--on-primary-soft);
  border-radius: 999px; padding: 5px 12px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
}
.pill.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.pill.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill.danger { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.pill.reward { background: color-mix(in srgb, var(--reward) 22%, transparent); color: var(--reward-ink); }
:root[data-theme="doce"] .pill.reward { color: #7a5600; }

.banner {
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; font-weight: 600;
  background: var(--primary-soft); color: var(--on-primary-soft);
}
.banner.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.banner.danger { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.banner.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }

/* ---------- buttons & forms ---------- */

.btn {
  appearance: none; border: 0; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 0 22px; border-radius: 18px;
  background: var(--primary); color: var(--on-primary);
  font-weight: 800; font-size: 17px;
  transition: transform 0.08s ease, filter 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: translateY(1px) scale(0.99); filter: brightness(0.92); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.reward { background: var(--reward); color: var(--on-reward); }
.btn.ghost { background: transparent; color: var(--muted); font-weight: 600; min-height: 44px; }
.btn.outline { background: transparent; color: var(--text); border: 2px solid var(--line); }
.btn.small { min-height: 44px; font-size: 15px; padding: 0 16px; border-radius: 14px; }
.btn .spinner { width: 20px; height: 20px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 700; font-size: 14px; }
.field .hint { font-size: 13px; color: var(--muted); }
.field .error { font-size: 13px; color: var(--danger); font-weight: 600; }
.input, .select {
  width: 100%; min-height: 52px; padding: 0 16px;
  background: var(--surface-2); color: var(--text);
  border: 2px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; font-size: 16px; /* 16px evita o zoom do iOS */
}
.input:focus, .select:focus { outline: none; border-color: var(--primary); }
.input.invalid { border-color: var(--danger); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--muted); }
.check input { width: 22px; height: 22px; accent-color: var(--primary); margin-top: 1px; flex: none; }

.segmented { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.seg {
  flex: none; min-height: 44px; padding: 0 16px; border-radius: 999px;
  background: var(--surface); border: 2px solid var(--line); color: var(--muted);
  font-weight: 700; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
}
.seg[aria-pressed="true"], .seg.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* ---------- progress ---------- */

.ring { position: relative; width: 88px; height: 88px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--line); }
.ring .bar { stroke: var(--reward); stroke-linecap: round; transition: stroke-dashoffset 0.9s cubic-bezier(.2, .8, .2, 1); }
.ring .label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 800; font-size: 18px;
}

.meter { height: 12px; border-radius: 6px; background: var(--line); overflow: hidden; }
.meter > span {
  display: block; height: 100%; border-radius: 6px; background: var(--reward);
  transition: width 0.9s cubic-bezier(.2, .8, .2, 1);
}

/* ---------- lists ---------- */

.list { display: flex; flex-direction: column; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: 0; }
.item .ico {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-2); color: var(--muted);
}
.item .ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.item .ico.up { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.item .ico.down { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.item .ico.wait { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.item .title { font-weight: 700; }
.item .amount { font-family: var(--font-display); font-weight: 800; white-space: nowrap; text-align: right; }

.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; font-size: 18px; }

/* ---------- task card ---------- */

.task { display: flex; flex-direction: column; gap: 16px; }
.task-head { display: flex; align-items: center; justify-content: space-between; }
.task-points { font-family: var(--font-display); font-weight: 800; font-size: 26px; color: var(--reward-ink); }
.task-target { display: flex; align-items: center; gap: 14px; }
.task-target .pic {
  width: 60px; height: 60px; border-radius: 50%; background: var(--surface-2); flex: none;
  display: grid; place-items: center; color: var(--muted);
}
.task-target .pic svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.task-target .name { font-weight: 800; font-size: 18px; overflow-wrap: anywhere; }
.steps { margin: 0; padding-left: 20px; color: var(--muted); font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.cta-lock { position: relative; overflow: hidden; }
.cta-lock .fill {
  position: absolute; inset: 0; transform-origin: left; transform: scaleX(0);
  background: rgba(255, 255, 255, 0.22);
}
.cta-lock.locked .fill { animation: unlock linear forwards; animation-duration: var(--lock-ms, 6s); }

.session-strip {
  display: flex; gap: 8px; align-items: center; justify-content: center;
  font-size: 13px; color: var(--muted); font-weight: 600;
}

/* ---------- code box (verificação de perfil) ---------- */

.code-box {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface-2); border: 2px dashed var(--primary); border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.code-box .code { font-family: var(--font-display); font-weight: 800; font-size: 26px; letter-spacing: 0.08em; }

/* ---------- toast & sheet ---------- */

.toasts {
  position: fixed; z-index: 60; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 12px);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px;
}
.toast {
  pointer-events: auto; max-width: 480px; width: 100%;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 16px; padding: 12px 16px; box-shadow: var(--shadow);
  display: flex; gap: 10px; align-items: center; font-weight: 700;
  animation: toast-in 0.35s cubic-bezier(.2, 1.3, .4, 1);
}
.toast.good { border-color: var(--ok); }
.toast.bad { border-color: var(--danger); }
.toast.leaving { animation: toast-out 0.25s ease forwards; }
.toast .big { font-family: var(--font-display); font-weight: 800; color: var(--reward); }

.fx-canvas { position: fixed; inset: 0; z-index: 80; pointer-events: none; width: 100%; height: 100%; }
.fx-coin {
  position: fixed; z-index: 81; width: 22px; height: 22px; border-radius: 50%; pointer-events: none;
  background: var(--reward); box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--on-reward) 22%, transparent);
}

.spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor;
  animation: spin 0.8s linear infinite;
}
.skeleton {
  border-radius: var(--radius-sm); min-height: 18px;
  background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2));
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite;
}

/* ---------- auth / guest ---------- */

.guest { max-width: 440px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 24px) 20px 40px; display: flex; flex-direction: column; gap: 22px; min-height: 100vh; min-height: 100dvh; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand .word { font-family: var(--font-display); font-weight: 800; font-size: 26px; letter-spacing: -0.02em; }
.brand .word span { color: var(--reward-ink); }
.hero h1 { font-size: 34px; }
.hero p { color: var(--muted); font-size: 17px; margin-top: 10px; }

/* ---------- animations ---------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes unlock { to { transform: scaleX(1); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
@keyframes float-up { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-36px); } }
.pop { animation: pop 0.45s cubic-bezier(.2, 1.4, .4, 1); }
.float-up { position: absolute; pointer-events: none; font-family: var(--font-display); font-weight: 800; color: var(--reward-ink); animation: float-up 1s ease-out forwards; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

@media (min-width: 700px) {
  body { background: var(--bg); }
  .app { padding-top: 32px; }
}

.reward-text { color: var(--reward-ink); font-variant-numeric: tabular-nums; }

/* ---------- loja ---------- */

.right { text-align: right; }
.product .num { font-variant-numeric: tabular-nums; }
.item .ico.down.like-ico { color: var(--like); }


/* ---------- revisão de UX: alvos de toque, senha, resumo de novidades ---------- */

/* Links de texto soltos (voltar, "Meus pedidos", rodapé) precisam de área de toque de 44px sem mudar o visual. */
a.small, .guest p a, .back-link { display: inline-flex; align-items: center; min-height: 44px; padding-block: 0; }
.guest p.small { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; column-gap: 6px; }
.guest p.small a { padding-inline: 6px; }

.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 84px; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); min-height: 44px; padding: 0 14px;
  background: transparent; border: 0; color: var(--link, var(--primary)); font-weight: 700; cursor: pointer; border-radius: 10px;
}

.btn:disabled, .btn[disabled] { cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
