/* Desafio 360: visual das telas do convidado (entrada, desafios, foto, galeria e ranking).
 * Referência: Visual/VISUAL-TELA-CONVIDADO.md e o protótipo que o acompanha.
 * O roxo segue a "Cor principal" de Painel > Aparência (padrão #6d28d9); as demais cores são fixas.
 * Carregado depois do app.css, só nas páginas do convidado. */

:root {
  --cv-paper: #ECE8F1;
  --cv-surface: #F7F5FA;
  --cv-card: #FFFFFF;
  --cv-ink: #1D1528;
  --cv-muted: #6B6278;
  --cv-line: #DDD6E6;
  --cv-gold: #C98A12;
  --cv-gold-soft: #FBF0D9;
  --cv-done: #1E7F55;
  --cv-done-soft: #DDF1E7;
  --cv-wait: #9A5B00;
  --cv-wait-soft: #FBEBD3;
  --f-display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --f-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --cv-r: 16px;
  --cv-tabs-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --cv-paper: #0E0A14; --cv-surface: #151020; --cv-card: #1E1729; --cv-ink: #F1ECF7; --cv-muted: #A59BB3; --cv-line: #2E2539;
    --cv-gold: #F0B94A; --cv-gold-soft: #3A2C12; --cv-done: #4CC48D; --cv-done-soft: #15302A; --cv-wait: #F5B65A; --cv-wait-soft: #3A2A12;
  }
}
:root[data-theme=dark] {
  --cv-paper: #0E0A14; --cv-surface: #151020; --cv-card: #1E1729; --cv-ink: #F1ECF7; --cv-muted: #A59BB3; --cv-line: #2E2539;
  --cv-gold: #F0B94A; --cv-gold-soft: #3A2C12; --cv-done: #4CC48D; --cv-done-soft: #15302A; --cv-wait: #F5B65A; --cv-wait-soft: #3A2A12;
}

/* Componentes comuns do app.css (avisos, miniaturas, ampliação) passam a usar estas cores */
body.cv {
  --bg: var(--cv-surface);
  --surface: var(--cv-card);
  --surface-2: var(--cv-paper);
  --text: var(--cv-ink);
  --muted: var(--cv-muted);
  --border: var(--cv-line);
  --violet: var(--primary);
  --violet-soft: var(--primary-soft);
  --violet-text: var(--primary-text);
  --on-violet: var(--on-primary);
  margin: 0;
  background: var(--cv-paper);
  color: var(--cv-ink);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.5;
  padding: 0;
}
body.cv a { color: var(--violet-text); }

/* ---------- Estrutura: coluna de app, centralizada no computador ---------- */
.cv-app {
  max-width: 480px; min-height: 100vh; margin: 0 auto;
  display: flex; flex-direction: column;
  background: var(--cv-surface);
}
@media (min-width: 520px) { .cv-app { border-inline: 1px solid var(--cv-line); } }
.cv-main { flex: 1; padding: 16px 18px 28px; }
body.cv-has-tabs .cv-main { padding-bottom: calc(var(--cv-tabs-h) + 28px + env(safe-area-inset-bottom, 0px)); }
.cv-view { display: flex; flex-direction: column; gap: 18px; }
.cv-view[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .cv-view { animation: cv-in .25s ease-out; }
}
@keyframes cv-in { from { opacity: .4; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Cabeçalho fixo */
.cv-top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px 12px; background: var(--cv-surface); border-bottom: 1px solid var(--cv-line);
}
.cv-logo {
  flex: none; display: flex; align-items: center; gap: 6px; text-decoration: none; color: var(--cv-ink) !important;
  font-family: var(--f-display); font-weight: 800; font-size: 12px; letter-spacing: -.02em; line-height: 1.05;
  max-width: 34%;
}
.cv-logo span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; text-transform: uppercase; }
.cv-logo i { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--violet); border-right-color: transparent; transform: rotate(-45deg); }
.cv-logo img { display: block; height: calc(30px * var(--logo-scale, 1)); width: auto; max-width: 100%; object-fit: contain; }
.cv-ev { flex: 1; min-width: 0; }
.cv-ev b { display: block; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-ev small { font-family: var(--f-mono); font-size: 11.5px; color: var(--cv-muted); }
.cv-me { flex: none; text-decoration: none; margin-left: auto; }
.cv-me span {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--violet); color: var(--on-violet); font-family: var(--f-display); font-size: 12px; font-weight: 700;
}

