/* ============================================================
   E-URZĄD PROSTO - design system
   Paleta: granat + złoto + krem (zaufanie instytucjonalne)
   Typografia: Spectral (display) + Archivo (body)
   ============================================================ */

:root {
  /* Light theme */
  --paper: #f6f3ea;
  --paper-alt: #efe9da;
  --card: #fffef9;
  --ink: #1c2430;
  --muted: #5b6570;
  --navy: #123b5e;
  --navy-deep: #0b2740;
  --blue: #1a66a3;
  --gold: #a97e12;
  --gold-soft: #d9b64a;
  --border: #e0d8c6;
  --border-strong: #c9bfa6;
  --header-bg: rgba(11, 39, 64, 0.97);
  --header-text: #f2ede1;
  --sidebar-bg: #efe9da;
  --hero-grad: linear-gradient(135deg, #0b2740 0%, #123b5e 55%, #1c4f7c 100%);
  --accent-grad: linear-gradient(135deg, #b8860b, #e2b64e);
  --shadow: 0 1px 3px rgba(27, 38, 54, 0.08), 0 4px 16px rgba(27, 38, 54, 0.06);
  --shadow-hover: 0 2px 6px rgba(27, 38, 54, 0.1), 0 10px 28px rgba(27, 38, 54, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --transition: all 0.2s ease-out;
  --font-display: "Spectral", Georgia, serif;
  --font-body: "Archivo", "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0b1622;
    --paper-alt: #0e1c2c;
    --card: #102030;
    --ink: #e9eef4;
    --muted: #9fb0c0;
    --navy: #1c5a8f;
    --navy-deep: #081220;
    --blue: #79b4e8;
    --gold: #e2b64e;
    --gold-soft: #d9b64a;
    --border: #1e3347;
    --border-strong: #2c4a66;
    --header-bg: rgba(8, 18, 32, 0.97);
    --header-text: #e9eef4;
    --sidebar-bg: #0e1c2c;
    --hero-grad: linear-gradient(135deg, #081220 0%, #0e2a45 55%, #123b5e 100%);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 2px 6px rgba(0, 0, 0, 0.5), 0 12px 30px rgba(0, 0, 0, 0.45);
  }
}

* { 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(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(900px 500px at -10% -10%, rgba(217, 182, 74, 0.14), transparent 60%),
    radial-gradient(800px 500px at 110% 110%, rgba(26, 102, 163, 0.1), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--gold); color: #0b2740; padding: 10px 18px;
  font-weight: 700; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--header-bg);
  color: var(--header-text);
  border-bottom: 1px solid rgba(217, 182, 74, 0.25);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}
.app-header::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(217, 182, 74, 0.45), transparent);
  pointer-events: none;
}
.header-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 22px; height: 62px;
}
.brand {
  display: flex; align-items: center; gap: 10px; color: var(--header-text);
  text-decoration: none; flex-shrink: 0;
}
.brand:hover { text-decoration: none; opacity: 0.92; }
.brand-seal { width: 34px; height: 34px; color: var(--gold-soft); }
.brand-text {
  font-family: var(--font-display); font-weight: 700; font-size: 1.22rem; letter-spacing: 0.01em;
  white-space: nowrap;
}
.brand-accent { color: var(--gold-soft); }

.search-wrap { position: relative; flex: 1; max-width: 460px; margin-left: auto; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: #9fb0c0; pointer-events: none; }
#searchInput {
  width: 100%; padding: 9px 14px 9px 36px; font-size: 0.95rem; font-family: var(--font-body);
  color: var(--header-text); background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.22); border-radius: 8px; outline: none;
  transition: var(--transition);
}
#searchInput::placeholder { color: #b9c4d0; }
#searchInput:focus { border-color: var(--gold-soft); background: rgba(255, 255, 255, 0.14); box-shadow: 0 0 0 3px rgba(217, 182, 74, 0.25); }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 120;
  background: var(--card); color: var(--ink); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-hover); overflow: hidden;
  max-height: 420px; overflow-y: auto;
}
.search-results a { display: block; padding: 10px 14px; color: var(--ink); border-bottom: 1px solid var(--border); }
.search-results a:last-child { border-bottom: none; }
.search-results a:hover { background: var(--paper-alt); text-decoration: none; }
.search-results .sr-title { font-weight: 600; font-size: 0.92rem; }
.search-results .sr-sect { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.search-results .sr-none { padding: 12px 14px; color: var(--muted); font-size: 0.9rem; }

.menu-btn {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 42px; height: 42px; padding: 10px; background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 8px; cursor: pointer;
}
.menu-btn span { display: block; height: 2px; background: var(--header-text); 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); }

