/* ============================================================
   Skóra - design system
   Paleta: leśna zieleń + teal (czystość, natura, zdrowie)
   + krem (ciepło, ton skóry) + terakota (akcent)
   Typografia: Lora (display) + Figtree (body)
   ============================================================ */

:root {
  /* Light theme */
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f0ede5;
  --text: #1d2b27;
  --muted: #4f605a;
  --accent: #0e7c66;
  --accent-strong: #0a5f4e;
  --accent-soft: #dcefe9;
  --warm: #b3542e;
  --warm-soft: #f6e5dc;
  --border: #e2ddd2;
  --shadow: 0 1px 3px rgba(29,43,39,.06), 0 4px 16px rgba(29,43,39,.05);
  --shadow-hover: 0 4px 12px rgba(29,43,39,.09), 0 12px 32px rgba(29,43,39,.08);
  --header-bg: rgba(247,245,240,.92);
  --hero-grad: linear-gradient(135deg, #0a5f4e 0%, #0e7c66 55%, #15997f 100%);
  --hero-text: #f4fbf8;
  --hero-sub: #cfe9e1;
  --font-display: 'Lora', Georgia, serif;
  --font-body: 'Figtree', '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: #0e1513;
    --surface: #16201d;
    --surface-2: #1b2723;
    --text: #e8e4da;
    --muted: #a3b2ac;
    --accent: #2fae92;
    --accent-strong: #3fc4a6;
    --accent-soft: #1a3a33;
    --warm: #e08a63;
    --warm-soft: #33251d;
    --border: #26332f;
    --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(14,21,19,.9);
    --hero-grad: linear-gradient(135deg, #082f28 0%, #0e5748 55%, #14745f 100%);
    --hero-text: #eef7f3;
    --hero-sub: #b9d9cf;
  }
}

* { 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(14,124,102,.07), transparent 60%),
    radial-gradient(ellipse 900px 600px at 110% 110%, rgba(201,111,74,.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(14,124,102,.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='%234f605a' 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(14,124,102,.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,18,.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,111,74,.25), 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: #ffd9a8; }
.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 skin diagram ---------- */
.skin-svg { width: 260px; 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 dt:first-child { margin-top: 0; }
.glossary dd {
  margin: .2rem 0 0 0; font-size: .95rem;
  padding-bottom: .4rem; border-bottom: 1px dashed var(--border);
}

/* Compare tables on porównania */
.cmp-good { color: #1a7a4c; font-weight: 600; }
.cmp-bad { color: #b3542e; font-weight: 600; }
@media (prefers-color-scheme: dark) {
  .cmp-good { color: #4fc48d; }
  .cmp-bad { color: #f0916b; }
}

/* Next/prev */
.article-nav {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-top: 2.4rem; padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  font-size: .9rem;
}
.article-nav a {
  text-decoration: none; color: var(--accent-strong);
  font-weight: 600; max-width: 45%;
}
.article-nav a:hover { text-decoration: underline; }
.article-nav .nav-label { display: block; font-size: .75rem; color: var(--muted); font-weight: 400; }

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

/* ---------- Motion ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.reveal { opacity: 0; transform: translateY(10px); 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;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: var(--header-h); left: 0; bottom: 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; }
}
@media (max-width: 600px) {
  body { font-size: 16.5px; }
  .header-inner { padding: 0 .9rem; gap: .7rem; }
  .brand { font-size: 1.15rem; }
  .brand-mark { font-size: 1.05rem; }
  .header-search input { padding-left: 2.1rem; font-size: .88rem; }
  .layout { padding: calc(var(--header-h) + .9rem) .9rem 1.5rem; }
  .home-hero { padding: 1.8rem 1.4rem 1.6rem; }
  .hero-art { display: none; }
  .hero-stats { gap: 1.1rem; }
  .hero-stat b { font-size: 1.4rem; }
  .home-grid { grid-template-columns: 1fr; }
  .article-toc { display: none; }
}
