/* ============================================================
   Motoryzacja - design system
   Paleta: asfalt (grafit) + bursztyn sygnalowy + stal + krem
   Typografia: Barlow Condensed (display) + Barlow (body) + JetBrains Mono
   Signature: licznik (gauge) w hero + linie drogowe jako separatory
   ============================================================ */

:root {
  /* Asphalt palette - light */
  --ink: #1c2128;
  --panel: #232a33;
  --bg: #f5f4f0;
  --bg-soft: #fcfbf8;
  --card-bg: #ffffff;
  --accent: #d97706;
  --accent-strong: #b45309;
  --accent-soft: #fdf1df;
  --steel: #475569;
  --muted: #5b6b7f;
  --border: #e3e0d8;
  --link: #b45309;
  --code-bg: #efede6;

  /* Typography */
  --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-body: "Barlow", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  /* Geometry */
  --radius: 14px;
  --radius-sm: 8px;
  --header-h: 64px;
  --sidebar-w: 300px;
  --transition: all .2s ease-out;
  --shadow-card: 0 1px 3px rgba(28, 33, 40, .08), 0 4px 14px rgba(28, 33, 40, .06);
  --shadow-card-hover: 0 2px 6px rgba(28, 33, 40, .1), 0 10px 26px rgba(28, 33, 40, .12);

  /* Body gradient - subtle amber + steel ellipses */
  --body-grad:
    radial-gradient(ellipse 600px 400px at 88% -5%, rgba(217, 119, 6, .10), transparent 60%),
    radial-gradient(ellipse 700px 500px at -10% 105%, rgba(71, 85, 105, .10), transparent 60%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8e6e1;
    --panel: #151a20;
    --bg: #101418;
    --bg-soft: #151a20;
    --card-bg: #1a2027;
    --accent: #f59e0b;
    --accent-strong: #fbbf24;
    --accent-soft: #2a2110;
    --steel: #94a3b8;
    --muted: #94a3b8;
    --border: #262d36;
    --link: #fbbf24;
    --code-bg: #1c222b;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, .35);
    --shadow-card-hover: 0 8px 24px rgba(0, 0, 0, .45);
    --body-grad:
      radial-gradient(ellipse 600px 400px at 88% -5%, rgba(245, 158, 11, .08), transparent 60%),
      radial-gradient(ellipse 700px 500px at -10% 105%, rgba(148, 163, 184, .06), transparent 60%);
  }
}

* { 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(--ink);
  background: var(--bg);
  background-image: var(--body-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

p { margin: 0 0 1.1em; text-wrap: pretty; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
strong { font-weight: 700; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: .01em;
  text-wrap: balance;
  margin: 0 0 .5em;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 1000;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: .02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--ink), var(--panel));
  color: var(--accent);
  box-shadow: 0 2px 10px rgba(217, 119, 6, .3), inset 0 0 0 1px rgba(245, 158, 11, .35);
}
.brand-name em { font-style: normal; color: var(--accent); }

.menu-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.menu-btn span {
  display: block;
  height: 2px;
  background: var(--ink);
  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); }

/* ---------- Search ---------- */
.search-wrap { position: relative; flex: 1; max-width: 420px; margin-left: auto; }
.search-input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l3 3'/%3E%3C/svg%3E") no-repeat 13px center;
  font-family: var(--font-body);
  font-size: .95rem;
  color: var(--ink);
  outline: none;
  transition: var(--transition);
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217, 119, 6, .15); }
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card-hover);
  max-height: 360px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: var(--transition);
  z-index: 50;
}
.search-results.open { opacity: 1; visibility: visible; transform: translateY(0); }
.search-item {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--accent-soft); text-decoration: none; }
.si-title { font-weight: 600; font-size: .92rem; }
.si-section { font-size: .75rem; color: var(--muted); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .05em; }
.search-empty { padding: 12px 14px; color: var(--muted); font-size: .9rem; }

.header-tagline {
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
}

/* ---------- Layout ---------- */
.layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: calc(var(--header-h) + 24px) 20px 40px;
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 20px);
  width: var(--sidebar-w);
  flex-shrink: 0;
  max-height: calc(100vh - var(--header-h) - 40px);
  overflow-y: auto;
  padding: 8px 16px 16px 0;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 18px; }
.side-group-title {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding-left: 10px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: .9rem;
  line-height: 1.4;
  transition: var(--transition);
}
.sidebar-link:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
  text-decoration: none;
  transform: translateX(2px);
}
.sidebar-link.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-link .s-icon { font-size: .95rem; flex-shrink: 0; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 90;
}
.sidebar-overlay.show { display: block; }

.main-content { flex: 1; min-width: 0; }
.app-content { max-width: 860px; }

