/* ============================================================
   Leki - design system
   Paleta apteczna: głęboka zieleń (zdrowie, zaufanie, apteka)
   + medyczny błękit (czystość, profesjonalizm) + krem
   Typografia: Source Serif 4 (display) + Nunito Sans (body)
   ============================================================ */

:root {
  /* Light theme */
  --bg: #f5f7f4;
  --bg-card: #ffffff;
  --bg-sidebar: #fafbf8;
  --bg-sunken: #edf1ec;
  --text: #16241f;
  --text-secondary: #4d5e57;
  --accent: #0b6e5c;
  --accent-strong: #085448;
  --accent-light: #e2f0eb;
  --accent-subtle: #c5e3d9;
  --sky: #1f6fae;
  --sky-light: #e3eef7;
  --border: #dfe5df;
  --border-strong: #c9d2cb;
  --warning: #9a5b0b;
  --warning-bg: #fbf1de;
  --danger: #b3261e;
  --danger-bg: #fdeceb;
  --shadow: 0 1px 3px rgba(22, 36, 31, .06), 0 10px 28px rgba(22, 36, 31, .05);
  --shadow-lg: 0 4px 14px rgba(22, 36, 31, .1), 0 18px 44px rgba(22, 36, 31, .12);
  --header-glow: linear-gradient(90deg, transparent, rgba(11, 110, 92, .4), transparent);
  --hero-gradient: linear-gradient(135deg, #064e3b 0%, #0b6e5c 48%, #1f6fae 100%);
  --font-heading: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-body: 'Nunito Sans', 'Segoe UI', sans-serif;
  --header-height: 60px;
  --sidebar-width: 286px;
  --radius: 12px;
  --transition: .2s ease-out;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1210;
    --bg-card: #131c18;
    --bg-sidebar: #0f1714;
    --bg-sunken: #080d0b;
    --text: #dfeae4;
    --text-secondary: #a2b5ab;
    --accent: #2dd4a7;
    --accent-strong: #6ee7c3;
    --accent-light: #14241e;
    --accent-subtle: #1d3a30;
    --sky: #60a5fa;
    --sky-light: #14283c;
    --border: #1d2a24;
    --border-strong: #2a3a32;
    --warning: #fbbf24;
    --warning-bg: #2b2110;
    --danger: #f87171;
    --danger-bg: #2c1616;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .35);
    --shadow-lg: 0 4px 14px rgba(0, 0, 0, .5), 0 18px 44px rgba(0, 0, 0, .5);
    --header-glow: linear-gradient(90deg, transparent, rgba(45, 212, 167, .3), transparent);
    --hero-gradient: linear-gradient(135deg, #052e24 0%, #0a4a3c 45%, #123c63 100%);
  }
}

/* ---------- 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);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
/* Ambient corner glows */
body::before, body::after {
  content: '';
  position: fixed;
  width: 520px; height: 520px;
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
  opacity: .45;
}
body::before {
  top: -220px; right: -140px;
  background: radial-gradient(circle, var(--accent-subtle), transparent 65%);
}
body::after {
  bottom: -240px; left: -160px;
  background: radial-gradient(circle, var(--sky-light), transparent 65%);
}
img { max-width: 100%; height: auto; }

h1, h2, h3 { text-wrap: balance; }
h1, h2, h3, h4 { font-family: var(--font-heading); line-height: 1.3; }
h1 { font-size: clamp(1.9rem, 4.2vw, 2.6rem); font-weight: 700; letter-spacing: -.01em; margin: 0 0 .5em; }
h2 { font-size: 1.42rem; font-weight: 600; margin: 2.2em 0 .6em; padding-bottom: .35em; border-bottom: 1px solid var(--border); }
h3 { font-size: 1.14rem; font-weight: 600; margin: 1.7em 0 .45em; }
p { margin: 1.05em 0; }
a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-strong); }
ul, ol { padding-left: 1.35em; margin: 1em 0; }
li { margin: .35em 0; }
strong { font-weight: 600; }
::selection { background: var(--accent-subtle); }

