/* ============================================================
   Onko - design system
   Paleta: sosnowa zieleń (zaufanie, zdrowie) + krem (człowiek)
   + bursztyn (nadzieja). Typografia: Lora (display) + Manrope (body).
   ============================================================ */

:root {
  /* paleta */
  --pine-900: #0a2e2a;
  --pine-800: #0c3b36;
  --pine-700: #0e5e54;
  --pine-600: #14705f;
  --teal-500: #2d8f7d;
  --teal-400: #4db6a5;
  --sage-200: #d9e6de;
  --sage-100: #e7efe9;
  --sage-50:  #f1f6f2;
  --amber-700: #b85c1a;
  --amber-600: #d9772e;
  --amber-500: #e8965a;
  --amber-100: #fbe9d7;
  --cream-100: #efeadd;
  --cream-50:  #f7f4ec;
  --ink-900: #1e2c29;
  --ink-700: #33443f;
  --ink-500: #5c6f6a;
  --white: #ffffff;
  --danger: #b3392e;
  --danger-bg: #fbeae7;

  /* typografia */
  --font-display: 'Lora', Georgia, 'Times New Roman', serif;
  --font-body: 'Manrope', 'Segoe UI', system-ui, -apple-system, sans-serif;

  /* wymiary */
  --header-h: 64px;
  --sidebar-w: 320px;
  --radius: 14px;
  --radius-sm: 9px;
  --content-max: 780px;

  /* efekty */
  --shadow-sm: 0 1px 3px rgba(10, 46, 42, .08);
  --shadow-md: 0 6px 24px rgba(10, 46, 42, .10);
  --shadow-card: 0 2px 10px rgba(10, 46, 42, .07);
  --shadow-card-hover: 0 10px 28px rgba(10, 46, 42, .14);
  --transition: all .2s ease-out;

  /* tła */
  --bg: var(--cream-50);
  --bg-card: var(--white);
  --bg-subtle: var(--sage-50);
  --border: #e3ded2;
  --text: var(--ink-900);
  --text-muted: var(--ink-500);
  --accent: var(--pine-700);
  --accent-strong: var(--pine-800);
  --accent-soft: var(--sage-100);
  --link: var(--pine-700);
  --header-bg: var(--pine-900);
  --header-text: #f2efe6;
  --footer-bg: var(--pine-900);
  --footer-text: #cfd8d3;
  --hero-bg: linear-gradient(150deg, #0a2e2a 0%, #0e5e54 55%, #14705f 100%);
  --hero-text: #f5f2e9;
  --hero-sub: #cfddd6;
  --code-bg: var(--sage-100);
  --toc-bg: var(--sage-50);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1412;
    --bg-card: #131d1a;
    --bg-subtle: #16211e;
    --border: #24332f;
    --text: #e9e6dc;
    --text-muted: #a9b8b2;
    --accent: var(--teal-400);
    --accent-strong: #7cc9b8;
    --accent-soft: #182521;
    --link: var(--teal-400);
    --header-bg: #081d1a;
    --header-text: #e9e6dc;
    --footer-bg: #081d1a;
    --footer-text: #a9b8b2;
    --hero-bg: linear-gradient(150deg, #081d1a 0%, #0b3b36 55%, #0e5e54 100%);
    --hero-text: #f2efe6;
    --hero-sub: #b8c8c2;
    --code-bg: #182521;
    --toc-bg: #131d1a;
    --shadow-card: 0 2px 10px rgba(0,0,0,.35);
    --shadow-card-hover: 0 10px 28px rgba(0,0,0,.5);
    --danger-bg: #2e1a18;
    --amber-100: #33241a;
  }
}

/* ---------- reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 700px 420px at -10% -5%, rgba(45, 143, 125, .10), transparent 60%),
    radial-gradient(ellipse 700px 420px at 110% 105%, rgba(217, 119, 46, .08), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; }
a { color: var(--link); }
:focus-visible { outline: 3px solid var(--amber-600); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--amber-600); color: #fff;
  padding: 10px 16px; z-index: 200; border-radius: 0 0 8px 0;
  font-weight: 700; text-decoration: none;
}
.skip-link:focus { left: 0; }

/* ---------- header ---------- */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: var(--header-bg);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.app-header::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(232, 150, 90, .45), transparent);
  opacity: .5;
}
.header-inner {
  max-width: 1280px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; gap: 18px; padding: 0 20px;
}
.menu-toggle {
  display: none; background: none; border: none; color: var(--header-text);
  cursor: pointer; padding: 8px; border-radius: 8px;
}
.menu-toggle:hover { background: rgba(255,255,255,.1); }
.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--header-text); text-decoration: none;
  font-family: var(--font-display); font-size: 1.35rem; font-weight: 700;
  letter-spacing: .2px; white-space: nowrap;
}
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--amber-600), var(--amber-500));
  color: #fff; font-size: 1.05rem; font-weight: 800;
  box-shadow: 0 2px 8px rgba(217,119,46,.4);
}
.brand-name em { font-style: normal; color: var(--amber-500); }
.search-wrap { position: relative; margin-left: auto; width: min(360px, 40vw); }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
#searchInput {
  width: 100%; height: 40px; padding: 0 14px 0 38px;
  border: 1px solid rgba(255,255,255,.16); border-radius: 10px;
  background: rgba(255,255,255,.08); color: var(--header-text);
  font-family: var(--font-body); font-size: .95rem; outline: none;
  transition: var(--transition);
}
#searchInput::placeholder { color: rgba(242,239,230,.55); }
#searchInput:focus { border-color: var(--amber-500); background: rgba(255,255,255,.12); }
.search-results {
  position: absolute; top: 48px; left: 0; right: 0; z-index: 120;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-md);
  max-height: 380px; overflow-y: auto;
}
.search-result {
  display: block; padding: 10px 14px; text-decoration: none;
  border-bottom: 1px solid var(--border); color: var(--text);
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--accent-soft); }
.sr-title { display: block; font-weight: 600; font-size: .92rem; }
.sr-excerpt { display: block; font-size: .8rem; color: var(--text-muted); margin-top: 2px; }

