/* ==========================================================================
   Platforma kursow - warstwa prezentacji.

   Zalozenie: to produkt sprzedawany firmom, wiec ma wygladac na powazny
   i czytelny, a nie na demo. Zero ozdob, ktore nie niosa informacji.
   Jeden akcent kolorystyczny, duzo swiatla, wyrazna hierarchia naglowkow.

   Zero webfontow i zewnetrznych zasobow - CSP na to nie pozwala, a strona
   ma sie renderowac natychmiast takze na slabym laczu.
   ========================================================================== */

:root {
  color-scheme: light dark;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --fg: #16191d;
  --fg-muted: #5b6470;
  --fg-faint: #78818e;
  --line: #dfe3e8;
  --line-strong: #c7cdd6;

  --accent: #1d4ed8;
  --accent-hover: #1a43b8;
  --accent-soft: #eaf0ff;
  --ok: #12744a;
  --ok-soft: #e6f4ec;
  --warn: #8a5a00;
  --warn-soft: #fdf3e0;
  --danger: #b42318;
  --danger-soft: #fdecea;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 4px 12px rgba(16, 24, 40, .08), 0 2px 4px rgba(16, 24, 40, .04);
  --shell: 1120px;
  --prose: 78ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1b1f26;
    --surface-2: #232830;
    --fg: #e8eaed;
    --fg-muted: #a8b0bb;
    --fg-faint: #8b939f;
    --line: #2c323b;
    --line-strong: #3a414c;
    --accent: #7ea2ff;
    --accent-hover: #9bb6ff;
    --accent-soft: #1e2a45;
    --ok: #5cc99a;
    --ok-soft: #17352a;
    --warn: #e0b45e;
    --warn-soft: #3a2f16;
    --danger: #f08b82;
    --danger-soft: #3d211f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 4px 14px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); font-size: .89em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
pre {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1rem; overflow-x: auto; line-height: 1.5;
}
pre code { background: none; padding: 0; }
hr { border: none; border-top: 1px solid var(--line); margin: 2rem 0; }

.shell { max-width: var(--shell); margin: 0 auto; padding: 0 1.25rem; }

.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--accent);
  color: #fff; padding: .6rem 1rem; z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---------------------------------------------------------------- naglowek */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  display: flex; align-items: center; gap: 1.5rem;
  min-height: 60px; flex-wrap: wrap;
}
.brand {
  font-weight: 700; font-size: 1.05rem; color: var(--fg);
  letter-spacing: -.02em; display: inline-flex; align-items: center; gap: .5rem;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 6px; background: var(--accent);
  color: #fff; display: grid; place-items: center; font-size: .78rem; font-weight: 700;
}
.topnav { display: flex; gap: 1.25rem; margin-left: auto; align-items: center; flex-wrap: wrap; }
.topnav a { color: var(--fg-muted); font-size: .94rem; }
.topnav a:hover, .topnav a[aria-current="page"] { color: var(--fg); text-decoration: none; }
.topnav a[aria-current="page"] { font-weight: 600; }
.topnav form { margin: 0; }

/* ------------------------------------------------------------------- stopka */
.footer {
  border-top: 1px solid var(--line); background: var(--surface);
  margin-top: 4rem; padding: 2rem 0; color: var(--fg-muted); font-size: .9rem;
}
.footer-inner { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

main { padding: 2rem 0 1rem; }

/* -------------------------------------------------------- naglowek strony */
.page-head { margin-bottom: 1.75rem; }
.page-head h1 { margin-bottom: .35rem; }
.page-lead { color: var(--fg-muted); font-size: 1.05rem; max-width: 68ch; margin: 0; }

.crumbs { font-size: .88rem; color: var(--fg-faint); margin: 0 0 .6rem; }
.crumbs a { color: var(--fg-muted); }
.crumbs span { margin: 0 .4rem; }

/* --------------------------------------------------------------------- karty */
.grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 1.35rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; transition: box-shadow .15s, border-color .15s;
}
.card:hover { box-shadow: var(--shadow-lg); border-color: var(--line-strong); }
.card h3 { margin-bottom: .4rem; }
.card h3 a { color: var(--fg); }
.card-sub { color: var(--fg-muted); font-size: .94rem; margin: 0 0 1rem; flex: 1; }
.card-foot {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding-top: .9rem; border-top: 1px solid var(--line); margin-top: auto;
}
.price { font-weight: 700; font-size: 1.05rem; margin-left: auto; }
.price--free { color: var(--ok); }

