/*
 * MEBLOVO Card Mobile Gallery — 0.8.4
 * Mobile/tablet: pełny slider jak w zaakceptowanej bazie.
 * 0.8.3: stabilna, kwadratowa wysokość mini-galerii w kafelkach, aby siatka kategorii nie pływa.
 * 0.8.4: delikatne dosunięcie ikon cech produktu pod miniaturę na mobile, bez zmiany desktopu.
 * Desktop: bezpieczny tryb in-place + panel ustawień administratora w PHP.
 */

@media (max-width: 1024px) {
  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap a.mccg-ready,
  ul.products li.product .astra-shop-thumbnail-wrap a.mccg-ready {
    display: block !important;
    position: relative;
    overflow: hidden;
    min-height: var(--mccg-stable-height, inherit);
    height: var(--mccg-stable-height, auto);
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-y;
  }

  .mccg-slider {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: inherit;
    overflow: hidden;
    background: transparent;
    border-radius: inherit;
    isolation: isolate;
    contain: layout paint;
  }

  .mccg-track {
    display: flex;
    width: 100%;
    height: 100%;
    transform: translate3d(0, 0, 0);
    transition: transform 260ms ease;
    will-change: transform;
  }

  .mccg-dragging .mccg-track {
    transition: none;
  }

  .mccg-slide {
    position: relative;
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    min-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    overflow: hidden;
  }

  .mccg-slide img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
    object-position: center center;
    border: 0;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
  }

  .mccg-cta-slide {
    box-sizing: border-box;
    cursor: pointer;
    background:
      radial-gradient(circle at 50% 0%, rgba(203, 188, 160, 0.18), rgba(255, 255, 255, 0) 48%),
      linear-gradient(180deg, #ffffff 0%, #faf8f4 100%);
    color: #111111;
  }

  .mccg-cta-inner {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    border: 1px solid rgba(203, 188, 160, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.62), 0 6px 18px rgba(17, 17, 17, 0.045);
  }

  .mccg-cta-kicker {
    display: block;
    line-height: 1.15;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(17, 17, 17, 0.42);
  }

  .mccg-cta-title {
    display: block;
    line-height: 1.16;
    font-weight: 750;
    letter-spacing: -0.018em;
    color: #111111;
  }

  .mccg-cta-action {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 999px;
    border: 1px solid rgba(17, 17, 17, 0.12);
    background: rgba(17, 17, 17, 0.92);
    color: #ffffff;
    line-height: 1;
    font-weight: 650;
    white-space: nowrap;
  }

  .mccg-cta-arrow {
    display: inline-block;
    transform: translateY(-0.5px);
    line-height: 1;
  }

  .mccg-dots {
    position: absolute;
    z-index: 3;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: max-content;
    max-width: calc(100% - 16px);
    border: 1px solid rgba(255, 255, 255, 0.38);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.44);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    pointer-events: none;
  }

  .mccg-dot {
    display: block;
    border-radius: 999px;
    background: rgba(17, 17, 17, 0.28);
    transition: width 180ms ease, background-color 180ms ease, opacity 180ms ease;
  }

  .mccg-dot.is-active {
    background: rgba(17, 17, 17, 0.78);
  }

  .mccg-noscript-hidden {
    display: none !important;
  }
}

