/* =====================================================================
   LEDart · Product code bar above listing images  (v1 · 2026-10-08)
   Shoptet template 11 · all shops. Load in the HEADER (no layout jump).
   Pairs with ldk-sku-bar.js (click-to-copy).
   Replaces the old hover script (togglePCodesOnHover): delete that one.

   How it works: the tile (.p) is already a flex column and the code
   (.p-code) is its direct child, so order:-1 moves it above the image.
   Pure CSS, so tiles loaded later (paging, filters) get it for free.
   ===================================================================== */

.products-block .p > .p-code {
  order: -1;                      /* above the image */
  position: static;               /* template overlays it top-right */
  display: flex !important;       /* template hides it on phones; also beats any leftover inline style */
  align-self: stretch;
  align-items: center;
  gap: 6px;
  height: 32px;
  box-sizing: border-box;
  margin: 0 0 10px;
  padding: 0 10px 0 12px;
  border: 1px solid #e3e8ed;
  border-radius: 8px;
  background: #f5f7fa;
  font-size: 12.5px;
  line-height: 1;
  color: #5f6a75;                 /* the shop's own label: Kód: / Kod: / Code: / Art.-Nr.: */
  white-space: nowrap;
  overflow: hidden;
  opacity: 1;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}

.products-block .p > .p-code [data-micro="sku"] {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  color: #1f2a33;
  letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
}

/* copy icon, pinned right */
.products-block .p > .p-code::after {
  content: "";
  order: 3;
  flex: none;
  width: 14px;
  height: 14px;
  margin-left: auto;
  background-color: #7b8691;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='12' height='12' rx='2'/%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='12' height='12' rx='2'/%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* hover: only on devices that really hover (no sticky hover on phones) */
@media (hover: hover) {
  .products-block .p > .p-code:hover { background: #ecf1f6; border-color: #cdd6df; }
  .products-block .p > .p-code:hover::after { background-color: #2a86c5; }
}

/* copied state: class + localized text set by ldk-sku-bar.js for 1.5 s */
.products-block .p > .p-code.ldk-sku-copied { background: #e7f5ec; border-color: #b5dcc3; }
.products-block .p > .p-code.ldk-sku-copied::before {
  content: attr(data-ldk-copied);
  order: 2;
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: #0e7a33;
}
.products-block .p > .p-code.ldk-sku-copied::after {
  margin-left: 0;
  background-color: #0e7a33;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

/* phones (2-column grid): slimmer bar, check icon only when copied */
@media (max-width: 767px) {
  .products-block .p > .p-code {
    gap: 4px;
    height: 28px;
    margin-bottom: 8px;
    padding: 0 8px 0 10px;
    font-size: 11.5px;
  }
  .products-block .p > .p-code.ldk-sku-copied::before { display: none; }
  .products-block .p > .p-code.ldk-sku-copied::after { margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .products-block .p > .p-code { transition: none; }
}
