/**
 * Mini cart drawer, structure only.
 *
 * Layout, stacking and the open/closed mechanics live here because they are behaviour, not design.
 * Colour, type, spacing scale, borders and shadow belong to the theme, which styles the same
 * class names.
 *
 * Two exceptions: the panel gets an opaque ground and the scrim a dim. A modal dialog that does not
 * occlude the page behind it is unreadable and its content can be clicked through, so that is
 * behaviour, not decoration. Both are single custom properties, so the theme overrides them with one
 * declaration each - --minicart-surface and --minicart-scrim - or simply restyles the selectors.
 */

.minicart {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}

.minicart[hidden] {
  display: none;
}

.minicart__scrim {
  position: absolute;
  inset: 0;
  background: var(--minicart-scrim, rgb(12 14 16 / 0.55));
  opacity: 0;
  transition: opacity 240ms ease;
  pointer-events: none;
}

.minicart__panel {
  position: relative;
  background: var(--minicart-surface, Canvas);
  color: var(--minicart-ink, CanvasText);
  display: flex;
  flex-direction: column;
  width: min(30rem, 100vw);
  max-width: 100%;
  height: 100%;
  overflow: hidden auto;
  overscroll-behavior: contain;
  transform: translateX(100%);
  transition: transform 260ms ease;
  pointer-events: none;
}

.minicart.is-open {
  pointer-events: auto;
}

.minicart.is-open .minicart__scrim {
  opacity: 1;
  pointer-events: auto;
}

.minicart.is-open .minicart__panel {
  transform: translateX(0);
  pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
  .minicart__scrim,
  .minicart__panel {
    transition: none;
  }
}

.minicart__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex: 0 0 auto;
}

.minicart__body {
  flex: 1 1 auto;
  min-height: 0;
}

.minicart__items {
  margin: 0;
  padding: 0;
  list-style: none;
}

.minicart__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 0.75rem;
}

.minicart__media img {
  display: block;
  max-width: 100%;
  height: auto;
}

.minicart__detail {
  min-width: 0;
}

.minicart__title {
  display: inline-block;
  overflow-wrap: anywhere;
}

.minicart__meta > * {
  display: block;
}

.minicart__qty {
  display: inline-flex;
  align-items: center;
}

.minicart__qty-input {
  width: 4em;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}

.minicart__qty-input::-webkit-outer-spin-button,
.minicart__qty-input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
}

/* Pointer target floor from BRIEF 12.4 (WCAG 2.5.8). */
.minicart__qty-step,
.minicart__remove,
.minicart__close {
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
}

.minicart__line {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.minicart__foot {
  position: sticky;
  bottom: 0;
  flex: 0 0 auto;
}

.minicart__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.minicart__actions > * {
  flex: 1 1 10rem;
  text-align: center;
}

.minicart__undo[hidden] {
  display: none;
}

.minicart__undo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.minicart__live {
  margin: 0;
}

.minicart.is-busy .minicart__body {
  opacity: 0.6;
}

/* Body scroll lock while the dialog is open. */
.wewira-scroll-lock,
.wewira-scroll-lock body {
  overflow: hidden;
}

/* Add to cart feedback and badge pulse; the theme supplies the visual language. */
@keyframes wewira-cart-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

[data-cart-count].is-pulsing {
  animation: wewira-cart-pulse 480ms ease;
}

@media (prefers-reduced-motion: reduce) {
  [data-cart-count].is-pulsing {
    animation: none;
  }
}
