/*
 * Dokumenty prawne KwantApp (regulamin, polityka prywatności).
 * Kolory = tokeny aplikacji 3.0 (src/theme/tokens.ts), tryb ciemny wg ustawień systemu.
 * Wszystko lokalnie: bez CDN, bez JavaScriptu.
 */

@font-face {
  font-family: "Archivo Kwant";
  src: url("../assets/fonts/ArchivoW88-Wght700.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  --ground: #eef1f4;
  --stock: #ffffff;
  --stock-2: #f5f7f9;
  --fill: #e4e8ed;
  --ink: #141b22;
  --ink-2: #4a5562;
  --carrier-text: #0f63a6;
  --band: #116bb3;
  --on-band: #ffffff;
  --on-band-soft: #e3eef8;
  --band-ink: #0c5895;
  --band-ink-2: #4a5562;
  --focus: #116bb3;
  --logo-blue: #0268ae;
  --logo-grey: #4a4a4c;

  --font-text: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Archivo Kwant", var(--font-text);

  --size-title: clamp(1.75rem, 1.15rem + 2.8vw, 3.25rem);
  --size-heading: clamp(1.125rem, 1rem + 0.55vw, 1.5rem);
  --size-text: 1.0625rem;
  --size-small: 0.875rem;

  --gutter: clamp(1rem, 0.6rem + 2vw, 2rem);
  --measure: 46rem;
  --indent: 2.25rem;
  --indent-nested: 2rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #15181c;
    --stock: #1f2328;
    --stock-2: #262b31;
    --fill: #2c3238;
    --ink: #eef1f4;
    --ink-2: #a9b3be;
    --carrier-text: #6fb1ec;
    --band: #17324f;
    --on-band: #ffffff;
    --on-band-soft: #c3d7eb;
    --band-ink: #17324f;
    --band-ink-2: #4a5562;
    --focus: #6fb1ec;
    --logo-blue: #3d8fd6;
    --logo-grey: #ffffff;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #15181c;
  --stock: #1f2328;
  --stock-2: #262b31;
  --fill: #2c3238;
  --ink: #eef1f4;
  --ink-2: #a9b3be;
  --carrier-text: #6fb1ec;
  --band: #17324f;
  --on-band: #ffffff;
  --on-band-soft: #c3d7eb;
  --band-ink: #17324f;
  --band-ink-2: #4a5562;
  --focus: #6fb1ec;
  --logo-blue: #3d8fd6;
  --logo-grey: #ffffff;
}

:root[data-theme="light"] {
  color-scheme: light;
}

@media screen and (max-width: 30rem) {
  :root {
    --indent: 1.875rem;
    --indent-nested: 1.625rem;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--stock);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--size-text);
  line-height: 1.6;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

p,
ol,
ul,
dl,
dd,
h1,
h2 {
  margin: 0;
}

strong {
  font-weight: 650;
}

a {
  color: var(--carrier-text);
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.18em;
  overflow-wrap: anywhere;
  transition: color 0.15s ease, text-decoration-thickness 0.15s ease;
}

a:hover {
  text-decoration-thickness: 0.14em;
}

a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection {
  background: var(--band);
  color: var(--on-band);
}

.wrap {
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Nagłówek z logo */

.site-header {
  background: var(--stock);
  padding-top: env(safe-area-inset-top, 0px);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4rem;
}

.logo {
  display: block;
  flex: none;
  width: auto;
  height: 1.75rem;
  aspect-ratio: 140 / 41;
}

/* Pobieranie PDF: akcja dokumentu na pasie tytułowym */

.pdf-link {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  column-gap: 0.625rem;
  row-gap: 0.125rem;
  min-height: 3rem;
  margin-top: clamp(1.5rem, 1.2rem + 1vw, 2rem);
  padding: 0.625rem 1.25rem 0.625rem 1rem;
  background: var(--on-band);
  color: var(--band-ink);
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

@media (hover: hover) {
  .pdf-link:hover {
    background: var(--on-band-soft);
  }
}

.pdf-link:active {
  transform: translateY(1px);
}

.pdf-link:focus-visible {
  outline: 2px solid var(--on-band);
  outline-offset: 3px;
  border-radius: 0;
}

.pdf-link-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
}

.pdf-meta {
  color: var(--band-ink-2);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.pdf-meta:empty {
  display: none;
}

/* Tytuł dokumentu na pasie w kolorze marki */

.title-band {
  background: var(--band);
  color: var(--on-band);
  padding-block: clamp(2.25rem, 1.5rem + 4vw, 5rem);
}

.title-band h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--size-title);
  line-height: 1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.document-kind {
  margin-bottom: 0.875rem;
  font-weight: 600;
}

.document-subtitle {
  margin-top: 0.875rem;
  font-size: 1.125rem;
}

/* Treść */

.document {
  padding-block: clamp(2rem, 1.5rem + 2.5vw, 4rem) clamp(3rem, 2rem + 4vw, 6rem);
}

.lead {
  display: grid;
  gap: 1rem;
  margin-bottom: clamp(2.5rem, 2rem + 2vw, 4rem);
  font-size: 1.125rem;
  line-height: 1.55;
}

.lead strong {
  font-weight: 600;
}

.lead .invitation {
  font-style: italic;
  font-weight: 650;
}

.lead .signature {
  display: block;
  margin-top: 0.5rem;
  text-align: right;
}

/* Rozdziały: numer w nagłówku z licznika listy */

.sections {
  list-style: none;
  padding: 0;
  counter-reset: section;
  display: grid;
  gap: clamp(2.5rem, 2rem + 2vw, 3.75rem);
}

.sections > li {
  counter-increment: section;
}

.sections > li > h2 {
  display: flex;
  gap: 0.6em;
  margin-bottom: 1.25rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--size-heading);
  line-height: 1.2;
  letter-spacing: -0.005em;
  scroll-margin-top: 1rem;
}

.sections > li > h2::before {
  flex: none;
  color: var(--carrier-text);
  font-variant-numeric: tabular-nums;
}

.sections.paren > li > h2::before {
  content: counter(section) ")";
}

.sections.roman > li > h2::before {
  content: counter(section, upper-roman) ".";
}

/* Akapity i wypunktowania bez numeru, bezpośrednio w rozdziale */

.sections > li > p + p,
.sections > li > p + ol,
.sections > li > ol + p,
.sections > li > p + ul,
.sections > li > ul + p {
  margin-top: 0.875rem;
}

.bullets {
  display: grid;
  gap: 0.5rem;
  padding-left: var(--indent);
}

.bullets > li::marker {
  color: var(--carrier-text);
}

/* Punkty i podpunkty */

.clauses {
  list-style: none;
  padding-left: var(--indent);
  counter-reset: clause;
  display: grid;
  gap: 0.875rem;
}

.clauses .clauses {
  padding-left: var(--indent-nested);
  margin-top: 0.75rem;
  gap: 0.5rem;
}

.clauses > li {
  counter-increment: clause;
  position: relative;
}

.clauses > li::before {
  position: absolute;
  left: calc(-1 * var(--indent));
  width: calc(var(--indent) - 0.5rem);
  color: var(--carrier-text);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  content: counter(clause) ".";
}

.clauses .clauses > li::before {
  left: calc(-1 * var(--indent-nested));
  width: calc(var(--indent-nested) - 0.5rem);
}

.clauses.latin > li::before {
  content: counter(clause, lower-latin) ".";
}

.clauses.paren > li::before {
  content: counter(clause) ")";
}

.clauses.paren.latin > li::before {
  content: counter(clause, lower-latin) ")";
}

.clauses > li > p + p,
.clauses > li > p + .clauses + p {
  margin-top: 0.5rem;
}

/* Definicje regulaminu */

.definitions {
  display: grid;
  gap: 1.25rem;
  margin-top: 1rem;
}

.definitions dt {
  color: var(--carrier-text);
  font-weight: 700;
  font-size: 0.9375rem;
  line-height: 1.35;
}

.definitions dd {
  margin-top: 0.25rem;
}

.definitions .clauses {
  margin-block: 0.5rem;
}

/* Tabela celów przetwarzania: jeden <tbody> na cel, pod nim informacja o podaniu danych */

.table-scroll {
  margin-top: 1rem;
}

.purposes {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.purposes th,
.purposes td {
  padding: 0.875rem 1rem;
  text-align: left;
  vertical-align: top;
}

.purposes thead th {
  background: var(--fill);
  font-weight: 700;
}

.purposes tbody:nth-of-type(even) {
  background: var(--stock-2);
}

.purposes td:first-child {
  font-weight: 600;
}

.purposes td p + p {
  margin-top: 0.5rem;
}

.purposes .purpose-note td {
  padding-top: 0;
  font-weight: 400;
  font-style: italic;
}

@media (min-width: 48rem) {
  .purposes th:first-child,
  .purposes td:first-child:not([colspan]) {
    width: 24%;
  }
}

@media screen and (max-width: 47.99rem) {
  .purposes thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .purposes,
  .purposes tbody,
  .purposes tr,
  .purposes td {
    display: block;
  }

  .purposes tbody,
  .purposes tbody:nth-of-type(even) {
    background: var(--stock-2);
    padding: 1rem;
  }

  .purposes tbody + tbody {
    margin-top: 0.75rem;
  }

  .purposes td {
    padding: 0;
  }

  .purposes td + td,
  .purposes .purpose-note td {
    margin-top: 0.875rem;
  }

  .purposes td:first-child:not([colspan]) {
    font-size: 1rem;
  }

  .purposes td + td::before {
    display: block;
    margin-bottom: 0.125rem;
    color: var(--ink-2);
    font-size: var(--size-small);
    font-weight: 650;
    content: attr(data-label);
  }
}

/* Wykaz producentów (Załącznik nr 2) */

.producers {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  line-height: 1.45;
}

.producers th,
.producers td {
  padding: 0.75rem 1rem;
  text-align: left;
  vertical-align: top;
}

.producers thead th {
  background: var(--fill);
  font-weight: 700;
  vertical-align: bottom;
}

.producers thead th:last-child {
  width: 38%;
}

.producers tbody tr:nth-child(even) {
  background: var(--stock-2);
}

.producers tbody th {
  font-weight: 600;
}

.producers td:first-child {
  color: var(--carrier-text);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.producers td:last-child {
  font-variant-numeric: tabular-nums;
}

@media screen and (max-width: 30rem) {
  .producers th,
  .producers td {
    padding: 0.625rem 0.5rem;
  }

  .producers thead th {
    font-size: var(--size-small);
  }
}

.note {
  margin-top: 1.75rem;
}

/* Potwierdzenie rejestracji (registration/) */

.action-button {
  display: inline-flex;
  align-items: center;
  min-height: 3rem;
  padding: 0.75rem 1.5rem;
  background: var(--band);
  color: var(--on-band);
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

@media (hover: hover) {
  .action-button:hover {
    background: var(--band-ink);
  }
}

.action-button:active {
  transform: translateY(1px);
}

.action-button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 0;
}

.progress {
  position: relative;
  overflow: hidden;
  max-width: 20rem;
  height: 0.375rem;
  background: var(--fill);
}

.progress span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 40%;
  background: var(--band);
  animation: progress-slide 1.2s ease-in-out infinite;
}

@keyframes progress-slide {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(250%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .progress span {
    width: 100%;
    animation: none;
    opacity: 0.5;
  }
}

.registration .lead {
  margin-bottom: 1.5rem;
}

.help-contact {
  margin-top: 1.5rem;
}

/* Stopka: pozostałe dokumenty, kontakt, wygląd */

.site-footer {
  background: var(--ground);
  color: var(--ink);
  padding-block: clamp(2.5rem, 2rem + 2.5vw, 4.5rem) calc(1.5rem + env(safe-area-inset-bottom, 0px));
}

.footer-grid {
  display: grid;
  gap: 2.5rem;
}

@media (min-width: 48rem) {
  .footer-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 2.5rem;
  }
}

.footer-title {
  margin-bottom: 0.875rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.125rem;
  line-height: 1.2;
}

.footer-documents {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.footer-documents a {
  display: grid;
  min-height: 2.75rem;
  align-content: center;
  padding-block: 0.375rem;
  text-decoration: none;
}

.footer-documents .doc-name {
  font-weight: 650;
  line-height: 1.35;
  text-decoration: underline;
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.18em;
}

@media (hover: hover) {
  .footer-documents a:hover .doc-name {
    text-decoration-thickness: 0.14em;
  }
}

.footer-documents .doc-note {
  margin-top: 0.125rem;
  color: var(--ink-2);
  font-size: var(--size-small);
  line-height: 1.35;
}

.footer-contact {
  font-style: normal;
  line-height: 1.6;
}

.footer-contact a {
  display: inline-block;
  padding-block: 0.25rem;
}

.footer-contact .operator {
  font-weight: 650;
}

.footer-contact + .footer-contact {
  margin-top: 1rem;
}

.footer-contact .contact-label {
  display: block;
  color: var(--ink-2);
  font-size: var(--size-small);
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap-reverse;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem 2rem;
  margin-top: clamp(2.5rem, 2rem + 2vw, 3.5rem);
  color: var(--ink-2);
  font-size: var(--size-small);
}

.footer-appearance {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.footer-appearance[hidden] {
  display: none;
}

.appearance-label {
  color: var(--ink);
  font-weight: 650;
  font-size: 0.9375rem;
}

/* Wygląd: Jasny / Ciemny / Auto, jak w aplikacji */

.theme-switch {
  display: inline-flex;
  padding: 0.1875rem;
  border-radius: 999px;
  background: var(--fill);
}

.theme-switch button {
  min-height: 2.5rem;
  padding: 0 0.875rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

@media (hover: hover) {
  .theme-switch button:hover {
    color: var(--ink);
  }
}

.theme-switch button[aria-pressed="true"] {
  background: var(--stock);
  color: var(--ink);
}

.theme-switch button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Wydruk i PDF: zawsze jasny motyw, kolory marki zachowane */

@page {
  size: A4;
  margin: 16mm 16mm 18mm;
}

@media print {
  :root:not([data-theme="print"]) {
    color-scheme: light;
    --ground: #eef1f4;
    --stock: #ffffff;
    --stock-2: #f5f7f9;
    --fill: #e4e8ed;
    --ink: #141b22;
    --ink-2: #4a5562;
    --carrier-text: #0f63a6;
    --band: #116bb3;
    --on-band: #ffffff;
    --logo-blue: #0268ae;
    --logo-grey: #4a4a4c;
    --gutter: 0px;
    --measure: 100%;
    --size-title: 24pt;
    --size-heading: 13pt;
    --indent: 9mm;
    --indent-nested: 8mm;
  }

  html {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body {
    font-size: 10pt;
    line-height: 1.5;
  }

  .pdf-link,
  .site-footer {
    display: none;
  }

  .site-header .wrap {
    min-height: 0;
    padding-bottom: 6mm;
  }

  .logo {
    height: 9mm;
  }

  .title-band {
    padding: 9mm 8mm;
  }

  .document {
    padding-block: 8mm 0;
  }

  .lead {
    font-size: 11pt;
    margin-bottom: 9mm;
  }

  .sections {
    gap: 8mm;
  }

  .sections > li > h2 {
    margin-bottom: 3.5mm;
    break-after: avoid;
  }

  .clauses {
    gap: 2mm;
  }

  .clauses .clauses {
    margin-top: 1.5mm;
    gap: 1.2mm;
  }

  .clauses > li:not(:has(.clauses, .definitions, .purposes)),
  .definitions > div:not(:has(.clauses)),
  .purposes tbody,
  .producers tr {
    break-inside: avoid-page;
  }

  .lead,
  .sections > li > h2 + .clauses > li:first-child > p:first-child {
    break-before: avoid;
  }

  .definitions {
    gap: 3mm;
  }

  .definitions dt {
    font-size: 9.5pt;
  }

  .purposes {
    font-size: 9pt;
  }

  .purposes th,
  .purposes td {
    padding: 2.5mm 3mm;
  }

  .purposes th:nth-child(1) {
    width: 22%;
  }

  .producers {
    font-size: 9.5pt;
  }

  .producers th,
  .producers td {
    padding: 1.6mm 3mm;
  }

  .note {
    margin-top: 5mm;
  }

  .purposes th:nth-child(2) {
    width: 36%;
  }

  a {
    text-decoration-thickness: 0.05em;
  }
}

@media (prefers-reduced-motion: reduce) {
  a,
  .pdf-link,
  .theme-switch button {
    transition: none;
  }
}
