/* ============================================================
   Cukrzyca - design system
   Paleta: zdrowie (świeża zieleń + teal/błękit + biel) + bursztyn glukozy
   Typografia: Lora (display) + Plus Jakarta Sans (body) + Space Mono (dane)
   ============================================================ */

:root {
  /* Light */
  --bg: #f4f7f5;
  --bg-card: #ffffff;
  --bg-subtle: #eaf1ec;
  --text: #14211c;
  --text-muted: #4c5c54;
  --accent: #0e7c66;
  --accent-strong: #0a5c4c;
  --accent-soft: rgba(14, 124, 102, 0.12);
  --accent-warm: #d97706;
  --accent-warm-soft: rgba(217, 119, 6, 0.12);
  --border: #d9e3dd;
  --header-bg: rgba(244, 247, 245, 0.92);
  --shadow-card: 0 1px 2px rgba(20, 33, 28, 0.06), 0 4px 16px rgba(20, 33, 28, 0.05);
  --shadow-card-hover: 0 2px 4px rgba(20, 33, 28, 0.08), 0 10px 28px rgba(14, 124, 102, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --font-display: 'Lora', Georgia, serif;
  --font-body: 'Plus Jakarta Sans', 'Segoe UI', sans-serif;
  --font-mono: 'Space Mono', 'Courier New', monospace;
  --header-height: 64px;
  --transition: 0.2s ease-out;
  --glow: linear-gradient(90deg, transparent, rgba(14, 124, 102, 0.35), transparent);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1310;
    --bg-card: #111c17;
    --bg-subtle: #15231c;
    --text: #e6ece8;
    --text-muted: #9db0a6;
    --accent: #2dd4a7;
    --accent-strong: #5eead4;
    --accent-soft: rgba(45, 212, 167, 0.14);
    --accent-warm: #f59e0b;
    --accent-warm-soft: rgba(245, 158, 11, 0.14);
    --border: #22332b;
    --header-bg: rgba(11, 19, 16, 0.92);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-card-hover: 0 2px 4px rgba(0, 0, 0, 0.35), 0 10px 28px rgba(45, 212, 167, 0.1);
  }
}

* { 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 700px 420px at 88% -8%, var(--accent-soft), transparent 65%),
    radial-gradient(ellipse 640px 400px at -6% 108%, var(--accent-warm-soft), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

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

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

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent-strong); color: #fff;
  padding: 10px 18px; border-radius: 0 0 8px 0; z-index: 200;
  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; bottom: -1px; left: 0; right: 0; height: 2px;
  background: var(--glow); 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: 16px;
}
.menu-btn {
  display: none; background: none; border: none; cursor: pointer;
  width: 42px; height: 42px; border-radius: 8px;
  flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.menu-btn span { display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; transition: all var(--transition); }
.menu-btn:hover { background: var(--bg-subtle); }
.menu-btn[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-btn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 22px; line-height: 1; }
.brand-name { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; }
.brand-name em { font-style: normal; color: var(--accent); }

.search-wrap { position: relative; flex: 1; max-width: 420px; margin-left: auto; }
.search-input {
  width: 100%; padding: 9px 14px 9px 38px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234c5c54' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4-4'/%3E%3C/svg%3E") no-repeat 14px center;
  font-family: var(--font-body); font-size: 0.95rem; color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card-hover); max-height: 380px; overflow-y: auto;
  display: none; z-index: 120;
}
.search-results.open { display: block; }
.search-item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--bg-subtle); text-decoration: none; }
.search-item .si-title { font-weight: 600; font-size: 0.95rem; }
.search-item .si-section { font-family: var(--font-mono); font-size: 0.7rem; color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; }
.search-empty { padding: 12px 14px; color: var(--text-muted); font-size: 0.9rem; }

.header-tagline {
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap;
}

