/* ============================================================
   PIERWSZAPOMOCPROSTO - design system
   Paleta "Ratunkowa czerwień i spokojny granat" (first aid)
   Spectral (display) + Archivo (body)
   ============================================================ */
:root {
  --ink: #16283e;            /* spokojny granat - autorytet w kryzysie */
  --ink-2: #1e3552;
  --panel: #f0ece3;
  --paper: #f6f4ef;          /* krem medycznej czystości */
  --paper-2: #ffffff;
  --red: #a1161f;            /* ratunkowa czerwień (tekst/CTA, 6.4:1) */
  --red-bright: #c81e2e;     /* gradienty, duże elementy */
  --amber: #92400e;          /* ostrzeżenia (7+:1) */
  --amber-bg: #fdf1e3;
  --text: #1c1917;
  --text-dim: #57534e;
  --border: #ddd6c8;
  --shadow: 0 1px 2px rgba(22, 40, 62, .06), 0 8px 24px -12px rgba(22, 40, 62, .18);
  --radius: 12px;
  --header-h: 60px;
  --transition: all .2s ease-out;
  --font-display: 'Spectral', Georgia, serif;
  --font-body: 'Archivo', 'Segoe UI', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #0e1420;
    --ink-2: #141c2b;
    --panel: #1a2230;
    --paper: #10151d;
    --paper-2: #1a2230;
    --red: #ef4444;
    --red-bright: #f87171;
    --amber: #f59e0b;
    --amber-bg: #2a2114;
    --text: #e8e2d8;
    --text-dim: #a8a297;
    --border: #2a3442;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .5);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: clip; }
body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  background: var(--paper);
  background-image:
    radial-gradient(700px 400px at 92% -60px, rgba(200, 30, 46, .06), transparent 60%),
    radial-gradient(600px 380px at -40px 105%, rgba(22, 40, 62, .07), transparent 60%);
  background-attachment: fixed;
  transition: background .3s, color .3s;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
::selection { background: rgba(200, 30, 46, .18); }

:focus-visible { outline: 3px solid var(--red-bright); outline-offset: 2px; border-radius: 4px; }
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--red); color: #fff; padding: .6rem 1rem; border-radius: 0 0 8px 0;
  font-weight: 700; font-size: .9rem;
}
.skip-link:focus { left: 0; }

/* === HEADER === */
.header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: var(--ink);
  color: #f2efe9;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06);
}
.header::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(200, 30, 46, .75), transparent);
  opacity: .8; pointer-events: none;
}
.header-inner {
  max-width: 1280px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; gap: 1.2rem; padding: 0 1.2rem;
}
.mark { display: flex; align-items: center; gap: .55rem; color: #f2efe9; flex-shrink: 0; }
.mark:hover { text-decoration: none; }
.mark-glyph {
  display: grid; place-items: center; width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--red), var(--red-bright));
  border-radius: 9px; color: #fff;
}
.mark-text {
  font-family: var(--font-display); font-weight: 700; font-size: 1.12rem; letter-spacing: .01em;
  white-space: nowrap;
}
.mark-text em { font-style: normal; color: #f0a6ab; }
.search-wrap { position: relative; margin-left: auto; width: min(340px, 34vw); }
.search-ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: #8b95a3; pointer-events: none; }
#search-input {
  width: 100%; height: 38px; padding: 0 12px 0 34px;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 10px; color: #f2efe9; font-family: var(--font-body); font-size: .9rem;
}
#search-input::placeholder { color: #9aa5b4; }
#search-input:focus { outline: none; border-color: var(--red-bright); background: rgba(255, 255, 255, .12); }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 120;
  background: var(--paper-2); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); max-height: 380px; overflow: auto;
}
.search-results a { display: block; padding: .6rem .8rem; border-bottom: 1px solid var(--border); color: var(--text); }
.search-results a:hover { background: var(--panel); text-decoration: none; }
.search-results a strong { display: block; font-size: .88rem; }
.search-results a small { color: var(--text-dim); font-size: .75rem; }
.sr-empty { padding: .8rem; color: var(--text-dim); font-size: .85rem; }

