/* ============ Podstawy ============ */
:root {
  --accent: #FFB347;
  --bg: #000;
  --text: #fff;
  --muted: rgba(255, 255, 255, 0.7);
  --nav-h: 64px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  --font: 'Roboto Condensed', 'Arial Narrow', Arial, sans-serif;
  --media-width: 75%;              /* szerokość playerów YouTube i galerii 3D na komputerze: 100% = pełna szerokość */
  --header-opacity: 0.5;             /* krycie grafik w nagłówkach galerii: 0 = niewidoczne, 1 = pełne */
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  /* Po kliknięciu w menu nagłówek sekcji wyrównuje się z paskiem nawigacji */
  scroll-padding-top: env(safe-area-inset-top, 0px);
  background: var(--bg);
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

img {
  max-width: 100%;
  -webkit-user-drag: none;         /* bez przeciągania obrazków na pulpit */
  -webkit-touch-callout: none;     /* iPhone: bez menu „Zapisz obraz” po przytrzymaniu */
  user-select: none;
}
.photo:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

a { font-weight: bold; color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ============ Ekran ładowania ============ */
.preloader {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.8s ease, visibility 0.8s ease;
  /* Zabezpieczenie: gdyby skrypt nie zadziałał, ekran zniknie sam po 6 s */
  animation: preloader-failsafe 0.5s ease 6s forwards;
}
.preloader img {
  height: 56px;
  width: auto;
  animation: pulse 1.6s ease-in-out infinite;
}
.is-loaded .preloader { opacity: 0; visibility: hidden; animation: none; }

@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes preloader-failsafe { to { opacity: 0; visibility: hidden; } }

/* ============ Nawigacja ============ */
.site-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: calc(var(--nav-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 20px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;            /* przezroczysty pasek nie blokuje kliknięć w treść */
}
.site-nav > * { pointer-events: auto; }

.site-nav .sygnet-link { display: flex; }
.site-nav .sygnet {
  height: 42px;
  width: auto;
  filter: drop-shadow(var(--shadow));
}
.site-nav ul {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  gap: 20px;
}
.site-nav ul a {
  color: var(--text);
  font-size: 18px;
  text-shadow: var(--shadow);
}
.site-nav ul a:hover { color: var(--accent); text-decoration: none; }

/* Hamburger – ukryty na szerokich ekranach */
.menu-toggle {
  display: none;
  width: 44px; height: 44px;
  padding: 11px 8px;
  background: none;
  border: 0;
  cursor: pointer;
  flex-direction: column;
  justify-content: space-between;
}
.menu-toggle span {
  display: block;
  height: 2px;
  background: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.menu-open .menu-toggle span:nth-child(1) { transform: translateY(10px) rotate(45deg); }
.menu-open .menu-toggle span:nth-child(2) { opacity: 0; }
.menu-open .menu-toggle span:nth-child(3) { transform: translateY(-10px) rotate(-45deg); }

@media (max-width: 768px) {
  :root { --nav-h: 56px; }
  .site-nav { padding-right: 8px; }
  .site-nav .sygnet { height: 36px; }
  .menu-toggle { display: flex; }

  /* Rozwijane menu pod przyciskiem */
  .site-nav ul {
    position: absolute;
    top: 100%;
    right: 0;
    flex-direction: column;
    gap: 0;
    min-width: 150px;
    padding: 8px 0;
    background: rgba(0, 0, 0, 0.0);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  }
  .menu-open ul { opacity: 1; visibility: visible; transform: none; }
  .site-nav ul a {
    display: block;
    padding: 14px 24px;
    font-size: 18px;
    text-align: right;
  }
}

/* ============ Ekran powitalny ============ */
.intro {
  position: relative;
  height: 100vh;
  height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.intro-bg { position: absolute; inset: 0; z-index: 0; background: #111; }
.intro-bg img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.5s ease-in-out;
}
.intro-bg img.active { opacity: 1; }

/* Powolne powiększanie teł (włączane w content.js polem backgroundZoom).
   Każde zdjęcie powiększa się od chwili pojawienia się, także podczas przenikania. */
.intro-bg.zoom img {
  transform-origin: center;
  will-change: transform;
  animation: bg-zoom 12s linear forwards;
}
@keyframes bg-zoom {
  from { transform: scale(1); }
  to   { transform: scale(calc(1 + var(--bg-zoom, 0.01) * 12)); }
}
@media (prefers-reduced-motion: reduce) {
  .intro-bg.zoom img { animation: none; }
}

.intro-logo {
  position: relative;
  z-index: 1;
  width: 25vw;
  max-width: 520px;
  height: auto;
  top: -30vh;          /* przesunięcie w dół względem środka ekranu (ujemna wartość = w górę) */
}
.intro-text {
  position: absolute;
  z-index: 1;
  bottom: 8vh;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 900px;
  margin: 0;
  font-size: clamp(16px, 2.2vw, 30px);
  font-weight: 400;
  line-height: 1.35;
  text-align: center;
  text-shadow: var(--shadow);
}
@media (max-width: 768px) {
  .intro-logo { width: 60vw; top: -30vh; }   /* telefon: przesunięcie logo */
  .intro-text { bottom: 10vh; }
}

/* ============ Sekcje strony głównej ============ */
.section { background: var(--bg); }
.section-header {
  margin: 0;
  height: var(--nav-h);            /* ta sama wysokość co pasek nawigacji */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  font-size: 24px;
  font-weight: 700;
  text-align: center;
}

/* Siatka prac */
.work-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 1000px) { .work-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .work-grid { grid-template-columns: 1fr; } }

.tile {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #111;
  color: var(--text);
}
.tile img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease, filter 0.3s ease, opacity 0.6s ease;
}
.tile-title {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  font-size: 36px;
  font-weight: 400;
  text-align: center;
  text-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.tile:hover { text-decoration: none; }
.tile:hover img, .tile:focus-visible img { transform: scale(1.08); filter: brightness(0.5); }
.tile:hover .tile-title, .tile:focus-visible .tile-title { opacity: 1; }

/* Ekrany dotykowe: brak hovera, więc tytuł widoczny stale na dole kafelka */
@media (hover: none) {
  .tile-title {
    opacity: 1;
    inset: auto 0 0 0;
    justify-content: flex-start;
    padding: 40px 16px 12px;
    font-size: 22px;
    background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75));
  }
  .tile:hover img { transform: none; filter: none; }
}

/* Płynne pojawianie się obrazów po wczytaniu */
img.fade { opacity: 0; }
img.fade.loaded { opacity: 1; }

/* Tekst: RESEARCH, ABOUT */
.prose {
  max-width: 1000px;
  margin: 0 auto;
  padding: 10px 20px 60px;
  font-size: 18px;
  line-height: 1.6;
}
.prose p { max-width: 75ch; }
.prose h3 { margin: 1.6em 0 0.4em; font-size: 20px; }
.prose h3:first-child { margin-top: 0.4em; }
.research-items { margin: 0; padding-left: 1.2em; max-width: 75ch; }
.research-items li { margin-bottom: 0.7em; }

/* RESEARCH w dwóch kolumnach – przeglądarka sama wyrównuje ich długość */
#research-list {
  max-width: 1300px;
  column-count: 2;
  column-gap: 60px;
}
#research-list li { break-inside: avoid; }
#research-list h3 { break-after: avoid; }
#research-list h3:first-child { margin-top: 0; }
@media (max-width: 800px) {
  #research-list { column-count: 1; }
}
.research-note { color: var(--muted); font-size: 16px; }

.about {
  display: grid;
  grid-template-columns: minmax(200px, 320px) 1fr;
  gap: 40px;
  align-items: start;
}
.about-photo {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  background: #111;
}
.about-text p:first-child { margin-top: 0; }
.about-subhead { margin: 1.6em 0 0.5em; font-size: 20px; }
/* ABOUT tak szeroki jak sekcja RESEARCH (zdjęcie + tekst) */
.prose.about { max-width: 1300px; }
.about-text p, .about-text .research-items { max-width: none; }
@media (max-width: 700px) {
  .about { grid-template-columns: 1fr; gap: 20px; }
  .about-photo { max-width: 360px; }
}

/* ============ Podstrona projektu ============ */
.project-header {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 4.3;
  overflow: hidden;
  background: var(--bg);           /* przy mniejszym kryciu grafika przyciemnia się do czerni */
}
.project-slides { position: absolute; inset: 0; }
.project-slides img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.5s ease-in-out;
}
.project-slides img.active { opacity: var(--header-opacity); }
.project-header h1 {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--nav-h) 20px 0;
  font-size: clamp(32px, 4vw, 56px);
  font-weight: 400;
  text-align: center;
  text-shadow: var(--shadow);
}
@media (max-width: 768px) {
  .project-header { aspect-ratio: auto; height: 30vh; height: 30svh; min-height: 200px; }
  .project-header h1 { font-weight: 700; }
}

