/**
 * Nick Kids — Commerce Components
 * ===============================
 * ProductCard, CategoryCard, Price, StockStatus, Rating, ReviewCard,
 * SizeSelector, ColorSelector, QuantitySelector, ProductGallery,
 * PromotionalBanner, attribute lists, sticky mobile CTA.
 */

/* =======================================================================
 * PRODUCT CARD — .nk-product-card
 * Mobile: 2-up grid. Tablet: 3-up. Desktop: 4-up.
 * The whole card is one link target; secondary actions sit above it.
 * ===================================================================== */

.nk-product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: var(--nk-surface-raised);
  border: var(--nk-border-width) solid var(--nk-border-subtle);
  border-radius: var(--nk-radius-lg);
  overflow: hidden;
  transition: box-shadow var(--nk-duration-normal) var(--nk-ease-standard),
              transform var(--nk-duration-normal) var(--nk-ease-standard);
}

@media (hover: hover) {
  .nk-product-card:hover { box-shadow: var(--nk-shadow-md); transform: translateY(-2px); }
  .nk-product-card:hover .nk-product-card__img--hover { opacity: 1; }
}

/* Focus ring goes on the card, not just the inner link. */
.nk-product-card:focus-within { outline: var(--nk-focus-ring-width) solid var(--nk-focus-ring-color); outline-offset: var(--nk-focus-ring-offset); }

.nk-product-card__media {
  position: relative;
  aspect-ratio: var(--nk-ratio-product);
  background-color: var(--nk-surface-sunken);
  overflow: hidden;
}
.nk-product-card__img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
}
/* Second image revealed on hover — desktop affordance only. */
.nk-product-card__img--hover {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--nk-duration-normal) var(--nk-ease-standard);
}

/* Badge rail — top inline-start corner, stacks downward. */
.nk-product-card__badges {
  position: absolute;
  inset-block-start: var(--nk-space-2);
  inset-inline-start: var(--nk-space-2);
  z-index: var(--nk-z-raised);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--nk-space-1);
}

/* Wishlist — opposite corner from the badges. */
.nk-product-card__wish {
  position: absolute;
  inset-block-start: var(--nk-space-2);
  inset-inline-end: var(--nk-space-2);
  z-index: var(--nk-z-raised);
  inline-size: 36px;
  block-size: 36px;
  background-color: rgb(255 255 255 / 0.9);
  backdrop-filter: blur(4px);
  border-radius: var(--nk-radius-pill);
  color: var(--nk-text-muted);
}
/**
 * The visible pill stays 36px so it doesn't dominate the card, but the
 * tappable area is extended to 44px with a transparent pseudo-element.
 * This is the standard way to satisfy WCAG 2.5.5 without a bigger button.
 */
.nk-product-card__wish::before {
  content: "";
  position: absolute;
  inset: 50%;
  inline-size: var(--nk-touch-target);
  block-size: var(--nk-touch-target);
  transform: translate(50%, -50%);
}
[dir="ltr"] .nk-product-card__wish::before { transform: translate(-50%, -50%); }
.nk-product-card__wish[aria-pressed="true"] { color: var(--nk-action-primary); }

.nk-product-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--nk-space-2);
  padding: var(--nk-space-3);
  flex: 1;
}

.nk-product-card__title {
  font-family: var(--nk-font-ui);
  font-size: var(--nk-text-base);
  font-weight: var(--nk-weight-medium);
  color: var(--nk-text-strong);
  line-height: var(--nk-leading-snug);
  /* Two lines max so every card in a row has the same height. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.nk-product-card__title a { color: inherit; text-decoration: none; }
/* Stretched link — makes the whole card clickable without nesting <a>. */
.nk-product-card__title a::after { content: ""; position: absolute; inset: 0; }

.nk-product-card__meta {
  display: flex;
  align-items: center;
  gap: var(--nk-space-2);
  font-size: var(--nk-text-xs);
  color: var(--nk-text-muted);
}

.nk-product-card__footer {
  margin-block-start: auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--nk-space-2);
}

@media (min-width: 768px) {
  .nk-product-card__body { padding: var(--nk-space-4); gap: var(--nk-space-3); }
  .nk-product-card__title { font-size: var(--nk-text-md); }
}