.burger {
  display: none; flex-direction: column; justify-content: center; gap: 4px;
  width: 42px; height: 42px; background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14); border-radius: 10px; cursor: pointer;
}
.burger span { display: block; width: 20px; height: 2px; background: #f2efe9; margin: 0 auto; border-radius: 2px; transition: var(--transition); }
.burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* === LAYOUT === */
.page-wrap { display: flex; max-width: 1280px; margin: 0 auto; padding-top: calc(var(--header-h) + 18px); gap: 1.6rem; padding-left: 1.2rem; padding-right: 1.2rem; }
.sidebar {
  width: 264px; flex-shrink: 0; position: sticky; top: calc(var(--header-h) + 18px);
  height: calc(100vh - var(--header-h) - 36px); overflow-y: auto;
  padding: .9rem 1rem 1.4rem;
  background: var(--paper-2); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  scrollbar-width: thin;
}
.sidebar-home {
  display: flex; align-items: center; gap: .5rem;
  padding: .55rem .6rem; margin-bottom: .4rem; border-radius: 8px;
  color: var(--text); font-weight: 700; font-size: .9rem;
}
.sidebar-home:hover { background: var(--panel); text-decoration: none; }
.sidebar-home.active { background: rgba(200, 30, 46, .1); color: var(--red); }
.sidebar-sec {
  font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-dim); margin: 1rem .6rem .35rem;
}
.sidebar-link {
  display: flex; align-items: flex-start; gap: .5rem;
  padding: .42rem .6rem; border-radius: 8px;
  color: var(--text); font-size: .95rem; line-height: 1.35;
}
.sidebar-link:hover { background: var(--panel); text-decoration: none; }
.sidebar-link.active { background: rgba(200, 30, 46, .1); color: var(--red); font-weight: 600; }
.sico { flex-shrink: 0; font-size: .85rem; line-height: 1.3; }

.main { flex: 1; min-width: 0; }
.main-inner { padding-bottom: 2.4rem; }

