/* =========================================
   VARIÁVEIS DE TEMA (CLARO / ESCURO)
========================================= */
:root {
  --bg-color: #ffffff;
  --text-color: #000000;
  --card-border: #cccccc;
}

.dark {
  --bg-color: #121212;
  --text-color: #ffffff;
  --card-border: #333333;
}

/* =========================================
   ESTILOS GERAIS
========================================= */
body {
  margin: 0;
  font-family: Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background 0.3s, color 0.3s;
}

/* =========================================
   CABEÇALHO E NAVEGAÇÃO
========================================= */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #ff0000;
  color: white;
  padding: 10px 1rem;
  text-align: center;
  z-index: 100; /* abaixo do modal */
  transition: transform 0.3s ease-in-out;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

header h1 {
  margin: 5px 0;
  font-size: 24px;
}

header.hidden {
  transform: translateY(-100%);
}

nav .nav-link {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 16px;
  margin: 0 10px;
  color: white;
  text-decoration: underline;
  cursor: pointer;
  padding: 5px;
}

nav .nav-link:hover {
  color: #f0f0f0;
}

/* =========================================
   LAYOUT PRINCIPAL
========================================= */
.container {
  max-width: 1000px;
  margin: 180px auto 20px;
  padding: 0 1rem;
  text-align: center;
}

.search-bar {
  display: flex;
  justify-content: center;
  margin-top: 15px;
}

input[type="text"] {
  padding: 0.5rem;
  font-size: 16px;
  max-width: 500px;
  width: 100%;
  border: 1px solid var(--card-border);
  border-radius: 4px;
}

button {
  padding: 0.5rem 1rem;
  font-size: 16px;
  cursor: pointer;
  max-width: 250px;
  background-color: #ff0000;
  color: white;
  border: none;
  border-radius: 4px;
  transition: background-color 0.2s, transform 0.2s;
}

button:hover {
  background-color: #cc0000;
}

/* =========================================
   GRID DE VÍDEOS E CARDS
========================================= */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  justify-items: center;
}

.video-card {
  background: var(--bg-color);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  width: 100%;
}

.video-card:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.video-card img {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.video-info {
  padding: 10px;
  text-align: left;
}

.video-info h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}

.meta {
  font-size: 14px;
  color: gray;
  margin-top: 5px;
}

/* =========================================
   RODAPÉ E MODAL (PLAYER)
========================================= */
.footer {
  text-align: center;
  padding: 20px;
  font-size: 14px;
  color: gray;
}

#videoPlayerWrapper {
  display: none;
  position: fixed;
  inset: 0; /* cobre toda a tela */
  background-color: rgba(0, 0, 0, 0.95);
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999; /* sempre acima do header */
}

#videoPlayerWrapper iframe {
  width: 90%;
  max-width: 900px;
  aspect-ratio: 16 / 9;
  height: auto;
  border: none;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

#videoPlayerWrapper .close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 45px;
  color: white;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.2s;
  z-index: 10000; /* acima do modal */
}

#videoPlayerWrapper .close-btn:hover {
  color: #ff0000;
}

/* Ajuste do botão de fechar para Celulares */
@media (max-width: 600px) {
  #videoPlayerWrapper .close-btn {
    top: 10px;
    right: 15px;
    font-size: 50px;
    background-color: rgba(0,0,0,0.5);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    line-height: 60px;
  }
}

/* =========================================
   ACESSIBILIDADE: TECLADO E GAMEPAD
========================================= */

.video-card:focus {
  outline: 4px solid #ff0000;
  outline-offset: 4px;
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

button[onclick="loadMore()"]:focus {
  outline: 4px solid #ffffff;
  outline-offset: 4px;
  transform: scale(1.05);
  background-color: #cc0000;
}

header input:focus,
header .nav-link:focus {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
  transform: scale(1.05);
  border-radius: 4px;
}

.video-card:focus:not(:focus-visible),
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
.nav-link:focus:not(:focus-visible),
.tecla-vk:focus:not(:focus-visible) {
  outline: none;
  transform: scale(1);
}

/* =========================================
   TECLADO VIRTUAL (GAMEPAD)
========================================= */
#virtualKeyboard {
  z-index: 3000 !important;
}

.tecla-vk {
  padding: 15px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  background: #333333;
  color: white;
  border: 2px solid #555555;
  border-radius: 6px;
  transition: all 0.2s;
}

.tecla-vk:focus {
  outline: 4px solid #ff0000;
  outline-offset: 2px;
  background: #ff0000;
  transform: scale(1.1);
  box-shadow: 0 5px 15px rgba(255,0,0,0.4);
}

@keyframes blink {
  0% { opacity: 1; }
  50% { opacity: 0; }
  100% { opacity: 1; }
}