/* ============================================
   ELEKTRYKA PROSTO - design system v1
   Palette: amber (energy) + graphite (installations)
   Fonts: Space Grotesk (display) + Manrope (body)
   ============================================ */

:root {
  /* Light theme */
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f0ede5;
  --text: #1c2126;
  --text-secondary: #4b555d;
  --muted: #5c666e;
  --accent: #b45309;
  --accent-hover: #9a3412;
  --accent-soft: #fef3c7;
  --accent-subtle: #fde68a;
  --info: #0e7490;
  --info-bg: #ecfeff;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --border: #e5e0d6;
  --border-strong: #d6d0c2;
  --header-bg: rgba(247, 245, 240, 0.92);
  --sidebar-bg: #f1eee7;
  --shadow-card: 0 1px 3px rgba(28, 33, 38, 0.05), 0 4px 14px rgba(28, 33, 38, 0.05);
  --shadow-card-hover: 0 2px 6px rgba(28, 33, 38, 0.07), 0 10px 26px rgba(180, 83, 9, 0.10);
  --glow: rgba(245, 158, 11, 0.35);

  /* Typography */
  --font-heading: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Manrope', 'Segoe UI', system-ui, sans-serif;
  --base-size: 17px;
  --line-height: 1.7;
  --radius: 12px;
  --radius-sm: 8px;
  --header-height: 60px;
  --sidebar-width: 300px;
  --transition: all .2s ease-out;
  --accent-gradient: linear-gradient(135deg, #b45309, #d97706);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161b;
    --surface: #1a2027;
    --surface-2: #1e252d;
    --text: #e8e6e1;
    --text-secondary: #c3c9cf;
    --muted: #9aa4ad;
    --accent: #f59e0b;
    --accent-hover: #fbbf24;
    --accent-soft: #3b2f14;
    --accent-subtle: #4a3a18;
    --info: #38bdf8;
    --info-bg: #0e2230;
    --danger: #f87171;
    --danger-bg: #341519;
    --ok: #4ade80;
    --ok-bg: #12261a;
    --border: #2a323b;
    --border-strong: #3a444e;
    --header-bg: rgba(18, 22, 27, 0.92);
    --sidebar-bg: #171c22;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
    --shadow-card-hover: 0 2px 6px rgba(0, 0, 0, 0.35), 0 10px 26px rgba(245, 158, 11, 0.08);
    --glow: rgba(245, 158, 11, 0.16);
    --accent-gradient: linear-gradient(135deg, #f59e0b, #fbbf24);
  }
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: var(--base-size);
  line-height: var(--line-height);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 900px 500px at 100% 0%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 60%),
    radial-gradient(ellipse 800px 500px at 0% 100%, color-mix(in srgb, var(--info) 5%, transparent), transparent 60%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

h1, h2, h3, h4 { font-family: var(--font-heading); line-height: 1.25; text-wrap: balance; }

::selection { background: var(--accent-subtle); color: var(--text); }

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

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

.logo-mark {
  font-size: 1.4rem;
  line-height: 1;
  filter: drop-shadow(0 0 6px var(--glow));
  animation: glowPulse 4s ease-in-out infinite;
}
@keyframes glowPulse {
  0%, 100% { filter: drop-shadow(0 0 3px var(--glow)); }
  50% { filter: drop-shadow(0 0 10px var(--glow)); }
}

.brand-name { font-family: var(--font-heading); font-weight: 700; font-size: 1.1rem; letter-spacing: -.01em; white-space: nowrap; }
.brand-name a { color: var(--text); }
.brand-name a:hover { color: var(--accent); }
.brand-name em { font-style: normal; color: var(--accent); }

.header-search {
  position: relative;
  margin-left: auto;
  width: min(360px, 40vw);
}
.header-search .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: .85rem; opacity: .55; }
.header-search input {
  width: 100%;
  padding: 9px 14px 9px 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .875rem;
  transition: var(--transition);
}
.header-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

#search-results {
  display: none;
  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: 0 12px 32px rgba(0,0,0,.14);
  overflow: hidden;
  z-index: 200;
  max-height: 420px;
  overflow-y: auto;
}
#search-results a { font-family: var(--font-body); }

