:root {
  --pink: #f14e95;
  --ink: #202020;
  --muted: #777;
  --paper: #f8f7f5;
  --header: rgba(255, 255, 255, 0.94);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  min-width: 280px;
  background: var(--paper);
  color: var(--ink);
  font-family: "Work Sans", Arial, sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}
button, a { -webkit-tap-highlight-color: transparent; }

.gallery-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--header);
  border-bottom: 1px solid rgba(0,0,0,.06);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.gallery-header-inner {
  width: min(1560px, calc(100% - 64px));
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 0 10px;
}

.gallery-nav-row {
  min-height: 58px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: clamp(52px, 5vw, 110px);
}

.gallery-nav-simple {
  width: min(980px, 100%);
  margin: 0 auto;
  justify-content: space-between;
  gap: clamp(28px, 5vw, 80px);
}

.gallery-back {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 2px;
  color: #555;
  font-family: "Work Sans", Arial, sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: color .16s ease;
}

.gallery-back::before {
  content: "←";
  margin-right: 8px;
  font-size: 16px;
  line-height: 1;
}

.gallery-back::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 4px;
  height: 1px;
  background: #222;
  transition: right .16s ease;
}

.gallery-back:hover,
.gallery-back:focus-visible {
  color: #222;
}

.gallery-back:hover::after,
.gallery-back:focus-visible::after {
  right: 0;
}

.gallery-logo {
  flex: 0 0 auto;
  color: #222;
  font-family: "Sacramento", cursive;
  font-size: clamp(36px, 3vw, 47px);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  text-align: left;
}

.gallery-date {
  display: inline-block;
  margin-left: .22em;
  font-family: "Work Sans", Arial, sans-serif;
  font-size: .23em;
  font-weight: 400;
  letter-spacing: .08em;
  vertical-align: .34em;
}

.gallery-menu {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 2.1vw, 38px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.gallery-menu a {
  position: relative;
  display: block;
  padding: 9px 0;
  color: #707070;
  text-decoration: none;
  font-size: clamp(11px, .78vw, 14px);
  line-height: 1.25;
  font-weight: 400;
  white-space: nowrap;
  transition: color .16s ease;
}

.gallery-menu a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 3px;
  height: 1px;
  background: #222;
  transition: right .16s ease;
}

.gallery-menu a:hover,
.gallery-menu a:focus-visible,
.gallery-menu a.active {
  color: #222;
}

.gallery-menu a:hover::after,
.gallery-menu a:focus-visible::after,
.gallery-menu a.active::after {
  right: 0;
}

.gallery-heading {
  margin-top: 2px;
  text-align: center;
}

.gallery-heading h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 400;
}

.gallery-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.gallery-main {
  width: min(1600px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 60px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.photo-tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 5px;
  background: #eceae7;
  cursor: zoom-in;
}
.photo-tile img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transform: scale(1.002);
  transition: transform .25s ease, filter .25s ease;
}
.photo-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.03);
  transition: background .2s ease;
}
.photo-tile:hover img { transform: scale(1.035); }
.photo-tile:hover::after { background: rgba(0,0,0,.05); }
.photo-tile:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }

.gallery-empty {
  min-height: calc(100vh - 180px);
  display: grid;
  place-items: center;
  text-align: center;
  color: #666;
}
.gallery-empty h2 { margin-top: 0; color: #333; font-weight: 400; }
.gallery-empty p { margin: 18px 0 8px; }
.gallery-empty code {
  display: inline-block;
  max-width: calc(100vw - 40px);
  padding: 8px 10px;
  overflow-wrap: anywhere;
  background: #fff;
  border: 1px solid #e8e5e1;
  border-radius: 6px;
  color: #333;
}

/* Pełnoekranowy podgląd */
body.lightbox-open { overflow: hidden; }
.lightbox[hidden] { display: none !important; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: 70px 1fr 70px;
  grid-template-rows: 70px 1fr;
  color: #fff;
}
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(8, 8, 8, .96);
}
.lightbox-topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 8px max(18px, env(safe-area-inset-left));
  pointer-events: none;
}
.lightbox-counter {
  color: rgba(255,255,255,.72);
  font-size: 13px;
  font-weight: 400;
}
.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}
.lightbox-download,
.lightbox-close {
  color: #fff;
  border: 0;
  background: transparent;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
}
.lightbox-download {
  padding: 9px 12px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 400;
}
.lightbox-download:hover { border-color: rgba(255,255,255,.7); }
.lightbox-close {
  width: 44px;
  height: 44px;
  font-size: 36px;
  line-height: 38px;
  opacity: .88;
}

