/* Product page of the pryalka theme */

/* The description column is as tall as its text (the old theme fitted it to the image with an inner scroll) */
@media (min-width: 576px) {
  #product-info .row.mb-3 > .col-sm-7 {
    position: static;
  }
}

#product-info .tab-content-wrapper,
#product-info .tab-content {
  overflow: visible;
  flex: none;
}

/* A long description or specification: cut with a fading edge and "show all" (product.js) */
.pp-collapse {
  position: relative;
  max-height: 320px;
  overflow: hidden;
}

.pp-collapse.fits,
.pp-collapse.open {
  max-height: none;
}

.pp-collapse.cut::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 72px;
  background: linear-gradient(rgba(255, 255, 255, 0), #fff);
  pointer-events: none;
}

.pp-collapse-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--ph-accent);
  font-size: 15px;
  font-weight: 600;
}

.pp-collapse-btn[hidden] {
  display: none;
}

.pp-collapse-btn:hover {
  color: var(--ph-accent-dark);
}

.pp-collapse-btn i {
  font-size: 12px;
  transition: transform 0.2s;
}

.pp-collapse-btn[aria-expanded="true"] i {
  transform: rotate(180deg);
}

.pp-collapse-btn span + span,
.pp-collapse-btn[aria-expanded="true"] span:first-child {
  display: none;
}

.pp-collapse-btn[aria-expanded="true"] span + span {
  display: inline;
}

@media (max-width: 575.98px) {
  .pp-collapse {
    max-height: 220px;
  }
}

/* Price and the way to buy */
.pp-buy {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  margin: 8px 0 4px;
}

.pp-price {
  display: flex;
  align-items: baseline;
  gap: 4px 10px;
}

.pp-from {
  margin-right: -4px;
  color: #6c6c6c;
  font-size: 18px;
}

.pp-price-new {
  font-size: 30px;
  font-weight: 700;
  color: #2b2b2b;
}

.pp-price-new:has(+ .pp-price-old) {
  color: var(--ph-accent);
}

.pp-price-old {
  font-size: 17px;
  color: #6c6c6c;
  text-decoration: line-through;
}

.pp-price-note {
  color: #6c6c6c;
  font-size: 14px;
}

.pp-stock {
  color: #1e7b34;
  font-size: 14px;
}

.pp-stock.low {
  color: var(--ph-accent-dark);
  font-weight: 600;
}

.pp-stock.none {
  color: #6c6c6c;
}

/* A product without variants: the quantity, "to the cart" and the quick order in one row by the price */
.pp-cart-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex-basis: 100%;
}

.pp-qty-box {
  display: inline-flex;
  align-items: center;
  height: 48px;
  border-radius: 10px;
  background: #f4f4f4;
}

.pp-qty-step {
  width: 44px;
  height: 100%;
  border: 0;
  border-radius: 10px;
  background: none;
  color: #2b2b2b;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}

.pp-qty-step:hover {
  background: #e9e9e9;
  color: var(--ph-accent);
}

.pp-qty-box input {
  width: 44px;
  border: 0;
  background: none;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
}

#product-info .pp-cart-row .pp-add,
#product-info .pp-cart-row [data-quick-order-add] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  /* The quick order button comes with .ms-2 (!important) */
  margin: 0 !important;
  padding: 0 24px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  box-shadow: none;
  transform: none;
}

#product-info .pp-cart-row .pp-add {
  min-width: 200px;
  border-color: var(--ph-accent);
  background: var(--ph-accent);
}

#product-info .pp-cart-row .pp-add:hover {
  border-color: var(--ph-accent-dark);
  background: var(--ph-accent-dark);
}

/* The quick order is the second way: outlined in the brand colour, not a second bright button */
#product-info .pp-cart-row [data-quick-order-add] {
  border: 1.5px solid var(--ph-accent);
  background: #fff;
  color: var(--ph-accent);
}

#product-info .pp-cart-row [data-quick-order-add]:hover {
  background: var(--ph-tint);
  color: var(--ph-accent-dark);
}

@media (max-width: 575.98px) {
  /* The title, the price and the button together on the first screen */
  #product-info .product-info-right h1 {
    margin-bottom: 4px;
    font-size: 24px;
  }

  #product-info .pp-buy {
    margin-top: 4px;
  }

  #product-info .pp-cart-row .pp-add {
    flex: 1;
    min-width: 0;
    padding: 0 12px;
  }

  #product-info .pp-cart-row [data-quick-order-add] {
    flex-basis: 100%;
  }
}

