/* consent-banner.css — wygląd banera zgód (skill cookie-consent-gtm)
 * Podpięcie pod design projektu: nadpisz tokeny --cc-* (np. w :root projektu).
 * Zasada symetrii: „Odrzuć wszystkie” i „Akceptuj wszystkie” mają TEN SAM styl (.cc-btn--primary).
 */
:root {
  --cc-font: inherit;
  --cc-bg: #ffffff;
  --cc-fg: #1a1a1a;
  --cc-muted: #4a4a4a;          /* ≥ 4.5:1 na --cc-bg */
  --cc-border: #767676;         /* ≥ 3:1 na --cc-bg (obrys przycisku drugorzędnego, przełącznika) */
  --cc-accent: #1a1a1a;         /* tło przycisków głównych */
  --cc-accent-fg: #ffffff;
  --cc-focus: #005fcc;
  --cc-switch-on: #1a1a1a;
  --cc-surface: #f4f4f4;        /* tło zaślepki embedu, tabel */
  --cc-backdrop: rgb(0 0 0 / 0.5);
  --cc-radius: 8px;
  --cc-shadow: 0 -2px 16px rgb(0 0 0 / 0.12);
  --cc-z: 2147483000;
  --cc-max: 1120px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --cc-bg: #1c1c1e;
    --cc-fg: #f2f2f2;
    --cc-muted: #c7c7c7;
    --cc-border: #9a9a9a;
    --cc-accent: #f2f2f2;
    --cc-accent-fg: #111111;
    --cc-focus: #7ab7ff;
    --cc-switch-on: #f2f2f2;
    --cc-surface: #2a2a2d;
    --cc-shadow: 0 -2px 16px rgb(0 0 0 / 0.5);
  }
}
:root[data-theme="dark"] {
  --cc-bg: #1c1c1e;
  --cc-fg: #f2f2f2;
  --cc-muted: #c7c7c7;
  --cc-border: #9a9a9a;
  --cc-accent: #f2f2f2;
  --cc-accent-fg: #111111;
  --cc-focus: #7ab7ff;
  --cc-switch-on: #f2f2f2;
  --cc-surface: #2a2a2d;
}

.cc-banner, .cc-settings, .cc-floating, .cc-embed {
  font-family: var(--cc-font);
  color: var(--cc-fg);
  box-sizing: border-box;
}
.cc-banner *, .cc-settings *, .cc-embed * { box-sizing: border-box; }
.cc-banner[hidden], .cc-floating[hidden] { display: none !important; }

/* ---------- warstwa 1: pasek ---------- */
.cc-banner--bar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: var(--cc-z);
  background: var(--cc-bg);
  box-shadow: var(--cc-shadow);
  border-top: 1px solid var(--cc-border);
  max-height: 40dvh;             /* przy zoomie 400% treść strony nadal widoczna [WCAG 1.4.10] */
  overflow-y: auto;
}
.cc-banner__inner {
  max-width: var(--cc-max);
  margin: 0 auto;
  padding: 20px 16px;
  display: grid;
  gap: 8px 32px;
  grid-template-columns: 1fr;
}
@media (min-width: 900px) {
  .cc-banner--bar .cc-banner__inner { grid-template-columns: 1fr auto; align-items: center; }
  .cc-banner--bar .cc-banner__title { grid-column: 1; }
  .cc-banner--bar .cc-banner__text { grid-column: 1; }
  .cc-banner--bar .cc-banner__actions { grid-column: 2; grid-row: 1 / span 2; }
}
.cc-banner__title:focus, .cc-settings__title:focus { outline: none; }
.cc-banner__title { margin: 0; font-size: 1.125rem; line-height: 1.3; font-weight: 700; }
.cc-banner__text { margin: 0; font-size: 0.9375rem; line-height: 1.5; color: var(--cc-muted); max-width: 70ch; }
.cc-banner a, .cc-settings a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- warstwa 1: okienko w rogu ('box') ----------
   Odrzuć i Akceptuj obok siebie, równej szerokości i w tym samym stylu (symetria, EROD); Ustawienia pod nimi. */
.cc-banner--box {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: var(--cc-z);
  width: min(28rem, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--cc-bg);
  border: 1px solid var(--cc-border);
  border-radius: var(--cc-radius-box, 16px);
  box-shadow: var(--cc-shadow);
}
.cc-banner--box .cc-banner__inner { padding: 20px; gap: 10px; }
.cc-banner--box .cc-banner__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.cc-banner--box .cc-banner__actions [data-cc-action="settings"] { grid-column: 1 / -1; order: 3; }
.cc-banner--box .cc-btn--primary { min-height: 48px; font-size: 1rem; }
@media (max-width: 599px) {
  .cc-banner--box { inset: auto 0 0 0; width: auto; max-height: 70dvh; border-width: 1px 0 0; border-radius: var(--cc-radius-box, 16px) var(--cc-radius-box, 16px) 0 0; }
}

/* ---------- warstwa 1: modal ---------- */
.cc-banner--modal {
  border: 0;
  padding: 0;
  border-radius: var(--cc-radius);
  background: var(--cc-bg);
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
}
.cc-banner--modal::backdrop, .cc-settings::backdrop { background: var(--cc-backdrop); }
.cc-banner--modal .cc-banner__inner { padding: 24px; gap: 12px; }

