/* ============================================================
   QUANTUM EXPERT HUD  (core/expert-hud.js)

   Lutfi's "Quantum Dawn Expert Stages" design. Its measurements are for a
   1918-pixel-wide screen; every size here is the design's own number times
   --s, which expert-hud.js sets from the play area (1 at 1600 px and wider,
   never under 0.62). A phone, or a window under 430 px tall, gets the
   compact layout at the end. --accent is the stage's colour.

   It sits over the canvas (z 3), under the banners, the touch pads and the
   sheets, and takes no clicks or taps.
   ============================================================ */
.xh {
  --s: 1;
  --accent: #edbc78;
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  color: #f1f3fa;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: normal;
  text-align: left;
  -webkit-user-select: none;
  user-select: none;
}
.xh[hidden] { display: none !important; }
.xh *, .xh *::before, .xh *::after { box-sizing: border-box; }

.xh-panel {
  position: absolute;
  background: linear-gradient(115deg, #09111ded, #151b2ce8);
  border: 1px solid #ffffff30;
  border-radius: calc(14px * var(--s));
  box-shadow: 0 calc(12px * var(--s)) calc(36px * var(--s)) #0005;
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
}
.xh-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.xh-tiny { font-size: calc(14px * var(--s)); color: #b6c2d3; letter-spacing: calc(2px * var(--s)); font-weight: 650; }

/* ---- vitals ---- */
.xh-player { left: calc(28px * var(--s)); top: calc(25px * var(--s)); width: calc(380px * var(--s)); padding: calc(20px * var(--s)) calc(22px * var(--s)) calc(18px * var(--s)); }
.xh-hearts { color: #88d6ba; font-size: calc(23px * var(--s)); letter-spacing: calc(3px * var(--s)); line-height: 1; white-space: nowrap; }
.xh-hearts i { font-style: normal; }
.xh-hearts i.is-lost { color: #3b4b53; }
.xh-hearts.is-low i:not(.is-lost) { color: #ff8aa2; }
.xh-hearts em { font-style: normal; font-size: 0.6em; margin-left: 4px; color: #cfc2e8; }
.xh-numbers { display: grid; grid-template-columns: 1fr 1.25fr 0.65fr; margin: calc(23px * var(--s)) 0 calc(21px * var(--s)); }
.xh-numbers > div { border-right: 1px solid #ffffff1c; padding-left: calc(19px * var(--s)); min-width: 0; }
.xh-numbers > div:first-child { padding-left: 0; }
.xh-numbers > div:last-child { border-right: 0; }
.xh-numbers .xh-tiny { font-size: calc(12px * var(--s)); letter-spacing: calc(1.3px * var(--s)); display: block; margin-bottom: calc(6px * var(--s)); white-space: nowrap; }
.xh-numbers strong { font-size: calc(34px * var(--s)); font-weight: 550; line-height: 1; letter-spacing: -1px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.xh-numbers em { font-style: normal; font-size: calc(18px * var(--s)); color: #a3b0c1; margin-left: calc(5px * var(--s)); }
.xh-numbers > div.is-low strong { color: #ff9ab0; }
.xh-skill { border-top: 1px solid #ffffff1c; padding-top: calc(16px * var(--s)); display: flex; align-items: center; gap: calc(12px * var(--s)); font-size: calc(15px * var(--s)); }
.xh-skill-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.xh kbd {
  font-family: inherit; font-size: 0.9em; display: inline-block; margin-right: calc(7px * var(--s));
  border: 1px solid #7a88946b; border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; color: #b9c4d0;
}
.xh-charge { height: calc(5px * var(--s)); min-height: 3px; border-radius: 3px; background: #304950; flex: 1; overflow: hidden; }
.xh-charge i { display: block; height: 100%; width: 100%; background: #8bdbc2; }
.xh-ready { font-size: calc(11px * var(--s)); letter-spacing: 1.4px; color: #b78cff; white-space: nowrap; }
.xh-ready.is-ready { color: #96dcc5; }

/* ---- boss ---- */
.xh-boss {
  position: absolute; left: 50%; top: calc(32px * var(--s)); width: calc(618px * var(--s)); max-width: 46%;
  transform: translateX(-50%); padding: calc(16px * var(--s)) calc(24px * var(--s));
  background: linear-gradient(90deg, transparent, #07101cca, transparent); display: none;
}
.xh-boss.is-on { display: block; }
.xh-boss-label { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: calc(12px * var(--s)); font-size: calc(20px * var(--s)); font-weight: 600; white-space: nowrap; }
.xh-phase { font-size: calc(12px * var(--s)); letter-spacing: 2px; color: #c8bace; }
.xh-boss-meter { height: calc(10px * var(--s)); min-height: 6px; background: #0c121f; border: 1px solid #d3a6bd44; position: relative; overflow: hidden; border-radius: 9px; }
.xh-boss-meter i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #eeaf95, #d379a0); transition: width 0.2s; }
.xh-boss-meter b { position: absolute; height: 100%; top: 0; background: #2b152777; width: 2px; left: 35%; }
.xh-boss-meter b:last-child { left: 70%; }

/* ---- field objectives ---- */
.xh-objectives { right: calc(28px * var(--s)); top: calc(25px * var(--s)); width: calc(366px * var(--s)); padding: calc(20px * var(--s)); }
.xh-objectives .xh-tiny { font-size: calc(12px * var(--s)); letter-spacing: calc(1.5px * var(--s)); }
.xh-sealed { font-size: calc(10px * var(--s)); letter-spacing: 1px; border: 1px solid #d0a4b94d; padding: calc(5px * var(--s)) calc(7px * var(--s)); border-radius: 4px; color: #e0b5c4; white-space: nowrap; }
.xh-sealed.is-open { color: #9ff0c8; border-color: #9ff0c866; }
.xh-resources { display: flex; gap: calc(22px * var(--s)); margin: calc(22px * var(--s)) 0 calc(19px * var(--s)); color: #b7c3d2; font-size: calc(17px * var(--s)); }
.xh-resources > span { display: flex; align-items: center; gap: calc(18px * var(--s)); flex: 1; white-space: nowrap; }
.xh-resources b { margin-left: auto; color: #edf0f8; }
.xh-audit { display: flex; align-items: center; justify-content: space-between; font-size: calc(17px * var(--s)); }
.xh-audit b { font-size: calc(14px * var(--s)); margin-left: calc(8px * var(--s)); color: #a9bacf; }
.xh-dots { display: flex; gap: calc(5px * var(--s)); }
.xh-dots i { width: calc(25px * var(--s)); height: calc(7px * var(--s)); min-height: 4px; background: #3a4152; border: 1px solid #78879733; border-radius: 2px; }
.xh-dots i.is-good { background: var(--accent); }
.xh-dots i.is-bad { background: #ef8aa2; }
.xh-dots i.is-wait { background: #9fb0c4; }
.xh-pass { font-size: calc(13px * var(--s)); color: #b5a6b7; margin: calc(14px * var(--s)) 0 calc(16px * var(--s)); }
.xh-fct { display: flex; justify-content: space-between; border-top: 1px solid #ffffff15; padding-top: calc(12px * var(--s)); font-size: calc(11px * var(--s)); color: #aeb7c4; }
.xh-fct > span { display: flex; gap: 3px; align-items: center; }
.xh-fct i { width: calc(10px * var(--s)); height: calc(4px * var(--s)); min-height: 3px; background: #454a58; }
.xh-fct .yellow { background: #e1c084; }
.xh-fct .blue { background: #89add8; }
.xh-fct .green { background: #85c3a0; }

/* ---- the stage caption: the design's "STAGE 01 / 05  Amber Academy" ---- */
.xh-caption {
  position: absolute; top: 34%; left: calc(48px * var(--s)); text-shadow: 0 2px 16px #0008;
  opacity: 0; transform: translateY(10px); transition: opacity 0.5s ease, transform 0.5s ease;
}
.xh-caption.is-on { opacity: 1; transform: none; }
.xh-caption.is-out { opacity: 0; transform: none; }
.xh-caption .xh-tiny { color: var(--accent); font-size: calc(13px * var(--s)); letter-spacing: 3.5px; margin-bottom: calc(10px * var(--s)); }
.xh-caption-name { font-family: Georgia, "Times New Roman", serif; font-size: calc(48px * var(--s)); letter-spacing: -1.4px; color: #f4f0e9; }
.xh-caption-line { display: block; width: calc(48px * var(--s)); height: 2px; margin-top: calc(20px * var(--s)); background: var(--accent); }

/* ---- bottom: the quest label and the route map ---- */
.xh-bottom-label { position: absolute; bottom: calc(27px * var(--s)); left: calc(35px * var(--s)); font-size: calc(12px * var(--s)); letter-spacing: 2px; color: #adb8ca; white-space: nowrap; }
.xh-bottom-label span { margin-left: calc(14px * var(--s)); color: var(--accent); }
.xh-map { position: absolute; bottom: calc(25px * var(--s)); left: 50%; width: calc(345px * var(--s)); height: calc(18px * var(--s)); transform: translateX(-50%); }
.xh-map-line { position: absolute; top: 50%; left: 0; right: 0; height: 2px; margin-top: -1px; background: #697489; }
.xh-map i { position: absolute; top: 50%; z-index: 1; border: 2px solid #192333; width: calc(8px * var(--s)); height: calc(8px * var(--s)); min-width: 7px; min-height: 7px; border-radius: 50%; background: #ac9dc6; transform: translate(-50%, -50%); }
.xh-map-marks { position: absolute; inset: 0; }
.xh-map .xh-map-player { width: calc(12px * var(--s)); height: calc(12px * var(--s)); min-width: 10px; min-height: 10px; background: #88d5b9; z-index: 2; }
.xh-map .xh-map-boss { display: none; background: #e5a58b; border-radius: 0; width: calc(9px * var(--s)); height: calc(9px * var(--s)); transform: translate(-50%, -50%) rotate(45deg); }
.xh-map .xh-map-boss.is-on { display: block; }
.xh-map .xh-map-gate { border-radius: 0; background: #e5c283; width: calc(7px * var(--s)); height: calc(12px * var(--s)); min-width: 6px; min-height: 10px; }
.xh-map .xh-map-gate.is-open { background: #9ff0c8; }

/* ---------- compact: a phone, or a short window ----------
   Two small corner panels (vitals: hearts, score, time; objectives: the
   question and the gate) and the boss bar. The skill bar (the touch deck
   has its own Skill button), relics, crystals and foes, the F/C/T row, the
   bottom label and the route map step aside. */
.xh.is-compact .xh-player { left: 8px; top: 8px; width: auto; min-width: calc(150px * var(--s)); padding: 8px 10px; border-radius: 10px; }
.xh.is-compact .xh-player > .xh-row .xh-tiny { display: none; }
.xh.is-compact .xh-hearts { font-size: calc(15px * var(--s)); letter-spacing: 1px; }
.xh.is-compact .xh-numbers { grid-template-columns: auto auto; gap: 12px; margin: 6px 0 0; }
.xh.is-compact .xh-numbers > div { padding-left: 10px; }
.xh.is-compact .xh-numbers > div:first-child { padding-left: 0; }
.xh.is-compact .xh-numbers > div:nth-child(2) { border-right: 0; }
.xh.is-compact .xh-numbers > div:nth-child(3) { display: none; }
.xh.is-compact .xh-numbers .xh-tiny { font-size: calc(10px * var(--s)); margin-bottom: 2px; }
.xh.is-compact .xh-numbers strong { font-size: calc(20px * var(--s)); }
.xh.is-compact .xh-numbers em { font-size: calc(12px * var(--s)); }
.xh.is-compact .xh-skill { display: none; }
.xh.is-compact .xh-objectives { right: 8px; top: 8px; width: auto; min-width: calc(140px * var(--s)); padding: 8px 10px; border-radius: 10px; }
.xh.is-compact .xh-objectives > .xh-row .xh-tiny,
.xh.is-compact .xh-resources,
.xh.is-compact .xh-pass,
.xh.is-compact .xh-fct { display: none; }
.xh.is-compact .xh-objectives > .xh-row { justify-content: flex-end; }
.xh.is-compact .xh-sealed { font-size: calc(10px * var(--s)); padding: 3px 6px; }
.xh.is-compact .xh-audit { font-size: calc(13px * var(--s)); gap: 8px; margin-top: 6px; }
.xh.is-compact .xh-audit b { font-size: calc(12px * var(--s)); }
.xh.is-compact .xh-dots i { width: calc(16px * var(--s)); }
.xh.is-compact .xh-boss { top: calc(92px * var(--s)); width: 86%; max-width: 86%; padding: 4px 8px; }
.xh.is-compact .xh-boss-label { font-size: calc(13px * var(--s)); margin-bottom: 4px; }
.xh.is-compact .xh-phase { font-size: calc(10px * var(--s)); }
.xh.is-compact .xh-caption { left: 14px; top: 38%; }
.xh.is-compact .xh-caption-name { font-size: calc(30px * var(--s)); }
.xh.is-compact .xh-bottom-label,
.xh.is-compact .xh-map { display: none; }
/* a phone held sideways: the boss bar fits between the two corner panels */
@media (min-width: 700px) {
  .xh.is-compact .xh-boss { top: 8px; width: 38%; max-width: 38%; }
}

/* ---------- the scene's banners ----------
   While the HUD is up (.sceneWrap.has-xh), the stage banner and the respawn
   notes drop below the boss bar instead of covering it, and on a phone
   below the two corner panels as well. */
.sceneWrap.has-xh .overlayTop { top: calc(100px * var(--xh-s, 1)); }
.sceneWrap.has-xh.xh-compact .overlayTop { top: calc(126px * var(--xh-s, 1)); }
@media (min-width: 700px) {
  .sceneWrap.has-xh.xh-compact .overlayTop { top: 40px; }
}

/* ---------- settings ---------- */
body.a11y-high-contrast .xh-panel { background: #05080fee; border-color: #ffffffaa; }
body.a11y-high-contrast .xh-tiny, body.a11y-high-contrast .xh-pass,
body.a11y-high-contrast .xh-resources, body.a11y-high-contrast .xh-bottom-label { color: #eef3fb; }
body.a11y-large-text .xh { --lt: 1.15; }
@media (prefers-reduced-motion: reduce) {
  .xh-caption, .xh-boss-meter i { transition: none; }
}
body.a11y-reduced-motion .xh-caption, body.a11y-reduced-motion .xh-boss-meter i { transition: none; }