/* The sticky price and button of a phone (product.js shows it), on the bottom bar */
.pp-sticky {
  display: none;
}

@media (max-width: 991.98px) {
  .pp-sticky {
    display: flex;
    align-items: center;
    gap: 12px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--ph-tabbar-h, 0px) + env(safe-area-inset-bottom));
    z-index: 1035;
    padding: 8px 12px;
    border-top: 1px solid #ececec;
    background: #fff;
    box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.06);
    transform: translateY(calc(100% + var(--ph-tabbar-h, 0px) + 20px));
    transition: transform 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
  }

  .pp-sticky.shown {
    transform: none;
  }

  .pp-sticky-price {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    white-space: nowrap;
  }

  .pp-sticky-price .pp-price-new {
    font-size: 20px;
  }

  .pp-sticky-price .pp-price-old {
    font-size: 13px;
  }

  .pp-sticky-price .pp-from {
    margin: 0;
    font-size: 12px;
  }

  .pp-sticky .btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
  }

  .pp-sticky .pp-to-palette {
    max-width: none;
  }

  /* The button "to the top" stands over the bar while it is shown */
  body:has(.pp-sticky.shown) .ft-top {
    bottom: calc(var(--ph-tabbar-h, 0px) + env(safe-area-inset-bottom) + 76px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pp-sticky {
    transition: none;
  }
}

.pp-to-palette {
  flex-basis: 100%;
  max-width: 320px;
}

/* Palette */
.pp-palette {
  scroll-margin-top: 90px;
}

@media (max-width: 991.98px) {
  /* Under the sticky row of the header (catalog, search, cart) */
  .pp-palette {
    scroll-margin-top: 70px;
  }
}

.pp-palette-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.pp-palette-title {
  margin: 0;
  font-size: 22px;
}

.pp-palette-title small {
  color: #9a9a9a;
  font-size: 15px;
  font-weight: 400;
}

.pp-palette-tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pp-search {
  position: relative;
  margin: 0;
}

.pp-search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9a9a9a;
  pointer-events: none;
}

.pp-search .form-control {
  width: 260px;
  padding-left: 36px;
}

.pp-view .btn.active {
  background: #2b2b2b;
  border-color: #2b2b2b;
  color: #fff;
}

.pp-empty {
  padding: 24px;
  color: #6c6c6c;
  text-align: center;
}

#product-info .pp-palette .options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  padding: 0;
}

/*
 * The price list (sizes of eyes, needles): a row per variant, the name, the price, the stock and the button in
 * columns; on a phone two lines (the name and the price, then the stock and the button)
 */
#product-info .pp-palette.pp-list .options-grid {
  display: flex;
  flex-direction: column;
  /* The price stays near the name: a row is read at a glance */
  max-width: 760px;
  gap: 0;
  border: 1px solid #ececec;
  border-radius: 10px;
  overflow: hidden;
}

#product-info .pp-palette.pp-list .pp-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 150px 180px;
  grid-template-areas: "name cost stock actions";
  align-items: center;
  gap: 4px 16px;
  padding: 10px 16px;
  border: 0;
  border-radius: 0;
}

#product-info .pp-palette.pp-list .pp-item + .pp-item {
  border-top: 1px solid #ececec;
}

#product-info .pp-palette.pp-list .pp-item:hover {
  background: #fafafa;
}

#product-info .pp-palette.pp-list .pp-item[hidden] {
  display: none;
}

.pp-list .pp-item-name {
  grid-area: name;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 8px;
  font-size: 15px;
  text-align: left;
}

.pp-list .pp-item-title {
  font-weight: 600;
}

.pp-list .pp-item-cost {
  grid-area: cost;
  text-align: right;
}

.pp-list .pp-item-stock {
  grid-area: stock;
  text-align: left;
}

#product-info .pp-palette.pp-list .pp-item .option-actions {
  grid-area: actions;
  margin: 0;
  padding: 0;
}

@media (max-width: 575.98px) {
  #product-info .pp-palette.pp-list .pp-item {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name cost"
      "stock actions";
    gap: 6px 12px;
    padding: 10px 12px;
  }

  #product-info .pp-palette.pp-list .pp-item .option-actions {
    width: 150px;
  }
}

.pp-item-cost {
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.pp-item-cost:has(s) {
  color: var(--ph-accent);
}

.pp-item-cost s {
  color: #6c6c6c;
  font-size: 12px;
  font-weight: 400;
}

#product-info .pp-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 8px;
  border: 1px solid #ececec;
  border-radius: 10px;
  background: #fff;
}

