/* ============================================================
   GIEŁDA PROSTO - Design System
   Paleta: głęboka zieleń (pieniądze, zaufanie) + złoto (bogactwo)
           + granat (stabilność) + krem (czytelność)
   Typografia: Zilla Slab (display) + Karla (body)
   Inspiracje: NerdWallet, Motley Fool, Bankrate
   ============================================================ */

:root {
  /* Kolor bazowy */
  --green-900: #0f3d2e;
  --green-800: #12462f;
  --green-700: #166534;
  --green-600: #1a7a45;
  --green-100: #dcefe3;
  --green-50: #eef7f0;

  /* Złoto */
  --gold: #c99700;
  --gold-strong: #8a6500;
  --gold-soft: #f7edd2;
  --gold-bright: #f5d061;

  /* Granat */
  --navy: #14243c;
  --navy-soft: #e7ecf4;

  /* Tła i tekst (jasny motyw) */
  --bg: #f7f4ec;
  --paper: #fffdf8;
  --paper-border: #e6e0d2;
  --text: #1c231f;
  --muted: #5d6b62;
  --heading: #123a2b;

  /* Komponenty */
  --green-soft: #e7f3ea;
  --red-soft: #fdecec;
  --red-text: #8a1f1f;
  --gold-box: #faf3dd;
  --blue-soft: #e9f0f8;

  /* Efekty */
  --shadow-card: 0 1px 2px rgba(20, 30, 25, .05), 0 4px 14px rgba(20, 30, 25, .06);
  --shadow-card-hover: 0 2px 4px rgba(20, 30, 25, .06), 0 10px 26px rgba(20, 30, 25, .12);
  --radius: 14px;
  --transition: all .2s ease-out;

  /* Typografia */
  --font-display: 'Zilla Slab', Georgia, 'Times New Roman', serif;
  --font-body: 'Karla', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Wymiary */
  --header-height: 64px;
  --sidebar-width: 300px;
}

/* ---------- DARK MODE ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1512;
    --paper: #131e18;
    --paper-border: #22332a;
    --text: #e8e4d8;
    --muted: #a3b3a9;
    --heading: #e8e4d8;
    --green-soft: #14301f;
    --red-soft: #2a1212;
    --red-text: #f0a5a5;
    --gold-box: #2e2a17;
    --blue-soft: #14202e;
    --navy-soft: #16222f;
    --green-50: #10271a;
    --green-100: #1c3d2b;
    --gold-soft: #3a3015;
    --shadow-card: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.35);
    --shadow-card-hover: 0 2px 4px rgba(0,0,0,.4), 0 10px 26px rgba(0,0,0,.5);
  }
}

/* ---------- RESET / BASE ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Subtelne gradienty w tle (przeciwległe rogi) */
body::before, body::after {
  content: '';
  position: fixed;
  width: 520px; height: 520px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  filter: blur(90px);
  opacity: .5;
}
body::before {
  background: radial-gradient(circle, rgba(26, 122, 69, .16), transparent 65%);
  top: -180px; left: -180px;
}
body::after {
  background: radial-gradient(circle, rgba(201, 151, 0, .14), transparent 65%);
  bottom: -200px; right: -160px;
}
@media (prefers-color-scheme: dark) {
  body::before { background: radial-gradient(circle, rgba(26, 122, 69, .22), transparent 65%); }
  body::after { background: radial-gradient(circle, rgba(201, 151, 0, .12), transparent 65%); }
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--heading);
  line-height: 1.25;
  text-wrap: balance;
  margin: 0 0 .5em;
}
p { margin: 0 0 1.1em; }
a { color: var(--green-700); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--green-900); color: #fff;
  padding: 10px 16px; border-radius: 0 0 8px 0; z-index: 200;
}
.skip-link:focus { left: 0; }