/* ---------- Layout ---------- */
.layout {
  display: grid; grid-template-columns: 280px minmax(0, 1fr);
  max-width: 1280px; margin: 0 auto; padding: 82px 20px 0; gap: 32px;
  min-height: calc(100vh - 200px);
}

.sidebar {
  position: sticky; top: 82px; align-self: start;
  max-height: calc(100vh - 100px); overflow-y: auto;
  padding: 6px 16px 14px 0;
  scrollbar-width: thin;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-section-label {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted); padding: 16px 10px 5px;
}
.sidebar-link {
  display: block; font-size: 0.9rem; font-weight: 500; color: var(--ink);
  padding: 6px 10px; border-radius: var(--radius-sm); line-height: 1.35;
  border-left: 2px solid transparent; transition: var(--transition);
}
.sidebar-link:hover { background: var(--paper-alt); text-decoration: none; color: var(--blue); }
.sidebar-link.active {
  background: var(--card); color: var(--navy); font-weight: 600;
  border-left-color: var(--gold); box-shadow: var(--shadow);
}
.sidebar-foot { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.sidebar-foot a { font-size: 0.85rem; font-weight: 600; color: var(--gold); padding: 2px 10px; }

.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 90;
  background: rgba(8, 18, 32, 0.55); backdrop-filter: blur(2px);
}

/* ---------- Main / content ---------- */
.main { min-width: 0; padding-bottom: 60px; outline: none; }

.content-article { animation: fadeUp 0.28s ease-out; }
.content-article h1 {
  font-family: var(--font-display); font-size: 2.1rem; font-weight: 700;
  line-height: 1.2; margin: 6px 0 12px; text-wrap: balance; color: var(--ink);
}
.article-meta {
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center;
  font-size: 0.8rem; color: var(--muted); margin-bottom: 22px;
  padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.article-meta .meta-section { color: var(--gold); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.72rem; }
.content-article h2 {
  font-family: var(--font-display); font-size: 1.5rem; font-weight: 700;
  margin: 34px 0 12px; line-height: 1.3; text-wrap: balance; scroll-margin-top: 90px;
}
.content-article h3 {
  font-family: var(--font-display); font-size: 1.18rem; font-weight: 700;
  margin: 26px 0 10px; text-wrap: balance; scroll-margin-top: 90px;
}
.content-article p { margin: 0 0 15px; }
.content-article ul, .content-article ol { margin: 0 0 16px; padding-left: 24px; }
.content-article li { margin-bottom: 6px; }
.content-article strong { font-weight: 700; }
.content-article img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }

/* TOC */
.toc {
  background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--gold);
  border-radius: var(--radius-sm); padding: 16px 20px; margin: 0 0 24px; font-size: 0.92rem;
}
.toc strong { display: block; margin-bottom: 8px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.toc a { display: block; padding: 3px 0; color: var(--ink); }
.toc a:hover { color: var(--blue); }

/* Info box */
.info-box {
  background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--blue);
  border-radius: var(--radius-sm); padding: 14px 18px; margin: 18px 0; font-size: 0.95rem;
}
.info-box.gold { border-left-color: var(--gold); }
.info-box.red { border-left-color: #b3382c; }

/* Tables */
.table-responsive { overflow-x: auto; margin: 18px 0; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table.error-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; background: var(--card); min-width: 480px; }
.error-table th {
  background: var(--navy); color: #f2ede1; text-align: left; padding: 10px 14px; font-weight: 600;
  font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em;
}
.error-table td { padding: 10px 14px; border-top: 1px solid var(--border); vertical-align: top; }
.error-table tr:nth-child(even) td { background: var(--paper-alt); }
.error-table td:first-child { font-weight: 600; color: var(--navy); white-space: nowrap; }

/* FAQ */
.faq-item { margin: 0 0 14px; }
.faq-item summary {
  cursor: pointer; font-weight: 600; padding: 12px 16px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-sm); list-style: none;
  transition: var(--transition); color: var(--ink);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before { content: "Q: "; color: var(--gold); font-weight: 700; }
.faq-item summary:hover { border-color: var(--border-strong); }
.faq-item[open] summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-color: var(--gold); }
.faq-item .faq-a { padding: 12px 16px; border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm); font-size: 0.95rem; }
.faq-item .faq-a p { margin-bottom: 8px; }

