/* DARK HOSPITAL — Phase 3: optional horror / chase UI effects.
   Additive stylesheet. Enable with classes on <body>:
   monster-alert, monster-chasing, monster-searching, monster-attacking,
   monster-near, monster-jumpscare.
   No external images, fonts or audio assets are required.
*/

:root {
  --monster-red: #df323b;
  --monster-amber: #e9b476;
  --monster-dark: #130607;
}

/* Non-interactive screen-space horror overlays. */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.32s ease;
}

body::before {
  background: radial-gradient(
    ellipse at 50% 50%,
    transparent 31%,
    rgba(105, 6, 10, 0.33) 75%,
    rgba(44, 0, 2, 0.68) 100%
  );
  mix-blend-mode: screen;
}
body.monster-near::before {
  opacity: 0.3;
}
body.monster-alert::before {
  opacity: 0.5;
}
body.monster-chasing::before {
  opacity: 0.9;
  animation: dh-heartbeat 1.03s ease-in-out infinite;
}
body.monster-attacking::before {
  opacity: 1;
  animation: dh-hit-flash 0.36s ease-out 1;
}

body::after {
  background: repeating-linear-gradient(
    0deg,
    transparent 0,
    transparent 3px,
    rgba(0, 0, 0, 0.12) 4px
  );
}
body.monster-searching::after,
body.monster-alert::after {
  opacity: 0.22;
}
body.monster-chasing::after {
  opacity: 0.36;
  animation: dh-static 0.24s steps(2, end) infinite;
}

/* Optional status widget: create an element with id="monsterWarning" from JS.
   Existing game UI stays unchanged when this element doesn't exist. */
#monsterWarning {
  position: fixed;
  top: clamp(66px, 12vh, 110px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  max-width: min(90vw, 400px);
  padding: 10px 18px;
  border: 1px solid rgba(255, 96, 101, 0.56);
  border-radius: 4px;
  background: rgba(32, 5, 8, 0.81);
  color: #fff0e9;
  font:
    700 11px/1.5 Arial,
    sans-serif;
  letter-spacing: 0.22em;
  text-align: center;
  text-shadow: 0 0 12px rgba(245, 33, 52, 0.8);
  box-shadow: 0 0 22px rgba(145, 8, 23, 0.22);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
body.monster-alert #monsterWarning,
body.monster-searching #monsterWarning,
body.monster-chasing #monsterWarning {
  opacity: 1;
}
body.monster-chasing #monsterWarning {
  animation: dh-warning-pulse 1s ease-in-out infinite;
}
body.monster-searching #monsterWarning {
  color: var(--monster-amber);
  border-color: rgba(233, 180, 118, 0.4);
}

/* Subtle UI stress, only while the monster is in pursuit. */
body.monster-chasing #cross {
  filter: drop-shadow(0 0 5px rgba(240, 40, 44, 0.9));
}
body.monster-chasing #healthFill {
  box-shadow: 0 0 12px rgba(233, 47, 55, 0.6);
}

body.monster-jumpscare::before {
  opacity: 1;
  background: rgba(220, 9, 15, 0.72);
  animation: dh-jumpscare 0.55s ease-out 1;
}

@keyframes dh-heartbeat {
  0%,
  25%,
  54%,
  100% {
    opacity: 0.45;
  }
  12%,
  38% {
    opacity: 0.95;
  }
}
@keyframes dh-hit-flash {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0.1;
  }
}
@keyframes dh-static {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(3px);
  }
}
@keyframes dh-warning-pulse {
  0%,
  100% {
    box-shadow: 0 0 14px rgba(145, 8, 23, 0.2);
  }
  50% {
    box-shadow: 0 0 30px rgba(230, 32, 50, 0.5);
  }
}
@keyframes dh-jumpscare {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@media (max-width: 600px) {
  #monsterWarning {
    top: 82px;
    padding: 8px 10px;
    font-size: 9px;
    letter-spacing: 0.12em;
  }
}
@media (prefers-reduced-motion: reduce) {
  body::before,
  body::after,
  #monsterWarning {
    animation: none !important;
    transition: none !important;
  }
}
