/* ============================================================
   PART DRAWER — persistent workshop component
   ============================================================
   Layout model:
     [ horizontal tab strip of category icons ]  ← always visible
     [ drawer panel with part grid ]             ← shown when active

   Aesthetic: candy-cane red tabs with brass dividers, butter-cream
   drawer panel that feels like pulling open a workbench drawer.
*/

.part-drawer {
  /* The drawer spans the workspace horizontally, sits BETWEEN the
     header row and the circuit rails. See index.html. */
  width: 100%;
  background: transparent;
  margin-bottom: 8px;
  position: relative;
  z-index: 5;
}

/* ----------- TAB STRIP ----------- */
.drawer-tabstrip {
  display: flex;
  gap: 4px;
  padding: 6px 8px 0;
  background: linear-gradient(180deg, var(--wood) 0%, var(--wood-dark) 100%);
  border: 3px solid var(--brass-dark);
  border-radius: 6px 6px 0 0;
  border-bottom: 2px solid var(--wood-dark);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.15);
}

/* If no drawer body, round the bottom too */
.part-drawer:not(.drawer-open) .drawer-tabstrip {
  border-radius: 6px;
  border-bottom: 3px solid var(--brass-dark);
}

.drawer-tab {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px 8px;
  border: 2px solid var(--brass-dark);
  border-bottom: none;
  border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-dark) 100%);
  color: var(--ink);
  font-family: 'Didot', Georgia, serif;
  font-weight: bold;
  font-size: 11px;
  letter-spacing: 2px;
  cursor: pointer;
  position: relative;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.08s ease, background 0.15s ease;
}
.drawer-tab:hover {
  background: linear-gradient(180deg, var(--snow-cream) 0%, var(--paper) 100%);
  transform: translateY(-1px);
}

/* Active tab: candy-red, pops forward + down into the drawer body */
.drawer-tab.active {
  background: linear-gradient(180deg, var(--candy) 0%, var(--santa) 100%);
  color: var(--snow-cream);
  border-color: var(--santa-dark);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -2px 0 var(--santa-dark),
    0 -2px 4px rgba(0, 0, 0, 0.1);
  transform: translateY(0);
  z-index: 6;
}
.drawer-tab.active::after {
  /* little "connects to drawer body" nub underneath the active tab */
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: -5px;
  height: 5px;
  background: var(--snow-cream);
  border-left: 2px solid var(--santa-dark);
  border-right: 2px solid var(--santa-dark);
}

.drawer-tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brass-dark);
}
.drawer-tab.active .drawer-tab-icon {
  color: var(--snow);
}
.drawer-tab-icon svg {
  display: block;
}

.drawer-tab-label {
  /* Keep the label visible on wider screens, hidden on narrow */
  white-space: nowrap;
}

.drawer-tab-badge {
  font-family: 'Courier New', monospace;
  font-size: 9px;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  color: var(--ink-light);
}
.drawer-tab.active .drawer-tab-badge {
  background: rgba(255, 255, 255, 0.22);
  color: var(--snow-cream);
}

/* ----------- DRAWER BODY ----------- */
.drawer-body {
  background: linear-gradient(180deg, var(--snow-cream) 0%, var(--paper) 100%);
  border: 3px solid var(--brass-dark);
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 12px 14px 14px;
  box-shadow:
    inset 0 2px 6px rgba(107, 68, 35, 0.1),
    0 3px 0 var(--brass-dark),
    0 5px 10px rgba(0, 0, 0, 0.15);
  animation: drawerSlide 0.22s cubic-bezier(0.2, 0.85, 0.4, 1) both;
}
@keyframes drawerSlide {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.drawer-body-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px dashed var(--paper-edge);
}
.drawer-body-title {
  font-family: 'Didot', Georgia, serif;
  font-size: 14px;
  letter-spacing: 3px;
  font-weight: bold;
  color: var(--santa-dark);
}
.drawer-body-sub {
  flex: 1;
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 11px;
  color: var(--ink-light);
}
.drawer-close-btn {
  background: var(--paper);
  border: 1.5px solid var(--brass-dark);
  color: var(--ink);
  padding: 2px 8px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: background 0.1s ease;
}
.drawer-close-btn:hover {
  background: var(--santa);
  color: var(--snow-cream);
  border-color: var(--santa-dark);
}

/* ----------- CARD GRID ----------- */
.drawer-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 8px;
}

.drawer-part-card {
  background: var(--snow-cream);
  border: 2px solid var(--brass);
  border-radius: 4px;
  padding: 8px 10px;
  cursor: pointer;
  position: relative;
  transition: transform 0.08s ease, box-shadow 0.08s ease, border-color 0.1s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 96px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 1px 2px rgba(107, 68, 35, 0.15);
}
.drawer-part-card:hover:not(.disabled) {
  transform: translateY(-2px);
  border-color: var(--santa);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 4px 8px rgba(200, 48, 48, 0.2);
}
.drawer-part-card:active:not(.disabled) {
  transform: translateY(0);
}

.drawer-part-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: saturate(0.4);
}
.drawer-part-card.disabled:hover {
  transform: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 1px 2px rgba(107, 68, 35, 0.15);
}

.drawer-part-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.drawer-part-name {
  font-family: Georgia, serif;
  font-weight: bold;
  font-size: 12px;
  color: var(--ink);
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-voltage {
  font-family: 'Courier New', monospace;
  font-size: 9px;
  font-weight: bold;
  padding: 1px 4px;
  border-radius: 2px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.drawer-voltage.v-9  { background: var(--santa);      color: var(--snow-cream); border: 1px solid var(--santa-dark); }
.drawer-voltage.v-5  { background: var(--gold);       color: var(--ink);        border: 1px solid var(--brass-dark); }
.drawer-voltage.v-3  { background: var(--sky);        color: var(--snow-cream); border: 1px solid var(--sky-dark); }
.drawer-voltage.v-1  { background: var(--paper-dark); color: var(--ink);        border: 1px solid var(--brass-dark); }

.drawer-part-icon-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  color: var(--ink-light);
}
.drawer-part-icon-slot svg {
  max-width: 40px;
  max-height: 34px;
}

.drawer-part-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  padding-top: 4px;
  border-top: 1px dotted var(--paper-edge);
}
.drawer-part-cat {
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
  color: var(--ink-light);
  text-transform: uppercase;
  font-size: 9px;
}
.drawer-part-cost {
  font-family: 'Didot', Georgia, serif;
  font-weight: bold;
  color: var(--santa-dark);
  font-size: 12px;
}

.drawer-disabled-overlay {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  background: rgba(107, 68, 35, 0.92);
  color: var(--snow-cream);
  padding: 4px 8px;
  font-family: 'Courier New', monospace;
  font-size: 10px;
  font-weight: bold;
  text-align: center;
  letter-spacing: 1px;
  border-top: 1px solid var(--brass-dark);
  border-bottom: 1px solid var(--brass-dark);
  pointer-events: none;
}
.drawer-part-card.reason-tier .drawer-disabled-overlay { background: rgba(58, 107, 138, 0.9); }  /* sky-dark — R&D gate */
.drawer-part-card.reason-wc .drawer-disabled-overlay { background: rgba(200, 48, 48, 0.88); }   /* red — broke */
.drawer-part-card.reason-budget .drawer-disabled-overlay { background: rgba(212, 160, 74, 0.92); color: var(--ink); }  /* amber — repair gate */

/* ----------- RESPONSIVE ----------- */
@media (max-width: 720px) {
  .drawer-tab-label { display: none; }
  .drawer-tab { padding: 7px 6px 8px; }
}
