/* ============================================================
   Fotowoltaika - design system
   Paleta: słońce (bursztyn) + zieleń natury + granat nieba
   Typografia: Sora (display) + Albert Sans (body) + JetBrains Mono
   ============================================================ */

:root {
  /* Solar palette - light */
  --ink: #16283f;
  --panel: #1c314e;
  --bg: #f7f4ec;
  --bg-soft: #fdfbf5;
  --card-bg: #ffffff;
  --accent: #d97706;
  --accent-strong: #b45309;
  --accent-soft: #fef3e2;
  --green: #1e7a4f;
  --green-strong: #166534;
  --green-soft: #e6f4ec;
  --gold: #f59e0b;
  --muted: #6b7280;
  --border: #e7e0d2;
  --link: #b45309;
  --code-bg: #f1ede2;

  /* Typography */
  --font-display: "Sora", system-ui, sans-serif;
  --font-body: "Albert Sans", 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(22, 40, 63, .08), 0 4px 14px rgba(22, 40, 63, .06);
  --shadow-card-hover: 0 2px 6px rgba(22, 40, 63, .1), 0 10px 26px rgba(22, 40, 63, .12);

  /* Body gradient - subtle sun + green 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(30, 122, 79, .09), transparent 60%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e6edf3;
    --panel: #1a2432;
    --bg: #0e1622;
    --bg-soft: #111b29;
    --card-bg: #16202e;
    --accent: #f59e0b;
    --accent-strong: #fbbf24;
    --accent-soft: #2a2410;
    --green: #34d399;
    --green-strong: #6ee7b7;
    --green-soft: #10271d;
    --gold: #fbbf24;
    --muted: #9aa7b4;
    --border: #243244;
    --link: #fbbf24;
    --code-bg: #1c2735;
    --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(52, 211, 153, .07), 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);
  line-height: 1.25;
  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: .3;
  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.1rem;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  font-size: 1.15rem;
  box-shadow: 0 2px 8px rgba(217, 119, 6, .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='%236b7280' 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);
}
.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) ---------- */
.home-hero {
  position: relative;
  border-radius: var(--radius);
  padding: 48px 48px 40px;
  margin-bottom: 40px;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(22, 40, 63, .96) 0%, rgba(28, 49, 78, .88) 42%, rgba(28, 49, 78, .55) 75%, rgba(34, 65, 95, .45) 100%),
    url("/assets/hero-pv.webp") center 18% / cover no-repeat,
    linear-gradient(135deg, #16283f 0%, #1c314e 55%, #22415f 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, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 700px 400px at 80% 30%, #000 30%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 700px 400px at 80% 30%, #000 30%, transparent 70%);
  pointer-events: none;
}
.hero-inner { position: relative; z-index: 1; max-width: 640px; }
.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(1.7rem, 3.4vw, 2.6rem);
  font-weight: 800;
  margin-bottom: 14px;
  letter-spacing: -.02em;
}
.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: 560px; }
.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: .95rem;
  transition: var(--transition);
  cursor: pointer;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--gold));
  color: #fff;
  box-shadow: 0 4px 14px rgba(217, 119, 6, .4);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(217, 119, 6, .5); }
.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); }

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

/* Sun signature (hero) - rotating sun rays over photo */
.hero-sun {
  position: absolute;
  top: 20px;
  right: 36px;
  width: 120px;
  height: 120px;
  opacity: .5;
  z-index: 1;
  pointer-events: none;
}
.hero-sun .sun-core {
  fill: #fbbf24;
  animation: sunPulse 4s ease-in-out infinite;
}
.hero-sun .sun-ray {
  stroke: #fbbf24;
  stroke-width: 2.5;
  stroke-linecap: round;
  opacity: .55;
  animation: sunSpin 36s linear infinite;
  transform-origin: 75px 75px;
}
@keyframes sunSpin { to { transform: rotate(360deg); } }
@keyframes sunPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .75; }
}
@media (max-width: 900px) { .hero-sun { width: 90px; height: 90px; top: 14px; right: 14px; } }
@media (max-width: 600px) { .hero-sun { display: none; } }