a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

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

/* ---------- Header ---------- */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: .85em;
  padding: 0 1.3em;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.app-header::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 2px;
  background: var(--header-glow);
  opacity: .3;
  pointer-events: none;
}
.logo-mark { font-size: 1.35rem; line-height: 1; }
.logo-text { font-family: var(--font-heading); font-size: 1.12rem; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.logo-text a { color: var(--text); text-decoration: none; }
.logo-text a:hover { color: var(--accent); }
.mobile-menu-btn {
  display: none;
  background: none; border: 1px solid var(--border-strong); border-radius: 8px;
  font-size: 1.15rem; padding: .3em .55em; cursor: pointer; color: var(--text);
  transition: background var(--transition), border-color var(--transition);
}
.mobile-menu-btn:hover { background: var(--accent-light); border-color: var(--accent); }

.header-search { position: relative; margin-left: auto; width: min(330px, 40vw); }
.search-icon { position: absolute; left: .85em; top: 50%; transform: translateY(-50%); font-size: .85rem; opacity: .55; pointer-events: none; }
.header-search input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: .52em 1em .52em 2.4em;
  font-family: var(--font-body);
  font-size: .9rem;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.header-search input::placeholder { color: var(--text-secondary); opacity: .7; }
.header-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); outline: none; }

#search-results {
  position: absolute;
  top: calc(100% + 8px); left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 250;
  overflow: hidden;
  display: none;
}
#search-results a {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: .875rem;
}
#search-results a:last-child { border-bottom: none; }
#search-results a:hover { background: var(--accent-light); }
#search-results .sr-excerpt { display: block; font-size: .8rem; color: var(--text-secondary); line-height: 1.35; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1.1em .9em 4em;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.sidebar-nav { list-style: none; margin: 0; padding: 0; }
.sidebar-nav a {
  display: flex;
  align-items: flex-start;
  gap: .55em;
  font-size: .9rem;
  line-height: 1.35;
  color: var(--text);
  text-decoration: none;
  padding: .42em .6em;
  border-radius: 8px;
  transition: background var(--transition), color var(--transition);
}
.sidebar-nav a:hover { background: var(--accent-light); color: var(--accent-strong); }
.sidebar-nav a.active { background: var(--accent-light); color: var(--accent-strong); font-weight: 600; }
.sidebar-nav .nav-section {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-secondary);
  margin: 1.6em 0 .4em;
  padding: 0 .6em;
}
.sidebar-nav > li:first-child { margin-bottom: .4em; }
.sidebar-nav > li:first-child a { font-weight: 600; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 12, .55);
  z-index: 90;
}

/* ---------- Main ---------- */
.main-content {
  margin-left: var(--sidebar-width);
  padding: calc(var(--header-height) + 2.2rem) clamp(1.2rem, 4vw, 3.2rem) 5rem;
}
.content-article {
  max-width: 840px;
  margin: 0 auto;
  animation: fadeUp .28s ease-out both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.article-meta {
  color: var(--text-secondary);
  font-size: .92rem;
  margin: -.3em 0 1.4em;
}

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: .45em;
  font-size: .82rem;
  color: var(--text-secondary);
  margin-bottom: 1.1em;
}
.breadcrumbs a { color: var(--text-secondary); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumbs span[aria-hidden="true"] { opacity: .6; }

/* Related articles */
.related-box {
  margin-top: 2.6em;
  padding-top: 1.4em;
  border-top: 1px solid var(--border);
}
.related-box h3 {
  font-family: var(--font-body);
  font-size: .74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-secondary);
  margin: 0 0 .7em;
}
.related-link {
  display: flex;
  align-items: center;
  gap: .6em;
  padding: .55em .7em;
  border-radius: 9px;
  color: var(--text);
  text-decoration: none;
  font-size: .92rem;
  transition: background var(--transition);
}
.related-link:hover { background: var(--accent-light); color: var(--accent-strong); }
.related-icon { font-size: 1.05rem; }

