/* ============================================================
   X8 PLAYER — motor de vídeo nativo
   ------------------------------------------------------------
   Estética: preto quente do Mini Bento, âmbar #ff9040 como energia
   (barra de progresso e foco), lilás para o "já assistido".
   Tudo escopado em .x8p — não vaza para o resto do app.

   Regra de layout: o player é `aspect-ratio: 16/9` e os controles
   ficam SOBRE o vídeo (overlay), aparecendo no hover/foco/toque.
   Em tela cheia o aspect-ratio some e ele ocupa tudo.
   ============================================================ */

.x8p {
  --x8p-accent: #ff9040;
  --x8p-seen: #a5b4fc;
  --x8p-bg: #08080a;
  --x8p-ctl: rgba(255, 255, 255, .92);
  --x8p-h: 3px;          /* altura da barra em repouso */
  --x8p-h-hover: 6px;

  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--x8p-bg);
  border-radius: 14px;
  overflow: hidden;
  font-family: var(--via-font, 'Geist', system-ui, sans-serif);
  color: var(--x8p-ctl);
  user-select: none;
  -webkit-user-select: none;
  isolation: isolate;
}
.x8p:fullscreen, .x8p:-webkit-full-screen { aspect-ratio: auto; border-radius: 0; }

.x8p__video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
  /* ⚠ não é proteção real (ver nota em x8-player.js) — só evita o
     "salvar vídeo como" do menu de contexto e o arraste do elemento. */
  -webkit-user-drag: none;
  pointer-events: none;      /* o clique é tratado pela camada de cima */
}

/* ---- camada de clique/gestos: play-pause, duplo-toque p/ pular ---- */
.x8p__palco { position: absolute; inset: 0; cursor: pointer; z-index: 1; }

/* ---- véu que escurece de baixo p/ cima quando os controles aparecem ---- */
.x8p__veu {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background:
    linear-gradient(to top, rgba(0,0,0,.72) 0%, rgba(0,0,0,.28) 22%, transparent 46%),
    /* topo: contraste para o título, sem pesar sobre a imagem */
    linear-gradient(to bottom, rgba(0,0,0,.55) 0%, rgba(0,0,0,.18) 14%, transparent 32%);
  opacity: 0; transition: opacity .18s ease;
}
.x8p.is-ativo .x8p__veu, .x8p.is-pausado .x8p__veu { opacity: 1; }

/* ---- barra de controles ---- */
.x8p__ctrl {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  padding: 0 12px 10px;
  display: flex; flex-direction: column; gap: 6px;
  opacity: 0; transform: translateY(6px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}
.x8p.is-ativo .x8p__ctrl, .x8p.is-pausado .x8p__ctrl { opacity: 1; transform: none; pointer-events: auto; }
.x8p.is-ativo { cursor: default; }
.x8p:not(.is-ativo):not(.is-pausado) { cursor: none; }

/* ---- BARRA DE PROGRESSO estilo iOS (pílula de vidro) ------------------
   Referência do usuário: pílula escura translúcida com o tempo decorrido à
   esquerda, o trilho no meio e o tempo RESTANTE (negativo) à direita.

   O vidro é o nosso liquid glass NATIVO (liquid-glass-parkado): o filtro SVG
   é injetado por JS e entra aqui como `backdrop-filter: url(#...)`. Quando o
   navegador não suporta (Safari/Firefox), a regra abaixo já deixa um
   `blur()` decente — o script só troca por url(#) quando dá. */
.x8p__barra {
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px; height: 38px; border-radius: 999px;
  background: rgba(255, 255, 255, .10);
  -webkit-backdrop-filter: blur(14px) saturate(1.6);
  backdrop-filter: blur(14px) saturate(1.6);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.34),
    inset 0 0 0 1px rgba(255,255,255,.14),
    0 8px 26px -10px rgba(0,0,0,.55);
  /* o filtro de refração precisa de camada própria pra não vazar */
  isolation: isolate;
}
.x8p__t {
  font-family: var(--via-font-mono, ui-monospace, monospace);
  font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums;
  color: rgba(255,255,255,.94); white-space: nowrap; letter-spacing: -.01em;
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
  min-width: 44px;
}
.x8p__t--resta { text-align: right; color: rgba(255,255,255,.62); }

