/* ============================================================
   KredytyProsto - design system
   Paleta: głęboka zieleń (pieniądze, zaufanie) + złoto (wartość)
   + ciemny granat (powaga) + krem (ciepło)
   Typografia: Fraunces (display) + Outfit (body)
   ============================================================ */

:root {
  /* Light theme */
  --bg: #f7f3ea;
  --bg-card: #fffdf7;
  --surface: #ffffff;
  --text: #201a12;
  --text-muted: #6d6152;
  --accent: #166534;
  --accent-strong: #14532d;
  --accent-soft: #e7efe4;
  --gold: #a16207;
  --gold-soft: #f6edd8;
  --navy: #0d1526;
  --border: #e6ddcb;
  --border-strong: #d8ccb4;
  --header-bg: rgba(247, 243, 234, 0.92);
  --shadow-card: 0 1px 2px rgba(32, 26, 18, 0.05), 0 4px 16px rgba(32, 26, 18, 0.06);
  --shadow-card-hover: 0 2px 4px rgba(32, 26, 18, 0.07), 0 10px 28px rgba(32, 26, 18, 0.1);
  --hero-grad: radial-gradient(900px 400px at 85% -10%, rgba(212, 175, 55, 0.22), transparent 60%),
               linear-gradient(135deg, #14532d 0%, #0d1526 100%);
  --body-grad-a: radial-gradient(600px 400px at -10% -5%, rgba(22, 101, 52, 0.07), transparent 60%);
  --body-grad-b: radial-gradient(600px 400px at 110% 105%, rgba(212, 175, 55, 0.08), transparent 60%);
  --accent-subtle: rgba(212, 175, 55, 0.55);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Outfit", system-ui, sans-serif;
  --radius: 14px;
  --radius-sm: 9px;
  --header-h: 60px;
  --sidebar-w: 280px;
  --transition: all 0.2s ease-out;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1526;
    --bg-card: #131c31;
    --surface: #182238;
    --text: #e6ebf4;
    --text-muted: #9aa8c0;
    --accent: #34d399;
    --accent-strong: #2bb582;
    --accent-soft: #12293a;
    --gold: #e3b341;
    --gold-soft: #2a2413;
    --navy: #0a101d;
    --border: #24304a;
    --border-strong: #32405f;
    --header-bg: rgba(13, 21, 38, 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(0, 0, 0, 0.5);
    --hero-grad: radial-gradient(900px 400px at 85% -10%, rgba(227, 179, 65, 0.16), transparent 60%),
                 linear-gradient(135deg, #0f3d24 0%, #0a101d 100%);
    --body-grad-a: radial-gradient(600px 400px at -10% -5%, rgba(52, 211, 153, 0.06), transparent 60%);
    --body-grad-b: radial-gradient(600px 400px at 110% 105%, rgba(227, 179, 65, 0.05), transparent 60%);
  }
}

* { 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: var(--body-grad-a), var(--body-grad-b);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Accessibility ---------- */
.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 200;
  background: var(--accent); color: #fff; padding: 10px 16px;
  border-radius: var(--radius-sm); font-weight: 600;
}
.skip-link:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

/* ---------- Header ---------- */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  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: 0.3;
}
.header-inner {
  max-width: 1280px; margin: 0 auto; height: 100%;
  padding: 0 20px;
  display: flex; align-items: center; gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text);
  flex-shrink: 0;
}
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #fff; font-weight: 700; font-size: 17px;
  box-shadow: 0 2px 8px rgba(20, 83, 45, 0.35);
}
.brand-name {
  font-family: var(--font-display);
  font-size: 1.28rem; font-weight: 700; letter-spacing: -0.01em;
}
.brand-name em { font-style: normal; color: var(--accent); }
.menu-toggle {
  display: none; background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px; color: var(--text);
  cursor: pointer;
}
.menu-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Search ---------- */
.search-wrap { position: relative; margin-left: auto; width: min(340px, 40vw); }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
#searchInput {
  width: 100%; padding: 9px 14px 9px 36px;
  font-family: var(--font-body); font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px;
  transition: var(--transition);
}
#searchInput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 120;
  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;
}
.search-result {
  display: block; padding: 10px 14px; text-decoration: none;
  color: var(--text); border-bottom: 1px solid var(--border);
  transition: var(--transition);
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--accent-soft); }
.search-result .sr-title { font-weight: 600; font-size: 0.92rem; }
.search-result .sr-excerpt { font-size: 0.8rem; color: var(--text-muted); display: block; }