/* ---------- Hero (home) - asphalt + gauge ---------- */
.home-hero {
  position: relative;
  border-radius: var(--radius);
  padding: 48px 48px 56px;
  margin-bottom: 40px;
  color: #fff;
  background:
    linear-gradient(100deg, rgba(28, 33, 40, .98) 0%, rgba(35, 42, 51, .94) 45%, rgba(46, 56, 68, .82) 75%, rgba(60, 70, 82, .6) 100%),
    linear-gradient(135deg, #1c2128 0%, #232a33 55%, #2e3844 100%);
  box-shadow: var(--shadow-card-hover);
  overflow: hidden;
}
.home-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse 720px 420px at 78% 30%, #000 30%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 720px 420px at 78% 30%, #000 30%, transparent 70%);
  pointer-events: none;
}
/* Road line under hero - signature */
.home-hero::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 6px;
  background: repeating-linear-gradient(90deg, var(--accent) 0 46px, transparent 46px 92px);
  opacity: .85;
  border-radius: 0 0 var(--radius) var(--radius);
  pointer-events: none;
}
.hero-inner { position: relative; z-index: 1; max-width: 620px; }
.hero-eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #fbbf24;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 999px;
  padding: 5px 13px;
  margin-bottom: 18px;
}
.home-hero h1 {
  font-size: clamp(2rem, 4vw, 3.1rem);
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 12px;
  letter-spacing: .01em;
}
.home-hero h1 em { font-style: normal; color: #fbbf24; }
.hero-sub { font-size: 1.05rem; color: rgba(255, 255, 255, .88); margin-bottom: 24px; max-width: 540px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 30px; }

.btn {
  display: inline-block;
  padding: 11px 22px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  transition: var(--transition);
  cursor: pointer;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn-primary {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #1c2128;
  box-shadow: 0 4px 14px rgba(217, 119, 6, .45);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(217, 119, 6, .55); }
.btn-ghost {
  border: 1px solid rgba(255, 255, 255, .4);
  color: #fff;
  background: rgba(255, 255, 255, .06);
}
.btn-ghost:hover { background: rgba(255, 255, 255, .14); }

/* Dark mode: burnt-amber button with white text (WCAG AA) */
@media (prefers-color-scheme: dark) {
  .btn-primary {
    background: linear-gradient(135deg, #c2410c, #b45309);
    color: #fff;
  }
}

.hero-stats { display: flex; gap: 28px; flex-wrap: wrap; }
.hero-stat .hs-num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.9rem;
  color: #fbbf24;
  line-height: 1.1;
}
.hero-stat .hs-label { font-size: .82rem; color: rgba(255, 255, 255, .75); }

/* Gauge (licznik) - signature SVG */
.hero-gauge {
  position: absolute;
  right: -30px;
  top: 50%;
  transform: translateY(-50%);
  width: 300px;
  height: 300px;
  opacity: .92;
  z-index: 0;
  pointer-events: none;
}
.hero-gauge .gauge-arc { fill: none; stroke: rgba(255, 255, 255, .12); stroke-width: 10; }
.hero-gauge .gauge-arc-accent { fill: none; stroke: #f59e0b; stroke-width: 10; stroke-linecap: round; }
.hero-gauge .gauge-needle {
  stroke: #fbbf24;
  stroke-width: 4;
  stroke-linecap: round;
  transform-origin: 90px 160px;
  animation: needle-settle 1.2s cubic-bezier(.34, 1.4, .5, 1) both;
}
.hero-gauge .gauge-hub { fill: #fbbf24; }
.hero-gauge .gauge-tick { stroke: rgba(255, 255, 255, .25); stroke-width: 2; }
@keyframes needle-settle {
  from { transform: rotate(-70deg); }
  to { transform: rotate(0deg); }
}
@media (prefers-reduced-motion: reduce) {
  .hero-gauge .gauge-needle { animation: none; }
}

/* ---------- Home sections ---------- */
.home-section { margin-bottom: 44px; }
.home-section h2 {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 1.65rem;
  text-transform: uppercase;
  letter-spacing: .02em;
  padding-bottom: 10px;
  border-bottom: 3px dashed var(--border);
  margin-bottom: 6px;
}
.home-section h2 .sec-count {
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--accent);
  font-weight: 600;
}
.sec-desc { color: var(--muted); font-size: .95rem; margin: 0 0 18px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
.home-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 18px 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  color: var(--ink);
  transition: var(--transition);
  position: relative;
}
.home-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(217, 119, 6, .45);
}
.hc-icon { font-size: 1.3rem; line-height: 1; }
.home-card h3 {
  font-size: .9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
  margin: 0;
}
.home-card p { font-size: .85rem; color: var(--muted); margin: 0; line-height: 1.55; }
.hc-more {
  margin-top: auto;
  padding-top: 8px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--accent-strong);
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.hc-more .arrow {
  display: inline-block;
  transition: var(--transition);
}
.home-card:hover .hc-more .arrow { transform: translateX(4px); }

/* ---------- Article ---------- */
.article-header { margin-bottom: 24px; }
.breadcrumbs {
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: 10px;
}
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--accent-strong); }
.breadcrumbs .sep { margin: 0 6px; color: var(--border); }
.article-header h1 {
  font-size: clamp(1.9rem, 3.4vw, 2.6rem);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .01em;
  margin-bottom: 10px;
}
.article-excerpt {
  font-size: 1.06rem;
  color: var(--steel);
  max-width: 640px;
}
.article-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 14px;
  font-size: .82rem;
  color: var(--muted);
}
.article-meta .tag {
  font-family: var(--font-mono);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid rgba(217, 119, 6, .3);
  border-radius: 999px;
  padding: 3px 10px;
}

