/* Mestres Play · janelas de oferta e de gatilho (v23a), no design system do Arsenal dos Mestres
   (design-system-arsenal: vitrine escura, moldura de luz, destaque verde-limão como luz, títulos em Sora, texto em DM Sans).
   O mesmo arquivo serve o site do aluno (comunicacao.js) e a prévia do painel (admin-inteligencia.js, admin-comunicacao.js):
   os tokens ficam no próprio componente, então a janela é igual nos dois lugares. Classes com prefixo com-oferta / mpo-. */

@font-face { font-family: 'Sora'; src: url('fonts/sora-latin.woff2') format('woff2'); font-weight: 100 800; font-display: swap; }
@font-face { font-family: 'DM Sans'; src: url('fonts/dm-sans-latin.woff2') format('woff2'); font-weight: 100 1000; font-display: swap; }

.com-oferta, .com-gatilho-fundo {
  --o-fundo: #060708;
  --o-topo: #14171b;
  --o-base: #0d0f12;
  --o-superficie: #13161a;
  --o-linha: rgba(255, 255, 255, .075);
  --o-linha-2: rgba(255, 255, 255, .13);
  --o-texto: #f5f6f8;
  --o-texto-2: #b9c0c8;
  --o-texto-3: #858d97;
  --o-destaque: #c5f76b;
  --o-sobre: #0b0d0f;
  --o-sucesso: #7fd6a0;
  --o-d12: color-mix(in srgb, var(--o-destaque) 12%, transparent);
  --o-d22: color-mix(in srgb, var(--o-destaque) 22%, transparent);
  --o-d35: color-mix(in srgb, var(--o-destaque) 35%, transparent);
  --o-d55: color-mix(in srgb, var(--o-destaque) 55%, transparent);
  --o-curva: cubic-bezier(.2, .8, .2, 1);
  --o-titulo: Sora, "DM Sans", system-ui, sans-serif;
  --o-leitura: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- a janela: cartão com moldura de luz e um halo do destaque no alto ---------- */
.com-oferta {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 150;
  width: min(380px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  overscroll-behavior: contain;
  color: var(--o-texto);
  font-family: var(--o-leitura);
  border: 1px solid transparent;
  border-radius: 24px;
  background:
    radial-gradient(120% 70% at 88% -12%, var(--o-d12) 0%, transparent 60%) padding-box,
    linear-gradient(180deg, var(--o-topo), var(--o-base)) padding-box,
    linear-gradient(160deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, .06) 26%, rgba(255, 255, 255, .03) 62%, var(--o-d35)) border-box;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 40px 90px -40px #000, 0 0 120px -56px var(--o-d55);
  animation: mpo-entra .45s var(--o-curva) both;
  -webkit-font-smoothing: antialiased;
}
.com-oferta * { box-sizing: border-box; }
/* a janela não herda o desenho de botão de quem a hospeda (o painel tem estilo próprio para todo button) */
.com-oferta button { box-shadow: none; filter: none; transform: none; min-height: 0; text-transform: none; letter-spacing: normal; }
.com-oferta button:hover, .com-oferta button:active { box-shadow: none; filter: none; transform: none; }

/* fechar: botão de vidro */
.com-oferta .com-oferta-fechar {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--o-texto-2);
  background: rgba(6, 7, 8, .62);
  border: 1px solid var(--o-linha-2);
  border-radius: 999px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
  transition: color .2s var(--o-curva), border-color .2s var(--o-curva), background .2s var(--o-curva);
}
.com-oferta .com-oferta-fechar:hover { color: var(--o-texto); border-color: var(--o-d35); background: rgba(6, 7, 8, .85); }

/* imagem ou vídeo da oferta: palco com cantos internos e véu escuro embaixo */
.com-oferta-midia {
  position: relative;
  margin: 8px 8px 0;
  border-radius: 18px;
  overflow: hidden;
  background: #000;
}
.com-oferta-midia img { display: block; width: 100%; aspect-ratio: 2 / 1; object-fit: cover; transition: transform .7s var(--o-curva); }
.com-oferta:hover .com-oferta-midia img { transform: scale(1.04); }
.com-oferta-midia iframe, .com-oferta-midia video { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; }
.com-oferta-img::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 45%;
  background: linear-gradient(180deg, transparent, rgba(13, 15, 18, .85));
  pointer-events: none;
}

