/* ===================== NASZE PROJEKTY — WERSJA DOCELOWA ===================== */
/* Ten plik styluje wyłącznie body.projects-page. Globalna czcionka pozostaje z styles.css. */

html:has(body.projects-page),
html.normal-scroll-page:has(body.projects-page),
html.snap-page:has(body.projects-page) {
  scroll-snap-type: none !important;
  scroll-behavior: auto !important;
  overflow-y: auto !important;
  height: auto !important;
  min-height: 100dvh !important;
}

body.projects-page {
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  background: #021F42;
  color: #fff;
}

body.projects-page *,
body.projects-page *::before,
body.projects-page *::after {
  box-sizing: border-box;
}

body.projects-page > .fade-page {
  width: min(100%, 1480px);
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    calc(var(--page-edge, 18px) + var(--nav-control-size, 62px) + clamp(18px, 3svh, 38px))
    clamp(16px, 4vw, 54px)
    clamp(48px, 7vw, 92px);
}

.projects-main {
  width: 100%;
}

.projects-header {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto clamp(32px, 5svh, 58px);
  text-align: center;
}

.projects-header h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(3rem, 6.2vw, 5rem);
  font-weight: 700;
  line-height: 1.05;
  text-shadow: 0 4px 22px rgba(0, 0, 0, 0.5);
}

/* ===================== KAFELKI ===================== */

.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(22px, 2.6vw, 38px);
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
}

.project-card {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: clamp(20px, 2vw, 28px);
  background: #082b4f;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  isolation: isolate;
  transform: translateZ(0);
  transition: transform 0.24s ease, box-shadow 0.24s ease, border-color 0.24s ease;
}

.project-card:hover,
.project-card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(187, 238, 255, 0.25);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
  outline: none;
}

.project-card:focus-visible {
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.34),
    0 0 0 3px rgba(187, 238, 255, 0.55);
}

.project-cover,
.project-cover img,
.project-cover-empty {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.project-cover {
  overflow: hidden;
  background: #082b4f;
}

.project-cover img {
  display: block;
  object-fit: cover;
  object-position: center;
  transition: transform 0.38s ease;
}

.project-cover-contain img {
  object-fit: contain;
  padding: clamp(12px, 1.6vw, 22px);
  background:
    radial-gradient(circle at center, rgba(187, 238, 255, 0.10), transparent 62%),
    #061f3e;
}

.project-card:hover .project-cover img,
.project-card:focus-visible .project-cover img {
  transform: scale(1.045);
}

.project-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(to top, rgba(2, 31, 66, 0.96) 0%, rgba(2, 31, 66, 0.60) 30%, rgba(2, 31, 66, 0.10) 70%, rgba(0, 0, 0, 0.10) 100%);
}

.project-card-title {
  position: absolute;
  z-index: 3;
  left: clamp(18px, 2vw, 28px);
  right: clamp(18px, 2vw, 28px);
  bottom: clamp(18px, 2vw, 27px);
  text-align: left;
}

.project-card-title span,
.project-modal-section {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.11);
  color: #cfdfff;
  font-size: clamp(0.78rem, 0.9vw, 0.96rem);
  font-weight: 700;
  line-height: 1.2;
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.project-card-title span {
  margin-bottom: 11px;
}

.project-card-title h2 {
  margin: 0;
  color: #fff;
  font-size: clamp(1.35rem, 1.7vw, 2rem);
  font-weight: 800;
  line-height: 1.13;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.78);
}

.project-cover-empty {
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(circle at 24% 18%, rgba(187, 238, 255, 0.18), transparent 38%),
    linear-gradient(135deg, #0b416f, #021f42 60%, #06152a);
  color: rgba(255, 255, 255, 0.78);
  text-align: center;
  font-weight: 700;
}

.project-cover-empty span {
  padding: 0.75rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(2, 31, 66, 0.46);
}

/* ===================== MODAL ===================== */

.project-modal {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3dvh, 30px) clamp(10px, 3vw, 26px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.24s ease, visibility 0.24s ease;
}

.project-modal.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.project-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.project-modal-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: min(94vw, 860px);
  max-height: calc(100dvh - clamp(24px, 6dvh, 60px));
  overflow-x: hidden;
  overflow-y: auto;
  gap: clamp(14px, 2vw, 22px);
  padding: clamp(14px, 2vw, 22px);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: clamp(20px, 2vw, 28px);
  background: #082b4f;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.66);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.project-modal-close {
  position: absolute;
  top: clamp(20px, 2.6vw, 30px);
  right: clamp(20px, 2.6vw, 30px);
  z-index: 30;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0 0 3px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  background: rgba(2, 31, 66, 0.80);
  color: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease;
}

.project-modal-close:hover,
.project-modal-close:focus-visible {
  transform: scale(1.06);
  background: rgba(20, 74, 119, 0.95);
  outline: none;
}

