/* ============================================================
   KODPROSTO - "Terminal i edytor" design system
   Palette: GitHub-inspired dark graphite + commit green + syntax blue
   Typography: Syne (display) + Lexend (body) + JetBrains Mono (code)
   ============================================================ */

:root {
  --bg: #f6f4ee;
  --bg-alt: #efece3;
  --bg-code: #0d1117;
  --panel: #ffffff;
  --text: #1c2128;
  --muted: #57606a;
  --accent: #1a7f37;
  --accent-hi: #0e5c28;
  --blue: #0969da;
  --amber: #9a6700;
  --red: #b62324;
  --border: #ddd8cc;
  --border-strong: #c9c3b5;
  --header-bg: #0d1117;
  --header-text: #e6edf3;
  --header-dim: #8b949e;
  --sidebar-bg: #f1eee6;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(28,33,40,.08), 0 4px 14px rgba(28,33,40,.05);
  --shadow-hover: 0 6px 22px rgba(28,33,40,.12);
  --font-display: 'Syne', 'Lexend', sans-serif;
  --font-body: 'Lexend', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --header-height: 60px;
  --sidebar-w: 300px;
  --transition: .2s ease-out;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --bg-alt: #10161d;
    --bg-code: #010409;
    --panel: #161b22;
    --text: #e6edf3;
    --muted: #8b949e;
    --accent: #3fb950;
    --accent-hi: #56d364;
    --blue: #58a6ff;
    --amber: #d29922;
    --red: #f85149;
    --border: #21262d;
    --border-strong: #30363d;
    --header-bg: #010409;
    --header-text: #e6edf3;
    --header-dim: #8b949e;
    --sidebar-bg: #0f141b;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
    --shadow-hover: 0 6px 22px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 600px 400px at 92% -5%, rgba(26,127,55,.08), transparent 60%),
    radial-gradient(ellipse 700px 500px at -8% 108%, rgba(9,105,218,.07), transparent 60%);
  background-attachment: fixed;
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
::selection { background: rgba(26,127,55,.25); }