/* ---------- Layout ---------- */
.layout {
  display: flex; max-width: 1280px; margin: 0 auto;
  padding: calc(var(--header-height) + 24px) 20px 48px; gap: 32px;
}
.sidebar {
  width: 268px; flex-shrink: 0;
  position: sticky; top: calc(var(--header-height) + 24px);
  align-self: flex-start; max-height: calc(100vh - var(--header-height) - 48px);
  overflow-y: auto; padding-right: 8px;
}
.sidebar-section { margin-bottom: 18px; }
.sidebar-label {
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 700;
  color: var(--accent); text-transform: uppercase; letter-spacing: 0.09em;
  padding: 0 10px 6px; display: block;
}
.sidebar-link {
  display: block; padding: 6px 10px; font-size: 0.9rem; line-height: 1.4;
  color: var(--text); border-radius: 8px; text-decoration: none;
  border-left: 2px solid transparent; transition: all var(--transition);
}
.sidebar-link:hover { background: var(--bg-subtle); text-decoration: none; color: var(--text); }
.sidebar-link.active {
  background: var(--accent-soft); color: var(--accent-strong);
  border-left-color: var(--accent); font-weight: 600;
}
.sidebar-overlay { display: none; }

.main-content { flex: 1; min-width: 0; }

/* ---------- Page transition ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.app-content { animation: fadeUp 0.25s ease-out; }

/* ---------- Home ---------- */
.home-hero {
  border-radius: var(--radius);
  padding: 44px 40px;
  background:
    radial-gradient(ellipse 520px 300px at 92% 0%, var(--accent-warm-soft), transparent 60%),
    linear-gradient(135deg, var(--accent-strong), var(--accent) 55%, var(--accent-strong));
  color: #f4fbf7;
  margin-bottom: 34px;
  position: relative; overflow: hidden;
}
.home-hero::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,0.14) 1px, transparent 1px);
  background-size: 22px 22px; opacity: 0.25;
}
.hero-eyebrow {
  font-family: var(--font-mono); font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.12em; color: rgba(244, 251, 247, 0.85);
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.hero-eyebrow .pulse {
  width: 8px; height: 8px; border-radius: 50%; background: #fde68a;
  box-shadow: 0 0 0 0 rgba(253, 230, 138, 0.6); animation: pulseGlow 2.4s infinite;
}
@keyframes pulseGlow {
  0% { box-shadow: 0 0 0 0 rgba(253, 230, 138, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(253, 230, 138, 0); }
  100% { box-shadow: 0 0 0 0 rgba(253, 230, 138, 0); }
}
.home-hero h1 {
  font-size: clamp(1.9rem, 3.6vw, 2.7rem); font-weight: 700; color: #fff;
  margin-bottom: 12px; max-width: 620px;
}
.home-hero .hero-sub { font-size: 1.06rem; max-width: 560px; color: rgba(244, 251, 247, 0.92); margin-bottom: 22px; }
.hero-stats { display: flex; gap: 28px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero-stat .hs-num {
  font-family: var(--font-mono); font-size: 1.5rem; font-weight: 700; color: #fde68a; display: block; line-height: 1.2;
}
.hero-stat .hs-label { font-size: 0.85rem; color: rgba(244, 251, 247, 0.85); max-width: 150px; display: block; }

.home-section { margin-bottom: 30px; }
.home-section-head {
  display: flex; align-items: baseline; gap: 14px; margin-bottom: 14px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.home-section-head h2 { font-size: 1.35rem; font-weight: 700; color: var(--text); }
.home-section-head .hs-count { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.home-card {
  display: block; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 18px 16px; text-decoration: none;
  color: var(--text); transition: all var(--transition);
  position: relative; overflow: hidden;
}
.home-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-warm));
  opacity: 0; transition: opacity var(--transition);
}
.home-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card-hover); text-decoration: none; border-color: var(--accent); }
.home-card:hover::before { opacity: 1; }
.home-card .hc-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.home-card .hc-icon { font-size: 1.35rem; line-height: 1; }
.home-card h3 { font-family: var(--font-body); font-size: 0.9rem; font-weight: 700; line-height: 1.4; color: var(--text); }
.home-card p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.55; }

