/* Reset i podstawowe style */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Shadows Into Light Two', cursive; /* globalnie nowy font */
  line-height: 1.6;
  color: #333;
  overflow-x: hidden;
  background: #000;
}

/* A11y helpers */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* Kontener tła */
.background-container {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
}

.background-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.7);
}

/* Latający duszek — warstwa nad headerem, klikalny tylko obrazek */
.ghost-container {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;         /* kontener nie blokuje klików */
  z-index: 1200;                /* nad headerem (1000) i karuzelą (5/6) */
}

.ghost {
  position: absolute;
  width: 80px;
  height: 80px;
  opacity: 0.8;
  filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.6));
  animation: ghost-fly 35s ease-in-out infinite;
  pointer-events: auto;         /* sam duch zbiera klik/tap */
  cursor: pointer;
}

@keyframes ghost-fly {
  0%   { top: 20%; left: 10%; transform: translateY(0) rotate(0deg); }
  8%   { top: 18%; left: 20%; transform: translateY(-15px) rotate(3deg); }
  16%  { top: 25%; left: 30%; transform: translateY(-8px) rotate(-2deg); }
  24%  { top: 22%; left: 45%; transform: translateY(-18px) rotate(2deg); }
  32%  { top: 35%; left: 60%; transform: translateY(-5px) rotate(-1deg); }
  40%  { top: 30%; left: 70%; transform: translateY(-20px) rotate(4deg); }
  48%  { top: 45%; left: 80%; transform: translateY(-10px) rotate(-2deg); }
  56%  { top: 55%; left: 75%; transform: translateY(-25px) rotate(3deg); }
  64%  { top: 65%; left: 65%; transform: translateY(-12px) rotate(-1deg); }
  72%  { top: 50%; left: 55%; transform: translateY(-22px) rotate(2deg); }
  80%  { top: 35%; left: 40%; transform: translateY(-8px) rotate(-3deg); }
  88%  { top: 28%; left: 25%; transform: translateY(-17px) rotate(1deg); }
  96%  { top: 22%; left: 15%; transform: translateY(-12px) rotate(-2deg); }
  100% { top: 20%; left: 10%; transform: translateY(0) rotate(0deg); }
}

/* Header i nawigacja */
.header {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1000;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1rem;
}

/* Sekcja CA */
.ca-section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  margin-left: auto;
}

.ca-text {
  color: #fff;
  font-size: 0.9rem;
  font-family: 'Shadows Into Light Two', cursive;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.copy-button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 5px;
  color: #fff;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.copy-icon {
  width: 20px;
  height: 20px;
  filter: brightness(0) invert(1);
}

.copy-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.1);
}

/* Nawigacja */
.navigation {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  width: auto;
  margin: 0 auto;
  padding: 0 0.8rem;
}

.nav-link {
  text-decoration: none;
  color: #fff;
  font-size: 1.2rem;
  font-family: 'Shadows Into Light Two', cursive;
  font-weight: 400;
  padding: 0.8rem 1.5rem;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 25px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  width: auto;
  min-width: 90px;
  text-align: center;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.8);
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.3),
              0 0 20px rgba(255,255,255,0.3),
              0 0 40px rgba(255,255,255,0.15);
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #fff, transparent);
  transition: all 0.4s cubic-bezier(0.4,0,0.2,1);
  transform: translateX(-50%);
}
.nav-link:hover::after { width: 70%; }

/* Widoczny focus dla klawiatury */
.nav-link:focus-visible,
.back-button:focus-visible,
.copy-button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
  border-radius: 8px;
}

/* Główna zawartość */
.main-content {
  position: relative;
  z-index: 10;
  padding: 8rem 4rem 0 4rem;
  min-height: 60vh;
}

.description-section {
  max-width: 500px;
  background: rgba(0,0,0,0.01);
  padding: 2rem;
  border-radius: 20px;
  border: 0 solid rgba(255,255,255,0.02);
  box-shadow: 0 20px 40px rgba(99,67,67,0.01);
  text-align: right;
}

