/* ============================================================
   Długi - design system
   Koncepcja: "Od długu do zera" - zaufanie (zieleń), powrót (bursztyn)
   Typografia: Spectral (display) + Manrope (body)
   ============================================================ */

:root {
  /* Light */
  --bg: #f6f3ea;
  --bg-soft: #efeadd;
  --panel: #fffdf7;
  --ink: #16211c;
  --ink-soft: #2c3a33;
  --muted: #4d5b53;
  --muted-2: #6b7a71;
  --accent: #b45309;
  --accent-strong: #9a4507;
  --accent-soft: #f7e8d6;
  --teal: #0f766e;
  --teal-soft: #e2f0ec;
  --deep: #123f32;
  --deep-2: #0d2f25;
  --border: #e2dccb;
  --border-strong: #cfc7b2;
  --shadow-card: 0 1px 2px rgba(18, 33, 28, .06), 0 6px 18px rgba(18, 33, 28, .06);
  --shadow-card-hover: 0 2px 4px rgba(18, 33, 28, .08), 0 12px 28px rgba(18, 33, 28, .12);
  --header-h: 60px;
  --sidebar-w: 300px;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: .2s ease-out;
  --font-display: 'Spectral', Georgia, 'Times New Roman', serif;
  --font-body: 'Manrope', 'Segoe UI', system-ui, sans-serif;
  --ledger: repeating-linear-gradient(0deg, transparent 0 31px, rgba(18, 63, 50, .035) 31px 32px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1512;
    --bg-soft: #101b16;
    --panel: #141f1a;
    --ink: #e8e6dc;
    --ink-soft: #d2d4c9;
    --muted: #a3b0a7;
    --muted-2: #83928a;
    --accent: #d97706;
    --accent-strong: #e58a1f;
    --accent-soft: #3a2a12;
    --teal: #2fb3a6;
    --teal-soft: #122a26;
    --deep: #0d2f25;
    --deep-2: #0a241c;
    --border: #24332c;
    --border-strong: #33463d;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .35);
    --shadow-card-hover: 0 2px 4px rgba(0, 0, 0, .5), 0 12px 30px rgba(0, 0, 0, .5);
    --ledger: repeating-linear-gradient(0deg, transparent 0 31px, rgba(255, 255, 255, .02) 31px 32px);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink);
  background-color: var(--bg);
  background-image: var(--ledger), radial-gradient(600px 400px at 85% -50px, rgba(15, 118, 110, .10), transparent 60%), radial-gradient(500px 380px at -80px 110%, rgba(180, 83, 9, .08), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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; z-index: 200;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
  font-weight: 700; font-size: .9rem;
}
.skip-link:focus { left: 0; color: #fff; text-decoration: none; }

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

/* ---------- header ---------- */

.app-header {
  position: fixed; inset: 0 0 auto 0; height: var(--header-h); z-index: 100;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  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), transparent);
  opacity: .3; pointer-events: none;
}

.header-inner {
  max-width: 1280px; height: 100%; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 16px;
}

.menu-btn {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 42px; height: 42px; padding: 10px; border: 1px solid var(--border);
  background: var(--panel); border-radius: var(--radius-sm); cursor: pointer;
}
.menu-btn span { display: block; height: 2px; background: var(--ink); border-radius: 2px; transition: var(--transition); }
.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: 10px; flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--deep), var(--deep-2));
  border-radius: 10px; font-size: 19px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.brand-name {
  font-family: var(--font-display); font-weight: 700; font-size: 1.28rem; color: var(--ink);
  letter-spacing: -.01em; white-space: nowrap;
}
.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; font-size: .92rem; font-family: var(--font-body);
  color: var(--ink); background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: 999px; transition: var(--transition);
}
.search-input::placeholder { color: var(--muted-2); }
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.search-wrap::before {
  content: ''; position: absolute; left: 14px; top: 50%; width: 14px; height: 14px;
  transform: translateY(-50%);
  border: 2px solid var(--muted-2); border-radius: 50%;
}
.search-wrap::after {
  content: ''; position: absolute; left: 26px; top: 62%; width: 7px; height: 2px;
  background: var(--muted-2); transform: rotate(45deg);
}

