/* ==========================================================================
   Laryngo - Design system
   Koncept: "złoto otoskopu" - granatowo-morski teal (zaufanie medyczne,
   wzorzec NHS/ENT Health/WebMD) + ciepłe złoto otoskopu (ludzkie ciepło) +
   krem (przyjazność) + czerwień tylko do czerwonych flag (wzorzec NHS).
   Typografia: Zilla Slab (display) + Nunito Sans (body) + Share Tech Mono
   ========================================================================== */

:root {
  /* Light theme - krem, granat morski, złoto otoskopu */
  --bg: #f7f4ee;
  --bg-soft: #efe9df;
  --card: #fffdf8;
  --card-border: #e2dccf;
  --text: #26333d;
  --text-soft: #4d5c66;
  --muted: #78858d;
  --ink: #0d1b24;
  --accent: #b45309;          /* złoto otoskopu (amber-700) */
  --accent-strong: #92400e;
  --accent-soft: #f3e0c8;
  --gold: #d97706;
  --teal: #0e7490;            /* akcent wtórny - zdrowie, czystość */
  --teal-strong: #0b5d73;
  --teal-soft: #d8eef3;
  --danger: #b91c1c;          /* czerwone flagi (wzorzec NHS) */
  --danger-soft: #f6dcdc;
  --header-bg: #f7f4ee;
  --sidebar-bg: #f1ece2;
  --shadow: 0 1px 2px rgba(13,27,36,.06), 0 8px 24px rgba(13,27,36,.06);
  --shadow-hover: 0 4px 12px rgba(13,27,36,.1), 0 16px 40px rgba(13,27,36,.1);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 60px;
  --sidebar-w: 290px;
  --transition: .2s ease-out;
  --font-display: 'Zilla Slab', serif;
  --font-body: 'Nunito Sans', sans-serif;
  --font-mono: 'Fira Mono', monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1b24;
    --bg-soft: #12232e;
    --card: #152430;
    --card-border: #223846;
    --text: #e6ebee;
    --text-soft: #b9c4cb;
    --muted: #8fa0aa;
    --ink: #f2ede4;
    --accent: #e8a33d;
    --accent-strong: #f0b35c;
    --accent-soft: #3a2c18;
    --gold: #f0b35c;
    --teal: #4cc3d4;
    --teal-strong: #6fd2e0;
    --teal-soft: #16343e;
    --danger: #f87171;
    --danger-soft: #3c2226;
    --header-bg: #0d1b24;
    --sidebar-bg: #0f1e28;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    --shadow-hover: 0 4px 12px rgba(0,0,0,.5), 0 16px 40px rgba(0,0,0,.45);
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
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(--bg);
  background-image:
    radial-gradient(ellipse 60vw 40vh at 90% -5%, rgba(14,116,144,.12), transparent 60%),
    radial-gradient(ellipse 50vw 35vh at -10% 105%, rgba(217,119,6,.1), transparent 60%);
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; height: auto; }
a { color: var(--teal-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; z-index: 200;
  background: var(--ink); color: var(--bg); padding: .6rem 1rem; 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);
  border-bottom: 1px solid var(--card-border);
  backdrop-filter: blur(10px);
}
.app-header::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(217,119,6,.4), rgba(14,116,144,.35), transparent);
  opacity: .5; pointer-events: none;
}
.header-inner {
  max-width: 1440px; margin: 0 auto; padding: 0 20px;
  height: var(--header-h);
  display: flex; align-items: center; gap: 24px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 700; font-size: 1.35rem;
  color: var(--text); text-decoration: none; white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 1.4rem; line-height: 1; }
.brand-text em {
  font-style: normal; color: var(--accent);
  background: linear-gradient(135deg, var(--accent), var(--gold));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.header-search { flex: 1; max-width: 480px; margin-left: auto; position: relative; }
.header-search input {
  width: 100%; padding: .55rem 1rem .55rem 2.4rem;
  border: 1px solid var(--card-border); border-radius: 999px;
  background: var(--card); color: var(--text); font-size: .95rem; font-family: var(--font-body);
}
.header-search input::placeholder { color: var(--muted); }
.header-search::before {
  content: '⌕'; position: absolute; left: .9rem; top: 50%; transform: translateY(-50%);
  font-size: 1.15rem; color: var(--muted); pointer-events: none;
}
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 120;
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-hover); overflow: hidden;
}
.search-results a {
  display: flex; flex-direction: column; padding: .6rem .9rem;
  border-bottom: 1px solid var(--card-border); color: var(--text);
}
.search-results a:last-child { border-bottom: none; }
.search-results a:hover { background: var(--bg-soft); text-decoration: none; }
.sr-title { font-weight: 700; font-size: .95rem; }
.sr-section { font-size: .78rem; color: var(--muted); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .04em; }
.sr-none { padding: .8rem .9rem; color: var(--muted); font-size: .9rem; }

