/**
 * mod_cpdostepnosc — accessibility widget and page effects.
 * Effects are driven by classes on <html>; the widget itself (.cpd-root) is always excluded.
 *
 * @copyright (C) 2026 UserX / Czysty Płock
 * @license   GNU General Public License version 2 or later
 */

/* ==========================================================================
   Font: OpenDyslexic 1.000 (CC BY 3.0, see ../fonts/LICENSE.txt).
   Downloaded by the browser only when the "dyslexic" mode is active.
   ========================================================================== */

@font-face {
  font-family: "CpdOpenDyslexic";
  src: url("../fonts/OpenDyslexic-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "CpdOpenDyslexic";
  src: url("../fonts/OpenDyslexic-Italic.otf") format("opentype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "CpdOpenDyslexic";
  src: url("../fonts/OpenDyslexic-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "CpdOpenDyslexic";
  src: url("../fonts/OpenDyslexic-BoldItalic.otf") format("opentype");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

/* ==========================================================================
   Widget
   ========================================================================== */

.cpd-root {
  --cpd-accent: #2f73d0;
  --cpd-on-accent: #ffffff;
  --cpd-top: 50%;
  --cpd-edge: 0px;
  --cpd-panel-w: 320px;
  --cpd-text: #1f2933;
  --cpd-muted: #4b5563;
  --cpd-line: #d5dbe3;
  --cpd-control: #6b7280;
  --cpd-toggle-size: 40px; /* same as the mod_cpsocial tab (--cps-size) */
}

.cpd-root,
.cpd-root * {
  box-sizing: border-box;
}

.cpd-sr {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Neutralise template button styles inside the widget. */
.cpd-root button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  font: inherit;
  letter-spacing: normal;
  text-transform: none;
  text-shadow: none;
  line-height: 1.3;
  cursor: pointer;
}

.cpd-root :focus {
  outline: none;
}

.cpd-root :focus-visible {
  outline: 3px solid #111827;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px #ffffff;
}

.cpd-root .cpd-panel:focus-visible {
  outline-offset: -3px;
  box-shadow: none;
}

/* Floating toggle button */
.cpd-toggle {
  position: fixed;
  z-index: 2147483001;
  top: var(--cpd-top);
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--cpd-toggle-size);
  height: var(--cpd-toggle-size);
  padding: 0;
  border: 0;
  color: var(--cpd-on-accent);
  background: var(--cpd-accent);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.2);
  transform: translateY(-50%);
  transition: filter 0.15s ease, box-shadow 0.15s ease;
}

.cpd-root--left .cpd-toggle {
  left: var(--cpd-edge);
  border-radius: 0 6px 6px 0;
}

.cpd-root--right .cpd-toggle {
  right: var(--cpd-edge);
  border-radius: 6px 0 0 6px;
}

.cpd-toggle:hover {
  filter: brightness(0.92);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.28);
}

.cpd-toggle__icon {
  display: block;
  /* glyph height matched to the mod_cpsocial "f" icon (14.8 px): 18.8 of 24 viewBox units */
  width: 19px;
  height: 19px;
}

/* Panel (non-modal dialog) */
.cpd-panel {
  position: fixed;
  z-index: 2147483002;
  /* Opens next to the toggle: JS (place()) aligns the top edge with the toggle and keeps the
     panel inside the viewport; 12px is the fallback before the first measurement. */
  top: 12px;
  width: min(var(--cpd-panel-w), calc(100vw - var(--cpd-edge) - var(--cpd-toggle-size) - 20px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 16px 16px;
  color: var(--cpd-text);
  background: #ffffff;
  border: 1px solid var(--cpd-line);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.14), 0 1px 3px rgba(15, 23, 42, 0.08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  letter-spacing: normal;
  word-spacing: normal;
}

.cpd-panel[hidden] {
  display: none;
}

.cpd-root--left .cpd-panel {
  left: calc(var(--cpd-edge) + var(--cpd-toggle-size) + 8px);
}

.cpd-root--right .cpd-panel {
  right: calc(var(--cpd-edge) + var(--cpd-toggle-size) + 8px);
}

.cpd-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.cpd-panel__title {
  margin: 2px 0 0;
  padding: 0;
  color: var(--cpd-text);
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: normal;
  text-transform: none;
}

.cpd-close {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-left: auto !important;
  padding: 0;
  color: var(--cpd-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
}

.cpd-close:hover {
  color: var(--cpd-text);
  background: #f1f4f8;
}

.cpd-close svg {
  width: 16px;
  height: 16px;
}

.cpd-panel__desc {
  margin: 0 0 12px;
  padding: 0;
  color: var(--cpd-muted);
  font-size: 14px;
  line-height: 1.45;
}

.cpd-group {
  margin: 0 0 12px;
}

.cpd-group__label {
  display: block;
  margin: 0 0 6px;
  color: var(--cpd-muted);
  font-size: 13px;
  font-weight: 600;
}

.cpd-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 12px;
}

.cpd-group .cpd-list {
  margin-bottom: 0;
}

/* Font size row */
.cpd-font {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cpd-btn {
  min-width: 40px;
  height: 36px;
  padding: 0 10px;
  color: var(--cpd-text);
  background: #ffffff;
  border: 1px solid var(--cpd-control);
  border-radius: 6px;
  font-weight: 600 !important;
}

.cpd-btn:hover {
  background: #f1f4f8;
}

.cpd-btn[aria-disabled="true"] {
  color: #6b7280;
  border-color: #c3cad3;
  background: #f8fafc;
  cursor: default;
}

.cpd-btn--text {
  margin-left: auto !important;
  font-weight: 400 !important;
}

.cpd-font__value {
  min-width: 48px;
  color: var(--cpd-text);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* Toggle rows (button + aria-pressed) */
.cpd-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 7px 10px;
  color: var(--cpd-text);
  text-align: left;
  background: #ffffff;
  border: 1px solid var(--cpd-line);
  border-radius: 6px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.cpd-switch:hover {
  background: #f5f7fa;
  border-color: #b8c0cb;
}

.cpd-switch__box {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: transparent;
  background: #ffffff;
  border: 2px solid var(--cpd-control);
  border-radius: 4px;
}

.cpd-switch__mark {
  width: 14px;
  height: 14px;
}

.cpd-switch[aria-pressed="true"] {
  border-color: var(--cpd-accent);
  background: #f3f7fd;
  font-weight: 600;
}

.cpd-switch[aria-pressed="true"] .cpd-switch__box {
  color: var(--cpd-on-accent);
  background: var(--cpd-accent);
  border-color: var(--cpd-accent);
}

/* Reset */
.cpd-reset {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  color: var(--cpd-text);
  background: #f5f7fa;
  border: 1px solid var(--cpd-control);
  border-radius: 6px;
}

.cpd-reset:hover {
  background: #e9edf2;
}

/* Small screens: panel docks to the bottom edge */
@media (max-width: 479px) {
  .cpd-root .cpd-panel {
    top: auto;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    max-height: 80vh;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cpd-root *,
  .cpd-root *::before,
  .cpd-root *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* Windows High Contrast / forced colours: keep the toggle visible. */
@media (forced-colors: active) {
  .cpd-toggle,
  .cpd-panel,
  .cpd-switch,
  .cpd-btn,
  .cpd-reset {
    border: 1px solid CanvasText;
  }

  .cpd-switch[aria-pressed="true"] .cpd-switch__box {
    color: Canvas;
    background: Highlight;
  }
}

/* ==========================================================================
   Page effects
   ========================================================================== */

/* 1. Text size — zoom on page wrappers (template sizes are in px, so root font-size
      would not work). Fixed-width Bootstrap containers are relaxed to avoid
      horizontal scrolling. */
html.cpd-fs-1 body > :not(.cpd-root) { zoom: 1.1; }
html.cpd-fs-2 body > :not(.cpd-root) { zoom: 1.2; }
html.cpd-fs-3 body > :not(.cpd-root) { zoom: 1.35; }
html.cpd-fs-4 body > :not(.cpd-root) { zoom: 1.5; }
html.cpd-fs-5 body > :not(.cpd-root) { zoom: 1.75; }

html[class*="cpd-fs-"] body .container {
  width: auto !important;
  max-width: min(100%, 1170px) !important;
}

/* Uber template header: with larger or wider text the main menu wraps onto a second line
   inside a Bootstrap .row whose negative margin pushes the first item off-screen
   (WCAG 1.4.10). Measured on DEV 2026-11-20: first item at x=-22px. */
html[class*="cpd-fs-"] .uber-header > .row,
html.cpd-dys .uber-header > .row,
html.cpd-spacing .uber-header > .row {
  margin-left: 0;
  margin-right: 0;
}

/* 2. Large cursor */
html.cpd-cursor,
html.cpd-cursor * {
  cursor: url("../img/kursor.svg") 6 3, auto !important;
}

html.cpd-cursor a[href],
html.cpd-cursor a[href] *,
html.cpd-cursor button,
html.cpd-cursor button *,
html.cpd-cursor [role="button"],
html.cpd-cursor label,
html.cpd-cursor select,
html.cpd-cursor summary,
html.cpd-cursor input[type="checkbox"],
html.cpd-cursor input[type="radio"],
html.cpd-cursor input[type="submit"],
html.cpd-cursor input[type="button"] {
  cursor: url("../img/kursor-dlon.svg") 17 5, pointer !important;
}

html.cpd-cursor input:not([type]),
html.cpd-cursor input[type="text"],
html.cpd-cursor input[type="search"],
html.cpd-cursor input[type="email"],
html.cpd-cursor input[type="tel"],
html.cpd-cursor input[type="url"],
html.cpd-cursor input[type="number"],
html.cpd-cursor input[type="password"],
html.cpd-cursor textarea {
  cursor: text !important;
}

/* 3. Dyslexia-friendly font (icon fonts are left untouched) */
html.cpd-dys body :not(.cpd-root):not(.cpd-root *):not(i):not(.fa):not(.fas):not(.far):not(.fab):not(.fal):not([class*="fa-"]):not(.glyphicon):not([class^="icon-"]):not([class*=" icon-"]):not(svg):not(svg *) {
  font-family: "CpdOpenDyslexic", "Comic Sans MS", Verdana, Tahoma, sans-serif !important;
}

/* 4. Text spacing — WCAG 2.1 SC 1.4.12 values */
html.cpd-spacing body :not(.cpd-root):not(.cpd-root *) {
  line-height: 1.5 !important;
  letter-spacing: 0.12em !important;
  word-spacing: 0.16em !important;
}

html.cpd-spacing body p:not(.cpd-root *) {
  margin-bottom: 2em !important;
}

/* 5. Grayscale and inverted colours — a full-viewport backdrop-filter layer placed
      under the widget. Filtering <body> itself would also filter the widget and would
      break position:fixed elements of the template. */
html.cpd-gray::after,
html.cpd-hc-invert::after {
  content: "";
  position: fixed;
  z-index: 2147483000;
  inset: 0;
  pointer-events: none;
}

html.cpd-gray::after {
  -webkit-backdrop-filter: grayscale(1);
  backdrop-filter: grayscale(1);
}

html.cpd-hc-invert::after {
  -webkit-backdrop-filter: invert(1) hue-rotate(180deg);
  backdrop-filter: invert(1) hue-rotate(180deg);
}

html.cpd-gray.cpd-hc-invert::after {
  -webkit-backdrop-filter: grayscale(1) invert(1);
  backdrop-filter: grayscale(1) invert(1);
}

/* Fallback for browsers without backdrop-filter: filter page wrappers only. */
@supports not ((backdrop-filter: grayscale(1)) or (-webkit-backdrop-filter: grayscale(1))) {
  html.cpd-gray body > :not(.cpd-root) { filter: grayscale(1); }
  html.cpd-hc-invert body > :not(.cpd-root) { filter: invert(1) hue-rotate(180deg); }
  html.cpd-gray.cpd-hc-invert body > :not(.cpd-root) { filter: grayscale(1) invert(1); }
}

/* 6. High contrast: yellow on black */
html.cpd-hc-yb,
html.cpd-hc-yb body {
  color: #ffff00 !important;
  background: #000000 !important;
}

html.cpd-hc-yb body :not(.cpd-root):not(.cpd-root *):not(img):not(video):not(iframe):not(canvas):not(svg):not(svg *) {
  color: #ffff00 !important;
  background-color: #000000 !important;
  background-image: none !important;
  border-color: #ffff00 !important;
  text-shadow: none !important;
  box-shadow: none !important;
}

html.cpd-hc-yb body a[href]:not(.cpd-root *),
html.cpd-hc-yb body a[href]:not(.cpd-root *) * {
  color: #00ffff !important;
  text-decoration: underline !important;
}

/* 7. High contrast: black on white */
html.cpd-hc-bw,
html.cpd-hc-bw body {
  color: #000000 !important;
  background: #ffffff !important;
}

html.cpd-hc-bw body :not(.cpd-root):not(.cpd-root *):not(img):not(video):not(iframe):not(canvas):not(svg):not(svg *) {
  color: #000000 !important;
  background-color: #ffffff !important;
  background-image: none !important;
  border-color: #000000 !important;
  text-shadow: none !important;
  box-shadow: none !important;
}

html.cpd-hc-bw body a[href]:not(.cpd-root *),
html.cpd-hc-bw body a[href]:not(.cpd-root *) * {
  color: #0000cc !important;
  text-decoration: underline !important;
}

/* High-contrast modes: placeholders in the toggle boxes show the scheme. */
.cpd-switch__box--yb { background: #000000; border-color: #000000; }
.cpd-switch__box--bw { background: #ffffff; }
.cpd-switch__box--invert { background: linear-gradient(135deg, #ffffff 50%, #1f2933 50%); }

/* Printing: the widget itself is never printed (the previous module was hidden by the
   template style's print CSS, see template style 151 "snippet_close_body"). */
@media print {
  .cpd-root {
    display: none !important;
  }
}