.main-title {
  font-size: 3rem;
  font-family: 'Shadows Into Light Two', cursive;
  font-weight: 400;
  letter-spacing: 2px;
  color: #fff;
  margin-bottom: 1.5rem;
  text-shadow: 0 4px 8px rgba(0,0,0,0.7);
}

.description-text {
  font-size: 1.2rem;
  font-family: 'Shadows Into Light Two', cursive;
  color: #e0e0e0;
  line-height: 1.8;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Karuzela obrazów */
.image-carousel-container {
  position: fixed;
  bottom: -10vh;
  left: 0;
  width: 100%;
  height: 50vh;
  overflow: hidden;
  z-index: 5;
}

.image-carousel {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  animation: scroll-left 120s linear infinite;
  width: max-content;
  /* performance hint */
  will-change: transform;
}

.carousel-image {
  width: 250px;
  height: 250px;
  object-fit: cover;
  border-radius: 15px;
  border: 3px solid rgba(255,255,255,0.3);
  box-shadow: 0 8px 25px rgba(0,0,0,0.4);
  transition: all 0.3s ease;
  filter: brightness(0.9);
  /* Stabilizacja miejsca (CLS) */
  aspect-ratio: 1 / 1;
}

.carousel-image:hover {
  transform: scale(1.05);
  border-color: rgba(255,255,255,0.8);
  box-shadow: 0 12px 35px rgba(0,0,0,0.6);
  filter: brightness(1.1);
}

@keyframes scroll-left {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* Galeria na osobnej stronie */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px,1fr));
  gap: 1rem;
  margin-top: 2rem;
  justify-content: center;
  justify-items: center;
}

.gallery-grid img {
  width: 100%;
  height: auto;
  border-radius: 15px;
  border: 3px solid rgba(255,255,255,0.3);
  box-shadow: 0 8px 25px rgba(0,0,0,0.4);
  transition: all 0.3s ease;
  filter: brightness(0.9);
  /* Stabilizacja miejsca (CLS) */
  aspect-ratio: 1 / 1;
}

.gallery-grid img:hover {
  transform: scale(1.05);
  border-color: rgba(255,255,255,0.8);
  box-shadow: 0 12px 35px rgba(0,0,0,0.6);
  filter: brightness(1.1);
}

.back-button {
  display: inline-block;
  text-decoration: none;
  color: #fff;
  font-family: 'Shadows Into Light Two', cursive;
  font-weight: 400;
  padding: 0.6rem 1.2rem;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  text-align: center;
  transition: all 0.3s ease;
  margin-bottom: 1rem;
}

.back-button:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.8);
  transform: translateY(-2px);
}

/* Pulsujące gwiazdki */
.pulsing-stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}

.star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  opacity: 0.3;
  box-shadow: 0 0 6px rgba(255,255,255,0.8);
  animation: pulse linear infinite;
  --min-opacity: 0.2;
  --max-opacity: 0.8;
}

@keyframes pulse {
  0%,100% {
    transform: scale(1);
    opacity: var(--min-opacity);
    box-shadow: 0 0 6px rgba(255,255,255,0.6);
  }
  50% {
    transform: scale(1.6);
    opacity: var(--max-opacity);
    box-shadow: 0 0 12px rgba(255,255,255,1);
  }
}

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  justify-content: center;
  align-items: center;
  z-index: 2000;
  -webkit-overflow-scrolling: touch;
}

.lightbox img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(255,255,255,0.5);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

/* Wydajność renderu dla długich list */
.image-carousel,
.gallery-grid img {
  content-visibility: auto;
  contain-intrinsic-size: 250px;
}

