/* ==========================================================================
   1. IMPORTAÇÃO DE FONTES & VARIÁVEIS GLOBAIS DE DESIGN
   ========================================================================== */
/* ==========================================================================
   1. IMPORTAÇÃO DE FONTES & VARIÁVEIS GLOBAIS DE DESIGN
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&family=Inter:wght@400;500;600;700&family=EB+Garamond:ital,wght@0,500;1,500&display=swap');

:root {
  /* MODO CLARO: Fundo Bege/Pergaminho com pontos dourados */
  --bg: #F7F5F2;
  --label-primary: #1A1A1E;
  --label-secondary: #8A857C;
  --fill-apple: #FFFFFF;
  --accent: #9A7B32;
  --separator: rgba(154, 123, 50, 0.12);
  --dot-color: rgba(154, 123, 50, 0.18); /* Cor dos pontinhos no claro */
  
  --blur: saturate(180%) blur(20px);
  --ease-ios: cubic-bezier(0.16, 1, 0.3, 1);
}

html.dark {
  /* MODO ESCURO: Fundo Azul Noturno com pontos sutis */
  --bg: #0B1121; /* Azul Escuro Elegante */
  --label-primary: #E5E2DD;
  --label-secondary: #969186;
  --fill-apple: #151E32; /* Azul dos cards */
  --separator: rgba(255, 255, 255, 0.08);
  --dot-color: rgba(255, 255, 255, 0.06); /* Pontinhos no modo escuro */
}

/* ==========================================================================
   2. RESETS E ESTRUTURA GLOBAL (COM FUNDO PONTILHADO)
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg);
  
  /* PADRÃO PONTILHADO CLÁSSICO */
  background-image: radial-gradient(var(--dot-color) 1.5px, transparent 1.5px);
  background-size: 24px 24px; /* Distância entre os pontinhos */
  background-attachment: fixed; /* Deixa os pontos parados ao rolar a página */
  
  color: var(--label-primary);
  overflow-x: hidden;
  padding-top: 200px;
  padding-bottom: 120px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==========================================================================
   3. CABEÇALHO (O CABEÇALHO SOME AO ROLAR A PÁGINA)
   ========================================================================== */
header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 36px 20px 24px;
  text-align: center;
  background-color: var(--bg); /* <-- A MÁGICA AQUI: fundo sólido! */
  z-index: 1000;
  border-bottom: 1px solid var(--separator); /* Uma linha sutil para separar do pontilhado */
}

header span {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 2.5px;
  font-weight: 700;
  color: var(--accent);
  display: block;
}

header h1 {
  font-family: 'Cinzel', serif;
  font-size: 26px;
  margin-top: 6px;
  line-height: 1.2;
}

/* Menu de Navegação */
.main-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.main-nav a {
  font-size: 11px;
  font-weight: 600;
  color: var(--label-primary);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  transition: color 0.2s ease;
}

.main-nav a:hover {
  color: var(--accent);
}

/* Botão de Tema */
.theme-toggle {
  position: absolute;
  right: 24px;
  top: 30px;
  background: transparent;
  border: 1px solid var(--separator);
  color: var(--label-primary);
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  background: var(--label-primary);
  color: var(--bg);
}

/* ==========================================================================
   4. LAYOUT COM MAIS ESPAÇAMENTO (GAP AUMENTADO)
   ========================================================================== */
main, .main-layout {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 36px; /* Maior espaçamento vertical entre os blocos */
}

.control-side, .feed-side {
  display: flex;
  flex-direction: column;
  gap: 36px; /* Espaçamento amplo entre os elementos */
}

/* Busca */
.search-wrapper {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 14px 16px 14px 44px;
  background: var(--fill-apple);
  border: 1px solid var(--separator);
  border-radius: 14px;
  font-size: 14px;
  color: var(--label-primary);
  outline: none;
  transition: all 0.2s ease;
}

.search-wrapper svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--label-secondary);
  width: 16px;
  height: 16px;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(154, 123, 50, 0.12);
}

/* Grade de Navegação Rápida */
.quick-nav-wrapper {
  background: var(--fill-apple);
  border: 1px solid var(--separator);
  border-radius: 24px;
  padding: 24px;
}

.quick-nav-title {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  text-align: center;
  margin-bottom: 16px;
}

.quick-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 8px;
  justify-content: center;
}

.quick-nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  background: var(--bg);
  border: 1px solid var(--separator);
  color: var(--label-primary);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s var(--ease-ios);
}

.quick-nav-item:hover {
  background: var(--label-primary);
  color: var(--bg);
  border-color: var(--label-primary);
  transform: scale(1.05);
}

/* ==========================================================================
   5. CARDS DOS ENSAIOS (SEM ACCORDION & COM BOTAO DIRETO)
   ========================================================================== */
.card, .module-card {
  background: var(--fill-apple);
  border-radius: 24px;
  padding: 36px 28px;
  margin-bottom: 12px; /* Maior separação */
  position: relative;
  overflow: hidden;
  border: 1px solid var(--separator);
  box-shadow: 0 8px 24px rgba(0,0,0,0.015);
  transition: transform 0.3s var(--ease-ios), box-shadow 0.3s ease;
}

.card:hover, .module-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.04);
}

.roman-watermark {
  position: absolute;
  top: -5px;
  right: 12px;
  font-family: 'Cinzel', serif;
  font-size: 130px;
  font-weight: 700;
  color: var(--label-primary);
  opacity: 0.025;
  pointer-events: none;
  user-select: none;
  line-height: 1;
}

