/* ============================================================
   Żylaki - design system
   Koncepcja: "krew i żyła" - karmazyn krwi żylnej + granat
   zaufania medycznego + krem papieru + śliwkowy grafit.
   Premium, medycznie ciepłe - bez generycznego niebieskiego.
   ============================================================ */

:root {
  /* Light */
  --bg: #f7f2ea;
  --card: #ffffff;
  --text: #26212b;
  --muted: #6a6170;
  --accent: #a3203a;
  --accent-strong: #7e1830;
  --accent-soft: #f6e3e7;
  --vein-blue: #46618f;
  --vein-soft: #e4eaf3;
  --green: #3f6f4a;
  --green-soft: #e3ede4;
  --border: #e5ddd2;
  --header-bg: #16121a;
  --header-text: #f2ecf3;
  --sidebar-bg: #fffcf7;
  --code-bg: #f1ece5;
  --shadow: 0 1px 3px rgba(38, 33, 43, 0.08), 0 4px 14px rgba(38, 33, 43, 0.06);
  --shadow-hover: 0 4px 10px rgba(38, 33, 43, 0.1), 0 10px 26px rgba(38, 33, 43, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease-out;
  --font-display: 'Alegreya', Georgia, serif;
  --font-body: 'Onest', 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16121a;
    --card: #1f1923;
    --text: #ece6ee;
    --muted: #a89fb0;
    --accent: #e0556d;
    --accent-strong: #f2a0ae;
    --accent-soft: #2c1a22;
    --vein-blue: #7d9cc9;
    --vein-soft: #1b2331;
    --green: #7fae88;
    --green-soft: #1d271f;
    --border: #2c2531;
    --header-bg: #0f0c13;
    --header-text: #f2ecf3;
    --sidebar-bg: #1a141e;
    --code-bg: #241d29;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 10px rgba(0, 0, 0, 0.5), 0 10px 26px rgba(0, 0, 0, 0.4);
  }
}

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

html { overflow-x: clip; }

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 500px at -10% -5%, var(--accent-soft) 0%, transparent 60%),
    radial-gradient(ellipse 800px 500px at 110% 110%, var(--vein-soft) 0%, transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.2;
  text-wrap: balance;
}

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

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

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

/* ---------- header ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  color: var(--header-text);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.app-header::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.35;
  pointer-events: none;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--header-text);
  text-decoration: none;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #16121a;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}
.brand-name em {
  font-style: normal;
  color: var(--accent);
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 460px;
  margin-left: auto;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
#search-input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: var(--header-text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color var(--transition), background var(--transition);
}
#search-input::placeholder { color: rgba(242, 236, 243, 0.55); }
#search-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.13);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-hover);
  overflow: hidden;
  z-index: 120;
}
.search-result {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.search-result:last-child { border-bottom: none; }
.search-result span { display: block; font-weight: 600; font-size: 0.95rem; }
.search-result small { color: var(--muted); font-size: 0.78rem; }
.search-result:hover, .search-result.active { background: var(--accent-soft); text-decoration: none; }
.search-empty { padding: 12px 14px; color: var(--muted); font-size: 0.9rem; }

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--header-text);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
}

/* ---------- layout ---------- */

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 78px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  scrollbar-width: thin;
}

.sidebar-nav-section { margin-bottom: 16px; }
.sidebar-nav-section:last-child { margin-bottom: 0; }

.sidebar-section-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  padding: 0 8px 6px;
}

.sidebar-link {
  display: block;
  padding: 5px 8px;
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--text);
  border-radius: 6px;
  border-left: 2px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}
.sidebar-link:hover { background: var(--accent-soft); text-decoration: none; }
.sidebar-link.active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  font-weight: 600;
}

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

/* ---------- main / hero ---------- */

.main { min-width: 0; }

