/* ============================================
   DESIGN SYSTEM - Praca Zdalna v1
   Kompendium pracy zdalnej i zarabiania w internecie
   Paleta "WZROST": głęboka zieleń (pieniądze, zaufanie)
   + złoto (wzrost, zarobek) + ciepły krem (premium)
   Typografia: Spectral (display serif) + Archivo (body)
   ============================================ */

/* --- CSS VARIABLES --- */
:root {
  /* Light theme - ciepły krem */
  --bg: #f7f3ea;
  --bg-card: #fffdf7;
  --bg-surface: #fbf8f0;
  --bg-sidebar: #faf6ec;
  --text: #1f2c25;
  --text-secondary: #3d4a42;
  --text-muted: #5f6b62;
  --accent: #176b47;
  --accent-hover: #115736;
  --accent-light: #e3efe7;
  --accent-subtle: #bcd8c9;
  --ink: #10241b;
  --ink-deep: #0b1a13;
  --ink-soft: #1a3a2b;
  --green-bright: #3fae7a;
  --gold: #8a5d0a;
  --gold-bright: #d9a441;
  --gold-soft: #f3e5c3;
  --border: #e4dcc9;
  --border-light: #ece5d4;
  --code-bg: #f1ecdd;
  --header-bg: rgba(250, 246, 236, .92);
  --shadow-sm: 0 1px 2px rgba(16, 36, 27, .07);
  --shadow-md: 0 4px 20px rgba(16, 36, 27, .1);
  --shadow-lg: 0 14px 44px rgba(16, 36, 27, .16);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-full: 9999px;
  --nav-width: 305px;
  --header-height: 64px;
  --content-max: 780px;
  --font-body: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading: 'Spectral', Georgia, 'Times New Roman', serif;
  --green: #176b47;
  --red: #b3261e;
  --transition: .2s ease-out;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1a13;
    --bg-card: #14241c;
    --bg-surface: #101e16;
    --bg-sidebar: #0f1c15;
    --text: #e8e4d6;
    --text-secondary: #c2c7bc;
    --text-muted: #9aa89f;
    --accent: #3fae7a;
    --accent-hover: #57c48d;
    --accent-light: #12291e;
    --accent-subtle: #1e4a35;
    --ink: #0b150f;
    --ink-deep: #081009;
    --ink-soft: #17301f;
    --green-bright: #4ec488;
    --gold: #e0b354;
    --gold-bright: #e3b341;
    --gold-soft: #3a2c12;
    --border: #24382c;
    --border-light: #1d2e24;
    --code-bg: #14241c;
    --header-bg: rgba(13, 26, 19, .92);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, .4);
    --shadow-lg: 0 14px 44px rgba(0, 0, 0, .55);
  }
}

/* --- BASE --- */
* { 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(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 700px 420px at -10% -5%, rgba(63, 174, 122, .16), transparent 60%),
    radial-gradient(ellipse 700px 460px at 110% 105%, rgba(217, 164, 65, .14), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-heading); line-height: 1.25; color: var(--text); text-wrap: balance; }
code { font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace; font-size: .85em; background: var(--code-bg); padding: .15em .45em; border-radius: 5px; }
:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 2px; border-radius: 4px; }
.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--ink); color: #fff;
  padding: .6rem 1rem; border-radius: 0 0 8px 0; z-index: 200; font-size: .9rem;
}
.skip-link:focus { left: 0; color: #fff; }

/* --- HEADER --- */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-height);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.app-header::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--green-bright), var(--gold-bright), transparent);
  opacity: .5; pointer-events: none;
}
.mobile-menu-btn {
  display: none; background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 1.25rem; width: 42px; height: 42px; cursor: pointer; color: var(--text);
  transition: all var(--transition);
}
.mobile-menu-btn:hover { border-color: var(--accent); color: var(--accent); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.logo-seal { display: inline-flex; flex-shrink: 0; }
.brand-name { font-family: var(--font-heading); font-size: 1.22rem; font-weight: 700; letter-spacing: -.01em; }
.brand-name em { font-style: italic; color: var(--gold); }
.header-search { position: relative; margin-left: auto; width: min(340px, 40vw); }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); display: flex; }
.header-search input {
  width: 100%; padding: 9px 12px 9px 34px; font-size: .9rem; font-family: var(--font-body);
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-full);
  transition: all var(--transition);
}
.header-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

