/* Potion belt - inventory picker + use confirmation */

.potion-belt-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.potion-belt-backdrop {
  position: absolute;
  inset: 0;
  background: var(--modal-backdrop);
  backdrop-filter: blur(4px);
}

.potion-belt-panel {
  position: relative;
  z-index: 1;
  width: min(1040px, 100%);
  max-height: min(92vh, 880px);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: linear-gradient(
    180deg,
    var(--color-modal-shell-start) 0%,
    var(--color-modal-shell-end) 100%
  );
  box-shadow: var(--shadow-lg);
  color: var(--color-text);
  /* Readable potion palette on light modal shells */
  --pb-heading: #065f46;
  --pb-title: #047857;
  --pb-accent: #059669;
  --pb-label: #374151;
  --pb-muted: #4b5563;
  --pb-spell: #4338ca;
  --pb-spell-val: #5b21b6;
  --pb-ready: #047857;
  --pb-pending: #b45309;
  --pb-stage-border: rgba(5, 150, 105, 0.45);
  --pb-stage-bg: var(--color-background-secondary);
}

html[data-theme="dark"] .potion-belt-panel,
:root:not([data-theme="light"]) .potion-belt-panel {
  --pb-heading: #6ee7b7;
  --pb-title: #a7f3d0;
  --pb-accent: #34d399;
  --pb-label: #d1d5db;
  --pb-muted: #9ca3af;
  --pb-spell: #a5b4fc;
  --pb-spell-val: #c4b5fd;
  --pb-ready: #34d399;
  --pb-pending: #fbbf24;
  --pb-stage-border: rgba(52, 211, 153, 0.45);
}

.potion-belt-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-modal-shell-header);
  flex-shrink: 0;
}

.potion-belt-header h2 {
  margin: 0;
  font-family: Cinzel, serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--pb-heading);
}

.potion-belt-header h2 i {
  margin-right: 8px;
  color: var(--pb-accent);
}

.potion-belt-sub {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: var(--pb-muted);
  max-width: 420px;
  line-height: 1.45;
}

.potion-belt-header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.potion-belt-count {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--pb-heading);
  white-space: nowrap;
}

.potion-belt-close {
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}

.potion-belt-close:hover {
  color: var(--color-text);
  background: var(--color-surface-hover);
}

.potion-belt-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
}

.potion-belt-preview {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
}

.potion-belt-preview-stage {
  position: relative;
  margin: 16px 16px 0;
  min-height: 200px;
  max-height: 42vh;
  flex: 1;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid var(--pb-stage-border);
  background:
    radial-gradient(circle at 50% 110%, rgba(16, 185, 129, 0.12), transparent 55%),
    var(--pb-stage-bg);
  box-shadow: inset 0 0 40px rgba(16, 185, 129, 0.06);
}

.potion-belt-preview-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 20px;
  filter: drop-shadow(0 12px 24px rgba(16, 185, 129, 0.35));
  transition: transform 0.2s ease;
}

.potion-belt-preview:not(.potion-belt-preview--empty) .potion-belt-preview-img {
  animation: potion-belt-preview-pop 0.35s ease;
}

@keyframes potion-belt-preview-pop {
  from {
    transform: scale(0.88);
    opacity: 0.5;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.potion-belt-preview-img--hidden {
  opacity: 0;
  pointer-events: none;
}

.potion-belt-preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
  color: var(--pb-muted);
}

.potion-belt-preview-empty i {
  font-size: 2.25rem;
  color: var(--pb-accent);
  opacity: 0.75;
}

.potion-belt-preview-empty p {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.5;
  max-width: 240px;
  color: var(--pb-label);
}

.potion-belt-preview--empty .potion-belt-preview-empty {
  display: flex;
}

.potion-belt-preview:not(.potion-belt-preview--empty) .potion-belt-preview-empty {
  display: none;
}

.potion-belt-preview-meta {
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  overflow-y: auto;
  max-height: 46vh;
}

.potion-belt-preview-kicker {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--pb-label);
}

.potion-belt-preview-title {
  margin: 0;
  font-family: Cinzel, serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--pb-title);
  line-height: 1.25;
}

.potion-belt-preview--empty .potion-belt-preview-title {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--pb-muted);
}

.potion-belt-preview-status {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--pb-muted);
}

.potion-belt-preview-status--ready {
  color: var(--pb-ready);
}

.potion-belt-preview-status--pending {
  color: var(--pb-pending);
}

.potion-belt-desc-heading,
.potion-belt-effects-heading {
  margin: 8px 0 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--pb-label);
}

.potion-belt-preview-desc {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--color-text);
}

.potion-belt-linked-spell {
  margin: 0 0 8px;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--pb-spell);
}

.potion-belt-linked-spell i {
  margin-right: 6px;
}

.potion-belt-spell-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.potion-belt-spell-icon {
  flex-shrink: 0;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.potion-belt-effects {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.potion-belt-effect {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(124, 115, 255, 0.1);
  border: 1px solid rgba(124, 115, 255, 0.28);
  font-size: 0.875rem;
  color: var(--color-text);
}

.potion-belt-effect-name {
  font-weight: 700;
}

.potion-belt-effect-value {
  font-weight: 800;
  color: var(--pb-spell-val);
}

.potion-belt-no-effects {
  margin: 0;
  font-size: 0.875rem;
  color: var(--pb-muted);
  font-style: italic;
}

.potion-belt-use {
  width: 100%;
  margin-top: 8px;
}

.potion-belt-use--busy {
  opacity: 0.75;
  pointer-events: none;
}

.potion-belt-inventory {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding: 12px 14px 14px;
}

.potion-belt-inventory-label {
  margin: 0 0 10px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--pb-label);
}

.potion-belt-inventory-label i {
  margin-right: 6px;
  color: var(--pb-accent);
}

.potion-belt-loading,
.potion-belt-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--pb-label);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.55;
}