/* ======= Responsywność ======= */
@media (max-width: 768px) {
  .header { 
    left: 0; right: 0; width: 100%;
    padding: 1rem; gap: 1rem; 
    align-items: center;
  }

  .ca-section { margin-left: 0; align-self: center; }
  .ca-text { font-size: 0.8rem; }
  .copy-button { font-size: 0.9rem; padding: 0.2rem 0.4rem; }

  .navigation { 
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-self: center; 
    width: 100%;
    max-width: calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 2px);
    box-sizing: border-box;
    margin: 0 auto;
    gap: 0.22rem !important;
    padding-left: max(0.5rem, env(safe-area-inset-left));
    padding-right: max(0.5rem, env(safe-area-inset-right));
    overflow-x: clip;
  }

  .nav-link { 
    white-space: nowrap;
    font-size: 0.82rem;
    padding: 0.14rem 0.42rem !important;
    border-width: 1px;
    width: auto; 
    min-width: 0 !important;
    max-inline-size: 100%;
    text-align: center;
    letter-spacing: 0;
    line-height: 1.15;
  }

  .description-section { padding: 1.5rem; max-width: 400px; }
  .main-title { font-size: 1.5rem; }
  .description-text { font-size: 0.9rem; }

  .carousel-image { width: 200px; height: 200px; }
  .image-carousel-container { 
    height: 40vh; 
    bottom: 0 !important;             /* zamiast -10vh */
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 6;
  }

  /* iOS/Safari stabilizacja animacji */
  .image-carousel{
    display: inline-flex !important;
    gap: 1rem;
    padding: 1rem;
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }
  .carousel-image{ flex: 0 0 auto; }

  .ghost { width: 60px; height: 60px; }
  .star { transform: scale(0.8); }
}

@media (max-width: 480px) {
  .header { 
    left: 0; right: 0; width: 100%;
    padding: 0.7rem; gap: 0.7rem; 
    align-items: center;
  }

  .ca-section { margin-left: 0; align-self: center; }
  .ca-text { font-size: 0.7rem; }
  .copy-button { font-size: 0.8rem; padding: 0.2rem 0.3rem; }

  .navigation { 
    display: flex;
    flex-wrap: nowrap;
    justify-content: center; 
    align-self: center; 
    width: 100%; 
    max-width: calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 2px);
    box-sizing: border-box;
    margin: 0 auto;
    gap: 0.18rem !important;
    padding-left: max(0.40rem, env(safe-area-inset-left));
    padding-right: max(0.40rem, env(safe-area-inset-right));
    overflow-x: clip;
  }

  .nav-link { 
    white-space: nowrap;
    font-size: 0.70rem;
    padding: 0.12rem 0.36rem !important;
    border-width: 1px;
    width: auto; 
    min-width: 0 !important;
    max-inline-size: 100%;
    text-align: center;
    letter-spacing: 0;
    line-height: 1.12;
  }

  .description-section { padding: 1rem; max-width: 350px; }
  .main-title { font-size: 1.2rem; }
  .description-text { font-size: 0.8rem; }

  .carousel-image { width: 180px; height: 180px; }
  .image-carousel-container { height: 35vh; }

  .ghost { width: 50px; height: 50px; }
  .star { transform: scale(0.6); }
}

/* Preferencje ograniczonego ruchu */
@media (prefers-reduced-motion: reduce) {
  .ghost,
  .image-carousel,
  .star,
  .description-section,
  .main-title,
  .navigation {
    animation: none !important;
    transition: none !important;
  }
}

/* iPhone edge-bleed fix: ramka do środka + minimalny zapas */
@supports (-webkit-touch-callout: none) {
  .navigation {
    padding-left: max(10px, env(safe-area-inset-left)) !important;
    padding-right: max(10px, env(safe-area-inset-right)) !important;
  }
  .nav-link {
    border: 0 !important;                               /* bez klasycznego borderu */
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35); /* ramka do środka */
    padding-inline: 0.36rem !important;
  }
  .nav-link:hover {
    box-shadow:
      inset 0 0 0 1px rgba(255,255,255,0.8),
      0 8px 25px rgba(0,0,0,0.3),
      0 0 20px rgba(255,255,255,0.3),
      0 0 40px rgba(255,255,255,0.15);
  }

  /* wymuś jeszcze raz layer na karuzeli */
  @media (max-width:768px){
    .image-carousel{ -webkit-transform: translateZ(0); }
  }
}