/* ============================================
   Niemiecki - design system
   Paleta "Niemiecki z klasa":
   krem papieru slownika + grafit + zloto (osiagniecia) + czerwień (energia CTA)
   Typografia: Lora (display) + Hanken Grotesk (body)
   ============================================ */

:root {
  /* Light */
  --bg: #f6f2e9;
  --bg-alt: #efe8d9;
  --panel: #ffffff;
  --text: #232220;
  --text-secondary: #55534c;
  --accent: #9a3b2e;
  --accent-gold: #8a6d1f;
  --accent-light: #f3e7d5;
  --accent-subtle: #f0dfc8;
  --border: #e0d9c8;
  --border-light: #ece6d8;
  --sidebar-bg: #fbf8f1;
  --header-bg: rgba(246, 242, 233, 0.92);
  --shadow: 0 1px 3px rgba(35, 34, 32, 0.06), 0 4px 14px rgba(35, 34, 32, 0.05);
  --shadow-card: 0 1px 2px rgba(35, 34, 32, 0.05), 0 6px 18px rgba(35, 34, 32, 0.06);
  --font-display: 'Lora', Georgia, 'Times New Roman', serif;
  --font-body: 'Hanken Grotesk', -apple-system, 'Segoe UI', sans-serif;
  --header-height: 60px;
  --sidebar-width: 300px;
  --accent-gradient: linear-gradient(135deg, #9a3b2e, #c1553a);
  --gold-gradient: linear-gradient(90deg, transparent, rgba(138, 109, 31, 0.5), transparent);
  --radius: 12px;
  --transition: all .2s ease-out;
  --glow-1: radial-gradient(600px 400px at 85% -10%, rgba(192, 85, 58, 0.10), transparent 70%);
  --glow-2: radial-gradient(500px 380px at 0% 110%, rgba(138, 109, 31, 0.12), transparent 70%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171b;
    --bg-alt: #1b1d22;
    --panel: #1f2127;
    --text: #e9e6dd;
    --text-secondary: #b8b4a8;
    --accent: #e07161;
    --accent-gold: #e0b64d;
    --accent-light: #2c2622;
    --accent-subtle: #33281f;
    --border: #2c2e36;
    --border-light: #26282f;
    --sidebar-bg: #1a1c21;
    --header-bg: rgba(22, 23, 27, 0.92);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.35);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.4);
    --accent-gradient: linear-gradient(135deg, #e07161, #e0b64d);
    --gold-gradient: linear-gradient(90deg, transparent, rgba(224, 182, 77, 0.45), transparent);
    --glow-1: radial-gradient(600px 400px at 85% -10%, rgba(224, 113, 97, 0.08), transparent 70%);
    --glow-2: radial-gradient(500px 380px at 0% 110%, rgba(224, 182, 77, 0.07), transparent 70%);
  }
}

/* --- Reset & base --- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: clip; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  background-image: var(--glow-1), var(--glow-2);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
::selection { background: var(--accent-subtle); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Skip link */
.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff;
  padding: 10px 16px; z-index: 300; border-radius: 0 0 8px 0;
  font-weight: 600;
}
.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(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.app-header::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--gold-gradient);
  opacity: .9;
  pointer-events: none;
}
.mobile-menu-btn {
  display: none;
  background: none; border: 1px solid var(--border);
  border-radius: 8px; width: 40px; height: 40px;
  font-size: 1.2rem; color: var(--text); cursor: pointer;
  transition: var(--transition);
}
.mobile-menu-btn:hover { background: var(--accent-light); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-dots { display: inline-flex; gap: 3px; }
.brand-dots i {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--text); display: block;
}
.brand-dots i:nth-child(2) { background: var(--accent); }
.brand-dots i:nth-child(3) { background: var(--accent-gold); }
.brand-name {
  font-family: var(--font-display);
  font-size: 1.15rem; font-weight: 600; letter-spacing: -.01em;
  white-space: nowrap;
}
.brand-name a { color: var(--text); }
.brand-accent { color: var(--accent); }
.header-search { position: relative; margin-left: auto; width: 300px; }
.header-search .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: .85rem; opacity: .6; pointer-events: none;
}
.header-search input {
  width: 100%; height: 38px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel); color: var(--text);
  padding: 0 12px 0 34px; font-size: .9rem; font-family: var(--font-body);
  transition: var(--transition);
}
.header-search input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
#search-results {
  display: none;
  position: absolute; top: calc(100% + 8px); right: 0; left: 0;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-card);
  overflow: hidden; z-index: 200;
  max-height: 420px; overflow-y: auto;
}
.search-result {
  display: flex; padding: 10px 14px; gap: 10px; align-items: flex-start;
  border-bottom: 1px solid var(--border-light);
  color: var(--text); text-decoration: none; font-size: .875rem;
  transition: background .15s ease-out;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--accent-light); text-decoration: none; }
