/* ============================================================
   INSULINOPROSTO - design system
   Paleta: leśna zieleń + krem + bursztyn (glukoza) + teal
   Typografia: Lora (display) + Hanken Grotesk (body)
   ============================================================ */

:root {
  /* Light theme */
  --ink: #10231a;
  --ink-soft: #1e3a2c;
  --paper: #f6f4ec;
  --paper-2: #efece0;
  --card: #ffffff;
  --green: #2e7d4f;
  --green-deep: #245f3c;
  --amber: #b85c00;
  --amber-soft: #fdf3e3;
  --teal: #1f7a6d;
  --teal-soft: #e7f2ef;
  --green-soft: #e9f3ec;
  --dim: #5c6b61;
  --border: #ded9c9;
  --mono: #3a4a40;

  --header-h: 64px;
  --sidebar-w: 300px;
  --radius: 12px;
  --transition: all .2s ease-out;

  --font-body: 'Hanken Grotesk', system-ui, sans-serif;
  --font-display: 'Lora', Georgia, serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --bg-gradient: radial-gradient(ellipse 60% 45% at 88% 0%, rgba(46,125,79,.07), transparent 60%),
                 radial-gradient(ellipse 50% 40% at 5% 100%, rgba(31,122,109,.06), transparent 60%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8e4d8;
    --ink-soft: #cfd8cc;
    --paper: #0c1710;
    --paper-2: #122118;
    --card: #15231a;
    --green: #4fae77;
    --green-deep: #3d9462;
    --amber: #f2a14f;
    --amber-soft: #2a2013;
    --teal: #58b3a4;
    --teal-soft: #162a25;
    --green-soft: #16261c;
    --dim: #9db0a2;
    --border: #26382c;
    --mono: #a8c0b0;
  }
}

* { 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(--ink);
  background: var(--paper);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.25; text-wrap: balance; }
h1 { font-size: 2.1rem; font-weight: 700; }
h2 { font-size: 1.45rem; margin: 2rem 0 .7rem; font-weight: 600; }
h3 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; font-weight: 600; }
p { margin-bottom: 1rem; }
a { color: var(--green-deep); }
a:hover { color: var(--teal); }
::selection { background: rgba(46,125,79,.25); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--green); color: #fff; padding: .6rem 1rem; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* === HEADER === */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  backdrop-filter: blur(8px);
}
.app-header::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(46,125,79,.35), transparent);
}
.header-inner {
  max-width: 1400px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; gap: 1.2rem; padding: 0 1.2rem;
}
.brand {
  display: flex; align-items: center; gap: .55rem; text-decoration: none;
  color: var(--ink); font-family: var(--font-display); font-size: 1.35rem; font-weight: 700;
  white-space: nowrap;
}
.brand-mark { color: var(--green); display: flex; }
.brand-text em { font-style: normal; color: var(--green); }
.brand:hover { color: var(--ink); }

.search-wrap { position: relative; flex: 1; max-width: 460px; margin-left: auto; }
#search-input {
  width: 100%; padding: .55rem 1rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--paper-2);
  font-family: var(--font-body); font-size: .95rem; color: var(--ink);
  outline: none;
}
#search-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(46,125,79,.15); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0,0,0,.12); z-index: 200; overflow: hidden;
}
.search-results a {
  display: block; padding: .65rem 1rem; text-decoration: none; color: var(--ink);
  border-bottom: 1px solid var(--border);
}
.search-results a:last-child { border-bottom: none; }
.search-results a:hover { background: var(--green-soft); }
.search-results strong { display: block; font-size: .92rem; }
.search-results small { color: var(--dim); font-size: .8rem; }
.sr-empty { padding: .8rem 1rem; color: var(--dim); font-size: .9rem; }

