/* ================================================================
   DBO UI MOTION
   Abertura/fechamento suave para todas as janelas e modais principais.
   ================================================================ */

:root {
  --ui-open-time: 360ms;
  --ui-close-time: 240ms;
  --ui-open-ease: cubic-bezier(.16,.88,.22,1);
  --ui-close-ease: cubic-bezier(.5,0,.72,.18);
}

/* HUD central: preserva o translate usado para centralizar a janela. */
#hud-win.ui-opening {
  animation: dboHudWindowIn var(--ui-open-time) var(--ui-open-ease) both;
  transform-origin: 50% 55%;
}
#hud-win.ui-closing {
  animation: dboHudWindowOut var(--ui-close-time) var(--ui-close-ease) both;
  pointer-events: none !important;
}
@keyframes dboHudWindowIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -44%) scale(.88);
    filter: blur(6px) brightness(.62) saturate(.72);
    box-shadow: 0 8px 18px rgba(0,0,0,.28);
  }
  52% {
    opacity: 1;
    transform: translate(-50%, -53.5%) scale(1.025);
    filter: blur(0) brightness(1.12) saturate(1.08);
    box-shadow:
      0 30px 90px rgba(0,0,0,.72),
      0 0 34px rgba(69,157,255,.30),
      0 0 16px rgba(244,190,73,.18);
  }
  76% {
    transform: translate(-50%, -51.5%) scale(.995);
    filter: brightness(1.03);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -52%) scale(1);
    filter: none;
    box-shadow: inherit;
  }
}
@keyframes dboHudWindowOut {
  from {
    opacity: 1;
    transform: translate(-50%, -52%) scale(1);
    filter: none;
  }
  35% {
    opacity: .92;
    transform: translate(-50%, -53%) scale(1.008);
    filter: brightness(1.06);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -45%) scale(.88);
    filter: blur(5px) brightness(.58) saturate(.65);
  }
}

/* Conteúdo interno entra alguns milissegundos depois da moldura. */
#hud-win.ui-opening > header {
  animation: dboHeaderIn 280ms 70ms var(--ui-open-ease) both;
}
#hud-win.ui-opening > .wbody {
  animation: dboBodyIn 310ms 95ms var(--ui-open-ease) both;
}
@keyframes dboHeaderIn {
  from { opacity: 0; transform: translateY(-16px); filter: blur(3px); }
  to { opacity: 1; transform: none; filter: none; }
}
@keyframes dboBodyIn {
  from { opacity: 0; transform: translateY(18px) scale(.985); filter: blur(3px); }
  to { opacity: 1; transform: none; filter: none; }
}

/* Overlay de confirmação do HUD. */
#hud-confirm.ui-opening {
  animation: dboOverlayIn var(--ui-open-time) var(--ui-open-ease) both;
}
#hud-confirm.ui-opening > * {
  animation: dboModalCardIn var(--ui-open-time) var(--ui-open-ease) both;
}
#hud-confirm.ui-closing {
  animation: dboOverlayOut var(--ui-close-time) linear both;
  pointer-events: none !important;
}
#hud-confirm.ui-closing > * {
  animation: dboModalCardOut var(--ui-close-time) var(--ui-close-ease) both;
}

/* Admin */
#admin.ui-opening {
  animation: dboOverlayIn var(--ui-open-time) var(--ui-open-ease) both;
}
#admin.ui-opening .adm-box {
  animation: dboModalCardIn var(--ui-open-time) var(--ui-open-ease) both;
}
#admin.ui-closing {
  animation: dboOverlayOut var(--ui-close-time) linear both;
  pointer-events: none !important;
}
#admin.ui-closing .adm-box {
  animation: dboModalCardOut var(--ui-close-time) var(--ui-close-ease) both;
}

/* Roleplay */
#rp.ui-opening {
  animation: dboOverlayIn var(--ui-open-time) var(--ui-open-ease) both;
}
#rp.ui-opening .rp-box {
  animation: dboModalCardIn var(--ui-open-time) var(--ui-open-ease) both;
}
#rp.ui-closing {
  animation: dboOverlayOut var(--ui-close-time) linear both;
  pointer-events: none !important;
}
#rp.ui-closing .rp-box {
  animation: dboModalCardOut var(--ui-close-time) var(--ui-close-ease) both;
}

