/**
 * WCAG 2.14 - skip link, focus, kontrast, reduced motion
 */

:root {
  --kpks-a11y-btn-size: 52px;
  --kpks-a11y-btn-gutter: 1rem;
  --kpks-a11y-clearance: calc(var(--kpks-a11y-btn-size) + var(--kpks-a11y-btn-gutter) + 0.35rem);
}

body {
  position: relative;
}

/* ===== Skip link ===== */
.kpks-skip-link {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100000;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  background: var(--kpks-navy, #031047);
  color: #fff;
  font-family: "Inter", sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(3, 16, 71, 0.28);
  transform: translateY(-160%);
  transition: transform 0.2s ease;
}

.kpks-skip-link:focus,
.kpks-skip-link:focus-visible {
  transform: translateY(0);
  outline: 3px solid var(--kpks-secondary, #ffd000);
  outline-offset: 2px;
}

#main-content:focus {
  outline: none;
}

#main-content:focus-visible {
  outline: 3px solid var(--kpks-primary, #008bd2);
  outline-offset: 4px;
}

/* ===== Screen reader only (nowoczesny wzorzec) ===== */
.kpks-sr-only,
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ===== Globalny focus widoczny ===== */
:where(
  a,
  button,
  input,
  select,
  textarea,
  summary,
  [tabindex]:not([tabindex="-1"])
):focus {
  outline: none;
}

:where(
  a,
  button,
  input,
  select,
  textarea,
  summary,
  [tabindex]:not([tabindex="-1"])
):focus-visible {
  outline: 3px solid var(--kpks-primary, #008bd2);
  outline-offset: 2px;
}

.navbar-nav .nav-link:focus-visible,
.kpks-mega-toggle:focus-visible,
.kpks-mega-link:focus-visible,
.kpks-brand:focus-visible,
.kpks-breadcrumbs-item a:focus-visible,
.kpks-header-contact-item:focus-visible,
.kpks-mobile-menu-btn:focus-visible,
.news-card-title a:focus-visible,
.news-card-link:focus-visible,
.news-card .btn:focus-visible,
.section-card-link:focus-visible,
.contact-method:focus-visible,
.contact-details a:focus-visible,
.footer-showcase-info-link:focus-visible,
.footer-showcase-section-pill:focus-visible,
.grants-logo-link:focus-visible,
.about-gallery-lightbox-close:focus-visible,
.about-gallery-lightbox-nav:focus-visible {
  outline: 3px solid var(--kpks-secondary, #ffd000);
  outline-offset: 2px;
  box-shadow: 0 0 0 1px var(--kpks-navy, #031047);
}

.kpks-social-link:focus-visible,
.kpks-social-group-toggle:focus-visible {
  outline: 3px solid var(--kpks-secondary, #ffd000);
  outline-offset: 2px;
}

/* ===== Kontrast linków w treści ===== */
.entry-content a,
.kpks-entry-content a,
.inner-page-content a:not(.btn):not(.kpks-social-link):not(.contact-method) {
  color: #006da3;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.15em;
}

.entry-content a:hover,
.kpks-entry-content a:hover {
  color: var(--kpks-navy, #031047);
}

/* ===== Breadcrumbs - bieżąca strona ===== */
.kpks-breadcrumbs-item.is-current span[aria-current="page"] {
  color: var(--kpks-navy, #031047);
  font-weight: 700;
}

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

  .kpks-skip-link {
    transition: none;
  }

  .fade-in-up {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ==========================================================================
   Ustawienia użytkownika - panel dostępności
   ========================================================================== */

html[data-kpks-a11y-font="0"] {
  font-size: 100%;
}

html[data-kpks-a11y-font="1"] {
  font-size: 112.5%;
}

html[data-kpks-a11y-font="2"] {
  font-size: 125%;
}

html[data-kpks-a11y-font="3"] {
  font-size: 140%;
}

html.kpks-a11y-readable body {
  font-family: Arial, Helvetica, sans-serif !important;
}

html.kpks-a11y-readable :where(
  h1,
  h2,
  h3,
  h4,
  h5,
  h6,
  .inner-hero-title,
  .page-hero-title,
  .section-heading,
  .news-card-title
) {
  font-family: Arial, Helvetica, sans-serif !important;
  letter-spacing: 0.01em;
}

html.kpks-a11y-spacing body {
  line-height: 1.8;
  letter-spacing: 0.02em;
  word-spacing: 0.05em;
}

html.kpks-a11y-spacing :where(p, li, dd, dt, blockquote, .news-card-excerpt) {
  line-height: 1.85 !important;
}

html.kpks-a11y-links :where(a, button.btn-link) {
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 0.18em !important;
}

html.kpks-a11y-links :where(.kpks-social-link, .kpks-social-group-toggle) {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

html.kpks-a11y-motion-off *,
html.kpks-a11y-motion-off *::before,
html.kpks-a11y-motion-off *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* Wysoki kontrast */
html.kpks-a11y-contrast {
  color-scheme: light;
}

html.kpks-a11y-contrast body {
  background: #fff !important;
  color: #000 !important;
}

html.kpks-a11y-contrast :where(
  .main-header,
  .site-footer,
  .footer-showcase,
  .page-hero,
  .contact-section-showcase,
  .about-achievements-showcase,
  .about-stats-showcase,
  .hero-slider,
  .section-card
) {
  background: #000 !important;
  color: #fff !important;
  background-image: none !important;
}

html.kpks-a11y-contrast :where(
  h1,
  h2,
  h3,
  h4,
  h5,
  h6,
  p,
  li,
  span,
  dt,
  dd,
  label,
  .inner-hero-title,
  .page-hero-title,
  .news-card-title,
  .section-heading
) {
  color: inherit !important;
}

html.kpks-a11y-contrast a {
  color: #0047b3 !important;
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
}

html.kpks-a11y-contrast :where(
  .main-header,
  .site-footer,
  .footer-showcase,
  .page-hero,
  .contact-section-showcase
) a {
  color: #ffea00 !important;
}

html.kpks-a11y-contrast :where(
  .news-card,
  .contact-panel,
  .news-single,
  .about-achievement-tile,
  .wladze-card,
  .grants-logo,
  .kpks-a11y-panel
) {
  background: #fff !important;
  color: #000 !important;
  border: 2px solid #000 !important;
  box-shadow: none !important;
}

html.kpks-a11y-contrast .contact-page .contact-panel--general .contact-details a,
html.kpks-a11y-contrast .contact-page .contact-club-email a,
html.kpks-a11y-contrast .contact-page .contact-map-link {
  color: #0047b3 !important;
}

html.kpks-a11y-contrast .contact-page .contact-panel--general .kpks-social-link,
html.kpks-a11y-contrast .contact-page .contact-panel--general .kpks-social-group-toggle {
  background: #000 !important;
  color: #fff !important;
  border: 2px solid #000 !important;
}

html.kpks-a11y-contrast :where(
  .btn,
  .kpks-a11y-btn,
  .kpks-a11y-toggle,
  .kpks-a11y-reset
) {
  background: #000 !important;
  color: #fff !important;
  border: 2px solid #000 !important;
}

html.kpks-a11y-contrast :where(.btn:hover, .kpks-a11y-btn:hover, .kpks-a11y-toggle:hover) {
  background: #fff !important;
  color: #000 !important;
}

html.kpks-a11y-contrast :where(input, select, textarea) {
  background: #fff !important;
  color: #000 !important;
  border: 2px solid #000 !important;
}

html.kpks-a11y-contrast img {
  filter: contrast(1.1);
}

/* ==========================================================================
   Panel dostępności - widget
   ========================================================================== */

.kpks-a11y-widget {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 99990;
}

.kpks-a11y-widget-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--kpks-a11y-btn-size);
  height: var(--kpks-a11y-btn-size);
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--kpks-navy, #031047);
  color: #fff;
  font-size: 1.35rem;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(3, 16, 71, 0.18),
    0 8px 24px rgba(3, 16, 71, 0.28);
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.kpks-a11y-widget-toggle:hover {
  background: #008bd2;
  border-color: #fff;
  transform: scale(1.04);
}

.kpks-a11y-widget-toggle:focus-visible {
  outline: 3px solid var(--kpks-secondary, #ffd000);
  outline-offset: 3px;
  border-color: #fff;
}

.kpks-a11y-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 0.65rem);
  width: min(320px, calc(100vw - 2rem));
  max-height: min(70vh, 520px);
  overflow: auto;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(3, 16, 71, 0.12);
  box-shadow: 0 16px 40px rgba(3, 16, 71, 0.18);
}

.kpks-a11y-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(3, 16, 71, 0.1);
  background: #f8f9fa;
}

.kpks-a11y-panel-title {
  margin: 0;
  font-family: "Oswald", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--kpks-navy, #031047);
}

.kpks-a11y-panel-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--kpks-navy, #031047);
  cursor: pointer;
}

.kpks-a11y-panel-close:hover {
  background: rgba(3, 16, 71, 0.08);
}

.kpks-a11y-panel-body {
  padding: 0.85rem 1rem 1rem;
}

.kpks-a11y-group + .kpks-a11y-group {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(3, 16, 71, 0.08);
}

.kpks-a11y-group-label {
  margin: 0 0 0.65rem;
  font-family: "Inter", sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(3, 16, 71, 0.72);
}

.kpks-a11y-font-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}

.kpks-a11y-btn,
.kpks-a11y-toggle,
.kpks-a11y-reset {
  font-family: "Inter", sans-serif;
}

.kpks-a11y-btn {
  min-height: 44px;
  border: 2px solid rgba(3, 16, 71, 0.14);
  border-radius: 10px;
  background: #fff;
  color: var(--kpks-navy, #031047);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.kpks-a11y-btn:hover {
  border-color: var(--kpks-primary, #008bd2);
  color: var(--kpks-primary, #008bd2);
}

.kpks-a11y-hint {
  margin: 0.55rem 0 0;
  font-size: 0.78rem;
  color: rgba(3, 16, 71, 0.65);
}

.kpks-a11y-toggles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.kpks-a11y-toggle {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.75rem;
  border: 2px solid rgba(3, 16, 71, 0.12);
  border-radius: 10px;
  background: #fff;
  color: var(--kpks-navy, #031047);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.kpks-a11y-toggle i {
  width: 1.1rem;
  text-align: center;
  color: var(--kpks-primary, #008bd2);
}

.kpks-a11y-toggle:hover {
  border-color: var(--kpks-primary, #008bd2);
}

.kpks-a11y-toggle.is-active {
  background: var(--kpks-navy, #031047);
  border-color: var(--kpks-navy, #031047);
  color: #fff;
}

.kpks-a11y-toggle.is-active i {
  color: var(--kpks-secondary, #ffd000);
}

.kpks-a11y-reset {
  width: 100%;
  margin-top: 1rem;
  min-height: 44px;
  border: 2px solid rgba(3, 16, 71, 0.14);
  border-radius: 10px;
  background: #eef1f5;
  color: var(--kpks-navy, #031047);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.kpks-a11y-reset:hover {
  background: #e2e7ee;
}

html.kpks-a11y-contrast .kpks-a11y-widget-toggle {
  border-color: #fff;
  box-shadow: 0 0 0 2px #000;
}

/* Stopka - logo nie nachodzi na przycisk dostępności */
.footer-showcase-bar .footer-showcase-brand {
  padding-left: max(0px, calc(var(--kpks-a11y-clearance) - var(--kpks-site-gutter, 28px)));
  gap: 0.65rem;
}

.footer-showcase-bar .footer-showcase-brand-logo {
  width: 44px;
  height: 44px;
}

@media (max-width: 767px) {
  .footer-showcase-bar .footer-showcase-brand {
    padding-left: max(0px, calc(var(--kpks-a11y-clearance) - var(--kpks-site-gutter, 16px)));
  }
}

@media (max-width: 575px) {
  .kpks-a11y-widget {
    left: 0.75rem;
    bottom: max(0.85rem, env(safe-area-inset-bottom, 0px));
  }

  .kpks-a11y-panel {
    width: min(300px, calc(100vw - 1.5rem));
  }

  .footer-showcase-bar .footer-showcase-brand-logo {
    width: 40px;
    height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kpks-a11y-widget-toggle {
    transition: none;
  }
}
