/* ============================================================
   OPERATION BLACKOUT — HUD stylesheet
   Owner: HUD module (js/ui/hud.js + css/hud.css only)
   COD-modern minimal: hairline rules, letterspaced micro-labels,
   warm-white type, amber accent, red for damage.
   ============================================================ */

#ui-root {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  font-family: 'Barlow Condensed', 'Oswald', sans-serif;
  color: #eef3f9;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#ui-root * { box-sizing: border-box; margin: 0; padding: 0; }

/* ---------- gameplay HUD layer ---------- */
.hud {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.hud.live { opacity: 1; }
.hud.dim  { opacity: 0; }

/* ---------- compass ---------- */
.hud-compass {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  height: 32px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 18%, #000 82%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 18%, #000 82%, transparent 100%);
}
.hud-compass-strip {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 2400px;
  will-change: transform;
}
.c-tick {
  position: absolute;
  top: 19px;
  width: 1px;
  height: 5px;
  background: rgba(238, 243, 249, 0.32);
}
.c-tick.mid { top: 17px; height: 7px; background: rgba(238, 243, 249, 0.5); }
.c-tick.maj { top: 15px; height: 9px; background: rgba(238, 243, 249, 0.78); }
.c-label {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: rgba(238, 243, 249, 0.92);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.c-label.inter { font-size: 10px; top: 3px; color: rgba(238, 243, 249, 0.55); }
.hud-compass-caret {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #ffb454;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}
.hud-heading {
  position: absolute;
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: rgba(238, 243, 249, 0.6);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

/* ---------- crosshair ---------- */
.hud-crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  --gap: 10px;
  will-change: opacity;
}
.ch-line {
  position: absolute;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.85);
}
.ch-t { width: 1.5px; height: 9px; left: -0.75px; bottom: var(--gap); }
.ch-b { width: 1.5px; height: 9px; left: -0.75px; top: var(--gap); }
.ch-l { height: 1.5px; width: 9px; top: -0.75px; right: var(--gap); }
.ch-r { height: 1.5px; width: 9px; top: -0.75px; left: var(--gap); }
.ch-dot {
  position: absolute;
  width: 2px;
  height: 2px;
  left: -1px;
  top: -1px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.85);
}

/* ---------- hitmarker ---------- */
.hud-hitmarker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  opacity: 0;
  transition: opacity 0.06s linear, transform 0.06s linear;
}
.hud-hitmarker.show { opacity: 1; }
.hud-hitmarker.kill { transform: scale(1.18); }
.hm {
  position: absolute;
  left: -5px;
  top: -0.75px;
  width: 10px;
  height: 1.5px;
  background: #fff;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}
.hm-1 { transform: rotate(45deg)  translateX(9px); }
.hm-2 { transform: rotate(135deg) translateX(9px); }
.hm-3 { transform: rotate(225deg) translateX(9px); }
.hm-4 { transform: rotate(315deg) translateX(9px); }
.hud-hitmarker.kill .hm { background: #ff5040; box-shadow: 0 0 5px rgba(255, 50, 30, 0.6); }

/* ---------- damage vignette + directional arcs ---------- */
.hud-vignette {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(115% 92% at 50% 50%,
    rgba(255, 40, 25, 0) 50%,
    rgba(255, 45, 28, 0.26) 74%,
    rgba(140, 0, 0, 0.66) 100%);
  will-change: opacity;
}
.dmg-arc {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  opacity: 0;
  will-change: transform, opacity;
}
.dmg-arc i {
  position: absolute;
  left: -42px;
  top: -138px;
  width: 84px;
  height: 30px;
  border-top: 3px solid rgba(255, 75, 58, 0.95);
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  filter: drop-shadow(0 0 8px rgba(255, 60, 40, 0.55));
}

/* ---------- ammo (bottom-right) ---------- */
.hud-ammo {
  position: absolute;
  right: 38px;
  bottom: 32px;
  text-align: right;
}
.ammo-name {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.28em;
  color: rgba(238, 243, 249, 0.6);
  margin-bottom: 3px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.ammo-row {
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
}
#ammo-mag {
  font-size: 44px;
  font-weight: 700;
  color: #f4f7fb;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
  transition: color 0.3s ease;
}
.ammo-div {
  font-size: 20px;
  font-weight: 500;
  margin: 0 8px;
  color: rgba(238, 243, 249, 0.32);
}
#ammo-res {
  font-size: 18px;
  font-weight: 500;
  color: rgba(238, 243, 249, 0.6);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.ammo-reload {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3em;
  color: #ffb454;
  opacity: 0;
  margin-top: 5px;
  transition: opacity 0.25s ease;
}
.hud-ammo.low  #ammo-mag { color: #ffb454; }
.hud-ammo.crit #ammo-mag { color: #ff453a; }
.hud-ammo.reloading #ammo-mag { color: rgba(238, 243, 249, 0.35); }
.hud-ammo.reloading .ammo-reload { opacity: 1; animation: ob-pulse 1s ease-in-out infinite; }
@keyframes ob-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- health + wave (bottom-left) ---------- */
.hud-left {
  position: absolute;
  left: 38px;
  bottom: 34px;
}
.hud-health {
  width: 140px;
  height: 3px;
  background: rgba(238, 243, 249, 0.16);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.hud-health.visible { opacity: 1; }
#health-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: #f4f7fb;
  transform-origin: left center;
  will-change: transform;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.22);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}
.hud-health.low #health-fill {
  background: #ff453a;
  box-shadow: 0 0 8px rgba(255, 69, 58, 0.5);
}
.hud-wave-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
}
#wave-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.24em;
  color: rgba(238, 243, 249, 0.75);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.hud-pips { display: flex; gap: 3px; }
