/* ============================================
   Zylaki - design system
   Paleta: zieleń żylna + teal + krem + bursztyn
   Typografia: Spectral (display) + Manrope (body)
   ============================================ */

:root {
  /* Light theme - zdrowie, czystość, zaufanie */
  --bg: #f7f5ef;
  --bg-alt: #eef2ec;
  --surface: #ffffff;
  --surface-alt: #f2f5f1;
  --text: #16221c;
  --text-secondary: #4a5a51;
  --muted: #5c6b63;
  --accent: #0c6b4a;
  --accent-strong: #085a3e;
  --accent-light: #dcebe2;
  --accent-subtle: #eaf3ee;
  --teal: #1f6f8b;
  --teal-light: #dcebf0;
  --amber: #b97f2c;
  --amber-light: #f6ead6;
  --danger: #a3322b;
  --danger-light: #f7e2e0;
  --border: #e3e1d8;
  --border-light: #eceadf;
  --shadow-card: 0 1px 3px rgba(22, 34, 28, 0.06), 0 4px 16px rgba(22, 34, 28, 0.05);
  --shadow-card-hover: 0 2px 6px rgba(12, 107, 74, 0.1), 0 10px 28px rgba(12, 107, 74, 0.12);
  --header-bg: rgba(247, 245, 239, 0.92);
  --radius: 14px;
  --radius-sm: 8px;
  --font-display: 'Spectral', Georgia, serif;
  --font-body: 'Manrope', 'Segoe UI', sans-serif;
  --transition: 0.2s ease-out;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1210;
    --bg-alt: #111815;
    --surface: #141c18;
    --surface-alt: #18211c;
    --text: #e6eae6;
    --text-secondary: #b4c0b8;
    --muted: #93a299;
    --accent: #4fd1a0;
    --accent-strong: #6fe0b4;
    --accent-light: #1d352b;
    --accent-subtle: #162720;
    --teal: #58b7d8;
    --teal-light: #1c2f38;
    --amber: #e0a94f;
    --amber-light: #362b18;
    --danger: #f08a82;
    --danger-light: #3a201e;
    --border: #242e28;
    --border-light: #1c2520;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-card-hover: 0 2px 6px rgba(79, 209, 160, 0.12), 0 10px 28px rgba(0, 0, 0, 0.4);
    --header-bg: rgba(13, 18, 16, 0.92);
  }
}

* { 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-color: var(--bg);
  background-image:
    radial-gradient(ellipse 900px 500px at -10% -10%, var(--accent-light), transparent 60%),
    radial-gradient(ellipse 800px 500px at 110% 110%, var(--teal-light), transparent 60%);
  background-attachment: fixed;
  min-height: 100vh;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  z-index: 2000;
  border-radius: 0 0 8px 0;
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.app-header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-subtle), var(--accent), var(--accent-subtle), transparent);
  opacity: 0.5;
  pointer-events: none;
}
.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
.logo-mark { font-size: 1.5rem; }
.logo-text {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.logo-text em {
  font-style: italic;
  color: var(--accent);
}

.header-search {
  position: relative;
  flex: 1;
  max-width: 420px;
  margin-left: auto;
}
.header-search input {
  width: 100%;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.header-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
#search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card-hover);
  overflow: hidden;
  display: none;
  z-index: 100;
}

/* ---------- Mobile menu button ---------- */
.mobile-menu-btn {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}
.mobile-menu-btn span {
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}

/* ---------- Layout ---------- */
.layout {
  display: flex;
  max-width: 1440px;
  margin: 0 auto;
  padding-top: 64px;
  min-height: calc(100vh - 64px);
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  padding: 24px 12px 40px 20px;
  border-right: 1px solid var(--border-light);
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
}
.sidebar-section {
  margin-bottom: 18px;
}
.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  padding: 0 10px;
  margin-bottom: 4px;
}
.sidebar-link {
  display: block;
  padding: 6px 10px;
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.sidebar-link:hover {
  color: var(--text);
  background: var(--accent-subtle);
}
.sidebar-link.active {
  color: var(--accent-strong);
  background: var(--accent-light);
  border-left-color: var(--accent);
  font-weight: 700;
}
@media (prefers-color-scheme: dark) {
  .sidebar-link.active { color: var(--accent); }
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 900;
}

/* ---------- Main ---------- */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 40px 48px 64px;
}

