/* ==========================================================================
   policzprocent.pl — Kalkulator procentowy
   Czysty CSS, mobile-first, bez zewnętrznych zależności
   ========================================================================== */

/* ---------- 1. Zmienne motywu ---------- */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.09);
  --up: #059669;
  --up-soft: rgba(5, 150, 105, 0.1);
  --down: #dc2626;
  --down-soft: rgba(220, 38, 38, 0.1);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 24px rgba(15, 23, 42, 0.07);
  --radius: 14px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --header-h: 60px;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111a2c;
  --surface-2: #162034;
  --text: #e8eefb;
  --muted: #94a3b8;
  --border: #24314a;
  --accent: #60a5fa;
  --accent-strong: #93c5fd;
  --accent-soft: rgba(96, 165, 250, 0.14);
  --up: #34d399;
  --up-soft: rgba(52, 211, 153, 0.14);
  --down: #f87171;
  --down-soft: rgba(248, 113, 113, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.45);
}

/* ---------- 2. Reset ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

p { margin: 0; }

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100;
}

.skip-link:focus { left: 0; }

/* ---------- 3. Layout ---------- */
.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

.container--narrow { max-width: 780px; }

.section { padding: 48px 0; }

.section--muted {
  background: var(--surface);
  border-block: 1px solid var(--border);
}

.section__head {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
}

.section__title {
  font-size: clamp(1.35rem, 1.1rem + 1.2vw, 1.9rem);
}

.section__lead {
  margin-top: 10px;
  color: var(--muted);
  max-width: 62ch;
}

.notice {
  padding: 12px 14px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.92rem;
}

/* ---------- 4. Nagłówek ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.02em;
}

.brand:hover { text-decoration: none; }

.brand__mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
}

.brand__tld { color: var(--muted); font-weight: 500; }

.theme-toggle {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover { border-color: var(--accent); }

.theme-toggle__icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: inset -5px -2px 0 0 var(--surface);
}

[data-theme="dark"] .theme-toggle__icon {
  box-shadow: inset 5px 2px 0 0 var(--surface);
}

/* ---------- 5. Hero ---------- */
.hero {
  padding: 40px 0 8px;
  text-align: center;
}

.hero__title {
  font-size: clamp(1.7rem, 1.3rem + 2.4vw, 2.7rem);
  font-weight: 800;
}

.hero__lead {
  margin: 14px auto 0;
  max-width: 60ch;
  color: var(--muted);
  font-size: clamp(0.98rem, 0.94rem + 0.3vw, 1.08rem);
}

.hero__lead strong { color: var(--text); }

.hero__badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.hero__badges li {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
}

/* ---------- 6. Wybór dokładności ---------- */
.precision {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--muted);
}

.select {
  padding: 8px 30px 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E")
    no-repeat right 11px center / 10px;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

/* ---------- 7. Karty kalkulatorów ---------- */
.cards {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

.card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card__head { margin-bottom: 16px; }

.card__title {
  font-size: 1.08rem;
  font-weight: 700;
}

.card__desc {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.fields {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.field__label,
.field label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.field__control {
  position: relative;
  display: flex;
  align-items: center;
}

.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field__suffix {
  position: absolute;
  right: 14px;
  color: var(--muted);
  font-size: 0.95rem;
  pointer-events: none;
}

.field__control:has(.field__suffix) .input { padding-right: 34px; }

/* ---------- 8. Wynik ---------- */
.result {
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.result.is-active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.result__label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result__value {
  margin-top: 4px;
  color: var(--accent);
  font-size: clamp(1.5rem, 1.3rem + 1.2vw, 1.9rem);
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.result__value--secondary {
  font-size: clamp(1.25rem, 1.1rem + 0.9vw, 1.6rem);
}

.result__value.is-up { color: var(--up); }
.result__value.is-down { color: var(--down); }

.result__divider {
  height: 1px;
  margin: 14px 0;
  border: 0;
  background: var(--border);
}

.result__formula {
  margin-top: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.error {
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--down) 40%, transparent);
  border-radius: var(--radius-sm);
  background: var(--down-soft);
  color: var(--down);
  font-size: 0.85rem;
}

.card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 14px;
}

.btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.btn--ghost { color: var(--muted); }

.btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.is-flashed {
  border-color: var(--up);
  color: var(--up);
}

/* ---------- 8.1 Progi ocen — blok "grades-table" (karta Procentownik ocen) ---------- */
.grades-table__caption {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.grades-table {
  width: 100%;
  margin-bottom: 16px;
  border-collapse: collapse;
  color: var(--muted);
  font-size: 0.82rem;
}

.grades-table__head {
  padding: 6px 8px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  text-align: left;
}

.grades-table__cell {
  padding: 6px 8px;
  border: 1px solid var(--border);
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.grades-table__progi {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  grid-template-columns: repeat(2, 1fr);
}

.grades-table__progi .input {
  padding: 9px 6px;
  font-size: 0.95rem;
  text-align: center;
}

.grades-table__toggle {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}

.grades-table__toggle input { margin-top: 4px; }

.grades-table__batch {
  min-height: 120px;
  margin-bottom: 16px;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
}

@media (min-width: 560px) {
  .grades-table__progi { grid-template-columns: repeat(5, 1fr); }
}

/* ---------- 9. Poradnik ---------- */
.guides {
  display: grid;
  gap: 16px;
  margin-top: 22px;
  grid-template-columns: 1fr;
}

.guide {
  padding: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.guide__title { font-size: 1rem; }

.formula {
  margin: 10px 0 12px;
  padding: 9px 12px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--accent-soft);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.83rem;
  overflow-wrap: anywhere;
}

.guide__calc {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--muted);
}

.guide__calc strong { color: var(--accent); }

.guide__hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.note {
  margin-top: 20px;
  padding: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.note__title { font-size: 1rem; }

.note p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.93rem;
}

/* ---------- 10. FAQ ---------- */
.faq {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.faq__item + .faq__item { border-top: 1px solid var(--border); }

.faq__question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  font-weight: 600;
  font-size: 0.97rem;
  cursor: pointer;
  list-style: none;
}

.faq__question::-webkit-details-marker { display: none; }

.faq__question::after {
  content: "+";
  flex: none;
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1;
}

.faq__item[open] .faq__question::after { content: "–"; }

.faq__question:hover { color: var(--accent); }

.faq__answer {
  padding: 0 18px 16px;
  color: var(--muted);
  font-size: 0.93rem;
}

/* ---------- 11. Stopka ---------- */
.site-footer {
  padding: 32px 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.site-footer__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.site-footer__brand { font-weight: 700; }

.site-footer__nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  font-size: 0.9rem;
}

.site-footer__note {
  color: var(--muted);
  font-size: 0.82rem;
}

/* ---------- 12. Media queries ---------- */
@media (min-width: 560px) {
  .fields { grid-template-columns: 1fr 1fr; }
  .hero { padding-top: 52px; }
  .section__head {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

@media (min-width: 760px) {
  .section { padding: 64px 0; }
  .cards { grid-template-columns: 1fr 1fr; }
  .guides { grid-template-columns: 1fr 1fr; }
  .site-footer__inner { gap: 12px; }
}

@media (min-width: 1024px) {
  .cards { gap: 20px; }
  .card { padding: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