/* Strzałki: poprzednia / następna praca */
.project-step {
  position: absolute;
  z-index: 2;
  top: calc(50% + var(--nav-h) / 2);
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  color: var(--text);
  text-shadow: var(--shadow);
}
.project-step:hover { color: var(--accent); text-decoration: none; }
.project-step--prev { left: 0; }
.project-step--next { right: 0; flex-direction: row-reverse; }
.step-arrow { font-size: 36px; line-height: 1; }
.step-label {
  font-size: 18px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.project-step:hover .step-label,
.project-step:focus-visible .step-label { opacity: 1; }
@media (max-width: 768px) {
  .project-step { padding: 16px 12px; }
  .step-arrow { font-size: 28px; }
  .step-label { display: none; }
}

.project-text {
  max-width: calc(850px + 40px);  /* 850 px tekstu + 2 × 20 px marginesu wewnętrznego */
  margin: 40px auto;
  padding: 0 20px;
  font-size: 16px;
  line-height: 1.6;
}
.project-info p { margin: 0.2em 0; color: var(--muted); }
.project-info { margin-bottom: 1.5em; }

.video {
  position: relative;
  width: 100%;
  max-width: var(--media-width);
  aspect-ratio: 16 / 9;
  margin: 0 auto 40px;
  background: #111;
}
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Skany 3D (Polycam) */
.scan-grid {
  display: grid;
  grid-template-columns: repeat(var(--scan-cols, 1), 1fr);
  max-width: var(--media-width);
  margin: 0 auto 40px;
}
@media (max-width: 1000px) {
  .scan-grid { grid-template-columns: 1fr; }
  .video, .scan-grid { max-width: none; }   /* tablet i telefon: pełna szerokość */
}
.scan {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #111;
}
.scan iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.scan-cover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0 24px;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}
.scan-cover span {
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  background: rgba(0, 0, 0, 0.6);
  transition: color 0.2s ease;
}
.scan-cover:hover span { color: var(--accent); }
.scan.active .scan-cover { display: none; }