/* ---------- TOC ---------- */
.article-toc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.05em 1.25em;
  margin: 1.4em 0 1.8em;
  font-size: .9rem;
  display: flex;
  flex-direction: column;
  gap: .28em;
}
@media (min-width: 901px) {
  .article-toc { position: sticky; top: calc(var(--header-height) + 1.2rem); }
}
.article-toc h3 {
  font-family: var(--font-body);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-secondary);
  margin: 0 0 .4em;
}
.article-toc a { text-decoration: none; color: var(--text); padding: .18em 0; }
.article-toc a:hover { color: var(--accent); }
.article-toc .toc-h3 { padding-left: 1.15em; font-size: .95em; color: var(--text-secondary); }
.article-toc .toc-h3:hover { color: var(--accent); }

/* ---------- Content components ---------- */
.key-takeaways {
  background: var(--accent-light);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.1em 1.4em;
  margin: 1.5em 0;
}
.key-takeaways h3 {
  font-family: var(--font-body);
  font-size: .74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--accent-strong);
  margin: 0 0 .5em;
}
.key-takeaways ul { margin: 0; padding-left: 1.3em; }
.key-takeaways li { margin: .3em 0; font-size: .97em; }

.info-box {
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: .95em 1.25em;
  margin: 1.4em 0;
  font-size: .97em;
}
.info-box p { margin: .3em 0; }

.warning-box {
  background: var(--warning-bg);
  border-left: 3px solid var(--warning);
  border-radius: 0 10px 10px 0;
  padding: .95em 1.25em;
  margin: 1.4em 0;
  font-size: .97em;
}
.warning-box p { margin: .3em 0; }

.takeaway-box {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 1.1em 1.4em;
  margin: 1.6em 0;
}
.takeaway-box h3 {
  font-family: var(--font-body);
  font-size: .74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--accent-strong);
  margin: 0 0 .5em;
}
.takeaway-box p { margin: .35em 0; }

.table-responsive { overflow-x: auto; margin: 1.4em 0; border-radius: 10px; border: 1px solid var(--border-strong); }
table.compare-table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 520px; }
.compare-table th, .compare-table td { padding: .7em .9em; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.compare-table thead th { background: var(--accent-light); color: var(--accent-strong); font-weight: 600; }
.compare-table tbody tr:last-child td { border-bottom: none; }
.compare-table tbody tr:hover td { background: var(--bg-sunken); }

.faq-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1em 1.25em;
  margin: .85em 0;
  background: var(--bg-card);
}
.faq-item h3 { margin: 0 0 .45em; font-size: 1.05rem; color: var(--accent-strong); }
.faq-item p { margin: .3em 0; }

dl.glossary { margin: 1.2em 0; }
dl.glossary dt { font-weight: 600; margin-top: 1.15em; color: var(--text); }
dl.glossary dt:first-child { margin-top: 0; }
dl.glossary dd { margin: .15em 0 0; color: var(--text-secondary); }

ul.checklist { list-style: none; padding-left: 0; }
ul.checklist li { position: relative; padding-left: 1.8em; margin: .5em 0; }
ul.checklist li::before { content: '✅'; position: absolute; left: 0; top: .1em; font-size: .95em; }