/* ------------------------------------------------------------------ etykiety */
.meta { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; color: var(--fg-muted); font-size: .88rem; }
.meta-dot { color: var(--line-strong); }

.badge {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem;
  font-weight: 600; padding: .18rem .55rem; border-radius: 999px;
  background: var(--surface-2); color: var(--fg-muted); white-space: nowrap;
}
.badge--ok    { background: var(--ok-soft); color: var(--ok); }
.badge--free  { background: var(--accent-soft); color: var(--accent); }
.badge--warn  { background: var(--warn-soft); color: var(--warn); }
.badge--muted { background: var(--surface-2); color: var(--fg-faint); }

/* ------------------------------------------------------------------ przyciski */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: inherit; font-weight: 600; font-size: .95rem; line-height: 1.2;
  padding: .6rem 1.1rem; border-radius: var(--radius); border: 1px solid transparent;
  background: var(--accent); color: #fff; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn--ghost { background: transparent; color: var(--fg); border-color: var(--line-strong); }
.btn--ghost:hover { background: var(--surface-2); color: var(--fg); }
.btn--link {
  background: none; border: none; color: var(--accent); padding: 0;
  font-weight: 500; text-decoration: underline;
}
.btn--link:hover { background: none; color: var(--accent-hover); }
.btn--danger { color: var(--danger); }
.btn--sm { padding: .35rem .7rem; font-size: .87rem; }
.btn--block { width: 100%; }