/* Własne modele 3D */
.model-stage { position: absolute; inset: 0; }
.model-stage canvas { display: block; width: 100%; height: 100%; }
.model-stage model-viewer {
  width: 100%; height: 100%;
  background: transparent;
  --poster-color: transparent;
}
.model-poster {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
/* Strzałki: poprzedni / następny model */
.model-step {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;                      /* nad nakładką i samym modelem */
  padding: 16px 14px;
  background: none;
  border: 0;
  color: var(--text);
  font-family: inherit;
  font-size: 32px;
  line-height: 1;
  text-shadow: var(--shadow);
  cursor: pointer;
}
.model-step:hover { color: var(--accent); }
.model-step--prev { left: 0; }
.model-step--next { right: 0; }
@media (max-width: 768px) { .model-step { font-size: 26px; padding: 12px 8px; } }

.model3d.running .model-poster { opacity: 0; }     /* uśpiony model znowu pokazuje plakat */
.model3d.running:not(.active) .scan-cover { background: none; }
@media (max-width: 768px) {
  .scan { aspect-ratio: 4 / 3; }
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), 1fr);
  margin-bottom: 40px;
}
@media (max-width: 1000px) { .photo-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .photo-grid { grid-template-columns: 1fr; } }

.photo {
  display: block;
  overflow: hidden;
  aspect-ratio: var(--ratio, 16 / 9);
  background: #111;
  cursor: zoom-in;
}
.photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease, filter 0.3s ease, opacity 0.6s ease;
}
@media (hover: hover) {
  .photo:hover img { transform: scale(1.08); filter: brightness(0.7); }
}