.pip {
  width: 4px;
  height: 10px;
  background: rgba(238, 243, 249, 0.16);
  transform: skewX(-12deg);
  transition: background 0.25s ease;
}
.pip.on  { background: rgba(255, 90, 70, 0.9); }
.pip.off { display: none; }

/* ---------- kill feed + score (top-right) ---------- */
.hud-right {
  position: absolute;
  top: 58px;
  right: 38px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.hud-feed {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.feed-row {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: rgba(8, 12, 18, 0.42);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: rgba(238, 243, 249, 0.92);
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 0.26s cubic-bezier(0.22, 0.9, 0.34, 1),
              transform 0.26s cubic-bezier(0.22, 0.9, 0.34, 1);
}
.feed-row.in { display: flex; opacity: 1; transform: translateX(0); }
.feed-row.in.out { opacity: 0; transform: translateX(6px); }
.feed-row .fx { color: #ffb454; font-style: normal; font-size: 11px; }
.feed-row b { color: #ff6a55; font-weight: 600; }
.hud-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: rgba(238, 243, 249, 0.48);
  text-align: right;
  line-height: 1.7;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.hud-score b { color: rgba(238, 243, 249, 0.8); font-weight: 500; }

/* ---------- wave banner ---------- */
.hud-banner {
  position: absolute;
  top: 26vh;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 56px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #f4f7fb;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
}
.hud-banner.play { animation: ob-banner 2.4s cubic-bezier(0.25, 0.1, 0.25, 1) forwards; }
@keyframes ob-banner {
  0%   { opacity: 0; letter-spacing: 0.55em; transform: translateY(-6px); }
  14%  { opacity: 1; }
  62%  { opacity: 1; letter-spacing: 0.22em; transform: translateY(0); }
  100% { opacity: 0; letter-spacing: 0.2em; }
}

/* ---------- menu ---------- */
.menu {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  cursor: default;
  opacity: 1;
  transition: opacity 0.34s cubic-bezier(0.4, 0, 0.2, 1);
}
.menu.hidden { opacity: 0; pointer-events: none; }
.menu-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg,
    rgba(4, 7, 11, 0.94) 0%,
    rgba(4, 7, 11, 0.78) 34%,
    rgba(4, 7, 11, 0.42) 62%,
    rgba(4, 7, 11, 0.18) 100%);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.menu-scrim::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(4, 7, 11, 0.8) 0%, transparent 30%);
}
.menu-content {
  position: absolute;
  left: clamp(48px, 8vw, 140px);
  top: 50%;
  transform: translateY(-52%);
  max-width: 640px;
}
.menu-eyebrow {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5em;
  color: rgba(255, 180, 84, 0.7);
  margin-bottom: 18px;
  opacity: 0;
}
.menu-title {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  font-size: clamp(46px, 7vw, 72px);
  line-height: 1.02;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #f2ead9;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.55);
  opacity: 0;
}
.menu-rule {
  width: 64px;
  height: 2px;
  background: #ffb454;
  margin: 26px 0 18px;
  transform-origin: left center;
  transform: scaleX(0);
}
.menu-tag {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.42em;
  color: rgba(238, 243, 249, 0.6);
  opacity: 0;
}
.menu-actions {
  margin-top: 44px;
  opacity: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.menu-controls {
  position: absolute;
  left: clamp(48px, 8vw, 140px);
  bottom: 42px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.26em;
  color: rgba(238, 243, 249, 0.42);
  opacity: 0;
}
.menu.reveal .menu-eyebrow  { animation: ob-fade-up 0.5s ease 0.05s forwards; }
.menu.reveal .menu-title    { animation: ob-title-in 1s cubic-bezier(0.22, 0.9, 0.3, 1) 0.1s forwards; }
.menu.reveal .menu-rule     { animation: ob-rule-in 0.5s cubic-bezier(0.3, 0.7, 0.3, 1) 0.7s forwards; }
.menu.reveal .menu-tag      { animation: ob-fade-up 0.5s ease 0.85s forwards; }
.menu.reveal .menu-actions  { animation: ob-fade-up 0.5s ease 1.05s forwards; }
.menu.reveal .menu-controls { animation: ob-fade-up 0.5s ease 1.25s forwards; }
@keyframes ob-title-in {
  0%   { opacity: 0; letter-spacing: 0.3em; }
  100% { opacity: 1; letter-spacing: 0.04em; }
}
@keyframes ob-rule-in { to { transform: scaleX(1); } }
@keyframes ob-fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- buttons ---------- */
.btn {
  pointer-events: auto;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  background: transparent;
  border: 1px solid rgba(238, 243, 249, 0.34);
  color: #eef3f9;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  padding: 15px 30px 15px 34px;
  transition: background 0.24s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.24s cubic-bezier(0.4, 0, 0.2, 1),
              color 0.24s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn .btn-arrow {
  color: #ffb454;
  font-size: 13px;
  transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1), color 0.24s ease;
}
.btn:hover {
  background: #ffb454;
  border-color: #ffb454;
  color: #0a0d12;
  box-shadow: 0 0 28px rgba(255, 180, 84, 0.28);
}
.btn:hover .btn-arrow { color: #0a0d12; transform: translateX(4px); }
.btn:active { transform: translateY(1px); }
.btn-ghost {
  border-color: rgba(238, 243, 249, 0.16);
  color: rgba(238, 243, 249, 0.72);
}
.btn-ghost .btn-arrow { color: rgba(255, 180, 84, 0.7); }

/* ---------- pause screen ---------- */
.pause {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.pause.show { opacity: 1; pointer-events: auto; cursor: default; }
.pause-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 100% at 50% 50%, rgba(4, 7, 11, 0.5) 30%, rgba(4, 7, 11, 0.86) 100%),
    linear-gradient(rgba(4, 7, 11, 0.45), rgba(4, 7, 11, 0.45));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.pause-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.pause-eyebrow {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5em;
  color: rgba(255, 180, 84, 0.7);
  margin-bottom: 14px;
}
.pause-title {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  font-size: clamp(40px, 6vw, 58px);
  line-height: 1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #f2ead9;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.55);
}
.pause-rule {
  width: 64px;
  height: 2px;
  background: #ffb454;
  margin: 24px 0 0;
}
.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 38px;
  min-width: 264px;
}
.pause-actions .btn { justify-content: space-between; }
.pause-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 42px;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.26em;
  color: rgba(238, 243, 249, 0.42);
}

/* ---------- death screen ---------- */
.death {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s ease;
}
.death.show { opacity: 1; pointer-events: auto; cursor: default; }
.death-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 100% at 50% 50%,
      rgba(30, 0, 0, 0.35) 40%,
      rgba(120, 4, 0, 0.72) 100%),
    linear-gradient(rgba(6, 4, 6, 0.55), rgba(6, 4, 6, 0.55));
}
.death-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 36px;
}
.death-title {
  font-family: 'Oswald', sans-serif;
  font-size: clamp(72px, 12vw, 128px);
  font-weight: 600;
  letter-spacing: 0.12em;
  color: #ff5a48;
  text-shadow: 0 0 40px rgba(255, 40, 25, 0.35);
  opacity: 0;
  transform: scale(0.96);
}
.death.show .death-title {
  animation: ob-kia-in 0.8s cubic-bezier(0.2, 0.8, 0.3, 1) 0.25s forwards;
}
@keyframes ob-kia-in { to { opacity: 1; transform: scale(1); } }
.death-sub {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.4em;
  color: rgba(238, 243, 249, 0.5);
  margin-top: -22px;
  opacity: 0;
}
.death.show .death-sub { animation: ob-fade-up 0.5s ease 0.7s forwards; }
.death .btn { opacity: 0; }
.death.show .btn { animation: ob-fade-up 0.5s ease 0.95s forwards; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .hud-ammo { right: 22px; bottom: 22px; }
  .hud-left { left: 22px; bottom: 24px; }
  .hud-right { right: 22px; top: 48px; }
  #ammo-mag { font-size: 36px; }
  .hud-banner { font-size: 40px; }
}