/* ---------- Article ---------- */
.article { max-width: 780px; }
.article-head { margin-bottom: 26px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.article-crumb { font-family: var(--font-mono); font-size: 0.72rem; color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; display: block; }
.article h1 { font-size: clamp(1.7rem, 3vw, 2.35rem); font-weight: 700; margin-bottom: 12px; }
.article .article-excerpt { font-size: 1.08rem; color: var(--text-muted); line-height: 1.6; }

.article h2 {
  font-size: 1.45rem; font-weight: 700; margin: 34px 0 12px;
  padding-top: 4px; scroll-margin-top: calc(var(--header-height) + 20px);
}
.article h3 { font-size: 1.15rem; font-weight: 700; margin: 24px 0 8px; scroll-margin-top: calc(var(--header-height) + 20px); }
.article p { margin-bottom: 14px; }
.article ul, .article ol { margin: 0 0 16px 22px; }
.article li { margin-bottom: 7px; }
.article strong { font-weight: 700; }

.article table {
  width: 100%; border-collapse: collapse; margin: 18px 0 22px; font-size: 0.93rem;
  background: var(--bg-card); border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border);
}
.article th, .article td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.article thead th { background: var(--bg-subtle); font-weight: 700; font-size: 0.9rem; }
.article tbody tr:last-child td { border-bottom: none; }
.article tbody tr:hover { background: var(--bg-subtle); }
.article .error-table td:first-child { font-family: var(--font-mono); font-size: 0.85rem; color: var(--accent-strong); font-weight: 700; white-space: nowrap; }

.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: 18px 0; font-size: 0.95rem;
}
.info-box strong { color: var(--accent-strong); }
.warn-box {
  background: var(--accent-warm-soft); border-left: 4px solid var(--accent-warm);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px; margin: 18px 0; font-size: 0.95rem;
}
.warn-box strong { color: var(--accent-warm); }

.faq-item { margin-bottom: 18px; padding: 16px 18px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.faq-item h3 { margin: 0 0 8px; font-size: 1.05rem; font-weight: 700; }
.faq-item p { margin-bottom: 0; }

.glossary { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; }
.glossary dt { font-weight: 700; margin-top: 14px; color: var(--accent-strong); }
.glossary dt:first-child { margin-top: 0; }
.glossary dd { margin: 2px 0 0; color: var(--text-muted); font-size: 0.95rem; }

.table-responsive { overflow-x: auto; }

.article-toc {
  background: var(--bg-subtle); border-radius: var(--radius-sm);
  padding: 16px 20px; margin: 20px 0 26px; font-size: 0.92rem;
}
.article-toc strong { font-family: var(--font-mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); display: block; margin-bottom: 8px; }
.article-toc a { display: inline-block; margin-right: 14px; margin-bottom: 4px; }

.article-footer { margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 0.85rem; color: var(--text-muted); }
.article-nav { display: flex; justify-content: space-between; gap: 16px; margin-top: 14px; }
.article-nav a { font-size: 0.9rem; font-weight: 600; max-width: 46%; }

/* ---------- Footer ---------- */
.app-footer { border-top: 1px solid var(--border); background: var(--bg-card); }
.footer-inner { max-width: 1280px; margin: 0 auto; padding: 28px 20px 40px; }
.footer-inner p { font-size: 0.92rem; color: var(--text-muted); margin-bottom: 10px; max-width: 860px; }
.footer-note { font-size: 0.82rem !important; }
.footer-copy { font-family: var(--font-mono); font-size: 0.78rem !important; color: var(--text-muted); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .menu-btn { display: flex; }
  .header-tagline { display: none; }
  .search-wrap { max-width: none; }
  .sidebar {
    position: fixed; top: var(--header-height); bottom: 0; left: 0;
    width: min(320px, 86vw); z-index: 110; background: var(--bg);
    border-right: 1px solid var(--border); padding: 20px 14px 40px;
    transform: translateX(-105%); transition: transform 0.25s ease-out;
    max-height: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.25); }
  .sidebar-overlay.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 105; }
  .layout { padding: calc(var(--header-height) + 16px) 16px 40px; gap: 0; }
  .home-hero { padding: 32px 24px; }
}

@media (max-width: 600px) {
  .header-inner { gap: 10px; padding: 0 14px; }
  .brand-name { font-size: 1.08rem; }
  .home-grid { grid-template-columns: 1fr; }
  .hero-stats { gap: 18px; }
  .home-hero h1 { font-size: 1.65rem; }
  .article-nav { flex-direction: column; }
  .article-nav a { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}

/* Focus visible */
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent-warm); outline-offset: 2px; border-radius: 4px;
}