/* ============ Modele 3D: siatka miniatur + przeglądarka na całym ekranie ============ */
.model-thumb { position: relative; }
.lightbox.model-lightbox { background: var(--bg); }     /* pełne tło – strona nie prześwituje spod modelu */
.model-badge {
  position: absolute;
  right: 10px; bottom: 10px;
  padding: 3px 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  background: rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.model-thumb:hover .model-badge { color: var(--accent); }

.model-lightbox .m3-stage {
  position: absolute;
  inset: calc(56px + env(safe-area-inset-top, 0px)) 64px calc(48px + env(safe-area-inset-bottom, 0px));
}
.model-lightbox .m3-stage model-viewer,
.model-lightbox .m3-stage canvas {
  display: block;
  width: 100%; height: 100%;
  background: transparent;
  --poster-color: transparent;
}
.model-lightbox .m3-status {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.model-lightbox .m3-caption {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top, 0px));
  left: 20px; right: 70px;
  font-size: 18px;
  text-shadow: var(--shadow);
}
.m3-prev { left: 4px;  top: 50%; transform: translateY(-50%); }
.m3-next { right: 4px; top: 50%; transform: translateY(-50%); }
.model-lightbox.single .m3-prev,
.model-lightbox.single .m3-next { display: none; }
@media (max-width: 768px) {
  .model-lightbox .m3-stage { left: 40px; right: 40px; }
}

/* ============ Lightbox ============ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.94);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  touch-action: pan-y;
}
.lightbox.open { opacity: 1; visibility: visible; }
.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  max-height: 88svh;
  object-fit: contain;
  user-select: none;
}
.lightbox button {
  position: absolute;
  background: none;
  border: 0;
  color: var(--text);
  font-family: inherit;
  font-size: 34px;
  line-height: 1;
  padding: 16px;
  cursor: pointer;
  text-shadow: var(--shadow);
}
.lightbox button:hover { color: var(--accent); }
.lb-close { top: calc(8px + env(safe-area-inset-top, 0px)); right: 8px; }
.lb-prev  { left: 4px;  top: 50%; transform: translateY(-50%); }
.lb-next  { right: 4px; top: 50%; transform: translateY(-50%); }
.lb-count {
  position: absolute;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  color: var(--muted);
}
@media (hover: none) { .lb-prev, .lb-next { display: none; } } /* na telefonie: przesuwanie palcem */

/* ============ Stopka ============ */
.site-footer {
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  font-size: 14px;
}
.site-footer .social { display: flex; justify-content: center; gap: 10px; margin-bottom: 12px; }
.site-footer .social img { width: 32px; height: 32px; display: block; }
.site-footer p { margin: 0; }

/* Stopka z grafiką (strona główna) */
.site-footer.has-image {
  position: relative;
  padding: 0;
  overflow: hidden;
}
.site-footer.has-image > img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 260px;
  object-fit: cover;
  transition: opacity 0.6s ease;
}
.site-footer.has-image::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 40%;
  background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.45));
  pointer-events: none;
}
.site-footer.has-image .social,
.site-footer.has-image p {
  position: absolute;
  left: 0; right: 0;
  z-index: 1;
  text-shadow: var(--shadow);
}
.site-footer.has-image .social {
  bottom: calc(48px + env(safe-area-inset-bottom, 0px));
  margin: 0;
}
.site-footer.has-image .social img { filter: drop-shadow(var(--shadow)); }
.site-footer.has-image p { bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }

/* ============ Pasek przewijania ============ */
html {
  scrollbar-color: #555 #000;   /* suwak, tło */
  scrollbar-width: thin;        /* thin = cienki, auto = normalny */
}

/* Przeglądarki bez obsługi standardu (Safari, starsze Chrome/Edge) */
@supports not (scrollbar-color: auto) {
  ::-webkit-scrollbar { width: 10px; }
  ::-webkit-scrollbar-track { background: #000; }
  ::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 5px;
    border: 2px solid #000;     /* odstęp suwaka od krawędzi */
  }
  ::-webkit-scrollbar-thumb:hover { background: var(--accent); }
}

/* ============ Ograniczenie animacji ============ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