/* --- SEARCH RESULTS --- */
#search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); overflow: hidden; z-index: 120; display: none;
}
.search-result {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px;
  border-bottom: 1px solid var(--border-light); color: var(--text);
  transition: background var(--transition);
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--accent-light); text-decoration: none; }
.sr-icon { font-size: 1.1rem; flex-shrink: 0; }
.sr-title { font-size: .9rem; font-weight: 600; display: block; }
.sr-excerpt { font-size: .78rem; color: var(--text-muted); display: block; margin-top: 2px; }
mark { background: var(--gold-soft); color: var(--gold); padding: 0 2px; border-radius: 3px; }

/* --- SIDEBAR --- */
.sidebar {
  position: fixed; top: var(--header-height); left: 0; bottom: 0; width: var(--nav-width);
  overflow-y: auto; background: var(--bg-sidebar); border-right: 1px solid var(--border);
  padding: 18px 14px 30px; z-index: 90; scrollbar-width: thin;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.sidebar-nav { list-style: none; }
.sidebar-nav li { margin: 1px 0; }
.nav-section {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-muted); padding: 16px 10px 5px; font-family: var(--font-body);
}
.sidebar-link {
  display: flex; align-items: center; gap: 9px; padding: 6px 10px;
  font-size: .9rem; line-height: 1.4; color: var(--text-secondary);
  border-radius: var(--radius-sm); border-left: 3px solid transparent;
  transition: all var(--transition);
}
.sidebar-link:hover { background: var(--accent-light); color: var(--accent); text-decoration: none; }
.sidebar-link.active {
  background: var(--accent-light); color: var(--accent); font-weight: 600;
  border-left-color: var(--accent);
}
.sl-icon { font-size: .95rem; flex-shrink: 0; opacity: .9; }
.sidebar-foot { margin-top: 26px; padding: 14px 10px 0; border-top: 1px solid var(--border-light); }
.foot-seal { font-size: 1.4rem; display: block; margin-bottom: 6px; }
.sidebar-foot p { font-size: .78rem; color: var(--text-muted); line-height: 1.5; }
.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(10, 20, 15, .5); z-index: 85;
  opacity: 0; pointer-events: none; transition: opacity var(--transition);
}

/* --- MAIN --- */
.main-content {
  margin-left: var(--nav-width); padding: calc(var(--header-height) + 34px) 28px 60px;
  min-height: 100vh;
}
.content-article { max-width: var(--content-max); margin: 0 auto; animation: fadeUp .28s ease-out both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.content-article h1 { font-size: 2.15rem; font-weight: 700; margin-bottom: 12px; letter-spacing: -.01em; }
.content-article h2 { font-size: 1.5rem; font-weight: 700; margin: 34px 0 12px; padding-top: 6px; }
.content-article h2::before { content: ''; display: block; width: 46px; height: 3px; background: linear-gradient(90deg, var(--green-bright), var(--gold-bright)); border-radius: 2px; margin-bottom: 10px; }
.content-article h3 { font-size: 1.18rem; font-weight: 700; margin: 24px 0 8px; }
.content-article p { margin: 0 0 14px; }
.content-article ul, .content-article ol { margin: 0 0 16px; padding-left: 24px; }
.content-article li { margin-bottom: 6px; }
.article-meta { font-size: 1rem; color: var(--text-muted); margin-bottom: 18px; }

/* --- TOC --- */
.article-toc {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; margin: 18px 0 26px;
}
.article-toc h3 { font-size: .95rem; margin: 0 0 10px; color: var(--text-secondary); font-family: var(--font-body); text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; }
.article-toc a { display: block; padding: 3px 0; font-size: .92rem; color: var(--accent); }
.article-toc a:hover { text-decoration: underline; }
.article-toc .toc-h2 { font-weight: 600; }
.article-toc .toc-h3 { padding-left: 16px; font-size: .86rem; color: var(--text-secondary); }

/* --- BOXES --- */
.info-box {
  background: var(--accent-light); border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm); padding: 14px 18px; margin: 18px 0; font-size: .97rem;
}
.info-box strong { color: var(--accent); }
.warning-box {
  background: var(--gold-soft); border-left: 4px solid var(--gold);
  border-radius: var(--radius-sm); padding: 14px 18px; margin: 18px 0; font-size: .97rem;
}
.warning-box strong { color: var(--gold); }
.key-takeaways {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 22px; margin: 20px 0;
}
.key-takeaways h3 { font-size: 1rem; margin: 0 0 10px; font-family: var(--font-body); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); font-size: .82rem; }
.key-takeaways ul { margin: 0; padding-left: 20px; }
.key-takeaways li { margin-bottom: 5px; font-size: .96rem; }
.focus-box {
  background: var(--bg-card); border: 1px dashed var(--accent-subtle); border-radius: var(--radius-sm);
  padding: 14px 18px; margin: 18px 0; font-size: .97rem;
}