/* ---- linha do tempo ---- */
.x8p__linha {
  position: relative; height: 22px; flex: 1; display: flex; align-items: center;
  cursor: pointer; touch-action: none;
}
.x8p__trilho {
  position: relative; width: 100%; height: 5px;
  background: rgba(255,255,255,.26); border-radius: 999px; overflow: hidden;
  transition: height .14s cubic-bezier(.32,.08,.24,1);
}
.x8p__linha:hover .x8p__trilho, .x8p__linha:focus-visible .x8p__trilho { height: 7px; }
.x8p__buffer  { position: absolute; inset: 0 auto 0 0; background: rgba(255,255,255,.20); width: 0; }
/* faixas do que foi REALMENTE assistido (não é o mesmo que a posição atual) */
.x8p__vistos  { position: absolute; inset: 0; }
.x8p__visto   { position: absolute; top: 0; bottom: 0; background: rgba(255,255,255,.34); }
/* preenchido: branco, como no iOS — o âmbar volta no knob e no foco */
.x8p__tocado  { position: absolute; inset: 0 auto 0 0; background: #fff; width: 0; }
.x8p__bolha {
  position: absolute; top: 50%; left: 0; width: 15px; height: 15px; margin: -7.5px 0 0 -7.5px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,.45), 0 0 0 .5px rgba(0,0,0,.10);
  transform: scale(1); transition: transform .14s cubic-bezier(.32,.08,.24,1);
}
.x8p__linha:hover .x8p__bolha, .x8p.is-arrastando .x8p__bolha { transform: scale(1.2); }
.x8p__linha:focus-visible { outline: none; }
.x8p__linha:focus-visible .x8p__bolha { box-shadow: 0 0 0 3px var(--x8p-accent); }
/* etiqueta de tempo que segue o mouse na linha */
.x8p__dica {
  position: absolute; bottom: 20px; transform: translateX(-50%);
  background: rgba(8,8,10,.92); border: 1px solid rgba(255,255,255,.10);
  padding: 3px 7px; border-radius: 7px; font-size: 11px;
  font-family: var(--via-font-mono, ui-monospace, monospace);
  font-variant-numeric: tabular-nums; white-space: nowrap;
  opacity: 0; transition: opacity .12s ease; pointer-events: none;
}
.x8p__linha:hover .x8p__dica { opacity: 1; }

/* ---- botões ---- */
.x8p__botoes { display: flex; align-items: center; gap: 4px; }
/* ⚠ quadrado FIXO + raio 50% = hover em círculo perfeito.
   Antes era padding + border-radius 9px: como o conteúdo (svg ou texto)
   define a largura, o realce saía retangular e arredondado, não redondo. */
.x8p__b {
  appearance: none; background: none; border: 0; padding: 0;
  width: 36px; height: 36px; flex: 0 0 36px;
  color: var(--x8p-ctl); cursor: pointer; border-radius: 50%; line-height: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s ease, color .12s ease;
}
.x8p__b:hover { background: rgba(255,255,255,.14); }
.x8p__b:focus-visible { outline: 2px solid var(--x8p-accent); outline-offset: 1px; }
.x8p__b svg { width: 19px; height: 19px; fill: currentColor; }
.x8p__b--play svg { width: 23px; height: 23px; }

.x8p__tempo {
  font-family: var(--via-font-mono, ui-monospace, monospace);
  font-size: 12px; font-variant-numeric: tabular-nums;
  opacity: .92; margin-left: 4px; white-space: nowrap;
}
.x8p__espaco { flex: 1; }

/* volume: cresce no hover, some no mobile */
/* ---- VOLUME: mesma linguagem da barra de progresso ----------------
   Branco sobre branco translúcido, SEM bolinha. Cresce no hover. */
.x8p__vol { display: flex; align-items: center; }
.x8p__vlinha {
  width: 0; opacity: 0; margin-left: 0; overflow: hidden;
  height: 22px; display: flex; align-items: center;
  cursor: pointer; touch-action: none;
  transition: width .18s cubic-bezier(.32,.08,.24,1), opacity .16s ease, margin-left .18s ease;
}
.x8p__vol:hover .x8p__vlinha,
.x8p__vol:focus-within .x8p__vlinha { width: 78px; opacity: 1; margin-left: 8px; }
.x8p__vtrilho {
  position: relative; width: 100%; height: 5px;
  background: rgba(255,255,255,.26); border-radius: 999px; overflow: hidden;
  transition: height .14s cubic-bezier(.32,.08,.24,1);
}
.x8p__vlinha:hover .x8p__vtrilho, .x8p__vlinha:focus-visible .x8p__vtrilho { height: 7px; }
.x8p__vcheio {
  position: absolute; inset: 0 auto 0 0; width: 100%;
  background: #fff; border-radius: 999px;
}
.x8p__vlinha:focus-visible { outline: 2px solid var(--x8p-accent); outline-offset: 3px; border-radius: 999px; }