/* ---------- Home hero ---------- */
.home-hero {
  position: relative;
  border-radius: var(--radius);
  padding: 48px 44px;
  margin-bottom: 40px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(8, 90, 62, 0.96), rgba(31, 111, 139, 0.92)),
    var(--accent);
  overflow: hidden;
  box-shadow: var(--shadow-card-hover);
}
.home-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle 300px at 85% 20%, rgba(255, 255, 255, 0.12), transparent 60%),
    radial-gradient(circle 240px at 15% 90%, rgba(201, 138, 61, 0.25), transparent 60%);
  pointer-events: none;
}
.hero-icon { font-size: 2.6rem; margin-bottom: 12px; }
.home-hero h1 {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 12px;
  text-wrap: balance;
}
.home-hero p {
  font-size: 1.05rem;
  max-width: 640px;
  color: rgba(255, 255, 255, 0.92);
  margin-bottom: 24px;
}
.stats-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.stat-card {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(4px);
}
.stat-card .num {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
}
.stat-card .label {
  font-size: 0.75rem;
  opacity: 0.88;
}

/* ---------- Home sections & cards ---------- */
.home-section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin: 36px 0 16px;
  text-wrap: balance;
}
.home-section-label:first-of-type { margin-top: 8px; }
.accent-bar {
  display: inline-block;
  width: 4px;
  height: 22px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--accent), var(--teal));
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.home-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.home-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--accent-light);
}
.card-icon { font-size: 1.5rem; display: block; margin-bottom: 8px; }
.home-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 6px;
  color: var(--text);
}
.home-card p {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--muted);
}

/* ---------- Article ---------- */
.content-article {
  max-width: 780px;
  animation: fadeUp 0.25s ease-out;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.content-article h1 {
  font-family: var(--font-display);
  font-size: 2.15rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 12px;
  color: var(--text);
  text-wrap: balance;
}
.article-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.article-toc {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin: 20px 0 28px;
}
.article-toc h3 {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}
.article-toc a {
  display: block;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 3px 0;
  line-height: 1.4;
}
.article-toc a:hover { color: var(--accent-strong); }
.article-toc .toc-h3 { padding-left: 14px; font-size: 0.85rem; }

.content-article h2 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text);
  margin: 34px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
  text-wrap: balance;
  scroll-margin-top: 84px;
}
.content-article h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin: 24px 0 8px;
  text-wrap: balance;
  scroll-margin-top: 84px;
}
.content-article p {
  margin-bottom: 14px;
  color: var(--text);
}
.content-article ul, .content-article ol {
  margin: 0 0 16px 22px;
  color: var(--text);
}
.content-article li { margin-bottom: 6px; }
.content-article strong { font-weight: 700; }
.content-article a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 2px;
}
@media (prefers-color-scheme: dark) {
  .content-article a { color: var(--accent); }
}

/* ---------- Info boxes ---------- */
.info-box {
  background: var(--accent-subtle);
  border: 1px solid var(--accent-light);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 18px 0;
  font-size: 0.95rem;
}
.info-box strong:first-child { color: var(--accent-strong); }
@media (prefers-color-scheme: dark) {
  .info-box strong:first-child { color: var(--accent); }
}

.warning-box {
  background: var(--danger-light);
  border: 1px solid rgba(163, 50, 43, 0.25);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 18px 0;
  font-size: 0.95rem;
}
.warning-box strong:first-child { color: var(--danger); }

.amber-box {
  background: var(--amber-light);
  border: 1px solid rgba(185, 127, 44, 0.3);
  border-left: 4px solid var(--amber);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 18px 0;
  font-size: 0.95rem;
}