.menu-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 44px; height: 44px; padding: 10px; background: none; border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); cursor: pointer;
}
.menu-toggle span { display: block; height: 2px; width: 100%; background: var(--text); transition: all .25s ease; }
.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 {
  display: flex; flex: 1;
  max-width: 1440px; width: 100%; margin: 0 auto;
}
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 22px 18px 32px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--card-border);
  scrollbar-width: thin;
}
.sidebar-nav { list-style: none; }
.sidebar-section-label {
  font-family: var(--font-mono); font-size: .75rem; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted);
  padding: 18px 10px 6px; border-bottom: 1px solid var(--card-border); margin-bottom: 4px;
}
.sidebar-nav li:first-child .sidebar-section-label { padding-top: 4px; }
.sidebar-link {
  display: block; padding: .42rem .6rem; border-radius: 6px;
  font-size: .9rem; line-height: 1.35; color: var(--text-soft);
  border-left: 2px solid transparent;
}
.sidebar-link:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.sidebar-link.active {
  background: var(--accent-soft); color: var(--ink);
  border-left-color: var(--accent); font-weight: 700;
}
.sidebar-foot { margin-top: 24px; padding: 14px 10px; border-top: 1px solid var(--card-border); }
.sidebar-foot p { font-size: .8rem; color: var(--muted); line-height: 1.5; }
.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,.45); backdrop-filter: blur(2px);
}

.main { flex: 1; min-width: 0; padding: 28px 34px 60px; }

/* ---------- Home hero ---------- */
.home-hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--ink) 0%, #10242f 55%, #14303d 100%);
  border-radius: var(--radius);
  padding: 48px 46px;
  margin-bottom: 40px;
  color: #eef2f4;
}
.home-hero::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse 80% 80% at 70% 30%, #000 30%, transparent 75%);
  pointer-events: none;
}
.hero-inner { display: flex; align-items: center; gap: 40px; position: relative; z-index: 1; }
.hero-copy { flex: 1; }
.hero-eyebrow {
  display: inline-block; font-family: var(--font-mono); font-size: .75rem;
  text-transform: uppercase; letter-spacing: .12em; color: var(--gold);
  background: rgba(232,163,61,.14); border: 1px solid rgba(232,163,61,.4);
  padding: .3rem .7rem; border-radius: 999px; margin-bottom: 16px;
}
.home-hero h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2rem, 4.4vw, 3.1rem); line-height: 1.12;
  text-wrap: balance; margin-bottom: 14px;
}
.home-hero h1 .hl {
  color: var(--gold);
  background: linear-gradient(135deg, #f0b35c, #e8a33d);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-sub { font-size: 1.08rem; color: #c2cdd3; max-width: 620px; margin-bottom: 20px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: .72rem 1.35rem; border-radius: 999px;
  font-weight: 800; font-size: .95rem; text-decoration: none;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(135deg, #f0b35c, #d97706);
  color: #0d1b24; box-shadow: 0 4px 14px rgba(232,163,61,.35);
}
.btn-primary:hover { box-shadow: 0 6px 22px rgba(232,163,61,.5); }
.btn-ghost { border: 1px solid rgba(255,255,255,.28); color: #eef2f4; background: rgba(255,255,255,.05); }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.hero-stats { display: flex; gap: 26px; flex-wrap: wrap; }
.hero-stat b {
  display: block; font-family: var(--font-display); font-weight: 700;
  font-size: 1.7rem; color: #fff; line-height: 1.1;
}
.hero-stat span { font-size: .8rem; color: #93a6b0; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .05em; }
.hero-art { flex-shrink: 0; width: 350px; }

/* ---------- Hero SVG: przekrój ucha ---------- */
.ear-svg { width: 100%; height: auto; display: block; }
.ear-svg .ear-path {
  fill: none; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 600; stroke-dashoffset: 600;
  animation: earDraw 1.6s ease-out forwards;
}
.ear-svg .ear-path.p2 { animation-delay: .25s; }
.ear-svg .ear-path.p3 { animation-delay: .5s; }
.ear-svg .ear-path.p4 { animation-delay: .75s; }
.ear-svg .ear-path.p5 { animation-delay: 1s; }
@keyframes earDraw { to { stroke-dashoffset: 0; } }
.ear-svg .wave {
  fill: none; stroke: #e8a33d; stroke-width: 2; stroke-linecap: round;
  opacity: 0; animation: wavePulse 3.2s ease-in-out infinite;
}
.ear-svg .wave.w2 { animation-delay: .5s; }
.ear-svg .wave.w3 { animation-delay: 1s; }
@keyframes wavePulse {
  0% { opacity: 0; transform: scale(.8); transform-origin: 72px 118px; }
  35% { opacity: .8; }
  100% { opacity: 0; transform: scale(1.15); transform-origin: 72px 118px; }
}
.ear-svg .cochlea-pulse { animation: cochlea 2.6s ease-in-out infinite; }
@keyframes cochlea {
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}

/* ---------- Home sections ---------- */
.home-section { margin-bottom: 40px; }
.home-section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 2px solid var(--card-border); padding-bottom: 10px; margin-bottom: 18px;
}
.home-section-head h2 {
  font-family: var(--font-display); font-weight: 700; font-size: 1.5rem;
  text-wrap: balance;
}
.home-section-head .count {
  font-family: var(--font-mono); font-size: .75rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.home-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px;
}
.home-card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 16px 18px;
  color: var(--text); position: relative; overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.home-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  opacity: 0; transition: opacity var(--transition);
}
.home-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); text-decoration: none; }
.home-card:hover::before { opacity: 1; }
.card-icon { font-size: 1.4rem; line-height: 1; transition: transform var(--transition); }
.home-card:hover .card-icon { transform: scale(1.18); }
.home-card h3 { font-size: .95rem; font-weight: 800; line-height: 1.35; text-wrap: balance; }
.home-card p { font-size: .85rem; color: var(--text-soft); line-height: 1.5; }