/* Glossary */
.glossary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.glossary-term { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; }
.glossary-term dt { font-weight: 700; color: var(--navy); font-size: 1rem; margin-bottom: 4px; }
.glossary-term dd { font-size: 0.92rem; color: var(--ink); margin: 0; }

/* Checklist */
.checklist { list-style: none; padding-left: 0 !important; }
.checklist li { padding: 8px 0 8px 32px; position: relative; border-bottom: 1px dashed var(--border); }
.checklist li::before {
  content: ""; position: absolute; left: 4px; top: 13px; width: 16px; height: 16px;
  border: 2px solid var(--gold); border-radius: 4px;
}
.checklist li:last-child { border-bottom: none; }

/* Prev/next */
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--border); }
.pager a {
  flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 16px; font-size: 0.88rem; color: var(--ink); transition: var(--transition);
}
.pager a:hover { border-color: var(--gold); transform: translateY(-2px); text-decoration: none; box-shadow: var(--shadow); }
.pager .pager-label { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 2px; }
.pager a.next { text-align: right; }

/* ---------- Home ---------- */
.home-hero {
  position: relative; overflow: hidden; color: #f2ede1;
  background: var(--hero-grad);
  border-radius: 14px; padding: 44px 40px 38px; margin-bottom: 34px;
}
.home-hero::before {
  content: ''; position: absolute; inset: 0; opacity: 0.16;
  background-image:
    linear-gradient(rgba(255,255,255,0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.16) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse at 30% 30%, black, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 30% 30%, black, transparent 75%);
}
.hero-inner { position: relative; display: flex; align-items: center; gap: 34px; max-width: 860px; }
.hero-text { flex: 1; }
.hero-eyebrow {
  display: inline-block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--gold-soft); margin-bottom: 12px;
  border: 1px solid rgba(217, 182, 74, 0.45); padding: 4px 12px; border-radius: 999px;
}
.home-hero h1 {
  font-family: var(--font-display); font-size: 2.35rem; font-weight: 700;
  line-height: 1.18; margin-bottom: 14px; text-wrap: balance;
}
.home-hero p.hero-sub { font-size: 1.06rem; color: #d5dde6; max-width: 520px; margin-bottom: 24px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: 12px 22px; border-radius: 8px; font-weight: 700; font-size: 0.95rem;
  transition: var(--transition); cursor: pointer; border: 2px solid transparent;
}
.btn:hover { transform: translateY(-2px); text-decoration: none; }
.btn-primary { background: var(--gold-soft); color: #0b2740; }
.btn-primary:hover { background: #e8c45e; box-shadow: 0 6px 20px rgba(217, 182, 74, 0.35); }
.btn-outline { border-color: rgba(242, 237, 225, 0.55); color: #f2ede1; background: transparent; }
.btn-outline:hover { border-color: #f2ede1; background: rgba(255, 255, 255, 0.08); }

/* Signature: official stamp */
.hero-stamp { flex-shrink: 0; width: 190px; height: 190px; position: relative; }
.stamp-svg { width: 100%; height: 100%; animation: stampIn 0.7s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.stamp-ring { transform-origin: center; animation: ringSpin 60s linear infinite; }
@keyframes stampIn {
  0% { transform: scale(1.9) rotate(-14deg); opacity: 0; }
  60% { transform: scale(0.96) rotate(1deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
@keyframes ringSpin { to { transform: rotate(360deg); } }

/* Trust strip */
.trust-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 34px;
}
.trust-item { background: var(--card); padding: 18px 20px; }
.trust-item .t-num {
  font-family: var(--font-display); font-size: 1.55rem; font-weight: 700; color: var(--navy);
  display: block; line-height: 1.1;
}
.trust-item .t-label { font-size: 0.8rem; color: var(--muted); }

/* Popular tasks */
.popular-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 40px;
}
.popular-link {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px;
  color: var(--ink); font-weight: 600; font-size: 0.92rem; transition: var(--transition);
}
.popular-link:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: var(--shadow-hover); text-decoration: none; }
.popular-link .p-icon { font-size: 1.3rem; }
.popular-link .p-arrow { margin-left: auto; color: var(--gold); opacity: 0; transform: translateX(-6px); transition: var(--transition); }
.popular-link:hover .p-arrow { opacity: 1; transform: translateX(0); }

/* Section card grid */
.home-section { margin-bottom: 38px; }
.home-section h2 {
  font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; margin-bottom: 4px;
  display: flex; align-items: center; gap: 10px; text-wrap: balance;
}
.home-section h2::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--border-strong), transparent); }
.home-section .sec-desc { color: var(--muted); font-size: 0.92rem; margin-bottom: 16px; }
.card-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(--card);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 18px;
  color: var(--ink); transition: var(--transition); position: relative; overflow: hidden;
}
.home-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent-grad); opacity: 0; transition: var(--transition);
}
.home-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--border-strong); text-decoration: none; }
.home-card:hover::before { opacity: 1; }
.home-card .card-icon { font-size: 1.5rem; line-height: 1; }
.home-card h3 { font-size: 0.9rem; font-weight: 700; line-height: 1.35; text-wrap: balance; color: var(--ink); }
.home-card p { font-size: 0.85rem; color: var(--muted); line-height: 1.5; margin: 0; }

