/* ==========================================================================
   WS Theme — single-product.css
   The custom /parduotuve single product page: gallery, buy-box (variant
   swatches + qty + add-to-cart), fullscreen gallery, mobile sticky buy bar,
   info tabs/accordion, related products, and the add-to-cart toast.
   design-system-v0.1.html §06, tabs §07. New transitions are transform/opacity
   only and collapse under prefers-reduced-motion (section 9).

   Contents:
     1. Layout (gallery + info split)
     2. Gallery
     3. Product info + price + stock
     4. Variant swatches (§06)
     5. Quantity + add-to-cart
     6. Info tabs / accordion (§07)
     7. Additional-information list
     8. Related products + toast
     9. Reduced motion
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Layout
   -------------------------------------------------------------------------- */
.single-product-main {
  padding-block: var(--spacing-xl);
}

.ws-product {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--spacing-lg);
}

@media (min-width: 992px) {
  .ws-product {
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-xl);
    align-items: start;
  }

  /* Keep the gallery in view while scrolling the info column (desktop only). */
  .ws-gallery {
    position: sticky;
    top: calc(var(--header-height) + var(--spacing-md));
  }
}

/* --------------------------------------------------------------------------
   2. Gallery
   -------------------------------------------------------------------------- */

.ws-gallery__stage {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  color: inherit;
  font: inherit;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(204, 0, 0, 0.08), transparent 60%),
    linear-gradient(180deg, var(--color-bg-card), var(--color-bg-surface));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: zoom-in;
  appearance: none;
}

.ws-gallery__stage:hover,
.ws-gallery__stage:focus-visible {
  border-color: rgba(255, 255, 255, 0.3);
}

.ws-gallery__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition:
    opacity 0.25s ease;
}

.ws-gallery__img.is-swapping {
  opacity: 0;
}

.ws-gallery__expand {
  position: absolute;
  right: var(--spacing-sm);
  bottom: var(--spacing-sm);
  width: 2.75rem;
  height: 2.75rem;
  background: rgba(17, 17, 17, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
}

.ws-gallery__expand::before,
.ws-gallery__expand::after {
  content: "";
  position: absolute;
  width: 0.65rem;
  height: 0.65rem;
  border-color: #fff;
}

.ws-gallery__expand::before {
  top: 0.65rem;
  right: 0.65rem;
  border-top: 2px solid;
  border-right: 2px solid;
}

.ws-gallery__expand::after {
  bottom: 0.65rem;
  left: 0.65rem;
  border-bottom: 2px solid;
  border-left: 2px solid;
}

.ws-gallery__thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-sm);
}

.ws-gallery__thumb {
  width: 4rem;
  height: 4rem;
  padding: 0;
  overflow: hidden;
  background-color: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.ws-gallery__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ws-gallery__thumb:hover,
.ws-gallery__thumb:focus-visible {
  border-color: rgba(255, 255, 255, 0.3);
}

.ws-gallery__thumb.is-active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent);
}

.ws-gallery-dialog {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  color: var(--color-text);
  background: rgba(10, 10, 10, 0.98);
  border: 0;
  opacity: 0;
  transform: scale(0.98);
  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    display 0.22s allow-discrete;
}

.ws-gallery-dialog[open] {
  display: block;
  opacity: 1;
  transform: scale(1);
}

.ws-gallery-dialog.is-closing {
  opacity: 0;
  transform: scale(0.98);
}

.ws-gallery-dialog::backdrop {
  background: rgba(0, 0, 0, 0.9);
}

@starting-style {
  .ws-gallery-dialog[open] {
    opacity: 0;
    transform: scale(0.98);
  }
}

.ws-gallery-dialog__surface,
.ws-gallery-dialog__media {
  width: 100%;
  height: 100%;
}

.ws-gallery-dialog__surface {
  position: relative;
}

.ws-gallery-dialog__media {
  display: grid;
  place-items: center;
  padding: clamp(4rem, 8vw, 6rem);
  touch-action: pan-y;
}