.search-results {
  display: none; position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 120;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-card-hover); overflow: hidden; max-height: 380px; overflow-y: auto;
}
.search-results.open { display: block; }
.search-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--bg-soft); text-decoration: none; }
.si-title { font-weight: 600; font-size: .9rem; color: var(--ink); }
.si-section { font-size: .75rem; color: var(--muted-2); text-transform: uppercase; letter-spacing: .04em; }
.search-empty { padding: 12px 14px; font-size: .88rem; color: var(--muted); }

.header-tagline { flex-shrink: 0; font-size: .8rem; color: var(--muted); letter-spacing: .02em; }

/* ---------- layout ---------- */

.layout { max-width: 1280px; margin: 0 auto; padding: calc(var(--header-h) + 24px) 20px 40px; display: flex; gap: 28px; }

.sidebar {
  position: sticky; top: calc(var(--header-h) + 24px); align-self: flex-start;
  width: var(--sidebar-w); flex-shrink: 0; max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto; padding: 18px 10px 18px 4px;
  border-right: 1px solid var(--border); scrollbar-width: thin;
}
.sidebar-nav { display: flex; flex-direction: column; }
.sidebar-section-label {
  font-size: .7rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase;
  color: var(--accent-strong); margin: 18px 10px 6px; }
.sidebar-section-label:first-child { margin-top: 0; }
.sidebar-link {
  display: flex; align-items: center; gap: 9px; padding: 6px 10px;
  font-size: .9rem; font-weight: 500; color: var(--ink-soft); border-radius: 8px;
  border-left: 3px solid transparent; transition: var(--transition); line-height: 1.4;
}
.sidebar-link:hover { background: var(--bg-soft); color: var(--ink); text-decoration: none; }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent-strong); border-left-color: var(--accent); font-weight: 700; }
.sl-icon { font-size: .95rem; flex-shrink: 0; }

.sidebar-overlay { display: none; }

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

/* ---------- home hero ---------- */

.home-hero {
  position: relative; overflow: hidden;
  background: linear-gradient(140deg, var(--deep) 0%, var(--deep-2) 55%, #0a2b1f 100%);
  color: #f4f1e6; border-radius: 18px; padding: 48px 44px 40px;
  box-shadow: var(--shadow-card-hover);
}
.home-hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: repeating-linear-gradient(0deg, transparent 0 39px, rgba(255, 255, 255, .03) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(255, 255, 255, .03) 39px 40px);
}
.home-hero::after {
  content: ''; position: absolute; right: -80px; top: -80px; width: 320px; height: 320px;
  border-radius: 50%; background: radial-gradient(circle, rgba(217, 119, 6, .28), transparent 65%);
  pointer-events: none;
}
.hero-eyebrow {
  display: inline-block; font-size: .78rem; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: #f0b35c; border: 1px solid rgba(240, 179, 92, .4);
  padding: 4px 12px; border-radius: 999px; margin-bottom: 18px;
}
.home-hero h1 {
  font-size: clamp(1.9rem, 4vw, 2.7rem); font-weight: 700; color: #fff;
  max-width: 620px; letter-spacing: -.01em; margin-bottom: 12px;
}
.hero-sub { max-width: 600px; color: #d8ddd3; font-size: 1.02rem; margin-bottom: 22px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 30px; }
.cta-primary {
  display: inline-block; background: var(--accent); color: #fff; font-weight: 700;
  padding: 12px 22px; border-radius: 10px; font-size: .98rem;
  transition: var(--transition); box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}
.cta-primary:hover { background: #c25e0d; transform: translateY(-1px); text-decoration: none; color: #fff; }
.cta-secondary {
  display: inline-block; background: transparent; color: #f0b35c; font-weight: 600;
  padding: 12px 22px; border-radius: 10px; font-size: .98rem; border: 1px solid rgba(240, 179, 92, .45);
  transition: var(--transition);
}
.cta-secondary:hover { background: rgba(240, 179, 92, .1); text-decoration: none; color: #f0b35c; }

.hero-odometer {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  border-top: 1px solid rgba(255, 255, 255, .14); padding-top: 22px;
}
.odo-num {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(2.4rem, 5.5vw, 3.6rem);
  color: #f0b35c; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1;
}
.odo-label { color: #c9d2c6; font-size: .92rem; max-width: 340px; }
.odo-label strong { color: #fff; font-weight: 700; }

/* ---------- home sections & cards ---------- */

.section-heading {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.42rem; font-weight: 600; color: var(--ink);
  margin: 44px 0 4px; padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
.sh-icon { font-size: 1.25rem; }

.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 16px; margin-top: 16px;
}
.home-card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 18px 16px; box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
}
.home-card::before {
  content: ''; position: absolute; top: 0; left: 16px; right: 16px; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--teal)); border-radius: 0 0 3px 3px;
  opacity: 0; transition: opacity var(--transition);
}
.home-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card-hover); border-color: var(--border-strong); text-decoration: none; }
.home-card:hover::before { opacity: 1; }
.hc-icon { font-size: 1.4rem; }
.home-card h3 { font-size: .98rem; font-weight: 600; color: var(--ink); font-family: var(--font-body); line-height: 1.4; }
.home-card p { font-size: .85rem; color: var(--muted); line-height: 1.55; flex: 1; }
.hc-arrow { font-size: .8rem; font-weight: 700; color: var(--accent); margin-top: 6px; }