.page-enter { animation: fadeUp 0.26s ease-out both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.home-hero {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background:
    linear-gradient(135deg, #16121a 0%, #231726 55%, #1a1420 100%);
  color: #f2ecf3;
  padding: 44px 40px;
  margin-bottom: 28px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.home-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 620px 320px at 82% 12%, rgba(224, 85, 109, 0.18) 0%, transparent 65%),
    radial-gradient(ellipse 420px 260px at 8% 100%, rgba(125, 156, 201, 0.1) 0%, transparent 60%);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 32px;
  align-items: center;
}

.hero-kicker {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #f2a0ae;
  margin-bottom: 12px;
}

.hero-copy h1 {
  font-size: clamp(1.9rem, 4vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}

.hero-sub {
  font-size: 1.05rem;
  color: #cfc6d6;
  max-width: 46ch;
  margin-bottom: 20px;
}

.hero-stats {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.hero-stat {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: #f2ecf3;
}
.hero-stat small {
  display: block;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
  color: #a89fb0;
  text-transform: none;
}

.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
  display: inline-block;
  padding: 11px 22px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn-primary {
  background: #a3203a;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(163, 32, 58, 0.35);
}
.btn-primary:hover { background: #b62c48; }
@media (prefers-color-scheme: dark) {
  .btn-primary {
    background: #e0556d;
    color: #16121a;
    box-shadow: 0 4px 14px rgba(224, 85, 109, 0.25);
  }
  .btn-primary:hover { background: #f06a80; }
}
.btn-ghost {
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  color: #f2ecf3;
  background: rgba(255, 255, 255, 0.08);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.16); }

/* Signature: żyła z zastawkami */
.hero-vein {
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.hero-vein svg { display: block; width: 100%; height: auto; }
.vein-label {
  font-family: var(--font-body);
  font-size: 12px;
  fill: #a89fb0;
}
.vein-cell { fill: #e0556d; }
.vein-cell-soft { fill: #f2a0ae; }
.vein-cells .c1 { animation: veinFlow 9s linear infinite; }
.vein-cells .c2 { animation: veinFlow 11s linear infinite; animation-delay: -3s; }
.vein-cells .c3 { animation: veinFlow 8s linear infinite; animation-delay: -5s; }
.vein-cells .c4 { animation: veinFlow 12s linear infinite; animation-delay: -7s; }
.vein-cells .c5 { animation: veinFlow 10s linear infinite; animation-delay: -2s; }
@keyframes veinFlow {
  0% { transform: translateX(-300px); opacity: 0; }
  8% { opacity: 0.9; }
  92% { opacity: 0.9; }
  100% { transform: translateX(300px); opacity: 0; }
}

/* ---------- AZ index ---------- */

.az-index {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 28px;
  box-shadow: var(--shadow);
}
.az-index h2 { font-size: 1.2rem; margin-bottom: 4px; }
.az-hint { color: var(--muted); font-size: 0.9rem; margin-bottom: 14px; }
.az-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.az-letter {
  min-width: 34px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}
.az-letter:hover { border-color: var(--accent); }
.az-letter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- home sections / cards ---------- */

.home-section { margin-bottom: 30px; }

.home-section h2 {
  font-size: 1.35rem;
  margin-bottom: 4px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.section-count {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.home-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.home-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
  text-decoration: none;
}
.home-card.hidden { display: none; }
.card-icon { font-size: 1.5rem; display: block; margin-bottom: 8px; }
.home-card h3 { font-size: 0.9rem; margin-bottom: 6px; line-height: 1.3; }
.home-card p {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- article ---------- */

.article {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 36px;
  box-shadow: var(--shadow);
}

.article-head { margin-bottom: 20px; }

.article-kicker {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-strong);
  margin-bottom: 10px;
}

.article h1 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); margin-bottom: 12px; }

.article-meta {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.85rem;
}
.trust-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
}
.read-time { font-weight: 500; }

.article-body { font-size: 1.02rem; }

.article-body h2 {
  font-size: 1.4rem;
  margin: 30px 0 12px;
  padding-top: 8px;
  scroll-margin-top: 90px;
}
.article-body h3 {
  font-size: 1.12rem;
  margin: 22px 0 8px;
  scroll-margin-top: 90px;
}
.article-body p { margin-bottom: 14px; }
.article-body ul, .article-body ol { margin: 0 0 14px 22px; }
.article-body li { margin-bottom: 6px; }
.article-body strong { font-weight: 700; }

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 20px;
  font-size: 0.92rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.article-body th, .article-body td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.article-body th {
  background: var(--accent-soft);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
}
.article-body tr:last-child td { border-bottom: none; }

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 16px 0 20px;
  border-radius: var(--radius-sm);
}
.table-responsive table { margin: 0; min-width: 560px; }
.table-responsive .compare-table th {
  background: var(--accent-soft);
}

.info-box {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 16px;
  margin: 16px 0;
}
.info-box p:last-child { margin-bottom: 0; }

.warning-box {
  background: #fdeaea;
  border-left: 4px solid #c0392b;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 16px;
  margin: 16px 0;
  color: #7b241c;
}
@media (prefers-color-scheme: dark) {
  .warning-box { background: #2a1715; color: #e8a59e; }
}

.error-table th { background: #fdeaea; }
@media (prefers-color-scheme: dark) {
  .error-table th { background: #2a1715; }
}

.faq-item { margin-bottom: 18px; }
.faq-item h3 { margin-bottom: 6px; }
.faq-item p { margin-bottom: 0; }

dl.glossary dt {
  font-family: var(--font-display);
  font-weight: 700;
  margin-top: 14px;
  color: var(--accent-strong);
}
dl.glossary dd { margin: 2px 0 0 0; color: var(--muted); }

.article-note {
  margin-top: 26px;
  padding: 12px 16px;
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--muted);
}

.toc {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 22px;
  font-size: 0.92rem;
}
.toc-title {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 8px;
}
.toc ol { margin: 0 0 0 18px; }
.toc li { margin-bottom: 4px; }
.toc a { color: var(--text); }
.toc a:hover { color: var(--accent-strong); }

.article-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.article-nav a {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  transition: border-color var(--transition), background var(--transition);
}
.article-nav a:hover { border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.article-nav a.next { text-align: right; }
.article-nav small { display: block; color: var(--muted); font-weight: 400; font-size: 0.75rem; }

/* ---------- notfound ---------- */

.notfound { text-align: center; padding: 60px 20px; }
.notfound h1 { font-size: 3rem; color: var(--accent-strong); }
.notfound p { margin-bottom: 10px; }

/* ---------- footer ---------- */

.app-footer {
  border-top: 1px solid var(--border);
  background: var(--card);
  margin-top: 40px;
}
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 20px 30px;
}
.footer-brand { font-family: var(--font-display); font-weight: 700; margin-bottom: 8px; }
.footer-brand em { font-style: normal; color: var(--accent-strong); }
.disclaimer { color: var(--muted); font-size: 0.82rem; max-width: 70ch; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 16px 14px;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    max-height: none;
    width: min(320px, 86vw);
    border-radius: 0;
    transform: translateX(-100%);
    transition: transform 0.24s ease-out;
    z-index: 110;
    padding: 24px 16px 40px;
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .search-wrap { max-width: none; }
  .hero-inner { grid-template-columns: 1fr; }
  .hero-vein { max-width: 420px; }
  .article { padding: 24px 20px; }
}

@media (max-width: 600px) {
  body { font-size: 16.5px; }
  .header-inner { padding: 8px 12px; gap: 10px; }
  .brand-name { font-size: 1.1rem; }
  .home-hero { padding: 30px 22px; }
  .article-nav { grid-template-columns: 1fr; }
  .article-nav a.next { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