.search-result strong { display: block; font-weight: 600; line-height: 1.35; }
.search-result span:last-child {
  display: block; font-size: .8rem; color: var(--text-secondary); line-height: 1.35;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed; top: var(--header-height); bottom: 0; left: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto; overflow-x: hidden;
  padding: 14px 10px 40px;
  z-index: 90;
}
.sidebar-nav { list-style: none; margin: 0; padding: 0; }
.sidebar-nav li { margin: 1px 0; }
.sidebar-nav a {
  display: block; padding: 5px 10px;
  font-size: .9rem; line-height: 1.35; color: var(--text);
  border-radius: 8px; text-decoration: none;
  transition: var(--transition);
  border-left: 2px solid transparent;
}
.sidebar-nav a:hover {
  background: var(--accent-light);
  color: var(--accent);
  text-decoration: none;
}
.sidebar-nav a.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
  border-left-color: var(--accent);
}
.nav-section {
  font-size: .7rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-secondary);
  padding: 16px 10px 4px;
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5); z-index: 85;
}
.sidebar-overlay.show { display: block; }

/* --- Main --- */
.main-content {
  margin-left: var(--sidebar-width);
  padding: calc(var(--header-height) + 28px) 28px 80px;
  max-width: 940px;
}
.loading { display: flex; justify-content: center; padding: 80px 0; }
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Home hero --- */
.home-hero {
  position: relative;
  border-radius: var(--radius);
  padding: 44px 40px 38px;
  margin-bottom: 34px;
  background: linear-gradient(135deg, var(--panel), var(--bg-alt));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.home-hero::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-gold), var(--accent));
}
.hero-kicker {
  font-size: .78rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent-gold);
  margin: 0 0 8px;
}
.home-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  line-height: 1.15; margin: 0 0 12px; text-wrap: balance;
}
.home-hero p.hero-lead {
  font-size: 1.05rem; color: var(--text-secondary);
  max-width: 620px; margin: 0 0 22px; text-wrap: balance;
}
.stats-row { display: flex; flex-wrap: wrap; gap: 12px; }
.stat-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 18px; text-align: center;
  min-width: 110px;
}
.stat-card .num {
  display: block; font-family: var(--font-display);
  font-size: 1.5rem; font-weight: 700; color: var(--accent);
  line-height: 1.2;
}
.stat-card .label {
  display: block; font-size: .75rem; color: var(--text-secondary);
  letter-spacing: .02em;
}

/* --- Home sections & cards --- */
.home-section-label {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display);
  font-size: 1.25rem; font-weight: 600;
  margin: 34px 0 14px; text-wrap: balance;
}
.accent-bar {
  width: 22px; height: 4px; border-radius: 2px;
  background: var(--accent-gradient);
  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(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 18px 16px;
  color: var(--text); text-decoration: none;
  transition: var(--transition);
  position: relative;
}
.home-card::after {
  content: '';
  position: absolute; left: 18px; right: 18px; bottom: 0;
  height: 2px; background: var(--accent-gradient);
  transform: scaleX(0); transform-origin: left;
  transition: transform .25s ease-out;
}
.home-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
  text-decoration: none;
}
.home-card:hover::after { transform: scaleX(1); }
.card-icon { font-size: 1.5rem; line-height: 1; }
.home-card h3 {
  font-size: .95rem; font-weight: 600; line-height: 1.35;
  margin: 0; text-wrap: balance;
  font-family: var(--font-body);
}
.home-card p {
  font-size: .85rem; line-height: 1.5; color: var(--text-secondary);
  margin: 0;
}