/* ---------- Home sections ---------- */
.home-section { margin-bottom: 44px; }
.home-section h2 {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -.01em;
  margin-bottom: 6px;
}
.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-bottom: 18px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 16px;
}
.home-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  color: var(--ink);
  transition: var(--transition);
}
.home-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--accent);
  text-decoration: none;
}
.hc-icon { font-size: 1.5rem; }
.home-card h3 { font-size: .95rem; font-weight: 700; margin: 0; }
.home-card p { font-size: .85rem; color: var(--muted); margin: 0; flex: 1; }
.hc-more {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.hc-more .arrow { transition: var(--transition); display: inline-block; }
.home-card:hover .hc-more .arrow { transform: translateX(4px); }

/* ---------- Article ---------- */
.article-header { margin-bottom: 28px; }
.breadcrumbs {
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: 14px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs .sep { color: var(--border); }
.article-header h1 {
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -.02em;
  margin-bottom: 10px;
}
.article-excerpt { font-size: 1.08rem; color: var(--muted); margin-bottom: 16px; }
.article-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  font-size: .82rem;
  color: var(--muted);
  font-family: var(--font-mono);
}
.article-meta .tag {
  background: var(--green-soft);
  color: var(--green-strong);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.article-body { font-size: 1.02rem; }
.article-body h2 {
  font-size: 1.45rem;
  font-weight: 700;
  margin-top: 2em;
  padding-top: .5em;
  border-top: 1px solid var(--border);
  letter-spacing: -.01em;
}
.article-body h3 { font-size: 1.15rem; font-weight: 700; margin-top: 1.6em; }
.article-body ul, .article-body ol { margin: 0 0 1.2em; padding-left: 1.4em; }
.article-body li { margin-bottom: .4em; }
.article-body code {
  font-family: var(--font-mono);
  font-size: .88em;
  background: var(--code-bg);
  border-radius: 4px;
  padding: 2px 6px;
}

/* TOC */
.article-toc {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 28px;
  font-size: .92rem;
}
.article-toc summary {
  font-family: var(--font-display);
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 8px;
}
.article-toc ol { margin: 0; padding-left: 1.3em; }
.article-toc li { margin-bottom: 4px; }

/* Info box */
.info-box {
  background: var(--accent-soft);
  border: 1px solid rgba(217, 119, 6, .35);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 1.4em 0;
  font-size: .95rem;
}
.info-box strong { color: var(--accent-strong); }

/* Green box (tips / savings) */
.tip-box {
  background: var(--green-soft);
  border: 1px solid rgba(30, 122, 79, .35);
  border-left: 4px solid var(--green);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 1.4em 0;
  font-size: .95rem;
}
.tip-box strong { color: var(--green-strong); }

/* Tables */
.table-responsive { overflow-x: auto; margin: 1.4em 0; }
.error-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.error-table th {
  background: var(--panel);
  color: #fff;
  text-align: left;
  padding: 10px 14px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: .88rem;
}
.error-table td {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  vertical-align: top;
}
.error-table tr:nth-child(even) td { background: var(--bg-soft); }
.error-table tr:hover td { background: var(--accent-soft); }
.error-table .num { font-family: var(--font-mono); white-space: nowrap; }

/* FAQ */
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 14px;
  background: var(--card-bg);
}
.faq-item h3 {
  font-size: 1.02rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--accent-strong);
}
.faq-item p { margin: 0; font-size: .95rem; }

/* Glossary */
.glossary-term {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.glossary-term dt {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--accent-strong);
}
.glossary-term dd { margin: 4px 0 0; font-size: .95rem; color: var(--muted); }

/* Article prev/next */
.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 44px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.article-nav a {
  flex: 1;
  max-width: 48%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: var(--ink);
  transition: var(--transition);
}
.article-nav a:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.article-nav .an-label {
  font-family: var(--font-mono);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 4px;
}
.article-nav .an-title { font-weight: 600; font-size: .95rem; }
.article-nav .next { text-align: right; }
.article-nav span { flex: 1; }

/* ---------- Footer ---------- */
.app-footer {
  border-top: 1px solid var(--border);
  margin-top: 40px;
  background: var(--bg-soft);
}
.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 20px;
  font-size: .88rem;
  color: var(--muted);
}
.footer-inner p { margin-bottom: 12px; }
.footer-note { font-size: .8rem; max-width: 900px; }
.footer-copy { font-family: var(--font-mono); font-size: .78rem; margin: 0; }

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

/* ---------- Page transition ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.app-content > * { animation: fadeUp .28s ease-out; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: 290px;
    background: var(--bg-soft);
    border-right: 1px solid var(--border);
    padding: 20px;
    transform: translateX(-100%);
    transition: transform .25s ease-out;
    z-index: 95;
    max-height: none;
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: flex; }
  .header-tagline { display: none; }
  .layout { padding-top: calc(var(--header-h) + 16px); }
}

@media (max-width: 600px) {
  :root { --header-h: 60px; }
  body { font-size: 16.5px; }
  .layout { padding-left: 14px; padding-right: 14px; gap: 0; }
  .search-wrap { max-width: none; }
  .brand-name { font-size: 1rem; }
  .home-hero { padding: 32px 22px; }
  .hero-stats { gap: 16px; }
  .card-grid { grid-template-columns: 1fr; }
  .article-nav { flex-direction: column; }
  .article-nav a { max-width: 100%; }
  .sidebar-link { font-size: .95rem; padding: 8px 10px; }
}