/* === HOME HERO === */
.home-hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  background: var(--ink);
  background-image:
    linear-gradient(135deg, #101d31 0%, var(--ink) 55%, #22395a 100%),
    url('https://images.unsplash.com/photo-1505751172876-fa1923c5c528?w=1600&q=70&auto=format&fit=crop');
  background-size: cover; background-position: center 42%;
  color: #f2efe9; padding: 2.6rem 2.4rem;
  box-shadow: var(--shadow);
}
.home-hero::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, rgba(13, 24, 40, .93) 0%, rgba(16, 29, 49, .82) 42%, rgba(16, 29, 49, .55) 100%);
}
.home-hero > * { position: relative; z-index: 1; }
.hero-inner { display: grid; grid-template-columns: 1.15fr .85fr; gap: 1.6rem; align-items: center; }
.badge {
  display: inline-block; font-size: .78rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: #f0a6ab; background: rgba(200, 30, 46, .16); border: 1px solid rgba(200, 30, 46, .4);
  padding: .3rem .7rem; border-radius: 999px; margin-bottom: 1rem;
}
.home-hero h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.9rem, 3.6vw, 2.9rem); line-height: 1.12;
  text-wrap: balance; margin-bottom: .8rem;
}
.home-hero h1 em { font-style: italic; color: #f5a3a8; }
.lead { font-size: 1.02rem; color: #d8dee7; max-width: 34em; margin-bottom: 1.4rem; }
.hero-cta { display: flex; gap: .7rem; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .68rem 1.25rem; border-radius: 10px;
  font-weight: 700; font-size: .95rem; transition: var(--transition);
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn-primary { background: linear-gradient(135deg, var(--red), var(--red-bright)); color: #fff; box-shadow: 0 4px 14px -4px rgba(200, 30, 46, .55); }
.btn-primary:hover { box-shadow: 0 8px 20px -6px rgba(200, 30, 46, .65); }
.btn-ghost { border: 1px solid rgba(255, 255, 255, .35); color: #f2efe9; background: rgba(255, 255, 255, .06); }
.btn-ghost:hover { background: rgba(255, 255, 255, .14); }

/* === EKG SIGNATURE === */
.ekg-wrap { background: rgba(9, 17, 28, .55); border: 1px solid rgba(255, 255, 255, .12); border-radius: 14px; padding: 1rem 1rem .6rem; }
.ekg-title { font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #9fb0c6; margin-bottom: .5rem; display: flex; justify-content: space-between; align-items: center; }
.ekg-title .ekg-tag { color: #f0a6ab; }
.ekg-svg { width: 100%; height: auto; display: block; }
.ekg-line { fill: none; stroke: #ff6b74; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ekg-heart { fill: none; stroke: #ff8f96; stroke-width: 2; }
.ekg-dot { fill: #ffb3b8; }
.chain {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .45rem; margin-top: .7rem;
}
.chain-link {
  display: flex; flex-direction: column; gap: .15rem; align-items: flex-start;
  padding: .5rem .55rem; border-radius: 9px;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .12);
  color: #e6ebf2; font-size: .75rem; line-height: 1.3; transition: var(--transition);
}
.chain-link:hover { background: rgba(200, 30, 46, .22); border-color: rgba(255, 111, 122, .5); text-decoration: none; transform: translateY(-2px); }
.chain-num { display: inline-flex; align-items: center; gap: .3rem; font-weight: 800; font-size: .75rem; letter-spacing: .06em; color: #f0a6ab; }
.chain-dot { width: 7px; height: 7px; border-radius: 50%; background: #ff6b74; animation: pulse 2s ease-in-out infinite; }
.chain-dot.d2 { animation-delay: .5s; }
.chain-dot.d3 { animation-delay: 1s; }
.chain-dot.d4 { animation-delay: 1.5s; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.72); } }
@keyframes dash { to { stroke-dashoffset: 0; } }

/* === STATS STRIP === */
.stats-strip {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;
  margin-top: 1.2rem;
}
.stat {
  background: var(--paper-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow);
}
.stat b { display: block; font-family: var(--font-display); font-weight: 700; font-size: 1.65rem; color: var(--red); line-height: 1.1; }
.stat span { font-size: .82rem; color: var(--text-dim); line-height: 1.45; display: block; margin-top: .2rem; }

/* === HOME SECTIONS === */
.home-section { margin-top: 2.2rem; }
.section-head { display: flex; align-items: baseline; gap: .7rem; margin-bottom: .9rem; }
.section-head h2 { font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; text-wrap: balance; }
.section-head h2::before { content: ''; display: inline-block; width: 14px; height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--red), var(--red-bright)); margin-right: .55rem; vertical-align: middle; }
.sec-count { font-size: .78rem; color: var(--text-dim); font-weight: 600; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: .9rem; }
.home-card {
  position: relative; display: block;
  background: var(--paper-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.05rem 1.1rem .95rem; box-shadow: var(--shadow);
  transition: var(--transition); overflow: hidden;
}
.home-card:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(22, 40, 62, .08), 0 14px 34px -14px rgba(22, 40, 62, .25); text-decoration: none; }
.home-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--red), var(--red-bright));
  opacity: 0; transition: var(--transition);
}
.home-card:hover::before { opacity: 1; }
.home-card .ico { font-size: 1.3rem; display: block; margin-bottom: .45rem; }
.home-card h3 { font-size: .95rem; font-weight: 700; line-height: 1.35; margin-bottom: .3rem; color: var(--text); text-wrap: balance; }
.home-card p { font-size: .85rem; color: var(--text-dim); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-arrow {
  position: absolute; right: .9rem; top: .9rem; font-size: 1rem;
  opacity: 0; transform: translateX(-6px); transition: var(--transition); color: var(--red);
}
.home-card:hover .card-arrow { opacity: 1; transform: translateX(0); }

/* === ARTICLE === */
.article { background: var(--paper-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem 2.2rem 2.6rem; box-shadow: var(--shadow); }
.breadcrumbs { font-size: .8rem; color: var(--text-dim); margin-bottom: .9rem; }
.breadcrumbs a { color: var(--red); }
.breadcrumbs span { margin: 0 .35rem; }
.article h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.7rem, 3vw, 2.3rem); line-height: 1.15; text-wrap: balance; margin-bottom: .6rem; }
.meta { display: flex; flex-wrap: wrap; gap: .5rem .9rem; align-items: center; font-size: .8rem; color: var(--text-dim); margin-bottom: 1.2rem; }
.meta-sec { font-weight: 700; color: var(--red); text-transform: uppercase; letter-spacing: .05em; font-size: .75rem; }
.trust-badge {
  font-size: .75rem; font-weight: 700; color: var(--amber);
  background: var(--amber-bg); border: 1px solid rgba(146, 64, 14, .25);
  padding: .22rem .6rem; border-radius: 999px;
}
.article h2 {
  font-family: var(--font-display); font-weight: 700; font-size: 1.4rem;
  margin: 2rem 0 .7rem; padding-top: .4rem; text-wrap: balance;
}
.article h2::before { content: ''; display: inline-block; width: 12px; height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--red), var(--red-bright)); margin-right: .5rem; vertical-align: middle; }
.article h3 { font-family: var(--font-display); font-weight: 700; font-size: 1.12rem; margin: 1.5rem 0 .5rem; text-wrap: balance; }
.article p { margin-bottom: .95rem; }
.article ul, .article ol { margin: 0 0 1rem 1.35rem; }
.article li { margin-bottom: .4rem; }
.article strong { font-weight: 700; }
.article em { font-style: italic; }
.article a { text-decoration: underline; text-underline-offset: 3px; }
.article a:hover { text-decoration-thickness: 2px; }

/* TOC */
.toc {
  background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--red);
  border-radius: 10px; padding: .9rem 1.1rem; margin: 1.2rem 0 1.6rem;
}
.toc > b { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); margin-bottom: .5rem; }
.toc-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .25rem .8rem; }
.toc-links a { display: block; font-size: .86rem; padding: .18rem 0; color: var(--text); }
.toc-links a:hover { color: var(--red); }

