/* Product detail palette builder - partials/palette-builder.ejs, assets/js/palette-builder.js.
   Colors come from the storefront's --shop-* tokens, so theme 9 restyles it automatically. */

.palette [hidden], .palette-sticky[hidden], .palette-sticky [hidden] { display: none !important; }

.pdp-price { margin: 4px 0 14px; }
.pdp-price .regular-price { font-size: 28px; font-weight: 700; color: var(--shop-ink, #24323f); }
.pdp-price .last { display: block; margin-top: 2px; color: var(--shop-muted, #71808d); font-size: 13px; }
.pdp-soldout { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }

.palette {
  margin: 0 0 14px; padding: 16px; border: 1px solid var(--shop-line, #dfe6eb); border-radius: 12px;
  background: linear-gradient(180deg, var(--shop-wash, #f3f6f8) 0%, #fff 70%);
}
.palette__head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; font-size: 14px; }
.palette__label { color: var(--shop-muted, #71808d); text-transform: uppercase; letter-spacing: .06em; font-size: 12px; font-weight: 600; }
.palette__name { color: var(--shop-ink, #24323f); font-size: 15px; }
.palette__stock { margin-left: auto; color: var(--shop-muted, #71808d); font-size: 12px; }

.palette__swatches {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px;
  margin: 0; padding: 2px; list-style: none; max-height: 196px; overflow-y: auto; overscroll-behavior: contain;
}
.palette__swatches li { margin: 0; padding: 0; }
.palette__swatch {
  position: relative; display: block; width: 100%; aspect-ratio: 1 / 1; padding: 0; overflow: hidden;
  border: 2px solid transparent; border-radius: 50%; background: #fff; cursor: pointer;
  box-shadow: 0 0 0 1px var(--shop-line, #dfe6eb); transition: transform .12s ease, box-shadow .12s ease;
}
.palette__swatch img, .palette__swatch .palette__dot { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.palette__swatch:hover { transform: scale(1.06); }
.palette__swatch:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--shop-blue, #3f82bd); }
.palette__swatch.is-selected { border-color: #fff; box-shadow: 0 0 0 2px var(--shop-blue, #3f82bd); }
.palette__check {
  position: absolute; right: 0; bottom: 0; display: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--shop-blue, #3f82bd); color: #fff; font-size: 10px; line-height: 18px; text-align: center;
}
.palette__swatch.is-selected .palette__check { display: block; }
.palette__dot { display: inline-block; width: 100%; height: 100%; border-radius: 50%; }

.palette__hint { margin: 10px 0 0; color: var(--shop-muted, #71808d); font-size: 12px; }
.palette__hint .fa { color: var(--shop-orange, #ef7d42); }

.palette__tray { margin: 12px 0 0; padding: 0; list-style: none; }
.palette__row {
  display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px dashed var(--shop-line, #dfe6eb);
  animation: palette-in .18s ease-out;
}
@keyframes palette-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.palette__row-thumb { flex: 0 0 36px; width: 36px; height: 36px; }
.palette__row-thumb img, .palette__row-thumb .palette__dot { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.palette__row-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.palette__row-name { font-weight: 600; color: var(--shop-ink, #24323f); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette__row-meta { color: var(--shop-muted, #71808d); font-size: 12px; }
.palette__stepper { display: inline-flex; align-items: center; border: 1px solid var(--shop-line, #dfe6eb); border-radius: 999px; background: #fff; }
.palette__step { width: 30px; height: 30px; padding: 0; border: 0; background: none; color: var(--shop-ink, #24323f); font-size: 11px; cursor: pointer; }
.palette__step:disabled { opacity: .35; cursor: default; }
.palette__packs { min-width: 22px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.palette__row-total { flex: 0 0 auto; min-width: 64px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.palette__remove { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--shop-muted, #71808d); cursor: pointer; }
.palette__remove:hover { background: var(--shop-wash, #f3f6f8); color: var(--shop-ink, #24323f); }

.palette__summary { display: flex; align-items: center; gap: 14px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--shop-line, #dfe6eb); }
.palette__total { display: flex; flex-direction: column; line-height: 1.15; }
.palette__total-label { color: var(--shop-muted, #71808d); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.palette__total-value { font-size: 22px; font-weight: 800; color: var(--shop-ink, #24323f); font-variant-numeric: tabular-nums; }
.palette__cta, .palette-sticky__cta {
  flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 999px; font-size: 15px; font-weight: 700;
}
.productDetail .right .prices .palette__cta, .prices .palette__cta { width: auto; margin: 0; float: none; }
.palette__cta:disabled, .palette-sticky__cta:disabled { opacity: .55; cursor: not-allowed; }
.palette__cta-count {
  display: inline-block; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: rgba(255, 255, 255, .25); font-size: 12px; line-height: 22px;
}
.palette__done { margin: 10px 0 0; color: #2e7d32; font-weight: 600; }
.palette__done a { margin-left: 4px; text-decoration: underline; }

.palette-sticky {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: #fff;
  box-shadow: 0 -6px 20px rgba(20, 30, 40, .12); transform: translateY(110%); transition: transform .2s ease;
}
.palette-sticky.is-visible { transform: none; }
.palette-sticky__thumb img { display: block; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.palette-sticky__total { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.palette-sticky__cta { min-height: 44px; font-size: 14px; }

@media (min-width: 768px) {
  .palette-sticky { display: none !important; }
}
@media (max-width: 767px) {
  .palette { padding: 12px; }
  .palette__swatches { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); }
  .palette__row { gap: 8px; }
  .palette__row-total { display: none; }
  .palette__summary { flex-wrap: wrap; }
  .productDetail .right .prices .palette__cta, .prices .palette__cta { flex-basis: 100%; width: 100%; }
  .palette-sticky { bottom: 56px; }
}
@media (prefers-reduced-motion: reduce) {
  .palette__swatch, .palette-sticky, .palette__row { transition: none; animation: none; }
}
