/*
 * Súbor: css/components/references.css
 * Obsah: Referencie, fotografická koláž, štvorcová mriežka s popismi, pohyblivé pásy, logá a jedna spoločná galéria pre všetky služby.
 * Použitie: index.html, betonove-a-oporne-mury.html, havarie-a-opravy-inzinierskych-sieti.html, inzinierske-siete-a-pripojky.html, sanacie-stavieb-a-staticke-zabezpecenie.html, rodinne-domy-hruba-stavba-a-holodom.html, rodinne-domy-hruba-stavba-a-holodom-bratislava.html, lokálne stránky inzinierske-siete-a-pripojky-{mesto}.html v koreni a sanacie-stavieb-a-staticke-zabezpecenie-pezinok.html.
 * Zapojenie: Po css/main.css; presné poradie uvádza css/README.md.
 * Závislosti: css/main.css, jeho farebné premenné a triedy komponentu.
 */

.references-heading {
  max-width: 760px;
  margin: 0 auto 36px;
  text-align: center;
}

.references-heading h2 {
  margin-bottom: 0;
}

/* Fotografická koláž */

.reference-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  grid-template-areas: "a a b b" "c d b b" "e e f g" "e e h h";
  width: min(960px, 100%);
  aspect-ratio: 1;
  margin-inline: auto;
  gap: 12px;
}

.reference-grid--wide {
  width: 100%;
}

:where(.reference-grid) .reference-project:nth-child(1) {
  grid-area: a;
}

:where(.reference-grid) .reference-project:nth-child(2) {
  grid-area: b;
}

:where(.reference-grid) .reference-project:nth-child(3) {
  grid-area: c;
}

:where(.reference-grid) .reference-project:nth-child(4) {
  grid-area: d;
}

:where(.reference-grid) .reference-project:nth-child(5) {
  grid-area: e;
}

:where(.reference-grid) .reference-project:nth-child(6) {
  grid-area: f;
}

:where(.reference-grid) .reference-project:nth-child(7) {
  grid-area: g;
}

:where(.reference-grid) .reference-project:nth-child(8) {
  grid-area: h;
}

.reference-scroll-hint {
  display: none;
}

.reference-project {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius);
  background: var(--palette-dark);
}

.reference-project__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .35s ease;
}

.reference-project:hover .reference-project__image,
.reference-project:focus-within .reference-project__image {
  transform: scale(1.035);
}

.reference-project__open {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: zoom-in;
  border-radius: inherit;
}

.reference-project__open:focus-visible {
  outline: 3px solid var(--palette-sand);
  outline-offset: -4px;
}

.reference-project__caption {
  position: absolute;
  inset: auto 0 0;
  padding: 30px 14px 12px;
  background: linear-gradient(to bottom, transparent, rgb(35 35 32 / 22%) 40%, rgb(35 35 32 / 54%));
  color: var(--palette-light);
  text-shadow: 0 1px 4px rgb(0 0 0 / 65%);
}

.reference-project__caption h3 {
  margin: 0 0 2px;
  color: var(--palette-light);
  font-size: clamp(14px, 1.4vw, 18px);
  line-height: 1.2;
  letter-spacing: -.02em;
}

.reference-project__caption p {
  margin: 0;
  color: var(--palette-light);
  font-size: 12px;
  line-height: 1.3;
}

@media (min-width: 768px) and (max-width: 1023px) {
  .reference-grid {
    gap: 10px;
  }

  :where(html:not([data-palette="homepage"])) .reference-project__caption {
    padding: 24px 10px 10px;
  }
}

@media (max-width: 767px) {
  .references-heading {
    margin-bottom: 24px;
  }

  .reference-grid {
    grid-template-areas: none;
    grid-template-columns: none;
    grid-template-rows: none;
    grid-auto-flow: column;
    grid-auto-columns: 82%;
    aspect-ratio: auto;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding-bottom: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--palette-taupe) var(--palette-light-alt);
  }

  .reference-grid .reference-project {
    grid-area: auto;
    aspect-ratio: 4 / 3;
    scroll-snap-align: start;
  }

  :where(html:not([data-palette="homepage"])) .reference-project__caption {
    padding: 30px 14px 12px;
  }

  :where(html:not([data-palette="homepage"])) .reference-project__caption h3 {
    font-size: 17px;
  }

  :where(html:not([data-palette="homepage"])) .reference-project__caption p {
    font-size: 13px;
  }

  .reference-scroll-hint {
    display: block;
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 12px;
  }
}
/* Štvorcové fotografie s popismi pod obrázkom */