.lightbox-stage {
  position: relative;
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
}
.lightbox-image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 88px);
  max-height: calc(100svh - 88px);
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  opacity: 0;
  transform: translate3d(0,0,0) scale(1);
  transform-origin: center center;
  transition: opacity .15s ease, transform .18s ease;
  will-change: transform;
}
.lightbox-image.is-loaded { opacity: 1; }

.lightbox-loader {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: rgba(255,255,255,.85);
  border-radius: 50%;
  animation: gallery-spin .8s linear infinite;
}
.lightbox-loader.is-hidden { display: none; }
@keyframes gallery-spin { to { transform: rotate(360deg); } }

.lightbox-nav {
  grid-row: 2;
  align-self: stretch;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.72);
  cursor: pointer;
  font-size: 34px;
  transition: color .15s ease, background .15s ease;
}
.lightbox-nav:hover { color: #fff; background: rgba(255,255,255,.035); }
.lightbox-prev { grid-column: 1; }
.lightbox-next { grid-column: 3; }

@media (max-width: 1180px) {
  .photo-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1120px) {
  .gallery-header-inner { width: min(820px, calc(100% - 36px)); }
  .gallery-nav-row { flex-direction: column; gap: 5px; }
  .gallery-logo { font-size: 42px; text-align: center; }
  .gallery-menu {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px 14px;
  }
  .gallery-menu a { padding: 6px 8px; text-align: center; white-space: normal; font-size: 12px; }
  .gallery-menu a::after { left: 16%; right: 84%; }
  .gallery-menu a:hover::after,
  .gallery-menu a:focus-visible::after,
  .gallery-menu a.active::after { right: 16%; }
}
@media (max-width: 820px) {
  .gallery-heading h1 { font-size: 16px; }
  .gallery-main { width: calc(100% - 20px); padding-top: 10px; }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .lightbox { grid-template-columns: 48px 1fr 48px; }
  .lightbox-nav { font-size: 28px; }
}
@media (max-width: 560px) {
  .gallery-header-inner { width: calc(100% - 24px); padding-top: max(9px, env(safe-area-inset-top)); }
  .gallery-nav-row { gap: 3px; }
  .gallery-logo { font-size: 30px; }
  .gallery-date { font-size: .22em; }
  .gallery-menu { gap: 2px 7px; }
  .gallery-menu a { min-height: 34px; display: flex; align-items: center; justify-content: center; padding: 4px 6px; font-size: 10.5px; }
  .gallery-heading { margin-top: 1px; }
  .gallery-heading h1 { font-size: 13px; }
  .gallery-heading p { font-size: 9px; margin-top: 1px; }
  .gallery-main { width: calc(100% - 8px); padding-top: 4px; }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; }
  .photo-tile { border-radius: 2px; }

  .lightbox {
    grid-template-columns: 1fr;
    grid-template-rows: 62px 1fr 56px;
  }
  .lightbox-topbar { grid-column: 1; grid-row: 1; }
  .lightbox-stage { grid-column: 1; grid-row: 2; padding: 0 4px; }
  .lightbox-image { max-height: calc(100svh - 130px); }
  .lightbox-nav {
    position: absolute;
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 2;
    width: 64px;
    height: 44px;
    background: rgba(255,255,255,.06);
    border-radius: 999px;
  }
  .lightbox-prev { left: calc(50% - 72px); }
  .lightbox-next { right: calc(50% - 72px); }
  .lightbox-download { padding: 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .photo-tile img,
  .lightbox-image { transition: none; }
  .lightbox-loader { animation-duration: 1.6s; }
}


/* Prosty pasek galerii: nazwa po lewej, tylko "Wróć" po prawej */
@media (max-width: 1120px) {
  .gallery-nav-row.gallery-nav-simple {
    flex-direction: row;
    justify-content: space-between;
    gap: 24px;
  }
  .gallery-nav-simple .gallery-logo {
    text-align: left;
  }
}

@media (max-width: 560px) {
  .gallery-nav-row.gallery-nav-simple {
    min-height: 46px;
    gap: 12px;
  }
  .gallery-nav-simple .gallery-logo {
    font-size: clamp(25px, 8vw, 31px);
    min-width: 0;
  }
  .gallery-nav-simple .gallery-date {
    font-size: .20em;
    margin-left: .12em;
  }
  .gallery-back {
    min-height: 36px;
    padding: 5px 0;
    font-size: 11px;
  }
  .gallery-back::before {
    margin-right: 5px;
    font-size: 14px;
  }
}

/* v6 — jeden spójny pasek galerii: para | tytuł + liczba | wróć */
.gallery-nav-row.gallery-nav-simple {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(18px, 3vw, 48px);
  min-height: 62px;
}

.gallery-nav-simple .gallery-logo {
  justify-self: start;
  font-size: clamp(32px, 2.5vw, 42px);
}

.gallery-current {
  justify-self: center;
  min-width: 0;
  text-align: center;
  font-family: "Work Sans", Arial, sans-serif;
  color: #222;
  line-height: 1.15;
  white-space: nowrap;
}

.gallery-current strong {
  display: block;
  font-size: clamp(12px, .9vw, 15px);
  font-weight: 500;
}

.gallery-current span {
  display: block;
  margin-top: 3px;
  color: #888;
  font-size: clamp(9px, .68vw, 11px);
  font-weight: 400;
}

.gallery-nav-simple .gallery-back {
  justify-self: end;
}

@media (max-width: 1120px) {
  .gallery-nav-row.gallery-nav-simple {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 18px;
  }

  .gallery-nav-simple .gallery-logo {
    font-size: clamp(28px, 4vw, 38px);
    text-align: left;
  }
}

@media (max-width: 560px) {
  .gallery-header-inner {
    width: calc(100% - 20px);
    padding-top: max(7px, env(safe-area-inset-top));
    padding-bottom: 7px;
  }

  .gallery-nav-row.gallery-nav-simple {
    min-height: 44px;
    gap: 7px;
  }

  .gallery-nav-simple .gallery-logo {
    font-size: clamp(22px, 6.8vw, 28px);
    line-height: .95;
  }

  .gallery-nav-simple .gallery-date {
    font-size: .19em;
    margin-left: .08em;
    letter-spacing: .04em;
    vertical-align: .38em;
  }

  .gallery-current strong {
    font-size: clamp(9px, 2.7vw, 11px);
  }

  .gallery-current span {
    margin-top: 2px;
    font-size: clamp(7.5px, 2.2vw, 9px);
  }

  .gallery-nav-simple .gallery-back {
    min-height: 30px;
    padding: 3px 0;
    font-size: 9.5px;
  }

  .gallery-nav-simple .gallery-back::before {
    margin-right: 3px;
    font-size: 12px;
  }
}

@media (max-width: 390px) {
  .gallery-nav-row.gallery-nav-simple { gap: 4px; }
  .gallery-nav-simple .gallery-logo { font-size: 21px; }
  .gallery-current strong { font-size: 8.5px; }
  .gallery-current span { font-size: 7px; }
  .gallery-nav-simple .gallery-back { font-size: 8.5px; }
}

/* v8 — szybkie przełączanie Wesele / Plener w galerii fotografa */
.gallery-current-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 9px;
  white-space: nowrap;
}

