/* ============================================================
   BUDŻETPROSTO - Design System
   Paleta: szmaragd (pieniądze, zaufanie) + złoto (oszczędności)
   + sosnowy grafit (ink) + krem (domowe ciepło)
   Typografia: Zilla Slab (display) + Work Sans (body)
   Signature: słoik oszczędności z animowanymi monetami w hero
   ============================================================ */

:root {
  /* Light theme (default) */
  --bg-primary: #f7f3ea;
  --bg-secondary: #efe9db;
  --bg-card: #fffdf7;
  --bg-code: #efe9db;
  --text-primary: #15241c;
  --text-secondary: #3f4a44;
  --text-muted: #5f6b64;
  --border: #e0d8c6;
  --accent: #0f7a4d;
  --accent-hover: #0b5c3a;
  --accent-soft: rgba(15, 122, 77, 0.09);
  --accent-2: #c9971c;
  --warning: #b45309;
  --warning-bg: #fdf0d7;
  --success: #047857;
  --success-bg: #d9f2e4;
  --danger: #b91c1c;
  --danger-bg: #fbe3e3;
  --header-bg: rgba(247, 243, 234, 0.92);
  --sidebar-bg: #f7f3ea;
  --shadow: 0 1px 3px rgba(21, 36, 28, 0.08);
  --shadow-lg: 0 12px 32px rgba(21, 36, 28, 0.14);
  --accent-light: rgba(15, 122, 77, 0.35);
  --accent-subtle: rgba(15, 122, 77, 0.13);
  --footer-bg: #0f1f17;
  --footer-text: #9fb0a6;
  --hero-bg: linear-gradient(135deg, #0c2e1f 0%, #0f5c3a 55%, #a87c14 130%);
  --hero-text: #f2f6f1;
  --hero-muted: #c6d4cb;
  --hero-accent: #f2c14e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #0d1512;
    --bg-secondary: #131e18;
    --bg-card: #15211b;
    --bg-code: #1b2a22;
    --text-primary: #e8e6dc;
    --text-secondary: #c4cfc8;
    --text-muted: #96a69c;
    --border: rgba(201, 151, 28, 0.18);
    --accent: #2e9e6b;
    --accent-hover: #45b980;
    --accent-soft: rgba(46, 158, 107, 0.14);
    --accent-2: #d9aa2e;
    --warning: #f0a04b;
    --warning-bg: rgba(240, 160, 75, 0.12);
    --success: #34c98a;
    --success-bg: rgba(52, 201, 138, 0.12);
    --danger: #f07575;
    --danger-bg: rgba(240, 117, 117, 0.12);
    --header-bg: rgba(13, 21, 18, 0.92);
    --sidebar-bg: #0d1512;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
    --accent-light: rgba(46, 158, 107, 0.4);
    --accent-subtle: rgba(46, 158, 107, 0.15);
    --footer-bg: #070d0a;
    --footer-text: #8a9b90;
    --hero-bg: linear-gradient(135deg, #081c12 0%, #0d4028 55%, #7a5c10 130%);
    --hero-text: #eef3ef;
    --hero-muted: #b9c8bf;
    --hero-accent: #e8b84a;
  }
}

/* ===== RESET / BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  font-family: 'Work Sans', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body::before, body::after {
  content: ''; position: fixed; pointer-events: none; z-index: -1;
  width: 600px; height: 600px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent-subtle), transparent 70%);
  opacity: .55;
}
body::before { top: -240px; right: -160px; }
body::after { bottom: -240px; left: -160px; }

::selection { background: var(--accent); color: #fff; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
input, button { font-family: inherit; }

h1, h2, h3, h4 {
  font-family: 'Zilla Slab', Georgia, serif;
  line-height: 1.22;
  text-wrap: balance;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); font-weight: 700; }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); font-weight: 600; margin: 2rem 0 .8rem; }
h3 { font-size: 1.15rem; font-weight: 600; margin: 1.6rem 0 .6rem; }
p { color: var(--text-secondary); line-height: 1.7; }
ul, ol { padding-left: 1.4rem; color: var(--text-secondary); }
li { margin: .3rem 0; }
strong { color: var(--text-primary); }

/* ===== HEADER ===== */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.app-header::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-subtle), transparent);
  opacity: .7;
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; gap: 20px;
  padding: 0 24px; height: 64px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: 'Zilla Slab', Georgia, serif;
  font-weight: 700; font-size: 1.1rem; color: var(--text-primary);
  white-space: nowrap;
}
.brand-icon {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; flex-shrink: 0;
}
.brand-icon svg { width: 19px; height: 19px; }
.brand-accent { color: var(--accent); }

