/* BROWNOUT tactical battle. Palette, faces and sizes are the HUD's custom properties (src/data/hud.js via hud.js);
   this file only lays the fight out. Type floor 0.875rem, as the HUD's. Everything wraps, so a half-screen window
   holds the whole dock. State arrives as data-* attributes (phase, mode, side, tone, sel, on, dead, tip) and aria-disabled. */

/* In a fight the first-person instruments step aside; the news and the power readout stay. */
html[data-mode='battle'] #hud .cross,
html[data-mode='battle'] #hud .prompt,
html[data-mode='battle'] #hud .progress,
html[data-mode='battle'] #hud .resume,
html[data-mode='battle'] #hud .now,
html[data-mode='battle'] #hud .dock { display: none; }
/* The news stands where it always does, the top right corner, out of the left edge, which is the side's: a line of news and the target do not meet. */

/* The page is two rows: the side (the target) above, the dock under it. Neither can cover the other, however tall
   the dock grows. The plates, floats and banner stand out of that flow over the whole of it. */
.battle {
  --side: min(15rem, 38vw);
  position: absolute; inset: 0; box-sizing: border-box; padding: var(--edge);
  display: grid; grid-template-rows: minmax(0, 1fr) auto;
  pointer-events: none; text-shadow: 0 0 .5em var(--shade), 0 0 .15em var(--shade);
}
.battle button { pointer-events: auto; }

.b-bar { position: relative; height: 3px; background: var(--rule); }
.b-bar > i { position: absolute; inset: 0; background: var(--ink); transform-origin: left; transform: scaleX(0); transition: transform .2s linear; }
.b-pips { font-size: .875rem; letter-spacing: .3em; color: var(--ink-dim); }

/* ── turn banner: thrown in, held, gone ──────────────────────────────────────────────────────────── */
.b-banner {
  position: absolute; left: 50%; top: 24%;
  transform: translateX(-50%);
  text-align: center; white-space: nowrap;
  opacity: 0;
}
.b-banner.b-show { animation: b-banner var(--b-hold) cubic-bezier(.05, .9, .15, 1) forwards; }
.b-big {
  font: 900 clamp(2.4rem, 9vh, 6rem) / .9 var(--font-display); font-stretch: condensed;
  letter-spacing: .08em; text-indent: .08em; text-transform: uppercase;
}
.b-banner[data-side='hostile'] .b-big { color: var(--red); }
.b-banner[data-side='neutral'] .b-big { color: var(--amber); }
.b-sub { margin-top: .6rem; font-size: 1rem; letter-spacing: .4em; text-indent: .4em; text-transform: uppercase; color: var(--ink-dim); }
@keyframes b-banner {
  0% { opacity: 0; transform: translateX(-50%) scale(1.12); filter: blur(10px); }
  12% { opacity: 1; transform: translateX(-50%) scale(1); filter: blur(0); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(1.02); }
}

/* ── over the bodies ─────────────────────────────────────────────────────────────────────────────── */
.b-plates, .b-floats { position: absolute; inset: 0; overflow: hidden; }
/* A plate is placed by its top left corner (view.js stacks plates that would overlap). The dark's keep their name and a thin bar;
   the squad's and the bystanders' stand on a dark ground of their own, so they read on lit floor and on black alike. */
