:root {
  --vermelho: #c0392b;
  --vermelho-escuro: #922b21;
  --texto: #2c3e50;
  --cinza: #6b7785;
  --fundo: #f4f6f8;
  --branco: #ffffff;
  --sombra: 0 8px 24px rgba(0, 0, 0, 0.12);
  --raio: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--texto);
  background: var(--fundo);
  line-height: 1.5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Cabeçalho ===== */
.site-header {
  background: linear-gradient(135deg, #1c2833, #2c3e50);
  color: var(--branco);
  padding: 48px 0 36px;
  text-align: center;
}

.logo {
  font-size: 2.2rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.tagline {
  margin-top: 10px;
  color: #d6dce2;
  font-size: 1.05rem;
}

.search {
  margin-top: 24px;
  width: 100%;
  max-width: 420px;
  padding: 12px 18px;
  border: none;
  border-radius: 30px;
  font-size: 1rem;
  outline: none;
  box-shadow: var(--sombra);
}

/* ===== Grelha de cartões ===== */
.grelha {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 26px;
  padding: 44px 0;
}

.card {
  position: relative;
  border-radius: var(--raio);
  overflow: hidden;
  box-shadow: var(--sombra);
  min-height: 420px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: var(--branco);
  background-size: cover;
  background-position: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
}

/* camada escura para legibilidade do texto */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72) 18%, rgba(0, 0, 0, 0.12) 60%, transparent);
}

.card-icone {
  position: absolute;
  top: 26px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 5rem;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.4));
}

.card-conteudo {
  position: relative;
  padding: 24px 22px 26px;
  text-align: center;
}

.card-subtitulo {
  font-style: italic;
  font-size: 1.05rem;
  opacity: 0.92;
}

.card-titulo {
  margin: 4px 0 6px;
  font-size: 1.6rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-meta {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-bottom: 4px;
}

.card-descricao {
  font-size: 0.88rem;
  opacity: 0.85;
  margin-bottom: 18px;
  min-height: 38px;
}

.btn {
  display: block;
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.btn-testes {
  background: transparent;
  color: var(--branco);
  border: 2px solid rgba(255, 255, 255, 0.85);
  margin-bottom: 12px;
}

.btn-testes:hover {
  background: rgba(255, 255, 255, 0.95);
  color: var(--texto);
}

.btn-aderir {
  background: var(--vermelho);
  color: var(--branco);
}

.btn-aderir:hover {
  background: var(--vermelho-escuro);
}

.sem-resultados {
  text-align: center;
  padding: 40px 0 80px;
  color: var(--cinza);
  font-size: 1.1rem;
}

/* ===== Modo de Treino (treino.html) — layout normal, com scroll ===== */
.treino-area {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 0 70px;
}

.treino-topo {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.progresso {
  background: var(--texto);
  color: var(--branco);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 6px 16px;
  border-radius: 20px;
}

.pergunta {
  background: var(--branco);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 26px 26px 28px;
}

.pergunta-topico {
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--vermelho);
  margin-bottom: 8px;
}

.pergunta-texto {
  font-size: 1.2rem;
  line-height: 1.4;
  color: var(--texto);
  margin-bottom: 18px;
}

.pergunta-imagem {
  display: block;
  max-width: 100%;
  max-height: 300px;
  margin: 0 auto 22px;
  border-radius: 8px;
  border: 1px solid #e2e6ea;
}

.respostas {
  list-style: none;
}

.respostas li {
  margin-bottom: 12px;
}

.respostas li:last-child {
  margin-bottom: 0;
}

.resposta-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border: 2px solid #e2e6ea;
  border-radius: 8px;
  background: var(--branco);
  font-size: 1rem;
  color: var(--texto);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.resposta-btn:not(:disabled):hover {
  border-color: #2980b9;
  background: #f4f9fd;
}

.resposta-btn:disabled {
  cursor: default;
}

.resposta-btn.certa {
  background: #eafaf1;
  border-color: #27ae60;
  color: #1e7d4f;
  font-weight: 600;
}

.resposta-btn.errada {
  background: #fdecea;
  border-color: #e74c3c;
  color: #b03a2e;
  font-weight: 600;
}

.resposta-btn.escolhida {
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.06) inset;
}

.feedback {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 600;
  text-align: center;
}

.feedback-certo {
  background: #eafaf1;
  color: #1e7d4f;
}

.feedback-errado {
  background: #fdecea;
  color: #b03a2e;
}

.feedback-aviso {
  background: #fef5e7;
  color: #9c640c;
}

.explicacao {
  margin-top: 16px;
  padding: 14px 16px;
  background: #f4f6f8;
  border-left: 4px solid #2980b9;
  border-radius: 6px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--texto);
}

.treino-nav {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 24px;
}