/* --------------------------------------------------------------- panele */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden;
}
.panel-head {
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.panel-head h2, .panel-head h3 { margin: 0; }
.panel-body { padding: 1.25rem; }

.syllabus { list-style: none; margin: 0; padding: 0; }
.syllabus li { border-bottom: 1px solid var(--line); }
.syllabus li:last-child { border-bottom: none; }
.syllabus-row {
  display: grid; grid-template-columns: 2.4rem 1fr auto; gap: .9rem;
  align-items: center; padding: .85rem 1.25rem; color: var(--fg);
}
a.syllabus-row:hover { background: var(--surface-2); text-decoration: none; }
.syllabus-no {
  width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--surface-2);
  color: var(--fg-muted); display: grid; place-items: center; font-size: .82rem; font-weight: 600;
}
.syllabus-row--done .syllabus-no { background: var(--ok-soft); color: var(--ok); }
.syllabus-row--current { background: var(--accent-soft); }
.syllabus-row--current .syllabus-no { background: var(--accent); color: #fff; }
.syllabus-title { font-weight: 500; }
.syllabus-sub { color: var(--fg-muted); font-size: .87rem; margin: .1rem 0 0; }
.syllabus-flags { display: flex; gap: .4rem; align-items: center; }

/* --------------------------------------------------------- pasek postepu */
.progress { display: flex; align-items: center; gap: .7rem; }
.progress-bar {
  flex: 1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden;
}
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.progress-fill--done { background: var(--ok); }
.progress-label { font-size: .85rem; color: var(--fg-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------------- uklad lekcji */
.lesson-layout { display: grid; grid-template-columns: 300px 1fr; gap: 2rem; align-items: start; }
@media (max-width: 900px) { .lesson-layout { grid-template-columns: 1fr; } }
.lesson-aside { position: sticky; top: 76px; }
@media (max-width: 900px) { .lesson-aside { position: static; } }

.prose { max-width: var(--prose); }
.prose h2 { margin-top: 2rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); }
.prose h3 { margin-top: 1.6rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin: .35rem 0; }
.prose blockquote {
  margin: 1.2rem 0; padding: .6rem 1.1rem; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 var(--radius) var(--radius) 0;
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose table { border-collapse: collapse; width: 100%; margin: 1.2rem 0; }
.prose th, .prose td { border: 1px solid var(--line); padding: .5rem .7rem; text-align: left; }
.prose th { background: var(--surface-2); font-weight: 600; }

/* ------------------------------------------------------------------- blokada */
.locked-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 2.5rem 2rem; text-align: center; box-shadow: var(--shadow); max-width: 46rem;
}
.locked-icon {
  width: 48px; height: 48px; margin: 0 auto 1rem; border-radius: 50%;
  background: var(--surface-2); display: grid; place-items: center; font-size: 1.3rem;
}
.locked-box p { color: var(--fg-muted); max-width: 42ch; margin-left: auto; margin-right: auto; }
.locked-actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; margin-top: 1.25rem; }

/* ---------------------------------------------------------------- sprawdzian */
.quiz { margin-top: 2.5rem; }
.q-list { list-style: none; margin: 0; padding: 0; }
.q-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 1.35rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.q-item fieldset { border: none; margin: 0; padding: 0; }
.q-prompt { font-weight: 600; margin: 0 0 .9rem; display: block; }
.q-num { color: var(--fg-faint); font-weight: 600; margin-right: .5rem; }
.q-opt {
  display: flex; gap: .7rem; align-items: flex-start; padding: .6rem .8rem;
  border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .5rem; cursor: pointer;
}
.q-opt:hover { background: var(--surface-2); border-color: var(--line-strong); }
.q-opt input { margin: .3rem 0 0; flex: none; accent-color: var(--accent); }
.q-hint { color: var(--fg-faint); font-size: .86rem; margin: .4rem 0 0; }
.q-text-input { width: 100%; max-width: 32rem; }

/* -------------------------------------------------------------------- wynik */
.result {
  border-radius: var(--radius-lg); padding: 1.5rem; margin-bottom: 1.5rem;
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
}
.result--pass { border-left: 4px solid var(--ok); }
.result--fail { border-left: 4px solid var(--warn); }
.result-head { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.result-score { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.result--pass .result-score { color: var(--ok); }
.result--fail .result-score { color: var(--warn); }
.result-note { color: var(--fg-muted); margin: 0; }

.review { list-style: none; margin: 1.25rem 0 0; padding: 0; }
.review-item { border-top: 1px solid var(--line); padding: 1rem 0; }
.review-head { display: flex; gap: .6rem; align-items: flex-start; font-weight: 600; margin: 0 0 .5rem; }
.review-mark { flex: none; width: 1.35rem; height: 1.35rem; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; color: #fff; }
.review-item--ok  .review-mark { background: var(--ok); }
.review-item--bad .review-mark { background: var(--danger); }
.review-opts { list-style: none; margin: 0 0 .5rem 1.95rem; padding: 0; font-size: .93rem; color: var(--fg-muted); }
.review-opts li { padding: .12rem 0; }
.review-opts .is-correct { color: var(--ok); font-weight: 600; }
.review-opts .is-yours { color: var(--danger); }
.review-why {
  margin: .5rem 0 0 1.95rem; padding: .6rem .9rem; background: var(--surface-2);
  border-radius: var(--radius); font-size: .93rem; color: var(--fg-muted);
}

/* ------------------------------------------------------------------ formularze */
.form { display: flex; flex-direction: column; gap: 1.1rem; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }
.form-row > .field { flex: 1 1 12rem; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field > span { font-size: .9rem; font-weight: 600; color: var(--fg); }
.field em { font-style: normal; font-weight: 400; color: var(--fg-faint); }
.field input, .field textarea, .field select {
  font: inherit; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: .55rem .7rem; width: 100%;
}
.field textarea { font-family: var(--mono); font-size: .9rem; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
.check { display: flex; gap: .6rem; align-items: flex-start; }
.check input { margin: .3rem 0 0; accent-color: var(--accent); }
.check span { font-size: .94rem; }

.auth-card {
  max-width: 27rem; margin: 1rem auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 2rem; box-shadow: var(--shadow-lg);
}
.auth-card h1 { font-size: 1.45rem; }
.auth-foot { margin: 1.25rem 0 0; font-size: .92rem; color: var(--fg-muted); text-align: center; }

.alert { padding: .8rem 1rem; border-radius: var(--radius); margin-bottom: 1.25rem; font-size: .94rem; }
.alert--error { background: var(--danger-soft); color: var(--danger); }
.alert--ok    { background: var(--ok-soft); color: var(--ok); }

/* ---------------------------------------------------------------- stan pusty */
.empty {
  text-align: center; padding: 3.5rem 1.5rem; background: var(--surface);
  border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); color: var(--fg-muted);
}
.empty h2 { color: var(--fg); }

/* ------------------------------------------------------------------- tabele */
.table-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: .93rem; }
table.data th, table.data td {
  text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle;
}
table.data th { background: var(--surface-2); font-weight: 600; color: var(--fg-muted); white-space: nowrap; }
table.data tbody tr:hover { background: var(--surface-2); }
.actions { display: flex; gap: .75rem; align-items: center; }
.actions form { margin: 0; }
.code-value { font-family: var(--mono); font-weight: 600; letter-spacing: .04em; }

/* --------------------------------------------------------- nawigacja lekcji */
.lesson-nav {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line);
}

.section { margin-bottom: 2.5rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.section-head h2 { margin: 0; }