/* ============================================================ FPS + ADS  */
/* Added in r22 alongside the adaptive quality ladder and the ADS toggle.   */

/* Top-left is the only free corner: compass is centred, ammo bottom-right,
   health/wave bottom-left, feed/score top-right. 38px matches the gutter
   every other HUD block uses. */
.hud-perf {
  position: absolute;
  top: 58px;
  left: 38px;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.2s ease;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}
.hud-perf.on { opacity: 1; }
.perf-fps {
  font-size: 20px;
  font-weight: 700;
  color: #eef3f9;
  letter-spacing: 0.02em;
}
.perf-unit {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  color: rgba(238, 243, 249, 0.5);
  margin-left: 5px;
}
.perf-ms {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: rgba(238, 243, 249, 0.45);
  margin-top: 4px;
}
.perf-tier {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.24em;
  color: rgba(255, 180, 84, 0.75);
  margin-top: 3px;
  min-height: 11px;
}
/* Graded against the display's real refresh rate, not a hardcoded 60. */
.hud-perf.warn .perf-fps { color: #ffb454; }
.hud-perf.bad  .perf-fps { color: #ff6a55; }

/* ADS toggle state. A latched toggle must never be invisible — this is lit
   whenever aimLatched is true, including through the reload window where the
   sight picture is temporarily gone. */
.hud-ads {
  position: absolute;
  right: 38px;
  bottom: 112px;   /* .hud-ammo is bottom:32 + ~70 tall = top edge 102; clear it */
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3em;
  color: rgba(39, 224, 255, 0.9);
  border: 1px solid rgba(39, 224, 255, 0.35);
  padding: 3px 9px 2px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}
.hud-ads.on { opacity: 1; transform: translateY(0); }

/* Resupply rows must not render in the kill-feed red — that reads as a kill. */
.feed-row.pickup b { color: #ffb454; }

/* The controls hint gained "RMB/Q ADS TOGGLE · ` FPS"; give the left-anchored
   menu line a right edge so it wraps instead of running off a narrow window. */
.menu-controls { right: clamp(32px, 6vw, 140px); line-height: 1.9; }

@media (max-width: 900px) {
  .hud-perf { top: 46px; left: 20px; }
  .hud-ads  { right: 20px; bottom: 104px; }
}

/* Primary's reserve, shown under the ammo block while the unlimited secondary
   is equipped — without it every ammo crate reads as a no-op next to 'INF'. */
.ammo-stash {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: rgba(238, 243, 249, 0.42);
  margin-top: 3px;
  min-height: 11px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