/* ---------- przyciski ---------- */
.cc-banner__actions, .cc-settings__actions, .cc-embed__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cc-btn {
  flex: 1 1 auto;
  min-height: 44px;              /* cel dotyku [WCAG 2.5.8 min. 24px; zalecane 44px] */
  min-width: 10ch;
  padding: 10px 18px;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: var(--cc-radius);
  border: 2px solid var(--cc-accent);
  cursor: pointer;
  text-align: center;
}
.cc-btn--primary { background: var(--cc-accent); color: var(--cc-accent-fg); }
.cc-btn--secondary { background: transparent; color: var(--cc-fg); border-color: var(--cc-border); }
.cc-btn:hover { filter: brightness(1.08); }
.cc-btn:focus-visible, .cc-close:focus-visible, .cc-switch:focus-visible,
.cc-floating:focus-visible, .cc-settings summary:focus-visible,
.cc-banner a:focus-visible, .cc-settings a:focus-visible {
  outline: 3px solid var(--cc-focus);
  outline-offset: 2px;
}
@media (min-width: 600px) {
  .cc-btn { flex: 0 1 auto; }
}
/* Wąski ekran: „Odrzuć” i „Akceptuj” w jednym rzędzie, równej szerokości; trzeci przycisk pod nimi.
   Zawijanie flexem dawało „Akceptuj” na całą szerokość, a „Odrzuć” na pół — zgoda bardziej widoczna (EROD). */
@media (max-width: 599px) {
  .cc-banner__actions, .cc-settings__actions { display: grid; grid-template-columns: 1fr 1fr; }
  .cc-banner__actions [data-cc-action="settings"],
  .cc-settings__actions [data-cc-action="save"] { grid-column: 1 / -1; order: 3; }
}

/* ---------- warstwa 2: panel ustawień ---------- */
.cc-settings {
  border: 0;
  padding: 0;
  border-radius: var(--cc-radius);
  background: var(--cc-bg);
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  display: none;
  flex-direction: column;
}
.cc-settings[open] { display: flex; }
.cc-settings__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--cc-border);
}
.cc-settings__title { margin: 0; font-size: 1.25rem; line-height: 1.3; }
.cc-close {
  width: 44px; height: 44px;
  flex: none;
  font: inherit; font-size: 1.75rem; line-height: 1;
  border: 0; border-radius: var(--cc-radius);
  background: transparent; color: var(--cc-fg);
  cursor: pointer;
}
.cc-settings__body { padding: 16px 24px; overflow-y: auto; }
.cc-settings__body > p { margin: 0 0 16px; color: var(--cc-muted); line-height: 1.5; }
.cc-settings__actions { padding: 16px 24px 20px; border-top: 1px solid var(--cc-border); }

.cc-cat { padding: 14px 0; border-top: 1px solid color-mix(in srgb, var(--cc-border) 40%, transparent); }
.cc-cat:first-of-type { border-top: 0; }
.cc-cat__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.cc-cat__name { margin: 0; font-size: 1rem; font-weight: 700; cursor: pointer; }
h3.cc-cat__name { cursor: default; }
.cc-cat__always { font-size: 0.875rem; font-weight: 600; color: var(--cc-muted); }
.cc-cat__desc { margin: 6px 0 0; font-size: 0.9375rem; line-height: 1.5; color: var(--cc-muted); }
.cc-cat__details { margin-top: 8px; font-size: 0.875rem; }
.cc-cat__details summary { cursor: pointer; min-height: 24px; padding: 4px 0; font-weight: 600; }

/* przełącznik: natywny checkbox z role="switch" */
.cc-switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  position: relative;
  width: 48px; height: 28px;
  margin: 0;
  border-radius: 999px;
  border: 2px solid var(--cc-border);
  background: var(--cc-bg);
  cursor: pointer;
}
.cc-switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--cc-border);
  transition: transform 0.15s ease-out;
}
.cc-switch:checked { background: var(--cc-switch-on); border-color: var(--cc-switch-on); }
.cc-switch:checked::after { transform: translateX(20px); background: var(--cc-bg); }
@media (prefers-reduced-motion: reduce) { .cc-switch::after { transition: none; } }

.cc-table-wrap { overflow-x: auto; margin-top: 6px; }
.cc-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.cc-table th, .cc-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid color-mix(in srgb, var(--cc-border) 40%, transparent); vertical-align: top; }
.cc-table th { font-weight: 700; background: var(--cc-surface); }

/* ---------- pływający przycisk ---------- */
.cc-floating {
  position: fixed;
  left: 16px; bottom: 16px;
  z-index: calc(var(--cc-z) - 1);
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--cc-border);
  background: var(--cc-bg);
  color: var(--cc-fg);
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.15);
  cursor: pointer;
}

/* ---------- zaślepka embedu (YouTube, Mapy) ---------- */
.cc-embed {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  background: var(--cc-surface);
  border-radius: var(--cc-radius);
  overflow: hidden;
}
.cc-embed__inner { max-width: 46ch; padding: 24px; text-align: center; }
.cc-embed__title { margin: 0 0 8px; font-weight: 700; }
.cc-embed__text { margin: 0 0 16px; font-size: 0.9375rem; line-height: 1.5; color: var(--cc-muted); }
.cc-embed__actions { justify-content: center; }
.cc-embed__alt { margin: 12px 0 0; font-size: 0.875rem; }
.cc-embed__alt a { color: inherit; }
.cc-embed__frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

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

/* Bardzo niskie okno (zoom 400%, telefon poziomo): pasek wraca do przepływu strony, nic nie zasłania [WCAG 1.4.10] */
@media (max-height: 30rem) {
  .cc-banner--bar, .cc-banner--box { position: static; max-height: none; box-shadow: none; width: auto; border-radius: 0; }
}
/* Tryb wysokiego kontrastu Windows: przełącznik i przyciski muszą mieć widoczne krawędzie i stan */
@media (forced-colors: active) {
  .cc-btn, .cc-switch, .cc-floating, .cc-close { border: 2px solid ButtonText; }
  .cc-switch::after { background: ButtonText; forced-color-adjust: none; }
  .cc-switch:checked { background: Highlight; }
  .cc-switch:checked::after { background: HighlightText; }
}
