/* BIP WSKS – arkusz stylów
   Kolory spełniają WCAG 2.1 AA (kontrast tekstu min. 4.5:1). */

:root {
  --bg: #ffffff;
  --bg-alt: #f3f5f9;
  --text: #1a1a1a;
  --muted: #4a4f5c;
  --primary: #222d5b;      /* granat z logo WSKS */
  --primary-text: #ffffff;
  --accent: #b0101f;       /* czerwień BIP, przyciemniona dla kontrastu */
  --link: #1f3f8f;
  --link-visited: #5a2a82;
  --border: #c5cad6;
  --focus: #ffbf47;
  --focus-ring: #1a1a1a;
  --table-head: #e4e8f1;
  --radius: 4px;
  --maxw: 72rem;
}

/* ---------- Tryby kontrastu ---------- */
html[data-contrast="yb"] {          /* żółty na czarnym */
  --bg: #000; --bg-alt: #000; --text: #ffff00; --muted: #ffff00;
  --primary: #000; --primary-text: #ffff00; --accent: #ffff00;
  --link: #ffff00; --link-visited: #ffff00; --border: #ffff00;
  --focus: #ffffff; --focus-ring: #000; --table-head: #000;
}
html[data-contrast="by"] {          /* czarny na żółtym */
  --bg: #ffff00; --bg-alt: #ffff00; --text: #000; --muted: #000;
  --primary: #ffff00; --primary-text: #000; --accent: #000;
  --link: #000; --link-visited: #000; --border: #000;
  --focus: #000; --focus-ring: #ffff00; --table-head: #ffff00;
}
html[data-contrast="wb"] {          /* biały na czarnym */
  --bg: #000; --bg-alt: #000; --text: #fff; --muted: #fff;
  --primary: #000; --primary-text: #fff; --accent: #fff;
  --link: #fff; --link-visited: #fff; --border: #fff;
  --focus: #ffff00; --focus-ring: #000; --table-head: #000;
}
html[data-contrast="bw"] {          /* czarny na białym */
  --bg: #fff; --bg-alt: #fff; --text: #000; --muted: #000;
  --primary: #fff; --primary-text: #000; --accent: #000;
  --link: #000; --link-visited: #000; --border: #000;
  --focus: #000; --focus-ring: #fff; --table-head: #fff;
}
html[data-contrast] a { text-decoration: underline; }
html[data-contrast] .logo-box { background: #fff; outline: 2px solid var(--border); }
html[data-contrast] .main-nav a,
html[data-contrast] .a11y-bar,
html[data-contrast] .site-footer { border-color: var(--border); }

/* ---------- Wielkość tekstu ---------- */
html { font-size: 100%; }
html[data-font="1"] { font-size: 125%; }
html[data-font="2"] { font-size: 150%; }

/* ---------- Odstępy (WCAG 1.4.12) ---------- */
html[data-spacing="1"] body { line-height: 1.8 !important; letter-spacing: .12em !important; word-spacing: .16em !important; }
html[data-spacing="1"] p { margin-bottom: 2em !important; }

/* ---------- Podstawy ---------- */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}
img { max-width: 100%; height: auto; }
a { color: var(--link); text-underline-offset: .15em; }
a:visited { color: var(--link-visited); }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { line-height: 1.25; color: var(--text); }
h1 { font-size: 1.85rem; margin: .25rem 0 1.25rem; }
h2 { font-size: 1.35rem; margin: 2rem 0 .75rem; }
h3 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--focus-ring);
}

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 1rem; }

/* ---------- Link „przejdź do treści” ---------- */
.skip-links a {
  position: absolute; left: 1rem; top: -10rem; z-index: 100;
  background: var(--primary); color: var(--primary-text);
  padding: .75rem 1rem; font-weight: 700; border: 2px solid var(--focus);
}
.skip-links a:focus { top: .5rem; }

