/* ============================================================
   Mężczyzna - design system
   Paleta: głęboka zieleń (zaufanie medyczne) + złoto (energia) + krem
   Typografia: Spectral (display serif) + Archivo (body)
   ============================================================ */

:root {
  --green: #16634a;
  --green-deep: #0f4a36;
  --accent: #8f5400;
  --accent-strong: #6b3d00;
  --accent-soft: #f5e8d2;
  --text: #16211c;
  --muted: #5c6b62;
  --bg: #f6f1e6;
  --bg-soft: #ede5d3;
  --card: #fffdf7;
  --border: #e0d7c3;
  --header-bg: rgba(246, 241, 230, 0.92);
  --shadow: 0 1px 2px rgba(22, 33, 28, 0.05), 0 8px 24px rgba(22, 33, 28, 0.06);
  --shadow-hover: 0 2px 4px rgba(22, 33, 28, 0.07), 0 14px 34px rgba(22, 33, 28, 0.1);
  --radius: 14px;
  --radius-sm: 9px;
  --transition: all 0.2s ease-out;
  --font-display: "Spectral", Georgia, serif;
  --font-body: "Archivo", "Segoe UI", sans-serif;
  --header-height: 64px;
  --sidebar-width: 280px;
  --accent-light: #e8a33d;
  --accent-subtle: rgba(143, 84, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --green: #5bb98d;
    --green-deep: #4aa87a;
    --accent: #e8a33d;
    --accent-strong: #f2b75e;
    --accent-soft: #33271a;
    --text: #e8e2d2;
    --muted: #a8b8ae;
    --bg: #101713;
    --bg-soft: #18231d;
    --card: #1a261f;
    --border: #2b3a31;
    --header-bg: rgba(16, 23, 19, 0.92);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.35), 0 14px 34px rgba(0, 0, 0, 0.4);
    --accent-light: #f2b75e;
    --accent-subtle: rgba(232, 163, 61, 0.3);
  }
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 900px 500px at -10% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(ellipse 900px 500px at 110% 110%, rgba(22, 99, 74, 0.09), transparent 60%);
  background-attachment: fixed;
  min-height: 100vh;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff; padding: 10px 18px;
  border-radius: 0 0 8px 0; z-index: 1000; font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-height);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.app-header::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-subtle), transparent);
  opacity: 0.3; pointer-events: none;
}
.header-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 20px;
  height: 100%; display: flex; align-items: center; gap: 24px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text); flex-shrink: 0;
}
.brand-pulse { display: block; }
.brand-text {
  font-family: var(--font-display); font-size: 1.35rem; font-weight: 600;
  letter-spacing: -0.01em;
}
.brand-text strong { color: var(--accent); font-weight: 700; }

.search-wrap { position: relative; flex: 1; max-width: 460px; margin-left: auto; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
#search-input {
  width: 100%; padding: 10px 16px 10px 40px;
  font: inherit; font-size: 0.95rem;
  color: var(--text); background: var(--card);
  border: 1px solid var(--border); border-radius: 999px;
  outline: none; transition: var(--transition);
}
#search-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22, 99, 74, 0.18); }
#search-input::placeholder { color: var(--muted); }

.menu-toggle {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: 0; cursor: pointer; padding: 8px;
}
.menu-toggle span {
  width: 24px; 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); }

/* Search results dropdown */
.search-results {
  position: absolute; top: calc(var(--header-height) - 6px); left: 0; right: 0;
  max-width: 560px; margin: 0 auto; z-index: 200;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-hover);
  overflow: hidden;
}
.search-results a {
  display: block; padding: 12px 18px; text-decoration: none;
  color: var(--text); border-bottom: 1px solid var(--border);
  transition: var(--transition);
}
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover, .search-results a:focus { background: var(--bg-soft); }
.search-results .sr-title { font-weight: 600; font-size: 0.95rem; }
.search-results .sr-section { font-size: 0.78rem; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; }
.search-results .sr-empty { padding: 16px 18px; color: var(--muted); font-size: 0.95rem; }