/* --- TABLES --- */
.table-responsive { overflow-x: auto; margin: 20px 0; border-radius: var(--radius); border: 1px solid var(--border); }
.error-table { width: 100%; border-collapse: collapse; font-size: .93rem; min-width: 560px; }
.error-table th {
  background: var(--ink); color: #f0ece0; text-align: left; padding: 11px 14px;
  font-weight: 600; font-size: .88rem; letter-spacing: .02em;
}
.error-table td { padding: 10px 14px; border-top: 1px solid var(--border-light); vertical-align: top; }
.error-table tr:nth-child(even) td { background: var(--bg-surface); }
.error-table tr:hover td { background: var(--accent-light); }

/* --- FAQ --- */
.faq-item { border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 10px 0; overflow: hidden; }
.faq-q {
  font-family: var(--font-body); font-size: 1rem; font-weight: 700; margin: 0;
  padding: 13px 18px; cursor: pointer; background: var(--bg-card); color: var(--text);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  transition: background var(--transition);
}
.faq-q::after { content: '+'; font-size: 1.3rem; color: var(--accent); flex-shrink: 0; transition: transform var(--transition); }
.faq-item.open .faq-q::after { transform: rotate(45deg); }
.faq-q:hover { background: var(--accent-light); }
.faq-a { display: none; padding: 4px 18px 14px; margin: 0; font-size: .95rem; }
.faq-item.open .faq-a { display: block; }

/* --- GLOSSARY --- */
.glossary { margin: 18px 0; }
.glossary dt {
  font-weight: 700; color: var(--accent); margin-top: 14px; font-size: 1rem;
  padding-left: 14px; border-left: 3px solid var(--accent-subtle);
}
.glossary dd { margin: 3px 0 0 17px; font-size: .95rem; color: var(--text-secondary); }

/* --- PREV / NEXT --- */
.prev-next { display: flex; justify-content: space-between; gap: 16px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border); }
.prev-next a {
  flex: 1; padding: 12px 16px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: .92rem; color: var(--text);
  transition: all var(--transition);
}
.prev-next a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.pn-label { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 3px; }

