/* ── Shared HUD plate (ability bar + stats panel) ────────────────── */

:root {
  --hud-h: 90px; /* collapsed height shared by the ability bar and stats panel */
}

.ability-bar,
.stats-panel {
  background: linear-gradient(180deg, rgba(22, 25, 40, 0.94) 0%, rgba(10, 11, 20, 0.96) 100%);
  border: 1px solid rgba(130, 140, 180, 0.22);
  border-top-color: rgba(240, 192, 64, 0.28);
  border-radius: 8px;
  box-shadow:
    0 6px 24px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -6px 14px rgba(0, 0, 0, 0.35);
}

/* ── Ability Bar ─────────────────────────────────────────────────── */

.ability-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  height: var(--hud-h);
  box-sizing: border-box;
  padding: 0 12px;
  pointer-events: auto;
}

/* ── Slot ────────────────────────────────────────────────────────── */

.ability-slot {
  position: relative;
  width: 68px;
  height: 68px;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(90, 100, 140, 0.45);
  background: #0c0e18;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.5);
  cursor: default;
  flex-shrink: 0;
  transition: border-color 0.15s;
}

.ability-slot:hover {
  border-color: rgba(240, 192, 64, 0.6);
}

/* ── Passive tile (left of Q — smaller, no cooldown or key) ──────── */

.ability-slot.passive {
  width: 44px;
  height: 44px;
  align-self: center;
  margin-right: 3px;
  border-color: rgba(240, 192, 64, 0.35);
}

.ability-slot.passive .ability-icon-fallback {
  font-size: 18px;
}

.passive-tag {
  position: absolute;
  bottom: 1px;
  right: 1px;
  padding: 0 3px;
  border-radius: 2px;
  font-size: 9px;
  font-weight: 800;
  color: rgba(240, 192, 64, 0.9);
  background: rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

/* Condition met (elemental_warrior at full rage: crits are live). */
.ability-slot.passive.passive-active {
  border-color: rgba(255, 140, 40, 0.95);
  box-shadow: 0 0 10px rgba(255, 120, 30, 0.75), inset 0 0 8px rgba(255, 140, 40, 0.45);
}

/* ── Summoner spell column (Flash/Backport — small, stacked) ─────── */

.summoner-col {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 68px;
  gap: 4px;
  margin-left: 3px;
  flex-shrink: 0;
}

.ability-slot.summoner {
  width: 32px;
  height: 32px;
  border-radius: 4px;
}

.ability-slot.summoner .cd-text {
  font-size: 10px;
  letter-spacing: -0.3px;
  align-items: flex-start;
  padding-top: 4px;
}

.ability-slot.summoner .keybind {
  font-size: 8px;
  padding: 0 2px;
  bottom: 1px;
  right: 1px;
  border-radius: 2px;
}

/* Hide the keybind chip while a summoner spell counts down — the tiny slot
   can't fit both, and the countdown is the information that matters. */
.ability-slot.summoner.on-cooldown .keybind {
  display: none;
}

/* ── Icon ────────────────────────────────────────────────────────── */

.ability-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  transition: filter 0.2s;
}

/* ── Cooldown overlay (drains from top down) ─────────────────────── */

.cd-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: rgba(0, 0, 0, 0.72);
  pointer-events: none;
}

/* ── Cooldown countdown text ─────────────────────────────────────── */

.cd-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
  pointer-events: none;
  opacity: 0;
  letter-spacing: -0.5px;
}

/* ── Keybind badge (chip, bottom-right like classic MOBAs) ───────── */

.keybind {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 10px;
  font-weight: 700;
  color: #f0c040;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(240, 192, 64, 0.35);
  border-radius: 3px;
  padding: 1px 4px;
  pointer-events: none;
  text-transform: uppercase;
  line-height: 1.2;
}

/* ── On-cooldown state (ability NOT usable) ──────────────────────── */

.ability-slot.on-cooldown .ability-icon {
  filter: saturate(0.35) brightness(0.7);
}

.ability-slot.on-cooldown .cd-text {
  opacity: 1;
}

/* ── Rage-not-ready state (ultimate locked until rage is full) ───── */