/* TABLES */
.table-responsive { overflow-x: auto; margin: 1.2rem 0; border-radius: 10px; border: 1px solid var(--border); }
.cmp-table, .error-table { width: 100%; border-collapse: collapse; font-size: .88rem; background: var(--paper-2); min-width: 560px; }
.cmp-table th, .error-table th {
  background: var(--ink); color: #f2efe9; text-align: left;
  padding: .65rem .8rem; font-size: .8rem; letter-spacing: .02em;
}
.cmp-table td, .error-table td { padding: .6rem .8rem; border-top: 1px solid var(--border); vertical-align: top; }
.cmp-table tr:nth-child(even) td, .error-table tr:nth-child(even) td { background: rgba(22, 40, 62, .03); }
.cmp-table td:first-child { font-weight: 700; }
.error-table td:first-child { font-weight: 700; color: var(--red); white-space: nowrap; }

/* INFO + WARN boxes */
.info-box, .warn-box {
  border-radius: 10px; padding: .95rem 1.1rem; margin: 1.2rem 0; font-size: .92rem; line-height: 1.6;
}
.info-box {
  background: rgba(22, 40, 62, .05); border: 1px solid rgba(22, 40, 62, .18); border-left: 4px solid var(--ink);
}
.info-box b:first-child, .warn-box b:first-child { display: block; margin-bottom: .3rem; text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; }
.info-box b:first-child { color: var(--ink); }
.warn-box {
  background: var(--amber-bg); border: 1px solid rgba(146, 64, 14, .3); border-left: 4px solid var(--amber);
}
.warn-box b:first-child { color: var(--amber); }