/* Product grid — the canonical listing layout. */
.nk-product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--nk-grid-gap);
}
@media (min-width: 768px) { .nk-product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .nk-product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/**
 * Carousel variant — horizontal scroll-snap on mobile, no JS needed.
 * Used for "related" and "recommended" rails.
 */
.nk-product-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 46%;
  gap: var(--nk-grid-gap);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  /* Bleed to the screen edge so cards look like they continue off-screen. */
  padding-inline: var(--nk-gutter);
  margin-inline: calc(var(--nk-gutter) * -1);
  padding-block-end: var(--nk-space-2);
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.nk-product-rail::-webkit-scrollbar { display: none; }
.nk-product-rail > * { scroll-snap-align: start; }
@media (min-width: 480px) { .nk-product-rail { grid-auto-columns: 33%; } }
@media (min-width: 768px) { .nk-product-rail { grid-auto-columns: 25%; } }
@media (min-width: 1024px) {
  .nk-product-rail { grid-auto-columns: 22%; padding-inline: 0; margin-inline: 0; }
}

/* =======================================================================
 * CATEGORY CARD — .nk-category-card
 * ===================================================================== */

.nk-category-card {
  position: relative;
  display: block;
  aspect-ratio: var(--nk-ratio-category);
  border-radius: var(--nk-radius-xl);
  overflow: hidden;
  background-color: var(--nk-surface-sunken);
  text-decoration: none;
}
.nk-category-card__img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  transition: transform var(--nk-duration-slow) var(--nk-ease-out);
}
@media (hover: hover) {
  .nk-category-card:hover .nk-category-card__img { transform: scale(1.04); }
}
.nk-category-card__overlay {
  position: absolute;
  inset-block-end: 0;
  inset-inline: 0;
  padding: var(--nk-space-4);
  background: linear-gradient(to top, rgb(16 26 44 / 0.75), transparent);
  color: var(--nk-text-inverse);
}
.nk-category-card__title {
  font-family: var(--nk-font-display);
  font-size: var(--nk-text-lg);
  font-weight: var(--nk-weight-bold);
  color: var(--nk-white);
}
.nk-category-card__count { font-size: var(--nk-text-xs); opacity: 0.85; }

/* Pastel variant — flat colour instead of photography. */
.nk-category-card--pastel { background-color: var(--nk-pastel-sky); }
.nk-category-card--pastel .nk-category-card__overlay { background: none; color: var(--nk-text-strong); }
.nk-category-card--pastel .nk-category-card__title { color: var(--nk-text-strong); }

/* =======================================================================
 * PRICE — .nk-price
 * Layout in RTL: [amount] [currency], with the old price after the new one.
 * ===================================================================== */

.nk-price {
  display: flex;
  align-items: baseline;
  gap: var(--nk-space-2);
  flex-wrap: wrap;
}

