/*
 * Approved Bag feedback and Custom step player.
 * Hostname loading is enforced by inc/ui-feedback.php.
 */

/* Existing Bag: retain its icon, geometry and panel; animate only count and icon. */
.norbu-floating-bag-count,
[data-norbu-mobile-cart-count] {
  overflow: hidden;
  isolation: isolate;
}

.norbu-floating-bag-count.is-lhari-counting,
[data-norbu-mobile-cart-count].is-lhari-counting {
  color: transparent !important;
  animation: LHARIBagBadgePop .62s cubic-bezier(.22, 1, .36, 1) both;
}

.norbu-floating-bag-count.is-lhari-counting::before,
.norbu-floating-bag-count.is-lhari-counting::after,
[data-norbu-mobile-cart-count].is-lhari-counting::before,
[data-norbu-mobile-cart-count].is-lhari-counting::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  color: #fff8ec;
  font: inherit;
  line-height: inherit;
  pointer-events: none;
}

.norbu-floating-bag-count.is-lhari-counting::before,
[data-norbu-mobile-cart-count].is-lhari-counting::before {
  content: attr(data-lhari-count-from);
}

.norbu-floating-bag-count.is-lhari-counting::after,
[data-norbu-mobile-cart-count].is-lhari-counting::after {
  content: attr(data-lhari-count-to);
}

[data-lhari-count-direction="up"].is-lhari-counting::before {
  animation: LHARICountOldUp .58s cubic-bezier(.22, 1, .36, 1) both;
}

[data-lhari-count-direction="up"].is-lhari-counting::after {
  animation: LHARICountNewUp .58s cubic-bezier(.22, 1, .36, 1) both;
}

[data-lhari-count-direction="down"].is-lhari-counting::before {
  animation: LHARICountOldDown .58s cubic-bezier(.22, 1, .36, 1) both;
}

[data-lhari-count-direction="down"].is-lhari-counting::after {
  animation: LHARICountNewDown .58s cubic-bezier(.22, 1, .36, 1) both;
}

.norbu-floating-bag-button.is-lhari-bag-ringing .norbu-floating-bag-icon {
  transform-origin: 50% -7px;
  animation: LHARIBagSwing .72s cubic-bezier(.36, .07, .19, .97) .82s both;
}

[data-norbu-floating-bag-open].is-lhari-bag-ringing svg {
  transform-origin: 50% 18%;
  animation: LHARIBagSwing .72s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes LHARIBagBadgePop {
  0% { transform: scale(.74); }
  42% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

@keyframes LHARICountOldUp {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-112%); }
}

@keyframes LHARICountNewUp {
  0% { opacity: 0; transform: translateY(112%); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes LHARICountOldDown {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(112%); }
}

@keyframes LHARICountNewDown {
  0% { opacity: 0; transform: translateY(-112%); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes LHARIBagSwing {
  0%, 100% { transform: rotate(0deg); }
  18% { transform: rotate(-15deg); }
  36% { transform: rotate(12deg); }
  54% { transform: rotate(-8deg); }
  70% { transform: rotate(5deg); }
  84% { transform: rotate(-2deg); }
}

/* Custom Step player: actual form state drives a seekable, labelled track. */
.lhari-custom-step-player {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  margin-top: 12px;
  padding-top: 20px;
  border-top: 1px solid rgba(48, 42, 35, .2);
}

.lhari-custom-step-player .lhari-custom-steps {
  min-width: 0;
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.lhari-custom-step-player .lhari-custom-steps li {
  display: block;
  flex: 0 0 auto;
  margin: 0;
}

.lhari-custom-step-player .lhari-custom-steps li::after { display: none !important; }

.lhari-custom-step-player .lhari-custom-steps button {
  --lhari-step-fill: 0%;
  position: relative;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 0;
  overflow: hidden;
  padding: 0 14px;
  border: 1px solid rgba(49, 92, 114, .23);
  border-radius: 999px;
  background: rgba(255, 252, 246, .5);
  color: #315c72;
  cursor: pointer;
  transition: width .42s cubic-bezier(.22, 1, .36, 1), color .24s ease, background .24s ease, border-color .24s ease, transform .2s ease;
}

.lhari-custom-step-player .lhari-custom-steps button:hover,
.lhari-custom-step-player .lhari-custom-steps button:focus-visible {
  border-color: rgba(49, 92, 114, .55);
  transform: translateY(-1px);
  outline: 2px solid rgba(49, 92, 114, .22);
  outline-offset: 3px;
}

.lhari-custom-step-player .lhari-custom-steps li.is-active button {
  width: 162px;
  border-color: #071522;
  background: #071522;
  color: #fffaf0;
}

.lhari-custom-step-player .lhari-custom-steps li.is-complete button {
  border-color: #315c72;
  background: #315c72;
  color: #fffaf0;
}

.lhari-custom-step-number {
  position: relative;
  z-index: 2;
  flex: 0 0 14px;
  color: inherit !important;
  font-size: 9px !important;
  font-weight: 800;
  line-height: 1;
  letter-spacing: .03em;
}

.lhari-custom-step-copy {
  position: relative;
  z-index: 2;
  max-width: 0;
  overflow: hidden;
  color: inherit !important;
  font-size: 9px !important;
  font-weight: 800;
  line-height: 1;
  letter-spacing: .1em;
  opacity: 0;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translateX(-5px);
  transition: max-width .35s cubic-bezier(.22, 1, .36, 1), margin .35s ease, opacity .22s ease, transform .35s ease;
}

.lhari-custom-steps li.is-active .lhari-custom-step-copy {
  max-width: 112px;
  margin-left: 10px;
  opacity: 1;
  transform: translateX(0);
}

.lhari-custom-step-fill {
  position: absolute;
  left: 8px;
  right: auto;
  bottom: 5px;
  z-index: 1;
  width: var(--lhari-step-fill);
  max-width: calc(100% - 16px);
  height: 2px;
  border-radius: 999px;
  background: #a9c0c6;
  transform-origin: left center;
  transition: width .48s cubic-bezier(.22, 1, .36, 1);
}

.lhari-custom-step-status {
  margin: 0 !important;
  color: #70685f;
  font: 700 9px/1.3 Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.lhari-custom-step-target { scroll-margin-top: 160px; }

@media (max-width: 760px) {
  .lhari-custom-step-player {
    grid-template-columns: minmax(0, 1fr);
    gap: 13px;
  }

  .lhari-custom-step-player .lhari-custom-steps {
    width: 100%;
    justify-content: space-between;
    gap: 5px;
  }

  .lhari-custom-step-player .lhari-custom-steps button {
    width: 38px;
    height: 38px;
    padding: 0 12px;
  }

  .lhari-custom-step-player .lhari-custom-steps li.is-active button { width: 126px; }
  .lhari-custom-steps li.is-active .lhari-custom-step-copy { max-width: 84px; margin-left: 7px; font-size: 8px !important; }
  .lhari-custom-step-status { white-space: normal; }
  .lhari-custom-step-target { scroll-margin-top: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  .norbu-floating-bag-count.is-lhari-counting,
  [data-norbu-mobile-cart-count].is-lhari-counting,
  .norbu-floating-bag-button.is-lhari-bag-ringing .norbu-floating-bag-icon,
  [data-norbu-floating-bag-open].is-lhari-bag-ringing svg {
    animation: none !important;
  }

  .lhari-custom-step-player .lhari-custom-steps button,
  .lhari-custom-step-copy,
  .lhari-custom-step-fill {
    transition: none !important;
  }
}
