/* ==========================================================================
   build.css — Build Your Kit (drag-and-drop configurator)
   Interaction handled by the inline script in build.html.
   ========================================================================== */

.builder {
  padding-block: var(--section-space-s);
  padding-inline: var(--space-gutter);
}

.builder-dnd {
  max-width: var(--container);
  margin-inline: auto;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: var(--space-l);
  align-items: start;
}

/* --- Palette --- */
.palette {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 108px);
  overflow-y: auto;
  background: var(--pebble);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: var(--space-m);
  display: flex;
  flex-direction: column;
  gap: var(--space-m);
}

.palette-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: var(--text-h3);
  color: var(--deep-ocean);
  line-height: 1;
}

.palette-hint {
  font-size: var(--text-small);
  color: var(--graphite);
  line-height: 1.5;
  margin-top: calc(var(--space-s) * -1 + 4px);
}

.palette-group h4 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--graphite);
  margin-bottom: var(--space-xs);
}

.parts {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.part {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-s);
  width: 100%;
  text-align: left;
  background: var(--off-white);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: var(--space-xs) var(--space-s);
  cursor: grab;
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast), border-color var(--duration-fast);
}

.part:hover {
  border-color: var(--terracotta);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.part:active {
  cursor: grabbing;
}

.part:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 2px;
}

.part.dragging {
  opacity: 0.45;
}

.part-ic {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--coastal-soft);
  display: grid;
  place-items: center;
  color: var(--deep-ocean);
}

.part-ic .material-symbols-outlined {
  font-size: 22px;
}

.part-name {
  font-weight: 600;
  font-size: var(--text-small);
  color: var(--charcoal);
}

.part-price {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--text-small);
  color: var(--deep-ocean);
}

/* --- Canvas --- */
.canvas-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-s);
}

.canvas-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.canvas-head h2 {
  font-size: var(--text-h3);
  font-weight: 800;
}

.clear-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--graphite);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: color var(--duration-fast), background var(--duration-fast);
}

.clear-btn:hover {
  color: var(--terracotta);
  background: var(--pebble);
}

.clear-btn .material-symbols-outlined {
  font-size: 18px;
}

.canvas {
  min-height: 440px;
  border: 2px dashed var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--off-white);
  padding: var(--space-m);
  transition: border-color var(--duration-fast), background var(--duration-fast);
}

.canvas.is-over {
  border-color: var(--terracotta);
  background: var(--coastal-soft);
}

/* [hidden] must beat the display rules below (JS toggles these) */
.canvas-empty[hidden],
.build-tiles[hidden] {
  display: none;
}

.canvas-empty {
  min-height: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-2xs);
  color: var(--graphite);
  pointer-events: none;
}

.canvas-empty .material-symbols-outlined {
  font-size: 48px;
  color: var(--coastal-blue);
  margin-bottom: var(--space-2xs);
}

.canvas-empty strong {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--text-h4);
  color: var(--deep-ocean);
}

.canvas-empty span {
  font-size: var(--text-small);
  max-width: 42ch;
  line-height: 1.5;
}

/* --- Build tiles --- */
.build-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-s);
}

.tile {
  position: relative;
  background: var(--pebble);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: var(--space-s);
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  align-items: flex-start;
  animation: scaleIn 0.35s var(--ease-out);
}

.tile-rm {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: rgba(27, 94, 122, 0.08);
  color: var(--graphite);
  display: grid;
  place-items: center;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.tile-rm:hover {
  background: var(--terracotta);
  color: #fff;
}

.tile-rm .material-symbols-outlined {
  font-size: 16px;
}

.tile-ic {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--coastal-soft);
  display: grid;
  place-items: center;
  color: var(--deep-ocean);
}

.tile-ic .material-symbols-outlined {
  font-size: 24px;
}

.tile-name {
  font-weight: 600;
  font-size: var(--text-small);
  color: var(--charcoal);
  line-height: 1.3;
}

.tile-price {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--deep-ocean);
}

/* --- Summary bar --- */
.build-summary {
  display: flex;
  align-items: center;
  gap: var(--space-m);
  flex-wrap: wrap;
  background: var(--deep-ocean);
  color: var(--off-white);
  border-radius: var(--radius-lg);
  padding: var(--space-m) var(--space-l);
}

.bs-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 auto;
}

.bs-count {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--off-white);
}

.bs-ship {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-small);
  color: var(--coastal-blue);
}

.bs-ship .material-symbols-outlined {
  font-size: 18px;
}

.bs-ship.free {
  color: #9fe0b4;
}

.bs-total {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.bt-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--coastal-blue);
}

.bt-value {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1;
  color: var(--off-white);
}

.build-summary .btn-primary[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.build-note {
  font-size: var(--text-small);
  color: var(--graphite);
  line-height: 1.5;
  max-width: 74ch;
}

/* --- Responsive --- */
@media (max-width: 860px) {
  .builder-dnd {
    grid-template-columns: 1fr;
    gap: var(--space-m);
  }

  .palette {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .parts {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .build-summary {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }

  .bs-total {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
  }

  .build-summary .btn-primary {
    justify-content: center;
  }

  .parts {
    grid-template-columns: 1fr;
  }
}