.burger {
  display: none; flex-direction: column; gap: 5px; padding: 10px;
  background: none; border: none; cursor: pointer;
}
.burger span { display: block; width: 22px; height: 2px; background: var(--ink); border-radius: 2px; transition: var(--transition); }
.burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* === LAYOUT === */
.layout { display: flex; max-width: 1400px; margin: 0 auto; padding-top: var(--header-h); min-height: calc(100vh - var(--header-h)); }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  padding: 1.4rem 1rem 2rem; border-right: 1px solid var(--border);
  position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h));
  overflow-y: auto;
}
.sidebar-home {
  display: flex; align-items: center; gap: .5rem;
  font-weight: 700; font-size: .95rem; text-decoration: none; color: var(--ink);
  padding: .55rem .8rem; border-radius: 8px; margin-bottom: .4rem;
}
.sidebar-home:hover { background: var(--green-soft); }
.sidebar-sec {
  font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--dim); margin: 1.1rem 0 .35rem; padding: 0 .8rem;
}
.sidebar-link {
  display: flex; align-items: center; gap: .55rem;
  font-size: .9rem; line-height: 1.35; padding: .42rem .8rem; border-radius: 8px;
  text-decoration: none; color: var(--ink-soft);
}
.sidebar-link:hover { background: var(--green-soft); color: var(--ink); }
.sidebar-link.active { background: var(--green-soft); color: var(--green-deep); font-weight: 600; }
.sidebar-link .sico { font-size: .95rem; flex-shrink: 0; }

.main { flex: 1; min-width: 0; padding: 1.6rem 2.2rem 3rem; }
.sidebar-overlay { display: none; }

