/* PobreFlix 10.13 - mobile Player 2 / SuperFlix.
   Carregado depois da correção 10.12. A tela de idioma/fonte do iframe
   precisa de altura, diferente de um vídeo comum em 16:9.
   Não modifica a página remota (iframe cross-origin), player 1 ou APIs.
*/
@media (max-width: 900px) {
  /* Não permita que o iframe fique com 220px de altura e corte as opções. */
  html body #player.nix-open.pf-superflix-mode > .box > .content {
    aspect-ratio: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: hidden !important;
    border-radius: 14px !important;
    background: #050506 !important;
  }

  html body #player.nix-open.pf-superflix-mode .vizer-embed-shell {
    position: relative !important;
    inset: auto !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    aspect-ratio: auto !important;
    overflow: hidden !important;
    border-radius: 14px !important;
    isolation: isolate;
  }

  /* A barra fica FORA da tela interna do SuperFlix: nada cobre o título. */
  html body #player.nix-open.pf-superflix-mode .vizer-embed-topbar {
    position: relative !important;
    inset: auto !important;
    z-index: 10 !important;
    order: 0 !important;
    display: grid !important;
    grid-template-columns: 40px minmax(0, 1fr) 82px !important;
    align-items: center !important;
    gap: 6px !important;
    flex: 0 0 56px !important;
    width: 100% !important;
    height: 56px !important;
    min-height: 56px !important;
    padding: 7px 10px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    background: #101116 !important;
    border-bottom: 1px solid rgba(255,255,255,.11) !important;
    overflow: hidden !important;
  }
  html body #player.nix-open.pf-superflix-mode .vizer-embed-topbar > .vizer-loading-close {
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
    justify-self: start !important;
    position: relative !important;
  }
  html body #player.nix-open.pf-superflix-mode .vizer-embed-meta {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }
  html body #player.nix-open.pf-superflix-mode .vizer-embed-meta .vizer-brand-image {
    width: min(112px, 100%) !important;
    max-width: 100% !important;
    height: 28px !important;
  }
  html body #player.nix-open.pf-superflix-mode .vizer-embed-actions {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    flex-wrap: nowrap !important;
    gap: 5px !important;
    min-width: 0 !important;
    pointer-events: auto !important;
  }
  html body #player.nix-open.pf-superflix-mode .vizer-embed-actions .vizer-icon-btn {
    flex: 0 0 36px !important;
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
  }

  /* A área de seleção da fonte tem espaço para opções de áudio/idioma.
     A rolagem do iframe continua sendo controlada pela página de origem. */
  html body #player.nix-open.pf-superflix-mode .vizer-embed-frame {
    position: relative !important;
    inset: auto !important;
    order: 1 !important;
    display: block !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: clamp(390px, 59dvh, 640px) !important;
    max-height: none !important;
    min-height: 390px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: #08080b !important;
    box-sizing: border-box !important;
  }
  html body #player.nix-open.pf-superflix-mode .vizer-embed-footer {
    display: none !important;
  }
  html body #player.nix-open.pf-superflix-mode .vizer-embed-loading {
    inset: 56px 0 0 !important;
    min-height: 0 !important;
    z-index: 5 !important;
  }
  html body #player.nix-open.pf-superflix-mode .pf-mega-sources {
    padding-top: 12px !important;
    padding-bottom: 12px !important;
  }

  /* Modo expandido reserva 100% do viewport no iPhone mesmo sem Fullscreen API. */
  html body #player.nix-open.pf-superflix-mode .vizer-embed-shell.pf-embed-fullview {
    position: fixed !important;
    z-index: 2147483647 !important;
    inset: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    background: #000 !important;
  }
  html body #player.nix-open.pf-superflix-mode .vizer-embed-shell.pf-embed-fullview .vizer-embed-frame {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
  }
  html body #player.nix-open.pf-superflix-mode .vizer-embed-shell.pf-embed-fullview .vizer-embed-loading {
    inset: 56px 0 0 !important;
  }
}

@media (max-width: 350px) and (orientation: portrait) {
  html body #player.nix-open.pf-superflix-mode .vizer-embed-actions .vizer-embed-cast { display: none !important; }
  html body #player.nix-open.pf-superflix-mode .vizer-embed-topbar {
    grid-template-columns: 40px minmax(0, 1fr) 40px !important;
  }
}

/* Nas telas em paisagem, a altura extra da seleção não deve encolher o iframe. */
@media (max-width: 900px) and (orientation: landscape) {
  html body #player.nix-open.pf-superflix-mode > .box {
    width: min(100%, 760px) !important;
    max-width: 760px !important;
  }
  html body #player.nix-open.pf-superflix-mode .vizer-embed-frame {
    height: max(290px, 62dvh) !important;
    min-height: 290px !important;
  }
}

/* Quando fullscreen nativo está ativo, não restringir às proporções do modal. */
@media (max-width: 900px) {
  html body #player.nix-open.pf-superflix-mode .vizer-embed-shell:fullscreen,
  html body #player.nix-open.pf-superflix-mode .vizer-embed-shell:-webkit-full-screen {
    position: fixed !important;
    inset: 0 !important;
    display: flex !important;
    width: 100vw !important;
    max-width: none !important;
    height: 100dvh !important;
    max-height: none !important;
    border-radius: 0 !important;
  }
  html body #player.nix-open.pf-superflix-mode .vizer-embed-shell:fullscreen .vizer-embed-frame,
  html body #player.nix-open.pf-superflix-mode .vizer-embed-shell:-webkit-full-screen .vizer-embed-frame {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
  }
}
