/* ability-card.css -- self-contained. Only knob you must set is --ac-accent.
   Font: <link href="https://fonts.googleapis.com/css2?family=Alegreya+Sans:ital,wght@0,400;0,500;0,700;0,800;1,400;1,500&display=swap" rel="stylesheet"> */

.ac-card {
  --ac-accent: #5b8fae;
  --ac-bar: color-mix(in srgb, var(--ac-accent) 58%, #0d1218);
  --ac-body: color-mix(in srgb, var(--ac-accent) 18%, #2b3239);
  --ac-unit: color-mix(in srgb, var(--ac-accent) 58%, #ffffff);
  --ac-up: #5ddc7a;

  width: 560px;
  max-width: 100%;
  border-radius: 14px;
  overflow: hidden;
  color: #e7edf2;
  font-family: 'Alegreya Sans', system-ui, sans-serif;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .06);
}

/* Header ------------------------------------------------------------------ */
.ac-top {
  position: relative;
  background: var(--ac-accent);
}
.ac-head {
  position: relative;
  padding: 26px 24px 24px;
}
.ac-art {
  position: absolute;
  inset: 0 0 0 46%;
  background-size: cover;
  background-position: center;
  opacity: .55;
  mix-blend-mode: screen;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 42%);
  mask-image: linear-gradient(to right, transparent 0%, #000 42%);
}
.ac-head-text { position: relative; }

/* Tier corner -- mirrors the .ai-tier corner on the item icon */
.ac-corner {
  position: absolute;
  top: 0;
  right: 0;
  width: 62px;
  height: 62px;
  background: color-mix(in srgb, var(--ac-accent) 52%, #0d1218);
  clip-path: polygon(100% 0, 0 0, 100% 100%);
  pointer-events: none;
}
.ac-corner > span {
  position: absolute;
  top: 5px;
  right: 9px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1;
  color: #fff;
}
.ac-head:has(.ac-corner) .ac-head-text { padding-right: 54px; }
.ac-title {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: .2px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .28);
}
.ac-level {
  margin: 5px 0 0;
  font-size: 19px;
  font-weight: 500;
  color: rgba(255, 255, 255, .78);
}

/* Type bar -- sits over the header background ------------------------------ */
.ac-bar {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  min-height: 48px;
  background: color-mix(in srgb, var(--ac-bar) 78%, transparent);
}
.ac-type {
  display: flex;
  align-items: center;
  padding-left: 24px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .3px;
  color: #fff;
}
.ac-cd {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 6px;
  padding: 0 14px;
  border-radius: 5px;
  background: #0e141b;
  font-size: 20px;
  font-weight: 700;
  color: #eef4f8;
}
.ac-cd svg { flex: none; }
.ac-caret { font-size: 13px; color: rgba(255, 255, 255, .45); transform: translateY(1px); }

/* Body -------------------------------------------------------------------- */
.ac-body { padding: 22px 24px 24px; background: var(--ac-body); }
.ac-desc {
  margin: 0;
  font-size: 19px;
  line-height: 1.45;
  color: #d7e0e8;
  text-wrap: pretty;
}
.ac-desc strong { color: #fff; font-weight: 700; }
.ac-note {
  margin: 14px 0 0;
  font-size: 17px;
  line-height: 1.4;
  font-style: italic;
  color: #95a3af;
  text-wrap: pretty;
}

/* Stat panel -- both sections are optional -------------------------------- */
.ac-panel {
  margin-top: 20px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .24);
  overflow: hidden;
}
.ac-body > .ac-panel:first-child { margin-top: 0; }

.ac-stats { display: flex; }
.ac-stat {
  flex: 1;
  min-width: 0;
  padding: 18px 12px;
  text-align: center;
}
.ac-stat + .ac-stat { box-shadow: inset 1px 0 rgba(255, 255, 255, .13); }
.ac-stat-val {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
}
.ac-stat-val svg { flex: none; }
.ac-stat-label {
  margin-top: 4px;
  font-size: 17px;
  font-weight: 500;
  color: #adbac5;
}

.ac-details {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 12px 24px;
  padding: 14px 20px 16px;
}
.ac-stats + .ac-details { border-top: 1px solid rgba(255, 255, 255, .1); }
.ac-detail {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}
.ac-detail-val { font-size: 21px; font-weight: 700; color: #fff; }
.ac-detail-label { font-size: 18px; font-weight: 500; color: #adbac5; }

.ac-unit { font-size: 16px; font-weight: 700; color: var(--ac-unit); }
.ac-stat-val .ac-unit { font-size: 20px; }
.ac-up { font-size: 11px; line-height: 1; color: var(--ac-up); }
.ac-stat-val .ac-up { font-size: 12px; align-self: flex-start; margin-top: 2px; }

/* Narrow screens ---------------------------------------------------------- */
@media (max-width: 600px) {
  .ac-card { width: 100%; }
  .ac-details { grid-template-columns: 1fr; }
  .ac-stats { flex-wrap: wrap; }
  .ac-stat { flex-basis: 50%; }
}

/* Shell -- card + buy panel side by side ----------------------------------- */
.ac-shell {
  display: flex;
  align-items: stretch;
  gap: 8px;
  font-family: 'Alegreya Sans', system-ui, sans-serif;
}

.ac-side {
  width: 208px;
  flex: none;
  padding: 16px 18px 18px;
  border-radius: 10px;
  background: #43474d;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(255, 255, 255, .07);
  color: #e7edf2;
}
.ac-side-title {
  margin: 0 0 12px;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.15;
  color: #fff;
  text-wrap: balance;
}
.ac-cost {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  font-size: 26px;
  font-weight: 700;
  color: #fff;
}
.ac-cost svg { flex: none; }
.ac-cost-label {
  margin-left: auto;
  font-size: 16px;
  font-weight: 500;
  color: #b0bac3;
}
.ac-deltas {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.ac-delta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 18px;
  line-height: 1.2;
}
.ac-delta-val {
  flex: none;
  min-width: 46px;
  font-weight: 700;
  color: #5ddc7a;
}
.ac-delta.ac-delta--down .ac-delta-val { color: #e2705f; }
.ac-delta-label { font-weight: 500; color: #c3ccd4; text-wrap: pretty; }
.ac-side-note {
  margin: 14px 0 0;
  font-size: 16px;
  font-style: italic;
  line-height: 1.35;
  color: #97a2ac;
}

/* Tier / upgrade rows ------------------------------------------------------ */
.ac-tiers {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 18px;
}
.ac-tier {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05);
}
.ac-tier--owned {
  background: color-mix(in srgb, var(--ac-accent) 30%, rgba(0, 0, 0, .2));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ac-accent) 55%, transparent);
}
.ac-tier--next { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .26); }
.ac-tier--locked { opacity: .5; }

.ac-tier-cost {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 34px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .42);
  font-size: 16px;
  font-weight: 700;
  color: #e9eff4;
}
.ac-tier--owned .ac-tier-cost { background: rgba(0, 0, 0, .34); }
.ac-pip {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--ac-accent) 45%, #ffffff);
  transform: rotate(45deg);
}
.ac-tier-bonus {
  font-size: 18px;
  line-height: 1.35;
  color: #d7e0e8;
  text-wrap: pretty;
}
.ac-tier-bonus strong { color: #fff; font-weight: 700; }
.ac-tier-state {
  margin-left: auto;
  flex: none;
  align-self: center;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .55);
}

