/* ============================================
   Wątroba i Trzustka - design system
   Paleta: "Zieleń + bursztyn żółci" (zdrowie, natura, żółć)
   Typografia: Newsreader (display) + Atkinson Hyperlegible (body)
   ============================================ */

:root {
  /* Paleta - ciemny motyw */
  --ink: #0d2118;            /* głęboka butelkowa zieleń - tło */
  --panel: #153022;          /* zieleń leśna - panele */
  --panel2: #1b3a2a;         /* jaśniejszy panel */
  --paper: #f4efe3;          /* ciepły krem - tło jasne */
  --paper-dim: #d6cdb8;      /* krem przygaszony */
  --body-dark: #dfe8d5;      /* tekst na ciemnym (12.5:1) */
  --body-light: #22352a;     /* tekst na jasnym (11.9:1) */
  --muted-dark: #a8b8a4;     /* muted na ciemnym (7:1) */
  --muted-light: #5d6b5f;    /* muted na jasnym (5.4:1) */
  --accent: #e09a2f;         /* bursztyn (żółć) - CTA (6.4:1 na ink) */
  --accent-bright: #f0b04a;  /* jasny bursztyn - hover */
  --accent-ink: #8a5a12;     /* bursztyn na jasnym (5.1:1) */
  --accent-subtle: rgba(224, 154, 47, 0.14);
  --sage: #8fae98;           /* szałwia - drugorzędne akcenty */
  --danger: #e0654d;         /* ostrzeżenia (5.1:1 na ink) */

  --border-dark: rgba(223, 232, 213, 0.09);
  --border-light: rgba(34, 53, 42, 0.14);

  --radius: 14px;
  --radius-sm: 9px;
  --transition: all .2s ease-out;

  --header-height: 64px;
  --sidebar-width: 300px;

  --font-display: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-body: 'Atkinson Hyperlegible', 'Segoe UI', system-ui, sans-serif;
}

/* Jasny motyw */
@media (prefers-color-scheme: light) {
  :root {
    --ink: #f4efe3;
    --panel: #ede6d4;
    --panel2: #e6ddc7;
    --paper: #0d2118;
    --body-dark: #22352a;
    --body-light: #dfe8d5;
    --muted-dark: #5d6b5f;
    --muted-light: #a8b8a4;
    --border-dark: rgba(34, 53, 42, 0.12);
    --accent: #8a5a12;
    --accent-bright: #6d4709;
    --accent-ink: #e09a2f;
    --accent-subtle: rgba(138, 90, 18, 0.12);
    --sage: #3f6b4c;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; overflow-x: clip; }

body {
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.7;
  background: var(--ink);
  color: var(--body-dark);
  min-height: 100vh;
  transition: background .3s, color .3s;
  /* Dwa subtelne radial-gradient - atmosfera bez dystrakcji */
  background-image:
    radial-gradient(ellipse 60vw 40vh at 100% 0%, rgba(224, 154, 47, 0.05), transparent 60%),
    radial-gradient(ellipse 50vw 40vh at 0% 100%, rgba(143, 174, 152, 0.07), transparent 60%);
  background-attachment: fixed;
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-bright); }

/* ---------- HEADER ---------- */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: var(--header-height);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: rgba(13, 33, 24, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-dark);
  transition: background .3s;
}
@media (prefers-color-scheme: light) {
  .app-header { background: rgba(244, 239, 227, 0.94); }
}
/* Poświata na dolnej krawędzi headera */
.app-header::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(224, 154, 47, 0.45), transparent);
  opacity: .5; pointer-events: none;
}

.brand { display: flex; align-items: center; white-space: nowrap; }
.brand a { display: flex; align-items: center; gap: 8px; color: var(--body-dark); }
.brand-mark { font-size: 26px; line-height: 1; }
.brand-name {
  font-family: var(--font-display);
  font-size: 1.25rem; font-weight: 600; letter-spacing: .01em;
}
.brand-accent { color: var(--accent); }

