/* =============================================================================
   unimissidecart — slide-out side cart drawer + free-shipping progress bar
   -----------------------------------------------------------------------------
   Owned file (CSS layer Ⓑ). Self-contained, registered sitewide.
   Everything is scoped under .unimis-sidecart / .unimis-freeship so nothing
   leaks into the theme. Brand tokens come from themes/unimis_theme custom.css
   (:root{ --unimis-* }) and are referenced with safe fallbacks.

   Mobile-first: base rules target small screens; desktop is layered in a
   min-width media query.
   ========================================================================== */

/* -----------------------------------------------------------------------------
   Local tokens — derive from brand tokens with fallbacks. Keeps the rest of the
   file readable and gives one place to tune the drawer.
   -------------------------------------------------------------------------- */
.unimis-sidecart {
  --sc-brand: var(--unimis-brand, #ea5e25);
  --sc-brand-rgb: var(--unimis-brand-rgb, 234, 94, 37);
  --sc-brand-dark: var(--unimis-brand-dark, #c94e1d);
  --sc-accent: var(--unimis-accent, #f7b139);
  --sc-heading: var(--unimis-heading, #0e332f);

  /* No green brand token exists — use a tasteful success green as fallback. */
  --sc-success: var(--unimis-success, #2e9e5b);
  --sc-success-rgb: var(--unimis-success-rgb, 46, 158, 91);

  --sc-radius: var(--unimis-radius, 10px);
  --sc-radius-sm: var(--unimis-radius-sm, 4px);

  --sc-surface: #ffffff;
  --sc-text: #212121;
  --sc-muted: rgba(33, 33, 33, 0.6);
  --sc-border: #e6e6e6;
  --sc-track: #ededed;
  --sc-overlay-bg: rgba(14, 51, 47, 0.5);

  --sc-panel-width: 400px;
  --sc-pad: 1.25rem;
  --sc-anim: 320ms;
  --sc-ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* z-index: above page content, ~1050 (typical modal layer). */
  --sc-z: 1050;
}

/* -----------------------------------------------------------------------------
   Root — the HTML `hidden` attribute already removes it from layout.
   When NOT hidden, the root spans the viewport so its fixed children anchor.
   -------------------------------------------------------------------------- */
.unimis-sidecart {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--sc-text);
  line-height: 1.45;
}

.unimis-sidecart[hidden] {
  display: none !important;
}

/* -----------------------------------------------------------------------------
   Overlay — full-viewport dim layer, fades with .is-open on the root.
   Below the panel, above page content. Not interactive until open.
   -------------------------------------------------------------------------- */
.unimis-sidecart__overlay {
  position: fixed;
  inset: 0;
  z-index: var(--sc-z);
  background: var(--sc-overlay-bg);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--sc-anim) ease, visibility 0s linear var(--sc-anim);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.unimis-sidecart.is-open .unimis-sidecart__overlay {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--sc-anim) ease;
}

/* -----------------------------------------------------------------------------
   Panel — fixed to the right edge, slides in. Flex column:
   head (fixed) · body (scrolls) · foot (sticky bottom).
   -------------------------------------------------------------------------- */
.unimis-sidecart__panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: calc(var(--sc-z) + 1);

  display: flex;
  flex-direction: column;

  width: 100%;            /* mobile: full width */
  max-width: 100vw;
  height: 100%;
  background: var(--sc-surface);
  box-shadow: -8px 0 32px rgba(14, 51, 47, 0.18);

  transform: translateX(100%);
  transition: transform var(--sc-anim) var(--sc-ease);
  will-change: transform;

  /* Respect notches / home indicators on mobile. */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.unimis-sidecart.is-open .unimis-sidecart__panel {
  transform: translateX(0);
}

/* -----------------------------------------------------------------------------
   Head — title + close button.
   -------------------------------------------------------------------------- */
.unimis-sidecart__head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: var(--sc-pad);
  border-bottom: 1px solid var(--sc-border);
}

.unimis-sidecart__title {
  margin: 0;
  font-family: "Poppins", "Inter", sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1.2;
  color: var(--sc-heading);
}

.unimis-sidecart__close {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1.75rem;
  line-height: 1;
  color: var(--sc-heading);
  background: transparent;
  border: 0;
  border-radius: var(--sc-radius-sm);
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}

.unimis-sidecart__close:hover,
.unimis-sidecart__close:focus-visible {
  background: rgba(var(--sc-brand-rgb), 0.1);
  color: var(--sc-brand);
}

.unimis-sidecart__close:focus-visible {
  outline: 2px solid var(--sc-brand);
  outline-offset: 2px;
}

/* -----------------------------------------------------------------------------
   Body — the scrollable region (bar + content). flex:1 so it absorbs space.
   -------------------------------------------------------------------------- */
.unimis-sidecart__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* -----------------------------------------------------------------------------
   Free-shipping progress bar.
   -------------------------------------------------------------------------- */
.unimis-freeship {
  padding: var(--sc-pad);
  border-bottom: 1px solid var(--sc-border);
  background: rgba(var(--sc-brand-rgb), 0.05);
}

.unimis-freeship__msg {
  margin: 0 0 0.625rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--sc-heading);
}

.unimis-freeship__track {
  position: relative;
  width: 100%;
  height: 8px;
  background: var(--sc-track);
  border-radius: 999px;
  overflow: hidden;
}

.unimis-freeship__fill {
  display: block;
  height: 100%;
  width: 0;                 /* inline style="width:N%" from markup/JS wins */
  max-width: 100%;
  border-radius: inherit;
  background: var(--sc-brand);
  background-image: var(--unimis-gradient, linear-gradient(110deg, #ea5e25 30%, #f7b139 93%));
  transition: width 400ms var(--sc-ease), background-color 250ms ease;
}

/* Qualified — threshold reached: switch to success tone + tint the block. */
.unimis-freeship.is-qualified {
  background: rgba(var(--sc-success-rgb), 0.08);
}

.unimis-freeship.is-qualified .unimis-freeship__msg {
  color: var(--sc-success);
}

.unimis-freeship.is-qualified .unimis-freeship__fill {
  background: var(--sc-success);
  background-image: none;
}

/* -----------------------------------------------------------------------------
   Content — items list, totals, empty state.
   -------------------------------------------------------------------------- */
.unimis-sidecart__content {
  padding: var(--sc-pad);
}

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

.unimis-sidecart__item {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--sc-border);
}

.unimis-sidecart__item:first-child {
  padding-top: 0;
}

.unimis-sidecart__item-img {
  flex: 0 0 auto;
  display: block;
  width: 72px;
  height: 72px;
  border-radius: var(--sc-radius-sm);
  overflow: hidden;
  background: #f5f5f5;
  border: 1px solid var(--sc-border);
}

.unimis-sidecart__item-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.unimis-sidecart__item-info {
  flex: 1 1 auto;
  min-width: 0;             /* enables ellipsis on children */
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.unimis-sidecart__item-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--sc-heading);
  text-decoration: none;
}

.unimis-sidecart__item-name:hover {
  color: var(--sc-brand);
}

.unimis-sidecart__item-attr {
  font-size: 0.8125rem;
  color: var(--sc-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unimis-sidecart__item-meta {
  display: flex;
  align-items: baseline;
  gap: 0.375rem;
  margin-top: 0.125rem;
  font-size: 0.9375rem;
}

.unimis-sidecart__item-qty {
  color: var(--sc-muted);
  white-space: nowrap;
}

.unimis-sidecart__item-price {
  font-family: "Poppins", "Inter", sans-serif;
  font-weight: 700;
  color: var(--sc-heading);
}

/* Totals — clear separator above the grand total. */
.unimis-sidecart__totals {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 2px solid var(--sc-border);
}

.unimis-sidecart__total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.unimis-sidecart__total-row--grand {
  font-family: "Poppins", "Inter", sans-serif;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--sc-heading);
}

.unimis-sidecart__total-label {
  color: var(--sc-heading);
}

.unimis-sidecart__total-value {
  white-space: nowrap;
}

/* Empty state — centered, muted. */
.unimis-sidecart__empty {
  margin: 0;
  padding: 3rem 1rem;
  text-align: center;
  color: var(--sc-muted);
  font-size: 1rem;
}

/* -----------------------------------------------------------------------------
   Foot — sticky bottom checkout. The link already has .btn .btn-primary from
   the theme; here we just make it block / full-width and add the bar chrome.
   -------------------------------------------------------------------------- */
.unimis-sidecart__foot {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  padding: var(--sc-pad);
  background: var(--sc-surface);
  border-top: 1px solid var(--sc-border);
  box-shadow: 0 -4px 16px rgba(14, 51, 47, 0.06);
}

.unimis-sidecart__checkout {
  display: block;
  width: 100%;
  text-align: center;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  font-weight: 600;
}

/* -----------------------------------------------------------------------------
   Body scroll lock — JS toggles .unimis-sidecart-open on <body>.
   -------------------------------------------------------------------------- */
body.unimis-sidecart-open {
  overflow: hidden;
}

/* -----------------------------------------------------------------------------
   Desktop — constrain the panel to ~400px / max 92vw.
   -------------------------------------------------------------------------- */
@media (min-width: 576px) {
  .unimis-sidecart__panel {
    width: var(--sc-panel-width);
    max-width: 92vw;
  }
}

/* -----------------------------------------------------------------------------
   Reduced motion — disable slide/fade/width transitions; just show/hide.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .unimis-sidecart__panel,
  .unimis-sidecart__overlay,
  .unimis-freeship__fill,
  .unimis-sidecart__close {
    transition: none !important;
  }

  .unimis-sidecart__overlay {
    transition: visibility 0s !important;
  }
}