.project-gallery {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: clamp(250px, 43dvh, 410px);
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: clamp(17px, 2vw, 24px);
  background: #021F42;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
  touch-action: pan-y;
}

.project-gallery img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: #021F42;
  user-select: none;
  -webkit-user-drag: none;
}

.project-gallery img[hidden],
.project-gallery-empty[hidden],
.project-gallery-btn[hidden],
.project-gallery-counter[hidden],
.project-gallery-dots[hidden] {
  display: none !important;
}

.project-gallery-empty {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 2rem;
  color: #cfdfff;
  text-align: center;
  font-weight: 700;
  background:
    radial-gradient(circle at center, rgba(187, 238, 255, 0.12), transparent 58%),
    #021F42;
}

.project-gallery-empty span {
  max-width: 80%;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.project-gallery-btn {
  position: absolute;
  top: 50%;
  z-index: 20;
  display: grid;
  place-items: center;
  width: 46px;
  height: 56px;
  padding: 0;
  transform: translateY(-50%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(2, 31, 66, 0.80);
  color: #fff;
  font-size: 1.85rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease;
}

.project-gallery-btn:hover,
.project-gallery-btn:focus-visible {
  transform: translateY(-50%) scale(1.05);
  background: rgba(31, 92, 139, 0.94);
  outline: none;
}

.project-gallery-prev {
  left: clamp(10px, 2vw, 18px);
}

.project-gallery-next {
  right: clamp(10px, 2vw, 18px);
}

.project-gallery-counter {
  position: absolute;
  left: 50%;
  bottom: 13px;
  z-index: 20;
  transform: translateX(-50%);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(2, 31, 66, 0.82);
  color: #cfdfff;
  font-size: 0.9rem;
  font-weight: 700;
  pointer-events: none;
}

.project-gallery-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  width: 100%;
  min-height: 12px;
  margin: -2px 0 0;
}

.project-gallery-dots button {
  width: 11px;
  height: 11px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.30);
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease;
}

.project-gallery-dots button:hover,
.project-gallery-dots button:focus-visible {
  transform: scale(1.22);
  outline: none;
}

.project-gallery-dots button.active {
  transform: scale(1.28);
  background: #bbeeff;
}

.project-modal-text {
  width: 100%;
  padding: clamp(4px, 1vw, 10px) clamp(4px, 1vw, 10px) clamp(2px, 1vw, 8px);
  text-align: left;
}

.project-modal-section {
  margin-bottom: 14px;
}

.project-modal-text h2 {
  margin: 0 0 14px;
  color: #fff;
  font-size: clamp(1.65rem, 3vw, 2.65rem);
  font-weight: 800;
  line-height: 1.12;
  text-shadow: 0 4px 22px rgba(0, 0, 0, 0.42);
}

.project-modal-text p {
  margin: 0;
  color: #fff;
  font-size: clamp(0.98rem, 1.22vw, 1.14rem);
  line-height: 1.58;
}

/* Blokada strony pod modalem — tylko dla podstrony Projekty. */
html.project-scroll-lock,
body.project-scroll-lock {
  overflow: hidden !important;
}

body.project-scroll-lock {
  position: fixed !important;
  left: 0;
  right: 0;
  width: 100%;
}

/* ===================== TABLET ===================== */

@media (max-width: 1023px) {
  .projects-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 860px;
  }

  .project-card-title h2 {
    font-size: clamp(1.35rem, 2.5vw, 1.85rem);
  }
}

/* ===================== TELEFON PIONOWO ===================== */

@media (max-width: 760px) {
  body.projects-page > .fade-page {
    padding-top: calc(var(--page-edge, 12px) + var(--nav-control-size, 54px) + 18px);
    padding-left: 14px;
    padding-right: 14px;
    padding-bottom: 54px;
  }

  .projects-header {
    margin-bottom: 28px;
  }

  .projects-header h1 {
    font-size: clamp(2.45rem, 11vw, 3.45rem);
  }

  .projects-grid {
    grid-template-columns: 1fr;
    max-width: 430px;
    gap: 22px;
  }

  .project-card {
    border-radius: 22px;
  }

  .project-card:hover {
    transform: none;
  }

  .project-modal {
    padding: 10px;
  }

  .project-modal-content {
    width: min(96vw, 560px);
    max-height: calc(100dvh - 20px);
    gap: 12px;
    padding: 12px;
    border-radius: 20px;
  }

  .project-modal-close {
    top: 18px;
    right: 18px;
    width: 40px;
    height: 40px;
    font-size: 1.8rem;
  }

  .project-gallery {
    height: clamp(190px, 32dvh, 280px);
    border-radius: 16px;
  }

  .project-gallery-btn {
    width: 40px;
    height: 50px;
    font-size: 1.6rem;
  }

  .project-gallery-prev {
    left: 8px;
  }

  .project-gallery-next {
    right: 8px;
  }

  .project-gallery-counter {
    bottom: 9px;
    padding: 6px 12px;
    font-size: 0.82rem;
  }

  .project-modal-text {
    padding: 4px 4px 8px;
    text-align: center;
  }

  .project-modal-section {
    margin-left: auto;
    margin-right: auto;
  }

  .project-modal-text h2 {
    font-size: clamp(1.35rem, 6.2vw, 2rem);
    margin-bottom: 11px;
  }

  .project-modal-text p {
    font-size: clamp(0.9rem, 3.7vw, 1.02rem);
    line-height: 1.5;
  }
}