/* --- Article --- */
.content-article { animation: fadeUp .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: clamp(1.7rem, 3.6vw, 2.3rem);
  line-height: 1.2; margin: 0 0 6px; text-wrap: balance;
}
.article-meta {
  color: var(--text-secondary); font-size: .9rem;
  margin-bottom: 8px;
}
.article-toc {
  background: var(--panel); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 16px 20px; margin: 22px 0 26px;
  scroll-margin-top: calc(var(--header-height) + 16px);
}
.article-toc h3 { margin: 0 0 8px; font-size: .9rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); }
.article-toc a {
  display: block; padding: 3px 0; color: var(--text);
  font-size: .9rem; line-height: 1.45;
}
.article-toc a:hover { color: var(--accent); }
.article-toc a.toc-h3 { padding-left: 16px; font-size: .85rem; color: var(--text-secondary); }
.content-article h2 {
  font-family: var(--font-display);
  font-size: 1.4rem; margin: 34px 0 10px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
  scroll-margin-top: calc(var(--header-height) + 16px);
  text-wrap: balance;
}
.content-article h3 {
  font-family: var(--font-display);
  font-size: 1.1rem; margin: 24px 0 8px;
  scroll-margin-top: calc(var(--header-height) + 16px);
  text-wrap: balance;
}
.content-article p { margin: 0 0 14px; }
.content-article ul, .content-article ol { margin: 0 0 16px; padding-left: 22px; }
.content-article li { margin-bottom: 6px; }
.content-article strong { font-weight: 650; }
.content-article em { font-style: italic; }
.content-article blockquote {
  margin: 18px 0; padding: 14px 18px;
  border-left: 3px solid var(--accent-gold);
  background: var(--accent-light); border-radius: 0 10px 10px 0;
  color: var(--text); font-style: italic;
}

/* --- Info box --- */
.info-box {
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-gold);
  border-radius: 10px;
  padding: 14px 18px; margin: 18px 0;
  font-size: .95rem; line-height: 1.6;
}
.info-box strong { color: var(--accent-gold); }

/* --- Tables --- */
.table-responsive { overflow-x: auto; margin: 18px 0; border-radius: 10px; }
table.error-table {
  width: 100%; border-collapse: collapse;
  font-size: .9rem; line-height: 1.5;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
}
.error-table th {
  background: var(--bg-alt); color: var(--text);
  font-weight: 700; text-align: left;
  padding: 10px 14px; border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.error-table td {
  padding: 10px 14px; border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}
.error-table tr:last-child td { border-bottom: none; }
.error-table tr:hover td { background: var(--bg-alt); }

/* --- FAQ --- */
.faq-item {
  border: 1px solid var(--border);
  border-radius: 10px; margin: 10px 0;
  background: var(--panel);
  overflow: hidden;
}
.faq-item summary {
  cursor: pointer; padding: 13px 16px;
  font-weight: 600; font-size: .95rem; line-height: 1.4;
  list-style: none; position: relative;
  padding-right: 40px;
  transition: var(--transition);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+'; position: absolute; right: 16px; top: 50%;
  transform: translateY(-50%);
  color: var(--accent); font-size: 1.2rem; font-weight: 700;
  transition: transform .2s ease-out;
}
.faq-item[open] summary::after { transform: translateY(-50%) rotate(45deg); }
.faq-item summary:hover { background: var(--accent-light); }
.faq-item .faq-a { padding: 0 16px 14px; font-size: .93rem; line-height: 1.65; }

/* --- Glossary --- */
.glossary { margin: 18px 0; }
.glossary dt {
  font-weight: 700; font-size: .95rem;
  margin-top: 14px; color: var(--accent);
}
.glossary dd { margin: 2px 0 0; font-size: .92rem; color: var(--text-secondary); }

/* --- Prev/next --- */
.article-nav {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 36px; padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: .9rem;
}
.article-nav a { color: var(--text); display: block; max-width: 46%; }
.article-nav a:hover { color: var(--accent); }
.article-nav .nav-label { display: block; font-size: .75rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .06em; }

/* --- Footer note --- */
.content-foot {
  margin-top: 40px; padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: .8rem; color: var(--text-secondary);
}

/* --- 404 --- */
.page-404 { text-align: center; padding-top: 60px; }
.page-404 .code {
  font-family: var(--font-display); font-size: 4.5rem; font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin: 0;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .mobile-menu-btn { display: block; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease-out;
    box-shadow: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-card); }
  .main-content { margin-left: 0; padding: calc(var(--header-height) + 18px) 16px 60px; }
  .header-search { width: auto; flex: 1; max-width: 320px; }
  .home-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .home-grid { grid-template-columns: 1fr; }
  .home-hero { padding: 30px 22px 26px; }
  .brand-name { font-size: 1rem; }
  .stats-row { gap: 8px; }
  .stat-card { min-width: 92px; padding: 8px 12px; }
}

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