.nk-price__current {
  font-family: var(--nk-font-numeric);
  font-size: var(--nk-text-lg);
  font-weight: var(--nk-weight-bold);
  color: var(--nk-text-strong);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.nk-price__currency {
  font-size: var(--nk-text-xs);
  font-weight: var(--nk-weight-medium);
  color: var(--nk-text-muted);
  margin-inline-start: var(--nk-space-1);
}
.nk-price__old {
  font-family: var(--nk-font-numeric);
  font-size: var(--nk-text-base);
  color: var(--nk-text-subtle);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  white-space: nowrap;
}
.nk-price__off {
  font-size: var(--nk-text-xs);
  font-weight: var(--nk-weight-bold);
  color: var(--nk-text-on-accent);
  background-color: var(--nk-action-primary);
  padding-inline: var(--nk-space-2);
  padding-block: 2px;
  border-radius: var(--nk-radius-sm);
}
/* On sale, the live price takes the accent colour. */
.nk-price--sale .nk-price__current { color: var(--nk-action-primary); }

.nk-price--lg .nk-price__current { font-size: var(--nk-text-3xl); }
.nk-price--sm .nk-price__current { font-size: var(--nk-text-md); }

/* =======================================================================
 * STOCK STATUS — .nk-stock
 * ===================================================================== */

.nk-stock {
  display: inline-flex;
  align-items: center;
  gap: var(--nk-space-2);
  font-size: var(--nk-text-sm);
  font-weight: var(--nk-weight-medium);
}
.nk-stock__dot {
  inline-size: 8px;
  block-size: 8px;
  border-radius: var(--nk-radius-circle);
  flex: none;
  background-color: currentColor;
}
.nk-stock--in  { color: var(--nk-status-success-text); }
.nk-stock--low { color: var(--nk-status-warning-text); }
.nk-stock--out { color: var(--nk-text-muted); }

/* Low-stock urgency bar — only shown when remaining ≤ 5. */
.nk-stock-bar {
  block-size: 4px;
  inline-size: 100%;
  max-inline-size: 160px;
  background-color: var(--nk-navy-100);
  border-radius: var(--nk-radius-pill);
  overflow: hidden;
}
.nk-stock-bar__fill {
  block-size: 100%;
  background-color: var(--nk-status-warning);
  border-radius: inherit;
}

/* =======================================================================
 * RATING — .nk-rating
 * ===================================================================== */

.nk-rating { display: inline-flex; align-items: center; gap: var(--nk-space-1); }
.nk-rating__stars { display: inline-flex; gap: var(--nk-space-hair); color: var(--nk-amber-500); }
.nk-rating__stars .nk-icon { inline-size: var(--nk-icon-sm); block-size: var(--nk-icon-sm); }
.nk-rating__star--empty { color: var(--nk-navy-200); }
.nk-rating__value {
  font-family: var(--nk-font-numeric);
  font-size: var(--nk-text-sm);
  font-weight: var(--nk-weight-semibold);
  color: var(--nk-text-strong);
}
.nk-rating__count { font-size: var(--nk-text-xs); color: var(--nk-text-muted); }

/* Distribution bars in the reviews summary. */
.nk-rating-bar { display: flex; align-items: center; gap: var(--nk-space-2); }
.nk-rating-bar__track {
  flex: 1;
  block-size: 6px;
  background-color: var(--nk-navy-100);
  border-radius: var(--nk-radius-pill);
  overflow: hidden;
}
.nk-rating-bar__fill { block-size: 100%; background-color: var(--nk-amber-500); }

/* =======================================================================
 * REVIEW CARD — .nk-review
 * ===================================================================== */

.nk-review {
  padding-block: var(--nk-space-5);
  border-block-end: var(--nk-border-hairline);
}
.nk-review__head {
  display: flex;
  align-items: center;
  gap: var(--nk-space-3);
  margin-block-end: var(--nk-space-3);
}
.nk-review__avatar {
  inline-size: 40px;
  block-size: 40px;
  border-radius: var(--nk-radius-circle);
  background-color: var(--nk-surface-accent);
  color: var(--nk-action-primary);
  display: grid;
  place-items: center;
  font-weight: var(--nk-weight-semibold);
  flex: none;
}
.nk-review__author { font-weight: var(--nk-weight-semibold); color: var(--nk-text-strong); font-size: var(--nk-text-base); }
.nk-review__date { font-size: var(--nk-text-xs); color: var(--nk-text-muted); }
.nk-review__verified {
  display: inline-flex;
  align-items: center;
  gap: var(--nk-space-1);
  font-size: var(--nk-text-xs);
  color: var(--nk-status-success-text);
}
.nk-review__body { color: var(--nk-text-default); line-height: var(--nk-leading-normal); }
.nk-review__footer {
  margin-block-start: var(--nk-space-3);
  display: flex;
  align-items: center;
  gap: var(--nk-space-4);
  font-size: var(--nk-text-sm);
  color: var(--nk-text-muted);
}

/* =======================================================================
 * SIZE SELECTOR — .nk-size-select
 * Radio group styled as tiles. Never a <select> on mobile.
 * ===================================================================== */

.nk-size-select { display: flex; flex-wrap: wrap; gap: var(--nk-space-2); }

.nk-size-select__option { position: relative; }
.nk-size-select__input {
  position: absolute;
  opacity: 0;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  margin: 0;
  cursor: pointer;
}
.nk-size-select__label {
  display: grid;
  place-items: center;
  min-inline-size: var(--nk-touch-target);
  min-block-size: var(--nk-touch-target);
  padding-inline: var(--nk-space-3);
  border: var(--nk-border-width) solid var(--nk-border-default);
  border-radius: var(--nk-radius-md);
  background-color: var(--nk-surface-raised);
  font-size: var(--nk-text-base);
  font-weight: var(--nk-weight-medium);
  color: var(--nk-text-strong);
  cursor: pointer;
  transition: all var(--nk-transition-base);
}
.nk-size-select__input:hover + .nk-size-select__label { border-color: var(--nk-border-strong); }
.nk-size-select__input:checked + .nk-size-select__label {
  border-color: var(--nk-navy-800);
  border-width: var(--nk-border-width-thick);
  background-color: var(--nk-navy-800);
  color: var(--nk-text-inverse);
}
.nk-size-select__input:focus-visible + .nk-size-select__label {
  outline: var(--nk-focus-ring-width) solid var(--nk-focus-ring-color);
  outline-offset: var(--nk-focus-ring-offset);
}
/* Out of stock — struck through, still focusable so it can announce why. */
.nk-size-select__input:disabled + .nk-size-select__label {
  color: var(--nk-action-disabled-text);
  background-color: var(--nk-navy-50);
  border-color: var(--nk-border-subtle);
  cursor: not-allowed;
  text-decoration: line-through;
}

.nk-size-select__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block-end: var(--nk-space-3);
}

