/* Material 3, paleta zasiana kolorem z ikony (niebieski klosz).
   Kolory jako tokeny tonalne, wysokość przez odcień powierzchni
   zamiast ciężkich cieni, stany dotyku przez warstwę stanu (state layer). */

:root {
  color-scheme: light dark;

  --primary: #2c5ea8;
  --on-primary: #ffffff;
  --primary-container: #d8e2ff;
  --on-primary-container: #001a41;

  --surface: #fdfbff;
  --surface-container: #eef0f7;
  --surface-container-high: #e8eaf2;
  --on-surface: #1a1b20;
  --on-surface-variant: #44464f;
  --outline-variant: #c4c6d0;

  --error: #ba1a1a;
  --on-error: #ffffff;
  --error-container: #ffdad6;
  --on-error-container: #410002;

  /* Warstwa stanu: nieprzezroczystość wg specyfikacji M3. */
  --stan-hover: 0.08;
  --stan-press: 0.12;

  --ksztalt-s: 8px;
  --ksztalt-m: 12px;
  --ksztalt-l: 16px;
  --ksztalt-xl: 28px;

  --easing: cubic-bezier(0.2, 0, 0, 1);
  --krok: 8px;

  --font: Roboto, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #aec6ff;
    --on-primary: #002e69;
    --primary-container: #00458f;
    --on-primary-container: #d8e2ff;

    --surface: #111318;
    --surface-container: #1d2024;
    --surface-container-high: #282a2f;
    --on-surface: #e2e2e9;
    --on-surface-variant: #c4c6d0;
    --outline-variant: #44464f;

    --error: #ffb4ab;
    --on-error: #690005;
    --error-container: #93000a;
    --on-error-container: #ffdad6;
  }
}

* { box-sizing: border-box; }

/* Atrybut `hidden` chowa element regułą przeglądarki `[hidden] { display: none }`,
   a reguły autora zawsze ją przebijają. Każde nasze `display` na klasie elementu
   chowanego przez `hidden` (banner, przyciski) unieważniałoby to ukrycie —
   stąd ta reguła z !important. Nie usuwać. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--surface);
  color: var(--on-surface);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* --- skala typograficzna M3 --- */
.headline-small { font-size: 24px; line-height: 32px; font-weight: 500; letter-spacing: 0; }
.title-medium   { font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: 0.15px; }
.body-medium    { font-size: 14px; line-height: 20px; font-weight: 400; letter-spacing: 0.25px; }
.body-small     { font-size: 12px; line-height: 16px; font-weight: 400; letter-spacing: 0.4px; }
.label-large    { font-size: 14px; line-height: 20px; font-weight: 600; letter-spacing: 0.1px; }

/* --- top app bar --- */

.pasek-gorny {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--krok);
  min-height: 64px;
  padding: calc(env(safe-area-inset-top) + 8px) 4px 8px 16px;
  background: var(--surface);
}

.pasek-gorny h1 { margin: 0; font-size: 24px; line-height: 32px; font-weight: 500; }

/* --- przyciski --- */

.przycisk-tekstowy,
.przycisk-wypelniony {
  position: relative;
  font-family: inherit;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  letter-spacing: 0.1px;
  border: 0;
  border-radius: 20px;
  min-height: 40px;
  padding: 10px 24px;
  cursor: pointer;
  overflow: hidden;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.przycisk-tekstowy { background: transparent; color: var(--primary); padding: 10px 12px; }
.przycisk-wypelniony { background: var(--primary); color: var(--on-primary); }
.przycisk-wypelniony.blad { background: var(--error); color: var(--on-error); }
.przycisk-tekstowy.blad { color: var(--error); }

/* Warstwa stanu zamiast zmiany koloru tła — tak działa Material. */
.przycisk-tekstowy::after,
.przycisk-wypelniony::after,
.karta-akcja::after {
  content: "";
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity 100ms var(--easing);
  pointer-events: none;
}

.przycisk-tekstowy:active::after,
.przycisk-wypelniony:active::after,
.karta-akcja:active::after { opacity: var(--stan-press); }

.przycisk-tekstowy:focus-visible,
.przycisk-wypelniony:focus-visible,
.karta-akcja:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.przycisk-wypelniony[disabled],
.przycisk-tekstowy[disabled] { opacity: 0.38; cursor: default; }

.przycisk-pelna-szerokosc { width: 100%; }

/* --- banner: stan trwały, wymagający decyzji --- */

.baner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--krok);
  margin: 0 16px 8px;
  padding: 16px;
  border-radius: var(--ksztalt-m);
  background: var(--surface-container-high);
  color: var(--on-surface);
}

.baner p { margin: 0; flex: 1 1 16ch; font-size: 14px; line-height: 20px; }
.baner.pilny { background: var(--error-container); color: var(--on-error-container); }
.baner.pilny .przycisk-tekstowy { color: var(--on-error-container); }
.baner-akcje { margin-left: auto; display: flex; gap: 4px; }