.header-search {
  position: relative; flex: 1; max-width: 420px; margin-left: auto;
}
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 15px; opacity: .7; }
.header-search input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border-radius: 999px;
  border: 1px solid var(--border-dark);
  background: var(--panel);
  color: var(--body-dark);
  font-family: var(--font-body); font-size: .95rem;
  outline: none;
  transition: var(--transition);
}
.header-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.header-search input::placeholder { color: var(--muted-dark); }

#search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--panel2);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  overflow: hidden; display: none; z-index: 250;
}
#search-results a {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 14px; color: var(--body-dark);
  border-bottom: 1px solid var(--border-dark);
}
#search-results a:hover { background: var(--accent-subtle); }
#search-results a:last-child { border-bottom: none; }
.sr-title { display: block; font-weight: 700; font-size: .9rem; }
.sr-excerpt { display: block; font-size: .8rem; color: var(--muted-dark); }

.mobile-menu-btn {
  display: none;
  width: 40px; height: 40px;
  border: 1px solid var(--border-dark); border-radius: 8px;
  background: var(--panel); color: var(--body-dark);
  font-size: 18px; cursor: pointer;
  transition: var(--transition);
}
.mobile-menu-btn:hover { border-color: var(--accent); }

/* ---------- LAYOUT ---------- */
.sidebar {
  position: fixed; top: var(--header-height); left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--panel);
  border-right: 1px solid var(--border-dark);
  overflow-y: auto; padding: 16px 12px 24px;
  z-index: 150;
  transition: var(--transition);
}
.main {
  margin-left: var(--sidebar-width);
  padding: calc(var(--header-height) + 32px) 40px 60px;
  min-height: 100vh;
  max-width: 100%;
}

/* ---------- SIDEBAR NAV ---------- */
.sidebar-nav { list-style: none; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--body-dark);
  font-size: .9rem;   /* min 15px - wymóg użytkownika */
  line-height: 1.45;
  transition: var(--transition);
}
.sidebar-nav a:hover { background: var(--accent-subtle); color: var(--accent-bright); }
.sidebar-nav a.active { background: var(--accent-subtle); color: var(--accent); font-weight: 700; }
.nav-home { font-weight: 700; margin-bottom: 6px; }
.nav-section {
  margin: 18px 10px 6px;
  font-size: .75rem;           /* min 12px */
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--accent);
}
.nav-section:first-of-type { margin-top: 6px; }

.sidebar-ad { margin-top: 24px; padding: 0 4px; }

.ad-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px dashed var(--border-dark);
  border-radius: var(--radius-sm);
  color: var(--muted-dark);
  font-size: .8rem; text-align: center;
  padding: 24px 12px;
}
.sidebar-ad .ad-placeholder { min-height: 300px; }
.ad-leaderboard { display: none; }
.ad-leaderboard .ad-placeholder { min-height: 90px; margin: 8px auto; max-width: 970px; }

/* ---------- ARTICLE ---------- */
.content-article { max-width: 780px; margin: 0 auto; }
.content-article h1 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  font-weight: 600;
  line-height: 1.15;
  margin-bottom: 14px;
  color: var(--body-dark);
  text-wrap: balance;
}
.content-article h2 {
  font-family: var(--font-display);
  font-size: 1.55rem; font-weight: 600;
  margin: 38px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-dark);
  color: var(--body-dark);
  text-wrap: balance;
}
.content-article h3 {
  font-family: var(--font-display);
  font-size: 1.22rem; font-weight: 600;
  margin: 26px 0 8px;
  color: var(--body-dark);
  text-wrap: balance;
}
.content-article p { margin-bottom: 14px; }
.content-article ul, .content-article ol { margin: 0 0 16px 24px; }
.content-article li { margin-bottom: 6px; }
.content-article strong { font-weight: 700; }

.article-meta {
  color: var(--muted-dark);
  font-size: 1.02rem;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-dark);
}

/* ---------- INFO BOX ---------- */
.info-box {
  background: var(--accent-subtle);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px 18px;
  margin: 22px 0;
  color: var(--body-dark);
}
.info-box p { margin: 0; }

