/* ══════════════════════════════════════════════════════════════
   Component — Action Bar (bottom bar)
   Extracted from shoot/v0.4/style.css + v0.8a overrides
   + shared/stratagem-ui.css (phase-end-cluster, btn-strat)
══════════════════════════════════════════════════════════════ */

/* Hoisted as a CSS var so other chrome (e.g. AI pacing toast) can
   anchor itself relative to the action-bar without hard-coding 48px. */
:root { --action-bar-height: 48px; }

#action-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: var(--action-bar-height);
  background: rgba(8,12,16,.97);
  border-top: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 10px; /* v0.8a override (was 0 12px) */
  gap: 10px; /* v0.8a override (was 8px) */
  z-index: 20;
  backdrop-filter: blur(4px);
}

/* Phase indicator */
.phase-row { display: flex; align-items: center; gap: 0; }
.ph-item {
  display: flex; align-items: center; gap: 4px;
  padding: 2px 6px;
  font: 600 8px/1 'Rajdhani', sans-serif; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text-dis); cursor: default; user-select: none;
}
.ph-item.done   { color: var(--text-muted); }
/* active-faction: phase pill themes to the player whose turn it is */
.ph-item.active { color: var(--active-faction); }
.ph-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .35; }
.ph-item.active .ph-dot { opacity: 1; }
.ph-item.done   .ph-dot { opacity: .5; }
.ph-sep { color: var(--text-dis); font-size: 9px; opacity: .25; user-select: none; }

/* Mode group (NORMAL MOVE / ADVANCE radio toggle) */
.mode-group { display: flex; gap: 0; }
.mode-btn {
  font: 600 11px/1 'Rajdhani', sans-serif; letter-spacing: 1.5px; text-transform: uppercase;
  padding: 0 10px; height: 32px;
  border: 1px solid var(--text-dis);
  background: var(--bg-surface); color: var(--text-muted);
  cursor: pointer; transition: background .12s, color .12s, border-color .12s;
  margin-right: -1px;
  position: relative;
}
.mode-btn:hover   { background: var(--bg-raised); color: var(--text-sec); z-index: 1; }
/* active-faction: mode toggle highlights to the active player */
.mode-btn.active  { background: var(--bg-selected); color: var(--active-faction); border-color: var(--active-faction); z-index: 2; }
.mode-btn:disabled { opacity: .35; cursor: default; }
.mode-btn:disabled:hover { background: var(--bg-surface); color: var(--text-muted); }

/* Mode label */
#status-label {
  font: 700 9px/1 'Rajdhani', sans-serif; letter-spacing: 2px; text-transform: uppercase;
  color: transparent; /* v0.8a override */
  padding: 0 4px;
  min-width: 0; /* v0.8a override (was 90px) */
  flex: 1; /* v0.8a override */
  text-align: left; /* v0.8a override (was center) */
  font-size: 10px; /* v0.8a override */
}
/* active-faction: mode label tracks active player's turn */
#status-label.active-move    { color: var(--active-faction); }
#status-label.active-advance { color: var(--strat); }