/* Jornada / Expedição */
.content-panel.ui-opening {
  animation: dboOverlayIn var(--ui-open-time) var(--ui-open-ease) both;
}
.content-panel.ui-opening .content-shell {
  animation: dboContentShellIn 390ms var(--ui-open-ease) both;
}
.content-panel.ui-closing {
  animation: dboOverlayOut var(--ui-close-time) linear both;
  pointer-events: none !important;
}
.content-panel.ui-closing .content-shell {
  animation: dboModalCardOut var(--ui-close-time) var(--ui-close-ease) both;
}
@keyframes dboContentShellIn {
  0% { opacity: 0; transform: translateY(42px) scale(.90); filter: blur(6px) brightness(.65); }
  55% { opacity: 1; transform: translateY(-9px) scale(1.022); filter: blur(0) brightness(1.10); }
  78% { transform: translateY(3px) scale(.996); }
  100% { opacity: 1; transform: none; filter: none; }
}

/* Diálogos do servidor: alertas, escolha, input etc. */
#dialog.ui-opening {
  animation: dboOverlayIn 180ms ease-out both;
}
#dialog.ui-opening > .dialog {
  animation: dboModalCardIn 205ms var(--ui-open-ease) both;
}
#dialog.ui-closing {
  animation: dboOverlayOut 145ms linear both;
  pointer-events: none !important;
}
#dialog.ui-closing > .dialog {
  animation: dboModalCardOut 145ms var(--ui-close-ease) both;
}

/* Base das animações de overlay/card. */
@keyframes dboOverlayIn {
  from { opacity: 0; backdrop-filter: blur(0); }
  to { opacity: 1; }
}
@keyframes dboOverlayOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes dboModalCardIn {
  0% {
    opacity: 0;
    transform: translateY(34px) scale(.90);
    filter: blur(6px) brightness(.62) saturate(.72);
  }
  54% {
    opacity: 1;
    transform: translateY(-8px) scale(1.025);
    filter: blur(0) brightness(1.10) saturate(1.08);
  }
  78% {
    transform: translateY(3px) scale(.995);
    filter: brightness(1.03);
  }
  100% {
    opacity: 1;
    transform: none;
    filter: none;
  }
}
@keyframes dboModalCardOut {
  from {
    opacity: 1;
    transform: none;
    filter: none;
  }
  30% {
    transform: translateY(-4px) scale(1.01);
    filter: brightness(1.05);
  }
  to {
    opacity: 0;
    transform: translateY(28px) scale(.90);
    filter: blur(5px) brightness(.58) saturate(.68);
  }
}

/* Pequeno feedback ao trocar abas dentro das janelas, sem reabrir tudo. */
#hud-win .wtabs button,
#admin header nav button,
#rp header nav button,
.content-tabs button {
  transition:
    transform 120ms ease,
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    filter 140ms ease !important;
}
#hud-win .wtabs button:active,
#admin header nav button:active,
#rp header nav button:active,
.content-tabs button:active {
  transform: scale(.97);
}

/* Acessibilidade e também segurança em máquinas mais fracas. */
@media (prefers-reduced-motion: reduce) {
  #hud-win.ui-opening,
  #hud-win.ui-closing,
  #hud-win.ui-opening > header,
  #hud-win.ui-opening > .wbody,
  #hud-confirm.ui-opening,
  #hud-confirm.ui-closing,
  #hud-confirm.ui-opening > *,
  #hud-confirm.ui-closing > *,
  #admin.ui-opening,
  #admin.ui-closing,
  #admin.ui-opening .adm-box,
  #admin.ui-closing .adm-box,
  #rp.ui-opening,
  #rp.ui-closing,
  #rp.ui-opening .rp-box,
  #rp.ui-closing .rp-box,
  .content-panel.ui-opening,
  .content-panel.ui-closing,
  .content-panel.ui-opening .content-shell,
  .content-panel.ui-closing .content-shell,
  #dialog.ui-opening,
  #dialog.ui-closing,
  #dialog.ui-opening > .dialog,
  #dialog.ui-closing > .dialog {
    animation: none !important;
    transition: none !important;
    filter: none !important;
  }
}
