/* Zakładka Historia: oś czasu z animacjami. Telefon najpierw, na komputerze oś przechodzi na środek. */
:root {
  --kat-wies: #3f5f7f; --kat-parafia: #7a3b46; --kat-dwor: #8a6a2f;
  --kat-szkola: #2e7d3a; --kat-straz: #b3321f; --kat-wojna: #4b4f55;
}

.hist-hero { margin: 4px 0 16px; padding: 24px 20px 18px; color: #fff; border-radius: var(--radius); background: linear-gradient(135deg, rgba(18, 58, 31, .97), rgba(27, 77, 43, .93)), url("tlo-strony.jpg") center / cover; box-shadow: var(--cien-wysoki); border-bottom: 3px solid var(--zloto); }
.hist-hero h1 { margin: 0 0 8px; color: #fff; }
.hist-hero > p { max-width: 64ch; margin: 0 0 16px; color: rgba(255, 255, 255, .9); }
.hist-liczby { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 0; }
.hist-liczby > div { padding: 9px 12px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .16); border-radius: var(--radius); }
.hist-liczby dt { font-size: 1.75rem; font-weight: 900; line-height: 1.1; color: var(--zloto2); font-variant-numeric: tabular-nums; }
.hist-liczby dd { margin: 2px 0 0; font-size: .8rem; color: rgba(255, 255, 255, .82); }

.hist-filtry { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.hist-filtry::-webkit-scrollbar { display: none; }
.hist-filtry button { flex: none; display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 13px; border: 1px solid var(--linia2); border-radius: var(--radius); background: #fff; color: var(--zielen-ciemna); font: inherit; font-size: .88rem; font-weight: 700; cursor: pointer; box-shadow: 0 1px 1px rgba(20, 50, 15, .06); transition: background var(--ruch), border-color var(--ruch), color var(--ruch), box-shadow var(--ruch); }
.hist-filtry button span { padding: 0 6px; border-radius: var(--radius); background: rgba(27, 77, 43, .12); font-size: .75rem; line-height: 18px; }
.hist-filtry button:hover { background: var(--zielen-jasna); border-color: var(--zielen); }
.hist-filtry button.aktywny { background: var(--zielen-ciemna); border-color: var(--zielen-ciemna); color: #fff; box-shadow: 0 2px 6px rgba(27, 77, 43, .3); }
.hist-filtry button.aktywny span { background: rgba(255, 255, 255, .22); }
.hist-filtry button:focus-visible, .hist-ery button:focus-visible { outline: 2px solid var(--zloto2); outline-offset: 2px; }

/* Pasek epok przykleja się pod menu; cienka linia na dole pokazuje postęp przewijania osi */
.hist-ery { position: sticky; top: var(--nav-wys, 0px); z-index: 15; display: flex; gap: 2px; overflow-x: auto; margin: 0 0 6px; padding: 0 0 3px; background: rgba(241, 245, 234, .96); backdrop-filter: blur(6px); border-bottom: 1px solid var(--linia); scrollbar-width: none; }
.hist-ery::-webkit-scrollbar { display: none; }
.hist-ery::after { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: calc(var(--postep, 0) * 100%); background: linear-gradient(90deg, var(--zielen), var(--zloto)); transition: width .15s linear; }
.hist-ery button { flex: none; position: relative; min-height: 42px; padding: 0 14px; border: 0; background: none; color: var(--tekst2); font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer; transition: color var(--ruch), background var(--ruch); }
.hist-ery button::before { content: ""; position: absolute; left: 14px; right: 14px; bottom: 2px; height: 2px; background: var(--zloto); transform: scaleX(0); transform-origin: left; transition: transform var(--ruch); }
.hist-ery button:hover { color: var(--zielen-ciemna); background: rgba(46, 125, 58, .08); }
.hist-ery button.aktywna { color: var(--zielen-ciemna); }
.hist-ery button.aktywna::before { transform: scaleX(1); }
.hist-ery button:disabled { opacity: .35; cursor: default; background: none; }

/* Oś czasu */
.hist-os { --postep: 0; position: relative; list-style: none; margin: 18px 0 30px; padding: 0 0 0 30px; }
.hist-os::before, .hist-os::after { content: ""; position: absolute; left: 8px; top: 0; width: 2px; }
.hist-os::before { bottom: 0; background: var(--linia2); }
.hist-os::after { height: calc(var(--postep) * 100%); background: linear-gradient(var(--zielen), var(--zloto)); transition: height .12s linear; }
.hist-wpis { position: relative; margin: 0 0 18px; scroll-margin-top: calc(var(--nav-wys, 0px) + 70px); }
.hist-link { color: inherit; text-decoration: none; }
.hist-link:hover .hist-rok { text-decoration: underline; }
.hist-wpis.ukryty { display: none; }
.hist-wezel { position: absolute; left: -30px; top: 19px; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--linia2); transition: border-color .35s, background .35s, transform .35s, box-shadow .35s; }
.hist-wpis.widoczna .hist-wezel { border-color: var(--zielen); }
.hist-wpis.biezaca .hist-wezel { background: var(--zloto); border-color: var(--zloto-ciemne); transform: scale(1.2); box-shadow: 0 0 0 6px rgba(216, 155, 20, .2); }

.hist-karta { padding: 14px 16px 12px; background: rgba(255, 255, 255, .88); border: 1px solid var(--linia); border-left: 4px solid var(--linia2); border-radius: var(--radius); box-shadow: var(--cien); transition: opacity .55s ease, transform .55s ease, box-shadow var(--ruch), border-left-color .35s; }
.hist-wpis.biezaca .hist-karta { box-shadow: var(--cien-wysoki); border-left-color: var(--zloto); }
/* Animacja wejścia tylko wtedy, gdy działa skrypt; bez niego wszystko jest od razu widoczne */
.hist-os.z-js .hist-karta { opacity: 0; transform: translateY(20px); }
.hist-os.z-js .hist-wpis.widoczna .hist-karta { opacity: 1; transform: none; }

.hist-karta header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 2px; }
.hist-rok { font-size: 1.3rem; font-weight: 900; letter-spacing: -.01em; color: var(--zielen-ciemna); }
.hist-kat { padding: 1px 8px; border-radius: var(--radius); color: #fff; font-size: .68rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.kat-wies { background: var(--kat-wies); } .kat-parafia { background: var(--kat-parafia); } .kat-dwor { background: var(--kat-dwor); }
.kat-szkola { background: var(--kat-szkola); } .kat-straz { background: var(--kat-straz); } .kat-wojna { background: var(--kat-wojna); }
.hist-karta h2 { margin: 2px 0 6px; font-size: 1.1rem; line-height: 1.3; text-transform: none; }
.hist-karta p { margin: 0 0 8px; }
.hist-foto { margin: 10px 0; }
.hist-foto a { display: block; overflow: hidden; border-radius: var(--radius); }
.hist-foto img { display: block; width: 100%; max-height: 360px; object-fit: cover; object-position: center 35%; transition: transform .6s ease; }
.hist-foto a:hover img { transform: scale(1.04); }
.hist-foto figcaption { margin-top: 4px; font-size: .75rem; line-height: 1.35; color: var(--tekst2); }
.hist-wiecej { margin: 0 0 8px; }
.hist-wiecej summary { cursor: pointer; color: var(--zielen-ciemna); font-size: .9rem; font-weight: 700; }
.hist-wiecej p { margin: 6px 0 0; padding-left: 10px; border-left: 2px solid var(--linia2); font-size: .94rem; }
.hist-zrodla { margin: 8px 0 0 !important; padding-top: 6px; border-top: 1px solid var(--linia); font-size: .76rem; line-height: 1.45; color: var(--tekst2); }
.hist-zrodla span { font-weight: 900; letter-spacing: .05em; text-transform: uppercase; }
.hist-zrodla a { color: var(--tekst2); }
.hist-zrodla a:hover { color: var(--zielen-ciemna); }

.hist-uwagi { max-width: 760px; margin: 10px 0 20px; padding: 16px 18px; background: #fff; border: 1px solid var(--linia); border-top: 3px solid var(--zielen-ciemna); border-radius: var(--radius); box-shadow: var(--cien); }
.hist-uwagi h2 { margin: 0 0 6px; font-size: 1.1rem; }
.hist-uwagi h3 { margin: 12px 0 4px; font-size: 1rem; }
.hist-uwagi p { margin: 0 0 8px; font-size: .94rem; }

@media (min-width: 700px) {
  .hist-liczby { grid-template-columns: repeat(4, 1fr); }
  .hist-hero { padding: 30px 30px 24px; }
}

/* Komputer: oś na środku, wpisy po przemian z lewej i z prawej (strony przydziela skrypt) */
@media (min-width: 900px) {
  .hist-os { max-width: 1060px; margin-inline: auto; padding: 0; }
  .hist-os::before, .hist-os::after { left: 50%; margin-left: -1px; }
  .hist-wpis { width: 50%; padding-right: 38px; }
  .hist-wpis[data-strona="p"] { margin-left: 50%; padding-right: 0; padding-left: 38px; }
  .hist-wezel { left: auto; right: -9px; }
  .hist-wpis[data-strona="p"] .hist-wezel { right: auto; left: -9px; }
  .hist-os.z-js .hist-wpis .hist-karta { transform: translate(-26px, 14px); }
  .hist-os.z-js .hist-wpis[data-strona="p"] .hist-karta { transform: translate(26px, 14px); }
  .hist-os.z-js .hist-wpis.widoczna .hist-karta { transform: none; }
  .hist-uwagi { margin-inline: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .hist-os.z-js .hist-karta { opacity: 1; transform: none; }
  .hist-foto a:hover img { transform: none; }
}

/* Wkłady mieszkańców */
.hist-od { padding: 1px 8px; border: 1px solid var(--zloto); border-radius: var(--radius); color: var(--zloto-ciemne); font-size: .68rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.hist-cta { margin-top: 16px; }
.wklad-adm { margin: 0 0 22px; }
.wklad-adm .formularz { margin-bottom: 8px; }
.wklad-adm .zdjecia-edycja { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.wklad-adm .zdjecia-edycja img { display: block; max-width: 160px; max-height: 120px; border-radius: var(--radius); border: 1px solid var(--linia); }

/* Tła epok: zdjęcia z epoki, które żyją. Kamera najeżdża na zdjęcie (animacje poniżej), a cała scena sunie i „oddycha” razem
   z przewijaniem (zmienne --px, --py, --sk ustawia historia-tla.js). Warstwa przyklejona do okna, pod kartami.
   Zapas na brzegach (inset -4% i skala sceny od 1,06) jest większy niż suma ruchów, więc nigdy nie widać krawędzi zdjęcia. */
.hist-tlo { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: #e9eadb; }
.hist-scena { position: absolute; inset: 0; opacity: 0; transition: opacity 1.8s ease; transform: translate3d(calc(var(--px, 0) * 1vw), calc(var(--py, 0) * 1vh), 0) scale(var(--sk, 1.1)); will-change: transform, opacity; }
.hist-scena.aktywna { opacity: 1; }
.hist-zdj { position: absolute; inset: -4%; background-position: center; background-size: cover; opacity: 0; transition: opacity 1.8s ease; will-change: transform, opacity; }
.hist-zdj.biezace { opacity: 1; }
.hist-zdj.ruch0 { animation: tlo-najazd0 30s ease-in-out infinite alternate; }
.hist-zdj.ruch1 { animation: tlo-najazd1 36s ease-in-out infinite alternate; }
.hist-zdj.ruch2 { animation: tlo-najazd2 33s ease-in-out infinite alternate; }
@keyframes tlo-najazd0 { from { transform: scale(1.06) translate(0, 0); } to { transform: scale(1.18) translate(-2.6%, -1.5%); } }
@keyframes tlo-najazd1 { from { transform: scale(1.16) translate(2.2%, 1.2%); } to { transform: scale(1.06) translate(-1.2%, 0); } }
@keyframes tlo-najazd2 { from { transform: scale(1.07) translate(-2.2%, 1.5%); } to { transform: scale(1.18) translate(2.2%, -1.2%); } }
.hist-scena:not(.aktywna) .hist-zdj { animation-play-state: paused; }
/* Nakładka ujednolica kolory i zapewnia czytelność tekstu poza kartami; korekcja barw zależy od epoki */
.hist-scena::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(243, 240, 228, .14), rgba(243, 240, 228, .3)); }
.hist-scena[data-era="dawne"] .hist-zdj, .hist-scena[data-era="xix"] .hist-zdj { filter: sepia(.75) contrast(1.04); }
.hist-scena[data-era="miedzy"] .hist-zdj { filter: sepia(.4) contrast(1.05); }
.hist-scena[data-era="wojna"] .hist-zdj { filter: grayscale(1) contrast(1.18) brightness(.8); }
.hist-scena[data-era="wojna"]::after { background: radial-gradient(ellipse at center, rgba(18, 20, 22, .2), rgba(8, 10, 12, .66)); }
.hist-scena[data-era="po"] .hist-zdj { filter: saturate(.85) sepia(.15); }
.hist-tlo-podpis { position: fixed; left: 8px; bottom: 6px; z-index: 6; max-width: min(640px, calc(100% - 16px)); margin: 0; padding: 2px 8px; border-radius: var(--radius); background: rgba(255, 255, 255, .82); color: var(--tekst2); font-size: .66rem; line-height: 1.35; }
.hist-tlo-podpis:empty { display: none; }
.hist-tlo-podpis[hidden] { display: none; }
.hist-tlo-podpis a { color: inherit; }

.hist-pasek { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px 12px; margin: 2px 0 6px; }
.hist-tlo-przelacznik { min-height: 32px; padding: 0 12px; border: 1px solid var(--linia2); border-radius: var(--radius); background: rgba(255, 255, 255, .9); color: var(--zielen-ciemna); font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer; transition: background var(--ruch), border-color var(--ruch); }
.hist-tlo-przelacznik:hover { background: var(--zielen-jasna); border-color: var(--zielen); }

@media (prefers-reduced-motion: reduce) {
  .hist-scena, .hist-zdj { transition: none; }
  .hist-zdj { animation: none !important; }
}

/* Wąski ekran (telefon, tablet pionowo): karty zasłaniają tło prawie w całości, więc go nie pokazujemy (skrypt nie pobiera wtedy zdjęć) */
@media (max-width: 899px) {
  .hist-tlo, .hist-tlo-podpis, .hist-pasek { display: none; }
}