/* --- LEGAL NOTE --- */
.legal-note {
  margin-top: 34px; padding: 14px 18px; background: var(--bg-surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .82rem; color: var(--text-muted);
}

/* --- HOME HERO --- */
.home-hero {
  background: var(--ink);
  background-image:
    radial-gradient(ellipse 500px 300px at 85% -10%, rgba(63, 174, 122, .28), transparent 60%),
    radial-gradient(ellipse 420px 280px at 0% 110%, rgba(217, 164, 65, .22), transparent 55%);
  border-radius: var(--radius);
  padding: 44px 42px 34px; margin-bottom: 40px; color: #f0ece0;
  position: relative; overflow: hidden;
}
.home-hero::before {
  content: ''; position: absolute; inset: 0; opacity: .1; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.5) 1px, transparent 1px);
  background-size: 22px 22px;
}
.hero-badge {
  display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--gold-bright);
  border: 1px solid rgba(217, 164, 65, .5); border-radius: var(--radius-full);
  padding: 5px 14px; margin-bottom: 18px;
}
.home-hero h1 { color: #f7f3ea; font-size: 2.5rem; font-weight: 700; margin-bottom: 14px; letter-spacing: -.01em; }
.hero-sub { font-size: 1.08rem; color: #d8d4c6; max-width: 600px; margin-bottom: 26px; line-height: 1.65; }
.hero-cta {
  display: inline-block; background: var(--gold-bright); color: var(--ink-deep);
  font-weight: 700; font-size: 1rem; padding: 12px 26px; border-radius: var(--radius-full);
  transition: all var(--transition);
}
.hero-cta:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(217, 164, 65, .35); color: var(--ink-deep); text-decoration: none; }
.hero-cta span { margin-left: 6px; }

/* --- CHART SIGNATURE --- */
.chart-sig { margin: 30px 0 8px; }
.chart-sig svg { width: 100%; max-width: 620px; height: auto; display: block; }
.chart-path { stroke-dasharray: 520; stroke-dashoffset: 520; }
.chart-sig.in .chart-path { animation: drawLine 1.6s .2s ease-out forwards; }
.chart-sig.in .chart-dot { animation: popIn .5s 1.3s ease-out both; }
.chart-sig.in .chart-axis { animation: fadeIn 1s .1s ease-out both; }
@keyframes drawLine { to { stroke-dashoffset: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(.2); } to { opacity: 1; transform: scale(1); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sig-label { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: .78rem; color: #b5b2a4; letter-spacing: .04em; }
.sig-tag { color: var(--green-bright); font-weight: 700; text-transform: uppercase; font-size: .72rem; letter-spacing: .1em; }

/* --- STATS --- */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 26px; }
.stat-card { background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .12); border-radius: var(--radius-sm); padding: 14px 16px; }
.stat-card .num { display: block; font-family: var(--font-heading); font-size: 1.7rem; font-weight: 700; color: var(--gold-bright); line-height: 1.1; }
.stat-card .label { font-size: .8rem; color: #c8c5b7; }

/* --- HOME SECTIONS + CARDS --- */
.home-section-label {
  font-size: 1.35rem; font-weight: 700; margin: 40px 0 16px; display: flex; align-items: center; gap: 12px;
}
.accent-bar { display: inline-block; width: 8px; height: 26px; border-radius: 4px; background: linear-gradient(180deg, var(--green-bright), var(--gold-bright)); }
.home-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.home-card {
  display: block; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; color: var(--text);
  transition: all var(--transition);
}
.home-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--accent-subtle); text-decoration: none; color: var(--text); }
.card-icon { font-size: 1.4rem; display: block; margin-bottom: 8px; }
.home-card h3 { font-size: .9rem; font-weight: 700; margin-bottom: 5px; line-height: 1.35; }
.home-card p { font-size: .85rem; color: var(--text-muted); line-height: 1.5; margin: 0; }

/* --- FOOTER --- */
.app-footer { margin-left: var(--nav-width); border-top: 1px solid var(--border); background: var(--bg-surface); }
.footer-inner { max-width: var(--content-max); margin: 0 auto; padding: 22px 28px; display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--text-muted); }
.footer-note { font-size: .78rem; }

/* --- RESPONSIVE --- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-105%); transition: transform .25s ease-out; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { opacity: 1; pointer-events: auto; }
  .main-content { margin-left: 0; padding: calc(var(--header-height) + 24px) 18px 50px; }
  .app-footer { margin-left: 0; }
  .mobile-menu-btn { display: block; }
  .header-search { width: auto; flex: 1; }
  .brand-name { font-size: 1.05rem; }
  .home-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .home-hero { padding: 34px 24px 28px; }
  .home-hero h1 { font-size: 1.9rem; }
  .content-article h1 { font-size: 1.7rem; }
  .prev-next { flex-direction: column; }
}

@media (max-width: 600px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 10px 12px; }
  .stat-card .num { font-size: 1.4rem; }
  .hero-cta { width: 100%; text-align: center; }
  .content-article { font-size: 16.5px; }
}

/* --- REDUCED MOTION --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .chart-path { stroke-dashoffset: 0; }
}