/* ---------- Layout ---------- */
.layout {
  max-width: 1280px; margin: 0 auto;
  padding: calc(var(--header-h) + 28px) 20px 60px;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 44px;
  min-height: calc(100vh - var(--header-h));
}
.sidebar {
  position: sticky; top: calc(var(--header-h) + 28px);
  align-self: start; height: calc(100vh - var(--header-h) - 56px);
  overflow-y: auto;
  padding: 4px 18px 20px 0;
  border-right: 1px solid var(--border);
  scrollbar-width: thin;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.home-link { font-weight: 700; }
.nav-section {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--text-muted);
  margin: 18px 10px 6px;
}
.sidebar-link {
  display: block; padding: 6px 10px;
  font-size: 0.9rem; line-height: 1.35; font-weight: 500;
  color: var(--text); text-decoration: none;
  border-radius: 8px;
  border-left: 3px solid transparent;
  transition: var(--transition);
}
.sidebar-link:hover { background: var(--accent-soft); color: var(--accent-strong); border-left-color: var(--gold); }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; border-left-color: var(--accent); }
.sidebar-foot { margin-top: 22px; padding: 14px 10px; font-size: 0.78rem; color: var(--text-muted); border-top: 1px solid var(--border); }
.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 90;
  background: rgba(10, 16, 29, 0.55); backdrop-filter: blur(2px);
}
.main { min-width: 0; }

/* ---------- Hero (home) ---------- */
.home-hero {
  position: relative;
  background: var(--hero-grad);
  border-radius: 22px;
  padding: 56px 48px 48px;
  color: #f4f1e8;
  overflow: hidden;
  margin-bottom: 44px;
  box-shadow: 0 12px 40px rgba(10, 16, 29, 0.28);
}
.home-hero::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: 0.5;
  pointer-events: none;
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--gold);
  border: 1px solid rgba(227, 179, 65, 0.4);
  background: rgba(227, 179, 65, 0.1);
  padding: 5px 14px; border-radius: 999px;
  margin-bottom: 20px;
}
.home-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 3.6vw, 2.8rem);
  font-weight: 700; line-height: 1.12; letter-spacing: -0.015em;
  max-width: 640px; text-wrap: balance;
  margin-bottom: 16px;
}
.home-hero h1 .gold { color: var(--gold); }
.home-hero p.hero-sub {
  font-size: 1.05rem; line-height: 1.6; color: rgba(244, 241, 232, 0.85);
  max-width: 560px; margin-bottom: 30px;
}
.hero-stats {
  display: flex; gap: 34px; flex-wrap: wrap;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding-top: 22px;
}
.hero-stat .hs-num {
  font-family: var(--font-display);
  font-size: 1.7rem; font-weight: 700; color: var(--gold);
}
.hero-stat .hs-label { font-size: 0.82rem; color: rgba(244, 241, 232, 0.75); }

/* ---------- Home sections & cards ---------- */
.home-section { margin-bottom: 40px; }
.home-section > h2 {
  font-family: var(--font-display);
  font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em;
  margin-bottom: 6px; text-wrap: balance;
  display: flex; align-items: center; gap: 12px;
}
.home-section > h2::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--border-strong), transparent);
}
.home-section > p.section-desc { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 18px; }
.home-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 16px;
}
.home-card {
  display: block; text-decoration: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  animation: fadeUp 0.35s var(--ease) backwards;
}
.home-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card-hover);
}
.home-card .card-icon { font-size: 1.5rem; line-height: 1; margin-bottom: 10px; display: block; }
.home-card h3 {
  font-family: var(--font-display);
  font-size: 1rem; font-weight: 600; line-height: 1.35;
  color: var(--text); margin-bottom: 6px; text-wrap: balance;
}
.home-card:hover h3 { color: var(--accent-strong); }
.home-card p {
  font-size: 0.92rem; line-height: 1.55; color: var(--text-muted);
}
.home-card .card-more {
  display: inline-block; margin-top: 10px;
  font-size: 0.82rem; font-weight: 600; color: var(--accent);
}

/* ---------- Article ---------- */
.content-article { max-width: 780px; animation: fadeUp 0.3s var(--ease) backwards; }
.content-article .article-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 0.82rem; color: var(--text-muted);
  margin-bottom: 14px;
}
.content-article .article-meta .badge {
  background: var(--accent-soft); color: var(--accent-strong);
  font-weight: 600; padding: 3px 12px; border-radius: 999px;
  font-size: 0.78rem;
}
.content-article h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3.4vw, 2.5rem);
  font-weight: 700; line-height: 1.15; letter-spacing: -0.015em;
  margin-bottom: 18px; text-wrap: balance;
}
.content-article h2 {
  font-family: var(--font-display);
  font-size: 1.45rem; font-weight: 700;
  margin: 38px 0 14px; padding-top: 6px;
  text-wrap: balance;
}
.content-article h2::before {
  content: '';
  display: block; width: 44px; height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  margin-bottom: 10px;
}
.content-article h3 {
  font-family: var(--font-display);
  font-size: 1.15rem; font-weight: 600;
  margin: 26px 0 10px; text-wrap: balance;
}
.content-article p { margin-bottom: 16px; }
.content-article ul, .content-article ol { margin: 0 0 18px 22px; }
.content-article li { margin-bottom: 8px; }
.content-article strong { font-weight: 700; }
.content-article a { color: var(--accent-strong); text-decoration-color: var(--gold); text-underline-offset: 3px; }
.content-article a:hover { color: var(--accent); }
.content-article hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }

/* Boxes */
.info-box, .warning-box, .tip-box {
  border-radius: var(--radius-sm);
  padding: 16px 18px; margin: 20px 0;
  font-size: 0.95rem; line-height: 1.6;
  border: 1px solid;
}
.info-box { background: var(--accent-soft); border-color: var(--border-strong); }
.warning-box { background: var(--gold-soft); border-color: var(--border-strong); }
.tip-box { background: var(--accent-soft); border-color: var(--border-strong); }
.info-box strong, .warning-box strong, .tip-box strong { display: block; margin-bottom: 4px; }

/* Tables */
.table-responsive { overflow-x: auto; margin: 20px 0; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.cmp-table, .content-article table {
  width: 100%; border-collapse: collapse;
  font-size: 0.9rem; line-height: 1.5;
  background: var(--bg-card);
}
.cmp-table thead th, .content-article table thead th {
  background: var(--accent-strong); color: #f4f1e8;
  text-align: left; font-weight: 600;
  padding: 11px 14px; font-size: 0.86rem;
}
.cmp-table tbody td, .content-article table tbody td {
  padding: 10px 14px; border-top: 1px solid var(--border);
  vertical-align: top;
}
.cmp-table tbody tr:nth-child(even), .content-article table tbody tr:nth-child(even) { background: var(--accent-soft); }
.cmp-table tbody tr:hover, .content-article table tbody tr:hover { background: var(--gold-soft); }

/* FAQ */
.faq-item {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 16px 18px; margin-bottom: 12px;
  background: var(--bg-card);
}
.faq-item h3 { font-size: 1rem; margin: 0 0 6px; font-family: var(--font-display); }
.faq-item p { margin: 0; font-size: 0.95rem; }

/* Glossary */
.content-article dl { margin: 0 0 20px; }
.content-article dt {
  font-weight: 700; font-family: var(--font-display); font-size: 1.02rem;
  margin-top: 16px; color: var(--accent-strong);
}
.content-article dd { margin: 4px 0 0 0; font-size: 0.95rem; }

/* Checklist */
.checklist { list-style: none; margin-left: 0 !important; }
.checklist li { padding-left: 30px; position: relative; }
.checklist li::before {
  content: '☐';
  position: absolute; left: 0; top: 0;
  color: var(--accent); font-size: 1.1rem; font-weight: 700;
}

/* TOC */
.toc {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px; margin: 24px 0;
  font-size: 0.9rem;
}
.toc-title { font-weight: 700; font-family: var(--font-display); margin-bottom: 8px; font-size: 1rem; }
.toc a { display: block; padding: 3px 0; color: var(--text); text-decoration: none; }
.toc a:hover { color: var(--accent-strong); }

/* Article nav */
.article-nav {
  display: flex; justify-content: space-between; gap: 16px;
  margin-top: 44px; padding-top: 20px;
  border-top: 1px solid var(--border);
}
.article-nav a {
  font-size: 0.9rem; font-weight: 600; color: var(--accent-strong);
  text-decoration: none; max-width: 45%;
}
.article-nav a:hover { text-decoration: underline; }
.article-nav .nav-next { text-align: right; }

/* ---------- Footer ---------- */
.app-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  padding: 40px 20px 48px;
}
.footer-inner { max-width: 1280px; margin: 0 auto; }
.app-footer p { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 8px; }
.app-footer strong { color: var(--text); font-family: var(--font-display); }
.footer-note { font-size: 0.8rem; max-width: 720px; }
.footer-links a { color: var(--accent-strong); text-decoration: none; font-weight: 600; }
.footer-links a:hover { text-decoration: underline; }

/* ---------- Animations ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 28px; padding-top: calc(var(--header-h) + 20px); }
  .menu-toggle { display: block; }
  .sidebar {
    position: fixed; top: var(--header-h); left: 0; bottom: 0; z-index: 95;
    width: min(320px, 85vw); height: auto;
    background: var(--bg); border-right: 1px solid var(--border);
    padding: 20px 18px 30px;
    transform: translateX(-105%);
    transition: transform 0.25s var(--ease);
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.15);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .home-hero { padding: 40px 26px 32px; }
  .search-wrap { width: auto; }
  #searchInput { padding-left: 34px; }
}

@media (max-width: 600px) {
  body { font-size: 16.5px; }
  .header-inner { padding: 0 12px; gap: 10px; }
  .brand-name { font-size: 1.1rem; }
  .search-icon { left: 9px; }
  .home-hero { border-radius: 16px; margin-bottom: 32px; }
  .hero-stats { gap: 20px; }
  .home-grid { grid-template-columns: 1fr; }
  .content-article h2 { font-size: 1.3rem; }
  .article-nav { flex-direction: column; }
  .article-nav .nav-next { text-align: left; }
  .app-footer { padding: 30px 16px 36px; }
}