.search-box { position: relative; margin-left: auto; width: min(340px, 38vw); }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted); pointer-events: none;
}
#search-input {
  width: 100%; height: 40px; padding: 0 14px 0 36px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-secondary); color: var(--text-primary);
  font-size: .92rem; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-results {
  position: absolute; top: 46px; left: 0; right: 0; z-index: 120;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  max-height: 380px; overflow-y: auto; padding: 6px;
}
.search-results a {
  display: block; padding: 9px 12px; border-radius: 8px;
  font-size: .88rem; color: var(--text-primary);
}
.search-results a:hover { background: var(--accent-soft); }
.search-results .sr-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); padding: 8px 12px 2px; }

.burger {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 8px;
}
.burger span { display: block; width: 22px; height: 2px; background: var(--text-primary); border-radius: 2px; transition: transform .25s, opacity .25s; }
.burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger.open span:nth-child(2) { opacity: 0; }
.burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ===== SIDEBAR ===== */
.page-wrap { display: flex; flex: 1; padding-top: 64px; }
.sidebar {
  width: 290px; flex-shrink: 0;
  position: sticky; top: 64px; height: calc(100vh - 64px);
  overflow-y: auto; padding: 16px 12px 40px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.sidebar-link {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 8px;
  font-size: .9rem; color: var(--text-secondary);
  border-left: 2px solid transparent;
  transition: background .15s, color .15s;
  line-height: 1.35;
}
.sidebar-link:hover { background: var(--accent-soft); color: var(--text-primary); }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.sidebar-link .si { font-size: .85rem; flex-shrink: 0; }
.sidebar-sec {
  padding: 16px 12px 4px;
  font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-muted);
}
.sidebar-overlay { display: none; }

/* ===== MAIN ===== */
.main {
  flex: 1; min-width: 0;
  padding: 40px 48px 80px;
  max-width: 980px;
  animation: fadeUp .28s ease-out;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== HOME HERO (signature: słoik z monetami) ===== */
.home-hero {
  position: relative;
  border-radius: 18px; overflow: hidden;
  padding: 48px 44px;
  background: var(--hero-bg);
  color: var(--hero-text);
  box-shadow: var(--shadow-lg);
  margin-bottom: 40px;
}
.home-hero::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 44px 44px;
  opacity: .5;
}
.home-hero > * { position: relative; }
.home-hero .hero-label {
  display: inline-block; font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .14em;
  color: var(--hero-accent); margin-bottom: 14px;
}
.home-hero h1 { font-size: clamp(1.9rem, 4.5vw, 2.7rem); color: var(--hero-text); margin-bottom: 14px; }
.home-hero h1 .hl { color: var(--hero-accent); }
.home-hero p { color: var(--hero-muted); font-size: 1.05rem; max-width: 620px; }
.home-hero .hero-cta {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 24px; padding: 12px 24px;
  background: linear-gradient(135deg, #e8b84a, #c9971c);
  color: #2a2005; font-weight: 700; font-size: .92rem;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: transform .2s ease-out, box-shadow .2s ease-out;
}
.home-hero .hero-cta:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); }
.home-hero .hero-stats {
  display: flex; gap: 32px; margin-top: 28px; flex-wrap: wrap;
}
.home-hero .hero-stat .num { font-family: 'Zilla Slab', Georgia, serif; font-size: 1.6rem; font-weight: 700; color: var(--hero-accent); }
.home-hero .hero-stat .lbl { font-size: .8rem; color: var(--hero-muted); }

