/* ====================================================================== *
 * Idle Realms — components.css
 * ----------------------------------------------------------------------- *
 * Reusable UI component styles for the dark theme.
 *
 *   • Progress bars   (.progress-bar)        — animated gradient fill
 *   • Tooltips        ([data-tooltip], .tooltip) — hover + rich JS card
 *   • Modals          (.modal)               — centered overlay + blur
 *   • Tabs            (.tabs)                — pill / segmented style
 *   • Toasts          (.toast)               — slide-in notifications
 *   • Dropdowns       (.dropdown)            — click / focus menus
 *   • Item slots      (.slot-grid, .slot)    — rarity-bordered grid
 *   • Context menus   (.context-menu)        — right-click action menu
 *
 * Everything is driven by CSS custom properties and transitions so it
 * stays in sync with the rest of the dark theme.
 *
 * TOKENS:
 * `css/style.css` (TASK-001) is the canonical home for the `:root` palette.
 * It does not exist yet, so a fallback token block is defined below to keep
 * this file self-sufficient. Inline `var(--x, fallback)` defaults are also
 * used throughout, so every component renders correctly even if some tokens
 * are missing or overridden by a future `css/themes.css` (TASK-063). When
 * `style.css` defines the same names the cascade resolves identically.
 * ====================================================================== */

/* ----------------------------------------------------------------------
   Dark theme tokens (fallback / canonical until style.css ships)
   ---------------------------------------------------------------------- */
:root {
  /* Surfaces */
  --bg-app:        #0d1117;
  --bg-surface:    #161c26;
  --bg-elevated:   #1f2733;
  --bg-sunken:     #0b0f15;
  --bg-overlay:    rgba(8, 11, 16, 0.72);
  --bg-track:      rgba(0, 0, 0, 0.35);

  /* Text */
  --text:          #e8eaf0;
  --text-muted:    #9aa3b2;
  --text-dim:      #6b7280;

  /* Borders */
  --border:        rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  /* Brand / accents */
  --accent:        #4aa3ff;
  --accent-strong: #6db5ff;
  --accent-weak:   rgba(74, 163, 255, 0.16);
  --accent-2:      #7c5cff;

  /* Semantic colors */
  --gold:          #ffc83d;
  --success:       #3dd68c;
  --warning:       #f5b042;
  --danger:        #ff5c5c;
  --info:          #4aa3ff;

  /* Rarity colors (used by item slots + tooltips) */
  --rarity-common:    #b0b7c3;
  --rarity-uncommon:  #4ade80;
  --rarity-rare:      #4aa3ff;
  --rarity-epic:      #b061ff;
  --rarity-legendary: #ffb347;
  --rarity-mythic:    #ff4d6d;

  /* Radii */
  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   14px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.30);
  --shadow:    0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);

  /* Motion */
  --ease:      cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast:  0.15s;
  --dur:       0.25s;
  --dur-slow:  0.4s;

  /* Z-index scale */
  --z-dropdown: 800;
  --z-sticky:   850;
  --z-tooltip:  900;
  --z-modal:    1000;
  --z-toast:    1100;
  --z-context:  1200;
}

/* ----------------------------------------------------------------------
   Shared keyframes
   ---------------------------------------------------------------------- */