/* ---------- Layout ---------- */
.layout {
  max-width: 1280px; margin: 0 auto; padding: calc(var(--header-height) + 24px) 20px 40px;
  display: grid; grid-template-columns: var(--sidebar-width) 1fr; gap: 40px;
  align-items: start;
}

.sidebar {
  position: sticky; top: calc(var(--header-height) + 20px);
  max-height: calc(100vh - var(--header-height) - 40px);
  overflow-y: auto;
  padding: 6px 4px;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-section-title {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--muted);
  padding: 14px 12px 6px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.95rem; font-weight: 500; line-height: 1.35;
  color: var(--text); text-decoration: none;
  padding: 8px 12px; border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  transition: var(--transition);
}
.sidebar-link:hover { background: var(--bg-soft); color: var(--accent); }
.sidebar-link.active {
  background: var(--accent-soft); color: var(--accent-strong);
  border-left-color: var(--accent); font-weight: 600;
}
.sidebar-link .sl-icon { font-size: 1rem; flex-shrink: 0; }

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

/* ---------- Main content ---------- */
.main { min-width: 0; }
.content { animation: fadeUp 0.28s ease-out both; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.content-article { max-width: 780px; }
.content-article h1 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 700; line-height: 1.18;
  margin: 0 0 10px; text-wrap: balance;
}
.article-meta {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); font-size: 0.88rem; margin-bottom: 22px;
}
.article-meta .section-badge {
  background: var(--accent-soft); color: var(--accent-strong);
  padding: 3px 12px; border-radius: 999px; font-weight: 600;
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em;
}
.content-article h2 {
  font-family: var(--font-display);
  font-size: 1.5rem; font-weight: 600; line-height: 1.3;
  margin: 34px 0 12px; text-wrap: balance;
  scroll-margin-top: calc(var(--header-height) + 20px);
}
.content-article h3 {
  font-family: var(--font-display);
  font-size: 1.15rem; font-weight: 600;
  margin: 24px 0 8px; text-wrap: balance;
  scroll-margin-top: calc(var(--header-height) + 20px);
}
.content-article p { margin: 0 0 16px; }
.content-article ul, .content-article ol { margin: 0 0 18px; padding-left: 24px; }
.content-article li { margin-bottom: 7px; }
.content-article li::marker { color: var(--accent); }
.content-article a { color: var(--green-deep); text-decoration: underline; text-underline-offset: 3px; }
@media (prefers-color-scheme: dark) { .content-article a { color: var(--green); } }
.content-article a:hover { color: var(--accent); }
.content-article strong { font-weight: 700; }
.content-article blockquote {
  border-left: 4px solid var(--accent);
  background: var(--bg-soft); padding: 14px 18px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 0 0 18px; font-style: italic;
}

