/* ============================================================
   Odporność - design system
   Paleta: leśna zieleń + teal (natura, zdrowie, odporność)
   + krem (ciepło domowe) + miód (akcent, herbata z cytryną)
   Typografia: Spectral (display) + Karla (body)
   ============================================================ */

:root {
  /* Light theme */
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-2: #eef1e8;
  --text: #1c2b24;
  --muted: #4c5d53;
  --accent: #2f7d4f;
  --accent-strong: #1f5f3a;
  --accent-soft: #e2efe4;
  --warm: #c98a1b;
  --warm-soft: #f8efd9;
  --border: #dfe3d6;
  --shadow: 0 1px 3px rgba(28,43,36,.06), 0 4px 16px rgba(28,43,36,.05);
  --shadow-hover: 0 4px 12px rgba(28,43,36,.09), 0 12px 32px rgba(28,43,36,.08);
  --header-bg: rgba(246,247,242,.92);
  --hero-grad: linear-gradient(135deg, #1f5f3a 0%, #2f7d4f 55%, #4c9a63 100%);
  --hero-text: #f4fbf5;
  --hero-sub: #d3e8d5;
  --font-display: 'Spectral', Georgia, serif;
  --font-body: 'Karla', 'Segoe UI', sans-serif;
  --radius: 14px;
  --radius-sm: 8px;
  --header-h: 64px;
  --sidebar-w: 292px;
  --transition: all .2s ease-out;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1712;
    --surface: #17221b;
    --surface-2: #1c2a22;
    --text: #e7ecdf;
    --muted: #a3b3a8;
    --accent: #4fae72;
    --accent-strong: #6cc98c;
    --accent-soft: #1d3a28;
    --warm: #e0a63a;
    --warm-soft: #362c16;
    --border: #28362d;
    --shadow: 0 1px 3px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    --shadow-hover: 0 4px 12px rgba(0,0,0,.35), 0 12px 32px rgba(0,0,0,.3);
    --header-bg: rgba(15,23,18,.9);
    --hero-grad: linear-gradient(135deg, #0f3d24 0%, #1d5c38 55%, #2c7a49 100%);
    --hero-text: #eef7f0;
    --hero-sub: #bcd9c1;
  }
}

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

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 900px 600px at -10% -10%, rgba(47,125,79,.07), transparent 60%),
    radial-gradient(ellipse 900px 600px at 110% 110%, rgba(201,138,27,.07), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff;
  padding: .6rem 1.2rem; border-radius: 0 0 var(--radius-sm) 0;
  z-index: 200; font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.app-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.app-header::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(47,125,79,.28), transparent);
  opacity: .5;
  pointer-events: none;
}
.header-inner {
  max-width: 1400px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; gap: 1.2rem;
  padding: 0 1.4rem;
}
.brand {
  display: flex; align-items: center; gap: .5rem;
  text-decoration: none; color: var(--text);
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.35rem; letter-spacing: -.01em;
  white-space: nowrap;
}
.brand-mark { font-size: 1.3rem; }
.brand em { font-style: normal; color: var(--accent); }
.brand:hover .brand-mark { transform: rotate(12deg) scale(1.1); }
.brand-mark { display: inline-block; transition: var(--transition); }