.com-oferta-corpo { position: relative; padding: 20px 22px 22px; }
.com-oferta h3 {
  margin: 0 36px 8px 0;
  font-family: var(--o-titulo);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -.02em;
  text-wrap: balance;
  overflow-wrap: break-word;
  color: var(--o-texto);
}
.com-oferta p { margin: 0 0 18px; font-size: 14.5px; line-height: 1.55; color: var(--o-texto-2); text-wrap: pretty; }

/* ações: um botão principal (destaque com brilho) e o recusar como fantasma */
.com-oferta-acoes { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.com-oferta-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: var(--o-destaque);
  color: var(--o-sobre);
  font-family: var(--o-titulo);
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -.01em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 10px 26px -12px var(--o-destaque);
  transition: transform .2s var(--o-curva), box-shadow .2s var(--o-curva), gap .2s var(--o-curva), filter .2s var(--o-curva);
}
.com-oferta-cta svg { width: 16px; height: 16px; flex: none; }
.com-oferta-cta:hover { transform: translateY(-1px); gap: 11px; filter: brightness(1.04); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 16px 34px -12px var(--o-destaque); }
.com-oferta .com-oferta-recusar {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--o-texto-2);
  font-family: var(--o-titulo);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: color .2s var(--o-curva), background .2s var(--o-curva);
}
.com-oferta .com-oferta-recusar:hover { color: var(--o-texto); background: rgba(255, 255, 255, .05); }
.com-oferta-fechar:focus-visible, .com-oferta-recusar:focus-visible, .com-oferta-cta:focus-visible { outline: 2px solid var(--o-destaque); outline-offset: 3px; }

/* ---------- gatilho: celebração da aula concluída, no centro ---------- */
.com-gatilho-fundo {
  position: fixed;
  inset: 0;
  z-index: 149;
  background:
    radial-gradient(55% 45% at 50% 46%, var(--o-d12), transparent 70%),
    rgba(6, 7, 8, .74);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  animation: mpo-fundo .3s ease both;
}
.com-oferta.com-gatilho {
  right: auto;
  bottom: auto;
  left: 50%;
  top: 50%;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  transform: translate(-50%, -50%);
  border-radius: 28px;
  animation: mpo-gatilho-entra .55s var(--o-curva) both;
}
.com-gatilho .com-oferta-corpo { padding: 4px 26px 26px; text-align: left; }
.com-gatilho h3 {
  margin-right: 0;
  font-size: 24px;
  line-height: 1.18;
  background: linear-gradient(100deg, #fff 0%, #fff 42%, color-mix(in srgb, var(--o-destaque) 85%, #fff) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.com-gatilho .com-oferta-acoes { flex-direction: column; align-items: stretch; gap: 6px; }
.com-gatilho .com-oferta-cta { min-height: 50px; font-size: 15.5px; border-radius: 14px; }

/* palco: o espaço do Universo Mestres, com órbitas finas, estrelas e o emblema de vidro */
.mpo-palco {
  position: relative;
  height: 150px;
  margin: 8px 8px 0;
  border-radius: 20px;
  overflow: hidden;
  background:
    radial-gradient(42% 70% at 50% 58%, var(--o-d22), transparent 72%),
    radial-gradient(120% 120% at 50% 120%, #10140c, transparent 60%),
    linear-gradient(180deg, #07090a, #0b0e10);
  border: 1px solid var(--o-linha);
}
.mpo-palco svg.mpo-orbitas { position: absolute; inset: 0; width: 100%; height: 100%; }
.mpo-orbitas ellipse { fill: none; stroke: rgba(255, 255, 255, .09); stroke-width: 1; }
.mpo-orbitas ellipse.mpo-luz { stroke: var(--o-d55); stroke-width: 1.4; stroke-dasharray: 2 9; animation: mpo-orbita 12s linear infinite; }
.mpo-estrela { position: absolute; width: 10px; height: 10px; color: #fff; opacity: .7; animation: mpo-brilho 3.2s ease-in-out infinite; }
.mpo-estrela svg { display: block; width: 100%; height: 100%; }
.mpo-estrela:nth-of-type(1) { left: 16%; top: 22%; animation-delay: -.4s; }
.mpo-estrela:nth-of-type(2) { left: 78%; top: 18%; width: 7px; height: 7px; animation-delay: -1.6s; }
.mpo-estrela:nth-of-type(3) { left: 84%; top: 66%; width: 12px; height: 12px; color: var(--o-destaque); animation-delay: -2.4s; }
.mpo-estrela:nth-of-type(4) { left: 9%; top: 70%; width: 6px; height: 6px; animation-delay: -1s; }
.mpo-emblema {
  position: absolute;
  left: 50%;
  top: 56%;
  width: 104px;
  height: 104px;
  margin: -52px 0 0 -52px;
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, .55)) drop-shadow(0 0 26px var(--o-d55));
  animation: mpo-emblema-entra .7s var(--o-curva) both .08s, mpo-balanco 6s ease-in-out .8s infinite;
}
.mpo-emblema svg { display: block; width: 100%; height: 100%; }

/* selo e progresso */
.mpo-selo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 16px 0 10px;
  padding: 5px 11px 5px 8px;
  border-radius: 999px;
  font-family: var(--o-titulo);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--o-sucesso);
  background: rgba(127, 214, 160, .1);
  border: 1px solid rgba(127, 214, 160, .3);
}
.mpo-selo svg { width: 14px; height: 14px; }
.mpo-progresso { margin: -4px 0 20px; }
.mpo-progresso-t { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; font-family: var(--o-titulo); font-size: 12px; color: var(--o-texto-3); font-variant-numeric: tabular-nums; }
.mpo-progresso-t b { color: var(--o-texto); font-weight: 600; }
.mpo-barra { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.mpo-barra i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--o-destaque) 70%, #fff), var(--o-destaque));
  box-shadow: 0 0 14px -2px var(--o-d55);
  transform-origin: left center;
  animation: mpo-barra .9s var(--o-curva) both .35s;
}