/* ---------- 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(--paper);
  border-bottom: 1px solid var(--paper-border);
  backdrop-filter: blur(10px);
  z-index: 100;
}
.app-header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(26, 122, 69, .35), rgba(201, 151, 0, .4), transparent);
  opacity: .7;
  pointer-events: none;
}
.mobile-menu-btn {
  display: none;
  background: none; border: none;
  font-size: 22px; line-height: 1;
  color: var(--text);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
}
.mobile-menu-btn:hover { background: var(--green-50); }
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.logo-seal { display: flex; }
.brand-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: .2px;
}
.brand-name em { font-style: normal; color: var(--gold-strong); }
@media (prefers-color-scheme: dark) { .brand-name em { color: var(--gold-bright); } }
.header-search {
  position: relative;
  flex: 1;
  max-width: 420px;
  margin-left: auto;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 12px;
  color: var(--muted);
  display: flex;
}
#search-input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  font-size: .92rem;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--paper-border);
  border-radius: 999px;
  transition: border-color .2s ease-out, box-shadow .2s ease-out;
}
#search-input:focus {
  outline: none;
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(26, 122, 69, .18);
}
#search-results {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--paper);
  border: 1px solid var(--paper-border);
  border-radius: 12px;
  box-shadow: var(--shadow-card-hover);
  overflow: hidden;
  z-index: 120;
}
.search-result {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 14px;
  border-bottom: 1px solid var(--paper-border);
  color: var(--text);
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--green-50); text-decoration: none; }
.sr-icon { font-size: 1.05rem; }
.sr-title { display: block; font-weight: 600; font-size: .92rem; }
.sr-excerpt { display: block; font-size: .8rem; color: var(--muted); }
mark { background: var(--gold-soft); color: inherit; border-radius: 3px; padding: 0 2px; }

/* ---------- LAYOUT ---------- */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  overflow-y: auto;
  background: var(--paper);
  border-right: 1px solid var(--paper-border);
  padding: 16px 10px 24px;
  z-index: 90;
}
.sidebar-nav { list-style: none; margin: 0; padding: 0; }
.nav-section {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--gold-strong);
  padding: 20px 12px 8px;
}
.nav-section + li { margin-top: 2px; }
.sidebar-link + .sidebar-link { margin-top: 1px; }
@media (prefers-color-scheme: dark) { .nav-section { color: var(--gold-bright); } }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: .9rem;
  line-height: 1.4;
  color: var(--text);
  padding: 7px 12px;
  border-radius: 8px;
  transition: var(--transition);
}
.sidebar-link:hover {
  background: var(--green-50);
  text-decoration: none;
  transform: translateX(2px);
}
.sidebar-link.active {
  background: var(--green-100);
  color: var(--green-700);
  font-weight: 600;
}
@media (prefers-color-scheme: dark) { .sidebar-link.active { color: var(--gold-bright); background: var(--green-soft); } }
.sl-icon { font-size: .95rem; flex-shrink: 0; }
.sidebar-foot {
  margin-top: 22px;
  padding: 12px;
  border-top: 1px solid var(--paper-border);
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.55;
}
.foot-seal { font-size: 1.1rem; display: block; margin-bottom: 4px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 12, .5);
  z-index: 85;
}

.main-content {
  margin-left: var(--sidebar-width);
  padding: calc(var(--header-height) + 26px) 34px 60px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ---------- ARTYKUŁ ---------- */
.content-article {
  max-width: 860px;
  margin: 0 auto;
  animation: fadeUp .28s ease-out;
}
@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: .35em;
}
.content-article h2 {
  font-size: 1.55rem;
  font-weight: 700;
  margin-top: 1.9em;
  padding-bottom: .3em;
  border-bottom: 1px solid var(--paper-border);
}
.content-article h3 { font-size: 1.22rem; font-weight: 600; margin-top: 1.5em; }
.content-article ul, .content-article ol { padding-left: 1.4em; margin: 0 0 1.2em; }
.content-article li { margin-bottom: .45em; }
.content-article strong { font-weight: 700; }
.article-meta {
  color: var(--muted);
  font-size: .98rem;
  margin-bottom: 1.2em;
}