/* Słoik oszczędności - signature */
.hero-jar {
  position: absolute; right: 36px; bottom: 26px;
  width: 150px; height: 170px;
  pointer-events: none;
}
.hero-jar .jar-body {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 120px; height: 130px;
  background: rgba(255, 255, 255, 0.14);
  border: 3px solid rgba(255, 255, 255, 0.55);
  border-radius: 16px 16px 26px 26px;
  overflow: hidden;
}
.hero-jar .jar-lid {
  position: absolute; left: 50%; top: 22px; transform: translateX(-50%);
  width: 78px; height: 18px;
  background: rgba(255, 255, 255, 0.28);
  border: 3px solid rgba(255, 255, 255, 0.6);
  border-radius: 6px;
}
.hero-jar .coin {
  position: absolute; left: 50%;
  width: 30px; height: 30px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe9a8, #e8b84a 60%, #b8892a);
  border: 2px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  animation: coinDrop 3.2s ease-in infinite;
}
.hero-jar .coin::after {
  content: 'zł'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #7a5c10;
}
.hero-jar .coin.c1 { top: 34px; animation-delay: 0s; }
.hero-jar .coin.c2 { top: 34px; animation-delay: 1.1s; }
.hero-jar .coin.c3 { top: 34px; animation-delay: 2.2s; }
@keyframes coinDrop {
  0% { transform: translate(-50%, -170px) rotate(0deg); opacity: 0; }
  12% { opacity: 1; }
  55% { transform: translate(-50%, 0) rotate(200deg); opacity: 1; }
  60% { transform: translate(-50%, -8px) rotate(200deg); }
  70% { transform: translate(-50%, 0) rotate(200deg); }
  100% { transform: translate(-50%, 0) rotate(200deg); opacity: 1; }
}
.hero-jar .jar-pile { position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); }
.hero-jar .jar-pile .coin { position: relative; left: auto; top: auto; animation: none; margin: -6px; display: inline-block; }
.hero-jar .jar-pile .coin.p1 { width: 28px; height: 28px; }
.hero-jar .jar-pile .coin.p2 { width: 24px; height: 24px; }
.hero-jar .jar-pile .coin.p3 { width: 30px; height: 30px; }
.hero-jar .jar-glass {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 120px; height: 130px; border-radius: 16px 16px 26px 26px;
  background: linear-gradient(120deg, rgba(255,255,255,.18), transparent 45%);
  pointer-events: none;
}

/* ===== HOME SECTIONS & CARDS ===== */
.home-section { margin-bottom: 44px; }
.home-section-title {
  font-family: 'Zilla Slab', Georgia, serif;
  font-size: 1.3rem; font-weight: 600;
  margin-bottom: 6px; display: flex; align-items: center; gap: 10px;
}
.home-section-title::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}
.home-section-desc { font-size: .9rem; color: var(--text-muted); margin-bottom: 18px; }
.home-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}
.home-card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 20px 18px;
  transition: transform .2s ease-out, box-shadow .2s ease-out, border-color .2s;
}
.home-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--accent-subtle); }
.home-card .card-icon { font-size: 1.5rem; line-height: 1; }
.home-card h3 { font-size: .95rem; font-weight: 600; margin: 0; color: var(--text-primary); }
.home-card p { font-size: .85rem; color: var(--text-muted); line-height: 1.55; }
.home-card .card-link {
  margin-top: auto; font-size: .82rem; font-weight: 600; color: var(--accent);
  display: inline-flex; align-items: center; gap: 4px;
}
.home-card .card-link::after { content: '→'; transition: transform .2s; }
.home-card:hover .card-link::after { transform: translateX(3px); }

/* ===== ARTICLE ===== */
.article-header { margin-bottom: 28px; padding-bottom: 22px; border-bottom: 1px solid var(--border); }
.article-header .article-icon { font-size: 2.2rem; line-height: 1; margin-bottom: 12px; }
.article-header h1 { margin-bottom: 10px; }
.article-header .article-excerpt { font-size: 1.08rem; color: var(--text-secondary); max-width: 700px; }
.article-meta {
  display: flex; gap: 16px; margin-top: 14px;
  font-size: .8rem; color: var(--text-muted);
}
.article-meta span { display: inline-flex; align-items: center; gap: 5px; }

.info-box {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--accent-soft);
  border: 1px solid var(--accent-subtle);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 1.4rem 0;
  font-size: .95rem; color: var(--text-secondary);
}
.info-box .ib-icon { font-size: 1.15rem; line-height: 1.4; flex-shrink: 0; }

.warning-box {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--warning-bg);
  border: 1px solid rgba(180, 83, 9, 0.25);
  border-left: 4px solid var(--warning);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 1.4rem 0;
  font-size: .95rem; color: var(--text-secondary);
}
.warning-box .wb-icon { font-size: 1.15rem; line-height: 1.4; flex-shrink: 0; }