.potion-belt-loading--hidden,
.potion-belt-empty--hidden,
.potion-belt-slots--hidden {
  display: none;
}

.potion-belt-slots {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
  align-content: start;
  padding: 2px;
}

.potion-belt-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: inherit;
  text-align: center;
}

.potion-belt-slot-flask {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  max-width: 88px;
  border-radius: 14px;
  padding: 8px;
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.12), rgba(0, 0, 0, 0.15));
  border: 2px solid rgba(16, 185, 129, 0.25);
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}

.potion-belt-slot-flask img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25));
}

.potion-belt-slot:hover .potion-belt-slot-flask {
  border-color: rgba(52, 211, 153, 0.65);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.2);
}

.potion-belt-slot--selected .potion-belt-slot-flask {
  border-color: #34d399;
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.35), 0 8px 24px rgba(16, 185, 129, 0.25);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.22), rgba(0, 0, 0, 0.1));
}

.potion-belt-slot--pending .potion-belt-slot-flask {
  opacity: 0.65;
  filter: grayscale(0.35);
}

.potion-belt-slot--disabled {
  cursor: not-allowed;
}

.potion-belt-slot-qty {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 22px;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.75);
  color: #6ee7b7;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.2;
}

.potion-belt-slot-pending {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  color: #fbbf24;
  font-size: 0.75rem;
}

.potion-belt-slot-name {
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-text);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.potion-belt-panel .btn-primary:disabled {
  background: var(--color-surface-hover) !important;
  color: var(--pb-label) !important;
  border: 1px solid var(--color-border) !important;
  opacity: 1;
}

/* ── Potion used confirmation ─────────────────────────────────────────────── */

.potion-used-overlay {
  position: fixed;
  inset: 0;
  z-index: 12100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.potion-used-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
}

.potion-used-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 540px;
  max-height: min(90dvh, 880px);
  overflow-y: auto;
  padding: 26px 28px 24px;
  border-radius: 20px;
  background: linear-gradient(180deg, #ecfdf5 0%, #f0fdf4 40%, var(--color-modal-shell-end) 100%);
  border: 2px solid rgba(16, 185, 129, 0.4);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
  text-align: center;
  color: var(--color-text);
}

.potion-used-panel--celebrate {
  animation: potion-used-panel-in 0.4s ease;
}

@keyframes potion-used-panel-in {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.potion-used-kicker {
  margin: 0 0 12px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #059669;
}

.potion-used-image-wrap {
  width: 96px;
  height: 96px;
  margin: 0 auto 14px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--color-surface);
  border: 2px solid rgba(16, 185, 129, 0.3);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.2);
}

.potion-used-image-wrap--large {
  width: 140px;
  height: 140px;
  border-radius: 20px;
  animation: potion-used-flask-glow 1.2s ease;
}

@keyframes potion-used-flask-glow {
  0%,
  100% {
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.2);
  }
  50% {
    box-shadow: 0 12px 40px rgba(16, 185, 129, 0.45);
  }
}

.potion-used-image-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
}

.potion-used-name {
  margin: 0 0 6px;
  font-family: Cinzel, serif;
  font-size: 1.35rem;
  color: #047857;
}

.potion-used-for {
  margin: 0 0 16px;
  font-size: 0.9375rem;
  color: var(--color-text);
}

.potion-used-effect-h {
  margin: 0 0 8px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text);
}

.potion-used-desc {
  margin: 0 0 16px;
  font-size: 0.92rem;
  line-height: 1.5;
  text-align: left;
}

.potion-used-spell-h {
  margin: 16px 0 8px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text);
  text-align: left;
}

.potion-used-spell-inner {
  text-align: left;
  padding: 12px;
  border-radius: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.potion-used-spell-inner .spell-cast-result-icon {
  max-width: 48px;
}

.potion-used-spell-inner .spell-cast-result-title {
  font-size: 1rem;
}

.potion-used-spell-fail {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #b91c1c;
  font-size: 0.88rem;
  text-align: left;
}

.potion-used-spell-fail i {
  margin-right: 6px;
}

.potion-used-dismiss {
  margin-top: 8px;
  min-width: 140px;
}

@media (max-width: 768px) {
  .potion-belt-overlay {
    padding: 0;
    align-items: stretch;
  }

  .potion-belt-panel {
    width: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .potion-belt-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .potion-belt-preview {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  .potion-belt-preview-stage {
    min-height: 160px;
    max-height: 32vh;
  }

  .potion-belt-preview-meta {
    max-height: none;
  }

  .potion-belt-slots {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  }
}

.potion-belt-charge-picker {
  margin: 12px 0 4px;
}

.potion-belt-charge-picker--hidden {
  display: none;
}

.potion-belt-charge-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text-muted, #6b7280);
}

.potion-belt-charge-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.potion-belt-charge-input {
  width: 4rem;
  text-align: center;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-weight: 600;
}

.potion-belt-charge-minus,
.potion-belt-charge-plus {
  min-width: 2.25rem;
  padding: 6px 10px;
}