/* --- siatka kart --- */

.siatka {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: var(--krok);
  padding: 0 16px 16px;
  flex: 1;
  align-content: start;
}

.karta {
  position: relative;
  border-radius: var(--ksztalt-l);
  background: var(--surface-container);
  overflow: hidden;
}

.karta-akcja {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  min-height: 148px;
  padding: 16px;
  border: 0;
  background: none;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

/* Elementy w <button> muszą być liniowe — dlatego jawnie łamiemy je na bloki.
   Bez tego nazwa i status sklejają się w jedną linię. */
.karta-tytul,
.karta-opis { display: block; }

.karta-tytul {
  font-size: 16px;
  line-height: 22px;
  font-weight: 600;
  letter-spacing: 0.15px;
  overflow-wrap: anywhere;
}

.karta-opis {
  margin-top: 4px;
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0.4px;
  color: var(--on-surface-variant);
}

.awatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-container);
  font-size: 24px;
  line-height: 1;
}

.karta-tresc { margin-top: auto; }

.karta.wyciszony { opacity: 0.6; }
.karta.zablokowany .karta-opis { color: var(--primary); font-weight: 600; }

/* --- stan pusty --- */

.pusto {
  grid-column: 1 / -1;
  margin: 0;
  padding: 48px 8px;
  color: var(--on-surface-variant);
  font-size: 14px;
  line-height: 20px;
  max-width: 46ch;
}

/* --- bottom sheet: decyzja pod kciukiem --- */

.warstwa-modalna { position: fixed; inset: 0; z-index: 10; }
.zaslona { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4); }

.arkusz {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 24px calc(24px + env(safe-area-inset-bottom));
  border-radius: var(--ksztalt-xl) var(--ksztalt-xl) 0 0;
  background: var(--surface-container-high);
  animation: wysun 250ms var(--easing);
}

@keyframes wysun { from { transform: translateY(100%); } to { transform: translateY(0); } }

.uchwyt {
  width: 32px;
  height: 4px;
  margin: 0 auto 16px;
  border-radius: 2px;
  background: var(--outline-variant);
}

.arkusz h2 { margin: 0 0 8px; font-size: 22px; line-height: 28px; font-weight: 500; }
.arkusz p { margin: 0 0 24px; font-size: 14px; line-height: 20px; color: var(--on-surface-variant); }
.arkusz-akcje { display: flex; justify-content: flex-end; gap: var(--krok); }

/* --- snackbar: ulotne potwierdzenie --- */

.snackbar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 20;
  padding: 14px 16px;
  border-radius: var(--ksztalt-s);
  background: var(--on-surface);
  color: var(--surface);
  font-size: 14px;
  line-height: 20px;
  animation: podnies 200ms var(--easing);
}

@keyframes podnies { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .arkusz, .snackbar { animation: none; }
}

/* --- ekrany formularzowe --- */

.kolumna { width: 100%; max-width: 34rem; margin: 0 auto; padding: 0 16px 32px; }

.sekcja {
  margin-bottom: var(--krok);
  padding: 24px;
  border-radius: var(--ksztalt-l);
  background: var(--surface-container);
}

.sekcja h2 { margin: 0 0 8px; font-size: 22px; line-height: 28px; font-weight: 500; }
.sekcja p { margin: 0 0 20px; font-size: 14px; line-height: 20px; color: var(--on-surface-variant); }
.sekcja .przycisk-pelna-szerokosc + .przycisk-pelna-szerokosc { margin-top: var(--krok); }

/* Pole tekstowe w stylu "filled" z M3. */
.pole { position: relative; margin-bottom: 16px; }

.pole label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0.4px;
  color: var(--on-surface-variant);
}

.pole input {
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  border: 0;
  border-bottom: 1px solid var(--on-surface-variant);
  border-radius: var(--ksztalt-s) var(--ksztalt-s) 0 0;
  background: var(--surface-container-high);
  color: var(--on-surface);
  font-family: inherit;
  font-size: 16px;
}

.pole input:focus-visible { outline: none; border-bottom: 2px solid var(--primary); }

.lista { list-style: none; margin: 0; padding: 0; }

.lista li {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 12px 0;
  border-bottom: 1px solid var(--outline-variant);
}

.lista li:last-child { border-bottom: 0; }
.lista .tresc { flex: 1; min-width: 0; }
.lista .tytul { font-size: 16px; line-height: 22px; font-weight: 500; }
.lista .opis { margin-top: 2px; font-size: 12px; line-height: 16px; color: var(--on-surface-variant); }

input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--primary); flex: none; }

.rzad { display: flex; gap: var(--krok); align-items: flex-end; flex-wrap: wrap; }
.rzad > * { flex: 1 1 8rem; }
.rzad .waski { flex: 0 0 5rem; }

.stopka { padding: 24px 16px; font-size: 12px; line-height: 16px; color: var(--on-surface-variant); text-align: center; }