#product-info .pp-item[hidden] {
  display: none;
}

#product-info .pp-item .option-image {
  order: 0;
  position: relative;
  aspect-ratio: 1 / 1;
  margin: 0;
}

#product-info .pp-item .option-image a,
#product-info .pp-item .option-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* The full price of a colour with a price change; with a special the old one struck through */
.pp-item-price {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 700;
}

.pp-item-price:has(s) {
  color: var(--ph-accent);
}

.pp-item-price s {
  color: #6c6c6c;
  font-size: 11px;
  font-weight: 400;
}

/* Name: the colour number first, then its name, a note in brackets (mixed dye lots and so on) small and grey */
.pp-item-name {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #2b2b2b;
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
}

.pp-item-num {
  font-weight: 700;
}

.pp-item-title {
  font-weight: 500;
}

.pp-item-note {
  color: #6c6c6c;
  font-size: 11px;
}

/* Darker than the stock green (4.6:1 instead of 3.3:1); the last ones in the orange of the theme */
.pp-item-stock {
  color: #1e7b34;
  font-size: 12px;
  text-align: center;
}

.pp-item-stock.low {
  color: var(--ph-accent-dark);
  font-weight: 600;
}

#product-info .pp-item .option-actions {
  margin-top: auto;
  padding: 4px 0 0;
}

/* Outlined: 60 filled buttons would drown the colours of the yarn; a colour in the cart shows its filled stepper */
#product-info .pp-item .add-to-cart-option {
  width: 100%;
  height: 38px;
  white-space: nowrap;
  padding: 0 12px;
  font-size: 13px;
  background: #fff;
  border: 1px solid var(--ph-accent);
  color: var(--ph-accent);
  font-weight: 600;
  box-shadow: none;
  transform: none;
  transition: background 0.15s, color 0.15s;
}

#product-info .pp-item .add-to-cart-option:hover,
#product-info .pp-item .add-to-cart-option:focus-visible {
  background: var(--ph-accent);
  color: #fff;
}

#product-info .pp-item .add-to-cart-option:disabled {
  border-color: #d5d5d5;
  background: #fff;
  color: #9a9a9a;
}

.pp-stepper {
  display: none;
  align-items: center;
  height: 38px;
  border-radius: var(--bs-border-radius-sm, 4px);
  background: var(--ph-accent);
  color: #fff;
}

.pp-item.in-cart .pp-stepper {
  display: flex;
}

.pp-item.in-cart .add-to-cart-option {
  display: none;
}

.pp-count {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

.pp-step {
  flex: none;
  width: 38px;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  font-size: 12px;
}

.pp-step:hover:not(:disabled) {
  background: var(--ph-accent-dark);
}

.pp-step:disabled {
  opacity: 0.4;
}

/* Compact: small swatches, the button adds the minimum quantity */
#product-info .pp-palette.compact .options-grid {
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

#product-info .pp-palette.compact .pp-item {
  padding: 6px;
}

#product-info .pp-palette.compact .pp-item-stock,
#product-info .pp-palette.compact .pp-item-note,
#product-info .pp-palette.compact .pp-cart-text {
  display: none;
}

#product-info .pp-palette.compact .pp-item-name {
  font-size: 12px;
}

#product-info .pp-palette.compact .add-to-cart-option,
#product-info .pp-palette.compact .pp-stepper {
  height: 30px;
}

#product-info .pp-palette.compact .pp-step {
  width: 24px;
}

#product-info .pp-palette.compact .pp-count-unit {
  display: none;
}

#product-info .pp-palette.compact .pp-count {
  font-size: 12px;
}

@media (max-width: 575.98px) {
  .pp-price-new {
    font-size: 26px;
  }

  .pp-to-palette {
    max-width: none;
  }

  .pp-palette-tools {
    flex: 1;
  }

  .pp-search {
    flex: 1;
  }

  .pp-search .form-control {
    width: 100%;
  }

  #product-info .pp-palette .options-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  #product-info .pp-palette.compact .options-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  #product-info .pp-palette.compact .pp-item-name {
    font-size: 11px;
  }

  /* The core stylesheet makes this button 16px on phones, with !important */
  #product-info .pp-item .add-to-cart-option {
    padding: 0 8px !important;
    font-size: 14px !important;
  }

  /* The description above ends with its own margins */
  #product-info .pp-palette {
    margin-top: 0;
  }

  #product-info .tab-content > .tab-pane > :last-child {
    margin-bottom: 0;
  }
}