/* =======================================================================
 * COLOR SELECTOR — .nk-color-select
 * Colour is never the only signal: the selected name is always shown.
 * ===================================================================== */

.nk-color-select { display: flex; flex-wrap: wrap; gap: var(--nk-space-3); }
.nk-color-select__option { position: relative; }
.nk-color-select__input { position: absolute; opacity: 0; inset: 0; inline-size: 100%; block-size: 100%; margin: 0; cursor: pointer; }
.nk-color-select__swatch {
  display: block;
  inline-size: 36px;
  block-size: 36px;
  border-radius: var(--nk-radius-circle);
  background-color: var(--nk-swatch, var(--nk-navy-200));
  box-shadow: inset 0 0 0 1px rgb(16 26 44 / 0.12);
  cursor: pointer;
  transition: transform var(--nk-transition-base), box-shadow var(--nk-transition-base);
}
/* The 36px dot sits inside a 44px touch target. */
.nk-color-select__option {
  display: grid;
  place-items: center;
  inline-size: var(--nk-touch-target);
  block-size: var(--nk-touch-target);
}
.nk-color-select__input:checked + .nk-color-select__swatch {
  box-shadow: inset 0 0 0 1px rgb(16 26 44 / 0.12),
              0 0 0 2px var(--nk-surface-raised),
              0 0 0 4px var(--nk-navy-800);
}
.nk-color-select__input:focus-visible + .nk-color-select__swatch {
  outline: var(--nk-focus-ring-width) solid var(--nk-focus-ring-color);
  outline-offset: var(--nk-focus-ring-offset);
}
.nk-color-select__input:disabled + .nk-color-select__swatch { opacity: 0.35; cursor: not-allowed; }

/* =======================================================================
 * QUANTITY SELECTOR — .nk-qty
 * ===================================================================== */

