/* ============================================================
   Stawy - design system "Lód i ruch"
   Paleta dopasowana do tematu (stawy, kości, ortopedia):
   - głęboki granat: stabilność, struktura, zaufanie medyczne
   - lodowy błękit: czystość, chłód (terapia zimnem), spokój
   - koral: ciepło, energia, ruch (akcent CTA)
   - chłodny krem: czystość bez klinicznej bieli
   Typografia: Source Serif 4 (display) + IBM Plex Sans (body)
   ============================================================ */

:root {
  --accent: #c2410c;
  --accent-strong: #b3341a;
  --accent-light: #fdeee7;
  --accent-subtle: #f3d5c8;
  --ice: #2e6da4;
  --ice-strong: #1d4e79;
  --ice-light: #e8f0f8;
  --ice-subtle: #c9dcee;
  --bg: #f6f7f9;
  --bg-alt: #e9eef4;
  --surface: #ffffff;
  --text: #16222e;
  --muted: #5a6b7a;
  --border: #dde4ec;
  --header-bg: rgba(246, 247, 249, 0.92);
  --shadow-card: 0 1px 2px rgba(22, 34, 46, 0.05), 0 4px 16px rgba(22, 34, 46, 0.06);
  --shadow-card-hover: 0 2px 4px rgba(22, 34, 46, 0.07), 0 10px 28px rgba(194, 65, 12, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --header-height: 64px;
  --sidebar-width: 272px;
  --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --transition: all 0.2s ease-out;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #ff8a66;
    --accent-strong: #ffa489;
    --accent-light: #2b1a14;
    --accent-subtle: #3d2519;
    --ice: #7db8e8;
    --ice-strong: #a3cdf0;
    --ice-light: #14202c;
    --ice-subtle: #1d3142;
    --bg: #101a24;
    --bg-alt: #131f2b;
    --surface: #16222e;
    --text: #e8eef5;
    --muted: #9db0c2;
    --border: #26384a;
    --header-bg: rgba(16, 26, 36, 0.92);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-card-hover: 0 2px 4px rgba(0, 0, 0, 0.4), 0 10px 28px rgba(255, 138, 102, 0.14);
  }
}

* { 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 60vw 40vh at -10% -5%, var(--ice-light) 0%, transparent 60%),
    radial-gradient(ellipse 50vw 35vh at 110% 105%, var(--accent-light) 0%, transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

/* ---------- Header ---------- */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  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: 1px;
  background: linear-gradient(90deg, transparent, var(--ice-subtle), transparent);
  opacity: 0.6;
  pointer-events: none;
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand em { font-style: normal; color: var(--accent); }
.brand-mark {
  display: inline-flex;
  width: 34px; height: 34px;
  align-items: center; justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, var(--ice), var(--accent));
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(46, 109, 164, 0.3);
}
.brand-mark svg { width: 20px; height: 20px; }

.search-box { position: relative; flex: 1; max-width: 420px; margin-left: auto; }
.search-icon {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  color: var(--muted);
  pointer-events: none;
}
#searchInput {
  width: 100%;
  padding: 9px 14px 9px 36px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  transition: var(--transition);
}
#searchInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card-hover);
  max-height: 380px;
  overflow-y: auto;
  z-index: 200;
}
.search-results a {
  display: block;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.search-results a:last-child { border-bottom: none; }
.search-results a:hover { background: var(--ice-light); text-decoration: none; }
.search-empty { padding: 12px 14px; font-size: 0.88rem; color: var(--muted); }

.menu-toggle { display: none; background: none; border: none; cursor: pointer; padding: 8px; }
.menu-toggle span {
  display: block; width: 22px; height: 2px;
  background: var(--text);
  margin: 5px 0;
  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: 1280px;
  margin: 0 auto;
  padding: calc(var(--header-height) + 24px) 20px 60px;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: calc(var(--header-height) + 24px);
  max-height: calc(100vh - var(--header-height) - 48px);
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-width: thin;
}
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.nav-section { margin-bottom: 14px; }
.nav-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 6px 12px 4px;
}
.sidebar-link {
  display: block;
  padding: 6px 12px;
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--text);
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  transition: var(--transition);
}
.sidebar-link:hover { background: var(--ice-light); text-decoration: none; color: var(--ice-strong); }
.sidebar-link.active {
  background: var(--ice-light);
  border-left-color: var(--ice);
  color: var(--ice-strong);
  font-weight: 600;
}
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 90;
}

/* ---------- Main / Article ---------- */
.main { min-width: 0; }