/* ---- menus (velocidade / qualidade) ---- */
.x8p__menu { position: relative; }
/* os dois botões de texto (1x / Auto) não cabem num círculo: viram pílula */
.x8p__menu-b {
  font-family: var(--via-font-mono, ui-monospace, monospace);
  font-size: 12px; font-weight: 500;
  width: auto; height: 32px; flex: 0 0 auto;
  padding: 0 12px; min-width: 46px; border-radius: 999px;
}
.x8p__lista {
  position: absolute; bottom: calc(100% + 8px); right: 0; z-index: 5;
  background: rgba(16,16,19,.97); border: 1px solid rgba(255,255,255,.10);
  border-radius: 12px; padding: 5px; min-width: 116px;
  box-shadow: 0 10px 34px rgba(0,0,0,.5);
  display: none; flex-direction: column; gap: 1px;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.x8p__menu.is-aberto .x8p__lista { display: flex; }
.x8p__opt {
  appearance: none; background: none; border: 0; color: rgba(255,255,255,.86);
  font: inherit; font-size: 12.5px; text-align: left; padding: 7px 10px;
  border-radius: 8px; cursor: pointer; white-space: nowrap;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.x8p__opt:hover { background: rgba(255,255,255,.09); }
.x8p__opt[aria-checked="true"] { color: var(--x8p-accent); font-weight: 500; }
.x8p__opt[aria-checked="true"]::after { content: "✓"; font-size: 11px; }

/* ---- retomar de onde parou ---- */
.x8p__retomar {
  position: absolute; left: 14px; bottom: 62px; z-index: 4;
  display: flex; align-items: center; gap: 10px;
  background: rgba(16,16,19,.94); border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px; padding: 9px 12px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.x8p__retomar button {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-size: 12.5px;
  padding: 6px 11px; border-radius: 999px; font-weight: 500;
}
.x8p__retomar .x8p__sim { background: var(--x8p-accent); color: #1a1004; }
.x8p__retomar .x8p__nao { background: rgba(255,255,255,.12); color: rgba(255,255,255,.86); }

/* ---- estados ---- */
.x8p__giro {
  position: absolute; inset: 0; z-index: 4; display: none;
  align-items: center; justify-content: center; pointer-events: none;
}
.x8p.is-carregando .x8p__giro { display: flex; }
.x8p__giro i {
  width: 38px; height: 38px; border-radius: 50%; display: block;
  border: 2.5px solid rgba(255,255,255,.20); border-top-color: var(--x8p-accent);
  animation: x8p-giro .8s linear infinite;
}
@keyframes x8p-giro { to { transform: rotate(360deg) } }

/* play gigante quando pausado no início */
.x8p__grande {
  position: absolute; inset: 0; z-index: 4; display: none;
  align-items: center; justify-content: center; pointer-events: none;
}
.x8p.is-inicio .x8p__grande { display: flex; }
.x8p__grande span {
  width: 68px; height: 68px; border-radius: 50%;
  background: rgba(8,8,10,.62); border: 1px solid rgba(255,255,255,.16);
  display: flex; align-items: center; justify-content: center;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.x8p__grande svg { width: 26px; height: 26px; fill: #fff; margin-left: 3px; }

.x8p__erro {
  position: absolute; inset: 0; z-index: 6; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; padding: 24px; background: rgba(8,8,10,.94);
}
.x8p.is-erro .x8p__erro { display: flex; }
.x8p__erro p { margin: 0; font-size: 14px; color: rgba(255,255,255,.90); }
.x8p__erro small { color: rgba(255,255,255,.55); font-size: 12px; }
.x8p__erro button {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-size: 12.5px;
  padding: 7px 14px; border-radius: 999px; background: var(--x8p-accent); color: #1a1004;
  font-weight: 500; margin-top: 2px;
}

/* aviso central efêmero (velocidade, pulo, mudo) */
.x8p__toast {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%) scale(.94);
  z-index: 5; background: rgba(8,8,10,.82); border: 1px solid rgba(255,255,255,.12);
  padding: 9px 15px; border-radius: 12px; font-size: 13.5px; font-weight: 500;
  opacity: 0; transition: opacity .16s ease, transform .16s ease; pointer-events: none;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.x8p__toast.is-vis { opacity: 1; transform: translate(-50%,-50%) scale(1); }

/* ---- mobile ---- */
@media (max-width: 640px) {
  .x8p { border-radius: 10px; }
  .x8p__vol { display: none; }               /* volume é do aparelho */
  .x8p__ctrl { padding: 0 8px 8px; }
  .x8p__b { padding: 8px; }
  .x8p__tempo { font-size: 11px; }
  .x8p__retomar { left: 8px; right: 8px; bottom: 56px; font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .x8p__ctrl, .x8p__veu, .x8p__toast, .x8p__bolha, .x8p__trilho { transition: none; }
  .x8p__giro i { animation-duration: 2s; }
}

/* ---- camada do vidro WebGL (liquid-glass-studio) --------------------
   Fica ACIMA do <video> e ABAIXO dos controles. Pinta só a pílula
   (u_soPilula) — o resto sai transparente e o vídeo real aparece. */
.x8p__vidro {
  position: absolute; inset: 0; z-index: 2;
  width: 100%; height: 100%;
  pointer-events: none;
  transition: opacity .18s ease;
}
/* com o vidro WebGL ativo, a pílula não usa mais backdrop-filter:
   quem desenha o vidro é o canvas atrás dela. */
.x8p__barra--wgl {
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}

/* ============================================================
   PLAY CENTRAL COM VIDRO
   ------------------------------------------------------------
   ⚠ TAMANHO NÃO É DECORAÇÃO AQUI. O preset foi calibrado numa forma
   de 140x102 com refThickness 38.85 — ou seja, a banda refrativa tem
   ~39px. Num círculo de 76px o raio é 38, então a banda engolia a
   forma inteira: sem miolo limpo, aquele aspecto "pesado". Com 104px
   o raio é 52 e sobram ~13px de centro nítido, que é a proporção em
   que o preset foi feito.
   ============================================================ */
.x8p__grande { z-index: 4; }
.x8p.is-pausado .x8p__grande, .x8p.is-inicio .x8p__grande { display: flex; }
.x8p__grande-b {
  appearance: none; border: 0; cursor: pointer; pointer-events: auto;
  width: 104px; height: 104px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.10);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  backdrop-filter: blur(16px) saturate(1.6);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.30),
    inset 0 0 0 1px rgba(255,255,255,.12),
    0 12px 34px -12px rgba(0,0,0,.55);
  transition: transform .16s cubic-bezier(.32,.08,.24,1);
}
.x8p__grande-b:hover { transform: scale(1.05); }
.x8p__grande-b svg { width: 34px; height: 34px; fill: #fff; margin-left: 5px;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.4)); }
/* com o vidro WebGL quem pinta é o canvas atrás */
.x8p--wgl .x8p__grande-b {
  background: transparent;
  -webkit-backdrop-filter: none; backdrop-filter: none;
  box-shadow: none;
}

/* ---- menus: vidro por backdrop-filter (não pelo shader) -----------
   Aqui o blur nativo é melhor que o shader: ele age no backdrop REAL,
   então borra também a BARRA DE PROGRESSO que fica atrás — que era
   justamente o que faltava. O shader só conhece a textura do vídeo. */
.x8p__lista {
  background: rgba(16,16,19,.55);
  border: 1px solid rgba(255,255,255,.14);
  -webkit-backdrop-filter: blur(28px) saturate(1.7) brightness(.92);
  backdrop-filter: blur(28px) saturate(1.7) brightness(.92);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.16),
    0 16px 44px -14px rgba(0,0,0,.7);
}
/* mesmo em modo WebGL o menu segue no blur nativo */
.x8p--wgl .x8p__lista {
  background: rgba(16,16,19,.55);
  -webkit-backdrop-filter: blur(28px) saturate(1.7) brightness(.92);
  backdrop-filter: blur(28px) saturate(1.7) brightness(.92);
}

/* ============================================================
   CABEÇALHO — curso + aula no alto à esquerda (estilo Netflix)
   Curso pequeno em cima, aula maior embaixo. Entra e sai junto
   com os controles, para não tampar o vídeo o tempo todo.
   ============================================================ */
.x8p__cabec {
  position: absolute; top: 0; left: 0; z-index: 3;
  padding: 18px 22px; max-width: 72%;
  pointer-events: none;
  opacity: 0; transform: translateY(-6px);
  transition: opacity .18s ease, transform .18s ease;
}
.x8p.is-ativo .x8p__cabec.is-vis,
.x8p.is-pausado .x8p__cabec.is-vis,
.x8p.is-inicio .x8p__cabec.is-vis { opacity: 1; transform: none; }

.x8p__curso {
  display: none;
  font-family: var(--via-font, 'Geist', system-ui, sans-serif);
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
  color: rgba(255,255,255,.78);
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
  margin-bottom: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.x8p__aula {
  display: none;
  font-family: var(--via-font, 'Geist', system-ui, sans-serif);
  font-size: 27px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,.55);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

@media (max-width: 640px) {
  .x8p__cabec { padding: 12px 14px; max-width: 84%; }
  .x8p__curso { font-size: 10.5px; }
  .x8p__aula { font-size: 18px; }
}