/* ---------- Header ---------- */
.header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-height);
  background: var(--header-bg);
  color: var(--header-text);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.header::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(63,185,80,.55), transparent);
  opacity: .45; pointer-events: none;
}
.header .inner {
  max-width: 1200px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; gap: 18px; padding: 0 20px;
}
.mark {
  font-family: var(--font-display);
  font-size: 1.25rem; font-weight: 800; letter-spacing: -.02em;
  color: var(--header-text); white-space: nowrap; display: flex; align-items: baseline; gap: 2px;
}
.mark b { color: #3fb950; font-weight: 800; }
.mark small {
  font-family: var(--font-mono); font-size: .6rem; font-weight: 400;
  color: var(--header-dim); margin-left: 6px; letter-spacing: .08em; text-transform: uppercase;
}
.searchbox {
  flex: 1; max-width: 420px; margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 8px; padding: 7px 12px; color: var(--header-dim);
}
.searchbox:focus-within { border-color: #3fb950; box-shadow: 0 0 0 3px rgba(63,185,80,.18); }
.searchbox input {
  width: 100%; background: transparent; border: none; outline: none;
  color: var(--header-text); font-family: var(--font-body); font-size: .9rem;
}
.searchbox input::placeholder { color: var(--header-dim); }
.burger {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px; padding: 9px 10px; cursor: pointer;
}
.burger span { display: block; width: 20px; height: 2px; background: var(--header-text); border-radius: 2px; transition: var(--transition); }
.burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger.open span:nth-child(2) { opacity: 0; }
.burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Layout ---------- */
.page-wrap { display: flex; max-width: 1200px; margin: 0 auto; padding-top: calc(var(--header-height) + 14px); }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  position: sticky; top: calc(var(--header-height) + 14px);
  height: calc(100vh - var(--header-height) - 28px);
  overflow-y: auto; padding: 10px 18px 30px 6px;
  background: transparent;
}
.main { flex: 1; min-width: 0; padding: 0 26px 60px; }
.main-inner { max-width: 780px; }

/* ---------- Sidebar ---------- */
.sidebar-sec {
  font-family: var(--font-mono);
  font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin: 20px 0 6px; padding-left: 8px;
  display: flex; align-items: center; gap: 6px;
}
.sidebar-sec .n {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  font-size: .65rem; font-weight: 700;
  color: var(--accent); background: rgba(26,127,55,.12);
  border: 1px solid rgba(26,127,55,.3); border-radius: 5px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 9px;
  font-size: .9rem; line-height: 1.35; color: var(--text);
  padding: 7px 10px; border-radius: 8px; margin-bottom: 1px;
  border-left: 2px solid transparent;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.sidebar-link .ic { font-size: .95rem; flex-shrink: 0; width: 22px; text-align: center; }
.sidebar-link:hover { background: var(--bg-alt); text-decoration: none; transform: translateX(2px); }
.sidebar-link.active {
  background: rgba(26,127,55,.1);
  border-left-color: var(--accent);
  font-weight: 600;
}
.sidebar a.sidebar-link:first-child { margin-top: 4px; }

/* ---------- Hero ---------- */
.home-hero {
  position: relative;
  background: var(--header-bg);
  color: #e6edf3;
  border-radius: var(--radius);
  padding: 40px 38px 34px;
  margin-bottom: 44px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.07);
}
.home-hero::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 500px 300px at 88% 8%, rgba(63,185,80,.14), transparent 60%),
    radial-gradient(ellipse 400px 300px at 4% 100%, rgba(88,166,255,.12), transparent 60%);
  pointer-events: none;
}
.home-hero .label {
  font-family: var(--font-mono); font-size: .72rem; letter-spacing: .14em;
  text-transform: uppercase; color: #3fb950; margin-bottom: 10px;
}
.home-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4.4vw, 2.9rem);
  font-weight: 800; line-height: 1.12; letter-spacing: -.02em;
  text-wrap: balance; margin-bottom: 14px;
}
.home-hero h1 em { font-style: normal; color: #58a6ff; }
.home-hero .lead { font-size: 1.05rem; line-height: 1.65; color: #b7c0ca; max-width: 620px; margin-bottom: 22px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }

/* ---------- Code window (signature) ---------- */
.code-window {
  margin-top: 6px;
  background: #010409;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  overflow: hidden;
  font-family: var(--font-mono);
  max-width: 560px;
  box-shadow: 0 8px 30px rgba(0,0,0,.45);
}
.code-titlebar {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 12px;
  background: rgba(255,255,255,.04);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.code-titlebar .dot { width: 11px; height: 11px; border-radius: 50%; }
.code-titlebar .dot.r { background: #f85149; }
.code-titlebar .dot.y { background: #d29922; }
.code-titlebar .dot.g { background: #3fb950; }
.code-titlebar .fname {
  margin-left: 8px; font-size: .72rem; color: #8b949e;
  letter-spacing: .03em;
}
.code-body { padding: 14px 16px; font-size: .84rem; line-height: 1.75; overflow-x: auto; }
.code-body .ln { display: block; white-space: pre; }
.code-body .cm { color: #6e7681; font-style: italic; }
.code-body .kw { color: #ff7b72; }
.code-body .fn { color: #d2a8ff; }
.code-body .str { color: #a5d6ff; }
.code-body .num { color: #79c0ff; }
.code-body .var { color: #ffa657; }
.code-body .ok { color: #3fb950; }
.code-body .cursor {
  display: inline-block; width: 8px; height: 15px;
  background: #3fb950; vertical-align: text-bottom;
  animation: blink 1.1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.code-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.code-chip {
  font-family: var(--font-mono); font-size: .72rem;
  color: #58a6ff; border: 1px solid rgba(88,166,255,.35);
  background: rgba(88,166,255,.08);
  padding: 4px 10px; border-radius: 6px; letter-spacing: .03em;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  font-family: var(--font-body); font-weight: 600; font-size: .92rem;
  padding: 10px 18px; border-radius: 8px;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: #238636; color: #fff; }
.btn-primary:hover { background: #2ea043; box-shadow: 0 4px 14px rgba(46,160,67,.35); }
.btn-blue { background: #1f6feb; color: #fff; }
.btn-blue:hover { background: #388bfd; box-shadow: 0 4px 14px rgba(56,139,253,.35); }
.btn-ghost {
  background: transparent; color: #c9d1d9;
  border: 1px solid rgba(255,255,255,.25);
}
.btn-ghost:hover { border-color: #3fb950; color: #3fb950; }

/* ---------- Home sections & cards ---------- */
.home-sec { margin-bottom: 40px; }
.home-sec-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
}
.home-sec-head h2 {
  font-family: var(--font-display);
  font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em;
  display: flex; align-items: center; gap: 10px;
}
.home-sec-head h2 .sec-no {
  font-family: var(--font-mono); font-size: .7rem; font-weight: 500;
  color: var(--accent); border: 1px solid rgba(26,127,55,.35);
  border-radius: 5px; padding: 2px 7px;
  background: rgba(26,127,55,.08);
}
.home-sec-head .count { font-family: var(--font-mono); font-size: .72rem; color: var(--muted); }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.home-card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
  color: var(--text);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.home-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--border-strong); text-decoration: none; }
.home-card .ico { font-size: 1.4rem; line-height: 1; }
.home-card h3 { font-size: .95rem; font-weight: 600; line-height: 1.4; text-wrap: balance; }
.home-card p { font-size: .85rem; color: var(--muted); line-height: 1.55; flex: 1; }
.home-card .go {
  font-size: .8rem; font-weight: 600; color: var(--accent);
  display: inline-flex; align-items: center; gap: 5px;
}
.home-card:hover .go { text-decoration: underline; }

.home-note {
  display: flex; gap: 12px; align-items: flex-start;
  background: rgba(26,127,55,.08);
  border: 1px solid rgba(26,127,55,.25);
  border-radius: 8px; padding: 14px 16px;
  font-size: .92rem; color: var(--text);
  margin-top: 34px;
}

/* ---------- Article ---------- */
.article .meta {
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center;
  font-family: var(--font-mono); font-size: .72rem; color: var(--muted);
  margin-bottom: 12px;
}
.article .meta .tag {
  color: var(--accent);
  border: 1px solid rgba(26,127,55,.35);
  background: rgba(26,127,55,.08);
  padding: 2px 9px; border-radius: 5px; letter-spacing: .05em; text-transform: uppercase;
}
.article h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.4vw, 2.3rem);
  font-weight: 800; line-height: 1.15; letter-spacing: -.02em;
  text-wrap: balance; margin-bottom: 22px;
}
.article h2 {
  font-family: var(--font-display);
  font-size: 1.28rem; font-weight: 700; letter-spacing: -.01em;
  margin: 34px 0 12px; padding-top: 6px;
  scroll-margin-top: calc(var(--header-height) + 16px);
}
.article h2::before { content: '// '; color: var(--accent); font-family: var(--font-mono); font-weight: 500; }
.article h3 { font-size: 1.06rem; font-weight: 700; margin: 24px 0 8px; }
.article p { margin-bottom: 14px; }
.article ul, .article ol { margin: 0 0 16px 24px; }
.article li { margin-bottom: 7px; }
.article li::marker { color: var(--accent); }
.article strong { color: var(--text); }
.article code {
  font-family: var(--font-mono); font-size: .85em;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px;
  color: var(--accent-hi);
}
@media (prefers-color-scheme: dark) { .article code { color: #7ee787; } }
.article pre {
  background: var(--bg-code); color: #e6edf3;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 8px; padding: 14px 16px;
  font-family: var(--font-mono); font-size: .84rem; line-height: 1.7;
  overflow-x: auto; margin-bottom: 18px;
}
.article pre code { background: none; border: none; color: inherit; padding: 0; font-size: inherit; }
.article pre .cm { color: #6e7681; }
.article pre .kw { color: #ff7b72; }
.article pre .str { color: #a5d6ff; }
.article pre .num { color: #79c0ff; }
.article pre .fn { color: #d2a8ff; }
.article pre .var { color: #ffa657; }

/* ---------- TOC ---------- */
.toc {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 14px 18px; margin: 6px 0 26px;
}
.toc h3 {
  font-family: var(--font-mono); font-size: .75rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 8px;
}
.toc ol { margin: 0 0 0 18px; }
.toc li { margin-bottom: 5px; font-size: .92rem; }
.toc a { color: var(--text); }
.toc a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Info boxes ---------- */
.info-box {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue);
  border-radius: 8px;
  padding: 13px 16px; margin: 16px 0;
  font-size: .95rem;
}
.info-box .ib-ic { font-size: 1.1rem; line-height: 1.4; flex-shrink: 0; }
.info-box.green { border-left-color: var(--accent); }
.info-box.amber { border-left-color: var(--amber); }
.info-box.red { border-left-color: var(--red); }
.info-box b { display: block; margin-bottom: 2px; }

/* ---------- Tables ---------- */
.table-responsive { overflow-x: auto; margin: 16px 0; }
table.data-table {
  width: 100%; border-collapse: collapse; font-size: .92rem;
  background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
table.data-table th, table.data-table td {
  padding: 10px 13px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--border);
}
table.data-table th {
  font-family: var(--font-mono); font-size: .74rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
  background: var(--bg-alt);
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: rgba(26,127,55,.05); }
table.data-table td:first-child { font-weight: 600; }
.error-table td:first-child { font-family: var(--font-mono); color: var(--red); font-size: .88rem; }

/* ---------- FAQ ---------- */
.faq-item {
  border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 10px; overflow: hidden;
  background: var(--panel);
}
.faq-item summary {
  cursor: pointer; padding: 13px 16px;
  font-weight: 600; font-size: .98rem;
  list-style: none; display: flex; justify-content: space-between; gap: 10px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; font-family: var(--font-mono); color: var(--accent); font-size: 1.1rem; }
.faq-item[open] summary::after { content: '−'; }
.faq-item summary:hover { background: var(--bg-alt); }
.faq-item .faq-a { padding: 0 16px 14px; font-size: .95rem; color: var(--muted); }
.faq-item .faq-a p { margin-bottom: 8px; }

/* ---------- Glossary ---------- */
.glossary { margin: 16px 0; }
.glossary dt {
  font-weight: 700; font-size: 1rem; margin-top: 16px;
  display: flex; align-items: baseline; gap: 8px;
}
.glossary dt code {
  font-family: var(--font-mono); font-size: .72rem;
  color: var(--blue); background: none; border: none; padding: 0;
}
.glossary dd { margin: 4px 0 0; font-size: .95rem; color: var(--muted); }

/* ---------- Checklist ---------- */
.checklist { list-style: none; margin: 16px 0 16px 4px !important; }
.checklist li { padding-left: 34px; position: relative; margin-bottom: 11px; }
.checklist li::before {
  content: '▢'; position: absolute; left: 0; top: 0;
  font-size: 1.1rem; color: var(--accent);
}
.checklist li b { color: var(--text); }

/* ---------- Footer / misc ---------- */
.article .footer {
  margin-top: 40px; padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: space-between;
  font-family: var(--font-mono); font-size: .72rem; color: var(--muted);
}
.error-page { text-align: center; padding: 70px 20px; }
.error-page h1 { font-family: var(--font-display); font-size: 3.4rem; color: var(--accent); }
.error-page p { margin: 12px 0 20px; color: var(--muted); }
.error-page a { font-weight: 600; }

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: #fff;
  padding: 8px 16px; border-radius: 0 0 8px 0; z-index: 200;
}
.skip-link:focus { left: 0; }

/* ---------- Motion ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp .28s ease-out both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: var(--header-height); left: 0; bottom: 0; z-index: 90;
    width: min(320px, 86vw);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    transform: translateX(-102%);
    transition: transform .24s ease-out;
    padding: 16px 18px 40px;
    box-shadow: var(--shadow-hover);
  }
  .sidebar.open { transform: translateX(0); }
  .burger { display: flex; }
  .main { padding: 0 16px 50px; }
  .home-hero { padding: 30px 22px 26px; }
}

@media (max-width: 600px) {
  body { font-size: 16.5px; }
  .header .inner { gap: 10px; padding: 0 12px; }
  .searchbox { max-width: 100%; }
  .home-grid { grid-template-columns: 1fr; }
  .hero-cta .btn { flex: 1 1 100%; text-align: center; }
  .code-body { font-size: .78rem; }
}

/* Focus visible */
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px;
}