/* ---------- Article ---------- */
.content-article {
  max-width: 780px;
  animation: fadeUp .25s ease-out;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.article-eyebrow {
  font-family: var(--font-mono); font-size: .75rem; text-transform: uppercase;
  letter-spacing: .1em; color: var(--accent); margin-bottom: 8px; font-weight: 400;
}
.content-article h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.7rem, 3.6vw, 2.4rem); line-height: 1.15;
  margin-bottom: 12px; text-wrap: balance;
}
.article-meta {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--card-border);
  font-size: .83rem; color: var(--muted);
}
.article-meta .tag {
  font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  background: var(--accent-soft); color: var(--ink);
  padding: .2rem .6rem; border-radius: 999px;
}
.article-toc {
  background: var(--bg-soft); border: 1px solid var(--card-border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 16px 20px; margin-bottom: 26px;
}
.article-toc strong { font-family: var(--font-display); font-size: .95rem; display: block; margin-bottom: 8px; }
.article-toc ol { padding-left: 1.2rem; }
.article-toc li { margin-bottom: 4px; font-size: .92rem; }
.article-toc a { color: var(--text-soft); }
.article-toc a:hover { color: var(--accent-strong); }
.article-body { font-size: 1.02rem; }
.article-body h2 {
  font-family: var(--font-display); font-weight: 700;
  font-size: 1.4rem; margin: 34px 0 12px; padding-top: 6px;
  text-wrap: balance; scroll-margin-top: calc(var(--header-h) + 16px);
}
.article-body h3 {
  font-family: var(--font-display); font-weight: 700;
  font-size: 1.12rem; margin: 26px 0 10px;
  text-wrap: balance; scroll-margin-top: calc(var(--header-h) + 16px);
}
.article-body h4 { font-size: 1rem; font-weight: 800; margin: 20px 0 8px; }
.article-body p { margin-bottom: 14px; }
.article-body ul, .article-body ol { margin: 0 0 16px 1.3rem; }
.article-body li { margin-bottom: 6px; }
.article-body strong { font-weight: 800; }

/* info-box / warn-box */
.info-box, .warn-box {
  border-radius: var(--radius-sm); padding: 14px 18px; margin: 18px 0;
  font-size: .97rem; line-height: 1.6;
}
.info-box {
  background: var(--teal-soft); border: 1px solid rgba(14,116,144,.35);
  border-left: 4px solid var(--teal);
}
.warn-box {
  background: var(--danger-soft); border: 1px solid rgba(185,28,28,.35);
  border-left: 4px solid var(--danger);
}
.info-box strong, .warn-box strong { display: block; margin-bottom: 4px; }
.info-box strong { color: var(--teal-strong); }
.warn-box strong { color: var(--danger); }

/* tables */
.table-responsive { overflow-x: auto; margin: 18px 0; border-radius: var(--radius-sm); }
.info-table, .error-table {
  width: 100%; border-collapse: collapse; font-size: .93rem;
  background: var(--card);
}
.info-table th, .error-table th {
  background: var(--ink); color: #eef2f4;
  font-family: var(--font-display); font-weight: 700; font-size: .88rem;
  text-align: left; padding: 10px 14px; white-space: nowrap;
}
.info-table td, .error-table td {
  padding: 10px 14px; border-bottom: 1px solid var(--card-border); vertical-align: top;
}
.info-table tr:nth-child(even) td, .error-table tr:nth-child(even) td { background: var(--bg-soft); }
.info-table tr:hover td, .error-table tr:hover td { background: var(--accent-soft); }
.table-responsive + p { margin-top: 4px; }

/* FAQ - wariant details/summary i wariant h3+p */
.faq-item {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); margin-bottom: 12px; overflow: hidden;
}
.faq-item summary {
  cursor: pointer; padding: 14px 18px; font-weight: 700; font-size: .98rem;
  list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+'; font-family: var(--font-mono); font-size: 1.2rem; color: var(--accent);
  transition: transform var(--transition); flex-shrink: 0;
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item summary:hover { background: var(--bg-soft); }
.faq-item .faq-a { padding: 0 18px 16px; font-size: .97rem; line-height: 1.65; }
.faq-item h3 {
  font-family: var(--font-body); font-weight: 800; font-size: .98rem;
  padding: 14px 18px 0; margin: 0;
}
.faq-item h3::before { content: '❓ '; }
.faq-item h3 + p { padding: 8px 18px 16px; font-size: .97rem; line-height: 1.65; }

/* glossary */
.glossary { display: grid; gap: 0; margin: 16px 0; }
.glossary dt {
  font-family: var(--font-display); font-weight: 700; font-size: 1rem;
  padding: 12px 16px 4px; color: var(--accent-strong);
}
.glossary dd { padding: 0 16px 12px; font-size: .96rem; line-height: 1.6; border-bottom: 1px dashed var(--card-border); }
.glossary dt:first-child { padding-top: 0; }

/* steps / checklist */
.steps { counter-reset: step; list-style: none; margin: 16px 0 16px 0 !important; }
.steps li {
  counter-increment: step; position: relative; padding-left: 44px; margin-bottom: 14px;
}
.steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute; left: 0; top: 0;
  font-family: var(--font-mono); font-size: .8rem;
  color: var(--ink); background: var(--accent-soft);
  border: 1px solid var(--card-border);
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.checklist { list-style: none !important; }
.checklist li { padding-left: 30px; position: relative; }
.checklist li::before {
  content: '✓'; position: absolute; left: 4px; top: 0; color: var(--gold); font-weight: 700;
}

/* article nav */
.article-nav {
  display: flex; justify-content: space-between; gap: 16px;
  margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--card-border);
}
.article-nav a {
  flex: 1; max-width: 46%;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-size: .9rem; font-weight: 700; color: var(--text);
  transition: transform var(--transition), box-shadow var(--transition);
}
.article-nav a:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.article-nav .nav-label {
  display: block; font-family: var(--font-mono); font-size: .75rem;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 2px;
}