/* ---------- Panel dostępności ---------- */
.a11y-bar { background: var(--bg-alt); border-bottom: 1px solid var(--border); font-size: .9rem; }
.a11y-bar .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; padding-top: .4rem; padding-bottom: .4rem; }
.a11y-group { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.a11y-group > span { font-weight: 600; margin-right: .25rem; }
.a11y-bar button {
  font: inherit; cursor: pointer; min-width: 2.75rem; min-height: 2.75rem;
  padding: .25rem .6rem; border: 2px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font-weight: 700;
}
.a11y-bar button[aria-pressed="true"] { border-color: var(--text); box-shadow: inset 0 0 0 2px var(--text); }
.a11y-bar button.c-yb { background: #000; color: #ff0; border-color: #000; }
.a11y-bar button.c-by { background: #ff0; color: #000; border-color: #000; }
.a11y-bar button.c-wb { background: #000; color: #fff; border-color: #000; }
.a11y-bar button.c-bw { background: #fff; color: #000; border-color: #000; }
.a11y-bar button.f1 { font-size: 1.1em; }
.a11y-bar button.f2 { font-size: 1.25em; }
.a11y-panel { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; }
.a11y-panel[hidden] { display: none; }
.a11y-toggle { margin-left: auto; }
.no-js .a11y-bar { display: none; }

/* ---------- Nagłówek ---------- */
.site-header { border-bottom: 4px solid var(--accent); background: var(--bg); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 2rem; padding-top: 1rem; padding-bottom: 1rem; }
.logo-box { display: inline-block; line-height: 0; padding: 4px; border-radius: var(--radius); }
.logo-bip img { width: 150px; }
.logo-wsks img { width: 206px; }
.site-title { flex: 1 1 16rem; margin: 0; font-size: 1.15rem; font-weight: 700; color: var(--primary); line-height: 1.3; }
html[data-contrast] .site-title { color: var(--text); }
.site-title small { display: block; font-weight: 400; color: var(--muted); font-size: .95rem; }

.search-form { display: flex; gap: .25rem; flex: 0 1 20rem; min-width: 0; max-width: 100%; }
.search-form label { position: absolute; left: -9999px; }
.search-form input[type="search"] {
  flex: 1; min-width: 0; width: 100%; font: inherit; padding: .55rem .7rem; min-height: 2.75rem;
  border: 2px solid var(--muted); border-radius: var(--radius); background: var(--bg); color: var(--text);
}
.btn {
  font: inherit; font-weight: 700; cursor: pointer; min-height: 2.75rem;
  padding: .5rem 1rem; border-radius: var(--radius);
  background: var(--primary); color: var(--primary-text); border: 2px solid var(--primary);
}
html[data-contrast] .btn { border-color: var(--border); }
.btn:hover { text-decoration: underline; }

/* ---------- Menu główne ---------- */
.main-nav { background: var(--primary); }
.main-nav .wrap { position: relative; }
.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; }
.main-nav a {
  display: block; padding: .8rem 1rem; color: var(--primary-text); text-decoration: none; font-weight: 600;
  border-bottom: 3px solid transparent;
}
.main-nav a:hover, .main-nav a[aria-current="page"] { border-bottom-color: var(--primary-text); text-decoration: underline; }
.nav-toggle { display: none; }

/* ---------- Układ ---------- */
.layout { display: grid; grid-template-columns: 17rem 1fr; gap: 2rem; padding-top: 1.5rem; padding-bottom: 2.5rem; }
.sidebar { order: 0; }
.content { order: 1; min-width: 0; }

.side-box { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1.25rem; background: var(--bg); }
.side-box h2 { margin: 0; padding: .6rem .9rem; font-size: 1rem; background: var(--primary); color: var(--primary-text); border-radius: var(--radius) var(--radius) 0 0; }
html[data-contrast] .side-box h2 { border-bottom: 1px solid var(--border); }
.side-box ul { list-style: none; margin: 0; padding: .35rem 0; }
.side-box li a { display: block; padding: .45rem .9rem; text-decoration: none; }
.side-box li a:hover { text-decoration: underline; background: var(--bg-alt); }
.side-box li a[aria-current="page"] { font-weight: 700; border-left: 4px solid var(--accent); padding-left: calc(.9rem - 4px); }
.side-box address { font-style: normal; padding: .75rem .9rem; }

/* ---------- Okruszki ---------- */
.breadcrumb ol { list-style: none; margin: 0 0 .75rem; padding: 0; display: flex; flex-wrap: wrap; font-size: .95rem; color: var(--muted); }
.breadcrumb li + li::before { content: "›"; padding: 0 .5rem; color: var(--muted); }
.breadcrumb .label { margin-right: .4rem; }

/* ---------- Tabele ---------- */
.table-wrap { overflow-x: auto; margin: 0 0 1.5rem; }
table { border-collapse: collapse; width: 100%; background: var(--bg); }
caption { text-align: left; font-weight: 700; font-size: 1.1rem; padding: 0 0 .5rem; }
th, td { border: 1px solid var(--border); padding: .55rem .75rem; text-align: left; vertical-align: top; }
thead th { background: var(--table-head); }
tbody th { font-weight: 600; background: var(--bg-alt); width: 40%; }
table.docs tbody th { width: auto; background: transparent; font-weight: 400; }
td.action { white-space: nowrap; width: 1%; }
.file-type { font-size: .85em; color: var(--muted); }

/* ---------- Metryczka ---------- */
.meta { margin-top: 2.5rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-alt); padding: 0 1rem 1rem; font-size: .95rem; }
.meta h2 { font-size: 1.1rem; margin: 1rem 0 .5rem; }
.meta dl { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0; }
.meta dt { font-weight: 600; }
.meta dd { margin: 0; }
.meta table { font-size: .95rem; }
.page-tools { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.page-tools[hidden] { display: none; }

.notice { border-left: 5px solid var(--accent); background: var(--bg-alt); padding: .75rem 1rem; margin: 1rem 0; }

/* ---------- Wyszukiwarka ---------- */
.search-page form { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.search-page label { display: block; font-weight: 600; width: 100%; }
.search-page input[type="search"] { flex: 1 1 18rem; font: inherit; padding: .55rem .7rem; min-height: 2.75rem; border: 2px solid var(--muted); border-radius: var(--radius); background: var(--bg); color: var(--text); }
.results { list-style: none; padding: 0; }
.results li { border-bottom: 1px solid var(--border); padding: .75rem 0; }
.results a { font-weight: 700; font-size: 1.1rem; }
.results p { margin: .25rem 0 0; color: var(--muted); }
mark { background: #ffe066; color: #000; }

/* ---------- Stopka ---------- */
.site-footer { background: var(--primary); color: var(--primary-text); border-top: 4px solid var(--accent); }
.site-footer a { color: var(--primary-text); }
.site-footer .wrap { display: grid; grid-template-columns: 1fr 1fr auto; gap: 1.5rem 2rem; padding-top: 1.75rem; padding-bottom: 1.75rem; }
.site-footer h2 { color: var(--primary-text); font-size: 1rem; margin: 0 0 .5rem; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin: .2rem 0; }
.site-footer address { font-style: normal; }
.footer-logos { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.footer-logos .logo-box { background: #fff; }
.footer-logos .logo-bip img { width: 110px; }
.footer-logos .logo-wsks img { width: 160px; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.35); }
.footer-bottom .wrap { display: block; padding-top: .75rem; padding-bottom: .75rem; font-size: .9rem; }

/* ---------- Responsywność (WCAG 1.4.10) ---------- */
@media (max-width: 52rem) {
  .layout { grid-template-columns: 1fr; }
  .content { order: 0; }
  .sidebar { order: 1; }
  .site-footer .wrap { grid-template-columns: 1fr; }
  .js .nav-toggle {
    display: inline-flex; align-items: center; gap: .5rem; margin: .5rem 0;
    font: inherit; font-weight: 700; color: var(--primary-text); background: transparent;
    border: 2px solid var(--primary-text); border-radius: var(--radius); padding: .5rem .9rem; min-height: 2.75rem; cursor: pointer;
  }
  .js .main-nav ul[data-collapsed="true"] { display: none; }
  .main-nav ul { flex-direction: column; padding-bottom: .5rem; }
  .meta dl { grid-template-columns: 1fr; }
  .meta dd { margin-bottom: .5rem; }
  .search-form { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Druk ---------- */
@media print {
  .skip-links, .a11y-bar, .main-nav, .sidebar, .search-form, .page-tools, .site-footer .footer-nav, .nav-toggle { display: none !important; }
  body { color: #000; background: #fff; font-size: 11pt; }
  .layout { display: block; padding: 0; }
  .site-header { border-bottom: 2px solid #000; }
  a { color: #000; }
  .content a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .85em; word-break: break-all; }
  .site-footer { background: #fff; color: #000; border-top: 2px solid #000; }
  .site-footer a { color: #000; }
  th, td { border-color: #000; }
}

/* Przyciski kontrastu widoczne w każdym trybie */
.a11y-bar button.c-yb, .a11y-bar button.c-by, .a11y-bar button.c-wb, .a11y-bar button.c-bw { border-color: #767676; }
.a11y-bar button.c-yb[aria-pressed="true"], .a11y-bar button.c-by[aria-pressed="true"],
.a11y-bar button.c-wb[aria-pressed="true"], .a11y-bar button.c-bw[aria-pressed="true"] { outline: 3px solid var(--text); outline-offset: 1px; }