.module-badge {
  background: var(--label-primary);
  color: var(--bg);
  font-size: 9px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 20px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  display: inline-block;
  margin-bottom: 16px;
}

.card h2, .module-card h2 {
  font-family: 'Cinzel', serif;
  font-size: 21px;
  margin-bottom: 14px;
  line-height: 1.3;
}

.card p, .objetivo {
  font-size: 14.5px;
  color: var(--label-secondary);
  line-height: 1.7;
  margin-bottom: 24px;
}

/* Ação Direta no Card */
.card-action {
  margin-top: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--separator);
  display: flex;
  justify-content: flex-start;
}

.btn-acao {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg);
  border: 1px solid var(--separator);
  color: var(--label-primary);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s var(--ease-ios);
}

.btn-acao:hover {
  background: var(--label-primary);
  color: var(--bg);
  border-color: var(--label-primary);
}

/* ==========================================================================
   6. MODAL DE LEITURA IMERSIVA EM TELA CHEIA
   ========================================================================== */
.reading-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  z-index: 20000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease-ios);
  overflow-y: auto;
  padding: 60px 20px;
}

.reading-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content-wrapper {
  max-width: 620px;
  margin: 0 auto;
  width: 100%;
}

.modal-close-btn {
  background: transparent;
  border: 1px solid var(--separator);
  color: var(--label-primary);
  padding: 10px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 40px;
  transition: all 0.2s ease;
}

.modal-close-btn:hover {
  background: var(--label-primary);
  color: var(--bg);
}

.modal-article-title {
  font-family: 'Cinzel', serif;
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 24px;
  text-align: center;
  line-height: 1.25;
}

.modal-body-text {
  font-family: 'EB Garamond', serif;
  font-size: 1.35rem;
  line-height: 1.85;
  color: var(--label-primary);
  text-align: justify;
}

.modal-body-text p {
  margin-bottom: 24px;
  text-indent: 1.5em;
}

/* ==========================================================================
   7. BOTÃO FLUTUANTE (VOLTAR AO TOPO)
   ========================================================================== */
#fab-top {
  position: fixed;
  right: 24px;
  bottom: 30px;
  width: 48px;
  height: 48px;
  background: rgba(247, 245, 242, 0.85);
  color: var(--label-primary);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  z-index: 900;
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  pointer-events: none;
  transition: all 0.4s var(--ease-ios);
  border: 1px solid var(--separator);
}

html.dark #fab-top {
  background: rgba(26, 26, 28, 0.85);
}

#fab-top.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ==========================================================================
   8. RODAPÉ E ELEMENTOS FINAIS
   ========================================================================== */
.classical-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 50px auto 24px;
  max-width: 200px;
  opacity: 0.3;
}

.classical-divider::before, .classical-divider::after {
  content: '';
  height: 0.5px;
  flex-grow: 1;
  background: var(--accent);
}

.classical-divider span {
  font-size: 8px;
  color: var(--accent);
  transform: rotate(45deg);
}

footer, .footer-quote {
  text-align: center;
  padding: 20px 20px 40px;
  max-width: 600px;
  margin: 0 auto;
}

.final-phrase {
  font-family: 'EB Garamond', serif;
  font-style: italic;
  font-size: 1.3rem;
  color: var(--accent);
  margin-top: 18px;
  display: block;
  padding-top: 18px;
  border-top: 1px solid var(--separator);
}

.footer-copyright {
  margin-top: 24px;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  opacity: 0.5;
}

/* ==========================================================================
   9. DESKTOP / TELAS GRANDES
   ========================================================================== */
@media (min-width: 1024px) {
  body {
    padding-top: 200px;
  }

  header h1 {
    font-size: 30px;
  }

  main, .main-layout {
    max-width: 760px;
  }
}

/* ==========================================================================
   Ajuste Fino para Celular (Resolve o Botão Encavalado e o Título)
   ========================================================================== */
@media (max-width: 768px) {
  
  /* 1. Transforma o Header em relativo para empurrar o conteúdo naturalmente */
  header {
    position: relative !important;
    padding: 20px 16px 16px !important;
  }

  /* 2. Zera o padding do topo no body (já que o header não é mais absoluto) */
  body {
    padding-top: 0 !important;
  }

  /* 3. Ajusta a frase do topo para não bater no botão e não quebrar feio */
  header span {
    font-size: 8.5px !important;
    letter-spacing: 1.5px !important;
    padding-right: 0 !important;
    margin-bottom: 12px;
  }

  /* 4. Tira o botão da posição absoluta e coloca ele no final do menu */
  .theme-toggle {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    display: inline-block !important;
    margin: 16px auto 0 !important;
  }

  /* 5. Garante que os links do menu fiquem bem espaçados */
  .main-nav {
    gap: 10px 16px !important;
  }
}

/* ==========================================================================
   11. SUPORTE A TEMA ESCURO E CARREGADOR MINIMALISTA DA PÁGINA DE LOGIN
   ========================================================================== */

/* Compatibilidade do Modo Escuro via atributo data-theme */
html[data-theme="dark"] {
  --bg: #0B1121;
  --label-primary: #E5E2DD;
  --label-secondary: #969186;
  --fill-apple: #151E32;
  --separator: rgba(255, 255, 255, 0.08);
  --dot-color: rgba(255, 255, 255, 0.06);
}

/* Animação e Estilo do Carregador Eleganter sem Emoji */
.custom-loader {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px 0;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
}

.spinner-ring {
  width: 28px;
  height: 28px;
  border: 3px solid var(--separator);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  animation: spinLoader 0.8s linear infinite;
}

@keyframes spinLoader {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
