/* ========================= */
/* BASE                      */
/* ========================= */
html {
  background-color: black;   /* tło tylko tutaj, żeby #potwor z z-index:-1 był widoczny */
  touch-action: manipulation; /* no double-tap zoom */
}
body {
  margin: 0;
  color: white;
  touch-action: manipulation;
}

/* gif tła + jego warstwa (blokuje kliknięcia podczas intro) */
.x {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: auto;
}
.bg-gif {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  z-index: 2;
  pointer-events: auto;
}

/* tytuł */
.twinps {
  width: 90vw;
  max-width: 800px;
  height: auto;
  pointer-events: none;
}
.middle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  pointer-events: none;
}
.fade-out {
  opacity: 0;
  visibility: hidden;
  transition: opacity 2s ease, visibility 0s linear 2s;
}

/* potwór: na środku, za wszystkim */
#potwor {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(var(--potwor-scale, 1));
  z-index: -1;
  pointer-events: none;
}

/* ========================= */
/* GALLERY                   */
/* ========================= */
.imagecontainer {
  position: relative;
  z-index: 5;
  padding: 2rem;
  margin-top: 100vh;      /* galeria zaczyna się pod ekranem tytułowym */
  background: black;      /* usuń tę linię, jeśli chcesz widzieć potwora za galerią */
}

.gallery {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  gap: 4px;
  margin-top: 1.5rem;
}
.gallery figure {
  margin: 0;
  cursor: pointer;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  position: relative;
}
.gallery img, .gallery video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .3s;
}
.gallery figure:hover img, .gallery figure:hover video { transform: scale(1.1); }

.gallery .play {
  position: absolute; right: 2px; bottom: 2px;
  font-size: 8px; line-height: 1; padding: 2px 3px;
  color: #fff; background: rgba(0,0,0,.6); pointer-events: none;
}
.gallery .bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 3px; pointer-events: none;
}

.sortbar {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 1rem;
}
.sortbar button {
  color: #fff; background: transparent; border: 1px solid #555; padding: 2px 10px;
  margin-right: 4px; cursor: pointer; font: inherit;
}
.sortbar button:hover { border-color: #fff; }

@media (max-width: 700px) {
  .gallery { grid-template-columns: repeat(8, 1fr); }
}

/* ========================= */
/* LIGHTBOX                  */
/* ========================= */
.lb {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .92);
}
.lb[hidden] { display: none; }

.lb-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 92vw;
  max-height: 86vh;
}
.lb-stage img,
.lb-stage video {
  max-width: 92vw;
  max-height: 86vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.lb-stage video {
  opacity: 0;                    /* hidden until metadata loads, so no small-square flash */
  transition: opacity .15s;
}
.lb-stage video.ready { opacity: 1; }

.lb-info {
  position: absolute;
  bottom: 14px;
  left: 0;
  right: 0;
  text-align: center;
  color: #ccc;
  font-size: 14px;
}

.lb button {
  position: absolute;
  background: transparent;
  border: 0;
  color: #fff;
  cursor: pointer;
  line-height: 1;
  padding: 12px 16px;
  opacity: .7;
}
.lb button:hover { opacity: 1; }
.lb-close { top: 10px; right: 14px; font-size: 2.5rem; }
.lb-prev, .lb-next { top: 50%; transform: translateY(-50%); font-size: 3.5rem; }
.lb-prev { left: 10px; }
.lb-next { right: 10px; }
.lb-mute { bottom: 50px; right: 14px; font-size: 1.8rem; }

/* ========================= */
/* DESKTOP ONLY              */
/* ========================= */
@media (min-width: 769px) {
  #potwor {
    --potwor-scale: 1;     /* zmień np. na 0.5, jeśli jest za duży */
  }

  .content {
    display: flex;
  }

  .flex {
    flex-direction: column;
    display: flex;
    align-self: center;
    align-items: center;
  }

  .menu {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 30px;
  }

  .menu button {
    background: transparent;
    color: white;
    border: 1px solid white;
    padding: 10px 25px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
  }

  .menu button:hover {
    background: white;
    color: black;
  }

  .scaled {
    transform-origin: center;
  }
}

/* ========================= */
/* MOBILE ONLY               */
/* ========================= */
@media (max-width: 768px) {
  #potwor {
    --potwor-scale: 0.2;
  }

  .sortbar {
    position: relative;
    z-index: 6;            /* above #p so the buttons stay clickable */
    margin-top: 13vh;      /* tune: moves buttons up/down under the gif */
  }

  .bt {
    display: none;
  }

  #p {
    position: absolute;
    top: 5vh;                        /* gif top edge, always on screen */
    left: 50%;
    transform: translateX(-50%) scale(0.4);
    transform-origin: top center;    /* scales downward from the top edge */
    z-index: 5;
  }

  /* lightbox on phones: keep video away from the close button */
  .lb-stage {
    margin-top: 6vh;
    max-height: 70vh;
  }
  .lb-stage img,
  .lb-stage video {
    max-height: 70vh;
  }
  .lb-close {
    top: 8px;
    right: 8px;
    padding: 14px 18px;
  }
}