/* ============================================================
   pwa-mobile.css
   Estilos específicos para PWA, Navegação Mobile App e Modo Leitura
   ============================================================ */

/* ------------------------------------------------------------
   1. Ajuste de Espaçamento Global e Otimizações Mobile App
   ------------------------------------------------------------ */
@media (max-width: 768px) {
  body {
    padding-bottom: calc(78px + env(safe-area-inset-bottom, 12px));
  }
  
  /* Ajuste de legibilidade mobile (evita espaçamentos exagerados da justificação) */
  .content-section p,
  .content-section ul li,
  .content-section ol li,
  .character-bio p,
  .article-content p {
    text-align: left !important;
    hyphens: auto;
    -webkit-hyphens: auto;
    word-break: normal;
  }

  /* Otimização e Proporção Elegante de Botões no Mobile/App */
  .btn,
  .btn-primary,
  .btn-outline,
  .btn-outline-primary,
  .btn-outline-secondary,
  .btn-secondary,
  .btn-lg {
    font-size: 0.88rem !important;
    padding: 0.65rem 1.25rem !important;
    letter-spacing: 0.02em !important;
    text-transform: none !important; /* Muito mais elegante e moderno no app */
    font-weight: 700 !important;
    border-radius: 999px !important;
    white-space: normal !important;
    max-width: 100% !important;
    line-height: 1.35 !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
  }

  .btn-sm {
    font-size: 0.78rem !important;
    padding: 0.4rem 0.85rem !important;
  }

  /* Ajuste para botões de navegação de capítulos */
  .cronologia-nav,
  .contexto-historico-nav {
    flex-direction: column !important;
    gap: 0.75rem !important;
    margin-top: var(--space-8) !important;
    padding-top: var(--space-6) !important;
  }

  .cronologia-nav__btn,
  .contexto-historico-nav__btn {
    width: 100% !important;
    justify-content: center !important;
    font-size: 0.86rem !important;
    padding: 0.65rem 1rem !important;
  }
}

@media (max-width: 480px) {
  .btn,
  .btn-primary,
  .btn-outline,
  .btn-outline-primary,
  .btn-outline-secondary,
  .btn-secondary,
  .btn-lg {
    font-size: 0.84rem !important;
    padding: 0.6rem 1.1rem !important;
  }
}

/* ------------------------------------------------------------
   2. Barra de Navegação Inferior (App Bottom Navigation Bar)
   ------------------------------------------------------------ */
.app-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .app-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    min-height: 66px;
    height: auto;
    background: #1A252F;
    background: linear-gradient(180deg, rgba(28, 40, 52, 0.98) 0%, rgba(16, 24, 32, 1) 100%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(201, 168, 76, 0.35);
    z-index: 1000;
    padding-top: 9px;
    padding-bottom: calc(9px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
    justify-content: space-around;
    align-items: center;
    touch-action: manipulation;
  }

  .app-bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: auto;
    padding: 3px 0 2px;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-size: 0.68rem;
    font-weight: 600;
    gap: 4px;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    background: transparent;
    border: none;
  }

  .app-bottom-nav__item i {
    font-size: 1.25rem;
    line-height: 1;
    transition: transform 0.2s ease, color 0.2s ease;
  }

  .app-bottom-nav__item.active,
  .app-bottom-nav__item:active {
    color: #C9A84C;
  }

  .app-bottom-nav__item.active i {
    transform: translateY(-2px) scale(1.12);
    color: #F0C850;
  }

  .app-bottom-nav__item span {
    letter-spacing: 0.2px;
    line-height: 1.2;
    white-space: nowrap;
  }
}

/* ------------------------------------------------------------
   3. Banner Flutuante de Instalação do PWA
   ------------------------------------------------------------ */