/* prévia no painel: a mesma janela, parada no lugar */
.com-oferta.com-oferta-previa {
  position: relative;
  inset: auto;
  z-index: auto;
  width: 100%;
  max-width: 420px;
  max-height: none;
  transform: none;
  animation: none;
  overflow: visible;
}

@keyframes mpo-entra { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes mpo-fundo { from { opacity: 0; } to { opacity: 1; } }
@keyframes mpo-gatilho-entra { from { opacity: 0; transform: translate(-50%, -44%) scale(.96); } to { opacity: 1; transform: translate(-50%, -50%); } }
@keyframes mpo-emblema-entra { 0% { opacity: 0; transform: scale(.55) rotate(-14deg); } 70% { opacity: 1; transform: scale(1.06) rotate(3deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes mpo-balanco { 0%, 100% { transform: rotate(0) translateY(0); } 25% { transform: rotate(-8deg) translateY(1px); } 75% { transform: rotate(8deg) translateY(-3px); } }
@keyframes mpo-brilho { 0%, 100% { opacity: .25; transform: scale(.7); } 50% { opacity: .95; transform: scale(1); } }
@keyframes mpo-orbita { to { stroke-dashoffset: -440; } }
@keyframes mpo-barra { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* celular: a janela de canto ocupa a largura (acima da barra de abas); a do gatilho sobe por baixo */
@media (max-width: 800px) {
  .com-oferta { left: 16px; right: 16px; width: auto; bottom: calc(84px + env(safe-area-inset-bottom)); max-height: calc(100vh - 120px); }
  .com-oferta.com-oferta-aula { bottom: calc(16px + env(safe-area-inset-bottom)); }
  .com-oferta.com-gatilho { left: 10px; right: 10px; top: auto; bottom: calc(10px + env(safe-area-inset-bottom)); width: auto; transform: none; border-radius: 26px; animation: mpo-entra .45s var(--o-curva) both; }
  .com-gatilho h3 { font-size: 22px; }
  .mpo-palco { height: 128px; }
  .mpo-emblema { width: 92px; height: 92px; margin: -46px 0 0 -46px; }
  .com-oferta.com-oferta-previa { left: auto; right: auto; bottom: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .com-oferta, .com-gatilho-fundo, .com-oferta.com-gatilho, .mpo-emblema, .mpo-estrela, .mpo-orbitas ellipse.mpo-luz, .mpo-barra i { animation: none; }
  .com-oferta-cta, .com-oferta-midia img { transition: none; }
}