/* ---------- TABLES ---------- */
.table-responsive { overflow-x: auto; margin: 20px 0; border-radius: var(--radius-sm); }
.error-table, .compare-table {
  width: 100%; border-collapse: collapse;
  font-size: .95rem;
  background: var(--panel);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.error-table th, .compare-table th {
  background: var(--panel2);
  color: var(--accent);
  font-weight: 700; text-align: left;
  padding: 11px 14px;
  font-size: .88rem;
  text-transform: uppercase; letter-spacing: .05em;
}
.error-table td, .compare-table td {
  padding: 10px 14px;
  border-top: 1px solid var(--border-dark);
  vertical-align: top;
}
.error-table tr:nth-child(even) td, .compare-table tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
@media (prefers-color-scheme: light) {
  .error-table tr:nth-child(even) td, .compare-table tr:nth-child(even) td { background: rgba(13,33,24,0.03); }
}

/* ---------- FAQ ---------- */
.faq-item {
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: var(--panel);
  overflow: hidden;
}
.faq-q {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 18px;
  font-weight: 700; cursor: pointer;
  color: var(--body-dark);
  user-select: none;
  transition: var(--transition);
}
.faq-q:hover { color: var(--accent); }
.faq-q::after {
  content: '+';
  font-size: 1.3rem; font-weight: 400;
  color: var(--accent);
  transition: transform .25s ease-out;
  flex-shrink: 0;
}
.faq-item.open .faq-q::after { transform: rotate(45deg); }
.faq-a {
  display: none;
  padding: 0 18px 16px;
  color: var(--muted-dark);
}
.faq-item.open .faq-a { display: block; }

/* ---------- GLOSSARY ---------- */
.glossary-list dl { margin: 0; }
.glossary-list dt {
  font-weight: 700;
  color: var(--accent);
  margin-top: 18px;
  font-size: 1.05rem;
}
.glossary-list dd {
  margin: 4px 0 0 0;
  color: var(--muted-dark);
  line-height: 1.6;
}

/* ---------- TOC ---------- */
.article-toc {
  background: var(--panel);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin: 20px 0 26px;
}
.article-toc h3 {
  font-family: var(--font-display);
  font-size: 1.05rem; margin: 0 0 10px;
  color: var(--accent);
}
.article-toc a {
  display: block;
  padding: 4px 0;
  color: var(--body-dark);
  font-size: .92rem;
  border-left: 2px solid transparent;
  padding-left: 10px;
  transition: var(--transition);
}
.article-toc a:hover { color: var(--accent); border-left-color: var(--accent); }
.article-toc a.toc-h3 { padding-left: 24px; font-size: .88rem; color: var(--muted-dark); }
.article-toc a.active { border-left-color: var(--accent); color: var(--accent); }

/* ---------- HOME ---------- */
.home-hero {
  text-align: center;
  padding: 46px 24px 40px;
  margin-bottom: 44px;
  background:
    radial-gradient(ellipse 80% 100% at 50% 0%, var(--accent-subtle), transparent 65%),
    var(--panel);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}
.hero-tag {
  display: inline-block;
  font-size: .8rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-subtle);
  border: 1px solid rgba(224,154,47,.25);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 18px;
}
.home-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 600; line-height: 1.12;
  margin-bottom: 14px;
  text-wrap: balance;
}
.hero-accent { color: var(--accent); }
.hero-sub {
  font-size: 1.08rem;
  color: var(--muted-dark);
  max-width: 640px; margin: 0 auto 10px;
  text-wrap: balance;
}

.hero-seal { max-width: 620px; margin: 26px auto 6px; }
.hero-seal svg { width: 100%; height: auto; display: block; }

.stats-row {
  display: flex; justify-content: center; gap: 14px;
  margin-top: 26px; flex-wrap: wrap;
}
.stat-card {
  background: var(--panel2);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  padding: 12px 22px;
  min-width: 120px;
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); border-color: rgba(224,154,47,.35); }
.stat-card .num {
  display: block;
  font-family: var(--font-display);
  font-size: 1.7rem; font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}