.nk-qty {
  display: inline-flex;
  align-items: center;
  border: var(--nk-border-width) solid var(--nk-border-default);
  border-radius: var(--nk-radius-md);
  overflow: hidden;
  background-color: var(--nk-surface-raised);
}
.nk-qty__btn {
  inline-size: var(--nk-touch-target);
  block-size: var(--nk-touch-target);
  display: grid;
  place-items: center;
  color: var(--nk-text-strong);
  transition: background-color var(--nk-transition-base);
}
.nk-qty__btn:hover:not(:disabled) { background-color: var(--nk-navy-50); }
.nk-qty__btn:disabled { color: var(--nk-action-disabled-text); cursor: not-allowed; }
.nk-qty__input {
  inline-size: 48px;
  block-size: var(--nk-touch-target);
  border: none;
  border-inline: var(--nk-border-width) solid var(--nk-border-subtle);
  text-align: center;
  font-family: var(--nk-font-numeric);
  font-size: var(--nk-text-md);
  font-weight: var(--nk-weight-semibold);
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
.nk-qty__input::-webkit-outer-spin-button,
.nk-qty__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* =======================================================================
 * PRODUCT GALLERY — .nk-gallery
 * Mobile: full-bleed swipe with dot counter, no thumbnails.
 * Desktop: thumbnail column on the inline-start side + main stage.
 * ===================================================================== */

.nk-gallery { position: relative; }

.nk-gallery__stage {
  position: relative;
  aspect-ratio: var(--nk-ratio-product);
  background-color: var(--nk-surface-sunken);
  border-radius: var(--nk-radius-lg);
  overflow: hidden;
}

.nk-gallery__track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  block-size: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.nk-gallery__track::-webkit-scrollbar { display: none; }
.nk-gallery__slide { scroll-snap-align: center; block-size: 100%; }
.nk-gallery__slide img { inline-size: 100%; block-size: 100%; object-fit: cover; }

/* Counter pill — cheaper than dots when there are many images. */
.nk-gallery__counter {
  position: absolute;
  inset-block-end: var(--nk-space-3);
  inset-inline-end: var(--nk-space-3);
  padding-inline: var(--nk-space-3);
  padding-block: var(--nk-space-1);
  background-color: rgb(16 26 44 / 0.6);
  color: var(--nk-white);
  border-radius: var(--nk-radius-pill);
  font-family: var(--nk-font-numeric);
  font-size: var(--nk-text-xs);
  backdrop-filter: blur(6px);
}

.nk-gallery__thumbs { display: none; }

@media (min-width: 1024px) {
  .nk-gallery {
    display: grid;
    /* Thumbs first in DOM = inline-start in both directions. */
    grid-template-columns: 84px minmax(0, 1fr);
    gap: var(--nk-space-4);
    align-items: start;
  }
  .nk-gallery__thumbs {
    display: flex;
    flex-direction: column;
    gap: var(--nk-space-2);
    max-block-size: 560px;
    overflow-y: auto;
    scrollbar-width: thin;
  }
  .nk-gallery__thumb {
    aspect-ratio: var(--nk-ratio-product);
    border-radius: var(--nk-radius-md);
    overflow: hidden;
    border: var(--nk-border-width-thick) solid transparent;
    background-color: var(--nk-surface-sunken);
    cursor: pointer;
  }
  .nk-gallery__thumb img { inline-size: 100%; block-size: 100%; object-fit: cover; }
  .nk-gallery__thumb[aria-current="true"] { border-color: var(--nk-navy-800); }
  .nk-gallery__counter { display: none; }
}

/* =======================================================================
 * PRODUCT ATTRIBUTES / SPECIFICATIONS — .nk-specs
 * ===================================================================== */

.nk-specs { inline-size: 100%; font-size: var(--nk-text-base); }
.nk-specs tr { border-block-end: var(--nk-border-hairline); }
.nk-specs th,
.nk-specs td { padding-block: var(--nk-space-3); text-align: start; vertical-align: top; }
.nk-specs th { color: var(--nk-text-muted); font-weight: var(--nk-weight-regular); inline-size: 40%; }
.nk-specs td { color: var(--nk-text-strong); font-weight: var(--nk-weight-medium); }

/* Feature list with coral check marks. */
.nk-features { display: grid; gap: var(--nk-space-3); }
.nk-features li { display: flex; align-items: flex-start; gap: var(--nk-space-2); }
.nk-features .nk-icon { color: var(--nk-action-primary); margin-block-start: 2px; }

/* =======================================================================
 * PROMOTIONAL BANNER — .nk-promo
 * ===================================================================== */

.nk-promo {
  position: relative;
  display: grid;
  gap: var(--nk-space-4);
  padding: var(--nk-space-6);
  border-radius: var(--nk-radius-xl);
  background-color: var(--nk-surface-accent);
  overflow: hidden;
}
.nk-promo__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--nk-space-2);
  font-size: var(--nk-text-sm);
  font-weight: var(--nk-weight-semibold);
  color: var(--nk-text-accent);
}
.nk-promo__title {
  font-family: var(--nk-font-display);
  font-size: var(--nk-text-3xl);
  font-weight: var(--nk-weight-bold);
  color: var(--nk-text-strong);
  line-height: var(--nk-leading-tight);
}
.nk-promo__text { color: var(--nk-text-muted); }
.nk-promo--inverse { background-color: var(--nk-surface-inverse); }
.nk-promo--inverse .nk-promo__title { color: var(--nk-white); }
.nk-promo--inverse .nk-promo__text { color: var(--nk-cream-300); }

@media (min-width: 768px) {
  .nk-promo { padding: var(--nk-space-10); }
  .nk-promo--split { grid-template-columns: 1fr 1fr; align-items: center; }
  .nk-promo__title { font-size: var(--nk-text-4xl); }
}

/* =======================================================================
 * STICKY MOBILE ADD-TO-CART — .nk-sticky-cta
 * Appears once the in-page add-to-cart scrolls out of view.
 * Mobile only; hidden from 1024px up.
 * ===================================================================== */

.nk-sticky-cta {
  position: fixed;
  inset-inline: 0;
  inset-block-end: 0;
  z-index: var(--nk-z-sticky);
  display: flex;
  align-items: center;
  gap: var(--nk-space-3);
  padding: var(--nk-space-3) var(--nk-gutter);
  /* Keep clear of the iOS home indicator. */
  padding-block-end: calc(var(--nk-space-3) + var(--nk-safe-bottom));
  background-color: var(--nk-surface-raised);
  border-block-start: var(--nk-border-hairline);
  box-shadow: var(--nk-shadow-lg);
  transform: translateY(100%);
  transition: transform var(--nk-duration-normal) var(--nk-ease-out);
}
.nk-sticky-cta--visible { transform: translateY(0); }
.nk-sticky-cta__price { flex: none; }
.nk-sticky-cta .nk-btn { flex: 1; }

@media (min-width: 1024px) { .nk-sticky-cta { display: none; } }

/* When both the sticky CTA and bottom nav exist, the CTA sits above it. */
.nk-has-bottom-nav .nk-sticky-cta {
  inset-block-end: var(--nk-bottom-nav-height);
  padding-block-end: var(--nk-space-3);
}