@media (max-width: 767px) {
  /* Mobile: utrzymujemy równą, kwadratową mini-galerię w każdej karcie produktu.
     Zapobiega to rozjeżdżaniu rzędów, gdy obrazy lub slider ładują się asynchronicznie. */
  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap a.mccg-ready,
  ul.products li.product .astra-shop-thumbnail-wrap a.mccg-ready {
    height: var(--mccg-stable-height, auto) !important;
    min-height: var(--mccg-stable-height, 0px) !important;
    aspect-ratio: 1 / 1 !important;
  }

  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap a.mccg-ready .mccg-slider,
  ul.products li.product .astra-shop-thumbnail-wrap a.mccg-ready .mccg-slider {
    height: 100% !important;
    min-height: 0 !important;
  }
  .mccg-cta-slide {
    padding: 8px;
  }

  .mccg-cta-inner {
    min-height: 118px;
    padding: 12px 9px 11px;
    border-radius: 15px;
  }

  .mccg-cta-kicker {
    max-width: 136px;
    margin-bottom: 5px;
    font-size: 8.5px;
  }

  .mccg-cta-title {
    max-width: 138px;
    font-size: 11.6px;
  }

  .mccg-cta-action {
    max-width: 140px;
    margin-top: 8px;
    padding: 5px 8px;
    font-size: 9.5px;
  }

  .mccg-cta-arrow {
    font-size: 10px;
  }

  .mccg-dots {
    bottom: 6px;
    gap: 4px;
    padding: 3px 5px;
  }

  .mccg-dot {
    width: 4px;
    height: 4px;
  }

  .mccg-dot.is-active {
    width: 13px;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  /* Tablet: jednakowy, kwadratowy obszar mini-galerii dla każdego produktu. */
  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap a.mccg-ready,
  ul.products li.product .astra-shop-thumbnail-wrap a.mccg-ready {
    height: var(--mccg-stable-height, auto) !important;
    min-height: var(--mccg-stable-height, 0px) !important;
    aspect-ratio: 1 / 1 !important;
  }

  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap a.mccg-ready .mccg-slider,
  ul.products li.product .astra-shop-thumbnail-wrap a.mccg-ready .mccg-slider {
    height: 100% !important;
    min-height: 0 !important;
  }

  .mccg-cta-slide {
    padding: 12px;
  }

  .mccg-cta-inner {
    min-height: 168px;
    padding: 18px 16px 17px;
    border-radius: 20px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.66), 0 8px 24px rgba(17, 17, 17, 0.05);
  }

  .mccg-cta-kicker {
    max-width: 210px;
    margin-bottom: 8px;
    font-size: 10.5px;
  }

  .mccg-cta-title {
    max-width: 230px;
    font-size: 16px;
  }

  .mccg-cta-action {
    max-width: 230px;
    margin-top: 12px;
    padding: 8px 13px;
    font-size: 12px;
  }

  .mccg-cta-arrow {
    font-size: 13px;
  }

  .mccg-dots {
    bottom: 9px;
    gap: 5px;
    padding: 4px 7px;
    z-index: 4;
  }

  .mccg-dot {
    width: 5px;
    height: 5px;
  }

  .mccg-dot.is-active {
    width: 17px;
  }
}

@media (min-width: 1025px) {
  /* Desktop: nie zastępujemy obrazu sliderem. Dodajemy tylko absolutne kontrolki do istniejącej miniatury. */
  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap a.mccg-desktop-ready,
  ul.products li.product .astra-shop-thumbnail-wrap a.mccg-desktop-ready {
    position: relative !important;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
  }

  .mccg-desktop-nav {
    position: absolute;
    z-index: 5;
    top: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid rgba(17, 17, 17, 0.08);
    background: rgba(255, 255, 255, 0.78);
    color: rgba(17, 17, 17, 0.82);
    box-shadow: 0 8px 20px rgba(17, 17, 17, 0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    font-size: 25px;
    line-height: 1;
    font-weight: 300;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%) scale(0.96);
    transition: opacity 160ms ease, transform 160ms ease, background-color 160ms ease;
  }

  .mccg-desktop-prev {
    left: 12px;
  }

  .mccg-desktop-next {
    right: 12px;
  }

  .mccg-desktop-ready:hover .mccg-desktop-nav,
  .mccg-desktop-ready:focus-within .mccg-desktop-nav {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-50%) scale(1);
  }

  .mccg-desktop-nav:hover {
    background: rgba(255, 255, 255, 0.94);
  }

  .mccg-desktop-nav.is-disabled {
    opacity: 0 !important;
    pointer-events: none !important;
  }

  .mccg-desktop-cta {
    position: absolute;
    z-index: 3;
    inset: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    background:
      radial-gradient(circle at 50% 0%, rgba(203, 188, 160, 0.20), rgba(255, 255, 255, 0) 48%),
      linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(250, 248, 244, 0.97) 100%);
    color: #111111;
    transition: opacity 180ms ease;
  }

  .mccg-desktop-cta-active .mccg-desktop-cta {
    opacity: 1;
    pointer-events: auto;
  }

  .mccg-desktop-cta-inner {
    box-sizing: border-box;
    width: min(84%, 280px);
    min-height: 64%;
    border: 1px solid rgba(203, 188, 160, 0.92);
    border-radius: 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 22px 18px;
    background: rgba(255, 255, 255, 0.74);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.60), 0 10px 24px rgba(17, 17, 17, 0.05);
  }

  .mccg-desktop-cta-kicker {
    display: block;
    margin-bottom: 8px;
    font-size: 10px;
    line-height: 1.15;
    font-weight: 700;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: rgba(17, 17, 17, 0.42);
  }

  .mccg-desktop-cta-title {
    display: block;
    max-width: 230px;
    font-size: 17px;
    line-height: 1.16;
    font-weight: 750;
    letter-spacing: -0.018em;
    color: #111111;
  }

  .mccg-desktop-cta-action {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    max-width: 230px;
    margin-top: 14px;
    padding: 9px 15px;
    border-radius: 999px;
    border: 1px solid rgba(17, 17, 17, 0.12);
    background: rgba(17, 17, 17, 0.92);
    color: #ffffff;
    font-size: 12px;
    line-height: 1;
    font-weight: 650;
    white-space: nowrap;
  }

  .mccg-desktop-cta-arrow {
    display: inline-block;
    transform: translateY(-0.5px);
    line-height: 1;
  }

  .mccg-desktop-dots {
    position: absolute;
    z-index: 4;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: max-content;
    max-width: calc(100% - 18px);
    gap: 5px;
    padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, 0.38);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.44);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    pointer-events: none;
  }

  .mccg-desktop-dot {
    display: block;
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: rgba(17, 17, 17, 0.28);
    transition: width 160ms ease, background-color 160ms ease;
  }

  .mccg-desktop-dot.is-active {
    width: 18px;
    background: rgba(17, 17, 17, 0.78);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mccg-track,
  .mccg-dot,
  .mccg-desktop-dot,
  .mccg-desktop-nav {
    transition-duration: 1ms !important;
  }
}