.article-body {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 36px;
  box-shadow: var(--shadow-card);
}
.article-body h2 {
  font-size: 1.45rem;
  text-transform: uppercase;
  letter-spacing: .02em;
  margin: 1.5em 0 .5em;
  padding-top: 14px;
  border-top: 3px dashed var(--border);
}
.article-body h2:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.article-body h3 { font-size: 1.15rem; text-transform: uppercase; letter-spacing: .02em; margin: 1.3em 0 .4em; }
.article-body ul, .article-body ol { margin: 0 0 1.1em; padding-left: 1.4em; }
.article-body li { margin-bottom: .35em; }
.article-body code {
  font-family: var(--font-mono);
  font-size: .85em;
  background: var(--code-bg);
  border-radius: 5px;
  padding: 2px 6px;
}

/* Article TOC */
.article-toc {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 26px;
}
.article-toc summary {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  cursor: pointer;
  color: var(--accent-strong);
}
.article-toc ol { margin: 10px 0 0; padding-left: 1.3em; }
.article-toc li { margin-bottom: 5px; font-size: .92rem; }

/* Info box */
.info-box {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px;
  margin: 1.2em 0;
}
.info-box p { margin: 0; }
.info-box strong { color: var(--accent-strong); }

/* Warning box */
.warn-box {
  background: #fef2f2;
  border-left: 4px solid #dc2626;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px;
  margin: 1.2em 0;
  color: #7f1d1d;
}
@media (prefers-color-scheme: dark) {
  .warn-box { background: #2a1515; color: #fca5a5; }
}

/* Tables */
.table-responsive { overflow-x: auto; margin: 1.2em 0; }
table.error-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
  background: var(--card-bg);
}
.error-table th, .error-table td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
.error-table th {
  background: var(--panel);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: .88rem;
}
.error-table tr:nth-child(even) td { background: var(--bg); }
.error-table td:first-child { font-weight: 600; white-space: nowrap; }

/* FAQ */
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 12px;
  background: var(--bg-soft);
}
.faq-item h3 { margin: 0 0 8px; font-size: 1.05rem; }
.faq-item p { margin: 0; color: var(--steel); }

/* Glossary */
.glossary dl { margin: 0; }
.glossary dt {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: .02em;
  margin-top: 18px;
  color: var(--accent-strong);
}
.glossary dd { margin: 4px 0 0; color: var(--steel); }

/* Article prev/next nav */
.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 3px dashed var(--border);
}
.article-nav a {
  flex: 1;
  max-width: 48%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--ink);
  transition: var(--transition);
}
.article-nav a:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.article-nav a.next { text-align: right; }
.an-label {
  font-family: var(--font-mono);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
.an-title { font-weight: 600; font-size: .92rem; }

/* ---------- Footer ---------- */
.app-footer {
  border-top: 3px dashed var(--border);
  margin-top: 20px;
}
.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 26px 20px 34px;
}
.footer-inner p { font-size: .88rem; color: var(--muted); max-width: 860px; }
.footer-note { font-size: .8rem !important; opacity: .85; }
.footer-copy { font-family: var(--font-mono); font-size: .75rem !important; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .hero-gauge { width: 230px; height: 230px; right: -40px; }
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: min(320px, 85vw);
    background: var(--bg-soft);
    border-right: 1px solid var(--border);
    padding: 16px;
    transform: translateX(-105%);
    transition: transform .25s ease-out;
    z-index: 95;
    max-height: none;
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: flex; }
  .header-tagline { display: none; }
  .home-hero { padding: 36px 28px 48px; }
  .hero-gauge { display: none; }
  .article-body { padding: 24px 20px; }
}
@media (max-width: 600px) {
  .layout { padding: calc(var(--header-h) + 16px) 14px 32px; }
  .brand-name { font-size: 1.05rem; }
  .search-wrap { max-width: none; }
  .home-hero h1 { font-size: 1.7rem; }
  .hero-stats { gap: 18px; }
  .card-grid { grid-template-columns: 1fr; }
  .article-nav { flex-direction: column; }
  .article-nav a { max-width: none; }
}

/* ---------- Animations ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.app-content > * { animation: fadeUp .25s ease-out both; }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