.gallery-current .gallery-count {
  display: block;
  margin-top: 3px;
  color: #888;
  font-size: clamp(9px, .68vw, 11px);
  font-weight: 400;
}

.gallery-switch {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: clamp(9px, .68vw, 11px);
  font-weight: 400;
}

.gallery-switch i {
  color: #bbb;
  font-style: normal;
}

.gallery-switch a {
  position: relative;
  color: #999;
  text-decoration: none;
  transition: color .15s ease;
}

.gallery-switch a:hover,
.gallery-switch a:focus-visible,
.gallery-switch a.active {
  color: #222;
}

.gallery-switch a.active {
  font-weight: 600;
}

.gallery-switch a:focus-visible {
  outline: 1px solid #222;
  outline-offset: 3px;
  border-radius: 2px;
}

@media (max-width: 560px) {
  .gallery-current-line { gap: 4px; }
  .gallery-switch { gap: 3px; font-size: clamp(7px, 2vw, 8.5px); }
  .gallery-current .gallery-count { margin-top: 2px; font-size: clamp(7px, 2.1vw, 8.5px); }
}

@media (max-width: 390px) {
  .gallery-current-line { gap: 3px; }
  .gallery-switch { font-size: 6.8px; }
  .gallery-current .gallery-count { font-size: 6.8px; }
}

/* v10 — bardzo małe ekrany (np. iPhone 13 mini): mniejsze logo bez ruszania desktopu */
@media (max-width: 430px) {
  .gallery-header-inner {
    width: calc(100% - 12px);
  }

  .gallery-nav-row.gallery-nav-simple {
    gap: 3px;
  }

  .gallery-nav-simple .gallery-logo {
    font-size: clamp(16px, 4.6vw, 19px);
    line-height: 1;
  }

  .gallery-nav-simple .gallery-date {
    margin-left: 2px;
    font-size: 6px;
    letter-spacing: .02em;
    vertical-align: .45em;
  }

  .gallery-current strong {
    font-size: 8px;
  }

  .gallery-current-line {
    gap: 2px;
  }

  .gallery-switch {
    gap: 2px;
    font-size: 6.4px;
  }

  .gallery-current .gallery-count {
    font-size: 6.4px;
  }

  .gallery-nav-simple .gallery-back {
    font-size: 8px;
  }

  .gallery-nav-simple .gallery-back::before {
    margin-right: 2px;
    font-size: 11px;
  }
}