/* ---------- debt ladder (plan splaty) ---------- */

.debt-ladder {
  margin: 20px 0 0; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-card);
}
.debt-ladder h2 { font-size: 1.25rem; padding: 20px 22px 0; color: var(--ink); }
.debt-ladder > p { padding: 6px 22px 12px; color: var(--muted); font-size: .9rem; }
.ladder-row {
  display: flex; align-items: baseline; gap: 16px; padding: 15px 22px;
  border-top: 1px solid var(--border); transition: var(--transition);
}
.ladder-row:hover { background: var(--bg-soft); }
.ladder-num {
  font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--accent);
  min-width: 34px; font-variant-numeric: tabular-nums;
}
.ladder-body { flex: 1; }
.ladder-body strong { display: block; font-size: .98rem; color: var(--ink); }
.ladder-body span { font-size: .85rem; color: var(--muted); }
.ladder-arrow { color: var(--teal); font-size: 1.1rem; }

/* ---------- article ---------- */

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

.article-wrap { max-width: 780px; margin: 0 auto; }
.article-breadcrumb { font-size: .8rem; color: var(--muted-2); margin-bottom: 12px; }
.article-breadcrumb a { color: var(--muted); }
.article-breadcrumb a:hover { color: var(--accent-strong); }
.article-header h1 { font-size: clamp(1.75rem, 3.6vw, 2.4rem); font-weight: 700; color: var(--ink); margin-bottom: 10px; }
.article-excerpt { font-size: 1.05rem; color: var(--muted); line-height: 1.6; margin-bottom: 14px; }
.am-chip {
  display: inline-block; font-size: .75rem; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: var(--teal); background: var(--teal-soft);
  padding: 4px 12px; border-radius: 999px; margin-bottom: 8px;
}

.toc-box {
  background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 16px 20px; margin: 20px 0 28px;
}
.toc-box strong { display: block; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin-bottom: 8px; }
.toc-box ol { padding-left: 20px; display: grid; gap: 4px; }
.toc-box li { font-size: .9rem; }
.toc-box a { color: var(--ink-soft); }
.toc-box a:hover { color: var(--accent-strong); }

.content-article > * + * { margin-top: 1.05em; }
.content-article h2 {
  font-size: 1.5rem; font-weight: 600; color: var(--ink);
  margin-top: 1.8em; padding-bottom: 8px; border-bottom: 1px solid var(--border);
  scroll-margin-top: calc(var(--header-h) + 16px);
}
.content-article h3 { font-size: 1.16rem; font-weight: 600; color: var(--ink); margin-top: 1.4em; scroll-margin-top: calc(var(--header-h) + 16px); }
.content-article p { color: var(--ink-soft); }
.content-article ul, .content-article ol { padding-left: 24px; color: var(--ink-soft); }
.content-article li { margin: .3em 0; }
.content-article strong { color: var(--ink); font-weight: 700; }
.content-article blockquote {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  padding: 14px 18px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-soft); font-style: italic;
}