/* ---------- Mobile menu button ---------- */
.mobile-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 40px; height: 40px;
  font-size: 1.1rem;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
}
.mobile-menu-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  overflow-y: auto;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 18px 12px 40px;
  z-index: 90;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.sidebar-nav { list-style: none; }

.sidebar-nav li.nav-section {
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 18px 10px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-nav li.nav-section::before {
  content: '';
  width: 14px; height: 2px;
  background: var(--accent);
  border-radius: 2px;
  opacity: .7;
}
.sidebar-nav li:first-child { padding-top: 0; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6.5px 10px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  transition: var(--transition);
  line-height: 1.35;
}
.sidebar-nav a:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  transform: translateX(2px);
}
.sidebar-nav a.active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-left-color: var(--accent);
  font-weight: 700;
}

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

/* ---------- Main content ---------- */
.main-content {
  margin-left: var(--sidebar-width);
  padding: calc(var(--header-height) + 28px) 32px 80px;
  max-width: 980px;
  min-height: 100vh;
}

.content-article { animation: fadeUp .28s ease-out both; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Hero (home) ---------- */
.home-hero {
  position: relative;
  border-radius: var(--radius);
  padding: 44px 40px 38px;
  margin-bottom: 40px;
  background:
    radial-gradient(circle at 85% 20%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 42%),
    linear-gradient(135deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  overflow: hidden;
}
/* circuit dot-grid pattern */
.home-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, color-mix(in srgb, var(--accent) 26%, transparent) 1.5px, transparent 1.6px),
    radial-gradient(circle, color-mix(in srgb, var(--info) 18%, transparent) 1.5px, transparent 1.6px);
  background-size: 26px 26px, 26px 26px;
  background-position: 0 0, 13px 13px;
  opacity: .5;
  pointer-events: none;
  mask-image: linear-gradient(120deg, transparent 20%, #000 100%);
  -webkit-mask-image: linear-gradient(120deg, transparent 20%, #000 100%);
}
.home-hero > * { position: relative; }

.hero-icon { font-size: 2.4rem; margin-bottom: 10px; filter: drop-shadow(0 2px 10px var(--glow)); }

.home-hero h1 {
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: 10px;
  color: var(--text);
}
.home-hero h1 em { font-style: normal; color: var(--accent); }

.home-hero .hero-sub {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 620px;
  margin-bottom: 22px;
}

/* current-line signature */
.current-line {
  width: 130px;
  height: 3px;
  margin: 18px 0;
  background: repeating-linear-gradient(90deg, var(--accent) 0 10px, transparent 10px 20px);
  border-radius: 3px;
  animation: currentFlow 1.4s linear infinite;
  opacity: .85;
}
@keyframes currentFlow {
  to { background-position: 20px 0; }
}

.stats-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 110px;
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-card-hover); }
.stat-card .num { font-family: var(--font-heading); font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.stat-card .label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* ---------- Home grid ---------- */
.home-section-label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.15rem;
  font-weight: 700;
  margin: 38px 0 16px;
  color: var(--text);
}
.accent-bar {
  width: 26px; height: 4px;
  background: var(--accent-gradient);
  border-radius: 4px;
  flex-shrink: 0;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.home-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  color: var(--text);
  transition: var(--transition);
  overflow: hidden;
}
.home-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent-gradient);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .25s ease-out;
}
.home-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card-hover);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  color: var(--text);
}
.home-card:hover::before { transform: scaleX(1); }