/* Article TOC */
.article-toc {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 22px; margin: 0 0 26px;
  box-shadow: var(--shadow);
}
.article-toc h2 { font-size: 1.05rem; margin: 0 0 10px; font-family: var(--font-body); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.article-toc ol { margin: 0; padding-left: 20px; }
.article-toc li { margin-bottom: 5px; font-size: 0.95rem; }
.article-toc a { text-decoration: none; color: var(--text); }
.article-toc a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Components ---------- */
.info-box {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px; margin: 0 0 18px; font-size: 0.97rem;
}
.info-box strong { color: var(--accent-strong); }
.info-teal {
  background: rgba(22, 99, 74, 0.09);
  border-left-color: var(--green);
}
.info-teal strong { color: var(--green-deep); }
@media (prefers-color-scheme: dark) {
  .info-teal { background: rgba(91, 185, 141, 0.1); }
  .info-teal strong { color: var(--green); }
}
.warn-box {
  background: rgba(143, 84, 0, 0.1);
  border: 1px solid rgba(143, 84, 0, 0.35);
  border-radius: var(--radius-sm);
  padding: 14px 18px; margin: 0 0 18px; font-size: 0.97rem;
}
.warn-box strong { color: var(--accent-strong); }

.table-responsive { overflow-x: auto; margin: 0 0 18px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table.error-table, table.compare-table {
  width: 100%; border-collapse: collapse; font-size: 0.93rem;
  background: var(--card);
}
.error-table th, .error-table td, .compare-table th, .compare-table td {
  padding: 11px 14px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.error-table thead th, .compare-table thead th {
  background: var(--green-deep); color: #fff;
  font-weight: 600; font-size: 0.88rem;
}
@media (prefers-color-scheme: dark) {
  .error-table thead th, .compare-table thead th { background: rgba(91, 185, 141, 0.16); color: var(--green); }
}
.error-table tr:last-child td, .compare-table tr:last-child td { border-bottom: 0; }
.error-table tbody tr:nth-child(even), .compare-table tbody tr:nth-child(even) { background: var(--bg-soft); }
.error-table td:first-child, .compare-table td:first-child { font-weight: 600; white-space: nowrap; }

.faq-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; margin: 0 0 12px;
  box-shadow: var(--shadow);
}
.faq-item h3 {
  font-family: var(--font-body); font-size: 1.05rem; font-weight: 700;
  margin: 0 0 8px; color: var(--accent-strong);
}
.faq-item p, .faq-item ul { margin: 0; font-size: 0.97rem; }
.faq-item ul { padding-left: 20px; margin-top: 8px; }

dl.glossary { margin: 0 0 18px; }
dl.glossary dt {
  font-weight: 700; color: var(--green-deep);
  padding: 10px 0 2px; font-size: 1.02rem;
}
@media (prefers-color-scheme: dark) { dl.glossary dt { color: var(--green); } }
dl.glossary dd { margin: 0 0 6px 0; padding-left: 0; font-size: 0.97rem; }

.steps-list { counter-reset: step; list-style: none; padding-left: 0 !important; }
.steps-list li {
  counter-increment: step; position: relative;
  padding: 4px 0 14px 48px; margin: 0 !important;
}
.steps-list li::before {
  content: counter(step);
  position: absolute; left: 0; top: 2px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.92rem;
}

/* ---------- Home ---------- */
.home-hero {
  position: relative;
  border-radius: var(--radius);
  padding: 44px 44px 40px;
  margin: 0 0 34px;
  background: linear-gradient(135deg, var(--green-deep) 0%, #0d4a36 55%, #5a3600 130%);
  color: #f6f1e6;
  overflow: hidden;
  box-shadow: var(--shadow-hover);
}
.home-hero::before {
  content: "";
  position: absolute; right: -60px; top: -60px; width: 300px; height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 163, 61, 0.35), transparent 70%);
}
.home-hero::after {
  content: "";
  position: absolute; left: 42%; top: -120px; width: 280px; height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(91, 185, 141, 0.2), transparent 70%);
}
.home-hero .hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.12em; color: #f6d9a8;
  margin-bottom: 14px;
}
.home-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4.2vw, 2.7rem);
  font-weight: 700; line-height: 1.2; margin: 0 0 12px;
  color: #fff; text-wrap: balance; position: relative; z-index: 1;
}
.home-hero .hero-sub {
  font-size: 1.06rem; color: rgba(246, 241, 230, 0.92);
  max-width: 560px; margin: 0 0 20px; position: relative; z-index: 1;
}
.hero-cta {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin: 0 0 22px; position: relative; z-index: 1;
}
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fff;
  font-weight: 700; font-size: 0.98rem;
  padding: 11px 22px; border-radius: 999px;
  text-decoration: none; transition: var(--transition);
  box-shadow: 0 4px 14px rgba(143, 84, 0, 0.35);
}
.btn-primary:hover { background: var(--accent-strong); transform: translateY(-1px); }
.btn-ghost {
  display: inline-flex; align-items: center;
  color: #f6f1e6; font-weight: 600; font-size: 0.98rem;
  padding: 11px 22px; border-radius: 999px;
  border: 1px solid rgba(246, 241, 230, 0.45);
  text-decoration: none; transition: var(--transition);
}
.btn-ghost:hover { background: rgba(246, 241, 230, 0.12); }
.hero-stats {
  display: flex; gap: 28px; flex-wrap: wrap;
  position: relative; z-index: 1;
}
.hero-stats .stat { display: flex; flex-direction: column; }
.hero-stats .stat b { font-size: 1.5rem; font-family: var(--font-display); color: #f6d9a8; line-height: 1.2; }
.hero-stats .stat span { font-size: 0.82rem; color: rgba(246, 241, 230, 0.8); }

/* Hero ECG pulse line (signature element) */
.hero-ecg {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 64px; opacity: 0.5; pointer-events: none;
}
.hero-ecg path {
  fill: none;
  stroke: rgba(246, 217, 168, 0.55);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 400;
  stroke-dashoffset: 400;
  animation: ecgDraw 2.4s ease-out forwards;
}
@keyframes ecgDraw { to { stroke-dashoffset: 0; } }

.home-section { margin: 0 0 34px; }
.home-section-header {
  display: flex; align-items: baseline; gap: 14px;
  margin: 0 0 16px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.home-section-header h2 {
  font-family: var(--font-display);
  font-size: 1.45rem; font-weight: 600; text-wrap: balance;
}
.home-section-header .sec-count {
  font-size: 0.8rem; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em;
}

.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.home-card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  text-decoration: none; color: var(--text);
  box-shadow: var(--shadow);
  transition: var(--transition);
  position: relative;
}
.home-card::before {
  content: ""; position: absolute; top: 0; left: 18px; right: 18px; height: 3px;
  background: linear-gradient(90deg, var(--green), var(--accent));
  border-radius: 0 0 4px 4px;
  opacity: 0; transition: var(--transition);
}
.home-card:hover, .home-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--green);
}
.home-card:hover::before { opacity: 1; }
.home-card .card-icon { font-size: 1.5rem; line-height: 1; }
.home-card h3 { font-size: 0.98rem; font-weight: 700; line-height: 1.35; text-wrap: balance; }
.home-card p { font-size: 0.875rem; color: var(--muted); line-height: 1.55; }
.home-card .card-more {
  margin-top: auto; font-size: 0.85rem; font-weight: 700;
  color: var(--green-deep); display: flex; align-items: center; gap: 4px;
}
@media (prefers-color-scheme: dark) { .home-card .card-more { color: var(--green); } }
.home-card:hover .card-more { color: var(--accent); }

