/* ============================================================================
   J.A.R.V.I.S. · Player, ficheiros e acessibilidade
   ----------------------------------------------------------------------------
   A janela flutuante de vídeo, a zona de largar ficheiros e os ajustes de
   acessibilidade (movimento reduzido, alvos de toque).
   ========================================================================== */

/* ===== Player MÓVEL (janela flutuante para qualquer media) ===== */
.player {
  position: fixed;
  z-index: 95;  /* SEMPRE por cima: transmissão (F1) não fica engolida pela app de música (82) */
  top: 72px; right: 16px;
  width: min(520px, 92vw);
  /* Altura RELATIVA ao ecrã, não fixa: quando a janela do quiosque encolhe (vista
     de janelas do sway, mosaico com o mpv), 320px fixos passavam a "quase todo o
     ecrã" e parecia a app desformatada (queixa de 29 jul 2026). */
  height: min(320px, 60vh);
  min-width: 260px; min-height: 180px;
  max-width: 96vw; max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--glass-strong);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--edge-strong);
  border-radius: 16px;
  box-shadow:
    0 18px 60px rgba(0, 0, 0, 0.65),
    0 0 28px rgba(63, 220, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
  animation: fadeIn 0.18s ease-out;
}
.player.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: linear-gradient(180deg, rgba(63, 220, 255, 0.10), rgba(63, 220, 255, 0.03));
  border-bottom: 1px solid rgba(126, 222, 255, 0.12);
  cursor: move;            /* arrastar a janela pela barra */
  touch-action: none;
  user-select: none;
  flex-shrink: 0;
}
.player-title {
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-actions { display: flex; gap: 6px; flex-shrink: 0; }
.player-actions .round-btn { width: 32px; height: 32px; font-size: 14px; }
.player-frame {
  flex: 1;
  background: #000;
  overflow: hidden;
}
.player-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
/* O player nativo (ficheiros de vídeo diretos) ocupa a moldura tal como o iframe. */
.player-frame { position: relative; }
.player-frame video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
}
.player-frame [hidden] { display: none !important; }
/* Aviso honesto por cima do vídeo: "a carregar", "encalhou", "a tentar outra fonte". */
.player-aviso {
  position: absolute;
  inset: auto 10px 10px 10px;
  z-index: 3;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(4, 8, 15, 0.82);
  border: 1px solid rgba(63, 220, 255, 0.28);
  color: #cfe6f5;
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
  pointer-events: none;
}
/* Puxador de resize próprio (por cima do iframe, senão o iframe come o rato) */
.player-resize {
  position: absolute;
  right: 0; bottom: 0;
  width: 22px; height: 22px;
  cursor: nwse-resize;
  z-index: 2;
  background:
    linear-gradient(135deg, transparent 0 50%, var(--cyan-dim) 50% 60%, transparent 60% 70%, var(--cyan-dim) 70% 80%, transparent 80%);
  touch-action: none;
}

/* ===== Zona de largar ficheiros ===== */
.dropzone {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 7, 16, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 2px dashed rgba(63, 220, 255, 0.55);
  box-shadow: inset 0 0 80px rgba(63, 220, 255, 0.18);
  pointer-events: none;
}
.dropzone.hidden { display: none; }
.dropzone span {
  color: var(--cyan);
  font-size: 18px;
  letter-spacing: 1px;
  padding: 20px 28px;
  border: 1px solid var(--edge-strong);
  border-radius: 16px;
  background: var(--glass-strong);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

/* ===== Acessibilidade e afinações ===== */
:focus-visible {
  outline: 2px solid rgba(63, 220, 255, 0.6);
  outline-offset: 2px;
}
/* ---------- Fotos e vídeos no chat (show_images / show_videos) ---------- */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 6px;
  margin: 8px 0 2px;
  width: 100%;
}
.media-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--edge);
  cursor: pointer;
  background: var(--bg-2);
}
.media-grid img:active { outline: 2px solid var(--cyan-glow); }
/* Imagem que não carregou mesmo pelo proxy: fica um quadrado discreto em vez do
   ícone de imagem partida — a grelha mantém-se inteira. */
.media-grid img.img-dead { background: var(--bg-2); border-style: dashed; color: transparent; }
.media-grid.videos { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.video-card {
  cursor: pointer;
  border: 1px solid var(--edge);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-2);
}
.video-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 0;
  border-radius: 0;
  display: block;
}
.video-card .video-cap {
  font-size: 11px;
  color: var(--text-dim);
  padding: 5px 7px;
  line-height: 1.3;
  max-height: 3.9em;
  overflow: hidden;
}
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(3, 7, 16, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
#lightbox.hidden { display: none; }
#lightbox img {
  max-width: 96vw;
  max-height: 92vh;
  border-radius: 10px;
  border: 1px solid var(--edge-strong);
  box-shadow: 0 0 40px rgba(63, 220, 255, 0.25);
}

@media (prefers-reduced-motion: reduce) {
  /* a esfera de partículas trata do reduced-motion no js/reactor.js */
  .boot-reactor::before, .boot-reactor, .status::before { animation: none !important; }
  .boot-name, .hud-top::after, .mic-btn::before { animation: none !important; }
  .flank-bars i, .flank-wave i, .flank-row .fl-line::before,
  .flank-dial::before, .flank-dial::after, .flank-dial i { animation: none !important; }
  .msg { animation: none; }
}
@media (max-height: 640px) {
  .hint { margin-top: 8px; }
  .hud-bottom { margin-bottom: calc(8px + var(--safe-bottom)); padding: calc(7px * var(--dock-scale)) calc(16px * var(--dock-scale)); gap: calc(16px * var(--dock-scale)); }
}
@media (max-width: 380px) {
  .hud-bottom { gap: calc(14px * var(--dock-scale)); padding: calc(8px * var(--dock-scale)) calc(14px * var(--dock-scale)); }
  .msg { max-width: 92%; }
}