/*
 * 0.8.4 — mobile feature icons spacing safe patch
 * Cel: ikony cech produktu na kafelku kategorii mają siedzieć bliżej zdjęcia/mini-galerii
 * w widoku mobile. Desktop pozostaje bez zmian, bo jego ułożenie zostało zaakceptowane jako idealne.
 * Selektory są zawężone do list produktów WooCommerce/Astra oraz typowych klas warstwy ikon specyfikacji.
 */
@media (max-width: 767px) {
  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap {
    margin-bottom: 2px !important;
  }

  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap + .astra-shop-summary-wrap {
    margin-top: 0 !important;
  }

  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap .meblovo-product-feature-icons,
  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap .meblovo-feature-icons,
  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap .msp-product-feature-icons,
  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap .msp-feature-icons,
  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap .msp-card-icons,
  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap .msp-feature-chips,
  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap .product-feature-icons,
  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap .product-feature-icons-list,
  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap [class*="feature-icon"],
  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap [class*="feature-icons"],
  .woocommerce ul.products li.product .astra-shop-thumbnail-wrap [class*="msp-feature"],
  .woocommerce ul.products li.product .astra-shop-summary-wrap > .meblovo-product-feature-icons,
  .woocommerce ul.products li.product .astra-shop-summary-wrap > .meblovo-feature-icons,
  .woocommerce ul.products li.product .astra-shop-summary-wrap > .msp-product-feature-icons,
  .woocommerce ul.products li.product .astra-shop-summary-wrap > .msp-feature-icons,
  .woocommerce ul.products li.product .astra-shop-summary-wrap > .msp-card-icons,
  .woocommerce ul.products li.product .astra-shop-summary-wrap > .msp-feature-chips,
  .woocommerce ul.products li.product .astra-shop-summary-wrap > .product-feature-icons,
  .woocommerce ul.products li.product .astra-shop-summary-wrap > .product-feature-icons-list,
  .woocommerce ul.products li.product .astra-shop-summary-wrap > [class*="feature-icon"],
  .woocommerce ul.products li.product .astra-shop-summary-wrap > [class*="feature-icons"],
  .woocommerce ul.products li.product .astra-shop-summary-wrap > [class*="msp-feature"] {
    margin-top: 3px !important;
    margin-bottom: 4px !important;
    padding-top: 0 !important;
    row-gap: 4px !important;
    column-gap: 5px !important;
    gap: 4px 5px !important;
  }
}