/* Spis treści */
.article-toc {
  background: var(--paper);
  border: 1px solid var(--paper-border);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 1.4em 0 1.8em;
  font-size: .92rem;
}
.article-toc h3 {
  font-family: var(--font-body);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 0 0 8px;
}
.article-toc a { display: block; padding: 3px 0; color: var(--green-700); }
.article-toc a:hover { text-decoration: underline; }
.article-toc .toc-h3 { padding-left: 16px; color: var(--muted); }
@media (prefers-color-scheme: dark) { .article-toc a { color: #7ec99b; } }

/* Ramki */
.info-box, .tip-box, .warning-box, .key-takeaways {
  border-radius: 10px;
  padding: 14px 18px;
  margin: 1.3em 0;
  font-size: .96rem;
  line-height: 1.6;
}
.info-box { background: var(--green-soft); border-left: 3px solid var(--green-600); color: var(--text); }
.tip-box { background: var(--gold-box); border-left: 3px solid var(--gold); color: var(--text); }
.warning-box { background: var(--red-soft); border-left: 3px solid #c0392b; color: var(--text); }
.key-takeaways {
  background: var(--navy-soft);
  border: 1px solid var(--paper-border);
  border-left: 3px solid var(--navy);
}
.key-takeaways strong:first-child, .key-takeaways .kt-title { color: var(--green-700); }
@media (prefers-color-scheme: dark) { .key-takeaways strong:first-child { color: var(--gold-bright); } }
.info-box strong:first-child, .tip-box strong:first-child, .warning-box strong:first-child { display: block; margin-bottom: 4px; }

/* Tabele */
.table-responsive { overflow-x: auto; margin: 1.4em 0; border-radius: 10px; border: 1px solid var(--paper-border); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .93rem;
  background: var(--paper);
}
th, td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--paper-border); }
th {
  background: var(--green-900);
  color: #f0ead9;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: var(--green-50); }
tbody tr:hover { background: var(--green-100); }
td:first-child { font-weight: 600; }

/* FAQ */
.faq-item { margin: 0 0 10px; border: 1px solid var(--paper-border); border-radius: 10px; background: var(--paper); overflow: hidden; }
.faq-item details { padding: 0; }
.faq-item summary {
  cursor: pointer;
  padding: 13px 16px;
  font-weight: 600;
  font-size: .98rem;
  color: var(--heading);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+';
  font-family: var(--font-body);
  font-size: 1.2rem;
  color: var(--gold-strong);
  flex-shrink: 0;
  transition: transform .2s ease-out;
}
.faq-item details[open] summary::after { transform: rotate(45deg); }
.faq-item summary:hover { background: var(--green-50); }
.faq-answer { padding: 0 16px 14px; font-size: .95rem; color: var(--muted); }
.faq-answer p { margin-bottom: .6em; }

/* Słownik */
.glossary dl { margin: 0; }
.glossary dt {
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--green-700);
  margin-top: 1.1em;
}
.glossary dd { margin: .15em 0 0 0; color: var(--text); }
@media (prefers-color-scheme: dark) { .glossary dt { color: #7ec99b; } }

/* Checklista */
.checklist { list-style: none; padding-left: 0; }
.checklist li {
  padding: 8px 12px 8px 40px;
  position: relative;
  background: var(--paper);
  border: 1px solid var(--paper-border);
  border-radius: 8px;
  margin-bottom: 8px;
}
.checklist li::before {
  content: '☐';
  position: absolute;
  left: 14px;
  color: var(--gold-strong);
  font-size: 1.05rem;
}

/* Nawigacja poprzedni/następny */
.prev-next {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 2.6em;
  padding-top: 1.4em;
  border-top: 1px solid var(--paper-border);
}
.prev-next a {
  background: var(--paper);
  border: 1px solid var(--paper-border);
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 600;
  font-size: .93rem;
  color: var(--text);
  transition: var(--transition);
}
.prev-next a:hover { border-color: var(--green-600); transform: translateY(-2px); text-decoration: none; box-shadow: var(--shadow-card); }
.pn-label { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 2px; }
.prev-next > span { display: none; }

.legal-note {
  margin-top: 2.4em;
  padding: 12px 16px;
  background: var(--gold-box);
  border-radius: 10px;
  font-size: .82rem;
  color: var(--muted);
  line-height: 1.55;
}

/* ---------- STRONA GŁÓWNA ---------- */
.home-hero {
  position: relative;
  border-radius: 18px;
  padding: 44px 44px 36px;
  margin-bottom: 34px;
  color: #f0ead9;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(201, 151, 0, .22), transparent 60%),
    radial-gradient(900px 460px at -10% 110%, rgba(245, 208, 97, .12), transparent 55%),
    linear-gradient(135deg, var(--green-900) 0%, #12462f 55%, #0c2b20 100%);
  border: 1px solid rgba(245, 208, 97, .25);
  box-shadow: 0 10px 34px rgba(15, 61, 46, .28);
  overflow: hidden;
}
.home-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cpath d='M0 80 L30 60 L55 68 L85 40 L120 55' stroke='rgba(245,208,97,.07)' stroke-width='1' fill='none'/%3E%3C/svg%3E");
  pointer-events: none;
}
.hero-badge {
  display: inline-block;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--gold-bright);
  border: 1px solid rgba(245, 208, 97, .4);
  border-radius: 999px;
  padding: 5px 14px;
  margin-bottom: 16px;
  background: rgba(15, 61, 46, .4);
}
.home-hero h1 {
  color: #f7f3e8;
  font-size: 2.35rem;
  font-weight: 700;
  max-width: 620px;
  margin-bottom: 14px;
}
.home-hero .hero-sub {
  color: #cfd8d0;
  font-size: 1.06rem;
  max-width: 600px;
  margin-bottom: 22px;
}
.hero-cta {
  display: inline-block;
  background: linear-gradient(135deg, var(--gold) 0%, #b8860b 100%);
  color: #1c1505;
  font-weight: 700;
  font-size: .98rem;
  padding: 12px 22px;
  border-radius: 999px;
  transition: var(--transition);
}
.hero-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(201, 151, 0, .35);
  text-decoration: none;
}
.hero-sig { margin-top: 30px; }
.hero-sig svg { width: 100%; max-width: 640px; height: auto; display: block; }
.sig-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  font-size: .8rem;
  color: #a9c4b4;
  max-width: 640px;
}
.sig-tag {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--gold-bright);
  border: 1px solid rgba(245, 208, 97, .35);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

/* Animacja rysowania wykresu */
.chart-line {
  stroke-dasharray: 900;
  stroke-dashoffset: 900;
}
.hero-sig.in .chart-line { animation: drawLine 2.2s ease-out .2s forwards; }
.chart-area { opacity: 0; }
.hero-sig.in .chart-area { animation: fadeIn 1.2s ease-out 1.6s forwards; }
.chart-candle { opacity: 0; }
.hero-sig.in .chart-candle { animation: fadeIn .5s ease-out forwards; }
.hero-sig.in .chart-candle.c1 { animation-delay: 1.2s; }
.hero-sig.in .chart-candle.c2 { animation-delay: 1.45s; }
.hero-sig.in .chart-candle.c3 { animation-delay: 1.7s; }
@keyframes drawLine { to { stroke-dashoffset: 0; } }
@keyframes fadeIn { to { opacity: 1; } }

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 26px;
  max-width: 640px;
}
.stat-card {
  background: rgba(247, 243, 232, .08);
  border: 1px solid rgba(245, 208, 97, .22);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: center;
}
.stat-card .num { display: block; font-family: var(--font-display); font-size: 1.55rem; font-weight: 700; color: var(--gold-bright); line-height: 1.1; }
.stat-card .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: #a9c4b4; }

