/* =========================================================
   TWORZE — animowane tło portfolio
   ========================================================= */

:root {
  --tile-gap: 0px;

  /* Kolor bazowy kafelków.
     Możesz zmienić wszystkie poniższe wartości na własną tonację. */
  --c1: #e7edf0;
  --c2: #e2eaed;
  --c3: #dce6ea;
  --c4: #e9eef0;
  --c5: #d8e3e7;
  --c6: #e4ebee;
  --c7: #dfe9ec;
  --c8: #eaf0f2;

  --text: #111111;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #e4ebee;
  font-family: Arial, Helvetica, sans-serif;
}

/* 6 x 4 = 24 pól na dużym ekranie */
.background-grid {
  position: fixed;
  inset: 0;
  z-index: 0;

  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: var(--tile-gap);

  width: 100vw;
  height: 100vh;
}

.tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;

  display: flex;
  align-items: center;
  justify-content: center;
}

/* Oba obrazki leżą dokładnie w tym samym miejscu */
.tile img {
  position: absolute;
  width: 46%;
  height: 46%;
  object-fit: contain;

  /* Jeśli Twoje grafiki są bardzo szczegółowe, można zwiększyć do 55% */
  pointer-events: none;
  user-select: none;

  opacity: 0;
  transform: scale(0.98);
  transition:
    opacity 1.35s ease,
    transform 1.35s ease;
}

.tile img.active {
  opacity: 1;
  transform: scale(1);
}

/* Delikatna warstwa nad kafelkami.
   Możesz ustawić opacity na 0, jeśli nie będzie potrzebna. */
.readability-layer {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;

  background: rgba(255, 255, 255, 0.08);
}

/* Treść */
.hero {
  position: fixed;
  inset: 0;
  z-index: 10;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  pointer-events: none;
}

.logo {
  display: block;
  width: min(260px, 30vw);
  margin-bottom: clamp(35px, 6vh, 75px);

  pointer-events: auto;
}

.logo img {
  display: block;
  width: 100%;
  height: auto;
}

.main-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(28px, 5vw, 90px);

  pointer-events: auto;
}

.main-nav a {
  position: relative;

  color: #fff;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: clamp(32px, 2.1vw, 52px);
  font-weight: 700;

  transition: opacity 0.25s ease, transform 0.25s ease;
}

.main-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -8px;
  height: 2px;

  background: currentColor;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.25s ease;
}

.main-nav a:hover {
  opacity: 0.65;
  transform: translateY(-2px);
}

.main-nav a:hover::after,
.main-nav a:focus-visible::after {
  transform: scaleX(1);
}

.main-nav a:focus-visible,
.logo:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 8px;
}

/* =========================================================
   TELEFON
   2 x 4 = 8 widocznych pól
   ========================================================= */

@media (max-width: 700px) {
  .background-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(4, minmax(0, 1fr));
  }

  /* Pokazujemy tylko pierwsze 8 kafelków.
     JavaScript dobiera im 16 grafik z całej kolekcji. */
  .tile:nth-child(n + 9) {
    display: none;
  }

  .tile img {
    width: 48%;
    height: 48%;
  }

  .hero {
    justify-content: center;
  }

  .logo {
    width: min(210px, 52vw);
    margin-bottom: 48px;
  }

  .main-nav {
    flex-direction: column;
    gap: 22px;
  }

  .main-nav a {
    font-size: clamp(24px, 7vw, 34px);
  }
}

/* Małe telefony */
@media (max-width: 380px) {
  .logo {
    margin-bottom: 35px;
  }

  .main-nav {
    gap: 16px;
  }

  .main-nav a {
    font-size: 22px;
  }
}

/* Osoby, które ograniczają animacje w systemie,
   dostają spokojne, statyczne tło. */
@media (prefers-reduced-motion: reduce) {
  .tile img {
    transition: none;
  }
}