.reference-grid.reference-grid--square {
  width: 100%;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: none;
  grid-template-areas: none;
  grid-auto-flow: row;
  grid-auto-columns: auto;
  aspect-ratio: auto;
  gap: 36px 24px;
  overflow: visible;
  padding: 0;
}

.reference-grid--square .reference-project {
  grid-area: auto;
  aspect-ratio: auto;
  margin: 0;
  overflow: visible;
  border-radius: 0;
  background: transparent;
}

.reference-grid--square .reference-project__image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius);
  transition: none;
  transform: none;
}

.reference-grid--square .reference-project__caption {
  position: static;
  padding: 16px 0 0;
  background: none;
  color: var(--text);
  text-shadow: none;
}

.reference-grid--square .reference-project__caption h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.3;
}

.reference-grid--square .reference-project__caption p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.reference-grid--square .reference-project__open {
  inset: 0 0 auto;
  aspect-ratio: 1;
  border-radius: var(--radius);
}

.reference-grid--square .reference-project__open:focus-visible {
  outline-color: var(--text);
}

@media (max-width: 1023px) {
  .reference-grid.reference-grid--square {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px 20px;
  }
}

@media (max-width: 479px) {
  .reference-grid.reference-grid--square {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Spoločná galéria fotografií */

body.reference-gallery-open {
  overflow: hidden;
}

.reference-gallery {
  width: min(1100px, calc(100% - 24px));
  height: min(850px, calc(100dvh - 32px));
  max-width: none;
  max-height: none;
  padding: 52px 60px 18px;
  border: 1px solid var(--palette-taupe);
  border-radius: 12px;
  background: var(--palette-dark);
  color: var(--palette-light);
}

.reference-gallery::backdrop {
  background: rgb(0 0 0 / 82%);
}

.reference-gallery[open] {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.reference-gallery__image {
  width: 100%;
  flex: 1;
  min-height: 0;
  object-fit: contain;
  touch-action: pan-y;
}

.reference-gallery__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.reference-gallery__footer h3 {
  margin: 0 0 2px;
  color: var(--palette-light);
  font-size: 18px;
}

.reference-gallery__footer p {
  margin: 0;
  color: var(--palette-sand);
  font-size: 13px;
}

.reference-gallery__count {
  white-space: nowrap;
  color: var(--palette-sand);
  font-size: 13px;
}

.reference-gallery__button {
  position: absolute;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--palette-sand);
  border-radius: 50%;
  background: var(--palette-dark);
  color: var(--palette-light);
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
}

.reference-gallery__button:hover {
  background: var(--palette-taupe);
}

.reference-gallery__button:focus-visible {
  outline: 2px solid var(--palette-sand);
  outline-offset: 3px;
}

.reference-gallery__close {
  top: 8px;
  right: 8px;
}

.reference-gallery__previous {
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.reference-gallery__next {
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}

@media (max-width: 767px) {
  .reference-gallery {
    padding: 52px 8px 16px;
    gap: 12px;
  }

  .reference-gallery__previous,
  .reference-gallery__next {
    top: auto;
    bottom: 16px;
    transform: none;
    width: 36px;
    height: 36px;
  }

  .reference-gallery__footer {
    padding-inline: 44px;
    align-items: start;
  }

  .reference-gallery__footer h3 {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reference-project__image {
    transition: none;
  }
}

:where(html[data-palette="homepage"]) .references-heading h2 {
  margin-bottom: 16px;
}

:where(html[data-palette="homepage"]) .references-heading>p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

:where(html[data-palette="homepage"]) .references-heading>p.references-heading__promise {
  margin-top: 16px;
  color: var(--accent);
  font-size: clamp(18px, 2vw, 22px);
  font-weight: 700;
}

/* Pohyblivé pásy fotografií */

.reference-marquee {
  overflow: hidden;
  width: 100%;
  padding: 4px 0;
}

:where(.reference-marquee) .reference-track {
  display: flex;
  width: max-content;
  animation: reference-belt var(--belt-duration, 200s) linear infinite;
  will-change: transform;
}

:where(.reference-marquee) .reference-sequence {
  --tile-width: 240px;
  display: grid;
  grid-auto-columns: var(--tile-width);
  grid-template-rows: repeat(2, 190px);
  grid-auto-flow: column dense;
  gap: 12px;
  padding-right: 12px;
  flex: 0 0 auto;
}

:where(.reference-marquee) .reference-project:nth-child(5n + 1) {
  grid-row: span 2;
}

@keyframes reference-belt {


      to {
        transform: translateX(-50%);
      }
    
}

:where(.reference-marquee) .reference-project {
  border-radius: 12px;
}

:where(.reference-marquee) .reference-project__image {
  display: block;
}

:where(.reference-marquee) .reference-project:hover .reference-project__image,
:where(.reference-marquee) .reference-project:focus-within .reference-project__image {
  transform: scale(1.04);
}

:where(.reference-marquee) .reference-project__caption {
  padding: 48px 16px 16px;
  background: linear-gradient(transparent, rgb(0 0 0 / 72%));
  color: #fff;
  text-shadow: 0 1px 4px rgb(0 0 0 / 40%);
}

:where(.reference-marquee) .reference-project__caption h3 {
  margin: 0 0 5px;
  color: #fff;
  font-size: 17px;
}

:where(.reference-marquee) .reference-project__caption p {
  color: #fff;
}

@media (max-width: 767px) {
  :where(.reference-marquee) .reference-sequence {
    --tile-width: 180px;
    grid-template-rows: repeat(2, 150px);
    gap: 8px;
    padding-right: 8px;
  }

  :where(.reference-marquee) .reference-project__caption {
    padding: 36px 12px 12px;
  }

  :where(.reference-marquee) .reference-project__caption h3 {
    font-size: 15px;
  }
}

:where(html[data-palette="homepage"]) .reference-gallery::backdrop {
  background: rgb(36 49 66 / 82%);
}

@media (prefers-reduced-motion: reduce) {
  .reference-marquee {
    overflow-x: auto;
  }

  .reference-marquee .reference-track {
    animation: none;
  }

  .reference-marquee .reference-sequence[aria-hidden="true"] {
    display: none;
  }
}

/* Pás referenčných log */

.reference-logo-marquee {
  overflow: hidden;
  width: 100%;
  margin-top: 24px;
  padding-block: 12px;
}

.reference-logo-track {
  display: flex;
  width: max-content;
  animation: reference-logo-belt var(--belt-duration, 80s) linear infinite;
  will-change: transform;
}

.reference-logo-sequence {
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex: 0 0 auto;
  min-width: 100vw;
  gap: 24px;
  margin: 0;
  padding: 0 24px 0 0;
  list-style: none;
}

.reference-logo-sequence li {
  display: grid;
  place-items: center;
  flex: 0 0 208px;
  height: 112px;
  padding: 16px;
  border-radius: 8px;
  background: #fff;
}

.reference-logo-sequence img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

@keyframes reference-logo-belt {


  from { transform: translateX(-50%); }
  to { transform: translateX(0); }

}

@media (max-width: 767px) {
  .reference-logo-sequence {
    gap: 16px;
    padding-right: 16px;
  }

  .reference-logo-sequence li {
    flex-basis: 160px;
    height: 88px;
    padding: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reference-logo-marquee {
    overflow-x: auto;
  }

  .reference-logo-track {
    animation: none;
  }

  .reference-logo-sequence[aria-hidden="true"] {
    display: none;
  }
}

@media (min-width: 768px) {
  .sanacie-references .reference-grid {
    grid-template-areas: "a a b b" "c c b b" "d e f f" "d e f f";
  }
}