/* Barra de abas */
.cv-tabs {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 30;
  width: min(100%, 480px);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--cv-card); border-top: 1px solid var(--cv-line);
  padding: 8px 6px calc(10px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 520px) { .cv-tabs { border-inline: 1px solid var(--cv-line); } }
.cv-tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px;
  color: var(--cv-muted) !important; text-decoration: none; font-size: 11.5px; font-weight: 600;
}
.cv-tab .icon { width: 22px; height: 22px; }
.cv-tab[aria-current="page"] { color: var(--violet-text) !important; }

/* ---------- Tipografia e blocos ---------- */
.cv-kicker { font-family: var(--f-mono); font-size: 12px; color: var(--violet-text); letter-spacing: .04em; }
.cv-hero { padding-top: 10px; }
.cv-hero h1 {
  font-family: var(--f-display); font-weight: 800; font-size: 38px; line-height: 1; letter-spacing: -.04em;
  margin: 10px 0 0; text-wrap: balance; overflow-wrap: anywhere;
}
.cv-hero h1 em { font-style: normal; color: var(--violet-text); }
.cv-hero p { margin: 14px 0 0; color: var(--cv-muted); max-width: 34ch; }
.cv-hint { font-size: 12.5px; color: var(--cv-muted); margin: 0; }
.cv-sec { display: flex; flex-direction: column; gap: 10px; }
.cv-sec h2, .cv-h2 {
  font-family: var(--f-display); font-weight: 700; font-size: 13px; letter-spacing: -.01em; margin: 0;
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
}
.cv-sec h2 small, .cv-h2 small { font-family: var(--f-body); font-weight: 500; font-size: 12.5px; color: var(--cv-muted); }
.cv-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: var(--cv-muted); padding: 24px 12px; background: var(--cv-card); border: 1px solid var(--cv-line); border-radius: var(--cv-r); }
.cv-empty .icon { width: 36px; height: 36px; color: var(--violet-text); }
.cv-empty p { margin: 0; }

/* Botões e campos */
.cv-cta {
  font: inherit; font-weight: 700; font-size: 16px; border: 0; border-radius: 14px; padding: 16px;
  background: var(--violet); color: var(--on-violet) !important; cursor: pointer; text-decoration: none;
  display: flex; justify-content: center; align-items: center; gap: 10px; width: 100%;
}
.cv-cta .icon { width: 18px; height: 18px; }
.cv-cta:disabled { opacity: .45; cursor: not-allowed; }
.cv-ghost {
  font: inherit; font-weight: 600; font-size: 14px; border: 1.5px solid var(--cv-line); background: transparent;
  color: var(--cv-ink) !important; border-radius: 14px; padding: 13px; cursor: pointer; text-align: center; text-decoration: none; display: block; width: 100%;
}
.cv-ghost[hidden] { display: none; }
/* Voltar: fundo suave na cor do tema (o mesmo do ícone dos desafios) */
.cv-back { background: var(--violet-soft); border-color: transparent; }