/* === HERO === */
.home-hero {
  border-radius: 16px; overflow: hidden; position: relative;
  background: linear-gradient(135deg, var(--ink) 0%, #17382a 55%, var(--green-deep) 130%);
  color: #f2efe4; padding: 2.8rem 2.6rem;
  box-shadow: 0 10px 40px rgba(16,35,26,.18);
}
.home-hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 50% 60% at 90% 10%, rgba(79,174,119,.22), transparent 60%),
              radial-gradient(ellipse 40% 50% at 8% 90%, rgba(88,179,164,.16), transparent 60%);
}
.hero-inner { position: relative; display: grid; grid-template-columns: 1.25fr 1fr; gap: 2rem; align-items: center; }
.badge {
  display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: #d9f2e2;
  background: rgba(79,174,119,.18); border: 1px solid rgba(79,174,119,.4);
  padding: .3rem .8rem; border-radius: 999px; margin-bottom: 1rem;
}
.home-hero h1 { font-size: clamp(1.7rem, 3.2vw, 2.5rem); color: #fff; margin-bottom: .9rem; }
.home-hero h1 em { font-style: italic; color: #8fd6ab; }
.home-hero .lead { color: #cdd9cf; font-size: 1.05rem; max-width: 34em; }
.hero-cta { display: flex; gap: .8rem; margin-top: 1.4rem; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: .65rem 1.4rem; border-radius: 999px;
  font-weight: 700; font-size: .95rem; text-decoration: none; transition: var(--transition);
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-deep); color: #fff; transform: translateY(-1px); }
.btn-ghost { border: 1px solid rgba(255,255,255,.35); color: #f2efe4; }
.btn-ghost:hover { border-color: #8fd6ab; color: #8fd6ab; transform: translateY(-1px); }

/* === GLUKOZA SIGNATURE (hero) === */
.glucose-wrap { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.12); border-radius: 14px; padding: 1.2rem 1.2rem .9rem; }
.glucose-title { display: flex; justify-content: space-between; align-items: center; font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: #b9cdbf; margin-bottom: .5rem; }
.glucose-tag { font-family: var(--font-mono); font-size: .7rem; color: #8fd6ab; background: rgba(79,174,119,.15); padding: .15rem .5rem; border-radius: 4px; }
.curve-svg { width: 100%; height: auto; display: block; }
.curve-grid-line { stroke: rgba(255,255,255,.08); stroke-width: 1; }
.curve-normal { stroke: #8fd6ab; stroke-width: 2.6; fill: none; stroke-linecap: round; }
.curve-bad { stroke: #f2a14f; stroke-width: 2.2; fill: none; stroke-linecap: round; stroke-dasharray: 5 4; }
.curve-axis { stroke: rgba(255,255,255,.25); stroke-width: 1; }
.curve-label { fill: #b9cdbf; font-family: var(--font-mono); font-size: 10px; }
.curve-legend { display: flex; gap: 1rem; margin-top: .5rem; font-size: .75rem; color: #b9cdbf; }
.legend-dot { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: .4rem; vertical-align: middle; }
.glucose-tip { font-size: .72rem; color: #93a89a; margin-top: .6rem; font-family: var(--font-mono); }

/* === STATS === */
.stats-strip {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;
  margin: 1.4rem 0 2.4rem;
}
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.2rem;
}
.stat b { display: block; font-family: var(--font-display); font-size: 1.5rem; color: var(--green-deep); }
.stat span { font-size: .85rem; color: var(--dim); }

/* === HOME SECTIONS === */
.home-section { margin-bottom: 2.2rem; }
.section-head { display: flex; align-items: baseline; gap: .8rem; margin-bottom: .9rem; }
.section-head h2 { margin: 0; font-size: 1.35rem; }
.sec-count { font-size: .8rem; color: var(--dim); font-family: var(--font-mono); }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.home-card {
  position: relative; display: block; text-decoration: none;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; transition: var(--transition);
}
.home-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16,35,26,.1); border-color: var(--green); }
.card-arrow { position: absolute; top: 1rem; right: 1.1rem; opacity: 0; transform: translateX(-8px); transition: var(--transition); color: var(--green); font-weight: 700; }
.home-card:hover .card-arrow { opacity: 1; transform: translateX(0); }
.home-card .ico { font-size: 1.4rem; }
.home-card h3 { font-size: .95rem; margin: .45rem 0 .35rem; color: var(--ink); font-weight: 600; }
.home-card p { font-size: .85rem; color: var(--dim); margin: 0; line-height: 1.55; }

/* === ARTICLE === */
.article { max-width: 780px; animation: fadeUp .28s ease-out; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }
.breadcrumbs { font-size: .83rem; color: var(--dim); margin-bottom: .6rem; }
.breadcrumbs a { color: var(--green-deep); text-decoration: none; }
.breadcrumbs span { margin: 0 .35rem; }
.article h1 { margin-bottom: .5rem; }
.meta { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; font-size: .83rem; color: var(--dim); margin-bottom: 1.2rem; }
.meta-sec { background: var(--green-soft); color: var(--green-deep); padding: .2rem .7rem; border-radius: 999px; font-weight: 600; }
.trust-badge { color: var(--teal); font-weight: 600; }

.toc {
  background: var(--paper-2); border: 1px solid var(--border); border-left: 3px solid var(--green);
  border-radius: 8px; padding: 1rem 1.2rem; margin: 1.2rem 0 1.6rem;
}
.toc b { display: block; font-size: .85rem; margin-bottom: .5rem; letter-spacing: .04em; text-transform: uppercase; color: var(--dim); }
.toc-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .25rem .8rem; }
.toc-links a { font-size: .88rem; text-decoration: none; color: var(--ink-soft); padding: .15rem 0; }
.toc-links a:hover { color: var(--green-deep); }

.article ul, .article ol { margin: 0 0 1.1rem 1.3rem; }
.article li { margin-bottom: .35rem; }

/* === COMPONENTS === */
.info-box, .warn-box, .tip-box {
  border-radius: 10px; padding: 1rem 1.2rem; margin: 1.2rem 0;
  font-size: .95rem;
}
.info-box { background: var(--teal-soft); border: 1px solid rgba(31,122,109,.25); }
.info-box b { color: var(--teal); }
.warn-box { background: var(--amber-soft); border: 1px solid rgba(184,92,0,.3); }
.warn-box b { color: var(--amber); }
.tip-box { background: var(--green-soft); border: 1px solid rgba(46,125,79,.3); }
.tip-box b { color: var(--green-deep); }

.cmp-table, .error-table {
  width: 100%; border-collapse: collapse; margin: 1.2rem 0 1.6rem;
  font-size: .9rem;
}
.cmp-table th, .cmp-table td, .error-table th, .error-table td {
  border: 1px solid var(--border); padding: .6rem .8rem; text-align: left; vertical-align: top;
}
.cmp-table th, .error-table th { background: var(--paper-2); font-weight: 700; font-size: .88rem; }
.cmp-table tr:nth-child(even) td, .error-table tr:nth-child(even) td { background: rgba(239,236,208,.35); }
.table-responsive { overflow-x: auto; margin: 1.2rem 0; }
.table-responsive .cmp-table, .table-responsive .error-table { margin: 0; }

.steps { list-style: none; counter-reset: step; margin: 1.2rem 0 !important; }
.steps li {
  counter-increment: step; position: relative;
  padding: .7rem 0 .7rem 2.6rem; border-bottom: 1px solid var(--border);
}
.steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute; left: 0; top: .7rem;
  font-family: var(--font-mono); font-size: .85rem; font-weight: 600; color: var(--green);
}

.faq-item { border: 1px solid var(--border); border-radius: 10px; margin-bottom: .7rem; overflow: hidden; }
.faq-q {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  width: 100%; padding: .9rem 1.1rem; background: var(--card);
  border: none; cursor: pointer; text-align: left;
  font-family: var(--font-display); font-size: 1rem; font-weight: 600; color: var(--ink);
}
.faq-q::after { content: '+'; font-size: 1.3rem; color: var(--green); transition: var(--transition); }
.faq-item.open .faq-q::after { transform: rotate(45deg); }
.faq-a { display: none; padding: 0 1.1rem 1rem; font-size: .95rem; }
.faq-item.open .faq-a { display: block; }

dl.glossary { margin: 1.2rem 0; }
dl.glossary dt {
  font-family: var(--font-display); font-weight: 700; font-size: 1rem;
  margin-top: 1rem; color: var(--green-deep);
}
dl.glossary dd { margin: .2rem 0 0 0; font-size: .93rem; color: var(--ink-soft); }

.error-page { max-width: 600px; margin: 4rem auto; text-align: center; }
.error-page h1 { font-size: 4rem; color: var(--green); }

/* === FOOTER === */
.app-footer { border-top: 1px solid var(--border); background: var(--paper-2); }
.footer-inner { max-width: 1400px; margin: 0 auto; padding: 1.6rem 1.2rem 2rem; font-size: .88rem; color: var(--dim); }
.foot-note { margin: .5rem 0; }
.foot-bottom { font-size: .8rem; font-family: var(--font-mono); }

/* === RESPONSIVE === */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: var(--header-h); left: 0; bottom: 0; width: 300px;
    background: var(--paper); z-index: 150;
    transform: translateX(-100%); transition: transform .25s ease-out;
    box-shadow: 4px 0 30px rgba(0,0,0,.12);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; position: fixed; inset: var(--header-h) 0 0 0; background: rgba(12,23,16,.45); z-index: 140; }
  .burger { display: flex; }
  .hero-inner { grid-template-columns: 1fr; }
  .main { padding: 1.2rem 1.1rem 2.5rem; }
  .home-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  body { font-size: 16.5px; }
  h1 { font-size: 1.7rem; }
  .home-grid { grid-template-columns: 1fr; }
  .stats-strip { grid-template-columns: 1fr; }
  .home-hero { padding: 1.8rem 1.4rem; }
  .search-wrap { max-width: none; }
  .brand-text { font-size: 1.15rem; }
}

/* === KEYFRAMES === */
@keyframes curveDraw { to { stroke-dashoffset: 0; } }
@keyframes curveDot { to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto; }
}
