/* ==========================================================================
   OstuGrupp — cart widget UX
   Mini-cart dropdown · sticky mobile add-to-cart · back-to-top · qty steppers.
   Uses the design tokens from main.css (slate + green, radius, shadows, fonts).
   ========================================================================== */

/* ---- Header cart trigger: anchor the dropdown to it ---- */
.header-cart { position: relative; }
.header-cart__count { transition: transform .25s cubic-bezier(.34, 1.56, .64, 1); }
.header-cart.is-bumped .header-cart__count { transform: scale(1.35); }

/* ==========================================================================
   Mini-cart dropdown
   ========================================================================== */
.mini-cart {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  z-index: 200;
  width: min(360px, calc(100vw - 32px));
  /* Cap to the space below the header so the whole panel (items + subtotal +
     actions) is always reachable, even on short phones in landscape. The inner
     items list also scrolls (max-height:320px) for long carts. */
  max-height: calc(100dvh - 96px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.mini-cart[hidden] { display: none; }

/* When rendered floating in the footer (header didn't fire the hook), pin it
   to the viewport's top-right under the sticky header instead. */
.mini-cart-floating-root { position: static; }
.mini-cart-floating-root .mini-cart {
  position: fixed;
  top: 84px;
  right: max(16px, calc((100vw - var(--container)) / 2 + 24px));
  /* Never taller than the space below the header on short/mobile screens. */
  max-height: calc(100dvh - 96px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* On phones the sticky header row is ~64px; tuck the floating panel just below
   it and let it span the gutters so it is never clipped at the screen edge. */
@media (max-width: 600px) {
  .mini-cart-floating-root .mini-cart { top: 72px; right: 16px; left: 16px; width: auto; }
}

.mini-cart__panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card-hover);
  overflow: hidden;
  transform-origin: top right;
  animation: mini-cart-in .18s ease;
}
@keyframes mini-cart-in {
  from { opacity: 0; transform: translateY(-8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.mini-cart__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--muted);
}
.mini-cart__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--slate-dark);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.mini-cart__head-count {
  background: var(--green);
  color: #fff;
  border-radius: 999px;
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  padding: 0 6px;
}
.mini-cart__close {
  background: transparent;
  border: 0;
  color: var(--slate-500);
  font-size: 22px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, color .2s;
}
.mini-cart__close:hover { background: #fff; color: var(--slate-dark); }

.mini-cart__body { padding: 8px; }

/* Empty state */
.mini-cart__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 16px;
  color: var(--slate-500);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}
/* Was sized for an emoji glyph; now holds the theme's stroke cart icon. */
.mini-cart__empty-icon { display: inline-flex; color: var(--slate-300); opacity: 1; }
.mini-cart__empty-icon svg { width: 26px; height: 26px; }
/* The empty panel used to be a dead end — icon, sentence, no link out. */
.mini-cart__actions--empty { padding: 0 16px 24px; }
.mini-cart__actions--empty .mini-cart__browse { width: 100%; justify-content: center; }

/* Items */
.mini-cart__items {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
}
.mini-cart__item {
  position: relative;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 36px 12px 8px;
  border-radius: var(--radius);
  transition: background .15s;
}
.mini-cart__item + .mini-cart__item { border-top: 1px solid var(--border); }
.mini-cart__item:hover { background: var(--muted); }

.mini-cart__item-thumb img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: var(--muted);
  border-radius: 10px;
  padding: 4px;
}
.mini-cart__item-detail { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mini-cart__item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
a.mini-cart__item-name:hover { color: var(--green); }
.mini-cart__item-meta {
  font-size: 13px;
  color: var(--slate-500);
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.mini-cart__item-price {
  color: var(--slate-dark);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.mini-cart__item-qty { font-weight: 600; }

.mini-cart__item-remove {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--slate-500);
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, color .2s, border-color .2s;
}
.mini-cart__item-remove:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.mini-cart__item.is-removing { opacity: .45; pointer-events: none; }

/* Subtotal */
.mini-cart__subtotal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 10px 10px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--slate-600);
}
.mini-cart__subtotal strong {
  font-size: 18px;
  color: var(--slate-dark);
  font-variant-numeric: tabular-nums;
}

/* Actions */
.mini-cart__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 8px 10px 12px;
}
.mini-cart__actions .btn-primary,
.mini-cart__actions .btn-secondary {
  min-height: 44px;
  padding-inline: 12px;
  font-size: 14px;
  width: 100%;
  white-space: nowrap;
}
/* On the narrowest phones stack the two cart actions so neither label clips. */
@media (max-width: 360px) {
  .mini-cart__actions { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Quantity steppers (+/-) — single product & cart
   ========================================================================== */
.qty-stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}
.qty-stepper .qty-stepper__btn {
  /* 44px, not 42 — WCAG 2.5.5. These sit on the money path and the minus button
     used to be able to remove a product, so a mis-tap here was expensive. */
  width: 44px;
  border: 0;
  background: var(--muted);
  color: var(--slate-dark);
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.qty-stepper .qty-stepper__btn:hover { background: var(--green); color: #fff; }
.qty-stepper .qty-stepper__btn:disabled { opacity: .4; cursor: not-allowed; }
.qty-stepper .qty-stepper__btn:disabled:hover { background: var(--muted); color: var(--slate-dark); }

/* Neutralise inner input borders/radius once wrapped by the stepper. */
.qty-stepper input.qty {
  border: 0 !important;
  border-radius: 0 !important;
  border-left: 1px solid var(--border) !important;
  border-right: 1px solid var(--border) !important;
  -moz-appearance: textfield;
}
.qty-stepper input.qty::-webkit-outer-spin-button,
.qty-stepper input.qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ==========================================================================
   Sticky mobile add-to-cart bar (single product)
   ========================================================================== */
.sticky-atc {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 150;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px -16px rgba(15, 23, 42, .35);
  transform: translateY(110%);
  transition: transform .28s cubic-bezier(.22, 1, .36, 1);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
/* Same trap as the mobile filter drawer: translated off-screen but still
   focusable, so on a product page TAB ran through the sticky bar's name, price
   and Add-to-cart button while the bar was nowhere on screen. The delayed
   visibility keeps the slide-out animation intact. */
.sticky-atc { visibility: hidden; transition: transform .28s ease, visibility 0s .28s; }
.sticky-atc.is-visible { transform: translateY(0); visibility: visible; transition-delay: 0s; }
.sticky-atc__inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-block: 10px;
}
.sticky-atc__info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.sticky-atc__name {
  font-weight: 600;
  font-size: 14px;
  color: var(--slate-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sticky-atc__price {
  font-weight: 700;
  font-size: 16px;
  color: var(--green-dark);
  font-variant-numeric: tabular-nums;
}
.sticky-atc__price del { color: var(--slate-500); font-weight: 500; font-size: 13px; opacity: .7; margin-right: 6px; }
.sticky-atc__price ins { text-decoration: none; }
.sticky-atc__btn {
  flex: 0 0 auto;
  min-height: 46px;
  padding-inline: 22px;
  white-space: nowrap;
}
.sticky-atc__btn.is-loading { opacity: .8; pointer-events: none; }

/* Only ever surfaces on smaller viewports — desktop has the in-page button. */
@media (min-width: 1024px) {
  .sticky-atc { display: none; }
}

/* ==========================================================================
   Back-to-top
   ========================================================================== */
.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 140;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--slate-dark);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card-hover);
  opacity: 0;
  transform: translateY(12px) scale(.9);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease, background .2s;
}
.back-to-top[hidden] { display: none; }
.back-to-top.is-visible { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.back-to-top:hover { background: var(--green); transform: translateY(-2px) scale(1.04); }

/* Lift the back-to-top above the sticky add-to-cart bar when both are present. */
.sticky-atc.is-visible ~ .back-to-top.is-visible { bottom: 76px; }
@media (min-width: 1024px) {
  .sticky-atc.is-visible ~ .back-to-top.is-visible { bottom: 20px; }
}

/* ==========================================================================
   Toast (lightweight add-to-cart confirmation)
   ========================================================================== */
.cart-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  z-index: 300;
  background: var(--slate-dark);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  padding: 12px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card-hover);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
/* SVG tick, not the OS font glyph — ✓ renders differently on Windows, Android and
   iOS and was the last text character standing among stroke icons. currentColor
   does not reach a background image, so the stroke colour is baked in per use. */
.cart-toast::before { content: ""; width: 15px; height: 15px; flex: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2334d399' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5L20 7'/%3E%3C/svg%3E") center/contain no-repeat; }
.cart-toast.is-error::before { content: "!"; color: #f87171; }
.cart-toast.is-error { background: var(--danger-dark); }
.cart-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .mini-cart__panel { animation: none; }
  .sticky-atc, .back-to-top, .cart-toast, .header-cart__count { transition: none; }
}

/* The cart toast sat at a fixed bottom offset and hid behind the mobile bottom
   navigation — the confirmation that the product actually went into the cart was
   the one thing the shopper could not see. Same compensation wishlist.css:205
   already applies to its own toast. */
@media (max-width: 1023.98px) {
  body:has(.og-bottomnav) .cart-toast {
    bottom: calc(var(--og-bottomnav-h, 64px) + 28px + env(safe-area-inset-bottom, 0px));
  }
}

/* ==========================================================================
   Sticky add-to-cart vs the cookie plugin's re-open badge
   Reported live on a phone: scrolling a product page brings up the sticky bar,
   and the cookie plugin's little "Küpsised" pill sits on top of the PRICE.
   Measured: .oga-cc-bar is position:fixed; bottom:0; z-index:999999 — six digits,
   against our bar's 150 — so it wins everywhere and always.
   Two ways out, and only one of them is honest: raising our bar above it would
   bury a privacy control the visitor is entitled to reach. So the badge moves UP
   instead, clearing the bottom nav (65px) plus the bar (71px) plus a gap, and only
   while the bar is actually on screen. When the bar hides, the badge drops back.
   Scoped to phones/tablets, where both exist at once.
   ========================================================================== */
@media (max-width: 1023.98px) {
  body:has(.sticky-atc.is-visible) [class*="oga-cc"][class*="bar"],
  body:has(.sticky-atc.is-visible) [class*="oga-cc-reopen"],
  body:has(.sticky-atc.is-visible) [class*="oga-cc-badge"] {
    bottom: calc(var(--og-bottomnav-h, 64px) + 79px + env(safe-area-inset-bottom, 0px)) !important;
    transition: bottom .28s ease;
  }
}
/* Our own two fixed bars were also mis-stacked: the bottom nav sits at z-index
   1100 and the sticky bar at 150, so the nav could paint over the bar's lower
   edge. The bar belongs above the nav — it is the one carrying the price. */
.sticky-atc { z-index: 1150; }