/* Mesmo convidado em outro aparelho */
.cv-device-box {
  background: var(--cv-card); border: 1px solid var(--cv-line); border-radius: var(--cv-r);
  padding: 20px 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
}
.cv-device-box canvas { width: 220px; max-width: 100%; height: auto; image-rendering: pixelated; border-radius: 8px; background: #fff; }
.cv-device-code { font-family: var(--f-mono); font-weight: 700; font-size: 30px; letter-spacing: .12em; color: var(--cv-ink); }
.cv-namebox input.cv-code-input { font-family: var(--f-mono); font-weight: 700; font-size: 22px; letter-spacing: .12em; text-transform: uppercase; text-align: center; }
.cv-twin {
  background: var(--cv-gold-soft); border: 1px solid var(--cv-gold); border-radius: var(--cv-r);
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.cv-twin b { font-size: 15px; line-height: 1.3; }
.cv-twin p { margin: 0; font-size: 13.5px; color: var(--cv-ink); }
.cv-twin form { margin: 0; }
.cv-namebox[hidden] { display: none; }
.cv-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; }
.cv-links form { margin: 0; }
.cv-namebox { display: flex; flex-direction: column; gap: 8px; }
.cv-namebox label { font-size: 13px; font-weight: 600; }
.cv-namebox input[type=text], .cv-namebox input[type=tel] {
  width: 100%; font: inherit; font-size: 17px; color: var(--cv-ink); background: var(--cv-card);
  border: 1.5px solid var(--cv-line); border-radius: 14px; padding: 14px 16px;
}
body.cv input:focus, body.cv input:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
body.cv button:focus-visible, body.cv a:focus-visible, .cv-file:focus-within { outline: 2px solid var(--violet); outline-offset: 2px; }
.cv-namebox .cv-cta { margin-top: 6px; }

/* ---------- Entrada (convite) ---------- */
.cv-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cv-step { background: var(--cv-card); border: 1px solid var(--cv-line); border-radius: 14px; padding: 12px 10px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cv-step .icon { width: 22px; height: 22px; color: var(--violet-text); }
.cv-step b { font-size: 13px; line-height: 1.25; }

/* ---------- Página inicial (código do evento) ---------- */
body.cv-auth .cv-main { display: flex; flex-direction: column; justify-content: center; padding-top: 32px; }
.cv-home-logo { display: block; height: calc(96px * var(--logo-scale, 1)); width: auto; max-width: 100%; object-fit: contain; align-self: flex-start; }
.cv-home-mark { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--violet); color: var(--on-violet); }
.cv-home-mark .icon { width: 30px; height: 30px; }

/* ---------- Crie seu evento (cadastro do organizador) ---------- */
.cv-signup-form { background: var(--cv-card); border: 1px solid var(--cv-line); border-radius: 20px; padding: 18px 16px; }
img.cv-signup-logo { display: block; align-self: center; height: calc(80px * var(--logo-scale, 1)); width: auto; max-width: 100%; object-fit: contain; margin-bottom: 10px; }
.cv-home-mark.cv-signup-logo { align-self: center; margin-bottom: 10px; }
.cv-google {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  font: inherit; font-weight: 600; font-size: 15px; padding: 14px; border-radius: 14px; text-decoration: none;
  background: #fff; color: #1f1f1f !important; border: 1.5px solid var(--cv-line);
}
.cv-google svg { width: 20px; height: 20px; flex: none; }
.cv-google:hover { background: #f4f4f6; }
.cv-or { display: flex; align-items: center; gap: 12px; margin: 8px 0 2px; color: var(--cv-muted); font-size: 12.5px; }
.cv-or::before, .cv-or::after { content: ""; flex: 1; height: 1px; background: var(--cv-line); }
.cv-namebox input[type=password], .cv-namebox input[type=email] {
  width: 100%; font: inherit; font-size: 17px; color: var(--cv-ink); background: var(--cv-card);
  border: 1.5px solid var(--cv-line); border-radius: 14px; padding: 14px 16px;
}
.cv-signup-form input[aria-invalid="true"] { border-color: var(--cv-gold); }
.cv-pass { position: relative; }
.cv-namebox .cv-pass input { padding-right: 84px; }
.cv-pass .link-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); padding: 8px; font-size: 13px; }
.cv-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.cv-center { text-align: center; }
.cv-signup .cv-twin .cv-cta { margin-top: 2px; }