.b-plate { position: absolute; left: 0; top: 0; display: grid; gap: .2rem; justify-items: center; width: max-content; min-width: 5rem; }
.b-plate .b-bar { width: 100%; }
.b-plate[data-side='hostile'] .b-bar > i { background: var(--red); }
.b-plate[data-side='hostile'][data-sel='true'] .b-bar { outline: 1px solid var(--ink); outline-offset: 2px; }
.b-pname { font-size: .875rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-dim); white-space: nowrap; }
.b-plate[data-side='squad'], .b-plate[data-side='neutral'] { gap: .25rem; padding: .3rem .5rem .35rem; border: 1px solid var(--ink-faint); background: var(--veil); }
.b-plate[data-side='squad'] .b-pname, .b-plate[data-side='neutral'] .b-pname { font-size: .95rem; font-weight: 700; letter-spacing: .1em; color: var(--ink); }
.b-plate[data-side='squad'] .b-bar, .b-plate[data-side='neutral'] .b-bar { box-sizing: border-box; height: .5rem; border: 1px solid var(--ink-dim); background: var(--shade); }
.b-plate[data-side='neutral'] .b-bar > i { background: var(--amber); }
.b-plate .b-pips { color: var(--ink); line-height: 1; }
/* The fighter whose move it is says what is in their hands, and how they stand. */
.b-phands, .b-pstance { max-width: 13rem; font-size: .875rem; text-align: center; overflow-wrap: anywhere; }
.b-phands { color: var(--ink-dim); }
.b-pstance { letter-spacing: .08em; text-transform: uppercase; color: var(--amber); }
.b-phands:empty, .b-pstance:empty { display: none; }
/* The fighter whose move it is: a bright frame and a mark pointing down at the head. */
.b-plate[data-side='squad'][data-sel='true'] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.b-plate[data-side='squad'][data-sel='true']::after { content: '▼'; position: absolute; left: 50%; bottom: -1.15rem; transform: translateX(-50%); font-size: .875rem; line-height: 1; color: var(--ink); }

.b-float {
  position: absolute;
  font: 800 1.35rem / 1 var(--font-display); font-stretch: condensed; letter-spacing: .06em; white-space: nowrap;
  transform: translate(-50%, -100%);
  animation: b-rise 1.7s ease-out forwards;
}
.b-float[data-tone='red'] { color: var(--red); font-size: 1.7rem; }
.b-float[data-tone='amber'] { color: var(--amber); }
.b-float[data-tone='dim'] { color: var(--ink-dim); }
/* The number of the blow that opened the fight in the player's own eyes, over their own head as the camera leaves it. */
.b-float[data-opening='true'] { color: var(--red); font-size: clamp(2.2rem, 7vh, 4rem); }
@keyframes b-rise {
  0% { opacity: 0; transform: translate(-50%, -40%); }
  12% { opacity: 1; transform: translate(-50%, -100%); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -280%); }
}

/* ── the left edge: what a blow is worth ──────── */
.b-side {
  grid-row: 1; justify-self: start; align-self: start;
  display: grid; gap: .8rem; width: var(--side); max-height: 100%; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--ink-faint) transparent;
}
/* ── the target: what a blow is worth, in points that add up to the chance ───────────────────────── */
.b-target { display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; padding: .8rem 1rem; border: 1px solid var(--rule); background: var(--veil); }
.b-tname { align-self: end; font-size: .95rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-dim); }
.b-tlabel { font-size: .875rem; color: var(--ink-dim); }
.b-thit { grid-row: 1 / 4; grid-column: 2; font: 800 var(--value) / 1 var(--font-display); text-align: right; }
.b-tcrit { font-size: .875rem; letter-spacing: .1em; text-transform: uppercase; color: var(--amber); }
.b-parts { grid-column: 1 / -1; margin: .4rem 0 0; padding: .4rem 0 0; list-style: none; border-top: 1px solid var(--rule); }
.b-parts li { display: flex; justify-content: space-between; gap: 1rem; font-size: .95rem; padding: .1rem 0; }
.b-parts .b-pcap { justify-content: flex-end; font-size: .875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-dim); }
.b-plabel { color: var(--ink-dim); }
.b-pval { font-weight: 700; }
.b-limbs { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.b-limbs:empty { display: none; }
.b-limb { padding: .3rem .6rem; letter-spacing: .08em; }
.b-limb[data-on='true'] { background: var(--ink); color: var(--black); }
/* The side scrolls when the squad and the target are more than the room above the dock; the button that fires stays in view. */
.b-fire { grid-column: 1 / -1; position: sticky; bottom: 0; margin-top: .4rem; background: var(--black); border-color: var(--red); color: var(--red); }
.b-fire:hover:not(:disabled) { background: var(--red); color: var(--black); }

/* ── the dock: what can be done, and what the keys are ────────────────────────────────────────────── */
/* The one place to look at on the bar is the action, so an action that cannot be taken is only dimmed: why is on the hint line,
   for the one the pointer is over or that refused a press. (It is not `disabled`, which would keep the pointer's word from it.) */
.b-dock { grid-row: 2; position: relative; display: grid; justify-items: center; gap: .5rem; }
.b-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem; max-width: 52rem; }
.b-act {
  display: flex; align-items: center; gap: .55rem;
  min-width: 8.5rem; padding: .45rem .7rem;
  background: var(--veil); text-align: left;
}
.b-act .b-key { min-width: 1.8rem; padding: .05rem .4rem; border: 1px solid var(--ink-dim); text-align: center; font-weight: 700; }
.b-act .b-label { font-size: .875rem; }
.b-act[data-on='true'] { border-color: var(--ink); background: var(--wash); }
.b-act[aria-disabled='true'] { opacity: .55; cursor: default; }
.b-act[aria-disabled='true']:hover { background: var(--veil); color: var(--ink); }