.home-section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.3rem;
  font-weight: 700;
  margin: 34px 0 16px;
}
.accent-bar {
  width: 4px;
  height: 22px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--green-600), var(--gold));
  flex-shrink: 0;
}
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.home-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--paper);
  border: 1px solid var(--paper-border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  color: var(--text);
  transition: var(--transition);
}
.home-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(26, 122, 69, .5);
  text-decoration: none;
}
.card-icon { font-size: 1.4rem; line-height: 1; }
.home-card h3 { font-size: .95rem; font-weight: 700; margin: 0; color: var(--heading); }
.home-card p { font-size: .85rem; color: var(--muted); margin: 0; line-height: 1.55; }

/* ---------- STOPKA ---------- */
.app-footer {
  margin-left: var(--sidebar-width);
  border-top: 1px solid var(--paper-border);
  background: var(--paper);
  padding: 22px 34px;
  position: relative;
  z-index: 1;
}
.footer-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: .85rem;
  color: var(--muted);
}
.footer-note { font-size: .78rem; }

/* ---------- RESPONSYWNOŚĆ ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease-out; box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; padding: calc(var(--header-height) + 20px) 18px 50px; }
  .app-footer { margin-left: 0; padding: 18px; }
  .mobile-menu-btn { display: block; }
  .header-search { max-width: none; }
  .home-hero { padding: 30px 24px 26px; }
  .home-hero h1 { font-size: 1.85rem; }
  .content-article h1 { font-size: 1.75rem; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .brand-name { font-size: 1.1rem; }
  .home-grid { grid-template-columns: 1fr; }
  .prev-next { grid-template-columns: 1fr; }
  .sig-label { flex-direction: column; align-items: flex-start; gap: 6px; }
  .home-hero h1 { font-size: 1.6rem; }
  .content-article h2 { font-size: 1.35rem; }
  th, td { padding: 8px 10px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}

/* ---------- RUCH (reduced motion) ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto; }
}