.header-search {
  position: relative; flex: 1; max-width: 480px; margin-left: auto;
}
.header-search input {
  width: 100%;
  padding: .55rem 1rem .55rem 2.4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234c5d53' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat .9rem center;
  font-family: var(--font-body); font-size: .95rem; color: var(--text);
  transition: var(--transition);
}
.header-search input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,125,79,.15);
}
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-hover);
  max-height: 420px; overflow-y: auto; z-index: 150;
}
.search-results a {
  display: block; padding: .7rem 1rem;
  text-decoration: none; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.search-results a:last-child { border-bottom: none; }
.search-results a:hover { background: var(--surface-2); }
.search-results .sr-title { font-weight: 600; font-size: .95rem; }
.search-results .sr-section { font-size: .75rem; color: var(--muted); }
.search-results .sr-none { padding: .8rem 1rem; color: var(--muted); font-size: .9rem; }

.menu-toggle {
  display: none;
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm); width: 44px; height: 40px;
  cursor: pointer; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.menu-toggle span {
  display: block; width: 20px; height: 2px;
  background: var(--text); border-radius: 2px; transition: var(--transition);
}
.menu-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle.open span:nth-child(2) { opacity: 0; }
.menu-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Layout ---------- */
.layout {
  max-width: 1400px; margin: 0 auto;
  padding: calc(var(--header-h) + 1.4rem) 1.4rem 2rem;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 2.4rem;
  min-height: 100vh;
}

.sidebar {
  position: sticky; top: calc(var(--header-h) + 1.4rem);
  align-self: start; max-height: calc(100vh - var(--header-h) - 2.8rem);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem .9rem;
  box-shadow: var(--shadow);
  scrollbar-width: thin;
}
.sidebar-nav { list-style: none; }
.sidebar-section-label {
  font-size: .7rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent);
  padding: 1.1rem .6rem .35rem;
}
.sidebar-section-label:first-child { padding-top: .2rem; }
.sidebar-link {
  display: block;
  font-size: .9rem;
  line-height: 1.35;
  padding: .38rem .6rem;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  border-left: 3px solid transparent;
}
.sidebar-link:hover { background: var(--surface-2); color: var(--accent-strong); }
.sidebar-link.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-left-color: var(--accent);
  font-weight: 600;
}
.sidebar-foot {
  margin-top: 1rem; padding: .8rem .6rem 0;
  border-top: 1px solid var(--border);
  font-size: .78rem; color: var(--muted); line-height: 1.5;
}

.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(13,20,15,.5); z-index: 90;
}

.main { min-width: 0; }

/* ---------- Hero (home) ---------- */
.home-hero {
  position: relative;
  border-radius: var(--radius);
  background: var(--hero-grad);
  color: var(--hero-text);
  padding: 2.6rem 2.6rem 2.2rem;
  overflow: hidden;
  box-shadow: var(--shadow-hover);
  animation: fadeUp .35s ease-out;
}
.home-hero::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 500px 300px at 85% 15%, rgba(255,255,255,.14), transparent 60%),
    radial-gradient(ellipse 400px 300px at 10% 90%, rgba(201,138,27,.28), transparent 60%);
  pointer-events: none;
}
.hero-inner {
  position: relative; display: flex; align-items: center; gap: 2.4rem;
  flex-wrap: wrap;
}
.hero-copy { flex: 1 1 380px; min-width: 280px; }
.hero-eyebrow {
  display: inline-block; font-size: .78rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--hero-sub);
  border: 1px solid rgba(255,255,255,.3);
  padding: .28rem .8rem; border-radius: 999px; margin-bottom: 1rem;
}
.home-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  font-weight: 600; line-height: 1.15;
  letter-spacing: -.015em;
  text-wrap: balance;
  margin-bottom: .8rem;
}
.home-hero h1 .hl { color: #ffe1a1; }
.hero-sub {
  font-size: 1.05rem; color: var(--hero-sub);
  max-width: 520px; margin-bottom: 1.4rem;
  text-wrap: balance;
}
.hero-stats {
  display: flex; gap: 1.8rem; flex-wrap: wrap;
  margin-top: 1.2rem;
}
.hero-stat b {
  display: block; font-family: var(--font-display);
  font-size: 1.7rem; font-weight: 700; color: #fff;
  line-height: 1.1;
}
.hero-stat span { font-size: .8rem; color: var(--hero-sub); }
.hero-art { flex: 0 0 auto; }

/* ---------- SVG hero: filiżanka z cytryną ---------- */
.tea-svg { width: 250px; height: auto; filter: drop-shadow(0 8px 24px rgba(0,0,0,.25)); }

/* ---------- Home sections & cards ---------- */
.home-section { margin-top: 2.6rem; animation: fadeUp .35s ease-out; }
.home-section-head {
  display: flex; align-items: baseline; gap: .8rem;
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--border);
}
.home-section-head h2 {
  font-family: var(--font-display);
  font-size: 1.45rem; font-weight: 600;
  letter-spacing: -.01em;
}
.home-section-head .count {
  font-size: .78rem; color: var(--muted); font-weight: 600;
}
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: .9rem;
}
.home-card {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.05rem 1.1rem;
  text-decoration: none; color: var(--text);
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.home-card::before {
  content: '';
  position: absolute; top: 0; left: 1.1rem; right: 1.1rem; height: 3px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, var(--accent), var(--warm));
  opacity: 0; transition: var(--transition);
}
.home-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.home-card:hover::before { opacity: 1; }
.home-card:hover .card-icon { transform: scale(1.12) rotate(-4deg); }
.card-icon {
  font-size: 1.5rem; display: inline-block; margin-bottom: .45rem;
  transition: var(--transition);
}
.home-card h3 {
  font-size: .95rem; font-weight: 700; line-height: 1.35;
  margin-bottom: .3rem;
  letter-spacing: -.005em;
  text-wrap: balance;
}
.home-card p {
  font-size: .85rem; color: var(--muted); line-height: 1.5;
}

