/* =========================
   ARQUIVO: css/anuncios.css
   VERSAO: 2026-10-14d
   CAÇA-PAPÃO — anúncios no site: modal, faixa de aviso, banners e carrossel.
   Usado no painel (/papateste/), na página pública (/) e na prévia do admin.
   Tudo com prefixo "cpa-" para não brigar com o CSS das páginas.
========================= */

/* ---------- Cores de cada anúncio ---------- */
.cpa-cor-azul     { --cpa-c1: #1672d8; --cpa-c2: #57aff9; --cpa-suave: #eaf3ff; --cpa-texto-cor: #0b3c91; }
.cpa-cor-verde    { --cpa-c1: #15803d; --cpa-c2: #22c55e; --cpa-suave: #e6f7f0; --cpa-texto-cor: #065f46; }
.cpa-cor-laranja  { --cpa-c1: #e65100; --cpa-c2: #fb923c; --cpa-suave: #fff3e0; --cpa-texto-cor: #8a4500; }
.cpa-cor-vermelho { --cpa-c1: #c62828; --cpa-c2: #f87171; --cpa-suave: #fdecee; --cpa-texto-cor: #842029; }
.cpa-cor-roxo     { --cpa-c1: #6d28d9; --cpa-c2: #a78bfa; --cpa-suave: #f3e8ff; --cpa-texto-cor: #4c1d95; }
.cpa-cor-escuro   { --cpa-c1: #111827; --cpa-c2: #374151; --cpa-suave: #f3f4f6; --cpa-texto-cor: #111827; }

/* Medidas previsíveis em qualquer página */
.cpa-modal, .cpa-modal *, .cpa-modal *::before, .cpa-modal *::after,
.cpa-faixa, .cpa-faixa *,
.cpa-banners, .cpa-banners *,
.cpa-modal-caixa, .cpa-modal-caixa * { box-sizing: border-box; }

/* =========================
   TEXTO FORMATADO (vem do editor do admin)
========================= */
.cpa-texto-formatado { line-height: 1.55; overflow-wrap: anywhere; }
.cpa-texto-formatado div,
.cpa-texto-formatado p { margin: 0; }
.cpa-texto-formatado b,
.cpa-texto-formatado strong { font-weight: 700; }
.cpa-texto-formatado i,
.cpa-texto-formatado em { font-style: italic; }
.cpa-texto-formatado ul,
.cpa-texto-formatado ol { display: inline-block; margin: 0.35em 0; padding-left: 1.4em; text-align: left; }
.cpa-texto-formatado li { margin: 0.15em 0; }
.cpa-texto-formatado a {
  color: var(--cpa-c1, #1672d8);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  border-radius: 3px;
  transition: color 0.2s ease, text-decoration-color 0.2s ease, background 0.2s ease;
}
.cpa-texto-formatado a:hover { text-decoration-color: currentColor; background: rgba(22, 114, 216, 0.08); }
.cpa-texto-formatado a:focus-visible { outline: 2px solid var(--cpa-c2, #57aff9); outline-offset: 2px; }
[data-theme="dark"] .cpa-texto-formatado a { color: var(--cpa-c2, #57aff9); }
.cpa-texto-formatado span[style*="background"],
.cpa-texto-formatado b[style*="background"],
.cpa-texto-formatado i[style*="background"],
.cpa-texto-formatado u[style*="background"] { padding: 0 0.15em; border-radius: 3px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }

/* =========================
   MODAL
========================= */
.cpa-modal {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overscroll-behavior: contain;
}
.cpa-modal[hidden] { display: none; }

.cpa-modal-fundo {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.cpa-modal.aberto .cpa-modal-fundo { opacity: 1; }

.cpa-modal-caixa {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  border-radius: 16px;
  background: #fff;
  color: #374151;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
  overflow: hidden;
  font-family: inherit;
  text-align: center;
  --cpa-c1: #1672d8; --cpa-c2: #57aff9;
}
.cpa-modal-caixa.cpa-com-imagem { max-width: 520px; }
.cpa-modal-caixa:focus { outline: none; }

/* Faixa de cor no topo (identidade: mesmo degradê dos cabeçalhos do sistema) */
.cpa-modal-caixa::before {
  content: '';
  flex: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--cpa-c1), var(--cpa-c2));
}
.cpa-modal-caixa.cpa-com-imagem::before { display: none; }

/* Entrada e saída (a prévia do admin mostra sem animação: lá não existe .cpa-modal) */
.cpa-modal .cpa-modal-caixa {
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.cpa-modal.aberto .cpa-modal-caixa { opacity: 1; transform: none; }

/* X */
.cpa-modal-x {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #f1f5f9;
  color: #475569;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.cpa-modal-x:hover { background: var(--cpa-c1); color: #fff; transform: rotate(90deg); }
.cpa-modal-x:focus-visible { outline: 3px solid var(--cpa-c2); outline-offset: 2px; }
.cpa-com-imagem .cpa-modal-x { background: rgba(255, 255, 255, 0.95); box-shadow: 0 2px 10px rgba(15, 23, 42, 0.25); }

/* Barra do "fecha sozinho" */
.cpa-modal-tempo {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 4;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.85);
  transform-origin: left center;
  pointer-events: none;
}
.cpa-modal-caixa:not(.cpa-com-imagem) .cpa-modal-tempo { background: var(--cpa-c1); opacity: 0.35; height: 5px; }
.cpa-modal.aberto .cpa-modal-tempo { animation: cpaEncolher var(--cpa-fechar, 10s) linear forwards; }
@keyframes cpaEncolher { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Imagem: aparece inteira, nunca cortada */
.cpa-modal-imagem {
  display: block;
  flex: 0 1 auto;
  min-height: 0;
  background: #f1f5f9;
  line-height: 0;
}
.cpa-modal-imagem img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 42vh;
  max-height: 42dvh;
  object-fit: contain;
  margin: 0 auto;
}

/* Corpo */
.cpa-modal-corpo {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 26px 22px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.cpa-modal-corpo::-webkit-scrollbar { width: 6px; }
.cpa-modal-corpo::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
.cpa-modal-caixa:not(.cpa-com-imagem) .cpa-modal-corpo { padding-top: 30px; }
.cpa-sem-titulo:not(.cpa-com-imagem) .cpa-modal-corpo { padding-top: 34px; }

.cpa-modal-titulo,
.cpa-modal .cpa-modal-titulo {
  margin: 0 30px 10px;
  padding: 0;
  font-family: inherit;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  color: #111827;
  letter-spacing: -0.01em;
  border: none;
  text-transform: none;
}
.cpa-com-imagem .cpa-modal-titulo { margin-left: 0; margin-right: 0; }
.cpa-modal-titulo::after { content: none; }

.cpa-modal-texto { font-size: 0.98rem; color: #4b5563; }

/* Botões */
.cpa-modal-botoes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}
.cpa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 22px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none !important;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.cpa-btn-principal {
  flex: 1 1 180px;
  max-width: 280px;
  color: #fff !important;
  background: linear-gradient(135deg, var(--cpa-c1), var(--cpa-c2));
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.18);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--cpa-c1) 35%, transparent);
}
.cpa-btn-principal:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(15, 23, 42, 0.25); }
.cpa-btn-principal:hover { box-shadow: 0 10px 22px color-mix(in srgb, var(--cpa-c1) 45%, transparent); }
.cpa-btn-principal i { font-size: 0.85em; transition: transform 0.2s ease; }
.cpa-btn-principal:hover i { transform: translateX(3px); }
.cpa-btn-secundario { background: #f3f4f6; border-color: #e5e7eb; color: #4b5563; }
.cpa-btn-secundario:hover { background: #e5e7eb; color: #1f2937; }
.cpa-btn:focus-visible { outline: 3px solid var(--cpa-c2); outline-offset: 2px; }

/* ---------- Só a imagem: imagem inteira + X, sem caixa ---------- */
.cpa-modal-caixa.cpa-so-imagem {
  width: auto;
  max-width: min(640px, calc(100vw - 32px));
  background: transparent;
  box-shadow: none;
  overflow: visible;
  border-radius: 0;
}
.cpa-modal-caixa.cpa-so-imagem::before { display: none; }
.cpa-so-imagem .cpa-modal-imagem { background: none; border-radius: 14px; overflow: hidden; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45); }
.cpa-so-imagem .cpa-modal-imagem img {
  width: auto;
  max-width: 100%;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
}
.cpa-so-imagem a.cpa-modal-imagem { cursor: pointer; transition: transform 0.25s ease; }
.cpa-so-imagem a.cpa-modal-imagem:hover { transform: scale(1.01); }
.cpa-so-imagem .cpa-modal-x { top: -14px; right: -14px; width: 36px; height: 36px; background: #fff; color: #1f2937; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); }
.cpa-so-imagem .cpa-modal-tempo { top: 0; border-radius: 14px 14px 0 0; }

@media (max-width: 600px) {
  .cpa-modal { padding: 12px; }
  .cpa-modal-caixa { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); border-radius: 14px; }
  .cpa-modal-corpo { padding: 22px 18px 18px; }
  .cpa-modal-titulo, .cpa-modal .cpa-modal-titulo { font-size: 1.18rem; margin-left: 34px; margin-right: 34px; }
  .cpa-modal-texto { font-size: 0.92rem; }
  .cpa-modal-botoes { gap: 8px; }
  .cpa-btn { flex: 1 1 auto; padding: 10px 14px; }
  .cpa-btn-principal { max-width: none; }
  .cpa-modal-caixa.cpa-so-imagem { max-width: calc(100vw - 24px); }
  .cpa-so-imagem .cpa-modal-imagem img { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); }
  .cpa-so-imagem .cpa-modal-x { top: 8px; right: 8px; width: 34px; height: 34px; }
}

/* Página travada enquanto o modal está aberto (o JS guarda e devolve a posição da rolagem) */
html.cpa-rolagem-travada,
html.cpa-rolagem-travada body { overflow: hidden !important; }
html.cpa-rolagem-travada body { position: fixed !important; left: 0; right: 0; width: 100%; }

/* =========================
   FAIXA DE AVISO
========================= */
.cpa-faixa {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 11px 52px 11px 18px;
  background: linear-gradient(90deg, var(--cpa-c1, #1672d8), var(--cpa-c2, #57aff9));
  color: #fff;
  font-size: 0.92rem;
  line-height: 1.4;
  text-align: center;
  animation: cpaDescer 0.4s ease-out;
}
.cpa-faixa-icone { flex: 0 0 auto; font-size: 1rem; opacity: 0.95; animation: cpaBalancar 2.6s ease-in-out infinite; transform-origin: 30% 70%; }
.cpa-faixa-texto { min-width: 0; font-weight: 500; }
.cpa-faixa-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--cpa-c1, #1672d8) !important;
  font-weight: 700;
  font-size: 0.85em;
  text-decoration: none !important;
  white-space: nowrap;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.cpa-faixa-link:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18); }
.cpa-faixa-fechar {
  position: absolute;
  right: 10px;
  top: 50%;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 0.95rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transform: translateY(-50%);
  transition: background 0.2s ease;
}
.cpa-faixa-fechar:hover { background: rgba(255, 255, 255, 0.32); }
.cpa-faixa-fechar:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.cpa-faixa.saindo { animation: cpaSubir 0.3s ease-in forwards; }

@keyframes cpaDescer { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes cpaSubir { to { opacity: 0; transform: translateY(-8px); } }
@keyframes cpaBalancar { 0%, 70%, 100% { transform: rotate(0); } 80% { transform: rotate(-12deg); } 90% { transform: rotate(8deg); } }

@media (max-width: 600px) {
  .cpa-faixa { justify-content: flex-start; text-align: left; font-size: 0.85rem; padding: 10px 46px 10px 14px; }
  .cpa-faixa-link { margin: 4px 0 0; }
}

/* =========================
   BANNERS (imagem fixa) — topo, meio ou rodapé
========================= */
.cpa-banners {
  display: grid;
  gap: 16px;
  width: 100%;
  margin: 18px auto;
}
.cpa-banners.cpa-qtd-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cpa-banners.cpa-qtd-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cpa-banners > .cpa-carrossel { grid-column: 1 / -1; }   /* carrossel sempre na largura toda */

.cpa-banner {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #e5e7eb;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
  line-height: 0;
}
.cpa-banner > a { display: block; }
.cpa-banner > img,
.cpa-banner > a > img { display: block; width: 100%; height: auto; }
.cpa-banner > a { transition: filter 0.2s ease; }
.cpa-banner > a:hover { filter: brightness(1.04); }

.cpa-selo { display: block; margin-top: -10px; font-size: 0.68rem; color: #9ca3af; text-align: right; letter-spacing: 0.04em; text-transform: uppercase; }

@media (max-width: 700px) {
  .cpa-banners.cpa-qtd-2,
  .cpa-banners.cpa-qtd-3 { grid-template-columns: 1fr; }
  .cpa-banners { gap: 12px; margin: 14px auto; }
}

/* =========================
   CARROSSEL
========================= */
.cpa-carrossel {
  --cpa-proporcao: 4 / 1;        /* o PHP troca pela proporção da 1ª imagem */
  --cpa-intervalo: 5s;
  isolation: isolate;
  outline: none;
}
.cpa-carrossel-janela { overflow: hidden; aspect-ratio: var(--cpa-proporcao); }
.cpa-carrossel-trilho {
  display: flex;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: transform;
}
.cpa-slide { flex: 0 0 100%; height: 100%; }
.cpa-slide > a { display: block; height: 100%; }
.cpa-slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

.cpa-carrossel-seta {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 38px;
  height: 38px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #1672d8;
  font-size: 0.85rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.cpa-carrossel-ant  { left: 10px; }
.cpa-carrossel-prox { right: 10px; }
.cpa-carrossel:hover .cpa-carrossel-seta,
.cpa-carrossel:focus-within .cpa-carrossel-seta { opacity: 1; }
.cpa-carrossel-seta:hover { background: #1672d8; color: #fff; transform: translateY(-50%) scale(1.06); }
.cpa-carrossel-seta:focus-visible { outline: 2px solid #fff; outline-offset: 2px; opacity: 1; }
@media (hover: none) { .cpa-carrossel-seta { opacity: 0.85; width: 32px; height: 32px; } }

.cpa-carrossel-pontos {
  position: absolute;
  left: 50%;
  bottom: 10px;
  z-index: 2;
  display: flex;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.35);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transform: translateX(-50%);
  line-height: 0;
}
.cpa-carrossel-pontos button {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: width 0.3s ease, background 0.3s ease;
}
.cpa-carrossel-pontos button:hover { background: rgba(255, 255, 255, 0.9); }
.cpa-carrossel-pontos button.ativo { width: 22px; background: #fff; }
.cpa-carrossel-pontos button:focus-visible { outline: 2px solid #57aff9; outline-offset: 2px; }

.cpa-carrossel-tempo {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 3;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #1672d8, #57aff9);
  transform: scaleX(0);
  transform-origin: left center;
  pointer-events: none;
}
.cpa-carrossel-tempo.rodando { animation: cpaTempo var(--cpa-intervalo) linear forwards; }
@keyframes cpaTempo { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (max-width: 600px) {
  .cpa-banner { border-radius: 10px; }
  .cpa-carrossel-ant  { left: 6px; }
  .cpa-carrossel-prox { right: 6px; }
  .cpa-carrossel-pontos { bottom: 6px; padding: 4px 6px; gap: 5px; }
  .cpa-carrossel-pontos button { width: 6px; height: 6px; }
  .cpa-carrossel-pontos button.ativo { width: 16px; }
}

/* =========================
   TEMA ESCURO (página pública e painel usam data-theme="dark")
========================= */
[data-theme="dark"] .cpa-modal-caixa:not(.cpa-so-imagem) { background: #111827; color: #d1d5db; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6); }
[data-theme="dark"] .cpa-modal-titulo { color: #f9fafb; }
[data-theme="dark"] .cpa-modal-texto { color: #d1d5db; }
[data-theme="dark"] .cpa-modal-imagem { background: #0b1220; }
[data-theme="dark"] .cpa-modal-caixa:not(.cpa-com-imagem) .cpa-modal-x { background: #1f2937; color: #d1d5db; }
[data-theme="dark"] .cpa-btn-secundario { background: #1f2937; border-color: #374151; color: #d1d5db; }
[data-theme="dark"] .cpa-btn-secundario:hover { background: #374151; color: #fff; }
[data-theme="dark"] .cpa-banner { background: #1f2937; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4); }
[data-theme="dark"] .cpa-modal-corpo { scrollbar-color: #374151 transparent; }

/* Quem pede menos movimento */
@media (prefers-reduced-motion: reduce) {
  .cpa-modal .cpa-modal-caixa,
  .cpa-modal-fundo,
  .cpa-carrossel-trilho { transition: none; }
  .cpa-faixa,
  .cpa-faixa-icone { animation: none; }
  .cpa-carrossel-tempo { display: none; }
}