.btn-nav {
  flex: 1;
  padding: 13px;
  border: 2px solid #ccd2d8;
  border-radius: 8px;
  background: var(--branco);
  color: var(--texto);
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-nav:not(:disabled):hover {
  border-color: var(--texto);
}

.btn-nav-principal {
  background: var(--vermelho);
  border-color: var(--vermelho);
  color: var(--branco);
}

.btn-nav-principal:not(:disabled):hover {
  background: var(--vermelho-escuro);
  border-color: var(--vermelho-escuro);
}

.btn-nav:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ===== Quiz (exame.html / treino.html) — página com scroll normal, 80% de largura ===== */
body.quiz-page {
  min-height: 100vh;
}

body.quiz-page .site-header {
  flex: 0 0 auto;
  padding: 14px 0 12px;
}

body.quiz-page .site-header .voltar {
  margin-bottom: 6px;
}

body.quiz-page .logo {
  font-size: 1.4rem;
}

body.quiz-page .tagline {
  margin-top: 2px;
  font-size: 0.9rem;
}

body.quiz-page main.container {
  width: 80%;
  max-width: none;
  margin: 0 auto;
  padding: 24px 0 110px; /* espaço para a barra de navegação fixa em baixo */
}

/* Navegação fixa no fundo do ecrã, sempre visível */
body.quiz-page .treino-nav,
body.quiz-page .paginacao {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  margin: 0;
  padding: 12px 10%;
  background: var(--branco);
  border-top: 1px solid #e7eaee;
}

body.quiz-page .site-footer {
  display: none;
}

/* Barra de topo do quiz: ✕ + barra de progresso + contador (fica fixa no topo) */
.quiz-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 26px;
  background: var(--branco);
  border-bottom: 1px solid #e7eaee;
}

.quiz-fechar {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #d3d9df;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--texto);
  text-decoration: none;
  font-size: 1.1rem;
  line-height: 1;
  transition: background 0.15s ease;
}

.quiz-fechar:hover {
  background: #f1f3f5;
}

.quiz-progresso-barra {
  flex: 1 1 auto;
  height: 12px;
  background: #e3e7ec;
  border-radius: 6px;
  overflow: hidden;
}

.quiz-progresso-fill {
  height: 100%;
  width: 0;
  background: #2f6fd0;
  border-radius: 6px;
  transition: width 0.25s ease;
}

.quiz-progresso-label {
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--texto);
  white-space: nowrap;
}