.ability-slot.rage-not-ready .ability-icon {
  filter: saturate(0.25) brightness(0.55);
}

.ability-slot.rage-not-ready {
  border-color: rgba(180, 40, 40, 0.5);
}

/* ── Unskilled state (ability not yet leveled) ───────────────────── */

.ability-slot.unskilled .ability-icon {
  filter: saturate(0) brightness(0.4);
}

.ability-slot.unskilled {
  border-color: rgba(100, 100, 100, 0.3);
}

/* ── Stage-active state (recast window — ability IS usable) ──────── */

.ability-slot.stage-active {
  border-color: #f0a030;
  box-shadow: 0 0 8px 2px rgba(240, 160, 48, 0.5);
  animation: stage-pulse 1s ease-in-out infinite;
}

.ability-slot.stage-active .ability-icon {
  filter: none; /* full brightness */
}

.ability-slot.stage-active .cd-text {
  opacity: 1;
  color: #f0c040;
  font-size: 16px;
  text-shadow: 0 0 6px rgba(240, 160, 48, 0.9);
}

@keyframes stage-pulse {
  0%, 100% { box-shadow: 0 0 6px 1px rgba(240, 160, 48, 0.4); }
  50%       { box-shadow: 0 0 12px 4px rgba(240, 160, 48, 0.7); }
}

/* ── Level pips (rank notches along the bottom-left edge) ────────── */

.level-pips {
  position: absolute;
  bottom: 3px;
  left: 3px;
  display: flex;
  justify-content: flex-start;
  gap: 2px;
  pointer-events: none;
}

.level-pip {
  width: 6px;
  height: 3px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(0, 0, 0, 0.55);
  flex-shrink: 0;
}

.level-pip.filled {
  background: linear-gradient(180deg, #ffe08a, #d9a832);
  border-color: rgba(0, 0, 0, 0.7);
  box-shadow: 0 0 3px rgba(240, 192, 64, 0.55);
}

/* ── Stack badge (e.g. OnFire 0/5 → 5/5) ─────────────────────────── */

.stack-badge {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 11px;
  font-weight: 800;
  color: #ffd98a;
  text-shadow: 0 1px 4px rgba(0,0,0,0.95), 0 0 3px rgba(0,0,0,0.8);
  pointer-events: none;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(240, 140, 40, 0.35);
  letter-spacing: 0.3px;
}

.stack-badge.ready {
  color: #fffaf0;
  background: rgba(255, 80, 20, 0.78);
  border-color: rgba(255, 220, 120, 0.9);
  box-shadow: 0 0 6px rgba(255, 120, 40, 0.8);
  animation: stack-ready-pulse 0.9s ease-in-out infinite;
}

@keyframes stack-ready-pulse {
  0%, 100% { box-shadow: 0 0 4px rgba(255, 120, 40, 0.6); }
  50%      { box-shadow: 0 0 10px rgba(255, 160, 60, 1.0); }
}

/* Charging (stacks < max): icon is slightly dim to signal not-yet-ready */
.ability-slot.stacks-charging:not(.on-cooldown):not(.buff-active) .ability-icon {
  filter: saturate(0.75) brightness(0.9);
}

/* Ready (stacks == max, off cd): icon bright with warm ring */
.ability-slot.stacks-ready {
  border-color: #ff9030;
  box-shadow: 0 0 8px 2px rgba(255, 140, 40, 0.65);
  animation: stacks-ready-border 0.9s ease-in-out infinite;
}

.ability-slot.stacks-ready .ability-icon {
  filter: brightness(1.15) saturate(1.2);
}

@keyframes stacks-ready-border {
  0%, 100% { box-shadow: 0 0 6px 1px rgba(255, 140, 40, 0.5); }
  50%      { box-shadow: 0 0 14px 4px rgba(255, 160, 60, 0.85); }
}

/* ── Buff timer text (countdown while self-buff is active) ───────── */

.buff-timer {
  position: absolute;
  bottom: 14px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  color: #ffe6a0;
  text-shadow: 0 0 6px rgba(255, 120, 40, 1), 0 1px 3px rgba(0,0,0,0.9);
  pointer-events: none;
  letter-spacing: 0.5px;
}

.ability-slot.buff-active {
  border-color: #ff6020;
  box-shadow: 0 0 10px 3px rgba(255, 90, 20, 0.75), inset 0 0 14px rgba(255, 80, 0, 0.35);
  animation: buff-active-pulse 0.6s ease-in-out infinite;
}

.ability-slot.buff-active .ability-icon {
  filter: brightness(1.25) saturate(1.35) drop-shadow(0 0 4px rgba(255, 120, 40, 0.9));
}

@keyframes buff-active-pulse {
  0%, 100% { box-shadow: 0 0 8px 2px rgba(255, 90, 20, 0.6), inset 0 0 10px rgba(255, 80, 0, 0.3); }
  50%      { box-shadow: 0 0 16px 5px rgba(255, 140, 40, 1.0), inset 0 0 18px rgba(255, 100, 0, 0.5); }
}

/* ── Tooltip ─────────────────────────────────────────────────────── */

#ability-tooltip {
  position: fixed;
  width: 220px;
  background: rgba(8, 8, 18, 0.96);
  border: 1px solid rgba(240, 192, 64, 0.35);
  border-radius: 8px;
  padding: 10px 12px;
  pointer-events: auto;
  box-shadow: 0 6px 24px rgba(0,0,0,0.7);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 100;
}