.stat-card .label {
  display: block;
  font-size: .78rem; color: var(--muted-dark);
  text-transform: uppercase; letter-spacing: .07em;
  margin-top: 2px;
}

.home-section-label {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display);
  font-size: 1.45rem; font-weight: 600;
  margin: 40px 0 18px;
  color: var(--body-dark);
}
.accent-bar {
  width: 4px; height: 26px;
  background: linear-gradient(180deg, var(--accent), var(--sage));
  border-radius: 2px;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.home-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  padding: 18px 18px 16px;
  color: var(--body-dark);
  position: relative;
  transition: var(--transition);
  overflow: hidden;
}
.home-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--sage));
  opacity: 0; transition: opacity var(--transition);
}
.home-card:hover { transform: translateY(-2px); border-color: rgba(224,154,47,.35); box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.home-card:hover::before { opacity: 1; }
.card-icon { font-size: 1.6rem; display: block; margin-bottom: 8px; }
.home-card h3 {
  font-family: var(--font-display);
  font-size: .9rem;   /* min 15px - wymóg użytkownika */
  font-weight: 700; line-height: 1.35;
  margin-bottom: 6px;
  color: var(--body-dark);
}
.home-card p {
  font-size: .85rem;  /* min 14px - wymóg użytkownika */
  color: var(--muted-dark);
  line-height: 1.5;
}
.card-arrow {
  position: absolute; right: 14px; bottom: 12px;
  opacity: 0; transform: translateX(-8px);
  color: var(--accent); font-size: 1.1rem;
  transition: var(--transition);
}
.home-card:hover .card-arrow { opacity: 1; transform: translateX(0); }

/* ---------- 404 ---------- */
.error-404 { text-align: center; padding-top: 60px; }
.error-404 h1 { font-size: 4rem; color: var(--accent); }

/* ---------- FOOTER ---------- */
.app-footer {
  margin-left: var(--sidebar-width);
  border-top: 1px solid var(--border-dark);
  background: var(--panel);
  padding: 28px 40px;
}
.footer-inner { max-width: 780px; margin: 0 auto; }
.footer-brand {
  font-family: var(--font-display);
  font-weight: 600; font-size: 1.1rem;
  margin-bottom: 6px;
}
.footer-desc { font-size: .88rem; color: var(--muted-dark); margin-bottom: 10px; }
.footer-note { font-size: .82rem; color: var(--muted-dark); }
.footer-note a { color: var(--accent); }

/* ---------- ANIMATIONS ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.content-article > * { animation: fadeUp .28s ease-out both; }
.content-article > *:nth-child(2) { animation-delay: .04s; }
.content-article > *:nth-child(3) { animation-delay: .08s; }

/* SVG signature - rysowanie */
.hero-seal .draw { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.hero-seal .fill-in { transition: opacity .8s ease-out; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 900px) {
  .mobile-menu-btn { display: block; }
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 8px 0 32px rgba(0,0,0,.3);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    position: fixed; inset: 0; z-index: 140;
    background: rgba(0,0,0,.5);
    display: none;
  }
  .sidebar-overlay.show { display: block; }
  .main { margin-left: 0; padding: calc(var(--header-height) + 24px) 20px 48px; }
  .app-footer { margin-left: 0; padding: 24px 20px; }
  .header-search { max-width: none; }
  .brand-name { font-size: 1.05rem; }
  .home-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

@media (max-width: 600px) {
  body { font-size: 17px; }
  .app-header { gap: 10px; padding: 0 12px; }
  .brand-mark { font-size: 22px; }
  .home-hero { padding: 34px 16px 30px; }
  .stats-row { gap: 8px; }
  .stat-card { min-width: 96px; padding: 10px 14px; }
  .home-grid { grid-template-columns: 1fr; }
}

/* ---------- REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- FOCUS ---------- */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