.home-about {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 26px 28px;
  box-shadow: var(--shadow); margin: 0 0 34px;
}
.home-about h2 { font-family: var(--font-display); font-size: 1.4rem; margin-bottom: 10px; }
.home-about p { color: var(--muted); max-width: 720px; }

/* ---------- Footer ---------- */
.app-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  margin-top: 20px;
}
.footer-inner {
  max-width: 1280px; margin: 0 auto; padding: 28px 20px 40px;
  color: var(--muted); font-size: 0.9rem;
}
.footer-inner p { margin-bottom: 6px; }
.footer-note { font-size: 0.82rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 0; padding-top: calc(var(--header-height) + 16px); }
  .sidebar {
    position: fixed; top: var(--header-height); bottom: 0; left: 0;
    width: min(300px, 84vw); z-index: 95;
    background: var(--bg); border-right: 1px solid var(--border);
    padding: 12px 16px 30px;
    transform: translateX(-105%);
    transition: transform 0.25s ease-out;
    max-height: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-hover); }
  .sidebar-overlay.show { display: block; }
  .menu-toggle { display: flex; }
  .search-wrap { max-width: none; }
  .home-hero { padding: 32px 26px; }
}

@media (max-width: 600px) {
  body { font-size: 17px; }
  .header-inner { padding: 0 14px; gap: 12px; }
  .brand-text { font-size: 1.15rem; }
  #search-input { font-size: 0.9rem; padding: 9px 12px 9px 36px; }
  .card-grid { grid-template-columns: 1fr; }
  .content-article h1 { font-size: 1.7rem; }
  .home-hero h1 { font-size: 1.55rem; }
  .hero-ecg { height: 44px; }
}