.ws-gallery-dialog__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ws-gallery-dialog__close,
.ws-gallery-dialog__nav {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  color: #fff;
  font: inherit;
  font-size: 2rem;
  line-height: 1;
  background: rgba(26, 26, 26, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  cursor: pointer;
}

.ws-gallery-dialog__close {
  top: max(var(--spacing-md), env(safe-area-inset-top));
  right: var(--spacing-md);
}

.ws-gallery-dialog__nav {
  top: 50%;
  transform: translateY(-50%);
}

.ws-gallery-dialog__nav--prev {
  left: var(--spacing-md);
}

.ws-gallery-dialog__nav--next {
  right: var(--spacing-md);
}

.ws-gallery-dialog__count {
  position: absolute;
  bottom: max(var(--spacing-md), env(safe-area-inset-bottom));
  left: 50%;
  margin: 0;
  padding: 0.4rem 0.75rem;
  color: #fff;
  background: rgba(26, 26, 26, 0.88);
  border-radius: var(--radius-pill, 999px);
  transform: translateX(-50%);
}

/* --------------------------------------------------------------------------
   3. Product info + price + stock
   -------------------------------------------------------------------------- */
.ws-product__cat {
  margin: 0 0 var(--spacing-xs);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.ws-product__cat a {
  color: inherit;
}

.ws-product__title {
  margin: 0 0 var(--spacing-sm);
  font-size: clamp(1.6rem, 4vw, 2.25rem);
}

/* Price hierarchy mirrors the product card: bold amount + muted "su PVM". */
.ws-product__price {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  margin-bottom: var(--spacing-sm);
}

.ws-product__price-amount {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
}

.ws-product__price-amount del {
  margin-right: var(--spacing-xs);
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

.ws-product__price-amount ins {
  text-decoration: none;
}

.ws-product__price-sub {
  margin-top: 2px;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.ws-product__stock {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-sm);
  margin: 0 0 var(--spacing-md);
  font-size: 0.9375rem;
  color: var(--color-text);
}

.ws-product__stock-text {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--color-green);
  font-weight: 600;
}

.ws-product__stock-text::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  flex: 0 0 0.5rem;
  background-color: currentColor;
  border-radius: 50%;
}

.ws-product__stock.is-out .ws-product__stock-text {
  color: var(--color-text-muted);
}

.ws-product__stock.is-out .ws-product__stock-text::before {
  display: none;
}

/* The shared .pl-badge display rule otherwise overrides the native hidden UA rule. */
.ws-product__stock [data-ws-low-stock][hidden] {
  display: none;
}

.ws-product__excerpt {
  margin-bottom: var(--spacing-lg);
  color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   4. Variant swatches (design-system §06)
   -------------------------------------------------------------------------- */
.ws-swatches {
  margin-bottom: var(--spacing-md);
}

.ws-swatches__label {
  display: block;
  margin-bottom: var(--spacing-sm);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.ws-swatches__options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
}

.ws-swatch {
  min-width: 2.75rem;
  min-height: 2.75rem; /* 44px touch target */
  padding: 0.625rem 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  background-color: var(--color-bg-card);
  border: 1.5px solid var(--color-border);
  border-radius: 9px;
  cursor: pointer;
  transition:
    border-color 0.16s ease,
    background-color 0.16s ease,
    box-shadow 0.16s ease,
    color 0.16s ease;
}

.ws-swatch:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

/* Selected: accent border + soft glow fill. */
.ws-swatch.is-selected,
.ws-swatch[aria-checked="true"] {
  color: #fff;
  background-color: rgba(204, 0, 0, 0.12);
  border-color: var(--color-accent);
  box-shadow: 0 0 12px rgba(204, 0, 0, 0.25);
}

.ws-swatch:focus-visible {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(204, 0, 0, 0.2);
}

/* Out of stock: dashed, dimmed, visible but not selectable. */
.ws-swatch.is-oos {
  color: var(--color-text-muted);
  border-style: dashed;
  opacity: 0.5;
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   5. Quantity + add-to-cart
   -------------------------------------------------------------------------- */
.ws-buy__error {
  margin: 0 0 var(--spacing-sm);
  color: var(--color-accent-text);
  font-size: 0.875rem;
  font-weight: 600;
}

.ws-buy__error[hidden] {
  display: none;
}

.ws-buy__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  align-items: stretch;
  margin-top: var(--spacing-md);
}

.ws-qty {
  display: inline-flex;
  align-items: center;
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.ws-qty__btn {
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--color-text);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.ws-qty__btn:hover {
  background-color: rgba(255, 255, 255, 0.06);
}

.ws-qty__input {
  width: 3rem;
  height: 2.75rem;
  text-align: center;
  color: var(--color-text);
  background: none;
  border: none;
  border-inline: 1px solid var(--color-border);
  font-family: inherit;
  font-size: 1rem;
  appearance: textfield;
  -moz-appearance: textfield;
}

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

.ws-qty__input:focus-visible {
  outline: none;
}

.ws-add {
  flex: 1 1 12rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
}

/* Compact reassurance below the purchasing controls. */
.ws-product__info .ws-trust-badges {
  display: grid;
  align-items: center;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--spacing-sm) var(--spacing-md);
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--color-border);
}

.ws-trust-badges__item {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  gap: var(--spacing-sm);
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--color-text-muted);
}