/* Stat progression table --------------------------------------------------- */
.ac-prog {
  --ac-prog-n: 4;
  margin-top: 16px;
  padding: 12px 18px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .24);
}
.ac-prog-row {
  display: grid;
  grid-template-columns: 96px repeat(var(--ac-prog-n), 1fr);
  align-items: center;
  gap: 0 6px;
  padding: 5px 0;
}
.ac-prog-row + .ac-prog-row { border-top: 1px solid rgba(255, 255, 255, .07); }
.ac-prog-row--head { padding-bottom: 8px; }
.ac-prog-col {
  padding: 0 4px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  text-align: center;
  color: #8996a2;
}
.ac-prog-col.is-current { color: color-mix(in srgb, var(--ac-accent) 45%, #ffffff); }
.ac-prog-label { font-size: 17px; font-weight: 500; color: #adbac5; }
.ac-prog-step {
  min-width: 0;
  padding: 2px 4px;
  border-radius: 4px;
  background: transparent;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  color: rgba(255, 255, 255, .38);
}
.ac-prog-step.is-current {
  background: color-mix(in srgb, var(--ac-accent) 55%, transparent);
  color: #fff;
}
.ac-prog-step.is-future { color: color-mix(in srgb, var(--ac-accent) 50%, #ffffff); }

/* Hover popup -------------------------------------------------------------- */
.ac-pop {
  position: fixed;
  z-index: 90;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .09s ease, transform .09s ease;
  pointer-events: none;
}
.ac-pop.is-open { opacity: 1; transform: none; }

/* =========================================================================
   ITEM ICONS -- .ai-*  (companion to .ac-card)
   Everything scales from --ai-w, so one class handles 44px scoreboard chips
   and 110px build-browser tiles alike. Category colour is --ai-accent.
   ========================================================================= */

.ai-item {
  --ai-w: 110px;
  --ai-accent: #a45fd6;
  --ai-plate: color-mix(in srgb, var(--ai-accent) 42%, #ffffff);
  --ai-plate-text: #221d2a;
  --ai-art-bg: #efe9dd;

  position: relative;
  display: flex;
  flex-direction: column;
  width: var(--ai-w);
  flex: none;
  border-radius: calc(var(--ai-w) * .036);
  overflow: hidden;
  font-family: 'Alegreya Sans', system-ui, sans-serif;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .28), inset 0 0 0 1px rgba(255, 255, 255, .07);
  -webkit-user-select: none;
  user-select: none;
}

/* Dark / "activated" treatment -- dark art well, tinted label text */
.ai-item.ai--dark {
  --ai-plate: #23262c;
  --ai-plate-text: color-mix(in srgb, var(--ai-accent) 62%, #ffffff);
  --ai-art-bg: #12151a;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .13);
}

/* Category presets ------------------------------------------------------- */
.ai-item.ai--gun      { --ai-accent: #d4842c; --ai-art-bg: #efe6d3; }
.ai-item.ai--spirit   { --ai-accent: #a45fd6; }
.ai-item.ai--vitality { --ai-accent: #5fbb52; }

/* Art well --------------------------------------------------------------- */
.ai-art {
  position: relative;
  aspect-ratio: 1;
  background: var(--ai-art-bg) center / cover no-repeat;
}
.ai-art > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Tier corner ------------------------------------------------------------ */
.ai-tier {
  position: absolute;
  top: 0;
  right: 0;
  width: calc(var(--ai-w) * .31);
  aspect-ratio: 1;
  background: var(--ai-accent);
  clip-path: polygon(100% 0, 0 0, 100% 100%);
  pointer-events: none;
}
.ai-tier > span {
  position: absolute;
  top: max(1px, calc(var(--ai-w) * .012));
  right: max(2px, calc(var(--ai-w) * .042));
  font-size: max(8px, calc(var(--ai-w) * .105));
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1.25;
  color: #fff;
}

/* Badge strips (bottom of the art well, stacked) ------------------------- */
.ai-badges {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  flex-direction: column;
}
.ai-badge {
  padding: calc(var(--ai-w) * .022) 0;
  background: rgba(11, 12, 15, .88);
  font-size: max(7px, calc(var(--ai-w) * .085));
  font-weight: 700;
  letter-spacing: .16em;
  line-height: 1.25;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  color: #fff;
}
.ai-badge.ai-badge--imbue { background: #342449; }

/* Below ~64px there is no room for badge text -- collapse to colour bars. */
.ai-item.ai--chip .ai-badge {
  height: 3px;
  padding: 0;
  font-size: 0;
  letter-spacing: 0;
  background: rgba(232, 238, 243, .82);
}
.ai-item.ai--chip .ai-badge.ai-badge--imbue { background: #9a6fd0; }
.ai-item.ai--chip .ai-badges { gap: 1px; padding-bottom: 1px; }

/* Label plate ------------------------------------------------------------ */
.ai-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(var(--ai-w) * .33);
  padding: calc(var(--ai-w) * .055) calc(var(--ai-w) * .05);
  background: var(--ai-plate);
  font-size: calc(var(--ai-w) * .118);
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  text-wrap: balance;
  color: var(--ai-plate-text);
}

/* Layout helpers --------------------------------------------------------- */
.ai-grid { display: flex; flex-wrap: wrap; gap: calc(var(--ai-gap, 6px)); align-items: flex-start; }
.ai-row  { display: flex; flex-wrap: nowrap; gap: 2px; align-items: flex-start; }
