/* PilhA+ Game — Eventos adversos (alerta, contexto, impacto, decisão, consequência).
   Mesma estrutura visual para os 19 eventos: azul-marinho e ciano na interface,
   amarelo = atenção, vermelho = urgência (só quando o evento é crítico). */

.pm-ev {
  --ac: #ffd166;
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 10, 24, 0.74);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: pm-in 0.35s ease both;
}
.pm-ev--warn { --ac: #ffd166; }
.pm-ev--crit { --ac: #ef476f; }
.pm-ev.is-result { --ac: #4ade80; }
.pm-ev--cat { --ac: #6094f0; }

.pm-ev__card {
  width: min(560px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 18px 18px 16px;
  border: 2px solid var(--ac);
  border-radius: 20px;
  background: linear-gradient(180deg, #11295a, #0a1c3f);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ac) 16%, transparent), 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 44px color-mix(in srgb, var(--ac) 28%, transparent);
  animation: pm-ev-in 0.45s cubic-bezier(0.2, 1, 0.3, 1) both;
}
.pm-ev__card:focus { outline: none; }
.pm-ev__card:focus-visible { outline: 3px solid var(--pm-focus); outline-offset: 3px; }
@keyframes pm-ev-in { from { opacity: 0; transform: translateY(24px) scale(0.97); } to { opacity: 1; transform: none; } }

/* alerta: ícone + nome */
.pm-ev__hd { display: flex; align-items: center; gap: 14px; }
.pm-ev--cat .pm-ev__hd { align-items: flex-start; justify-content: space-between; }
.pm-ev__ico {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 2px solid var(--ac);
  border-radius: 50%;
  color: var(--ac);
  background: color-mix(in srgb, var(--ac) 14%, #0a1c3f);
}
.pm-ev__ico svg { width: 32px; height: 32px; animation-duration: 0.9s; animation-iteration-count: 2; animation-timing-function: ease-in-out; }
.pm-ev__ring { position: absolute; inset: -2px; border: 2px solid var(--ac); border-radius: 50%; opacity: 0; animation: pm-ev-ring 1.2s ease-out 2; }
@keyframes pm-ev-ring { 0% { opacity: 0.9; transform: scale(0.9); } 100% { opacity: 0; transform: scale(1.75); } }
.pm-an-blink svg { animation-name: pm-an-blink; animation-timing-function: steps(2, jump-none); }
.pm-an-shake svg { animation-name: pm-an-shake; }
.pm-an-pulse svg { animation-name: pm-an-pulse; }
.pm-an-slide svg { animation-name: pm-an-slide; }
.pm-an-drop svg { animation-name: pm-an-drop; }
.pm-an-rise svg { animation-name: pm-an-rise; }
.pm-an-sway svg { animation-name: pm-an-sway; transform-origin: 50% 90%; }
@keyframes pm-an-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@keyframes pm-an-shake { 0%, 100% { transform: none; } 20%, 60% { transform: translateX(-4px) rotate(-6deg); } 40%, 80% { transform: translateX(4px) rotate(6deg); } }
@keyframes pm-an-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.22); } }
@keyframes pm-an-slide { 0% { transform: translateX(-12px); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; } }
@keyframes pm-an-drop { 0% { transform: translateY(-12px); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; } }
@keyframes pm-an-rise { 0% { transform: translateY(12px); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; } }
@keyframes pm-an-sway { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }

.pm-ev__ttl { min-width: 0; }
.pm-ev__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 3px; }
.pm-ev__sev {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #1a1400;
  background: var(--ac);
}
.pm-ev--crit:not(.is-result) .pm-ev__sev { color: #fff; }
.pm-ev__cat { font-size: 0.7rem; font-weight: 750; color: var(--cc, var(--pm-soft)); }
.pm-ev__ttl h2 { margin: 0; font-size: 1.3rem; font-weight: 850; line-height: 1.15; }
.pm-ev__where { margin: 3px 0 0; font-size: 0.8rem; line-height: 1.35; color: var(--pm-soft); }

/* contexto, impacto, decisão: entram em sequência */
.pm-ev__ctx { margin: 14px 0 4px; font-size: 0.96rem; line-height: 1.5; animation: pm-ev-step 0.5s 0.25s ease both; }
.pm-ev__sec { margin-top: 12px; animation: pm-ev-step 0.5s 0.5s ease both; }
.pm-ev__sec + .pm-ev__sec { animation-delay: 0.75s; }
.pm-ev--cat .pm-ev__sec, .pm-ev.is-result .pm-ev__sec { animation-delay: 0.1s; }
@keyframes pm-ev-step { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.pm-ev__sec h3 { margin: 0 0 6px; font-size: 0.7rem; font-weight: 850; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cc, var(--pm-soft)); }
.pm-ev__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pm-chip--good { background: rgba(34, 197, 94, 0.16); color: #7df0b0; border-color: rgba(34, 197, 94, 0.45); }
.pm-chip--bad { background: rgba(239, 71, 111, 0.16); color: #ff9db3; border-color: rgba(239, 71, 111, 0.5); }
.pm-ev__idx { margin: 10px 0 0; font-size: 0.86rem; color: var(--pm-soft); }
.pm-ev__idx b { color: var(--pm-ink); font-variant-numeric: tabular-nums; }
.pm-ev__tip { margin: 8px 0 0; padding: 8px 10px; border-radius: 10px; font-size: 0.8rem; line-height: 1.4; color: #cfe0ff; background: rgba(96, 148, 240, 0.14); border: 1px solid rgba(96, 148, 240, 0.4); }
.pm-ev__note { margin: 12px 0 0; font-size: 0.72rem; font-weight: 700; text-align: center; color: var(--pm-soft); }
.pm-ev__go { width: 100%; min-height: 48px; margin-top: 14px; }

/* opções de decisão */
.pm-ev__opts { display: grid; gap: 8px; }
.pm-opt {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "t p" "d p" "fx fx";
  gap: 2px 12px;
  align-items: center;
  width: 100%;
  min-height: 56px;
  padding: 10px 12px;
  text-align: left;
  border: 1px solid var(--pm-line-soft);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.pm-opt:hover:not([disabled]) { border-color: var(--pm-gold); background: rgba(255, 210, 75, 0.08); }
.pm-opt:active:not([disabled]) { transform: translateY(1px); }
.pm-opt[disabled] { opacity: 0.5; cursor: not-allowed; }
.pm-opt__t { grid-area: t; font-size: 0.92rem; font-weight: 800; }
.pm-opt__d { grid-area: d; font-size: 0.78rem; line-height: 1.3; color: var(--pm-soft); }
.pm-opt__fx { grid-area: fx; display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.pm-opt__p { grid-area: p; display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; font-weight: 850; font-variant-numeric: tabular-nums; color: var(--pm-gold); white-space: nowrap; }

/* catálogo */
.pm-ev--cat .pm-ev__card { width: min(720px, 100%); }
.pm-evlist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.pm-evitem {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px;
  text-align: left;
  border: 1px solid var(--pm-line-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}
.pm-evitem:hover { border-color: var(--pm-gold); }
.pm-evitem svg { width: 22px; height: 22px; color: #ffd166; }
.pm-evitem--crit svg { color: #ef476f; }
.pm-evitem span { font-size: 0.84rem; font-weight: 750; line-height: 1.2; }
.pm-evitem em { font-style: normal; font-size: 0.62rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--pm-soft); }

/* botões do HUD e indicadores negativos */
.pm-evbtn {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid rgba(255, 210, 75, 0.45);
  border-radius: 999px;
  background: rgba(255, 210, 75, 0.08);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--pm-gold);
}
.pm-evbtn:hover { background: rgba(255, 210, 75, 0.16); }
.pm-factor b em.pm-neg { color: #ff8fa8; }

@media (max-width: 899px) {
  .pm-ev { place-items: end center; padding: 0; }
  .pm-ev__card { width: 100%; max-height: 92dvh; border-radius: 20px 20px 0 0; border-bottom-width: 0; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); animation-name: pm-sheet-in; }
  .pm-ev--cat .pm-ev__card { width: 100%; }
  .pm-evlist { grid-template-columns: minmax(0, 1fr); }
  .pm-ev__ttl h2 { font-size: 1.15rem; }
  .pm-ev__ico { width: 54px; height: 54px; }
  .pm-ev__ico svg { width: 28px; height: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .pm-ev, .pm-ev__card, .pm-ev__ctx, .pm-ev__sec, .pm-ev__ring, .pm-ev__ico svg { animation: none !important; }
  .pm-ev__ring { display: none; }
}