/* Confirm / Cancel */
.action-btn {
  height: 32px; min-width: 70px; padding: 0 10px; position: relative;
  font: 700 9px/1 'Rajdhani', sans-serif; letter-spacing: 2px; text-transform: uppercase;
  cursor: pointer; transition: all .15s;
  background: var(--bg-surface); border: 1px solid var(--text-dis); color: var(--text-dis);
}
.action-btn:disabled { opacity: .3; cursor: default; }
/* active-faction: action buttons are part of the active turn's chrome */
.action-btn.active   { background: color-mix(in srgb, var(--active-faction) 8%, transparent); border-color: color-mix(in srgb, var(--active-faction) 50%, transparent); color: var(--active-faction); }
/* active-faction */
.action-btn.confirm-move          { background: color-mix(in srgb, var(--active-faction) 10%, transparent); border: 1px solid color-mix(in srgb, var(--active-faction) 50%, transparent); color: var(--active-faction); }
.action-btn.confirm-move:disabled { background: transparent; border-color: var(--border); color: var(--text-dis); cursor: default; }
.action-btn.cancel-move           { background: rgba(204,32,32,.08); border: 1px solid rgba(204,32,32,.35); color: #cc4444; }
.action-btn.cancel-move:disabled  { background: transparent; border-color: var(--border); color: var(--text-dis); cursor: default; }

/* Hover polish — applies to all action buttons when enabled. Brightens
   the current color + faction-accent glow + subtle 1px lift. Neutral
   across factions via var() tokens. */
/* active-faction: glow themes to active turn */
.action-btn:not(:disabled):hover {
  filter: brightness(1.12);
  box-shadow: 0 0 14px var(--active-faction-glow);
  transform: translateY(-1px);
}
.action-btn.cancel-move:not(:disabled):hover {
  box-shadow: 0 0 14px rgba(204, 32, 32, 0.32);
}
.action-btn:not(:disabled):active { transform: translateY(0); filter: brightness(0.98); }

/* Keyboard shortcut tooltip */
.action-btn[data-shortcut]:hover::after,
.mode-btn[data-shortcut]:hover::after {
  content: '[' attr(data-shortcut) ']';
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  /* active-faction: shortcut tooltip themes to active turn */
  font: 600 9px/1 'Rajdhani', sans-serif; color: var(--active-faction);
  background: rgba(0,0,0,.8); padding: 2px 4px; white-space: nowrap; pointer-events: none;
}

/* active-faction: shoot button states ride active turn */
#btn-shoot-select.active,
#btn-confirm-shot.active,
#btn-dice.active { border-color: var(--active-faction); color: var(--active-faction); }
/* destructive: clear-shot is a CANCEL action — a "pull back the
   declaration" affordance — so it paints in --destructive (red),
   faction-independent. Mockups had it as --faction-b which only
   happened to look right because the legacy palette had B = red. */
#btn-clear-shot.active { border-color: var(--destructive); color: var(--destructive); }
#btn-end-shoot { min-width: 154px; } /* v0.8a */

/* Phase-end cluster (from shared/stratagem-ui.css) */
.phase-end-cluster {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px; /* v0.8a override (was 10px in stratagem-ui.css) */
  flex-shrink: 0;
}
.phase-end-cluster .btn-cta { margin-left: 0; }
.phase-end-divider {
  width: 1px;
  height: 24px;
  background: linear-gradient(180deg, rgba(204,136,0,0), rgba(204,136,0,.34), rgba(204,136,0,0));
  box-shadow: 0 0 10px rgba(204,136,0,.12);
}

/* Stratagem button (from shared/stratagem-ui.css — v0.8a override wins) */
.btn-strat {
  height: 32px;
  min-width: 126px;
  padding: 0 14px;
  background: rgba(204,136,0,.12);
  border: 1px solid var(--strat);
  color: var(--strat);
  font: 700 10px/1 'Rajdhani', sans-serif;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .16s ease;
}
.btn-strat:hover {
  background: rgba(204,136,0,.2);
  border-color: var(--strat);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(204,136,0,.15);
}
.btn-strat:active { transform: scale(.97); box-shadow: none; }

/* End phase CTA */
/* active-faction: end-phase CTA is the "your turn" call-to-action */
.btn-cta {
  font: 700 11px/1 'Rajdhani', sans-serif; letter-spacing: 1.5px; text-transform: uppercase;
  padding: 0 14px; height: 32px;
  background: var(--active-faction); color: #080c10;
  border: 1px solid var(--active-faction); cursor: pointer;
  transition: background .12s, border-color .12s, transform .12s, box-shadow .12s;
  margin-left: auto;
}
.btn-cta:hover  {
  background: var(--active-faction);
  border-color: var(--active-faction);
  filter: brightness(1.15);
  box-shadow: 0 4px 14px var(--active-faction-glow);
}
.btn-cta:active { transform: scale(.97); box-shadow: none; background: color-mix(in srgb, var(--active-faction) 60%, #000); filter: brightness(0.95); }

/* Disabled / blocked-by-error visual treatment. error-banner-registry
   sets `.blocked-by-error` on Confirm + End buttons whenever a red
   banner gates the phase; pair it with the existing :disabled visual so
   the player reads "this button is dead until I fix the banner." */
.btn-cta:disabled,
.action-btn:disabled {
  opacity: .3;
  cursor: not-allowed;
}
.btn-cta.blocked-by-error,
.action-btn.blocked-by-error {
  opacity: .35;
  cursor: not-allowed;
  filter: saturate(.4);
}

/* Action bar separator */
.ab-sep { width: 1px; height: 32px; background: var(--border); margin: 0 2px; flex-shrink: 0; }

/* ──────────────────────────────────────────────────────────────
   AI-turn gate
   When the active (or fight-phase activating) faction is AI-
   controlled, scene-registry.refreshFactionUI() adds
   `body.ai-turn-active`. The user must not be able to interrupt
   or manually advance the AI's turn, so every phase-control
   button in the action bar is force-disabled here.

   Covers: every per-phase END CTA (btn-end / -cmd / -shoot /
   -charge / -fight), the generic confirm/cancel buttons used
   by move + scout-move + charge + fight, and any mode-group
   button (move / advance / disembark / embark / etc.). Selectors
   target the button classes used by scene-registry rather than
   id-listing every phase button so it stays correct as new
   buttons are added.
   ────────────────────────────────────────────────────────────── */
body.ai-turn-active #action-bar .btn-cta,
body.ai-turn-active #action-bar .action-btn,
body.ai-turn-active #action-bar .mode-btn,
body.ai-turn-active #action-bar .btn-strat {
  pointer-events: none;
  opacity: 0.4;
  filter: grayscale(0.4);
}

/* Human-agency window inside an AI turn (defender pile-in, HI placement,
   overwatch dice, manual saves). Scene-registry toggles
   `body.human-agency-active` whenever `_humanAgencyDuringAiTurn` is true.
   END buttons stay locked — only Confirm/Cancel re-enable so the player
   can act on the open prompt without skipping the AI's remaining turn. */
body.ai-turn-active.human-agency-active #action-bar .action-btn {
  pointer-events: auto;
  opacity: 1;
  filter: none;
}