body.quiz-page .treino-area {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

body.quiz-page .treino-topo {
  margin-bottom: 12px;
}

/* Contador de acertos/erros (na barra de topo do treino) */
.treino-stats {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.treino-stats .stat {
  font-size: 0.9rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
}

.treino-stats .stat-certas {
  background: #eafaf1;
  color: #1e7d4f;
}

.treino-stats .stat-erradas {
  background: #fdecea;
  color: #b03a2e;
}

/* Sem cartão: fundo transparente, sem sombra; a página inteira faz scroll */
body.quiz-page .pergunta {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
}

/* Topo: imagem à esquerda + enunciado à direita (alinhados ao topo) */
body.quiz-page .pergunta-top {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 20px;
  align-items: start;
  margin-bottom: 16px;
}

body.quiz-page .pergunta-top.sem-imagem {
  grid-template-columns: 1fr;
}

body.quiz-page .pergunta-imagem {
  width: auto;
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
  margin: 0;
  border: none;
  border-radius: 0;
  justify-self: start;
}

body.quiz-page .pergunta-texto {
  font-size: 1.25rem;
  line-height: 1.35;
  margin-bottom: 0;
}

/* Respostas por baixo do enunciado, estilo "a) texto" */
body.quiz-page .respostas {
  margin-top: 16px;
}

body.quiz-page .respostas li {
  margin-bottom: 6px;
}

body.quiz-page .resposta-btn {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  min-height: 0;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  color: var(--texto);
  font-size: 1.05rem;
  overflow: visible;
}

body.quiz-page .resposta-btn:not(:disabled):hover {
  background: #eef2f6;
}

body.quiz-page .resp-letra {
  flex: 0 0 auto;
  width: auto;
  display: inline;
  background: transparent;
  border: none;
  font-weight: 700;
  color: var(--vermelho);
  font-size: 1.05rem;
}

body.quiz-page .resp-texto {
  flex: 1 1 auto;
  display: inline;
  padding: 0;
  font-size: 1.05rem;
}

/* Seleção durante o exame (sem revelar se está certa) */
body.quiz-page .resposta-btn.selecionada {
  background: #e8f0fb;
  border-color: #2980b9;
}

/* Revelação (treino e correção) */
body.quiz-page .resposta-btn.certa {
  background: #eafaf1;
  border-color: #58d68d;
  color: #1e7d4f;
}
body.quiz-page .resposta-btn.certa .resp-letra {
  color: #1e7d4f;
}
body.quiz-page .resposta-btn.errada {
  background: #fdecea;
  border-color: #e57373;
  color: #b03a2e;
}
body.quiz-page .resposta-btn.errada .resp-letra {
  color: #b03a2e;
}

/* ===== Paginação numerada (exame) ===== */
.paginacao {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.pag-numeros {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.pag-num {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid #ccd2d8;
  border-radius: 6px;
  background: var(--branco);
  color: var(--texto);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.pag-num.respondida {
  border-color: #2980b9;
  color: #2980b9;
}

.pag-num.atual {
  background: var(--vermelho);
  border-color: var(--vermelho);
  color: var(--branco);
}

.pag-seta {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 1px solid #ccd2d8;
  border-radius: 8px;
  background: #eceff1;
  color: var(--texto);
  font-size: 1.2rem;
  cursor: pointer;
}

.pag-seta:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-terminar {
  flex: 0 0 auto;
  padding: 0 18px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: #27ae60;
  color: var(--branco);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn-terminar:hover {
  background: #1e8449;
}

/* Modo de Treino com layout compacto: a explicação fica numa caixa própria
   que ocupa o espaço restante (com scroll só dentro dela). */
body.treino-page .respostas {
  margin-top: 14px;
}

body.treino-page .feedback {
  margin-top: 12px;
}

body.treino-page .explicacao {
  margin-top: 12px;
}

body.quiz-page .treino-nav {
  flex: 0 0 auto;
  margin-top: 12px;
}

@media (max-width: 640px) {
  body.quiz-page .pergunta-top {
    grid-template-columns: 1fr;
  }
}

/* ===== Resultado do Exame ===== */
.resultado {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 0 70px;
}

.resultado-banner {
  text-align: center;
  border-radius: var(--raio);
  padding: 28px 24px;
  color: var(--branco);
  margin-bottom: 22px;
}

.resultado-banner h2 {
  font-size: 1.9rem;
  margin-bottom: 6px;
}

.resultado-banner.passou {
  background: linear-gradient(135deg, #27ae60, #1e8449);
}

.resultado-banner.chumbou {
  background: linear-gradient(135deg, #c0392b, #922b21);
}

.resultado-contagem {
  display: flex;
  gap: 14px;
  margin-bottom: 22px;
}

.contagem {
  flex: 1;
  background: var(--branco);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  text-align: center;
  padding: 18px 10px;
}

.contagem strong {
  display: block;
  font-size: 2rem;
  line-height: 1.1;
}

.contagem span {
  font-size: 0.85rem;
  color: var(--cinza);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.contagem.certa strong {
  color: #1e7d4f;
}
.contagem.errada strong {
  color: #b03a2e;
}

.revisao-titulo {
  margin: 10px 0 16px;
  color: var(--texto);
}

.revisao {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rev-item {
  background: var(--branco);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 18px 20px;
  border-left: 5px solid #ccc;
}

.rev-item.ok {
  border-left-color: #27ae60;
}
.rev-item.ko {
  border-left-color: #e74c3c;
}

.rev-pergunta {
  font-weight: 600;
  color: var(--texto);
  margin-bottom: 12px;
  line-height: 1.4;
}

.rev-num {
  display: inline-block;
  min-width: 22px;
  font-weight: 700;
  color: var(--cinza);
}

.rev-lista {
  list-style: none;
}

.rev-resposta {
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 0.96rem;
  color: var(--texto);
  background: #f6f7f9;
}

.rev-resposta.certa {
  background: #eafaf1;
  color: #1e7d4f;
  font-weight: 600;
}

.rev-resposta.errada {
  background: #fdecea;
  color: #b03a2e;
  font-weight: 600;
}

.rev-tag {
  font-size: 0.82rem;
  font-weight: 600;
  opacity: 0.8;
}

/* ===== Página de modos (testes.html) ===== */
.voltar {
  display: inline-block;
  margin-bottom: 18px;
  color: #d6dce2;
  text-decoration: none;
  font-size: 0.95rem;
}

.voltar:hover {
  color: var(--branco);
  text-decoration: underline;
}

.modos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 28px;
  padding: 50px 0;
  max-width: 820px;
  margin: 0 auto;
}

.modo {
  background: var(--branco);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 36px 28px;
  text-align: center;
  border-top: 6px solid var(--vermelho);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.modo:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.18);
}

.modo-exame {
  border-top-color: #2980b9;
}

.modo-treino {
  border-top-color: #27ae60;
}

.modo-icone {
  font-size: 3.4rem;
  margin-bottom: 12px;
}

.modo-titulo {
  font-size: 1.5rem;
  margin-bottom: 12px;
  color: var(--texto);
}

.modo-desc {
  color: var(--cinza);
  font-size: 0.95rem;
  margin-bottom: 24px;
  min-height: 60px;
}

.modo-exame .btn-aderir {
  background: #2980b9;
}
.modo-exame .btn-aderir:hover {
  background: #1f618d;
}
.modo-treino .btn-aderir {
  background: #27ae60;
}
.modo-treino .btn-aderir:hover {
  background: #1e8449;
}

/* ===== Rodapé ===== */
.site-footer {
  background: #1c2833;
  color: #aeb6bf;
  text-align: center;
  padding: 22px 0;
  font-size: 0.9rem;
}

/* ===== Responsivo ===== */
@media (max-width: 640px) {
  .grelha {
    grid-template-columns: 1fr;
  }
  .logo {
    font-size: 1.8rem;
  }
}
