/* styles.css — galeria + kafelki (oczyszczona wersja) */

/* --- zmienne i reset --- */
:root{
  --bg: #f5f7fa;
  --panel: #ffffff;
  --muted: #6b7280;
  --accent: #1f2937;
  --gap: 20px;
  --radius: 12px;
  --card-shadow: 0 6px 20px rgba(18, 23, 33, 0.06);
  --thumb-height: 260px; /* zmień jedną wartość, żeby ustawić rozmiar */
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  background: var(--bg);
  color:var(--accent);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  line-height:1.4;
}

/* Header/top basic (header.css zawiera główne reguły nagłówka) */
.top{ padding:0; }
.container{ max-width:1200px; margin:0 auto; }

/* Grid wrapper */
main{ padding:18px 10px 60px; }
.cards-wrap{ padding: 6px 12px 30px; box-sizing:border-box; }

/* RESPONSYWNA SIATKA: auto-fit + minmax */
.grid {
  display: grid;
  gap: var(--gap);
  padding: 18px 24px 24px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  width: 100%;
  box-sizing: border-box;
  max-width: 1400px;
  margin: 0 auto;
  min-width: 0;
  justify-items: stretch;
}

/* ===== KAFELKI (figure.thumb) ===== */
.thumb{
  background: var(--panel);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  position: relative;
  transform: translateZ(0);
  transition: transform .22s ease, box-shadow .22s ease;
  display: block;
  width: 100%;      /* pozwól gridowi kontrolować szerokość */
  margin: 0;
}

/* hover effect */
.thumb:hover{
  transform: translateY(-6px);
  box-shadow: 0 18px 40px rgba(18,23,33,0.09);
}

/* CAŁY KAFEL jako link: obraz + caption razem */
.thumb .thumb-link{
  display:flex;
  flex-direction:column;
  height:100%;
  width:100%;
  text-decoration:none;
  color:inherit;
  -webkit-tap-highlight-color: transparent;
}

/* imgwrap: stała wysokość (wyrównuje wszystkie miniatury) */
.thumb .imgwrap{
  width:100%;
  height: var(--thumb-height);
  overflow:hidden;
  display:block;
  background: linear-gradient(180deg,#eee,#ddd);
  flex: 0 0 auto;
}

/* obraz wypełnia cały kontener i jest cropowany */
.thumb .imgwrap img{
  width:100%;
  height:100%;
  object-fit: cover;
  object-position: center;
  display:block;
  transition: transform .28s ease;
  border-radius: 0;
}

/* delikatna animacja na hover */
.thumb .thumb-link:hover .imgwrap img{ transform: scale(1.02); }

/* FIGCAPTION: tekst pod obrazkiem — pozwalamy na wielowierszowość */
.thumb figcaption.caption{
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
  text-align: left;
  background: transparent;
  white-space: normal;
  overflow: visible;
}

/* tytuł w caption (wyraźny) */
.thumb figcaption.caption .title,
.thumb figcaption.caption strong{
  display:block;
  color: #2b2b2b;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 15px;
  text-decoration: none;
}

/* treść opisu: ładne łamanie */
.thumb .caption-text{
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  color: var(--muted);
  hyphens: auto;
  word-break: normal;
}

/* usuń podkreślenia wewnątrz kafelka (dziedziczenie) */
.thumb .thumb-link,
.thumb .thumb-link *{
  text-decoration: none !important;
  color: inherit !important;
}

/* lekkie ograniczenia dla wąskich ekranów */
@media (max-width: 900px){
  :root { --thumb-height: 180px; }
  .grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
  .thumb { max-width: 360px; }
  .thumb figcaption.caption { padding: 10px 12px; font-size: 13px; }
}

@media (max-width: 520px){
  :root { --thumb-height: 140px; }
  .grid { padding-left: 12px; padding-right: 12px; gap: 12px; }
  .thumb { max-width: 100%; }
  .thumb figcaption.caption { padding: 10px; font-size: 13px; }
}

/* ===== lightbox (jeśli używasz) ===== */
.lightbox{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.78);
  z-index:9999;
  padding:30px;
  gap:12px;
}
.lightbox.hidden{ display:none; }
.lb-inner{ max-width:95%; max-height:90%; text-align:center; position:relative; }
.lb-inner img{ max-width:100%; max-height:80vh; border-radius:8px; box-shadow: 0 18px 60px rgba(0,0,0,0.6); display:block; margin:0 auto; }
.lb-caption{ margin-top:12px; color:#fff; font-size:15px; line-height:1.3; max-width:90%; margin-left:auto; margin-right:auto; }
.lb-btn{ position:absolute; top:50%; transform:translateY(-50%); background: rgba(255,255,255,0.06); border:0; color:#fff; width:44px; height:44px; border-radius:999px; display:flex; align-items:center; justify-content:center; cursor:pointer; font-size:20px; box-shadow: 0 6px 20px rgba(0,0,0,0.4); }
.lb-prev{ left:20px; } .lb-next{ right:20px; }
.lb-close{ position:fixed; top:18px; right:18px; background:transparent; border:0; color:#fff; font-size:28px; cursor:pointer; }

/* drobne responsywne poprawki */
@media (max-width:720px){
  .grid{ grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap:10px; }
  .lb-btn{ width:40px; height:40px; font-size:18px; }
}

/* === FORCE MOBILE: 1 column on narrow screens ===
   Wklej to NA KOŃCU styles.css (po wszystkich innych regułach). */

@media (max-width: 700px) {
  .grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    max-width: 100% !important;
  }

  .thumb {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  /* mobilna wysokość miniatury */
  :root { --thumb-height: 140px; }
  .thumb .imgwrap { height: var(--thumb-height) !important; }

  .thumb figcaption.caption {
    padding: 10px 12px !important;
    font-size: 13px !important;
  }
}

/* ==== Focus / accessibility: outline przy nawigacji klawiszami ==== */
.thumb .thumb-link:focus-visible {
  outline: 3px solid rgba(90,144,255,0.20);
  outline-offset: 4px;
  border-radius: 12px;
}
.thumb .thumb-link:focus {
  outline: 3px dashed rgba(90,144,255,0.18);
  outline-offset: 3px;
}

/* powiększ obszar dotykowy */
.thumb .thumb-link {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 0;
}

/* opcjonalnie: podkreślenie tytułu gdy focus (ułatwia orientację) */
.thumb .thumb-link:focus .title,
.thumb .thumb-link:focus .caption-text {
  text-decoration: underline;
}
