/**
 * Inline variation swatches for product cards (card style 4).
 *
 * Written with logical properties throughout, so it needs no RTL build step —
 * the same file is correct for the Arabic/Hebrew and English storefronts.
 */

.noqta-card-variations {
  position: relative;
  inline-size: 100%;
  /* Never let the footer's flex alignment shrink-to-fit this block and centre it. */
  align-self: stretch;
  margin-block: 6px;
  text-align: center;
}

/* ── Attribute rows ─────────────────────────────────────────────────── */

/* One row per attribute, stacked the way the single product page stacks them.
   Each row is a single non-wrapping line that scrolls sideways when it overflows,
   so card height depends on the number of attributes, never on the number of
   options — twelve colours and three colours produce identically tall cards, and
   the grid stays even. */

.noqta-card-row {
  display: flex;
  align-items: center;
  /* Centred, to sit on the same axis as card 2's title, price and button — all
     of which style-2.css centres.
     The `safe` keyword matters: this row is a scroll container, and plain
     centring pushes overflowing content past the start edge where it can never
     be scrolled back into view. `safe` drops to start alignment the moment the
     content stops fitting. The plain declaration above it is the fallback for
     browsers that do not parse the keyword. */
  justify-content: center;
  justify-content: safe center;
  inline-size: 100%;
  text-align: center;
  gap: 6px;
  min-height: 22px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  padding-block: 1px;
}

.noqta-card-row::-webkit-scrollbar {
  display: none;
}

.noqta-card-row + .noqta-card-row {
  margin-block-start: 5px;
}

/* Text chips are taller than colour dots, so their row gets a little more air. */
.noqta-card-row--text {
  gap: 5px;
  min-height: 26px;
}

/* Flags the row still waiting for a choice when the customer hits add. */
.noqta-card-row.needs-choice {
  animation: noqtaCardNudge 0.4s ease;
}

@keyframes noqtaCardNudge {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-3px); }
  75%      { transform: translateX(3px); }
}

/* ── Swatches ───────────────────────────────────────────────────────── */

/* Deliberately close to the single product page's swatches (see the plugin's
   css/color-swatches.css): same outline for the selected state, same
   strike-through for out of stock, same "hide impossible combinations"
   behaviour — just sized down for a card. */

.noqta-card-swatch {
  inline-size: 20px;
  block-size: 20px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 50%;
  background-color: #f4f6f8;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  cursor: pointer;
  position: relative;
  flex: 0 0 auto;
  scroll-snap-align: start;
  transition: transform 0.18s ease;
}

.noqta-card-swatch:hover {
  transform: scale(1.12);
}

.noqta-card-swatch.is-light {
  border-color: rgba(0, 0, 0, 0.28);
}

/* Matches .swatch.selected on the product page. outline, not box-shadow: it
   does not participate in layout, so a selected chip cannot nudge the row. */
.noqta-card-swatch.is-selected {
  outline: 2px solid #222;
  outline-offset: 1px;
}

.noqta-card-swatch:focus-visible {
  outline: 2px solid #222;
  outline-offset: 2px;
}

/* Sizes and other non-visual attributes: bordered chips, like the product page. */
.noqta-card-swatch--text {
  inline-size: auto;
  block-size: auto;
  min-inline-size: 24px;
  padding: 3px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: #fff;
  color: #222;
  font-size: 12px;
  line-height: 1.45;
  white-space: nowrap;
}

.noqta-card-swatch--text:hover {
  transform: none;
  border-color: #222;
}

.noqta-card-swatch--text.is-selected {
  background: #111;
  border-color: #111;
  color: #fff;
  outline: none;
}

/* Out of stock: still shown, struck through — the customer wants to know the
   option exists. Same strike as .swatch-disabled on the product page.

   A colour keeps its real colour: unlike the product page there is no name
   under the dot, so fading it would turn a sold-out black into a grey the
   product does not come in. The strike alone says "sold out".

   A sold-out colour with a photo can still be picked to see it (no
   aria-disabled), so only the ones that can't be picked get this cursor. */
.noqta-card-swatch.is-unavailable[aria-disabled="true"] {
  cursor: not-allowed;
}

.noqta-card-swatch.is-unavailable::after {
  content: "";
  position: absolute;
  /* Physical on purpose: translate() is physical, so pairing it with
     inset-inline-start throws the line onto the neighbouring swatch on RTL
     storefronts. */
  top: 50%;
  left: 50%;
  inline-size: 130%;
  block-size: 2px;
  background: rgba(0, 0, 0, 0.7);
  /* Keeps the line readable on dark and black swatches. */
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85);
  transform: translate(-50%, -50%) rotate(-45deg);
  pointer-events: none;
}