/* ---------- 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.9rem;
  background: var(--surface);
}
.error-table th {
  background: var(--accent);
  color: #fff;
  text-align: left;
  padding: 10px 14px;
  font-weight: 700;
  white-space: nowrap;
}
.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(--surface-alt); }
.error-table td:first-child { font-weight: 700; color: var(--text); white-space: nowrap; }

/* ---------- FAQ ---------- */
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 10px;
  overflow: hidden;
}
.faq-item summary {
  cursor: pointer;
  padding: 14px 18px;
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--text);
  list-style: none;
  position: relative;
  padding-right: 44px;
  transition: background var(--transition);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+';
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.3rem;
  color: var(--accent-strong);
  transition: transform var(--transition);
}
.faq-item[open] summary::after { transform: translateY(-50%) rotate(45deg); }
.faq-item summary:hover { background: var(--accent-subtle); }
.faq-item .faq-answer {
  padding: 4px 18px 14px;
  font-size: 0.95rem;
  color: var(--text-secondary);
}
.faq-item .faq-answer p { margin-bottom: 8px; }

/* ---------- Glossary ---------- */
.glossary-list { margin: 18px 0; }
.glossary-list dt {
  font-weight: 700;
  color: var(--accent-strong);
  margin-top: 14px;
  font-size: 1rem;
}
@media (prefers-color-scheme: dark) {
  .glossary-list dt { color: var(--accent); }
}
.glossary-list dd {
  margin: 2px 0 0 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ---------- Checklist ---------- */
.checklist {
  list-style: none;
  margin: 18px 0 !important;
}
.checklist li {
  position: relative;
  padding-left: 34px;
  margin-bottom: 10px;
  line-height: 1.55;
}
.checklist li::before {
  content: '☐';
  position: absolute;
  left: 0;
  top: 0;
  font-size: 1.1rem;
  color: var(--accent-strong);
}
@media (prefers-color-scheme: dark) {
  .checklist li::before { color: var(--accent); }
}

/* ---------- Do / Don't ---------- */
.do-list, .dont-list {
  list-style: none;
  margin: 0 0 16px 0 !important;
}
.do-list li, .dont-list li {
  position: relative;
  padding-left: 30px;
  margin-bottom: 8px;
}
.do-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--accent-strong);
  font-weight: 800;
}
.dont-list li::before {
  content: '✗';
  position: absolute;
  left: 0;
  color: var(--danger);
  font-weight: 800;
}

/* ---------- Footer ---------- */
.app-footer {
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  padding: 28px 20px 40px;
}
.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.6;
}
.footer-inner p { margin-bottom: 8px; }
.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  margin: 0 4px;
}
.footer-links a:hover { color: var(--accent-strong); }
.footer-copy { font-size: 0.78rem; opacity: 0.8; }

/* ---------- 404 ---------- */
.page-404 {
  text-align: center;
  padding-top: 4em;
}
.page-404 h1 {
  font-family: var(--font-display);
  font-size: 4.5rem;
  color: var(--accent);
}
.page-404 a { color: var(--accent-strong); }

/* ---------- Focus & reduced motion ---------- */
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
  border-radius: 4px;
}

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

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .mobile-menu-btn { display: flex; }
  .sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: 300px;
    z-index: 950;
    background: var(--bg);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.25s ease-out;
    box-shadow: var(--shadow-card-hover);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .main-content { padding: 28px 20px 48px; }
  .home-hero { padding: 36px 26px; }
  .home-hero h1 { font-size: 1.9rem; }
  .header-search { max-width: none; }
  .logo-text { font-size: 1.2rem; }
}

@media (max-width: 600px) {
  body { font-size: 16.5px; }
  .home-grid { grid-template-columns: 1fr; }
  .content-article h1 { font-size: 1.7rem; }
  .home-hero h1 { font-size: 1.6rem; }
  .stats-row .stat-card { flex: 1 1 40%; }
}