.ws-trust-badges__item svg {
  flex: 0 0 1rem;
  width: 1rem;
  height: 1rem;
  margin-top: 0.08em;
  color: var(--color-text);
}

.ws-trust-badges__item span {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 420px) {
  .ws-product__info .ws-trust-badges {
    grid-template-columns: 1fr;
  }
}

.ws-add__spinner {
  display: none;
  width: 1.1em;
  height: 1.1em;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ws-spin 0.7s linear infinite;
}

.ws-add.is-loading .ws-add__spinner {
  display: inline-block;
}

.ws-add.is-loading .ws-add__text {
  opacity: 0.85;
}

@keyframes ws-spin {
  to {
    transform: rotate(360deg);
  }
}

/* --------------------------------------------------------------------------
   6. Info tabs / accordion (design-system §07)
   -------------------------------------------------------------------------- */
.ws-tabs {
  margin-top: var(--spacing-xl);
}

/* Accordion headers: mobile only. */
.ws-acc {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--spacing-md) 0;
  color: var(--color-text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
}

.ws-acc__icon {
  position: relative;
  width: 0.7em;
  height: 0.7em;
  flex-shrink: 0;
}

.ws-acc__icon::before,
.ws-acc__icon::after {
  content: "";
  position: absolute;
  background-color: currentColor;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.ws-acc__icon::before {
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  transform: translateY(-50%);
}

.ws-acc__icon::after {
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  transform: translateX(-50%);
}

.ws-acc.is-open .ws-acc__icon::after {
  transform: translateX(-50%) scaleY(0);
  opacity: 0;
}

/* Tablist: desktop only (hidden on mobile, accordion takes over). */
.ws-tabs__list {
  display: none;
}

.ws-tab {
  position: relative;
  padding: 0.75rem 0.25rem;
  margin-right: 1.4rem;
  color: var(--color-text-muted);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s ease;
}

.ws-tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background-color: var(--color-accent);
  border-radius: 2px 2px 0 0;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.ws-tab:hover {
  color: var(--color-text);
}

.ws-tab.is-active {
  color: var(--color-text);
}

.ws-tab.is-active::after {
  transform: scaleX(1);
}

.ws-tabs__panel {
  padding-block: var(--spacing-lg);
  color: var(--color-text-muted);
  line-height: 1.7;
}

.ws-tabs__panel[hidden] {
  display: none;
}

/* Reveal fade (opacity + slight translate, no height animation). */
.ws-tabs__panel.is-active {
  animation: ws-panel-in 0.25s ease;
}

@keyframes ws-panel-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 768px) {
  .ws-acc {
    display: none;
  }

  .ws-tabs__list {
    display: flex;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--color-border);
  }
}

/* --------------------------------------------------------------------------
   7. Additional-information list
   -------------------------------------------------------------------------- */
.ws-info {
  margin: 0;
}

