/* The field bag in the character sheet.
 *
 * One of the stylesheets split out of the old style.css. index.html links them
 * in the order they had in that file, so the cascade is unchanged - keep
 * that order when adding a rule, or a later sheet may win where it used to lose. */

/* --- Field bag ----------------------------------------------------------
   A slot is a piece of the capacity, not a shop row. Empty slots stay visible
   so the limit reads before the player runs into it. */

.bag-panel {
  position: relative;
  margin: 0 0 14px;
  padding: 0 0 0 16px;
  border-left: 1px solid var(--rule);
}

.bag-panel-heading,
.bag-header,
.bag-hand,
.bag-details {
  display: flex;
  align-items: center;
}

.bag-panel-heading {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 9px;
}

.bag-panel-heading .eyebrow { margin: 0 0 2px; }
.bag-panel-heading h3 { margin: 0; color: #f2dfb8; font-size: 18px; }
.bag-panel-hint { margin: 0; max-width: 235px; color: var(--muted); font-size: 10px; text-align: right; line-height: 1.35; }

.bag-header {
  justify-content: space-between;
  gap: 12px;
  min-height: 43px;
  padding: 4px 0 8px;
}

.bag-capacity { display: flex; align-items: baseline; gap: 7px; }
.bag-capacity strong { color: #f1c66f; font-size: 18px; }
.bag-capacity span { color: var(--muted); font-size: 11px; }
#char-inventory[data-fill="full"] .bag-capacity strong { color: #e29a52; }
#char-inventory[data-fill="overflow"] .bag-capacity strong,
#char-inventory[data-fill="overflow"] .bag-capacity span { color: #ef7777; }

/* The bag carried, and where a bigger one is sold (js/ui/shop.js). */
.bag-shop-pointer { color: var(--muted); font-size: 11px; line-height: 1.3; text-align: right; }
.bag-maxed { color: var(--gold); font-size: 11px; }

.bag-hand {
  position: relative;
  gap: 10px;
  min-height: 64px;
  margin: 8px 0;
  padding: 9px 9px 9px 82px;
  background: var(--row);
}

.bag-hand-label {
  position: absolute;
  inset: 0 auto 0 0;
  width: 70px;
  display: grid;
  place-items: center;
  color: #d5b677;
  border-right: 1px solid var(--rule);
  font-size: 11px;
}

.bag-hand-icon {
  width: 46px;
  height: 46px;
  object-fit: contain;
  image-rendering: pixelated;
  padding: 2px;
  background: #090b0d;
  border: 1px solid #4a3b29;
}
.bag-hand-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.bag-hand-info strong { color: #fff0c9; font-size: 13px; }
.bag-hand-info small { color: var(--muted); font-size: 10px; }
.bag-hand-empty { flex: 1; display: flex; align-items: center; gap: 12px; color: var(--muted); }
.bag-hand-empty > span { color: #5c5548; font-size: 28px; }
.bag-hand-empty div { display: flex; flex-direction: column; gap: 2px; }
.bag-hand-empty strong { color: #c8b995; font-size: 12px; }
.bag-hand-empty small { font-size: 10px; }
.bag-grid-frame {
  padding: 0;
}

.bag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 8px;
}

.bag-slot {
  position: relative;
  min-width: 0 !important;
  width: 100%;
  aspect-ratio: 1;
  min-height: 0 !important;
  padding: 6px !important;
  overflow: hidden;
  background: var(--row);
  border: 1px solid var(--edge);
  outline: 1px solid transparent;
  box-shadow: none;
}

/* Room still free: a faint outline, so the bag's size reads before it fills. */
.bag-slot.empty {
  background: transparent;
  border: 1px dashed var(--empty-edge);
}

button.bag-slot.filled {
  display: flex;
  flex-direction: column;
  gap: 1px;
  cursor: pointer;
}
button.bag-slot.filled:hover,
button.bag-slot.filled.selected {
  border-color: var(--edge-strong);
  background-color: var(--row-hover);
}
button.bag-slot.filled.selected { border-color: var(--gold); }
.bag-slot.overflow { border-color: #8d3337; outline-color: #5a1f23; }
.bag-slot img { width: min(54px, 82%); height: min(54px, 72%); object-fit: contain; image-rendering: pixelated; pointer-events: none; }
.bag-gear-icon { width: min(54px, 82%); height: min(54px, 72%); display: grid; place-items: center; color: #d8c18d; font-size: 30px; pointer-events: none; }
.bag-gear-icon img { width: 100%; height: 100%; object-fit: contain; }
.bag-slot-name { width: 100%; overflow: hidden; color: #cfc3a9; font-size: 9px; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
.bag-quantity {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 19px;
  padding: 2px 3px;
  color: #fff2cc;
  background: #21170d;
  border: 1px solid var(--gold);
  box-shadow: 1px 2px 0 #000;
  font-size: 9px;
  line-height: 1;
  text-align: center;
  pointer-events: none;
}

.bag-details {
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  margin-top: 10px;
  padding: 10px 0 0;
  border-top: 1px solid var(--rule);
}
.bag-detail-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.bag-detail-copy strong { color: #fff0c9; font-size: 12px; }
.bag-detail-copy small { color: var(--muted); font-size: 9px; }
.bag-actions { display: flex; align-items: flex-end; gap: 8px; min-height: 34px; }
.bag-actions button { min-width: 62px !important; min-height: 34px !important; padding: 5px 9px !important; font-size: 10px !important; }
.bag-action-sell { color: #efc98f; }
.bag-action-upgrade { color: #a9cdec; }
.bag-action-discard { color: #df8b78; }
.bag-empty-note { margin: 0; color: var(--muted); font-size: 10px; }

/* Potions and draughts in the other party members' bags - same stock, drunk
   the same way; see partySupplies in server/gameManager.js. */
.bag-party-supplies {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.bag-party-supplies-title {
  flex: 1 0 100%;
  margin: 0;
  color: #cdb07a;
  font-size: 12px;
}
.bag-party-supply {
  min-width: 0 !important;
  min-height: 44px !important;
  padding: 6px 10px !important;
  gap: 8px !important;
  font-size: 11px !important;
  text-transform: none !important;
}
.bag-party-supply img { width: 24px; height: 24px; image-rendering: pixelated; }
.bag-party-supply.selected { outline-color: var(--gold); background-color: #30373a; }

.discard-confirmation-prompt {
  background: rgba(26, 18, 20, 0.95);
  border: 1px solid rgba(220, 70, 70, 0.4);
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  text-align: center;
}
.discard-confirmation-prompt p {
  margin: 0;
  font-size: 11px;
  color: #f08080;
  font-weight: 500;
}
.discard-confirmation-prompt .prompt-actions {
  display: flex;
  gap: 8px;
}
.discard-btn-confirm {
  background: #a33828 !important;
  color: #fff !important;
  border: 1px solid #c44 !important;
  padding: 3px 12px !important;
  border-radius: 4px;
  font-size: 11px !important;
  cursor: pointer;
  font-weight: 600;
  min-height: 28px !important;
}
.discard-btn-confirm:hover {
  background: #c44 !important;
}
.discard-btn-cancel {
  background: #333842 !important;
  color: #ccc !important;
  border: 1px solid #555 !important;
  padding: 3px 12px !important;
  border-radius: 4px;
  font-size: 11px !important;
  cursor: pointer;
  min-height: 28px !important;
}
.discard-btn-cancel:hover {
  background: #444a56 !important;
  color: #fff !important;
}

@media (max-width: 520px) {
  .bag-panel { padding: 10px; }
  .bag-panel-heading { align-items: flex-end; }
  .bag-panel-hint { max-width: 140px; }
  .bag-grid { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); }
  .bag-hand { padding-left: 68px; }
  .bag-hand-label { width: 58px; }
  .bag-details { align-items: flex-start; flex-direction: column; }
  .bag-actions { width: 100%; }
  .bag-actions button { flex: 1; }
}

/* How many of a stack the Give buttons hand to another party member. */
.bag-give-field { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.bag-give-qty {
  width: 56px; min-height: 32px; padding: 4px 6px; box-sizing: border-box;
  color: var(--parchment); background: #0d1012; border: 2px solid #3b3328; border-radius: 2px;
  font: inherit; font-size: 13px; text-align: center;
}
.bag-give-qty:focus-visible { outline: 2px solid #f1c66f; outline-offset: 1px; }

/* With Give buttons a stack can offer seven or eight actions, more than one
   row holds beside the item's name: let them wrap rather than push the sheet
   sideways and squeeze the name into a column one word wide. */
.bag-details { flex-wrap: wrap; }
.bag-detail-copy { flex: 1 1 150px; }
.bag-actions { flex-wrap: wrap; justify-content: flex-end; row-gap: 6px; }