@keyframes ir-fade-in      { from { opacity: 0; }                    to { opacity: 1; } }
@keyframes ir-pop-in       { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }
@keyframes ir-slide-in-r   { from { opacity: 0; transform: translateX(120%); } to { opacity: 1; transform: translateX(0); } }
@keyframes ir-slide-out-r  { to   { opacity: 0; transform: translateX(120%); } }
@keyframes ir-modal-in     { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes ir-ctx-in       { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }
@keyframes ir-shimmer      { from { background-position: -150% 0; } to { background-position: 250% 0; } }
@keyframes ir-bar-stripes  { from { background-position: 0 0; }      to { background-position: 32px 0; } }
@keyframes ir-glow-pulse   {
  0%, 100% { box-shadow: 0 0 0 1px var(--slot-ring, transparent), 0 0 6px var(--slot-glow, transparent); }
  50%      { box-shadow: 0 0 0 1px var(--slot-ring, transparent), 0 0 14px var(--slot-glow, transparent); }
}


/* ====================================================================== *
 * PROGRESS BARS
 * ====================================================================== */
.progress-bar {
  position: relative;
  width: 100%;
  height: var(--bar-h, 14px);
  background: var(--bg-track, rgba(0, 0, 0, 0.35));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-pill, 999px);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

.progress-bar--sm { --bar-h: 8px; }
.progress-bar--lg { --bar-h: 22px; }

/* The animated fill. Width is set inline/by JS; transitions feel juicy. */
.progress-bar__fill {
  position: relative;
  height: 100%;
  width: 0%;
  min-width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg,
    var(--bar-from, var(--accent, #4aa3ff)) 0%,
    var(--bar-to,   var(--accent-strong, #6db5ff)) 100%);
  transition: width var(--dur-slow, 0.4s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1));
  box-shadow: 0 0 8px var(--bar-glow, rgba(74, 163, 255, 0.45));
}

/* Sweeping shimmer highlight riding on top of the fill. */
.progress-bar__fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg,
    transparent 35%,
    rgba(255, 255, 255, 0.28) 50%,
    transparent 65%);
  background-size: 200% 100%;
  animation: ir-shimmer 2.4s linear infinite;
  pointer-events: none;
}

/* Optional animated diagonal stripes layered under the shimmer. */
.progress-bar--striped .progress-bar__fill {
  background-image:
    repeating-linear-gradient(45deg,
      rgba(255, 255, 255, 0.10) 0 8px,
      rgba(255, 255, 255, 0)    8px 16px),
    linear-gradient(90deg,
      var(--bar-from, var(--accent, #4aa3ff)) 0%,
      var(--bar-to,   var(--accent-strong, #6db5ff)) 100%);
  background-size: 32px 32px, 100% 100%;
  animation: ir-bar-stripes 0.9s linear infinite;
}
/* When striped + paused (e.g. idle action not running) stop the motion. */
.progress-bar--paused .progress-bar__fill,
.progress-bar--paused .progress-bar__fill::after { animation: none; }

/* Color modifiers — set --bar-from / --bar-to / --bar-glow. */
.progress-bar--success { --bar-from: #2bbf7a; --bar-to: var(--success, #3dd68c); --bar-glow: rgba(61, 214, 140, 0.45); }
.progress-bar--warning { --bar-from: #e09b2c; --bar-to: var(--warning, #f5b042); --bar-glow: rgba(245, 176, 66, 0.45); }
.progress-bar--danger  { --bar-from: #e0463f; --bar-to: var(--danger,  #ff5c5c); --bar-glow: rgba(255, 92, 92, 0.45); }
.progress-bar--gold    { --bar-from: #e6a817; --bar-to: var(--gold,    #ffc83d); --bar-glow: rgba(255, 200, 61, 0.45); }
.progress-bar--xp      { --bar-from: #6a4bff; --bar-to: var(--accent-2, #7c5cff); --bar-glow: rgba(124, 92, 255, 0.5); }
.progress-bar--hp      { --bar-from: #d83b3b; --bar-to: #ff6b6b; --bar-glow: rgba(255, 92, 92, 0.5); }

/* Centered label that sits over the fill. */
.progress-bar__text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text, #e8eaf0);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  white-space: nowrap;
}


/* ====================================================================== *
 * TOOLTIPS
 * ---------------------------------------------------------------------- *
 * Two complementary systems:
 *   1. [data-tooltip]  — pure-CSS, lightweight text tooltip (pseudo-elements)
 *   2. .tooltip        — rich card created & positioned by js/ui/tooltip.js
 * ====================================================================== */

/* --- 1. Lightweight attribute tooltip -------------------------------- */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::before,
[data-tooltip]::after {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              transform var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1));
  z-index: var(--z-tooltip, 900);
}
[data-tooltip]::before {                       /* the bubble */
  content: attr(data-tooltip);
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--bg-elevated, #1f2733);
  color: var(--text, #e8eaf0);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.16));
  padding: 6px 10px;
  border-radius: var(--radius-sm, 6px);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: var(--shadow, 0 8px 24px rgba(0, 0, 0, 0.45));
}
[data-tooltip]::after {                        /* the arrow */
  content: "";
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  border: 5px solid transparent;
  border-top-color: var(--border-strong, rgba(255, 255, 255, 0.16));
}
[data-tooltip]:hover::before,
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::before,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
/* Position variants */
[data-tooltip-pos="bottom"]::before { bottom: auto; top: calc(100% + 8px); transform: translateX(-50%) translateY(-4px); }
[data-tooltip-pos="bottom"]::after  { bottom: auto; top: calc(100% + 3px); transform: translateX(-50%) translateY(-4px); border-top-color: transparent; border-bottom-color: var(--border-strong, rgba(255, 255, 255, 0.16)); }
[data-tooltip-pos="bottom"]:hover::before,
[data-tooltip-pos="bottom"]:hover::after { transform: translateX(-50%) translateY(0); }
[data-tooltip-pos="left"]::before  { bottom: 50%; left: auto; right: calc(100% + 8px); transform: translate(4px, 50%); }
[data-tooltip-pos="right"]::before { bottom: 50%; left: calc(100% + 8px);  transform: translate(-4px, 50%); }

/* --- 2. Rich tooltip card (JS-driven) -------------------------------- */
.tooltip {
  position: fixed;
  z-index: var(--z-tooltip, 900);
  max-width: 300px;
  padding: 10px 12px;
  background: var(--bg-elevated, #1f2733);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.16));
  border-radius: var(--radius, 10px);
  box-shadow: var(--shadow, 0 8px 24px rgba(0, 0, 0, 0.45));
  color: var(--text, #e8eaf0);
  font-size: 12.5px;
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px) scale(0.98);
  transition: opacity var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              transform var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1));
}
.tooltip--visible {
  opacity: 1;
  transform: none;
}
/* Rarity tint on the top edge */
.tooltip--common    { border-top: 3px solid var(--rarity-common, #b0b7c3); }
.tooltip--uncommon  { border-top: 3px solid var(--rarity-uncommon, #4ade80); }
.tooltip--rare      { border-top: 3px solid var(--rarity-rare, #4aa3ff); box-shadow: var(--shadow, 0 8px 24px rgba(0,0,0,.45)), 0 0 12px rgba(74,163,255,.25); }
.tooltip--epic      { border-top: 3px solid var(--rarity-epic, #b061ff); box-shadow: var(--shadow, 0 8px 24px rgba(0,0,0,.45)), 0 0 12px rgba(176,97,255,.25); }
.tooltip--legendary { border-top: 3px solid var(--rarity-legendary, #ffb347); box-shadow: var(--shadow, 0 8px 24px rgba(0,0,0,.45)), 0 0 14px rgba(255,179,71,.30); }
.tooltip--mythic    { border-top: 3px solid var(--rarity-mythic, #ff4d6d); box-shadow: var(--shadow, 0 8px 24px rgba(0,0,0,.45)), 0 0 14px rgba(255,77,109,.30); }

.tooltip__title {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 700;
}
.tooltip__title--common    { color: var(--rarity-common, #b0b7c3); }
.tooltip__title--uncommon  { color: var(--rarity-uncommon, #4ade80); }
.tooltip__title--rare      { color: var(--rarity-rare, #4aa3ff); }
.tooltip__title--epic      { color: var(--rarity-epic, #b061ff); }
.tooltip__title--legendary { color: var(--rarity-legendary, #ffb347); }
.tooltip__title--mythic    { color: var(--rarity-mythic, #ff4d6d); }

.tooltip__subtitle {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--text-muted, #9aa3b2);
  font-style: italic;
}
.tooltip__section { margin-top: 8px; }
.tooltip__section-title {
  margin: 0 0 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim, #6b7280);
}
.tooltip__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 1px 0;
}
.tooltip__row--good { color: var(--success, #3dd68c); }
.tooltip__row--bad  { color: var(--danger, #ff5c5c); }
.tooltip__row b     { color: var(--text, #e8eaf0); font-weight: 600; }
.tooltip__divider {
  height: 1px;
  margin: 8px 0;
  background: var(--border, rgba(255, 255, 255, 0.08));
  border: 0;
}
.tooltip__footer {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--border, rgba(255, 255, 255, 0.08));
  font-size: 11px;
  color: var(--text-muted, #9aa3b2);
}
.tooltip__value { color: var(--gold, #ffc83d); font-weight: 600; }


/* ====================================================================== *
 * MODALS — centered overlay with backdrop blur + slide-in dialog
 * ====================================================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal, 1000);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  /* Hidden state (visibility lets us transition cleanly) */
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur, 0.25s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              visibility 0s linear var(--dur, 0.25s);
}
.modal--open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition: opacity var(--dur, 0.25s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1));
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: var(--bg-overlay, rgba(8, 11, 16, 0.72));
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.modal__dialog {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface, #161c26);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.16));
  border-radius: var(--radius-lg, 14px);
  box-shadow: var(--shadow-lg, 0 16px 48px rgba(0, 0, 0, 0.55));
  overflow: hidden;
  transform: translateY(12px) scale(0.98);
  transition: transform var(--dur-slow, 0.4s) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}
.modal--open .modal__dialog { transform: none; }
/* When the open animation kicks in via class, also play the keyframe pop. */
.modal--open .modal__dialog { animation: ir-modal-in var(--dur-slow, 0.4s) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) both; }

.modal--sm .modal__dialog { max-width: 380px; }
.modal--md .modal__dialog { max-width: 520px; }
.modal--lg .modal__dialog { max-width: 760px; }
.modal--xl .modal__dialog { max-width: 960px; }

.modal__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  background: linear-gradient(180deg, var(--bg-elevated, #1f2733), var(--bg-surface, #161c26));
}
.modal__title {
  flex: 1 1 auto;
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text, #e8eaf0);
}
.modal__subtitle {
  font-size: 12px;
  color: var(--text-muted, #9aa3b2);
  font-weight: 400;
}
.modal__close {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-sunken, #0b0f15);
  color: var(--text-muted, #9aa3b2);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              border-color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1));
}
.modal__close:hover {
  background: var(--bg-elevated, #1f2733);
  color: var(--text, #e8eaf0);
  border-color: var(--border-strong, rgba(255, 255, 255, 0.16));
}

.modal__body {
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--text, #e8eaf0);
}
.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  background: var(--bg-sunken, #0b0f15);
}


/* ====================================================================== *
 * TABS — pill / segmented style
 * ====================================================================== */
.tabs {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tabs__list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--bg-sunken, #0b0f15);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-pill, 999px);
  overflow-x: auto;
  scrollbar-width: thin;
}
.tabs__list--block { display: flex; width: 100%; }
.tabs__list--block .tab { flex: 1 1 0; }

.tab {
  appearance: none;
  border: 0;
  padding: 7px 16px;
  border-radius: var(--radius-pill, 999px);
  background: transparent;
  color: var(--text-muted, #9aa3b2);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              box-shadow var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1));
}
.tab:hover {
  color: var(--text, #e8eaf0);
  background: var(--bg-elevated, #1f2733);
}
.tab:focus-visible {
  outline: 2px solid var(--accent, #4aa3ff);
  outline-offset: 2px;
}
.tab--active {
  color: #fff;
  background: linear-gradient(180deg, var(--accent-strong, #6db5ff), var(--accent, #4aa3ff));
  box-shadow: 0 2px 8px var(--accent-weak, rgba(74, 163, 255, 0.16));
}
.tab--active:hover { background: linear-gradient(180deg, var(--accent-strong, #6db5ff), var(--accent, #4aa3ff)); }
.tab__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: var(--radius-pill, 999px);
  background: var(--bg-sunken, #0b0f15);
  color: var(--text-muted, #9aa3b2);
  font-size: 10.5px;
  font-weight: 700;
}
.tab--active .tab__badge { background: rgba(0, 0, 0, 0.28); color: #fff; }

.tabs__panels { position: relative; }
.tabs__panel {
  display: none;
  animation: ir-fade-in var(--dur, 0.25s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1));
}
.tabs__panel--active { display: block; }


/* ====================================================================== *
 * TOASTS — slide-in notifications
 * (The notifications engine owns its own `.notify-*` styles; these are the
 *  generic, reusable toast components for the rest of the UI.)
 * ====================================================================== */
.toast-stack {
  position: fixed;
  z-index: var(--z-toast, 1100);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;            /* clicks fall through gaps; toasts re-enable */
}
.toast-stack > * { pointer-events: auto; }
.toast-stack--br { right: 16px; bottom: 16px; flex-direction: column; }
.toast-stack--tr { right: 16px; top: 16px;    flex-direction: column-reverse; }
.toast-stack--bl { left: 16px;  bottom: 16px; flex-direction: column; align-items: flex-start; }
.toast-stack--tl { left: 16px;  top: 16px;    flex-direction: column-reverse; align-items: flex-start; }

.toast {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 34px 10px 12px;
  border-radius: var(--radius, 10px);
  background: linear-gradient(180deg, var(--bg-elevated, #1f2733), var(--bg-surface, #161c26));
  color: var(--text, #e8eaf0);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  border-left: 4px solid var(--toast-accent, var(--accent, #4aa3ff));
  box-shadow: var(--shadow, 0 8px 24px rgba(0, 0, 0, 0.45));
  font-size: 13px;
  line-height: 1.35;
  animation: ir-slide-in-r 0.3s var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)) both;
  transition: transform var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              opacity var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1));
}
.toast:hover { transform: translateY(-1px); }
.toast--out { animation: ir-slide-out-r 0.25s var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)) both !important; }

.toast--info     { --toast-accent: var(--info, #4aa3ff); }
.toast--success  { --toast-accent: var(--success, #3dd68c); }
.toast--warning  { --toast-accent: var(--warning, #f5b042); }
.toast--danger   { --toast-accent: var(--danger, #ff5c5c); }
.toast--gold     { --toast-accent: var(--gold, #ffc83d); }

.toast__icon  { flex: 0 0 auto; font-size: 18px; line-height: 1.2; }
.toast__body  { flex: 1 1 auto; min-width: 0; }
.toast__title {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--toast-accent, var(--accent, #4aa3ff));
  margin-bottom: 1px;
}
.toast__msg { word-break: break-word; }
.toast__close {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted, #9aa3b2);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm, 6px);
  transition: background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1));
}
.toast__close:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }


/* ====================================================================== *
 * DROPDOWN MENUS
 * ====================================================================== */
.dropdown {
  position: relative;
  display: inline-block;
}
.dropdown__trigger {
  cursor: pointer;
}
.dropdown__menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: var(--z-dropdown, 800);
  min-width: 180px;
  padding: 5px;
  background: var(--bg-elevated, #1f2733);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.16));
  border-radius: var(--radius, 10px);
  box-shadow: var(--shadow, 0 8px 24px rgba(0, 0, 0, 0.45));
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top left;
  transition: opacity var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              transform var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              visibility 0s linear var(--dur-fast, 0.15s);
}
/* Open via JS class OR CSS-only via focus-within. */
.dropdown--open .dropdown__menu,
.dropdown:focus-within .dropdown__menu {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              transform var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1));
}
.dropdown__menu--right { left: auto; right: 0; transform-origin: top right; }
.dropdown__menu--up    { top: auto; bottom: calc(100% + 6px); transform-origin: bottom left; }

.dropdown__header {
  padding: 6px 10px 8px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim, #6b7280);
}
.dropdown__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-sm, 6px);
  background: transparent;
  color: var(--text, #e8eaf0);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1));
}
.dropdown__item:hover,
.dropdown__item:focus-visible {
  background: var(--accent-weak, rgba(74, 163, 255, 0.16));
  color: #fff;
  outline: none;
}
.dropdown__item--active { color: var(--accent-strong, #6db5ff); }
.dropdown__item--danger { color: var(--danger, #ff5c5c); }
.dropdown__item--danger:hover { background: rgba(255, 92, 92, 0.16); color: var(--danger, #ff5c5c); }
.dropdown__item--disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.dropdown__item-icon { flex: 0 0 auto; font-size: 15px; }
.dropdown__item-label { flex: 1 1 auto; }
.dropdown__item-meta { font-size: 11px; color: var(--text-muted, #9aa3b2); }
.dropdown__divider {
  height: 1px;
  margin: 4px 6px;
  background: var(--border, rgba(255, 255, 255, 0.08));
}


/* ====================================================================== *
 * ITEM SLOTS — grid with rarity borders
 * ====================================================================== */
.slot-grid {
  display: grid;
  grid-template-columns: repeat(var(--slot-cols, 4), var(--slot-size, 52px));
  gap: var(--slot-gap, 6px);
  justify-content: start;
}
.slot-grid--auto {
  grid-template-columns: repeat(auto-fill, minmax(var(--slot-size, 52px), 1fr));
}

.slot {
  position: relative;
  width: var(--slot-size, 52px);
  height: var(--slot-size, 52px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-sunken, #0b0f15);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.16));
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  user-select: none;
  --slot-ring: transparent;
  --slot-glow: transparent;
  transition: transform var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              border-color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              box-shadow var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1));
}
.slot:hover {
  transform: translateY(-2px);
  background: var(--bg-elevated, #1f2733);
}
.slot:active { transform: translateY(0) scale(0.96); }

.slot--empty {
  cursor: default;
  background: var(--bg-track, rgba(0, 0, 0, 0.35));
  border-style: dashed;
  border-color: var(--border, rgba(255, 255, 255, 0.08));
}
.slot--empty:hover { transform: none; background: var(--bg-track, rgba(0, 0, 0, 0.35)); }

.slot__icon {
  font-size: calc(var(--slot-size, 52px) * 0.55);
  line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
}
.slot__qty {
  position: absolute;
  right: 2px;
  bottom: 1px;
  padding: 0 4px;
  min-width: 14px;
  text-align: center;
  background: rgba(0, 0, 0, 0.7);
  color: var(--text, #e8eaf0);
  border-radius: var(--radius-sm, 6px);
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
}
.slot__badge {                       /* e.g. equipped "E" / level dot */
  position: absolute;
  left: 2px;
  top: 1px;
  width: 12px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent, #4aa3ff);
  color: #fff;
  border-radius: var(--radius-pill, 999px);
  font-size: 8.5px;
  font-weight: 700;
}

/* States */
.slot--selected {
  border-color: var(--accent-strong, #6db5ff);
  box-shadow: 0 0 0 2px var(--accent-weak, rgba(74, 163, 255, 0.16));
}
.slot--equipped { border-color: var(--success, #3dd68c); }
.slot--locked,
.slot--locked:hover {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  background: var(--bg-track, rgba(0, 0, 0, 0.35));
}
.slot--locked::after {
  content: "🔒";
  position: absolute;
  font-size: calc(var(--slot-size, 52px) * 0.4);
  opacity: 0.8;
}

/* Sizes */
.slot--sm { --slot-size: 40px; }
.slot--md { --slot-size: 52px; }
.slot--lg { --slot-size: 64px; }

/* ---- Rarity borders + glow ---- */
.slot--common    { border-color: var(--rarity-common, #b0b7c3); }
.slot--uncommon  { border-color: var(--rarity-uncommon, #4ade80); --slot-glow: rgba(74, 222, 128, 0.35); }
.slot--rare      { border-color: var(--rarity-rare, #4aa3ff); --slot-glow: rgba(74, 163, 255, 0.40); }
.slot--epic      { border-color: var(--rarity-epic, #b061ff); --slot-glow: rgba(176, 97, 255, 0.40); }
.slot--legendary {
  border-color: var(--rarity-legendary, #ffb347);
  --slot-glow: rgba(255, 179, 71, 0.45);
  background-image: linear-gradient(135deg, rgba(255, 179, 71, 0.10), transparent 60%);
}
.slot--mythic {
  border-color: var(--rarity-mythic, #ff4d6d);
  --slot-glow: rgba(255, 77, 109, 0.50);
  background-image: linear-gradient(135deg, rgba(255, 77, 109, 0.12), transparent 60%);
}
/* Rare+ items glow gently; legendary/mythic pulse while hovered. */
.slot--rare:hover,
.slot--epic:hover,
.slot--legendary:hover,
.slot--mythic:hover {
  box-shadow: 0 0 0 1px var(--slot-ring, transparent), 0 0 14px var(--slot-glow);
}
.slot--legendary:hover,
.slot--mythic:hover {
  animation: ir-glow-pulse 1.6s var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)) infinite;
}

/* Shared rarity text helper (for item names in lists/tooltips). */
.rarity-text--common    { color: var(--rarity-common, #b0b7c3); }
.rarity-text--uncommon  { color: var(--rarity-uncommon, #4ade80); }
.rarity-text--rare      { color: var(--rarity-rare, #4aa3ff); }
.rarity-text--epic      { color: var(--rarity-epic, #b061ff); }
.rarity-text--legendary { color: var(--rarity-legendary, #ffb347); }
.rarity-text--mythic    { color: var(--rarity-mythic, #ff4d6d); }


/* ====================================================================== *
 * CONTEXT MENUS — right-click action menu
 * ====================================================================== */
.context-menu {
  position: fixed;
  z-index: var(--z-context, 1200);
  min-width: 180px;
  max-width: 260px;
  padding: 5px;
  background: var(--bg-elevated, #1f2733);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.16));
  border-radius: var(--radius, 10px);
  box-shadow: var(--shadow-lg, 0 16px 48px rgba(0, 0, 0, 0.55));
  color: var(--text, #e8eaf0);
  transform-origin: top left;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.92);
  transition: opacity var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              transform var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              visibility 0s linear var(--dur-fast, 0.15s);
}
.context-menu--open {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  animation: ir-ctx-in var(--dur, 0.25s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1));
  transition: opacity var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              transform var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1));
}
/* JS sets the flip origin when the menu would overflow the viewport. */
.context-menu--flip-x { transform-origin: top right; }
.context-menu--flip-y { transform-origin: bottom left; }

.context-menu__header {
  padding: 6px 10px 8px;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  margin-bottom: 4px;
}
.context-menu__title {
  font-size: 13px;
  font-weight: 700;
}
.context-menu__sub {
  font-size: 11px;
  color: var(--text-muted, #9aa3b2);
}

.context-menu__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-sm, 6px);
  background: transparent;
  color: var(--text, #e8eaf0);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
              color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.2, 0.8, 0.2, 1));
}
.context-menu__item:hover,
.context-menu__item:focus-visible {
  background: var(--accent-weak, rgba(74, 163, 255, 0.16));
  color: #fff;
  outline: none;
}
.context-menu__item--danger { color: var(--danger, #ff5c5c); }
.context-menu__item--danger:hover { background: rgba(255, 92, 92, 0.16); color: var(--danger, #ff5c5c); }
.context-menu__item--disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.context-menu__item-icon { flex: 0 0 auto; font-size: 15px; width: 18px; text-align: center; }
.context-menu__item-label { flex: 1 1 auto; }
.context-menu__shortcut {
  margin-left: auto;
  padding-left: 8px;
  color: var(--text-dim, #6b7280);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.context-menu__divider {
  height: 1px;
  margin: 4px 6px;
  background: var(--border, rgba(255, 255, 255, 0.08));
}


/* ====================================================================== *
 * Top bar action indicator (current global action + stop button)
 * ====================================================================== */
.top-bar__action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 22px;
  background: rgba(99, 179, 237, 0.1);
  border: 1px solid rgba(99, 179, 237, 0.25);
  font-size: 13px;
  animation: action-bar-in 0.2s ease-out;
}
.top-bar__action-bar[hidden] { display: none; }

@keyframes action-bar-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.action-bar__icon {
  font-size: 16px;
  animation: action-pulse 2s ease-in-out infinite;
}
@keyframes action-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.action-bar__label {
  color: var(--text, #e2e8f0);
  font-weight: 500;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-bar__stop {
  background: rgba(255, 107, 107, 0.15);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: #ff6b6b;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, transform 0.08s;
  flex-shrink: 0;
}
.action-bar__stop:hover {
  background: rgba(255, 107, 107, 0.3);
  transform: scale(1.1);
}
.action-bar__stop:active {
  transform: scale(0.9);
}


/* ====================================================================== *
 * Skill sidebar items
 * ====================================================================== */
.skill-category {
  list-style: none;
  padding: 8px 6px 2px;
}
.skill-category__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim, #6b7280);
}

.skill-item {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  background: transparent;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.skill-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}
.skill-item:active {
  transform: scale(0.98);
}
.skill-item--active {
  background: rgba(99, 179, 237, 0.12);
  border-color: rgba(99, 179, 237, 0.35);
}
.skill-item--active:hover {
  background: rgba(99, 179, 237, 0.18);
}
.skill-item[data-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}
.skill-item[data-disabled="true"]:hover {
  background: transparent;
  border-color: transparent;
}
.skill-item--levelup {
  animation: skill-flash 1.2s ease-out;
}
@keyframes skill-flash {
  0%   { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.6); }
  30%  { box-shadow: 0 0 0 6px rgba(255, 215, 0, 0.3); background: rgba(255, 215, 0, 0.1); }
  100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }
}

.skill-item__icon { font-size: 18px; flex-shrink: 0; width: 22px; text-align: center; }
.skill-item__name { flex: 1 1 auto; font-size: 13px; color: var(--text, #e2e8f0); }
.skill-item__level {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted, #9aa3b2);
  font-variant-numeric: tabular-nums;
}


/* ====================================================================== *
 * Inventory sidebar slots
 * ====================================================================== */
.inv-slot {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.inv-slot--filled {
  cursor: pointer;
}
.inv-slot--filled:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  transform: scale(1.05);
}
.inv-slot--filled:active {
  transform: scale(0.95);
}
.inv-slot__icon { font-size: 24px; }
.inv-slot__qty {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text, #e2e8f0);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  font-variant-numeric: tabular-nums;
}


/* ====================================================================== *
 * Inventory context menu
 * ====================================================================== */
.context-menu {
  position: fixed;
  z-index: 1200;
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.16));
  border-radius: 10px;
  background: linear-gradient(180deg, var(--bg-elevated, #1f2733), var(--bg-surface, #161c26));
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  color: var(--text, #e8eaf0);
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top left;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.context-menu--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.context-menu__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text, #e8eaf0);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.context-menu__item:hover,
.context-menu__item:focus-visible {
  background: var(--accent-weak, rgba(74, 163, 255, 0.16));
  outline: none;
}
.context-menu__icon { font-size: 16px; }
.context-menu__label { flex: 1; }
.context-menu__meta {
  color: var(--success, #3dd68c);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}


/* ====================================================================== *
 * Skill placeholder (for skills without a panel module yet)
 * ====================================================================== */
.skill-placeholder {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted, #9aa3b2);
}
.skill-placeholder h2 {
  font-size: 22px;
  margin-bottom: 12px;
}
.skill-placeholder__hint {
  margin-top: 8px;
  font-size: 13px;
}


/* ====================================================================== *
 * Reduced motion — respect the user's OS preference
 * ====================================================================== */
@media (prefers-reduced-motion: reduce) {
  .progress-bar__fill,
  .progress-bar__fill::after,
  .progress-bar--striped .progress-bar__fill,
  .toast,
  .modal__dialog,
  .context-menu,
  .context-menu--open,
  .slot,
  .slot--legendary:hover,
  .slot--mythic:hover,
  .tooltip {
    animation: none !important;
    transition: none !important;
  }
}
