/* TriviaRound — base e componentes dos ecrãs do protótipo (triviaround-web),
   para as páginas já convertidas para PHP (includes/pagina.php). As cores vêm
   das variáveis dos temas em css/app.css; as páginas antigas não carregam
   este ficheiro, porque muda regras gerais (body, h1, p). */

/* ---------- Base ---------- */
* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

button, input, select { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  min-height: 100svh; /* nunca maior que a área visível (o dvh muda após refresh na app instalada) */
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---------- Barra do topo ---------- */
.topo {
  position: sticky;
  top: 0;
  z-index: 10;
  height: calc(64px + env(safe-area-inset-top));
  flex-shrink: 0;
  padding: env(safe-area-inset-top) 8px 0;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bar);
  border-bottom: var(--bar-line);
}

/* Long names (a client's trail) shrink and stop at 2 lines, so they never spill out of the 64px bar */
.topo__titulo {
  flex: 1;
  min-width: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  padding-left: 4px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.topo__titulo--longo { font-size: 16px; }
.topo__marca { flex: 1; font-size: 22px; font-weight: 700; padding-left: 12px; }

.icone-btn {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 24px;
  background: transparent;
  color: var(--fg);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.icone-btn svg { width: 26px; height: 26px; }

/* ---------- Conteúdo ---------- */
.conteudo {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}

/* Na app instalada o Android pode desenhar a página por baixo das barras do
   sistema (viewport-fit=cover): as safe areas deixam esse espaço livre.
   .conteudo--cheio enche o ecrã pelo flex: 1 dentro de .app. */

h1, h2 { margin: 0; line-height: 1.15; }
h1 { font-size: 32px; }
h2 { font-size: 22px; }
p { margin: 0; }

.sub { color: var(--sub); font-size: 16px; }

/* ---------- Blocos grandes (início, gestão) ---------- */
.bloco {
  flex: 1;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 18px 22px;
  border-radius: 28px;
  border: var(--bord);
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}

.bloco--grande { flex: 1.7; }
.bloco svg { width: 34px; height: 34px; }
.bloco__nome { display: block; font-size: 27px; font-weight: 700; line-height: 1.1; }
.bloco--grande .bloco__nome { font-size: 32px; }
.bloco__sub { display: block; font-size: 16px; margin-top: 2px; }

/* Ecrãs baixos (Android com a barra do browser e o botão "Instalar a app"):
   blocos ainda mais compactos, para o aviso dos termos caber sem scroll. */
@media (max-height: 760px) {
  .bloco { min-height: 0; padding: 14px 20px; gap: 6px; border-radius: 24px; }
  .bloco svg { width: 30px; height: 30px; }
  .bloco__nome { font-size: 24px; }
  .bloco--grande .bloco__nome { font-size: 28px; }
}
.bloco__topo { display: flex; justify-content: space-between; align-items: flex-start; }
.bloco__aviso { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 700; }
.bloco__aviso svg { width: 18px; height: 18px; }

.cor-1 { background: var(--b1); color: var(--b1-t); }
.cor-2 { background: var(--b2); color: var(--b2-t); }
.cor-3 { background: var(--b3); color: var(--b3-t); }
.cor-4 { background: var(--b4); color: var(--b4-t); }

/* ---------- Botões ---------- */
.btn {
  min-height: 64px;
  padding: 0 20px;
  border-radius: 32px;
  border: var(--bord);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.btn svg { width: 22px; height: 22px; }
.btn--enorme { min-height: 96px; font-size: 26px; }
.btn--enorme svg { width: 34px; height: 34px; }

.btn--contorno {
  min-height: 54px;
  background: transparent;
  color: var(--fg);
  border: var(--outline);
  font-size: 18px;
}

.btn--compacto { min-height: 44px; font-size: 16px; }

.btn--pilula {
  min-height: 56px;
  padding: 0 8px;
  background: var(--pill);
  color: var(--pill-t);
  border: var(--pill-line);
  font-size: 18px;
}

.btn[aria-disabled="true"] {
  background: var(--off);
  color: var(--off-t);
  border: var(--off-line);
  cursor: not-allowed;
}

.grelha-2, .grelha-3 { display: grid; gap: 10px; }
.grelha-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grelha-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

/* ---------- Cartões e listas ---------- */
.cartao {
  padding: 18px 20px;
  border-radius: 28px;
  background: var(--card);
  border: var(--card-line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cartao ol, .cartao ul { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }

.lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.item {
  min-height: 76px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 10px 12px 16px;
  border-radius: 24px;
  background: var(--card);
  color: var(--fg);
  border: var(--card-line);
  text-align: left;
  cursor: pointer;
}

.item__texto { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.item__nome { font-size: 19px; font-weight: 700; }
.item__icone {
  width: 48px; height: 48px; flex-shrink: 0; border-radius: 24px;
  display: flex; align-items: center; justify-content: center;
}
.item__icone svg, .item > svg { width: 24px; height: 24px; flex-shrink: 0; }

.etiquetas { display: flex; flex-wrap: wrap; gap: 6px; }
.etiqueta {
  height: 30px; padding: 0 12px; border-radius: 15px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 700;
  background: var(--chip); color: var(--chip-t);
}
.etiqueta svg { width: 14px; height: 14px; }
.etiqueta--contorno { background: transparent; color: var(--fg); border: var(--chip-line); }

/* ---------- Formulários ---------- */
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo label, .campo legend { font-size: 17px; font-weight: 700; padding: 0; }

.campo input,
.campo select {
  height: 58px;
  padding: 0 16px;
  border-radius: 18px;
  border: var(--field-line);
  background: var(--field);
  color: var(--fg);
  font-size: 19px;
}

.campo input[type="search"] { border-radius: 29px; }
.campo input.codigo { height: 72px; font-size: 32px; letter-spacing: 10px; text-align: center; }

fieldset.campo { margin: 0; padding: 0; border: 0; }

.opcao {
  min-height: 52px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 26px;
  background: var(--pill);
  color: var(--fg);
  border: var(--chip-line);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

.opcao input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.opcao:has(input:checked) { background: var(--sel); color: var(--sel-t); border: var(--sel-line); }

/* ---------- Separadores ---------- */
.separadores {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  border-radius: 32px;
  background: var(--track);
  border: var(--track-line);
}

.separador {
  height: 52px; border-radius: 26px; border: 0;
  background: transparent; color: var(--fg);
  font-size: 18px; font-weight: 700; cursor: pointer;
}

.separador[aria-selected="true"] { background: var(--tab-on); color: var(--tab-on-t); border: var(--tab-on-line); }

/* ---------- Perfil ---------- */
.perfil-cabecalho { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 64px; height: 64px; flex-shrink: 0; border-radius: 32px;
  display: flex; align-items: center; justify-content: center; border: var(--bord);
}
.avatar svg { width: 32px; height: 32px; }

.numero { padding: 14px 12px; border-radius: 24px; border: var(--bord); display: flex; flex-direction: column; gap: 4px; }
.numero strong { font-size: 32px; line-height: 1; }
.numero span { font-size: 15px; line-height: 1.2; }

/* ---------- Jogo ---------- */
.mapa {
  flex: 1;
  min-height: 260px;
  border-radius: 32px;
  border: var(--dash);
  background: var(--card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: var(--sub);
}
.mapa svg { width: 72px; height: 72px; color: var(--fg); }

.destino { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-radius: 28px; border: var(--bord); }
.destino svg { width: 40px; height: 40px; flex-shrink: 0; }
.destino strong { display: block; font-size: 28px; }

/* ---------- Popup dos termos ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--shade);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}

.folha {
  width: calc(100% - 20px);
  max-width: 460px;
  margin-bottom: 10px;
  padding: 24px 22px 20px;
  border-radius: 32px;
  background: var(--card);
  color: var(--fg);
  border: var(--card-line);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.aceito {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border-radius: 20px;
  background: var(--chip);
  color: var(--chip-t);
  font-size: 19px;
  cursor: pointer;
}

.aceito input { width: 28px; height: 28px; margin: 0; flex-shrink: 0; accent-color: var(--accent); }

a.ligacao { color: var(--fg); font-size: 17px; align-self: flex-start; }

/* Itens de lista que são ligações */
a.item { text-decoration: none; }
.cartao .lista { padding-left: 0; }
