/* web/hud.css
   The bar under the game, drawn by web/hud.js and the modules in web/hud/. Its
   look is AB's web client's HUD, which Joseph chose as the target: near-black,
   Exo 2, bars with the reading centred and tinted to match, and tags beside
   them. Every colour is set in the scripts.

   Two sides, yours and your target's, each with the same slots. The page's Bar
   layout option sets data-bar-layout on the page: Frames draws each side as a
   frame with its name set into the top edge; Two lines draws you on one line
   and your target under you, column for column; Prompt lines, the default,
   draws them as two lines of text; Off shows no bar. Frames is also what the
   page draws with no layout set, which is why its rules read "not lines".
   Every size reads --hud-s, the Bar size option. */

:root { --hud-s: 1; }

#hud {
  flex: none; background: #050505; border-top: 2px solid #444;
  font-family: "Exo 2", sans-serif; font-size: calc(11px * var(--hud-s));
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: opacity .3s ease;
}
#hud[hidden] { display: none !important; }
/* Off: no bar under the game, for a player who shows the Player and Target
   panels instead. */
:root[data-bar-layout="off"] #hud { display: none !important; }
#hud.stale { opacity: .45; }
#hud [hidden] { display: none !important; }

/* ---- the slots, the same in both layouts ------------------------------- */
#hud .side { min-width: 0; }
#hud .legend { display: flex; flex-wrap: wrap; gap: 0 calc(8px * var(--hud-s)); align-items: baseline;
  min-width: 0; }
/* The name never shrinks to make room for the line beside it; only a name too
   long for the whole edge is cut. Even a fraction of a pixel of shrinking cuts
   a name that fits. */
#hud .legend .nm { font-weight: 700; font-size: calc(13px * var(--hud-s)); color: #ddd;
  flex: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#hud .legend .sb { color: #8a8a8a; flex: 0 1 auto; min-width: 0; }
#hud .side.it .legend .nm { color: #ff8844; }

/* A slot holds its place empty, as the dashed outline of a bar. */
#hud .slot { min-width: 0; height: calc(24px * var(--hud-s)); }
#hud .slot:empty { border: 1px dashed #2c2c2c; border-radius: calc(3px * var(--hud-s)); }

#hud .s-mid {
  display: flex; align-items: center; gap: calc(6px * var(--hud-s));
  min-width: 0; min-height: calc(18px * var(--hud-s));
}
/* Helpful on the left, the rest on the right: web/hud/effects.js gives each
   half its width, half each unless one needs less. */
#hud .s-fx {
  display: flex; gap: calc(6px * var(--hud-s));
  min-width: 0; min-height: calc(22px * var(--hud-s));
}
/* Each half keeps to one line; web/hud/effects.js hides what will not fit and
   counts it. The other half's first tag takes the slack, so its tags sit at the
   right and overflow the way a measure can see. */
#hud .fx {
  flex: 1 1 0; display: flex; align-items: center; gap: calc(4px * var(--hud-s));
  flex-wrap: nowrap; overflow: hidden; min-width: 0;
}
#hud .fx-harm > :first-child { margin-left: auto; }

#hud .info {
  color: #aaa; font-size: calc(12px * var(--hud-s)); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
#hud .info .who { color: #ddd; font-weight: 600; }

