/*
 * Produkty — wyłącznie układ dwóch kart.
 * Kolory, typografia, cienie, hover i pozostałe komponenty pochodzą z głównego style.css.
 */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: clamp(28px, 4.5vw, 72px);
  max-width: 1240px;
  margin: 0 auto;
}

.product-card {
  grid-template-rows: auto 1fr auto;
  min-height: 340px;
  padding: clamp(34px, 3vw, 44px) clamp(28px, 3.2vw, 48px) 28px;
}

.product-card h3 {
  min-height: 0;
  margin-bottom: 20px;
  font-size: clamp(20px, 1.45vw, 24px);
  line-height: 1.2;
}

.product-card p {
  max-width: 540px;
  font-size: clamp(14px, .98vw, 15.5px);
  line-height: 1.62;
}

.product-card .service-more {
  margin-top: 26px;
}

@media (max-width: 960px) {
  .product-grid {
    grid-template-columns: 1fr;
    max-width: 700px;
    gap: 24px;
  }

  .product-grid .product-card,
  .product-grid .product-card:last-child {
    grid-column: auto;
    justify-self: stretch;
    width: 100%;
    max-width: none;
    min-height: 0;
  }
}

@media (max-width: 560px) {
  .product-card {
    padding: 28px 22px 22px;
  }

  .product-card h3 {
    margin-bottom: 14px;
    font-size: 20px;
  }

  .product-card p {
    font-size: 14px;
    line-height: 1.58;
  }
}

/* Nagłówek firmy w pierwszej kolumnie stopki — wyrównany z nagłówkami pozostałych kolumn. */
.footer-brand {
  padding-top: 0;
}

.footer-brand .footer-company-name {
  width: clamp(330px, 19vw, 390px);
  margin: 0 0 14px;
  color: #fff;
  text-align: left;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.4;
}

@media (max-width: 960px) {
  .footer-brand .footer-company-name {
    width: 100%;
    text-align: center;
  }
}

/* Dłuższe opisy produktów pozostają czytelne bez zmiany wyglądu modala usług. */
#productModal .service-modal__content strong {
  color: var(--text);
  font-weight: 800;
}

#productModal .service-modal__content > p + p {
  margin-top: 14px;
}

/* Galeria jest tworzona dopiero, gdy wskazane pliki screenów faktycznie istnieją. */
.product-gallery[hidden],
.product-gallery__item[hidden] {
  display: none !important;
}

.product-gallery {
  margin: clamp(26px, 3vw, 38px) 0;
  padding-top: clamp(24px, 2.5vw, 34px);
  border-top: 1px solid rgba(11, 29, 58, .10);
}

.product-gallery__eyebrow {
  margin-bottom: 8px !important;
  color: var(--blue) !important;
}

#productModal .product-gallery h3 {
  margin: 0 0 20px;
  color: var(--navy);
  font-size: clamp(20px, 2vw, 27px);
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: -.02em;
}

.product-gallery__grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.product-gallery__grid .product-gallery__item {
  grid-column: span 2;
}

/* 1 screen: duży, ale nie rozciągnięty na całą szerokość modala. */
.product-gallery__grid[data-count="1"] {
  grid-template-columns: minmax(0, 760px);
  justify-content: center;
}

.product-gallery__grid[data-count="1"] .product-gallery__item {
  grid-column: auto;
}

/* 2 screeny: dwa równe kafelki. */
.product-gallery__grid[data-count="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 1040px;
  margin-inline: auto;
}

.product-gallery__grid[data-count="2"] .product-gallery__item {
  grid-column: auto;
}

/* 4 screeny wyglądają lepiej jako układ 2 × 2 niż 3 + 1. */
.product-gallery__grid[data-count="4"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 1040px;
  margin-inline: auto;
}

.product-gallery__grid[data-count="4"] .product-gallery__item {
  grid-column: auto;
}

/* Przy większej liczbie ostatni niepełny rząd jest wyśrodkowany. */
.product-gallery__grid.has-remainder-1 .product-gallery__item:last-child {
  grid-column: 3 / span 2;
}

.product-gallery__grid.has-remainder-2 .product-gallery__item:nth-last-child(2) {
  grid-column: 2 / span 2;
}

.product-gallery__grid.has-remainder-2 .product-gallery__item:last-child {
  grid-column: 4 / span 2;
}

.product-gallery__item {
  appearance: none;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  color: var(--text);
  text-align: left;
  background: #fff;
  border: 1px solid rgba(20, 107, 255, .16);
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(3, 13, 30, .08);
  cursor: zoom-in;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.product-gallery__item:hover,
.product-gallery__item:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(20, 107, 255, .34);
  box-shadow: 0 16px 34px rgba(3, 13, 30, .13);
  outline: none;
}

.product-gallery__item img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: top center;
  background: #f4f7fb;
}

.product-gallery__item span {
  display: block;
  padding: 11px 13px 13px;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 700;
}

.product-lightbox {
  position: fixed;
  inset: 0;
  z-index: 6500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(14px, 3vw, 32px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease, visibility .18s ease;
}

.product-lightbox.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.product-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 13, 30, .78);
}

.product-lightbox__dialog {
  position: relative;
  z-index: 1;
  width: min(1380px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  margin: 0;
  padding: 14px 14px 12px;
  overflow: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .35);
}

.product-lightbox__dialog img {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 110px);
  object-fit: contain;
  border-radius: 10px;
}

.product-lightbox__dialog figcaption {
  padding: 10px 46px 0 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  font-weight: 600;
}

.product-lightbox__close {
  position: absolute;
  top: 22px;
  right: 22px;
  z-index: 2;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--navy);
  background: rgba(255, 255, 255, .96);
  border: 1px solid rgba(11, 29, 58, .12);
  border-radius: 12px;
  box-shadow: 0 8px 22px rgba(3, 13, 30, .16);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 900px) {
  .product-gallery__grid,
  .product-gallery__grid[data-count="2"],
  .product-gallery__grid[data-count="4"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: none;
  }

  .product-gallery__grid .product-gallery__item,
  .product-gallery__grid.has-remainder-1 .product-gallery__item:last-child,
  .product-gallery__grid.has-remainder-2 .product-gallery__item:nth-last-child(2),
  .product-gallery__grid.has-remainder-2 .product-gallery__item:last-child {
    grid-column: auto;
  }

  .product-gallery__grid[data-count="1"] {
    grid-template-columns: minmax(0, 680px);
    justify-content: center;
  }

  .product-gallery__grid[data-count="1"] .product-gallery__item {
    grid-column: auto;
  }

  .product-gallery__grid:not([data-count="1"]) .product-gallery__item:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    width: calc(50% - 8px);
    justify-self: center;
  }

  .product-gallery__item span {
    font-size: 13px;
  }
}

@media (max-width: 620px) {
  .product-gallery__grid,
  .product-gallery__grid[data-count="1"],
  .product-gallery__grid[data-count="2"],
  .product-gallery__grid[data-count="4"] {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .product-gallery__grid .product-gallery__item,
  .product-gallery__grid:not([data-count="1"]) .product-gallery__item:last-child:nth-child(odd) {
    grid-column: auto;
    width: 100%;
    justify-self: stretch;
  }
}

/*
 * Długie modale produktów: okno zawsze mieści się w wysokości viewportu,
 * a przewijana jest jego zawartość. Dzięki temu początek opisu jest zawsze dostępny.
 */
#productModal .service-modal__dialog {
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

@media (max-width: 720px) {
  #productModal .service-modal__dialog {
    max-height: calc(100vh - 28px);
    max-height: calc(100dvh - 28px);
  }
}