.page-enter { animation: fadeUp 0.28s ease-out; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.article-header { margin-bottom: 28px; }
.article-header .breadcrumbs {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.article-header .breadcrumbs a { color: var(--accent); }
.article-header h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.2vw, 3rem);
  font-weight: 700;
  line-height: 1.15;
  text-wrap: balance;
  color: var(--text);
  margin-bottom: 12px;
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  font-size: 0.82rem;
  color: var(--muted);
}
.trust-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ice-strong);
  background: var(--ice-light);
  border: 1px solid var(--ice-subtle);
  border-radius: 999px;
}
.trust-badge svg { width: 14px; height: 14px; }

.content-article { font-size: 17px; line-height: 1.7; }
.content-article h2 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  margin: 40px 0 14px;
  padding-top: 8px;
  text-wrap: balance;
  color: var(--text);
  scroll-margin-top: calc(var(--header-height) + 20px);
}
.content-article h3 {
  font-size: 1.18rem;
  font-weight: 700;
  margin: 28px 0 10px;
  text-wrap: balance;
  color: var(--text);
  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: 8px; }
.content-article li::marker { color: var(--accent); }
.content-article strong { color: var(--text); }
.content-article a { text-decoration: underline; text-underline-offset: 2px; }

/* TOC */
.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  margin: 8px 0 28px;
  font-size: 0.92rem;
}
.toc-title {
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}
.toc ol { list-style: none; padding-left: 0; margin: 0; counter-reset: toc; }
.toc li { margin-bottom: 6px; counter-increment: toc; }
.toc li::before {
  content: counter(toc) ".";
  color: var(--accent);
  font-weight: 600;
  margin-right: 8px;
}
.toc a { color: var(--text); text-decoration: none; }
.toc a:hover { color: var(--accent); text-decoration: underline; }

/* Info box */
.info-box {
  background: var(--accent-light);
  border: 1px solid var(--accent-subtle);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin: 20px 0;
  font-size: 0.95rem;
}
.info-box strong { color: var(--accent-strong); }

.warning-box {
  background: var(--ice-light);
  border: 1px solid var(--ice-subtle);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin: 20px 0;
  font-size: 0.95rem;
}
.warning-box strong { color: var(--ice-strong); }

/* Key takeaways ("W skrócie") */
.takeaways {
  background: var(--ice-light);
  border: 1px solid var(--ice-subtle);
  border-left: 3px solid var(--ice);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin: 8px 0 24px;
  font-size: 0.95rem;
}
.takeaways-title {
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ice);
  margin-bottom: 10px;
}
.takeaways ul { margin: 0; padding-left: 20px; }
.takeaways li { margin-bottom: 6px; }
.takeaways li::marker { color: var(--ice); }

/* Tables */
.table-responsive { overflow-x: auto; margin: 20px 0; }
.error-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.error-table th {
  background: var(--ice);
  color: #fff;
  text-align: left;
  padding: 11px 14px;
  font-weight: 600;
  font-size: 0.88rem;
}
.error-table td {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  vertical-align: top;
}
.error-table tr:nth-child(even) td { background: var(--bg-alt); }

/* FAQ */
.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  margin-bottom: 12px;
}
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  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-size: 1.3rem;
  font-weight: 400;
  color: var(--accent);
  transition: var(--transition);
  flex-shrink: 0;
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item .faq-a { margin-top: 12px; font-size: 0.95rem; }

/* Glossary */
.glossary dl { margin: 0; }
.glossary dt {
  font-weight: 700;
  color: var(--ice-strong);
  margin-top: 18px;
}
.glossary dd { margin: 4px 0 0 0; font-size: 0.95rem; }

/* Compare table checkmarks */
.yes { color: var(--accent-strong); font-weight: 700; }
.no { color: #b3261e; font-weight: 700; }

/* Article nav (prev/next) */
.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}
.article-nav a {
  display: inline-block;
  max-width: 48%;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: var(--transition);
}
.article-nav a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
  transform: translateY(-2px);
}
.article-nav .nav-label { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 2px; }