.ws-info__row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.25rem;
  padding-block: var(--spacing-md);
  border-bottom: 1px solid var(--color-border-soft);
}

.ws-info__row:last-child {
  border-bottom: 0;
}

.ws-info__label {
  font-weight: 600;
  color: var(--color-text);
}

.ws-info__value {
  margin: 0;
  color: var(--color-text-muted);
}

@media (min-width: 600px) {
  .ws-info__row {
    grid-template-columns: 14rem 1fr;
    gap: var(--spacing-lg);
  }
}

/* --------------------------------------------------------------------------
   8. Related products
   Shared add-to-cart toast styles live in main.css.
   -------------------------------------------------------------------------- */
.ws-related {
  margin-top: var(--spacing-xl);
}

.ws-related__title {
  margin-bottom: var(--spacing-lg);
  font-size: clamp(1.4rem, 4vw, 2rem);
}

.ws-related__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
  margin: 0;
  padding: 0;
  list-style: none;
}

.ws-related__item {
  display: flex;
}

.ws-related__item > .product-card {
  width: 100%;
}

@media (min-width: 768px) {
  .ws-related__grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.ws-sticky-buy {
  display: none;
}

.ws-sticky-buy__sentinel {
  display: block;
  width: 100%;
  height: 1px;
  margin-top: -1px;
  pointer-events: none;
}

@media (max-width: 767px) {
  .ws-sticky-buy {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 300;
    display: block;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    padding-top: var(--spacing-sm);
    padding-right: calc(clamp(var(--spacing-sm), 4vw, var(--spacing-md)) + env(safe-area-inset-right));
    padding-bottom: calc(var(--spacing-sm) + env(safe-area-inset-bottom));
    padding-left: calc(clamp(var(--spacing-sm), 4vw, var(--spacing-md)) + env(safe-area-inset-left));
    background: rgba(17, 17, 17, 0.97);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(100%);
    visibility: hidden;
    pointer-events: none;
    transition:
      opacity 0.2s ease,
      transform 0.2s ease,
      visibility 0s linear 0.2s;
  }

  .ws-sticky-buy.is-visible {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
  }

  .ws-sticky-buy__inner {
    display: grid;
    grid-template-columns:
      clamp(2.5rem, 12vw, 3rem)
      minmax(0, 1fr)
      clamp(7rem, 38%, 8.75rem);
    align-items: center;
    gap: var(--spacing-sm);
    box-sizing: border-box;
    width: 100%;
    max-width: min(36rem, 100%);
    margin-inline: auto;
  }

  .ws-sticky-buy__inner > * {
    min-width: 0;
  }

  .ws-sticky-buy__thumb {
    width: 100%;
    max-width: 3rem;
    height: auto;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }

  .ws-sticky-buy__price {
    min-width: 0;
    overflow: hidden;
    color: var(--color-text);
    font-size: 0.875rem;
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .ws-sticky-buy__button {
    position: relative;
    width: 100%;
    min-width: 0;
    min-height: 3rem;
    padding-inline: clamp(0.625rem, 3vw, var(--spacing-md));
    white-space: nowrap;
  }

  .ws-sticky-buy__button.is-loading [data-ws-sticky-label] {
    opacity: 0;
  }

  .ws-sticky-buy__button.is-loading .ws-add__spinner {
    display: block;
    position: absolute;
    inset: 0;
    margin: auto;
  }

  body.has-ws-sticky-buy .single-product-main {
    padding-bottom: calc(6rem + env(safe-area-inset-bottom));
  }

}

/* --------------------------------------------------------------------------
   9. Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .ws-gallery__img,
  .ws-gallery__thumb,
  .ws-gallery-dialog,
  .ws-sticky-buy,
  .ws-swatch,
  .ws-qty__btn,
  .ws-tab,
  .ws-tab::after,
  .ws-acc__icon::before,
  .ws-acc__icon::after,
  .ws-gallery-dialog,
  .ws-gallery-dialog.is-closing {
    opacity: 1;
    transform: none;
  }

  .ws-tabs__panel.is-active,
  .ws-add__spinner {
    animation: none;
  }
}