/* FAQ */
.faq-item { border: 1px solid var(--border); border-radius: 10px; margin-bottom: .6rem; overflow: hidden; background: var(--paper-2); }
.faq-q {
  display: flex; justify-content: space-between; align-items: center; gap: .8rem;
  width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  padding: .85rem 1rem; font-family: var(--font-body); font-weight: 700; font-size: .95rem; color: var(--text);
}
.faq-q:hover { background: var(--panel); }
.faq-q .faq-arrow { color: var(--red); transition: var(--transition); flex-shrink: 0; }
.faq-item.open .faq-arrow { transform: rotate(180deg); }
.faq-a { display: none; padding: 0 1rem 1rem; font-size: .92rem; color: var(--text-dim); line-height: 1.65; }
.faq-item.open .faq-a { display: block; }
.faq-item.open .faq-q { border-bottom: 1px solid var(--border); }

/* Glossary */
.glossary { margin: 1.2rem 0; }
.glossary dt {
  font-weight: 700; color: var(--red); margin-top: 1rem; font-size: .98rem;
}
.glossary dt::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--red); margin-right: .5rem; }
.glossary dd { margin: .25rem 0 0 1rem; color: var(--text-dim); font-size: .92rem; }

/* Steps (numbered) */
.steps { counter-reset: step; list-style: none; margin: 1.1rem 0 !important; }
.steps li {
  counter-increment: step; position: relative;
  padding: .55rem 0 .55rem 2.7rem; margin-bottom: .35rem;
}
.steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute; left: 0; top: .55rem;
  width: 1.9rem; height: 1.9rem; border-radius: 8px;
  background: linear-gradient(135deg, var(--red), var(--red-bright)); color: #fff;
  font-weight: 800; font-size: .78rem; display: grid; place-items: center;
}

/* CHECKLIST */
.checklist { list-style: none; margin: 1rem 0 !important; }
.checklist li { padding-left: 1.9rem; position: relative; margin-bottom: .45rem; }
.checklist li::before {
  content: '✓'; position: absolute; left: 0; top: 0;
  color: #fff; background: linear-gradient(135deg, #2f7d4f, #3f9d63);
  width: 1.35rem; height: 1.35rem; border-radius: 6px; display: grid; place-items: center;
  font-size: .78rem; font-weight: 800; margin-top: .15rem;
}

/* 404 */
.error-page { background: var(--paper-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 3rem 2rem; text-align: center; box-shadow: var(--shadow); }
.error-page h1 { font-family: var(--font-display); font-size: 3.4rem; color: var(--red); }

/* FOOTER */
.footer { border-top: 1px solid var(--border); margin-top: 1.6rem; padding: 1.4rem 0 .4rem; color: var(--text-dim); font-size: .82rem; line-height: 1.7; }
.footer-links { margin-top: .5rem; }
.footer-links a { color: var(--red); margin: 0 .35rem; }
.footer-links span { opacity: .5; }

/* === RESPONSIVE === */
@media (max-width: 1100px) {
  .hero-inner { grid-template-columns: 1fr; }
  .ekg-wrap { max-width: 460px; }
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: var(--header-h); left: 0; bottom: 0; z-index: 90;
    width: min(320px, 86vw); height: auto;
    transform: translateX(-105%); transition: transform .25s ease-out;
    border-radius: 0 14px 0 0; border-left: none; border-top: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
  .burger { display: flex; }
  .search-wrap { width: min(240px, 36vw); }
  .stats-strip { grid-template-columns: 1fr; }
  .chain { grid-template-columns: repeat(2, 1fr); }
  .article { padding: 1.5rem 1.2rem 2rem; }
}
@media (max-width: 600px) {
  body { font-size: 16.5px; }
  .header-inner { gap: .7rem; padding: 0 .8rem; }
  .mark-text { font-size: 1rem; }
  .search-wrap { width: auto; flex: 1; min-width: 0; }
  #search-input { font-size: .85rem; }
  .home-hero { padding: 1.8rem 1.2rem; }
  .home-grid { grid-template-columns: 1fr; }
  .toc-links { grid-template-columns: 1fr; }
  .page-wrap { padding-left: .8rem; padding-right: .8rem; }
  .hero-cta .btn { width: 100%; justify-content: center; }
}

/* === MOTION === */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.main-inner > * { animation: fadeUp .28s ease-out both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .home-card:hover, .btn:hover, .chain-link:hover { transform: none; }
}