/* ---- Frames ------------------------------------------------------------- */
:root:not([data-bar-layout="lines"]) #hud {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: calc(10px * var(--hud-s));
  padding: calc(13px * var(--hud-s)) calc(6px * var(--hud-s)) calc(5px * var(--hud-s));
}
:root:not([data-bar-layout="lines"]) #hud .side {
  position: relative; display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas: "lg lg" "hp turn" "mid mid" "fx fx";
  gap: calc(4px * var(--hud-s)) calc(6px * var(--hud-s));
  border: 1px solid #3a3a3a; border-radius: calc(5px * var(--hud-s)); background: #0b0b0b;
  padding: calc(7px * var(--hud-s)) calc(8px * var(--hud-s)) calc(6px * var(--hud-s));
}
:root:not([data-bar-layout="lines"]) #hud .side.none { opacity: .4; }
:root:not([data-bar-layout="lines"]) #hud .legend {
  grid-area: lg; justify-self: start; position: relative; z-index: 1;
  top: calc(-20px * var(--hud-s)); margin: 0 0 calc(-19px * var(--hud-s)) calc(2px * var(--hud-s));
  line-height: calc(15px * var(--hud-s)); max-width: 100%; box-sizing: border-box;
  background: #050505; padding: 0 calc(6px * var(--hud-s));
}
:root:not([data-bar-layout="lines"]) #hud .s-hp { grid-area: hp; }
:root:not([data-bar-layout="lines"]) #hud .s-turn { grid-area: turn; }
:root:not([data-bar-layout="lines"]) #hud .s-mid { grid-area: mid; }
:root:not([data-bar-layout="lines"]) #hud .s-fx { grid-area: fx; }
/* A frame's pools share their line, a little shorter than the bars above. */
:root:not([data-bar-layout="lines"]) #hud .s-mid .bar.pool { flex: 1 1 0; height: calc(18px * var(--hud-s)); }
:root:not([data-bar-layout="lines"]) #hud .s-mid .bar.pool .text { font-size: calc(11px * var(--hud-s)); }

/* ---- Two lines ---------------------------------------------------------- */
/* Name, health, a column for each pool, the turn slot, effects. The middle
   line's own box steps aside, so each pool -- or a Pulsar's Density -- is a
   column of its own as tall as health; never more than two, since a Pulsar has
   no pool to spend. The target's line puts who it is attacking across both. */
:root[data-bar-layout="lines"] #hud {
  display: grid; align-items: center;
  grid-template-columns: minmax(0, .7fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr)
    minmax(0, 1fr) minmax(0, 1.6fr);
  gap: calc(4px * var(--hud-s)) calc(8px * var(--hud-s));
  padding: calc(4px * var(--hud-s)) calc(6px * var(--hud-s));
}
:root[data-bar-layout="lines"] #hud .side { display: contents; }
:root[data-bar-layout="lines"] #hud .side.none { display: none; }
:root[data-bar-layout="lines"] #hud .legend .sb { display: none; }
:root[data-bar-layout="lines"] #hud .s-mid { display: contents; }
:root[data-bar-layout="lines"] #hud .side.me > *,
:root[data-bar-layout="lines"] #hud .side.me > .s-mid > * { grid-row: 1; }
:root[data-bar-layout="lines"] #hud .side.it > *,
:root[data-bar-layout="lines"] #hud .side.it > .s-mid > * { grid-row: 2; }
:root[data-bar-layout="lines"] #hud .legend { grid-column: 1; }
:root[data-bar-layout="lines"] #hud .s-hp { grid-column: 2; }
:root[data-bar-layout="lines"] #hud .s-mid > :nth-child(1) { grid-column: 3; }
:root[data-bar-layout="lines"] #hud .s-mid > :nth-child(2) { grid-column: 4; }
:root[data-bar-layout="lines"] #hud .side.it .s-mid > .info { grid-column: 3 / 5; }
:root[data-bar-layout="lines"] #hud .s-turn { grid-column: 5; }
:root[data-bar-layout="lines"] #hud .s-fx { grid-column: 6; }

/* ---- Prompt lines ------------------------------------------------------- */
/* Two lines of text in the game's font (web/hud/prompt_lines.js) in place of
   the two sides: you, then your target. Every reading is a segment after a dim
   bar; paint() sets a segment's colour and also a background and border meant
   for a bar, which only an !important takes away. Each line keeps to one line:
   the effects take what is left and count what does not fit. A line holds its
   height while still empty, so the bar never grows as it fills. */