.card-icon { font-size: 1.35rem; line-height: 1; }
.home-card h3 {
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.35;
}
.home-card p {
  font-size: .85rem;
  color: var(--muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Article ---------- */
.content-article h1 {
  font-size: clamp(1.7rem, 3.4vw, 2.3rem);
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: 8px;
}

.article-meta {
  color: var(--muted);
  font-size: .95rem;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.content-article h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 34px 0 12px;
  padding-top: 6px;
  letter-spacing: -.01em;
}
.content-article h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 24px 0 10px;
}

.content-article p { margin: 0 0 14px; color: var(--text); }
.content-article ul, .content-article ol { margin: 0 0 16px; padding-left: 24px; }
.content-article li { margin-bottom: 7px; }
.content-article li::marker { color: var(--accent); }
.content-article strong { font-weight: 700; }
.content-article a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.content-article a:hover { text-decoration-color: var(--accent); }

/* ---------- TOC ---------- */
.article-toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin: 18px 0 26px;
}
.article-toc h3 {
  font-family: var(--font-heading);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: 10px;
}
.article-toc a {
  display: block;
  padding: 4px 0;
  font-size: .9rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
}
.article-toc a:hover { color: var(--accent); transform: translateX(3px); }
.article-toc a.toc-h3 { padding-left: 16px; font-size: .85rem; }

/* ---------- Info boxes ---------- */
.info-box {
  background: var(--info-bg);
  border: 1px solid color-mix(in srgb, var(--info) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 16px 0;
  font-size: .95rem;
  color: var(--text);
}
.info-box::before { content: 'ℹ️ '; }

.warning-box {
  background: var(--danger-bg);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 16px 0;
  font-size: .95rem;
  color: var(--text);
}
.warning-box::before { content: '⚠️ '; }

.tip-box {
  background: var(--ok-bg);
  border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 16px 0;
  font-size: .95rem;
}
.tip-box::before { content: '💡 '; }

/* ---------- Tables ---------- */
.table-responsive { overflow-x: auto; margin: 16px 0; border-radius: var(--radius-sm); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
th {
  font-family: var(--font-heading);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  text-align: left;
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 14px;
  border-bottom: 2px solid var(--border-strong);
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }

.error-table td:first-child {
  font-weight: 700;
  color: var(--danger);
  white-space: nowrap;
}

/* ---------- FAQ ---------- */
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 12px;
  overflow: hidden;
  transition: var(--transition);
}
.faq-item:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.faq-item summary {
  cursor: pointer;
  padding: 14px 18px;
  font-weight: 700;
  font-size: .98rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before {
  content: '+';
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: var(--accent);
  flex-shrink: 0;
  transition: transform .2s ease-out;
}
.faq-item[open] summary::before { transform: rotate(45deg); }
.faq-item summary:hover { color: var(--accent); }
.faq-item .faq-answer { padding: 0 18px 16px 44px; font-size: .95rem; color: var(--text-secondary); }

/* ---------- Glossary ---------- */
.glossary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 16px 0;
}
.glossary dt {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--accent);
  margin-top: 14px;
  font-size: 1rem;
}
.glossary dt:first-child { margin-top: 0; }
.glossary dd { margin: 3px 0 0; padding-bottom: 12px; border-bottom: 1px dashed var(--border); color: var(--text-secondary); font-size: .93rem; }
.glossary dd:last-child { border-bottom: none; }

/* ---------- Checklist ---------- */
.checklist { list-style: none !important; padding-left: 0 !important; }
.checklist li {
  padding-left: 30px;
  position: relative;
}
.checklist li::before {
  content: '✓';
  position: absolute;
  left: 2px;
  color: var(--ok);
  font-weight: 700;
}

/* ---------- Loading ---------- */
.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); } }

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 300;
}
.skip-link:focus { left: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .mobile-menu-btn { display: block; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease-out;
    width: min(320px, 85vw);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; padding: calc(var(--header-height) + 20px) 18px 60px; }
  .header-search { width: 180px; }
}

@media (max-width: 600px) {
  .header-search { width: 120px; }
  .header-search input { padding: 8px 10px 8px 30px; font-size: .82rem; }
  .home-hero { padding: 30px 22px 28px; }
  .home-grid { grid-template-columns: 1fr; }
  .stat-card { min-width: 90px; padding: 10px 14px; }
  .brand-name { font-size: 1rem; }
}

/* ---------- 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; }
}