/* ---------- Desafios: progresso de 360° ---------- */
.cv-prog {
  display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center;
  background: var(--cv-card); border: 1px solid var(--cv-line); border-radius: 20px; padding: 14px;
}
.cv-dial { width: 132px; height: 132px; position: relative; }
.cv-dial svg { width: 100%; height: 100%; display: block; }
.cv-dial .on { stroke: var(--violet); }
.cv-dial .off { stroke: var(--cv-line); }
.cv-dial-c { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.cv-deg { font-family: var(--f-display); font-weight: 800; font-size: 30px; line-height: .9; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.cv-of { font-family: var(--f-mono); font-size: 10.5px; color: var(--cv-muted); margin-top: 5px; }
.cv-pstats { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cv-k { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--cv-muted); }
.cv-v { font-family: var(--f-display); font-weight: 700; font-size: 20px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.cv-v.cv-gold { color: var(--cv-gold); }
.cv-v small { font-family: var(--f-body); font-weight: 500; font-size: 12px; color: var(--cv-muted); }

/* Lista de desafios */
.cv-chs { display: flex; flex-direction: column; gap: 8px; }
.cv-ch {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 12px;
  background: var(--cv-card); border: 1px solid var(--cv-line); border-radius: var(--cv-r);
  color: var(--cv-ink) !important; text-decoration: none;
}
.cv-ch:hover { border-color: var(--violet); }
.cv-ic { width: 44px; height: 44px; border-radius: 12px; background: var(--violet-soft); color: var(--violet-text); display: grid; place-items: center; }
.cv-ic .icon { width: 22px; height: 22px; }
.cv-ch b { display: block; font-size: 14.5px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.cv-ch small { color: var(--cv-muted); font-size: 12.5px; }
.cv-pill { font-family: var(--f-mono); font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 4px 10px; white-space: nowrap; background: var(--violet); color: var(--on-violet); }
.cv-ch-done .cv-ic { background: var(--cv-done-soft); color: var(--cv-done); }
.cv-ch-done .cv-pill { background: var(--cv-done-soft); color: var(--cv-done); }
.cv-ch-wait .cv-pill { background: var(--cv-wait-soft); color: var(--cv-wait); }
.cv-rename { text-align: center; font-size: 13px; }

/* ---------- Desafio aberto ---------- */
.cv-task h3 { font-family: var(--f-display); font-weight: 800; font-size: 28px; line-height: 1.05; letter-spacing: -.035em; margin: 8px 0 0; text-wrap: balance; overflow-wrap: anywhere; }
.cv-task p { color: var(--cv-muted); margin: 10px 0 0; }
.cv-row2 { display: grid; grid-template-columns: 1fr; gap: 8px; }
.cv-file { position: relative; }
.cv-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.cv-file .icon { width: 20px; height: 20px; }
.cv-gallery { display: flex; justify-content: center; align-items: center; gap: 8px; font-size: 15px; }
.cv-gallery[hidden] { display: none; }
.cv-toast { background: var(--cv-gold-soft); color: var(--cv-ink); border-radius: 14px; padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: center; }
.cv-toast[hidden] { display: none; }
.cv-toast b { color: var(--cv-gold); font-family: var(--f-mono); white-space: nowrap; }
.cv-detail .thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.cv-detail .thumb { width: auto; height: auto; aspect-ratio: 1 / 1; border-radius: 12px; }

/* ---------- Galeria ---------- */
.cv-filters {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px;
  margin-inline: -18px; padding-inline: 18px; scrollbar-width: none;
}
.cv-filters::-webkit-scrollbar { display: none; }
.cv-filters a {
  flex: none; font-size: 12.5px; font-weight: 600; border: 1px solid var(--cv-line); background: var(--cv-card);
  color: var(--cv-ink) !important; border-radius: 999px; padding: 7px 12px; white-space: nowrap; text-decoration: none;
}
.cv-filters a[aria-current="page"] { background: var(--cv-ink); color: var(--cv-surface) !important; border-color: var(--cv-ink); }
.cv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; grid-auto-flow: dense; }
.cv-ph { position: relative; display: block; border-radius: 14px; overflow: hidden; aspect-ratio: 3 / 4; background: var(--cv-card); }
.cv-ph.cv-tall { grid-row: span 2; aspect-ratio: auto; }
.cv-ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cv-cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 10px 9px;
  background: linear-gradient(transparent, rgba(12, 6, 20, .78)); color: #fff; font-size: 11.5px; line-height: 1.3;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.cv-cap b { display: block; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Ranking ---------- */
.cv-podium { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cv-pd { background: var(--cv-card); border: 1px solid var(--cv-line); border-radius: var(--cv-r); padding: 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cv-pd.cv-first { background: var(--violet); color: var(--on-violet); border-color: var(--violet); }
.cv-pos { font-family: var(--f-display); font-weight: 800; font-size: 30px; line-height: 1; letter-spacing: -.04em; }
.cv-pd b { font-size: 14px; overflow-wrap: anywhere; }
.cv-pd span { font-family: var(--f-mono); font-size: 12.5px; opacity: .85; }
.cv-rl { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; background: var(--cv-card); border: 1px solid var(--cv-line); border-radius: var(--cv-r); overflow: hidden; }
.cv-rr { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 11px 14px; border-top: 1px solid var(--cv-line); font-size: 14px; }
.cv-rr:first-child { border-top: 0; }
.cv-rr b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-p { font-family: var(--f-mono); font-weight: 700; color: var(--cv-muted); font-size: 12px; }
.cv-pts { font-family: var(--f-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.cv-rr.cv-you { background: var(--violet-soft); }
.cv-rr.cv-you b { color: var(--violet-text); }
.cv-screen { font-size: 12.5px; color: var(--cv-muted); display: flex; gap: 8px; align-items: center; }
.cv-screen .icon { width: 18px; height: 18px; flex: none; }

/* Aviso flutuante acima da barra de abas */
body.cv-has-tabs .toast { bottom: calc(var(--cv-tabs-h) + 16px + env(safe-area-inset-bottom, 0px)); }

/* Celular estreito (360px) */
@media (max-width: 380px) {
  .cv-hero h1 { font-size: 32px; }
  .cv-dial { width: 112px; height: 112px; }
  .cv-deg { font-size: 26px; }
  .cv-step b { font-size: 12px; }
}

/* ---------- Curtidas ---------- */
.cv-ph-link { position: absolute; inset: 0; display: block; }
.cv-like {
  position: absolute; top: 8px; right: 8px; z-index: 1; display: inline-flex; align-items: center; gap: 4px;
  min-height: 32px; padding: 4px 10px; border: 0; border-radius: 999px; cursor: pointer;
  background: rgba(12, 6, 20, .55); color: #fff; font: 600 13px/1 var(--f-body); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.cv-like span { font-size: 16px; line-height: 1; transition: transform .2s; }
.cv-like b { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.cv-like.is-on span { color: #ff4d6d; }
.cv-like.pop span { animation: cv-like-pop .35s ease-out; }
.cv-like:disabled { cursor: default; opacity: .85; }
.cv-like:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@keyframes cv-like-pop { 50% { transform: scale(1.45); } }
.lightbox .lightbox-like { position: static; margin-top: 10px; min-height: 40px; padding: 6px 16px; font-size: 15px; }
.lightbox .lightbox-like span { font-size: 20px; }
@media (prefers-reduced-motion: reduce) { .cv-like.pop span { animation: none; } }

/* Selos do ranking: empate (ainda sem sorteio) e posição decidida por sorteio */
.cv-tag {
  display: inline-block; margin-left: 4px; padding: 1px 7px; border-radius: 999px; font: 600 10.5px/1.5 var(--f-body);
  font-style: normal; background: var(--cv-wait-soft); color: var(--cv-wait); vertical-align: middle; white-space: nowrap;
}
.cv-tag.cv-tag-draw { background: var(--cv-gold-soft); color: var(--cv-gold); }
.cv-pd.cv-first .cv-tag { background: rgba(255, 255, 255, .2); color: inherit; }