#hud .pl { display: none; }
:root[data-bar-layout="prompt"] #hud {
  display: block; padding: calc(3px * var(--hud-s)) calc(14px * var(--hud-s)) calc(5px * var(--hud-s));
}
:root[data-bar-layout="prompt"] #hud .side { display: none; }
:root[data-bar-layout="prompt"] #hud .pl {
  display: block; font-family: var(--mono); font-size: calc(var(--mono-size) * var(--hud-s));
  line-height: 1.55; color: #ddd; -webkit-font-smoothing: auto; -moz-osx-font-smoothing: auto;
}
#hud .pl-line {
  display: flex; align-items: baseline; white-space: nowrap; overflow: hidden;
  min-height: 1.55em;
}
#hud .pl-name { flex: 0 1 auto; max-width: 40%; overflow: hidden; text-overflow: ellipsis; font-weight: 700; margin-right: .8em; }
#hud .pl-line.it .pl-name { color: #ff8844; }
#hud .pl-line.it.none .pl-name { color: #666; font-weight: 400; }
#hud .pl-slot { display: contents; }
#hud .pl-seg { flex: none; }
#hud .pl-seg::before, #hud .pl-fx > *::before { content: "|"; color: #444; padding: 0 .5em; }
#hud .pl-hp > .pl-seg::before { content: none; }
#hud .pl-aim .who { color: #ddd; font-weight: 700; }
#hud .pl-aim { color: #aaa; }
#hud .pl-fx { display: flex; flex: 1 1 0; min-width: 0; overflow: hidden; }
#hud .pl-fx > * { flex: none; }
#hud .pl-fx > .chip.more {
  display: inline; height: auto; padding: 0; background: none; border: none;
  font-size: 1em; color: #888;
}
:root[data-target-hp="exact"] #hud .pl .percent,
:root:not([data-target-hp="exact"]) #hud .pl .exact { display: none; }

/* ---- bars --------------------------------------------------------------- */
#hud .bar {
  position: relative; width: 100%; min-width: 0; height: calc(24px * var(--hud-s));
  border: 1px solid; border-radius: calc(3px * var(--hud-s)); overflow: hidden;
}
/* The fill slides to its new width rather than stepping, so a hit can be
   watched landing. */
#hud .fill {
  position: absolute; top: 0; bottom: 0; left: 0; width: 0;
  border-radius: calc(3px * var(--hud-s)); transition: width .3s ease-out;
}
/* A turn bar is moved every frame by web/hud/atb.js, so a slide would only
   make it lag behind the clock. */
#hud .bar.live .fill { transition: none; }
/* Whole-pixel sizes and a HARD one-pixel outline. AB's 10pt is 13.33px, which
   lands letters between pixels, and its 4px blurred shadow put a soft halo
   round every letter -- together they read as low resolution. The outline is
   also what keeps a reading legible over its own fill: AB's blue fill ends in
   almost exactly the blue of its text. */
#hud .text {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(13px * var(--hud-s)); font-weight: 600; white-space: nowrap; color: #fff;
  overflow: hidden;
  text-shadow: -1px 0 0 #000, 1px 0 0 #000, 0 -1px 0 #000, 0 1px 0 #000;
}
/* The page's Target option shows your target's reading as a percent or as
   exact numbers. */
:root[data-target-hp="exact"] #hud .bar.target .percent,
:root:not([data-target-hp="exact"]) #hud .bar.target .exact { display: none; }

/* Every bar's colours -- fill, reading, border and the dark behind the fill --
   are set by web/hud.js, from its one table: health and Rage fade as they
   empty and fill, and any other pool takes purple or blue by position. */

/* ---- tags --------------------------------------------------------------- */
#hud .chip {
  display: flex; align-items: center; flex: none;
  height: calc(22px * var(--hud-s)); padding: 0 calc(8px * var(--hud-s));
  background: rgb(80, 80, 80); border: 1px solid #555; border-radius: calc(4px * var(--hud-s));
  font-size: calc(12px * var(--hud-s)); color: #ccc; white-space: nowrap;
}
#hud .chip.more { background: #1c1c1c; border-color: #555; color: #ccc; }
/* An effect with a colour of its own is a dark tag edged and lettered in it;
   web/hud/effects.js sets the three colours. */
#hud .chip.effect.lit { font-weight: 600; }