.pwa-install-banner {
  position: fixed;
  bottom: 80px;
  left: 1rem;
  right: 1rem;
  max-width: 440px;
  margin: 0 auto;
  background: #FFFFFF;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  border-left: 4px solid #C9A84C;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 1000;
  transform: translateY(120%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.pwa-install-banner.is-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.pwa-install-banner__icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.pwa-install-banner__content {
  flex: 1;
  min-width: 0;
}

.pwa-install-banner__title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #2C3E50;
  margin: 0 0 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pwa-install-banner__desc {
  font-size: 0.75rem;
  color: #666;
  margin: 0;
}

.pwa-install-banner__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.pwa-install-banner__btn {
  background: #2C3E50;
  color: #FFFFFF;
  border: none;
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background 0.2s ease;
}

.pwa-install-banner__btn:hover {
  background: #C9A84C;
  color: #2C3E50;
}

.pwa-install-banner__close {
  background: transparent;
  border: none;
  color: #888;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ------------------------------------------------------------
   4. Barra de Ferramentas de Leitura (Reader Toolbar)
   ------------------------------------------------------------ */
.reader-toolbar {
  background: #FFFFFF;
  border: 1px solid #DDD5C8;
  border-radius: 12px;
  padding: 0.6rem 1rem;
  margin: 0 0 var(--space-6) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.reader-toolbar-home-container {
  margin-top: var(--space-6) !important;
  margin-bottom: 0 !important;
}

@media (max-width: 640px) {
  .page-hero {
    padding-top: calc(64px + var(--space-5)) !important;
    padding-bottom: var(--space-6) !important;
  }

  .home-hero {
    padding-top: calc(64px + var(--space-6)) !important;
    padding-bottom: var(--space-6) !important;
    min-height: auto;
  }

  .content-section,
  section.content-section {
    padding-top: var(--space-4) !important;
    padding-bottom: var(--space-10) !important;
  }

  .reader-toolbar {
    padding: 0.45rem 0.65rem;
    gap: 0.4rem;
    margin: 0 0 var(--space-4) 0;
    border-radius: 10px;
    justify-content: space-between;
  }

  .reader-toolbar-home-container {
    margin-top: var(--space-4) !important;
  }

  .reader-toolbar__label {
    display: none !important; /* Esconde textos 'Texto:' e 'Modo:' no celular, exibindo os botões de forma limpa */
  }

  .reader-toolbar__group {
    gap: 0.25rem !important;
  }

  .reader-btn {
    padding: 0.3rem 0.5rem !important;
    font-size: 0.8rem !important;
  }

  .reader-theme-btn {
    width: 22px !important;
    height: 22px !important;
  }

  #btnAudioPlay {
    padding: 0.35rem 0.6rem !important;
    font-size: 0.78rem !important;
  }
}

.reader-toolbar__group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.reader-toolbar__label {
  font-size: 0.8rem;
  color: #777;
  font-weight: 600;
  margin-right: 0.25rem;
}

.reader-btn {
  background: #F8F5F0;
  border: 1px solid #DDD5C8;
  color: #2C3E50;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
}

.reader-btn:hover {
  background: #EDE8DF;
  border-color: #C9A84C;
}

.reader-btn.is-active {
  background: #2C3E50;
  color: #FFFFFF;
  border-color: #2C3E50;
}

.reader-btn.is-playing {
  background: #8B6914;
  color: #FFFFFF;
  border-color: #8B6914;
  animation: pulse-audio 1.5s infinite;
}

@keyframes pulse-audio {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.reader-theme-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s ease;
}

.reader-theme-btn:hover {
  transform: scale(1.15);
}

.reader-theme-btn.is-active {
  border-color: #C9A84C;
  box-shadow: 0 0 0 2px rgba(201, 168, 76, 0.4);
}

.reader-theme-btn--light {
  background: #F8F5F0;
  border-color: #DDD5C8;
}

.reader-theme-btn--sepia {
  background: #F4ECD8;
  border-color: #D4C3A3;
}

.reader-theme-btn--dark {
  background: #1A1A2E;
  border-color: #334155;
}

/* ------------------------------------------------------------
   5. Temas Personalizados (Sépia e Noturno)
   ------------------------------------------------------------ */
/* Tema Sépia */
html.theme-sepia,
body.theme-sepia {
  --color-bg-primary: #F4ECD8 !important;
  --color-bg-secondary: #EAE1CB !important;
  --color-bg-card: #FAF4E6 !important;
  --color-text-primary: #3D2E1E !important;
  --color-text-secondary: #5C4A38 !important;
  --color-border: #D9CCA8 !important;
  background-color: #F4ECD8 !important;
  color: #3D2E1E !important;
}

body.theme-sepia .content-section,
body.theme-sepia .page-wrapper,
body.theme-sepia section:not(.page-hero) {
  background-color: #F4ECD8 !important;
}

body.theme-sepia h1:not(.page-hero__title):not(.home-hero__title),
body.theme-sepia h2:not(.page-hero *):not(.home-hero *),
body.theme-sepia h3:not(.page-hero *):not(.home-hero *),
body.theme-sepia h4:not(.page-hero *):not(.home-hero *) {
  color: #4A3525 !important;
}

body.theme-sepia p:not(.page-hero *):not(.home-hero *):not(.hero-subtitle):not(.site-footer *),
body.theme-sepia li:not(.page-hero *):not(.home-hero *):not(.site-footer *),
body.theme-sepia blockquote {
  color: #3D2E1E !important;
}

/* Preservação permanente do rodapé em todos os temas */
.site-footer,
.site-footer p,
.site-footer .footer-minimal__tagline,
.site-footer .footer-minimal__copy,
.site-footer .footer-minimal__copy strong,
body.theme-sepia .site-footer p,
body.theme-sepia .site-footer .footer-minimal__tagline,
body.theme-sepia .site-footer .footer-minimal__copy,
body.theme-sepia .site-footer .footer-minimal__copy strong,
body.theme-dark .site-footer p,
body.theme-dark .site-footer .footer-minimal__tagline,
body.theme-dark .site-footer .footer-minimal__copy,
body.theme-dark .site-footer .footer-minimal__copy strong {
  color: #FFFFFF !important;
}

.site-footer a.footer-link-orando,
.site-footer a.footer-link-orando i,
body.theme-sepia .site-footer a.footer-link-orando,
body.theme-sepia .site-footer a.footer-link-orando i,
body.theme-dark .site-footer a.footer-link-orando,
body.theme-dark .site-footer a.footer-link-orando i {
  color: #C9A84C !important;
  opacity: 1 !important;
}

/* ============================================================
   PRESERVAÇÃO TOTAL DAS CORES DOS BANNERS (HEROES) NO MODO SÉPIA E NOTURNO
   Todos os títulos, subtítulos, labels e breadcrumbs dos banners
   mantêm a mesma cor original para legibilidade perfeita.
   ============================================================ */
body.theme-sepia .home-hero__title,
body.theme-dark .home-hero__title {
  color: #FFFFFF !important;
}

body.theme-sepia .home-hero__title span,
body.theme-dark .home-hero__title span {
  color: #8B6914 !important;
  -webkit-text-fill-color: #8B6914 !important;
  -webkit-text-stroke: 1px #FFFFFF !important;
}

body.theme-sepia .home-hero__subtitle,
body.theme-dark .home-hero__subtitle,
body.theme-sepia .page-hero__subtitle,
body.theme-dark .page-hero__subtitle,
body.theme-sepia .hero-subtitle,
body.theme-dark .hero-subtitle {
  color: #FFFFFF !important;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.85) !important;
}

body.theme-sepia .page-hero__title,
body.theme-dark .page-hero__title {
  color: #FFFFFF !important;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

body.theme-sepia .page-hero__label,
body.theme-dark .page-hero__label {
  color: #C9A84C !important;
}

body.theme-sepia .page-hero .breadcrumb__item a,
body.theme-dark .page-hero .breadcrumb__item a {
  color: rgba(255, 255, 255, 0.75) !important;
}

body.theme-sepia .page-hero .breadcrumb__item--active,
body.theme-dark .page-hero .breadcrumb__item--active {
  color: #FFFFFF !important;
}

body.theme-sepia .page-hero .breadcrumb__separator,
body.theme-dark .page-hero .breadcrumb__separator {
  color: rgba(255, 255, 255, 0.4) !important;
}

body.theme-sepia .reader-toolbar {
  background: #EDE2C8 !important;
  border-color: #D4C3A3 !important;
}

body.theme-sepia .reader-btn {
  background: #FAF4E6 !important;
  border-color: #D4C3A3 !important;
  color: #3D2E1E !important;
}

body.theme-sepia .reader-btn.is-active {
  background: #8B6914 !important;
  color: #FFFFFF !important;
  border-color: #8B6914 !important;
}

body.theme-sepia .cronologia-nav {
  background: #EDE2C8 !important;
  border-color: #D4C3A3 !important;
}

/* Tema Noturno (Dark Mode) */
html.theme-dark,
body.theme-dark {
  --color-bg-primary: #0F172A !important;
  --color-bg-secondary: #1E293B !important;
  --color-bg-card: #1E293B !important;
  --color-text-primary: #E2E8F0 !important;
  --color-text-secondary: #94A3B8 !important;
  --color-border: #334155 !important;
  background-color: #0F172A !important;
  color: #E2E8F0 !important;
}

body.theme-dark .content-section,
body.theme-dark .page-wrapper,
body.theme-dark section:not(.page-hero) {
  background-color: #0F172A !important;
}

body.theme-dark h1:not(.page-hero__title):not(.home-hero__title),
body.theme-dark h2:not(.page-hero *):not(.home-hero *),
body.theme-dark h3:not(.page-hero *):not(.home-hero *),
body.theme-dark h4:not(.page-hero *):not(.home-hero *) {
  color: #F8FAFC !important;
}

body.theme-dark p:not(.page-hero *):not(.home-hero *):not(.hero-subtitle):not(.site-footer *),
body.theme-dark li:not(.page-hero *):not(.home-hero *):not(.site-footer *),
body.theme-dark blockquote {
  color: #CBD5E1 !important;
}

body.theme-dark .reader-toolbar {
  background: #1E293B !important;
  border-color: #334155 !important;
}

body.theme-dark .reader-toolbar__label {
  color: #94A3B8 !important;
}

body.theme-dark .reader-btn {
  background: #0F172A !important;
  border-color: #334155 !important;
  color: #E2E8F0 !important;
}

body.theme-dark .reader-btn:hover {
  background: #334155 !important;
  color: #FFFFFF !important;
}

body.theme-dark .reader-btn.is-active {
  background: #C9A84C !important;
  color: #0F172A !important;
  border-color: #C9A84C !important;
}

body.theme-dark .cronologia-nav {
  background: #1E293B !important;
  border-color: #334155 !important;
}

body.theme-dark .cronologia-nav__btn--voltar,
body.theme-dark .cronologia-nav__btn--proximo {
  background: #0F172A !important;
  color: #E2E8F0 !important;
  border-color: #334155 !important;
}

body.theme-dark .character-card,
body.theme-dark .resource-card,
body.theme-dark .card {
  background-color: #1E293B !important;
  border-color: #334155 !important;
  color: #E2E8F0 !important;
}

body.theme-dark .character-card__title,
body.theme-dark .resource-card__title {
  color: #F8FAFC !important;
}

body.theme-dark .character-card__description,
body.theme-dark .resource-card__description {
  color: #94A3B8 !important;
}

/* ------------------------------------------------------------
   Modal de Instalação do App (Mobile & Desktop)
   ------------------------------------------------------------ */
.modal-install-app {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-install-app[hidden] {
  display: none !important;
}

.modal-install-app__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.modal-install-app__box {
  position: relative;
  z-index: 1;
  background: #FFFFFF;
  border-radius: 20px;
  max-width: 420px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(201, 168, 76, 0.3);
  text-align: left;
  animation: modal-entrada 0.3s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.modal-install-app__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  border: none;
  color: #2C3E50;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-install-app__close:hover {
  background: #1A252F;
  color: #FFFFFF;
}

.modal-install-app__header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.modal-install-app__icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.modal-install-app__title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: #1A252F;
  margin: 0;
  line-height: 1.2;
}

.modal-install-app__subtitle {
  font-size: 0.85rem;
  color: #C9A84C;
  font-weight: 700;
  margin: 2px 0 0;
}

.modal-install-app__desc {
  font-size: 0.88rem;
  color: #555;
  line-height: 1.5;
  margin-bottom: 1.15rem;
}

.modal-install-app__steps {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: #F8F5F0;
  border: 1px solid #EAE1CB;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.modal-install-step {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.modal-install-step__num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #C9A84C;
  color: #1A252F;
  font-weight: 800;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-install-step p {
  margin: 0;
  font-size: 0.85rem;
  color: #2C3E50;
  line-height: 1.4;
}

.modal-install-app__action-btn {
  width: 100%;
  background: #1A252F;
  color: #FFFFFF;
  border: 1px solid #C9A84C;
  padding: 0.75rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
}

.modal-install-app__action-btn:hover {
  background: #C9A84C;
  color: #1A252F;
}

/* ------------------------------------------------------------
   6. Otimização de Tabelas de Conciliação e Leitura Mobile
   ------------------------------------------------------------ */
.content-section table,
.article-content table {
  width: 100%;
  border-collapse: collapse;
  min-width: 580px; /* Garante que em telas pequenas a tabela tenha respiro e scroll suave */
}

div[style*="overflow-x: auto"] {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* Tabelas no Modo Sépia */
body.theme-sepia table {
  background-color: #FAF4E6 !important;
  color: #3D2E1E !important;
}

body.theme-sepia table tr {
  border-bottom-color: #D9CCA8 !important;
}

body.theme-sepia table th {
  background-color: #EDE2C8 !important;
  color: #4A3525 !important;
  border-bottom: 2px solid #D9CCA8 !important;
}

body.theme-sepia table td {
  color: #3D2E1E !important;
  border-bottom-color: #E8DDCA !important;
}

body.theme-sepia table tr:nth-child(even) {
  background-color: rgba(61, 46, 30, 0.03) !important;
}

/* Tabelas no Modo Noturno */
body.theme-dark table {
  background-color: #1E293B !important;
  color: #E2E8F0 !important;
}

body.theme-dark table tr {
  border-bottom-color: #334155 !important;
}

body.theme-dark table th {
  background-color: #0F172A !important;
  color: #F8FAFC !important;
  border-bottom: 2px solid #334155 !important;
}

body.theme-dark table td {
  color: #CBD5E1 !important;
  border-bottom-color: #334155 !important;
}

body.theme-dark table tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.03) !important;
}

body.theme-dark table td strong {
  color: #E2E8F0 !important;
}

body.theme-dark table td em {
  color: #94A3B8 !important;
}

/* Barra de Leitura Mobile Touch Ergonomia */
@media (max-width: 480px) {
  .reader-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.65rem;
    gap: 0.35rem;
  }

  .reader-btn {
    min-height: 36px;
    padding: 0.35rem 0.6rem !important;
    font-size: 0.85rem !important;
  }

  .reader-theme-btn {
    min-width: 26px !important;
    min-height: 26px !important;
  }

  #btnAudioPlay,
  #btnAudioStop {
    min-height: 36px;
    font-size: 0.8rem !important;
    padding: 0.4rem 0.75rem !important;
  }
}