/* v11 — zoom zdjęcia: pinch, dwutap, kółko myszy i przesuwanie */
.lightbox-stage {
  cursor: zoom-in;
  overscroll-behavior: contain;
}

.lightbox-stage.is-zoomed {
  cursor: grab;
}

.lightbox-stage.is-zoomed:active {
  cursor: grabbing;
}

.lightbox-image.is-gesturing {
  transition: opacity .15s ease;
}

@media (hover: none) and (pointer: coarse) {
  .lightbox-stage,
  .lightbox-stage.is-zoomed {
    cursor: default;
  }
}

/* v13 — immersyjny podgląd zdjęć jak w galerii systemowej */
.lightbox {
  display: block;
  width: 100vw;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  background: #050505;
  overflow: hidden;
  overscroll-behavior: none;
}

.lightbox-backdrop {
  z-index: 0;
  background: #050505;
}

.lightbox-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

.lightbox-image {
  max-width: 100vw;
  max-height: 100vh;
  max-height: 100svh;
  max-height: 100dvh;
}

.lightbox-topbar {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  min-height: 68px;
  display: flex;
  padding:
    max(10px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    12px
    max(14px, env(safe-area-inset-left));
  background: linear-gradient(to bottom, rgba(0,0,0,.62), rgba(0,0,0,0));
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
}

.lightbox-actions {
  pointer-events: auto;
}

.lightbox-nav {
  position: absolute;
  z-index: 5;
  top: 50%;
  width: 58px;
  height: 82px;
  padding: 0;
  transform: translateY(-50%);
  border-radius: 999px;
  background: rgba(0,0,0,.12);
  color: rgba(255,255,255,.76);
  transition:
    opacity .22s ease,
    transform .22s ease,
    color .15s ease,
    background .15s ease;
}

.lightbox-prev {
  left: max(6px, env(safe-area-inset-left));
}

.lightbox-next {
  right: max(6px, env(safe-area-inset-right));
}

.lightbox.is-ui-hidden .lightbox-topbar {
  opacity: 0;
  transform: translateY(-12px);
  pointer-events: none;
}

.lightbox.is-ui-hidden .lightbox-actions {
  pointer-events: none;
}

.lightbox.is-ui-hidden .lightbox-nav {
  opacity: 0;
  pointer-events: none;
}

.lightbox-counter {
  text-shadow: 0 1px 8px rgba(0,0,0,.8);
}

@media (max-width: 560px) {
  .lightbox {
    display: block;
    grid-template-columns: none;
    grid-template-rows: none;
  }

  .lightbox-stage {
    grid-column: auto;
    grid-row: auto;
    padding:
      env(safe-area-inset-top)
      env(safe-area-inset-right)
      env(safe-area-inset-bottom)
      env(safe-area-inset-left);
  }

  .lightbox-image {
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100svh;
    max-height: 100dvh;
  }

  .lightbox-topbar {
    grid-column: auto;
    grid-row: auto;
  }

  .lightbox-nav {
    position: absolute;
    top: 50%;
    bottom: auto;
    width: 48px;
    height: 68px;
    background: rgba(0,0,0,.10);
    transform: translateY(-50%);
  }

  .lightbox-prev {
    left: max(2px, env(safe-area-inset-left));
  }

  .lightbox-next {
    right: max(2px, env(safe-area-inset-right));
  }

  .lightbox-download {
    padding: 7px 9px;
    font-size: 11px;
    background: rgba(0,0,0,.18);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  .lightbox-close {
    width: 40px;
    height: 40px;
    font-size: 32px;
  }
}

/* W poziomie zdjęcie dostaje praktycznie cały ekran — kontrolki są tylko nakładką. */
@media (orientation: landscape) and (max-height: 560px) {
  .lightbox-topbar {
    min-height: 48px;
    padding-top: max(4px, env(safe-area-inset-top));
    padding-bottom: 4px;
  }

  .lightbox-image {
    max-width: 100vw;
    max-height: 100dvh;
  }

  .lightbox-nav {
    width: 44px;
    height: 58px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox-topbar,
  .lightbox-nav {
    transition: none;
  }
}



/* v15 — partiowe doładowywanie bardzo dużych galerii */
.gallery-load-more {
  min-height: 72px;
  display: grid;
  place-items: center;
}

.gallery-load-more[hidden] {
  display: none;
}

.gallery-load-more span {
  width: 26px;
  height: 26px;
  border: 2px solid rgba(0,0,0,.10);
  border-top-color: rgba(0,0,0,.48);
  border-radius: 50%;
  animation: gallery-spin .8s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .gallery-load-more span {
    animation-duration: 1.6s;
  }
}
