/* =========================================================
   Nuni — Bästsäljare (V3)
   Ports Hero v3.html .v3-bestsellers section. BEM scope:
   .nuni-bs-v3 so it never collides with the other Bestsellers
   widget or other widgets on the same page.
   ========================================================= */

/* Break out of the parent Elementor column so the section spans the
   viewport. Same pattern Hero Stage / Testimonials use. */
.elementor-widget-nuni-bestsellers-v3,
.elementor-widget-nuni-bestsellers-v3 > .elementor-widget-container {
  width: 100%;
  max-width: none;
}
.elementor-widget-nuni-bestsellers-v3 > .elementor-widget-container { padding: 0; }
.elementor-widget-nuni-bestsellers-v3 > .elementor-widget-container > .nuni-bs-v3 {
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
  max-width: 100vw;
}
.elementor-editor-active .elementor-widget-nuni-bestsellers-v3 > .elementor-widget-container > .nuni-bs-v3 {
  width: 100vw;
  left: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
  max-width: 100vw;
}

/* Strip parent padding/margin AND any min-height at any nesting depth
   so adjacent Nuni v3 sections sit flush. `min-height: 0` is critical:
   without it a parent column/section with the Elementor "Height: Min
   Height" setting can be taller than the widget and the parent's
   background (or the body bg through it) shows below the widget. */
.e-con:has(.elementor-widget-nuni-bestsellers-v3),
.e-con-inner:has(.elementor-widget-nuni-bestsellers-v3),
.elementor-section:has(.elementor-widget-nuni-bestsellers-v3),
.elementor-container:has(.elementor-widget-nuni-bestsellers-v3),
.elementor-row:has(.elementor-widget-nuni-bestsellers-v3),
.elementor-column:has(.elementor-widget-nuni-bestsellers-v3),
.elementor-widget-wrap:has(.elementor-widget-nuni-bestsellers-v3) {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  /* Kill any flex/grid gap — Elementor's modern .e-con containers are
     `display: flex; flex-direction: column` and inherit a default gap
     between children that shows as a thin strip of the page bg between
     adjacent full-bleed Nuni sections. */
  gap: 0 !important;
  row-gap: 0 !important;
  overflow: visible !important;
  max-width: none !important;
  min-height: 0 !important;
}
.elementor-widget.elementor-widget-nuni-bestsellers-v3 {
  margin: 0 !important;
  padding: 0 !important;
}
/* Defensive: any element directly adjacent to a Nuni v3 widget loses
   its vertical margin so themes / Elementor's default
   `.elementor-widget:not(:last-child) { margin-block-end: 20px }` can't
   inject a gap between consecutive Nuni sections. */
.elementor-widget-nuni-bestsellers-v3,
.elementor-widget-nuni-bestsellers-v3 + .elementor-widget,
.elementor-widget + .elementor-widget-nuni-bestsellers-v3 {
  margin-block-start: 0 !important;
  margin-block-end: 0 !important;
}