.info-box, .warning-box {
  border-radius: var(--radius-sm); padding: 16px 18px; font-size: .95rem;
  display: flex; gap: 12px; align-items: flex-start;
}
.info-box { background: var(--teal-soft); border: 1px solid color-mix(in srgb, var(--teal) 30%, transparent); }
.warning-box { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.info-box .ib-icon, .warning-box .ib-icon { font-size: 1.15rem; line-height: 1.4; flex-shrink: 0; }
.info-box p, .warning-box p { margin: 0; color: var(--ink-soft); }
.info-box strong, .warning-box strong { color: var(--ink); }

.table-responsive { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.error-table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 560px; }
.error-table th {
  background: var(--deep); color: #f4f1e6; text-align: left; padding: 10px 14px;
  font-weight: 700; font-size: .85rem; letter-spacing: .02em;
}
.error-table td { padding: 10px 14px; border-top: 1px solid var(--border); color: var(--ink-soft); vertical-align: top; }
.error-table tr:nth-child(even) td { background: color-mix(in srgb, var(--bg-soft) 60%, transparent); }
.error-table tr:hover td { background: var(--accent-soft); }

.faq-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 18px 20px; background: var(--panel); margin-top: 14px; }
.faq-item h3 { margin: 0 0 8px; font-size: 1.05rem; }
.faq-item h3::before { content: 'Pytanie: '; color: var(--accent); font-weight: 700; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; display: block; margin-bottom: 4px; }
.faq-item p { margin: 0; color: var(--ink-soft); }

.content-article dl { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 20px; }
.content-article dt { font-weight: 700; color: var(--ink); margin-top: 14px; font-size: .98rem; }
.content-article dt:first-child { margin-top: 10px; }
.content-article dt::before { content: ''; display: inline-block; width: 7px; height: 7px; background: var(--accent); border-radius: 50%; margin-right: 8px; }
.content-article dd { margin: 2px 0 0 15px; color: var(--muted); font-size: .92rem; }

.not-found { max-width: 560px; margin: 60px auto; text-align: center; }
.nf-icon { font-size: 3rem; margin-bottom: 14px; }
.not-found h1 { font-size: 1.8rem; margin-bottom: 10px; }

/* ---------- footer ---------- */

.app-footer { border-top: 1px solid var(--border); background: var(--bg-soft); margin-top: 60px; }
.footer-inner { max-width: 1280px; margin: 0 auto; padding: 34px 20px 44px; }
.footer-inner p { color: var(--muted); font-size: .88rem; max-width: 760px; margin-bottom: 10px; }
.footer-inner strong { color: var(--ink); }
.footer-note { font-size: .8rem !important; color: var(--muted-2) !important; }
.footer-copy { font-size: .8rem !important; color: var(--muted-2) !important; margin-bottom: 0 !important; }

/* ---------- scroll reveal ---------- */

.reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s ease-out, transform .5s ease-out; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .menu-btn { display: flex; }
  .header-tagline { display: none; }
  .search-wrap { max-width: none; }
  .sidebar {
    position: fixed; top: var(--header-h); left: 0; bottom: 0; width: min(320px, 86vw); z-index: 110;
    background: var(--bg); border-right: 1px solid var(--border); padding: 20px 14px;
    transform: translateX(-102%); transition: transform .25s ease-out; box-shadow: var(--shadow-card-hover);
    max-height: none;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; position: fixed; inset: var(--header-h) 0 0 0; background: rgba(10, 20, 16, .5); z-index: 105; opacity: 0; pointer-events: none; transition: opacity .25s ease-out; }
  .sidebar-overlay.show { opacity: 1; pointer-events: auto; }
  .layout { padding: calc(var(--header-h) + 18px) 16px 36px; }
  .home-hero { padding: 36px 26px 30px; }
}

@media (max-width: 600px) {
  .home-hero { border-radius: 14px; }
  .hero-cta { flex-direction: column; }
  .cta-primary, .cta-secondary { text-align: center; }
  .card-grid { grid-template-columns: 1fr; }
  .ladder-row { flex-wrap: wrap; gap: 6px 12px; }
  .ladder-arrow { display: none; }
  .header-inner { gap: 10px; padding: 0 12px; }
  .brand-name { font-size: 1.12rem; }
  .search-input { padding-left: 34px; font-size: .85rem; }
}

@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; }
}