.success-box {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--success-bg);
  border: 1px solid rgba(4, 120, 87, 0.25);
  border-left: 4px solid var(--success);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 1.4rem 0;
  font-size: .95rem; color: var(--text-secondary);
}
.success-box .sb-icon { font-size: 1.15rem; line-height: 1.4; flex-shrink: 0; }

table {
  width: 100%; border-collapse: collapse;
  margin: 1.4rem 0; font-size: .92rem;
  background: var(--bg-card);
  border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border);
}
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg-secondary); font-family: 'Zilla Slab', Georgia, serif; font-size: .88rem; font-weight: 600; color: var(--text-primary); }
tr:last-child td { border-bottom: none; }
td { color: var(--text-secondary); }
.table-responsive { overflow-x: auto; }

.error-table th { background: var(--danger-bg); color: var(--danger); }
.error-table td:first-child { font-weight: 600; color: var(--danger); font-family: 'Zilla Slab', Georgia, serif; }

.faq-item { margin: 1.2rem 0; padding: 18px 20px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; }
.faq-item h3 { margin: 0 0 8px; font-size: 1.02rem; }
.faq-item p { margin: 0; }

dl { margin: 1.2rem 0; }
dt { font-family: 'Zilla Slab', Georgia, serif; font-weight: 600; color: var(--accent); margin-top: 1.1rem; font-size: 1rem; }
dd { color: var(--text-secondary); margin: .2rem 0 0; padding-left: 0; }

code {
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: .88em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px;
  color: var(--text-primary);
}

.content-article { max-width: 760px; }
.content-article h2:first-child { margin-top: 0; }

/* ===== TOC ===== */
.toc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin: 0 0 1.6rem;
  font-size: .9rem;
}
.toc-title {
  font-family: 'Zilla Slab', Georgia, serif;
  font-size: .8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-muted); margin-bottom: 8px;
}
.toc a {
  display: block; padding: 4px 0; color: var(--text-secondary);
  border-left: 2px solid transparent; padding-left: 10px;
  transition: color .15s, border-color .15s;
}
.toc a:hover { color: var(--accent); border-left-color: var(--accent); }

/* ===== 404 ===== */
.notfound { text-align: center; padding: 80px 20px; }
.notfound .nf-icon { font-size: 3rem; margin-bottom: 16px; }
.notfound h1 { margin-bottom: 10px; }
.notfound p { margin-bottom: 20px; }
.btn {
  display: inline-block; padding: 10px 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 600; font-size: .9rem;
  border-radius: 10px; transition: opacity .2s, transform .2s;
}
.btn:hover { opacity: .9; transform: translateY(-1px); }

/* ===== FOOTER ===== */
.app-footer {
  background: var(--footer-bg); color: var(--footer-text);
  padding: 40px 24px; margin-top: auto;
}
.footer-inner { max-width: 1200px; margin: 0 auto; }
.footer-brand { font-family: 'Zilla Slab', Georgia, serif; font-weight: 700; color: #e8e6dc; font-size: 1rem; margin-bottom: 8px; }
.footer-desc { font-size: .85rem; max-width: 640px; line-height: 1.6; }
.footer-copy { font-size: .78rem; margin-top: 16px; color: #6f8177; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: -300px; top: 64px; bottom: 0;
    width: 290px; z-index: 90;
    transition: left .3s ease-out;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }
  .sidebar-overlay {
    display: block; position: fixed; inset: 64px 0 0 0; z-index: 80;
    background: rgba(0,0,0,.45); opacity: 0; pointer-events: none;
    transition: opacity .3s;
  }
  .sidebar-overlay.show { opacity: 1; pointer-events: auto; }
  .burger { display: flex; }
  .search-box { width: auto; flex: 1; max-width: none; }
  .main { padding: 28px 24px 60px; }
  .hero-jar { right: 24px; transform: scale(.85); transform-origin: bottom right; }
}
@media (max-width: 600px) {
  body { font-size: 16.5px; }
  .header-inner { padding: 0 16px; gap: 12px; }
  .brand-text { font-size: .98rem; }
  .brand-accent { display: none; }
  .main { padding: 22px 16px 50px; }
  .home-hero { padding: 34px 24px; }
  .home-hero .hero-stats { gap: 20px; }
  .home-grid { grid-template-columns: 1fr; }
  .search-results { max-height: 320px; }
  .hero-jar { display: none; }
}

/* ===== FOCUS VISIBLE (WCAG) ===== */
a:focus-visible, input:focus-visible, button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