/* Why section (hairline rows) */
.why-list { border-top: 1px solid var(--border); margin-bottom: 40px; }
.why-row {
  display: flex; gap: 18px; padding: 18px 4px; border-bottom: 1px solid var(--border);
  align-items: flex-start; transition: var(--transition);
}
.why-row:hover { background: var(--card); padding-left: 12px; padding-right: 12px; }
.why-row .w-num {
  font-family: var(--font-display); font-weight: 700; color: var(--gold); font-size: 1.05rem;
  min-width: 34px;
}
.why-row h3 { font-size: 1.02rem; font-weight: 700; margin-bottom: 3px; }
.why-row p { font-size: 0.92rem; color: var(--muted); margin: 0; }

/* ---------- Footer ---------- */
.app-footer {
  border-top: 1px solid var(--border); background: var(--paper-alt); margin-top: 40px;
}
.footer-inner { max-width: 1280px; margin: 0 auto; padding: 28px 20px 34px; font-size: 0.88rem; color: var(--muted); }
.footer-inner strong { color: var(--ink); }
.footer-links { margin: 10px 0 6px; }
.footer-links a { color: var(--ink); font-weight: 600; }
.footer-muted a { color: var(--gold); }

/* ---------- Animations ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.5s ease-out, transform 0.5s ease-out; }
.reveal.visible { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding-top: 76px; }
  .sidebar {
    position: fixed; top: 62px; left: 0; bottom: 0; width: 290px; z-index: 95;
    background: var(--sidebar-bg); padding: 12px 18px 24px; transform: translateX(-100%);
    transition: transform 0.25s ease-out; max-height: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25); }
  .sidebar-overlay.show { display: block; }
  .menu-btn { display: flex; }
  .search-wrap { max-width: none; }
  .hero-stamp { display: none; }
  .trust-strip { grid-template-columns: repeat(2, 1fr); }
  .glossary { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  body { font-size: 16.5px; }
  .header-inner { gap: 10px; padding: 0 14px; height: 58px; }
  .brand-text { font-size: 1.05rem; }
  .home-hero { padding: 30px 22px; }
  .home-hero h1 { font-size: 1.75rem; }
  .content-article h1 { font-size: 1.65rem; }
  .trust-strip { grid-template-columns: 1fr 1fr; }
  .trust-item { padding: 14px 16px; }
  .pager { flex-direction: column; }
}

/* Focus visible */
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