/* ---------- Home ---------- */
.home-hero {
  position: relative;
  background:
    radial-gradient(ellipse 70% 100% at 85% 0%, rgba(255, 138, 102, 0.14), transparent 55%),
    linear-gradient(135deg, var(--ice-strong), var(--ice) 55%, var(--text));
  border-radius: var(--radius);
  padding: 44px 40px;
  margin-bottom: 40px;
  color: #fff;
  overflow: hidden;
}
.home-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: 0.3;
  pointer-events: none;
}
.home-hero h1 {
  position: relative;
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 4.6vw, 3.2rem);
  font-weight: 700;
  line-height: 1.12;
  text-wrap: balance;
  max-width: 620px;
  margin-bottom: 14px;
}
.home-hero p {
  position: relative;
  font-size: 1.08rem;
  opacity: 0.94;
  max-width: 560px;
  margin-bottom: 24px;
}
.hero-cta {
  display: inline-block;
  background: #fff;
  color: var(--ice-strong);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 11px 22px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  transition: var(--transition);
  text-decoration: none;
}
.hero-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.24);
  text-decoration: none;
}
.hero-stats {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
}
.hero-stat .num {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
}
.hero-stat .lbl { font-size: 0.78rem; opacity: 0.85; }

/* Signature: staw w ruchu (SVG) */
.hero-joint {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 260px;
  height: 240px;
  opacity: 0.95;
  pointer-events: none;
}
.hero-joint svg { width: 100%; height: 100%; }
.joint-bone {
  stroke: rgba(255, 255, 255, 0.92);
  animation: boneIn 0.9s ease-out both;
}
.joint-bone.femur { animation-delay: 0.15s; }
.joint-bone.tibia { animation-delay: 0.35s; }
.joint-cartilage { fill: rgba(125, 184, 232, 0.55); animation: boneIn 0.9s ease-out 0.5s both; }
.joint-cartilage-core { fill: rgba(255, 255, 255, 0.85); animation: boneIn 0.9s ease-out 0.6s both; }
.joint-ghost {
  stroke: rgba(255, 255, 255, 0.4);
  stroke-dasharray: 4 6;
  animation: boneIn 0.9s ease-out 0.55s both;
}
.joint-arc {
  stroke: #ff8a66;
  stroke-linecap: round;
  fill: none;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: arcDraw 1.6s ease-out 0.9s both;
}
.joint-arrow { fill: #ffb39a; animation: boneIn 0.5s ease-out 1.9s both; }
.joint-dot { fill: #ffb39a; }
.joint-dot-wrap { animation: boneIn 0.4s ease-out 1.8s both; }
.joint-arc-path { fill: none; }
@keyframes boneIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes arcDraw {
  to { stroke-dashoffset: 0; }
}
@media (max-width: 900px) {
  .hero-joint { width: 170px; height: 160px; right: 10px; opacity: 0.6; }
  .home-hero h1 { max-width: 100%; }
}
@media (max-width: 600px) {
  .hero-joint { display: none; }
}

.home-section { margin-bottom: 44px; }
.home-section h2 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  text-wrap: balance;
}
.section-line {
  width: 52px;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--ice));
  border-radius: 2px;
  margin: 8px 0 18px;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 16px;
}
.home-card {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  overflow: hidden;
}
.home-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--ice));
  opacity: 0;
  transition: var(--transition);
}
.home-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  text-decoration: none;
  border-color: var(--accent-subtle);
}
.home-card:hover::before { opacity: 1; }
.home-card .card-icon { font-size: 1.5rem; line-height: 1; margin-bottom: 8px; display: block; }
.home-card h3 {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text);
  margin-bottom: 6px;
  text-wrap: balance;
}
.home-card p {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--muted);
  margin: 0;
}

/* ---------- Footer ---------- */
.app-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  margin-top: 40px;
}
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 20px 36px;
  font-size: 0.88rem;
  color: var(--muted);
}
.footer-inner p { margin-bottom: 8px; }
.footer-note { font-size: 0.8rem; }
.footer-links a { color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding-top: calc(var(--header-height) + 16px);
  }
  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0; bottom: 0;
    width: 300px;
    max-height: none;
    background: var(--bg);
    border-right: 1px solid var(--border);
    padding: 16px;
    transform: translateX(-105%);
    transition: transform 0.25s ease-out;
    z-index: 95;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: block; }
  .search-box { max-width: none; }
  .brand-text { font-size: 1.3rem; }
  .home-hero { padding: 32px 24px; }
}
@media (max-width: 600px) {
  body { font-size: 16.5px; }
  .header-inner { gap: 12px; padding: 0 14px; }
  .search-box { display: none; }
  .card-grid { grid-template-columns: 1fr; }
  .hero-stats { gap: 18px; }
  .article-nav { flex-direction: column; }
  .article-nav a { max-width: 100%; }
}

/* ---------- Motion: reduced ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .joint-arc { stroke-dashoffset: 0 !important; }
}

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

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