#ability-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

/* A faded-out tooltip is still a 220px box sitting over the map. Without this it
   keeps swallowing clicks — the player right-clicks to walk somewhere and
   nothing happens, with nothing visible to explain why. */
#ability-tooltip:not(.visible) {
  pointer-events: none;
}

.tooltip-name {
  font-size: 13px;
  font-weight: 700;
  color: #f0c040;
  margin-bottom: 5px;
  line-height: 1.2;
}

.tooltip-desc {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.45;
  margin-bottom: 6px;
}

.tooltip-cooldown {
  font-size: 11px;
  color: rgba(200, 220, 255, 0.6);
  font-weight: 600;
}

/* ── Tooltip additions ───────────────────────────────────────────── */

#ability-tooltip {
  width: auto;
  min-width: 220px;
  max-width: 280px;
}

/* Level badge — hoverable to expand level table */
.tooltip-level {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: rgba(150, 210, 255, 0.75);
  margin-bottom: 4px;
  cursor: default;
  pointer-events: auto;
  border-bottom: 1px dotted rgba(150, 210, 255, 0.4);
  line-height: 1.4;
}

/* Inline damage chip in description */
.dmg-tag {
  color: #f0c040;
  font-weight: 700;
  pointer-events: auto;
  border-bottom: 1px dotted rgba(240, 192, 64, 0.5);
  cursor: pointer;
  transition: color 0.1s;
}

.dmg-tag:hover {
  color: #ffd966;
}

/* Shared sub-tooltip: damage breakdown + level table */
#ability-sub-tooltip {
  position: fixed;
  background: rgba(6, 6, 16, 0.97);
  border: 1px solid rgba(240, 192, 64, 0.4);
  border-radius: 6px;
  padding: 6px 10px;
  pointer-events: none;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.1s ease;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
}

#ability-sub-tooltip.visible {
  opacity: 1;
}

.stat-icon-inline {
  width: 12px;
  height: 12px;
  vertical-align: middle;
  margin-left: 2px;
}

/* Per-level table (rendered inside sub-tooltip) */
.lvl-table {
  border-collapse: collapse;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
}

.lvl-table th {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
  text-align: right;
  padding: 1px 4px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.lvl-table th:first-child,
.lvl-table td:first-child {
  text-align: left;
  padding-left: 0;
}

.lvl-table td {
  text-align: right;
  padding: 1px 4px;
}

.lvl-table tr.lvl-active td {
  color: #f0c040;
  font-weight: 700;
}

/* Stand-in when an ability icon file is missing (see abilities.js). A broken
   image glyph in the bar is worse than a letter, and the tooltip names the file
   that should exist. */
.ability-icon-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
  color: rgba(240, 192, 64, 0.8);
  background: rgba(255, 255, 255, 0.04);
}