/* ===================== TELEFON POZIOMO ===================== */

@media (orientation: landscape) and (max-width: 980px) and (max-height: 560px) {
  body.projects-page > .fade-page {
    padding-top: 0;
  }

  .projects-header {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    margin: 0;
    padding: 0 16px;
  }

  .projects-header h1 {
    font-size: clamp(2.75rem, 16svh, 4.8rem);
  }

  .projects-grid {
    grid-template-columns: 1fr;
    max-width: 560px;
    padding-top: clamp(18px, 5svh, 34px);
  }

  .project-modal {
    padding: 8px 12px;
  }

  .project-modal-content {
    width: min(94vw, 720px);
    max-height: calc(100dvh - 16px);
    gap: 10px;
    padding: 10px;
  }

  .project-gallery {
    height: clamp(145px, 43dvh, 230px);
  }

  .project-modal-text {
    padding: 4px 8px 6px;
    text-align: left;
  }

  .project-modal-section {
    margin-left: 0;
  }

  .project-modal-text h2 {
    font-size: clamp(1.25rem, 6svh, 1.85rem);
    margin-bottom: 9px;
  }

  .project-modal-text p {
    font-size: clamp(0.82rem, 3.6svh, 1rem);
    line-height: 1.45;
  }
}

@media (prefers-reduced-motion: reduce) {
  .project-card,
  .project-cover img,
  .project-modal,
  .project-modal-close,
  .project-gallery-btn,
  .project-gallery-dots button {
    transition: none !important;
  }
}


/* ===================== DOPASOWANIE ZDJĘĆ W MODALU =====================
   Nie zwiększa rozmiaru okna ani galerii.
   Całe zdjęcie jest zawsze widoczne i zachowuje naturalne proporcje.
   ===================================================================== */

/* Zachowujemy dotychczasowy rozmiar modalu */
body.projects-page .project-modal-content {
  width: min(94vw, 860px) !important;
  max-height: calc(100dvh - clamp(24px, 6dvh, 60px)) !important;
}

/* Zachowujemy dotychczasową wysokość pola zdjęcia */
body.projects-page .project-gallery {
  width: 100% !important;
  height: clamp(250px, 43dvh, 410px) !important;
  min-height: 0 !important;
  max-height: 410px !important;

  display: flex !important;
  align-items: center !important;
  justify-content: center !important;

  overflow: hidden !important;
  background: #021F42 !important;
}

/* Najważniejsza poprawka:
   zdjęcie mieści się W CAŁOŚCI wewnątrz istniejącej ramki. */
body.projects-page #projectModal #projectModalImage {
  display: block !important;

  width: 100% !important;
  height: 100% !important;

  max-width: 100% !important;
  max-height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;

  object-fit: contain !important;
  object-position: center center !important;

  margin: 0 auto !important;
  padding: 0 !important;
  transform: none !important;
  background: #021F42 !important;
}

/* Tablet — zachowujemy istniejący rozmiar okna */
@media (min-width: 761px) and (max-width: 1023px) {
  body.projects-page .project-modal-content {
    width: min(94vw, 720px) !important;
  }

  body.projects-page .project-gallery {
    height: clamp(250px, 43dvh, 410px) !important;
    max-height: 410px !important;
  }
}

/* Telefon pionowo — tylko dopasowanie zdjęcia, bez powiększania galerii */
@media (max-width: 760px) and (orientation: portrait) {
  body.projects-page .project-modal-content {
    width: min(96vw, 560px) !important;
    max-height: calc(100dvh - 20px) !important;
  }

  body.projects-page .project-gallery {
    height: clamp(190px, 32dvh, 280px) !important;
    max-height: 280px !important;
  }
}

/* Telefon poziomo — pozostawiamy wcześniejszy kompaktowy rozmiar */
@media (orientation: landscape) and (max-width: 980px) and (max-height: 560px) {
  body.projects-page .project-modal-content {
    width: min(94vw, 720px) !important;
    max-height: calc(100dvh - 16px) !important;
  }

  body.projects-page .project-gallery {
    height: clamp(145px, 43dvh, 230px) !important;
    max-height: 230px !important;
  }
}