/* ---------- layout ---------- */
.layout {
  display: flex; max-width: 1280px; margin: 0 auto;
  padding: calc(var(--header-h) + 24px) 20px 40px;
  gap: 28px; align-items: flex-start;
}
.sidebar {
  position: sticky; top: calc(var(--header-h) + 24px);
  width: var(--sidebar-w); flex-shrink: 0;
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto; padding: 6px 14px 20px 0;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.home-link { font-weight: 700; }
.nav-section {
  margin: 18px 0 6px; padding: 0 12px;
  font-size: .7rem; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-muted);
}
.sidebar-link {
  display: block; padding: 7px 12px; border-radius: 8px;
  font-size: .9rem; line-height: 1.45; color: var(--text);
  text-decoration: none; transition: var(--transition);
}
.sidebar-link:hover { background: var(--accent-soft); color: var(--link); }
.sidebar-link.active {
  background: var(--accent-soft); color: var(--accent-strong);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--amber-600);
}
.sidebar-foot {
  margin-top: 22px; padding: 12px; font-size: .78rem; line-height: 1.55;
  color: var(--text-muted); background: var(--bg-subtle);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.sidebar-overlay { display: none; }

.main { flex: 1; min-width: 0; }

/* ---------- hero (home) ---------- */
.home-hero {
  background: var(--hero-bg); color: var(--hero-text);
  border-radius: 20px; padding: 46px 44px 40px;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-md);
  animation: fadeUp .3s ease-out;
}
.home-hero::before {
  content: ''; position: absolute; top: -80px; right: -60px;
  width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle, rgba(232,150,90,.28), transparent 65%);
  pointer-events: none;
}
.home-hero::after {
  content: ''; position: absolute; bottom: -100px; left: -40px;
  width: 280px; height: 280px; border-radius: 50%;
  background: radial-gradient(circle, rgba(77,182,165,.22), transparent 65%);
  pointer-events: none;
}
.hero-eyebrow {
  display: inline-block; font-size: .8rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--amber-500); margin-bottom: 14px;
}
.home-hero h1 {
  font-family: var(--font-display); font-size: clamp(1.7rem, 3.6vw, 2.6rem);
  line-height: 1.22; margin: 0 0 14px; font-weight: 700;
  text-wrap: balance; max-width: 640px; position: relative; z-index: 1;
}
.home-hero h1 .gold { color: var(--amber-500); }
.hero-sub {
  font-size: 1.06rem; line-height: 1.65; color: var(--hero-sub);
  max-width: 620px; margin: 0 0 26px; position: relative; z-index: 1;
}
.hero-stats {
  display: flex; gap: 26px; flex-wrap: wrap;
  position: relative; z-index: 1;
}
.hero-stat { display: flex; flex-direction: column; gap: 2px; }
.hs-num {
  font-family: var(--font-display); font-size: 1.7rem; font-weight: 700;
  color: var(--amber-500); line-height: 1.1;
}
.hs-label { font-size: .82rem; color: var(--hero-sub); max-width: 150px; }