.noqta-card-swatch--text.is-unavailable {
  opacity: 0.45;
}

.noqta-card-swatch--text.is-unavailable::after {
  content: none;
}

/* On the label too: text-decoration does not reach it once a theme lays the
   chip out as flex or grid. */
.noqta-card-swatch--text.is-unavailable,
.noqta-card-swatch--text.is-unavailable .noqta-card-swatch__label {
  text-decoration: line-through;
}

.noqta-card-swatch.is-unavailable:hover {
  transform: none;
}

/* Impossible combination for the current choice — removed, exactly as the
   product page removes it from the dropdown.

   !important because this is state, not look: Studio themes restyle the
   swatches and set their own display on them, which would otherwise bring
   the impossible options back. */
.noqta-card-swatch.is-hidden {
  display: none !important;
}

/* Nothing left to pick in this row: drop it rather than leave a gap. */
.noqta-card-row.is-empty {
  display: none !important;
}

.noqta-card-swatch-more {
  font-size: 11px;
  font-weight: 600;
  color: #555;
  text-decoration: none;
  line-height: 20px;
  padding-inline: 4px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.noqta-card-swatch-more:hover {
  color: #111;
}

/* ── Add button ─────────────────────────────────────────────────────── */

/* Card 2 renders its add-to-cart as a full-width anchor styled by
   .treesal-add-to-cart-icon, and already ships a .loading spinner for it. Card 4
   swaps the anchor for a <button> (there is nowhere to navigate to) and keeps
   that class, so all it needs here is the handful of UA button defaults that an
   anchor never had. Everything visual — colour, padding, radius, spinner — still
   comes from style-2.css, which means the card follows the merchant's theme
   colours automatically. */

.noqta-card-add {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  margin: 0;
  font: inherit;
  line-height: inherit;
  text-align: center;
  cursor: pointer;
}

.noqta-card-add[disabled] {
  cursor: default;
}

/* ── Feedback ───────────────────────────────────────────────────────── */

.noqta-card-note {
  margin: 6px 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: #c0392b;
  text-align: center;
}

/* ── Hover swap vs. variation image ─────────────────────────────────── */

/* The card sheet fades the main image out and the second gallery image in on
   hover, via rules as specific as
     .treesal-product-style-17.product-card.cardproduct:hover .product-image-hover
   which is (0,5,0) and !important. These overrides therefore have to carry the
   same class chain plus .has-variation-image to win on specificity — !important
   alone is not enough, and relying on stylesheet order would be fragile since
   this file and woocommerce.css are enqueued independently.

   This matters more than it looks: on desktop the pointer is by definition over
   the card when a swatch is clicked, so without this the selected variation
   image is never visible — the gallery image sits on top of it.

   style-16 carries the identical hover pair, so it is covered too: the swatch
   renderer is not tied to card 4 and may be enabled on the other cards. */

.treesal-product-style-17.product-card.cardproduct.has-variation-image .product-image-hover,
.treesal-product-style-17.product-card.cardproduct.has-variation-image:hover .product-image-hover,
.treesal-product-style-16.product-card.cardproduct.has-variation-image .product-image-hover,
.treesal-product-style-16.product-card.cardproduct.has-variation-image:hover .product-image-hover,
.product-card.has-variation-image .product-image-hover {
  opacity: 0 !important;
}

.treesal-product-style-17.product-card.cardproduct.has-variation-image .product-image-main,
.treesal-product-style-17.product-card.cardproduct.has-variation-image:hover .product-image-main,
.treesal-product-style-16.product-card.cardproduct.has-variation-image .product-image-main,
.treesal-product-style-16.product-card.cardproduct.has-variation-image:hover .product-image-main,
.product-card.has-variation-image .product-image-main {
  opacity: 1 !important;
}

/* Belt and braces for card markup that keeps the state class on the wrapper. */
.product-card .product-image-wrapper.has-variation-image .product-image-hover {
  opacity: 0 !important;
}

@media (prefers-reduced-motion: reduce) {
  .noqta-card-swatch,
  .noqta-card-row {
    animation: none;
    transition: none;
  }

  .noqta-card-swatch:hover {
    transform: none;
  }
}

@media (max-width: 768px) {
  .noqta-card-swatch {
    inline-size: 18px;
    block-size: 18px;
  }

  /* Text chips stay finger-sized on mobile even though colour dots shrink. */
  .noqta-card-swatch--text {
    inline-size: auto;
    block-size: auto;
    padding: 4px 8px;
  }
}
