/* hud.css — In-game HUD (Soviet constructivist). Owned by the ui/hud.js agent.
   Theme vars come from css/style.css: --red --red-dark --gold --ink --paper --cb-enemy --cb-safe. */

:root { --enemy: var(--red); }              /* semantic "enemy/danger" red */
body.colorblind { --enemy: var(--cb-enemy); } /* colorblind: enemies shift red→blue */

/* Phase 15 slice 9: color-INDEPENDENT cues (shape/pattern, not just color).
   The colorblind swap above only changes hue; these add texture + a glyph so the
   combat status bars read without any color at all. The hazard glyphs (☢/☣),
   horde pips (▮) and hitmarker (× vs ☠) are already shape-based and unchanged. */
/* health bar: diagonal stripe texture over the fill (the <25% hazard stripes
   already override this via higher specificity when active). */
body.colorblind .hud-hp-fill {
  background-image: repeating-linear-gradient(45deg,
    rgba(255,255,255,0.18) 0 5px, rgba(0,0,0,0) 5px 10px),
    linear-gradient(180deg, var(--red) 0%, var(--red-dark) 100%);
}
/* horde bar: brighter stripe texture over the threat fill ... */
body.colorblind .hud-horde-fill {
  background-image: repeating-linear-gradient(45deg,
    rgba(255,255,255,0.4) 0 3px, rgba(0,0,0,0) 3px 7px),
    linear-gradient(180deg, #e04040 0%, var(--enemy) 45%, var(--red-dark) 100%);
}
/* ... and a skull glyph on the label when the horde is hot, so "danger" is
   conveyed by shape, not only the colored glow. */
body.colorblind .hud-horde.hot .hud-horde-label::before { content: '☠ '; }

#hud { position: absolute; inset: 0; overflow: hidden; pointer-events: none; font-family: var(--font); }

/* ---- mode gating: combat chrome hidden in menu / ending / dead ---- */
#hud[data-mode="menu"] .hud-combat,
#hud[data-mode="ending"] .hud-combat,
#hud[data-mode="dead"] .hud-combat { display: none !important; }
#hud:not([data-mode="playing"]) #hud-crosshair,
#hud:not([data-mode="playing"]) #hud-prompt { display: none !important; }

/* ================= compass (top center) ================= */
#hud-compass { position: absolute; top: 12px; left: 50%; margin-left: -220px; width: 440px; height: 62px; }
.hud-compass-win { position: relative; width: 440px; height: 34px; overflow: hidden;
  background: rgba(12,10,8,0.55); border-top: 2px solid var(--red); border-bottom: 2px solid var(--red); }
.hud-compass-strip { position: absolute; top: 0; left: 0; height: 100%; will-change: transform; }
.hud-ctick { position: absolute; bottom: 0; width: 2px; height: 7px; background: rgba(232,224,208,0.45); }
.hud-ctick.major { height: 13px; background: var(--gold); }
.hud-clbl { position: absolute; bottom: 15px; left: 50%; transform: translateX(-50%);
  font-size: var(--fs-xs); font-weight: bold; color: var(--gold); letter-spacing: 0.1em; }
.hud-compass-caret { position: absolute; left: 50%; top: 0; width: 0; height: 0; margin-left: -6px;
  border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 8px solid var(--red); }

#hud-marker { position: absolute; top: 18px; left: 0; width: 0; will-change: transform; }
.hud-mdiamond { position: absolute; left: -7px; top: 0; color: var(--gold); font-size: var(--fs-sm); text-shadow: 0 0 3px #000; }
#hud-marker.edge .hud-mdiamond { color: var(--red); }
.hud-mlabel { position: absolute; top: 18px; left: 0; transform: translateX(-50%); white-space: nowrap;
  font-size: var(--fs-xs); font-weight: bold; color: var(--paper); letter-spacing: 0.1em; text-shadow: 1px 1px 0 #000; }
.hud-mdist { position: absolute; top: 32px; left: 0; transform: translateX(-50%); white-space: nowrap;
  font-size: var(--fs-xs); color: var(--gold); text-shadow: 1px 1px 0 #000; }

/* ================= notify toasts ================= */
#hud-notify { position: absolute; top: 86px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hud-toast { background: rgba(12,10,8,0.92); border: 2px solid var(--red); border-left: 6px solid var(--gold);
  color: var(--paper); padding: 7px 20px; font-size: var(--fs-md); font-weight: bold; letter-spacing: 0.12em;
  text-transform: uppercase; white-space: nowrap; box-shadow: 4px 4px 0 rgba(0,0,0,0.6);
  animation: hudToast 4s forwards; }
@keyframes hudToast { 0% { opacity: 0; transform: translateY(-10px); } 6% { opacity: 1; transform: translateY(0); }
  82% { opacity: 1; } 100% { opacity: 0; } }

/* ================= top-right column: quest tracker + horde threat bar ================= */
#hud-topright { position: absolute; top: 12px; right: 14px; width: 250px;
  display: flex; flex-direction: column; gap: 10px; }

#hud-quests { width: auto; padding: 10px 12px; }
.hud-qhead { font-size: var(--fs-xs); font-weight: bold; color: var(--gold); letter-spacing: 0.22em;
  border-bottom: 1px solid var(--red-dark); padding-bottom: 4px; margin-bottom: 6px; }
.hud-qtitle { font-size: var(--fs-md); font-weight: bold; color: var(--gold); letter-spacing: 0.08em; }
.hud-qobj { font-size: var(--fs-sm); color: var(--paper); margin-top: 3px; line-height: 1.35; }
.hud-qsides { font-size: var(--fs-xs); color: #a89f8c; margin-top: 6px; white-space: pre-line; line-height: 1.5; }
.hud-qsides:empty { display: none; }

/* horde threat bar — fills red with awareCount/12; pips+count kept as secondary flavor */
.hud-horde { padding: 6px 10px 8px; background: rgba(12,10,8,0.55);
  border: 2px solid transparent; border-left: 4px solid var(--enemy); }
.hud-horde-label { font-size: 10px; letter-spacing: 0.22em; color: #a89f8c; }
.hud-horde-bar { height: 10px; margin-top: 4px; border: 1px solid var(--enemy); background: rgba(0,0,0,0.6); }
.hud-horde-fill { height: 100%; width: 0%;
  background: linear-gradient(180deg, #e04040 0%, var(--enemy) 45%, var(--red-dark) 100%);
  transition: width 0.25s ease-out; }
.hud-horde-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.hud-horde-pips { font-size: var(--fs-xs); color: var(--enemy); letter-spacing: 2px; min-height: 14px; }
.hud-horde-num { font-size: var(--fs-md); font-weight: bold; color: var(--gold); }
.hud-horde.hot { border-color: var(--enemy); animation: hudHorde 1s ease-in-out infinite; }
@keyframes hudHorde { 0%,100% { box-shadow: 0 0 0 rgba(0,0,0,0); } 50% { box-shadow: 0 0 14px var(--enemy); } }

/* ================= clock + vouchers + zone (top left) ================= */
#hud-topbar { position: absolute; top: 12px; left: 14px; background: rgba(12,10,8,0.55);
  border-left: 4px solid var(--red); padding: 6px 12px; }
.hud-clock { font-size: var(--fs-md); font-weight: bold; color: var(--paper); letter-spacing: 0.12em; }
.hud-vouchers { font-size: var(--fs-sm); color: var(--gold); letter-spacing: 0.12em; margin-top: 2px; }
.hud-zone { font-size: var(--fs-xs); font-weight: bold; color: var(--red); letter-spacing: 0.2em;
  margin-top: 3px; border-top: 1px solid var(--red-dark); padding-top: 3px; }

/* ================= vitals (bottom left) ================= */
#hud-vitals { position: absolute; left: 16px; bottom: 16px; }

.hud-hp-row { display: flex; align-items: center; gap: 10px; }
.hud-hp-icon { font-size: var(--fs-xl); color: var(--gold); text-shadow: 2px 2px 0 #000; }
.hud-hp-bar { width: 240px; height: 16px; border: 2px solid var(--red); background: rgba(0,0,0,0.6); }
.hud-hp-fill { height: 100%; width: 100%; background: linear-gradient(180deg, var(--red) 0%, var(--red-dark) 100%);
  transition: width 0.15s ease-out; }
/* hazard stripes <25% hp — static (no animation), epilepsy-safe */
.hud-hp-bar.hazard { border-color: #0c0a08; }
.hud-hp-bar.hazard .hud-hp-fill { background: repeating-linear-gradient(45deg,
  var(--red) 0, var(--red) 10px, #14100c 10px, #14100c 20px); }
.hud-hp-num { font-size: 24px; font-weight: bold; color: var(--paper); min-width: 44px; text-shadow: 2px 2px 0 #000; }
body.low-hp .hud-hp-num { color: var(--red); }

.hud-hazard { display: flex; gap: 10px; margin-top: 6px; min-height: 24px; }
.hud-hazard .hz { font-size: var(--fs-xl); text-shadow: 0 0 6px #000; }
.hud-hazard .hz-rad { color: var(--cb-safe); }
.hud-hazard .hz-tox { color: #5ac85a; }
.hud-hazard .hz.active { animation: hudBlink 0.5s steps(2,end) infinite; }
@keyframes hudBlink { 0% { opacity: 1; } 50% { opacity: 0.25; } 100% { opacity: 1; } }

.hud-xp-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.hud-level { font-size: var(--fs-xs); font-weight: bold; color: var(--gold); letter-spacing: 0.15em; }
.hud-xp-bar { width: 180px; height: 4px; background: rgba(0,0,0,0.6); border: 1px solid var(--gold); }
.hud-xp-fill { height: 100%; background: var(--gold); transition: width 0.2s ease-out; }
/* PHASE 42.1 — commendations waiting. The perk chooser no longer throws itself
   over the game, so this is how the player learns one is owed: "a little number
   for each level or something, that tells you". It sits on the XP row the vitals
   column already had — the part of the UI the player said they liked — and it is
   `hidden` at zero, so on a normal frame the row looks exactly as it did. */
.hud-perk-pip {
  font-size: var(--fs-xs); font-weight: bold; color: var(--gold);
  letter-spacing: 0.08em; text-shadow: 0 0 6px rgba(230, 190, 90, 0.85);
  animation: perkPipPulse 1.9s ease-in-out infinite;
}
@keyframes perkPipPulse { 0%, 100% { opacity: 0.62; } 50% { opacity: 1; } }
/* The pulse is decoration, not information — respect the accessibility setting
   the rest of the HUD already honours (hud.js:299, :504).
   ⚠️  THERE IS NO `body.reduce-motion` CLASS IN THIS PROJECT. reduceMotion is a
       state.settings flag read in JS and nothing ever mirrors it onto the DOM, so
       a `body.reduce-motion` selector — which is what this rule was first written
       as — silently never matches. hud.js toggles this class instead. */
.hud-perk-pip.no-pulse { animation: none; opacity: 1; }

/* ================= ammo (bottom right) ================= */
#hud-ammo { position: absolute; right: 16px; bottom: 16px; text-align: right;
  background: rgba(12,10,8,0.55); border-right: 4px solid var(--red); padding: 8px 14px; }
.hud-wname { font-size: var(--fs-sm); font-weight: bold; color: var(--gold); letter-spacing: 0.12em; }
.hud-wmode { font-size: var(--fs-xs); color: #a89f8c; letter-spacing: 0.2em; margin-top: 1px; }
.hud-wmode.reloading { color: var(--red); animation: hudBlink 0.4s steps(2,end) infinite; }
.hud-ammo-row { display: flex; align-items: baseline; justify-content: flex-end; gap: 8px; margin-top: 2px; }
/* industrial green phosphor digits */
.hud-mag { font-size: var(--fs-2xl); font-weight: bold; color: #7be382; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 8px rgba(110,220,120,0.4), 2px 2px 0 #000; }
.hud-ammo-sep { font-size: var(--fs-xl); font-weight: bold; color: var(--red); }
.hud-reserve { font-size: 18px; color: var(--gold); }
/* subtle digit flicker while reloading — 0.5s cycle = 2Hz max, opacity steps only */
#hud-ammo.reloading .hud-mag,
#hud-ammo.reloading .hud-reserve { animation: hudAmmoFlicker 0.5s steps(2,end) infinite; }
@keyframes hudAmmoFlicker { 0% { opacity: 1; } 50% { opacity: 0.55; } 100% { opacity: 1; } }

/* ================= battery indicator (above ammo block) ================= */
#hud-battery { position: absolute; right: 16px; bottom: 122px; display: flex; align-items: center;
  gap: 8px; background: rgba(12,10,8,0.55); border-right: 4px solid var(--gold); padding: 6px 10px; }
.hud-bat-body { position: relative; width: 34px; height: 14px; border: 2px solid var(--paper);
  background: rgba(0,0,0,0.6); }
.hud-bat-body::after { content: ''; position: absolute; right: -6px; top: 2px; width: 4px; height: 6px;
  background: var(--paper); }
.hud-bat-fill { height: 100%; width: 100%;
  background: linear-gradient(180deg, #8fd08f 0%, #4e9e4e 100%); transition: width 0.2s ease-out; }
.hud-bat-pct { font-size: var(--fs-sm); font-weight: bold; color: var(--paper); letter-spacing: 0.1em; }
#hud-battery.low .hud-bat-fill { background: linear-gradient(180deg, var(--gold) 0%, #9a741e 100%); }
#hud-battery.low .hud-bat-pct { color: var(--gold); }

/* ================= crosshair + hitmarker ================= */
#hud-crosshair { position: absolute; left: 50%; top: 50%; width: 0; height: 0; --gap: 6px; }
#hud-crosshair .ch { position: absolute; background: var(--paper); box-shadow: 0 0 2px #000; }
#hud-crosshair .ch-t { width: 2px; height: 9px; left: -1px; top: calc(-9px - var(--gap)); }
#hud-crosshair .ch-b { width: 2px; height: 9px; left: -1px; top: var(--gap); }
#hud-crosshair .ch-l { width: 9px; height: 2px; top: -1px; left: calc(-9px - var(--gap)); }
#hud-crosshair .ch-r { width: 9px; height: 2px; top: -1px; left: var(--gap); }
#hud-crosshair .ch-dot { position: absolute; width: 2px; height: 2px; left: -1px; top: -1px; background: var(--gold); }
#hud-crosshair.dot-only .ch { display: none; }
#hud-crosshair.dot-only .ch-dot { display: block; width: 4px; height: 4px; left: -2px; top: -2px; }

/* 0.8s gold flash on the ammo block when a weapon is equipped */
@keyframes wpn-flash { 0% { background: rgba(232,184,58,0.55); } 100% { background: transparent; } }
#hud-ammo.wpn-flash { animation: wpn-flash 0.8s ease-out; }

#hud-hitmarker { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  opacity: 0; pointer-events: none; }
#hud-hitmarker .hm-glyph { font-size: var(--fs-2xl); font-weight: bold; color: var(--paper); text-shadow: 0 0 4px #000; }
#hud-hitmarker.head .hm-glyph { color: var(--enemy); font-size: var(--fs-2xl); }
#hud-hitmarker.on { animation: hudHitFade 0.4s ease-out; }
#hud-hitmarker.on .hm-glyph { animation: hudHitPop 0.4s ease-out; }
@keyframes hudHitFade { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes hudHitPop { 0% { transform: scale(1.4); } 100% { transform: scale(0.9); } }

/* ================= scavengersEye loot diamonds ================= */
#hud-scaveye { position: absolute; inset: 0; overflow: hidden; }
.hud-eye-mark { position: absolute; left: 0; top: 0; color: #ffd94a; font-size: var(--fs-sm);
  text-shadow: 0 0 4px #000, 0 0 8px rgba(232,184,58,0.85); will-change: transform;
  animation: hudEyeBob 1.6s ease-in-out infinite; }
@keyframes hudEyeBob { 0%,100% { margin-top: 0; } 50% { margin-top: -4px; } }

/* ================= interaction prompt ================= */
#hud-prompt { position: absolute; left: 50%; bottom: 21%; transform: translateX(-50%);
  background: rgba(12,10,8,0.85); border: 2px solid var(--gold); padding: 8px 22px;
  font-size: var(--fs-md); font-weight: bold; letter-spacing: 0.12em; color: var(--paper);
  text-transform: uppercase; white-space: nowrap; }

/* ===== level-up banner (15.2), under the compass ===== */
#hud-levelup { position: absolute; left: 50%; top: 74px; transform: translateX(-50%);
  min-width: 260px; text-align: center; padding: 7px 20px 9px;
  background: rgba(12,10,8,0.86); border: 2px solid var(--gold);
  animation: lu-in 0.25s ease-out; }
#hud:not([data-mode="playing"]) #hud-levelup { display: none !important; }
.hud-lu-title { font-size: var(--fs-lg); font-weight: bold; letter-spacing: 0.18em; color: var(--gold);
  text-transform: uppercase; }
.hud-lu-bar { height: 5px; margin: 5px 0 4px; background: rgba(0,0,0,0.6);
  border: 1px solid rgba(232,184,58,0.5); overflow: hidden; }
.hud-lu-fill { height: 100%; width: 0; background: var(--gold); }
.hud-lu-sub { font-size: var(--fs-xs); letter-spacing: 0.10em; color: rgba(232,224,208,0.86);
  text-transform: uppercase; }
@keyframes lu-in { from { opacity: 0; transform: translate(-50%, -6px); }
                   to   { opacity: 1; transform: translate(-50%, 0); } }

/* Second-key prompt (15.1): sits just under the interact prompt, quieter, and
   carries its own button label so it reads as a separate control rather than an
   alternative to the one above it. */
#hud-altprompt { position: absolute; left: 50%; bottom: 16.4%; transform: translateX(-50%);
  background: rgba(12,10,8,0.72); border: 1px solid rgba(232,184,58,0.55); padding: 5px 16px;
  font-size: var(--fs-sm); font-weight: bold; letter-spacing: 0.10em; color: rgba(232,224,208,0.92);
  text-transform: uppercase; white-space: nowrap; }
#hud:not([data-mode="playing"]) #hud-altprompt { display: none !important; }

/* ================= bike panel (bottom center, while mounted) ================= */
#hud-bike { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  min-width: 230px; background: rgba(12,10,8,0.82); border: 2px solid var(--red);
  border-top: 4px solid var(--gold); padding: 8px 16px 10px; text-align: center;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.6); }
.hud-bike-speed-row { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.hud-bike-speed { font-size: 42px; font-weight: bold; color: var(--paper); text-shadow: 2px 2px 0 #000;
  line-height: 1; min-width: 74px; }
.hud-bike-unit { font-size: var(--fs-sm); font-weight: bold; color: var(--gold); letter-spacing: 0.2em; }
.hud-bike-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.hud-bike-label { font-size: 10px; font-weight: bold; color: #a89f8c; letter-spacing: 0.22em; width: 38px;
  text-align: right; }
.hud-bike-bar { flex: 1; height: 10px; border: 1px solid var(--gold); background: rgba(0,0,0,0.6); }
.hud-bike-fill { height: 100%; width: 100%; transition: width 0.15s ease-out; }
.hud-bike-fill.fuel { background: linear-gradient(180deg, var(--gold) 0%, #9a741e 100%); }
.hud-bike-fill.fuel.low { background: var(--red); animation: hudBlink 0.4s steps(2,end) infinite; }
.hud-bike-fill.cond { background: linear-gradient(180deg, var(--red) 0%, var(--red-dark) 100%); }

/* ================= subtitle bar ================= */
/* Phase 15 slice 6: --sub-scale (set live by hud.js from settings.subtitleScale)
   scales both lines; the text-shadow gives the text a hard dark edge so it stays
   legible over bright snow, fire, or the pale deadlands (subtitle readability). */
#hud-subtitle { position: absolute; left: 50%; bottom: 7%; transform: translateX(-50%);
  max-width: 640px; min-width: 280px; background: rgba(0,0,0,0.78);
  border-left: 4px solid var(--red); padding: 10px 18px; text-align: center;
  --sub-scale: 1; }
.hud-sub-speaker { font-size: calc(13px * var(--sub-scale)); font-weight: bold; color: var(--gold);
  letter-spacing: 0.18em; text-shadow: 0 1px 2px rgba(0,0,0,0.9); }
.hud-sub-speaker:empty { display: none; }
.hud-sub-text { font-size: calc(17px * var(--sub-scale)); color: var(--paper); text-transform: none;
  letter-spacing: 0.03em; line-height: 1.35; margin-top: 2px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9), 0 0 6px rgba(0,0,0,0.6); }

/* ================= overlays ================= */
#hud-damage { position: absolute; inset: 0; opacity: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(160,0,0,0) 42%, rgba(160,10,10,0.65) 100%); }
#hud-damage.on { animation: hudDmg 0.55s ease-out; }
@keyframes hudDmg { 0% { opacity: 1; } 100% { opacity: 0; } }

#hud-splash-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.hud-splatter { position: absolute; inset: 0; opacity: 0; animation: hudSplash 2s ease-out forwards; }
@keyframes hudSplash { 0% { opacity: 0.95; } 55% { opacity: 0.85; } 100% { opacity: 0; } }

#hud-lowhp { position: absolute; inset: 0; opacity: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(120,0,0,0) 48%, rgba(140,10,10,0.6) 100%); }
body.low-hp #hud-lowhp { animation: hudLow 1.2s ease-in-out infinite; }
@keyframes hudLow { 0%,100% { opacity: 0.12; } 50% { opacity: 0.75; } }


/* ===================================================================
   PHASE 8.6 — SCREEN-SPACE DAMAGE FEEDBACK
   =================================================================== */

/* Directional damage arcs.
   The ring is a full-screen square centred on the crosshair; each arc is a
   wedge pinned to the top of it and rotated into place by hud.js. Rotating a
   child of a centred square is the cheapest way to get "point at a bearing"
   without any per-frame layout, and it stays correct at every aspect ratio. */
#hud-dmg-ring {
  position: absolute; left: 50%; top: 50%;
  width: 62vmin; height: 62vmin; margin: -31vmin 0 0 -31vmin;
  pointer-events: none;
}
.hud-dmg-arc {
  position: absolute; inset: 0;
  opacity: 0;
  transform-origin: 50% 50%;
  /* A band in the OUTER third of the wedge. Keeping it away from the middle
     matters: an indicator that reaches the crosshair is read as a hit marker,
     not as a direction, and it also sits on top of whatever you are aiming at. */
  background:
    radial-gradient(closest-side at 50% 50%,
      transparent 58%,
      rgba(225, 45, 32, 0.30) 70%,
      rgba(235, 60, 40, 0.92) 84%,
      rgba(150, 12, 8, 0.0) 100%);
  /* Clip the ring down to a wedge pointing at 12 o'clock. Wide enough (~58deg)
     to be unmistakable at a glance while still separating four attackers. */
  clip-path: polygon(50% 50%, 22% 0%, 78% 0%);
}
.hud-dmg-arc.on { animation: hudArc 1.15s ease-out forwards; }
@keyframes hudArc {
  0%   { opacity: 0.95; }
  35%  { opacity: 0.8; }
  100% { opacity: 0; }
}

/* Low-health desaturation.
   Applied to the WebGL canvas rather than to a HUD overlay, because an overlay
   can only add colour on top and this effect has to REMOVE it. hud.js writes
   --hud-sat (1 = healthy, 0.5 = dead). style.css is read-only, so the canvas is
   selected here by tag; the variable defaults to 1, so with the HUD absent or
   before the first update this rule is a no-op. */
canvas {
  filter: saturate(var(--hud-sat, 1));
}