/* ---------- home sections / cards ---------- */
.home-section { margin-top: 42px; animation: fadeUp .35s ease-out both; }
.home-section h2 {
  font-family: var(--font-display); font-size: 1.45rem; font-weight: 700;
  margin: 0 0 18px; padding-bottom: 8px; text-wrap: balance;
  border-bottom: 2px solid var(--border);
  position: relative;
}
.home-section h2::after {
  content: ''; position: absolute; left: 0; bottom: -2px;
  width: 64px; height: 2px; background: var(--amber-600);
}
.home-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.home-card {
  display: block; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 18px 14px;
  text-decoration: none; color: var(--text);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  animation: fadeUp .35s ease-out both;
}
.home-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--teal-500);
}
.card-icon { font-size: 1.5rem; display: block; margin-bottom: 8px; }
.home-card h3 {
  font-size: .95rem; font-weight: 700; line-height: 1.4;
  margin: 0 0 6px; text-wrap: balance;
}
.home-card p {
  font-size: .85rem; line-height: 1.55; color: var(--text-muted);
  margin: 0 0 10px;
}
.card-more {
  font-size: .8rem; font-weight: 700; color: var(--link);
  display: inline-flex; align-items: center; gap: 4px;
  transition: var(--transition);
}
.home-card:hover .card-more { gap: 8px; color: var(--amber-700); }

/* ---------- article ---------- */
.content-article {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: 40px 44px;
  box-shadow: var(--shadow-card);
  animation: fadeUp .3s ease-out;
}
.article-meta {
  display: flex; align-items: center; gap: 12px;
  font-size: .82rem; color: var(--text-muted); margin-bottom: 14px;
}
.badge {
  display: inline-block; background: var(--accent-soft); color: var(--accent-strong);
  font-weight: 700; font-size: .74rem; letter-spacing: .04em;
  padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--border);
}
.content-article h1 {
  font-family: var(--font-display); font-size: clamp(1.65rem, 3vw, 2.3rem);
  line-height: 1.25; margin: 0 0 8px; font-weight: 700; text-wrap: balance;
}
.content-article h2 {
  font-family: var(--font-display); font-size: 1.4rem; font-weight: 700;
  margin: 38px 0 14px; padding-top: 22px; text-wrap: balance;
  border-top: 1px solid var(--border);
}
.content-article h2:first-of-type { border-top: none; padding-top: 0; }
.content-article h3 {
  font-size: 1.08rem; font-weight: 700; margin: 26px 0 10px; text-wrap: balance;
}
.content-article p { margin: 0 0 16px; }
.content-article ul, .content-article ol { margin: 0 0 16px; padding-left: 24px; }
.content-article li { margin-bottom: 6px; }
.content-article strong { font-weight: 700; }