/* ---------- Article page ---------- */
.content-article {
  max-width: 860px;
  animation: fadeUp .3s ease-out;
}
.content-article .article-eyebrow {
  font-size: .78rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent);
  margin-bottom: .5rem;
}
.content-article h1 {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3.4vw, 2.3rem);
  font-weight: 600; line-height: 1.2;
  letter-spacing: -.015em;
  margin-bottom: .7rem;
  text-wrap: balance;
}
.article-meta {
  display: flex; flex-wrap: wrap; gap: .5rem 1.2rem;
  font-size: .82rem; color: var(--muted);
  padding-bottom: 1rem; margin-bottom: 1.4rem;
  border-bottom: 1px solid var(--border);
}
.article-meta .tag {
  background: var(--accent-soft); color: var(--accent-strong);
  padding: .12rem .6rem; border-radius: 999px;
  font-weight: 600; font-size: .75rem;
}
.content-article h2 {
  font-family: var(--font-display);
  font-size: 1.45rem; font-weight: 600;
  margin: 2rem 0 .8rem;
  letter-spacing: -.01em;
  scroll-margin-top: calc(var(--header-h) + 20px);
  text-wrap: balance;
}
.content-article h3 {
  font-family: var(--font-display);
  font-size: 1.15rem; font-weight: 600;
  margin: 1.5rem 0 .6rem;
  scroll-margin-top: calc(var(--header-h) + 20px);
}
.content-article p { margin-bottom: 1rem; }
.content-article ul, .content-article ol {
  margin: 0 0 1.1rem 1.3rem;
}
.content-article li { margin-bottom: .35rem; }
.content-article strong { font-weight: 700; }
.content-article a { color: var(--accent-strong); }
.content-article a:hover { text-decoration-thickness: 2px; }

/* TOC */
.article-toc {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin: 0 0 1.6rem;
  font-size: .9rem;
}
.article-toc strong {
  display: block; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .1em; color: var(--muted); margin-bottom: .5rem;
}
.article-toc ol { margin: 0 0 0 1.2rem; }
.article-toc a { text-decoration: none; }
.article-toc li { margin-bottom: .25rem; }

/* Info box */
.info-box {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 1rem 1.2rem;
  margin: 1.2rem 0;
  font-size: .95rem;
}
.info-box.warm {
  background: var(--warm-soft);
  border-left-color: var(--warm);
}
.info-box strong { display: block; margin-bottom: .3rem; }