.nuni-bs-v3 {
  /* Tokens */
  --nuni-bg:           var(--e-global-color-7, #E8DFCE);
  --nuni-card-bg:      #F4ECDD;
  --nuni-ink:          var(--e-global-color-text,    #2A1F14);
  --nuni-ink-2:        #4A3C2C;
  --nuni-muted:        var(--e-global-color-accent,  #6B5B47);
  --nuni-sand-deep:    var(--e-global-color-secondary, #8A765C);
  --nuni-line-2:       rgba(28, 20, 12, 0.2);
  --nuni-shadow-sm:    0 6px 18px -8px rgba(28, 20, 12, 0.25);
  --nuni-r-sm:         8px;
  --nuni-r-md:         14px;
  --nuni-r-pill:       999px;
  --nuni-bs-tag-new-bg:  #2F7D5B;
  --nuni-bs-tag-sale-bg: #C8412C;
  --nuni-bs-tag-promo-bg: #2F7D5B;

  background: var(--nuni-bg);
  color: var(--nuni-ink);
  padding: clamp(56px, 5.5vw, 88px) 56px clamp(72px, 7vw, 112px);
}

.nuni-bs-v3__header {
  max-width: 1480px;
  margin: 0 auto clamp(32px, 3.5vw, 48px);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.nuni-bs-v3__heading {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nuni-bs-v3__eyebrow {
  font-family: 'Gilroy', 'Inter', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  /* --nuni-sand-deep (#8A765C) fails WCAG AA at 11px. The darker
     --nuni-muted (#6B5B47) clears 4.5:1 on the section background. */
  color: var(--nuni-muted);
  margin: 0;
}
.nuni-bs-v3__title {
  font-family: 'Camello Rough', 'Cormorant Garamond', 'Times New Roman', serif;
  font-weight: 400;
  font-size: clamp(38px, 4.2vw, 58px);
  line-height: 1;
  letter-spacing: -0.005em;
  color: var(--nuni-ink);
  margin: 0;
}

.nuni-bs-v3__link {
  font-family: 'Gilroy', 'Inter', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--nuni-ink);
  text-decoration: none;
  padding: 6px 0;
  border-bottom: 1.5px solid var(--nuni-ink);
  transition: opacity .2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.nuni-bs-v3__link:hover { opacity: 0.65; color: var(--nuni-ink); }
.nuni-bs-v3__link svg { width: 14px; height: 14px; }

.nuni-bs-v3__header-right {
  display: flex;
  align-items: center;
  gap: 18px;
}
.nuni-bs-v3__nav { display: inline-flex; gap: 6px; }
.nuni-bs-v3__nav-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--nuni-line-2);
  background: transparent;
  border-radius: 50%;
  color: var(--nuni-ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .2s ease, border-color .2s ease, color .2s ease, opacity .2s ease;
}
/* Multi-state hover/focus/active locked down so the theme's default
   link / button colors (often pink/red) can't bleed through on click.
   `!important` is used here because some themes use higher-specificity
   selectors like `.elementor button:active` to paint primary color. */
.nuni-bs-v3__nav-btn:hover:not(:disabled),
.nuni-bs-v3__nav-btn:focus:not(:disabled),
.nuni-bs-v3__nav-btn:focus-visible:not(:disabled),
.nuni-bs-v3__nav-btn:active:not(:disabled) {
  background: var(--nuni-ink) !important;
  border-color: var(--nuni-ink) !important;
  color: var(--nuni-card-bg) !important;
  outline: 0 !important;
}
/* Disabled state — pin EVERY interactive pseudo so the theme's
   `:hover` / `:active` color can't paint the faded button pink when
   the user mouses over the "end of carousel" arrow. */
.nuni-bs-v3__nav-btn:disabled,
.nuni-bs-v3__nav-btn:disabled:hover,
.nuni-bs-v3__nav-btn:disabled:focus,
.nuni-bs-v3__nav-btn:disabled:focus-visible,
.nuni-bs-v3__nav-btn:disabled:active {
  background: transparent !important;
  border-color: var(--nuni-line-2) !important;
  color: var(--nuni-ink) !important;
  opacity: 0.3 !important;
  cursor: not-allowed !important;
  outline: 0 !important;
  transform: none !important;
}
.nuni-bs-v3__nav-btn svg { width: 16px; height: 16px; }

/* ===== Carousel ===== */
.nuni-bs-v3__carousel {
  position: relative;
  max-width: 1480px;
  margin: 0 auto;
}
/* Soft right-edge fade when there's more to scroll into */
.nuni-bs-v3__carousel::after {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 56px;
  background: linear-gradient(90deg, rgba(232, 223, 206, 0) 0%, var(--nuni-bg) 100%);
  pointer-events: none;
  opacity: 0;
  transition: opacity .35s ease;
  z-index: 2;
}
.nuni-bs-v3__carousel.has-overflow-end::after { opacity: 1; }

.nuni-bs-v3__track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 3 * var(--cgap)) / 4);
  gap: var(--cgap, clamp(20px, 2.2vw, 36px));
  --cgap: clamp(20px, 2.2vw, 36px);
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  /* No CSS `scroll-behavior: smooth` — the rAF tween in bestsellers-v3.js
     drives the animation manually. Native smooth-scroll fights with each
     per-frame scrollLeft write and ends up looking instant on desktop
     browsers (Chrome, Edge), even though touch swipe momentum still
     animates fine because that uses a different code path. */
}
.nuni-bs-v3__track::-webkit-scrollbar { display: none; }
.nuni-bs-v3__track > * { scroll-snap-align: start; min-width: 0; }

/* Dot indicators (shown on mobile via JS toggling .is-active) */
.nuni-bs-v3__dots {
  max-width: 1480px;
  margin: clamp(24px, 2.5vw, 36px) auto 0;
  display: none;
  gap: 10px;
  justify-content: center;
  align-items: center;
}
.nuni-bs-v3__dots.is-active { display: flex; }
.nuni-bs-v3__dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(28, 20, 12, 0.22);
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
.nuni-bs-v3__dot::after { content: ""; position: absolute; inset: -10px; }
.nuni-bs-v3__dot:hover { background: rgba(28, 20, 12, 0.45); }
.nuni-bs-v3__dot.is-active {
  background: var(--nuni-ink);
  transform: scale(1.4);
}

/* ===== Product card ===== */
.nuni-bs-v3__card {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: transform .35s ease;
}
.nuni-bs-v3__media {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: var(--nuni-r-md);
  overflow: hidden;
  background: var(--nuni-card-bg);
}
/* High-specificity override so WC's inline width/height attributes on
   the <img> can't shrink the picture inside the card. */
.nuni-bs-v3__media > img,
.nuni-bs-v3__media .nuni-bs-v3__img,
.nuni-bs-v3__media img.attachment-woocommerce_thumbnail,
.nuni-bs-v3__media img.attachment-woocommerce_single,
.nuni-bs-v3__media img.attachment-large,
.nuni-bs-v3__media img.attachment-full {
  width: 100% !important;
  height: 100% !important;
  display: block !important;
  object-position: center;
}

/* Default: fill the card, may crop edges */
.nuni-bs-v3__media--cover > img,
.nuni-bs-v3__media--cover img {
  object-fit: cover;
}
/* "Whole image": never crops — shrinks to fit. We add a small inset so
   the image floats inside the card with a little breathing room (best
   for product shots on a white/transparent background that need to
   read as a framed product, not edge-to-edge composition). */
.nuni-bs-v3__media--contain > img,
.nuni-bs-v3__media--contain img {
  object-fit: contain;
  padding: 8%;
}
@media (max-width: 560px) {
  .nuni-bs-v3__media--contain > img,
  .nuni-bs-v3__media--contain img { padding: 6%; }
}

/* Quick-add — visible on touch / shown on hover on mouse devices */
.nuni-bs-v3__quickadd {
  position: absolute;
  right: 12px;
  bottom: 12px;
  border: 0;
  background: var(--nuni-ink);
  color: var(--nuni-card-bg);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--nuni-shadow-sm);
  transition: transform .2s ease, background .2s ease, opacity .2s ease;
  z-index: 3;
}
.nuni-bs-v3__quickadd:hover,
.nuni-bs-v3__quickadd:focus,
.nuni-bs-v3__quickadd:focus-visible,
.nuni-bs-v3__quickadd:active {
  background: var(--nuni-sand-deep) !important;
  color: var(--nuni-card-bg) !important;
  outline: 0 !important;
  transform: scale(1.06);
}
.nuni-bs-v3__quickadd:disabled { cursor: progress; opacity: 0.85; transform: none; }
.nuni-bs-v3__quickadd svg { width: 16px; height: 16px; display: block; }
.nuni-bs-v3__quickadd .nuni-bs-v3__quickadd-check { display: none; }

/* Loading: spin the plus icon */
.nuni-bs-v3__quickadd.is-loading .nuni-bs-v3__quickadd-icon {
  animation: nuni-bs-spin .8s linear infinite;
  opacity: 0.85;
}
@keyframes nuni-bs-spin {
  to { transform: rotate(360deg); }
}

/* Added: green pill, swap plus → check */
.nuni-bs-v3__quickadd.is-added { background: #2F7D5B; }
.nuni-bs-v3__quickadd.is-added .nuni-bs-v3__quickadd-icon { display: none; }
.nuni-bs-v3__quickadd.is-added .nuni-bs-v3__quickadd-check { display: block; }

/* Error: warm red pill */
.nuni-bs-v3__quickadd.is-error { background: var(--nuni-bs-tag-sale-bg, #C8412C); }

@media (hover: hover) and (pointer: fine) and (min-width: 720px) {
  .nuni-bs-v3__quickadd { opacity: 0; transform: translateY(8px); }
  .nuni-bs-v3__card:hover .nuni-bs-v3__quickadd,
  .nuni-bs-v3__card:focus-within .nuni-bs-v3__quickadd {
    opacity: 1;
    transform: translateY(0);
  }
}

.nuni-bs-v3__tag {
  position: absolute;
  top: 14px;
  left: 14px;
  background: var(--nuni-card-bg);
  color: var(--nuni-ink);
  font-family: 'Gilroy', 'Inter', system-ui, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: var(--nuni-r-pill);
  z-index: 4; /* above the soldout overlay so the pill stays vivid */
}
.nuni-bs-v3__tag--new     { background: var(--nuni-bs-tag-new-bg);     color: #FFFFFF; }
.nuni-bs-v3__tag--sale    { background: var(--nuni-bs-tag-sale-bg);    color: #FFFFFF; }
.nuni-bs-v3__tag--promo   { background: var(--nuni-bs-tag-promo-bg);   color: #FFFFFF; }
.nuni-bs-v3__tag--soldout {
  background: var(--nuni-bs-tag-soldout-bg, #6B5B47);
  color: #FFFFFF;
  letter-spacing: 0.18em;
}

/* ===== Out-of-stock treatment =====
   The card stays in the carousel so the slot/grid rhythm is preserved,
   but the image desaturates, the name/price gray out, the quick-add is
   suppressed (rendered conditionally in PHP), and a tag pill announces
   "Slutsåld". Pointer-events stay enabled so the product link still
   works (admins or returning shoppers may want to read the page). */
.nuni-bs-v3__card--soldout .nuni-bs-v3__media {
  position: relative;
}
.nuni-bs-v3__card--soldout .nuni-bs-v3__media > img,
.nuni-bs-v3__card--soldout .nuni-bs-v3__media img {
  filter: grayscale(1) brightness(1.04) contrast(0.92);
  opacity: 0.75;
  transition: filter .25s ease, opacity .25s ease;
}
/* Soft cream wash over the image to reinforce the "paused" state */
.nuni-bs-v3__card--soldout .nuni-bs-v3__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(244, 236, 221, 0.18);
  pointer-events: none;
  z-index: 1;
}
.nuni-bs-v3__card--soldout .nuni-bs-v3__name,
.nuni-bs-v3__card--soldout .nuni-bs-v3__sub,
.nuni-bs-v3__card--soldout .nuni-bs-v3__price {
  color: var(--nuni-muted) !important;
}
.nuni-bs-v3__card--soldout .nuni-bs-v3__price del {
  /* Strike-through already grays, no double-treatment needed */
  color: rgba(28, 20, 12, 0.35);
}
.nuni-bs-v3__card--soldout .nuni-bs-v3__meta:hover .nuni-bs-v3__name {
  color: var(--nuni-ink) !important;
}
/* Tighten the hover lift on soldout cards — they shouldn't feel inviting. */
.nuni-bs-v3__card--soldout { transition: none; }

.nuni-bs-v3__meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 2px;
  text-decoration: none;
  color: inherit;
}
.nuni-bs-v3__meta:hover .nuni-bs-v3__name { color: var(--nuni-sand-deep); }

.nuni-bs-v3__sub {
  font-family: 'Gilroy', 'Inter', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--nuni-muted);
  margin: 0;
}
.nuni-bs-v3__name {
  font-family: 'Gilroy', 'Inter', system-ui, sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--nuni-ink);
  margin: 0;
  line-height: 1.3;
  transition: color .2s ease;
}
.nuni-bs-v3__price {
  font-family: 'Camello Rough', 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: 18px;
  color: var(--nuni-ink);
  margin: 6px 0 0;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.nuni-bs-v3__price em {
  font-style: normal;
  font-family: 'Gilroy', 'Inter', system-ui, sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--nuni-muted);
  margin-left: 5px;
}
.nuni-bs-v3__price del {
  font-size: 0.78em;
  font-weight: 500;
  color: rgba(28, 20, 12, 0.45);
  text-decoration: line-through;
  margin-right: 6px;
}
.nuni-bs-v3__price ins {
  text-decoration: none;
  background: transparent;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .nuni-bs-v3__track {
    grid-auto-columns: calc((100% - 2 * var(--cgap)) / 3);
  }
}
@media (max-width: 720px) {
  .nuni-bs-v3__track {
    grid-auto-columns: calc((100% - 1.4 * var(--cgap)) / 2.2);
  }
  .nuni-bs-v3__nav { display: none; }
}
@media (max-width: 560px) {
  .nuni-bs-v3 { padding: 48px 0 64px; }
  .nuni-bs-v3__header { padding: 0 20px; margin-bottom: 20px; gap: 14px; }
  .nuni-bs-v3__title { font-size: 32px; }
  .nuni-bs-v3__eyebrow { font-size: 10px; letter-spacing: 0.22em; }
  .nuni-bs-v3__link { font-size: 12px; }

  .nuni-bs-v3__carousel { max-width: 100%; }
  .nuni-bs-v3__track {
    --cgap: 12px;
    padding: 0 20px;
    scroll-padding-left: 20px;
    grid-auto-columns: 62%;
  }

  .nuni-bs-v3__card { gap: 10px; }
  .nuni-bs-v3__media { aspect-ratio: 4 / 5; border-radius: var(--nuni-r-sm); }
  .nuni-bs-v3__tag {
    top: 10px;
    left: 10px;
    font-size: 9px;
    padding: 4px 8px;
    letter-spacing: 0.14em;
  }
  .nuni-bs-v3__sub { font-size: 10px; letter-spacing: 0.14em; }
  .nuni-bs-v3__name { font-size: 14px; line-height: 1.25; }
  .nuni-bs-v3__price { font-size: 16px; margin-top: 4px; }
  .nuni-bs-v3__price em { font-size: 11px; }
  .nuni-bs-v3__quickadd {
    width: 44px;
    height: 44px;
    right: 8px;
    bottom: 8px;
    opacity: 1;
    transform: none;
  }
}