/* ---------- Home ---------- */
.home-hero {
  background: var(--hero-gradient);
  border-radius: 18px;
  color: #fff;
  padding: clamp(2.1rem, 5vw, 3.6rem) clamp(1.5rem, 4vw, 3rem);
  margin-bottom: 2.6rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.home-hero::before {
  content: '';
  position: absolute;
  top: -60%; right: -15%;
  width: 480px; height: 480px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .13), transparent 62%);
  pointer-events: none;
}
.home-hero::after {
  content: '';
  position: absolute;
  bottom: -70%; left: -10%;
  width: 420px; height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(96, 165, 250, .25), transparent 62%);
  pointer-events: none;
}
/* Hero artwork: capsule + pharmacy cross signature */
.hero-art {
  position: absolute;
  right: 4%;
  top: 50%;
  transform: translateY(-50%);
  width: clamp(130px, 17vw, 220px);
  opacity: .95;
  pointer-events: none;
  animation: heroFloat 7s ease-in-out infinite;
}
.hero-art svg { width: 100%; height: auto; display: block; }
@keyframes heroFloat {
  0%, 100% { transform: translateY(-50%); }
  50% { transform: translateY(calc(-50% - 9px)); }
}
.home-hero .hero-eyebrow {
  display: inline-block;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  padding: .3em 1em;
  margin-bottom: 1em;
}
.home-hero h1 {
  font-size: clamp(1.9rem, 4.6vw, 2.9rem);
  color: #fff;
  margin: 0 0 .35em;
  max-width: 18ch;
}
.home-hero .hero-sub {
  font-size: 1.05rem;
  color: rgba(255, 255, 255, .92);
  max-width: 62ch;
  margin: 0 0 1.6em;
  line-height: 1.65;
}
.stats-row { display: flex; flex-wrap: wrap; gap: .8em; }
.stat-card {
  background: rgba(255, 255, 255, .13);
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 12px;
  padding: .75em 1.25em;
  display: flex;
  flex-direction: column;
}
.stat-card .num { font-family: var(--font-heading); font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-card .label { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(255, 255, 255, .85); }

.home-section-label {
  display: flex;
  align-items: center;
  gap: .65em;
  font-family: var(--font-heading);
  font-size: 1.22rem;
  font-weight: 600;
  margin: 3em 0 1.15em;
  padding-bottom: 0;
  border-bottom: none;
}
.accent-bar { width: 5px; height: 1.15em; background: var(--accent); border-radius: 3px; flex-shrink: 0; }

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 1rem;
}
.home-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2em 1.2em 1.25em;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(22, 36, 31, .04);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.home-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-subtle);
  box-shadow: 0 6px 16px rgba(22, 36, 31, .08), 0 18px 40px rgba(22, 36, 31, .1);
}
.home-card .card-icon {
  font-size: 1.3rem;
  line-height: 1;
  width: 46px; height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  border-radius: 12px;
  margin-bottom: .75em;
  transition: transform var(--transition), background var(--transition);
}
.home-card:hover .card-icon { transform: scale(1.1) rotate(-4deg); background: var(--accent-subtle); }
.home-card h3 { font-family: var(--font-body); font-size: .95rem; font-weight: 600; margin: 0 0 .4em; line-height: 1.4; }
.home-card p { font-size: .85rem; color: var(--text-secondary); line-height: 1.55; margin: 0; }

/* ---------- Loading ---------- */
.loading { display: flex; justify-content: center; padding: 5em 0; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .mobile-menu-btn { display: block; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease-out;
    box-shadow: none;
    z-index: 95;
    width: min(320px, 86vw);
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; padding: calc(var(--header-height) + 1.4rem) 1.1rem 4rem; }
  .header-search { width: min(300px, 46vw); }
}

@media (max-width: 600px) {
  body { font-size: 16.5px; }
  .app-header { padding: 0 .8em; gap: .55em; }
  .logo-text { font-size: 1rem; }
  .header-search { width: auto; flex: 1; }
  .home-hero { padding: 1.7rem 1.3rem; border-radius: 14px; }
  .hero-art { display: none; }
  .stats-row { gap: .55em; }
  .stat-card { padding: .6em .9em; }
  .home-grid { grid-template-columns: 1fr; }
  .content-article { font-size: 1rem; }
  .article-toc { font-size: .85rem; }
}

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