/* ── the weapons a swap offers: one row each, its key, its name, what it does ──────────────────────── */
/* Over the dock, in the middle of the window and no wider than leaves the side clear down the left edge, however the window is cut. */
.b-swap {
  position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%); margin-bottom: .8rem;
  width: min(40rem, calc(100vw - 2 * (var(--side) + 2 * var(--edge)))); box-sizing: border-box;
  display: grid; gap: .5rem; padding: .8rem 1rem; border: 1px solid var(--rule); background: var(--veil);
}
.b-stitle { font-size: .875rem; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-dim); }
.b-slist { display: grid; gap: .3rem; max-height: 38vh; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--ink-faint) transparent; }
.b-weapon { display: grid; grid-template-columns: 1.8rem minmax(0, 1fr); align-items: center; gap: .1rem .7rem; padding: .45rem .7rem; text-align: left; letter-spacing: normal; text-transform: none; background: var(--veil); }
.b-weapon .b-key { grid-row: 1 / 3; padding: .05rem 0; border: 1px solid var(--ink-dim); text-align: center; font-weight: 700; }
.b-weapon .b-key:empty { visibility: hidden; }
.b-wname { font-size: .95rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.b-wstats { font-size: .875rem; letter-spacing: .02em; color: var(--ink-dim); overflow-wrap: anywhere; }
.b-weapon:hover:not(:disabled) .b-wstats { color: inherit; }

/* ── the hint line: the keys as chips, or, over an action, what it does and why it cannot be taken; with no light on the ground, that the fighter cannot see ── */
/* All three stand in the one place, so the line is as tall as the tallest and does not jump. */
.b-hint { display: grid; justify-items: center; max-width: 100%; padding: .35rem .8rem; background: var(--veil); }
.b-chips, .b-tip, .b-dark { grid-area: 1 / 1; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; font-size: .875rem; }
.b-chips { gap: .3rem 1.1rem; }
.b-chip { display: inline-flex; align-items: center; gap: .45rem; color: var(--ink-dim); }
.b-chip .b-key, .b-dark .b-key { padding: .05rem .4rem; border: 1px solid var(--ink-dim); font-weight: 700; color: var(--ink); }
.b-tip { gap: .2rem 1rem; }
.b-tipname { font-weight: 700; }
.b-tipwhat { color: var(--ink-dim); }
.b-tipwhy { color: var(--amber); }
.b-dark { gap: .2rem .5rem; color: var(--ink); }
.b-dark > :first-child { font-weight: 700; color: var(--amber); }
.b-dark .b-key:empty { display: none; }
.b-hint[data-tip='on'] .b-chips, .b-hint[data-tip='on'] .b-dark, .b-hint[data-dark='on'] .b-chips,
.b-hint:not([data-dark='on']) .b-dark, .b-hint:not([data-tip='on']) .b-tip { visibility: hidden; }
.battle:not([data-phase='squad']) .b-actions, .battle:not([data-phase='squad']) .b-hint { visibility: hidden; }

@media (max-width: 760px) {
  .b-act { min-width: 0; flex: 1 1 7.5rem; }
}