/* Warning box */
.warn-box {
  background: #fdf0e8;
  border: 1px solid #e8c4b0;
  border-left: 4px solid var(--warm);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 1rem 1.2rem;
  margin: 1.2rem 0;
  font-size: .95rem;
}
@media (prefers-color-scheme: dark) {
  .warn-box { background: #33231a; border-color: #5a3a28; }
}

/* Tables */
.table-responsive { overflow-x: auto; margin: 1.2rem 0; }
.info-table {
  width: 100%; border-collapse: collapse;
  font-size: .92rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.info-table th {
  background: var(--accent-soft);
  color: var(--accent-strong);
  text-align: left;
  font-weight: 700;
  padding: .7rem .9rem;
  font-size: .85rem;
  white-space: nowrap;
}
.info-table td {
  padding: .65rem .9rem;
  border-top: 1px solid var(--border);
  vertical-align: top;
}
.info-table tr:hover td { background: var(--surface-2); }

/* FAQ */
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin: .8rem 0;
  overflow: hidden;
}
.faq-item summary {
  cursor: pointer;
  padding: .95rem 1.2rem;
  font-weight: 600;
  font-size: 1rem;
  list-style: none;
  display: flex; align-items: center; gap: .6rem;
  transition: var(--transition);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before {
  content: '+';
  flex: 0 0 auto;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-strong);
  border-radius: 50%;
  font-weight: 700; font-size: 1rem;
  transition: var(--transition);
}
.faq-item[open] summary::before { transform: rotate(45deg); background: var(--accent); color: #fff; }
.faq-item summary:hover { background: var(--surface-2); }
.faq-item .faq-a { padding: 0 1.2rem 1rem 2.9rem; font-size: .95rem; }

/* Glossary */
.glossary dt {
  font-weight: 700; margin-top: 1rem;
  color: var(--accent-strong);
  font-size: 1.02rem;
}
.glossary dd { margin: .2rem 0 0 0; font-size: .95rem; }

/* Article nav */
.article-nav {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-top: 2.4rem; padding-top: 1.4rem;
  border-top: 1px solid var(--border);
}
.article-nav a {
  text-decoration: none; color: var(--text);
  font-weight: 600; font-size: .92rem;
  max-width: 45%; line-height: 1.4;
  transition: var(--transition);
}
.article-nav a:hover { color: var(--accent-strong); }
.article-nav .nav-label {
  display: block; font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin-bottom: .2rem;
}

/* Footer */
.app-footer {
  border-top: 1px solid var(--border);
  margin-top: 3rem;
  background: var(--surface);
}
.footer-inner {
  max-width: 1400px; margin: 0 auto;
  padding: 2rem 1.4rem;
  font-size: .88rem; color: var(--muted);
  display: grid; gap: .6rem;
}
.footer-inner strong { color: var(--text); }
.footer-meta { font-size: .8rem; }

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.reveal { opacity: 0; transform: translateY(8px); transition: opacity .4s ease-out, transform .4s ease-out; }
.reveal.visible { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: var(--header-h); bottom: 0; left: 0;
    width: min(320px, 85vw);
    max-height: none; border-radius: 0;
    transform: translateX(-105%);
    transition: transform .25s ease-out;
    z-index: 95;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .menu-toggle { display: flex; }
  .header-search { max-width: none; }
  .hero-inner { flex-direction: column; align-items: flex-start; }
  .tea-svg { width: 180px; }
}

@media (max-width: 600px) {
  .layout { padding: calc(var(--header-h) + 1rem) 1rem 2rem; }
  .home-hero { padding: 1.8rem 1.4rem 1.6rem; }
  .hero-stats { gap: 1.2rem; }
  .home-grid { grid-template-columns: 1fr; }
  .header-inner { gap: .6rem; padding: 0 .8rem; }
  .brand { font-size: 1.1rem; }
}