.toc {
  background: var(--toc-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px 20px; margin: 22px 0 10px;
}
.toc-title {
  font-weight: 800; font-size: .82rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px;
}
.toc a {
  display: block; padding: 3px 0; font-size: .92rem;
  text-decoration: none; color: var(--text);
  border-bottom: 1px dashed var(--border);
  transition: var(--transition);
}
.toc a:last-child { border-bottom: none; }
.toc a:hover { color: var(--link); padding-left: 6px; }

/* ---------- components ---------- */
.info-box {
  background: var(--accent-soft); border-left: 4px solid var(--teal-500);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px 20px; margin: 20px 0;
  font-size: .96rem; line-height: 1.65;
}
.warn-box {
  background: var(--danger-bg); border-left: 4px solid var(--danger);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px 20px; margin: 20px 0;
  font-size: .96rem; line-height: 1.65;
}
.tip-box {
  background: var(--amber-100); border-left: 4px solid var(--amber-600);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px 20px; margin: 20px 0;
  font-size: .96rem; line-height: 1.65;
}
.info-box strong, .warn-box strong, .tip-box strong { display: block; margin-bottom: 4px; }

.table-responsive { overflow-x: auto; margin: 20px 0; border-radius: var(--radius-sm); }
table {
  width: 100%; border-collapse: collapse; font-size: .92rem;
  background: var(--bg-card);
}
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th {
  background: var(--pine-900); color: #f2efe6;
  font-weight: 700; font-size: .85rem; letter-spacing: .02em;
}
tr:hover td { background: var(--accent-soft); }
td:first-child { font-weight: 600; }

.faq-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px 20px; margin: 14px 0; background: var(--bg-card);
}
.faq-item summary {
  cursor: pointer; font-weight: 700; font-size: 1rem;
  list-style: none; position: relative; padding-right: 28px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+'; position: absolute; right: 4px; top: 0;
  font-size: 1.3rem; font-weight: 400; color: var(--amber-600);
  transition: var(--transition);
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p { margin: 12px 0 0; }

dl.glossary { margin: 0; }
dl.glossary dt {
  font-weight: 700; margin-top: 18px; padding-bottom: 4px;
  border-bottom: 1px dashed var(--border);
}
dl.glossary dt:first-child { margin-top: 0; }
dl.glossary dd { margin: 6px 0 0; font-size: .95rem; color: var(--text); }

.article-nav {
  display: flex; justify-content: space-between; gap: 16px;
  margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--border);
}
.nav-prev, .nav-next {
  text-decoration: none; font-weight: 700; font-size: .92rem;
  color: var(--link); max-width: 46%; line-height: 1.45;
  transition: var(--transition);
}
.nav-prev:hover, .nav-next:hover { color: var(--amber-700); }
.nav-next { text-align: right; margin-left: auto; }

/* ---------- footer ---------- */
.app-footer {
  background: var(--footer-bg); color: var(--footer-text);
  margin-top: 20px; padding: 34px 20px 40px;
}
.footer-inner { max-width: 1280px; margin: 0 auto; }
.app-footer p { margin: 0 0 8px; font-size: .92rem; line-height: 1.65; }
.app-footer strong { color: var(--header-text); }
.footer-note { font-size: .82rem; color: var(--footer-text); opacity: .85; max-width: 780px; }
.footer-links { margin-top: 14px !important; }
.footer-links a { color: var(--amber-500); text-decoration: none; margin-right: 14px; font-weight: 600; }
.footer-links a:hover { text-decoration: underline; }

/* ---------- motion ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- responsive ---------- */
@media (max-width: 1020px) {
  .sidebar { width: 280px; }
}
@media (max-width: 900px) {
  .menu-toggle { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 130;
    width: min(320px, 86vw); background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: calc(var(--header-h) + 8px) 18px 24px;
    transform: translateX(-102%); transition: transform .25s ease-out;
    max-height: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
  .sidebar-overlay {
    display: block; position: fixed; inset: 0; z-index: 120;
    background: rgba(10, 20, 18, .5); opacity: 0; pointer-events: none;
    transition: opacity .25s ease-out;
  }
  .sidebar-overlay.show { opacity: 1; pointer-events: auto; }
  .layout { padding: calc(var(--header-h) + 16px) 14px 32px; gap: 0; }
  .search-wrap { width: min(240px, 38vw); }
}
@media (max-width: 600px) {
  body { font-size: 16.5px; }
  .header-inner { gap: 10px; padding: 0 12px; }
  .brand { font-size: 1.15rem; }
  .brand-mark { width: 30px; height: 30px; }
  .search-wrap { width: min(190px, 44vw); }
  #searchInput { font-size: .88rem; padding-left: 34px; }
  .home-hero { padding: 32px 24px 28px; border-radius: 16px; }
  .home-hero h1 { font-size: 1.55rem; }
  .hero-stats { gap: 18px; }
  .hs-num { font-size: 1.4rem; }
  .content-article { padding: 26px 20px; border-radius: 16px; }
  .content-article h2 { font-size: 1.25rem; }
  .home-grid { grid-template-columns: 1fr; }
  .article-nav { flex-direction: column; }
  .nav-prev, .nav-next { max-width: 100%; text-align: left; }
}