/* warn in article footer */
.content-article > .warn-box { margin-top: 32px; }

/* ---------- Footer ---------- */
.app-footer {
  border-top: 1px solid var(--card-border); background: var(--sidebar-bg);
  margin-top: 40px;
}
.footer-inner { max-width: 1440px; margin: 0 auto; padding: 28px 34px; }
.footer-inner p { font-size: .88rem; color: var(--text-soft); margin-bottom: 6px; max-width: 780px; }
.footer-meta { font-size: .78rem !important; color: var(--muted); font-family: var(--font-mono); }

/* ---------- Reveal ---------- */
.reveal { opacity: 0; transform: translateY(8px); transition: opacity .45s ease-out, transform .45s ease-out; }
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 110;
    height: 100vh; width: min(320px, 85vw);
    transform: translateX(-105%); transition: transform .28s ease-out;
    box-shadow: var(--shadow-hover); border-right: none;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .menu-toggle { display: flex; }
  .header-search { max-width: none; }
  .main { padding: 20px 18px 48px; }
  .home-hero { padding: 34px 26px; }
  .hero-inner { flex-direction: column; }
  .hero-art { width: 260px; }
  .hero-art text { display: none; }
  .footer-inner { padding: 24px 18px; }
}

@media (max-width: 600px) {
  body { font-size: 16.5px; }
  .home-grid { grid-template-columns: 1fr; }
  .hero-stats { gap: 16px; }
  .hero-stat b { font-size: 1.4rem; }
  .hero-art { width: 210px; }
  .article-nav { flex-direction: column; }
  .article-nav a { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
  .ear-svg .ear-path { stroke-dashoffset: 0; animation: none; }
}
