/* ============================================================
   AGD - design system
   Koncepcja: "Etykieta energetyczna i stal" - grafit stali +
   zieleń klasy A+++ (efektywność) + bursztyn oszczędności.
   Typografia: Archivo (display) + Hanken Grotesk (body) +
   IBM Plex Mono (specyfikacje). WCAG 2.1 AA.
   ============================================================ */

:root {
  /* Light theme - "energy label & steel" */
  --bg: #f2f5f6;
  --surface: #ffffff;
  --surface-2: #e7edf0;
  --text: #1b2228;
  --muted: #55626d;
  --green: #1e7a4a;
  --green-deep: #145c37;
  --green-strong: #155f39;
  --green-soft: #e2f0e8;
  --amber: #a65c12;
  --amber-soft: #f7ecdd;
  --steel: #5b6b78;
  --line: rgba(27, 34, 40, 0.13);
  --line-strong: rgba(27, 34, 40, 0.28);
  --shadow-card: 0 1px 2px rgba(27, 34, 40, 0.05), 0 6px 24px -12px rgba(27, 34, 40, 0.16);
  --shadow-card-hover: 0 2px 4px rgba(27, 34, 40, 0.06), 0 14px 34px -14px rgba(30, 122, 74, 0.26);
  --header-bg: rgba(242, 245, 246, 0.86);
  --accent-light: rgba(30, 122, 74, 0.5);
  --accent-subtle: rgba(30, 122, 74, 0.55);

  --font-display: "Archivo", "Arial Narrow", sans-serif;
  --font-body: "Hanken Grotesk", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --header-height: 64px;
  --sidebar-w: 300px;
  --radius: 14px;
  --radius-sm: 9px;
  --transition: 0.2s ease-out;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161b;
    --surface: #1a2128;
    --surface-2: #222b34;
    --text: #e7ebee;
    --muted: #9aa7b1;
    --green: #45b87d;
    --green-deep: #2e8a5c;
    --green-strong: #5cc98f;
    --green-soft: #1c3226;
    --amber: #f0a35e;
    --amber-soft: #33261a;
    --steel: #8d9ba6;
    --line: rgba(231, 235, 238, 0.14);
    --line-strong: rgba(231, 235, 238, 0.3);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 24px -12px rgba(0, 0, 0, 0.5);
    --shadow-card-hover: 0 2px 4px rgba(0, 0, 0, 0.35), 0 14px 34px -14px rgba(0, 0, 0, 0.7);
    --header-bg: rgba(18, 22, 27, 0.86);
    --accent-light: rgba(69, 184, 125, 0.35);
    --accent-subtle: rgba(69, 184, 125, 0.4);
  }
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { 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(--text);
  background: var(--bg);
  background-image:
    radial-gradient(1100px 520px at -8% -6%, var(--accent-light) 0%, transparent 55%),
    radial-gradient(900px 480px at 108% 104%, var(--accent-light) 0%, transparent 52%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; }
a { color: var(--green-deep); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.22; text-wrap: balance; margin: 0 0 0.5em; letter-spacing: -0.012em; }
h1 { font-size: 2.35rem; font-weight: 700; }
h2 { font-size: 1.7rem; font-weight: 700; }
h3 { font-size: 1.22rem; font-weight: 700; }
p { margin: 0 0 1.1em; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 200;
  background: var(--green-deep); color: #fff; padding: 10px 16px; border-radius: 8px;
}
.skip-link:focus { left: 8px; }

/* ---------- Header ---------- */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-height);
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.app-header::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-subtle), transparent);
  opacity: 0.35; pointer-events: none;
}
.header-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 20px;
  height: 100%; display: flex; align-items: center; gap: 16px;
}
.menu-btn {
  display: none; background: none; border: 1px solid var(--line); border-radius: 9px;
  width: 42px; height: 42px; cursor: pointer; flex-shrink: 0;
  flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  background: var(--surface);
}
.menu-btn span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; transition: all 0.2s; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--green), var(--green-deep));
  color: #f2f5f6; flex-shrink: 0;
}
.brand-name { font-family: var(--font-display); font-size: 1.32rem; font-weight: 800; letter-spacing: -0.015em; }
.brand-name em { font-style: normal; color: var(--green); }
.header-tagline {
  margin-left: auto; font-size: 0.82rem; color: var(--muted); white-space: nowrap;
  font-weight: 600; letter-spacing: 0.02em;
}
.search-wrap { position: relative; width: min(340px, 38vw); margin-left: auto; }
.header-tagline + .search-wrap { margin-left: 0; }
.search-input {
  width: 100%; height: 42px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font-family: var(--font-body); font-size: 0.95rem; transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 120;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card-hover); overflow: hidden; display: none;
}
.search-results.open { display: block; }
.search-item { display: block; padding: 11px 16px; border-bottom: 1px solid var(--line); color: var(--text); }
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--surface-2); text-decoration: none; }
.si-title { font-weight: 700; font-size: 0.95rem; }
.si-section { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.search-empty { padding: 14px 16px; color: var(--muted); font-size: 0.9rem; }

/* ---------- Layout ---------- */
.layout { max-width: 1280px; margin: 0 auto; padding: calc(var(--header-height) + 24px) 20px 48px; display: flex; gap: 32px; align-items: flex-start; }
.sidebar {
  position: sticky; top: calc(var(--header-height) + 24px);
  width: var(--sidebar-w); flex-shrink: 0;
  max-height: calc(100vh - var(--header-height) - 48px);
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 14px 24px; box-shadow: var(--shadow-card);
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
.side-group { margin-bottom: 14px; }
.side-group-title {
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--green); margin: 0 8px 6px; padding-bottom: 5px; border-bottom: 1px solid var(--line);
}
.sidebar-link {
  display: flex; align-items: center; gap: 9px;
  font-size: 0.9rem; line-height: 1.35; color: var(--text);
  padding: 6px 8px; border-radius: 8px; margin-bottom: 1px;
  transition: background 0.15s, transform 0.15s;
}
.sidebar-link:hover { background: var(--surface-2); text-decoration: none; transform: translateX(2px); }
.sidebar-link.active { background: var(--green-soft); color: var(--green-deep); font-weight: 700; }
.sidebar-link.active .s-icon { color: var(--green); }
.s-icon { font-size: 0.95rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-overlay { display: none; }

.main-content { flex: 1; min-width: 0; }
.app-content { animation: fadeUp 0.26s ease-out; }

/* ---------- Hero ---------- */
.home-hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  background:
    radial-gradient(720px 300px at 88% -20%, rgba(69, 184, 125, 0.25), transparent 60%),
    linear-gradient(135deg, #10151a 0%, #1b2a24 58%, #234d38 100%);
  color: #eef3ef;
  padding: 52px 48px 0;
  display: flex; gap: 36px; align-items: flex-end; justify-content: space-between;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow-card-hover);
}
.home-hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.14;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
}
.hero-inner { position: relative; max-width: 640px; padding-bottom: 44px; }
.hero-eyebrow {
  display: inline-block; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase;
  color: #7fd6a8; margin-bottom: 14px; padding: 5px 12px; border: 1px solid rgba(127, 214, 168, 0.45);
  border-radius: 999px; background: rgba(127, 214, 168, 0.08);
}
.home-hero h1 { color: #fff; font-size: 2.6rem; margin-bottom: 14px; }
.home-hero h1 em { font-style: italic; color: #7fd6a8; }
.hero-sub { color: #c8d3cc; font-size: 1.06rem; max-width: 56ch; margin-bottom: 26px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px; border-radius: 10px; font-weight: 700; font-size: 0.98rem;
  transition: transform 0.18s ease-out, box-shadow 0.18s ease-out, background 0.18s;
  border: 1px solid transparent;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn-primary { background: #7fd6a8; color: #10151a; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22); }
.btn-primary:hover { background: #9ce3bb; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); }
.btn-ghost { background: transparent; color: #eef3ef; border-color: rgba(238, 243, 239, 0.4); }
.btn-ghost:hover { background: rgba(238, 243, 239, 0.1); }
.hero-stats { display: flex; gap: 34px; margin-top: 32px; }
.hero-stat .hs-num { font-family: var(--font-display); font-size: 1.9rem; font-weight: 800; color: #7fd6a8; line-height: 1.1; }
.hero-stat .hs-label { font-size: 0.8rem; color: #9fb0a6; margin-top: 2px; }

/* Signature: etykieta energetyczna */
.hero-label { position: relative; flex-shrink: 0; padding-bottom: 8px; }
.hero-label svg { display: block; width: 300px; height: 260px; }
.el-frame { fill: rgba(238, 243, 239, 0.05); stroke: rgba(238, 243, 239, 0.28); stroke-width: 1.5; }
.el-title { fill: #eef3ef; font-family: var(--font-display); font-size: 17px; font-weight: 800; }
.el-bar-bg { fill: #2a3540; }
.el-bar-A { fill: #45b87d; }
.el-bar { fill: rgba(238, 243, 239, 0.16); }
.el-arrow { fill: #7fd6a8; }
.el-class { fill: #7fd6a8; font-family: var(--font-display); font-size: 26px; font-weight: 800; }
.el-spec { fill: #9fb0a6; font-family: var(--font-mono); font-size: 10.5px; }
.el-spec strong { fill: #eef3ef; }
.el-flash { fill: #f0a35e; font-family: var(--font-mono); font-size: 9.5px; }
@keyframes elPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
.el-bar-A.pulse { animation: elPulse 2.6s ease-in-out infinite; }
.el-bar-r { transition: opacity 0.4s; }

/* ---------- Home sections ---------- */
.home-section { margin-top: 46px; }
.home-section h2 {
  display: flex; align-items: baseline; gap: 12px; font-size: 1.5rem;
  padding-bottom: 10px; border-bottom: 2px solid var(--line);
}
.sec-count {
  font-family: var(--font-mono); font-size: 0.8rem; font-weight: 600; color: #fff;
  background: var(--green); padding: 3px 8px; border-radius: 6px; letter-spacing: 0.03em;
}
.sec-desc { color: var(--muted); font-size: 0.98rem; margin: 10px 0 20px; max-width: 70ch; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.home-card {
  position: relative; display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 18px 16px; color: var(--text);
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out, border-color 0.2s;
}
.home-card::before {
  content: ""; position: absolute; top: 0; left: 18px; right: 18px; height: 3px;
  background: linear-gradient(90deg, var(--green), var(--steel));
  border-radius: 0 0 4px 4px; opacity: 0; transition: opacity 0.2s;
}
.home-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card-hover); border-color: var(--line-strong); text-decoration: none; }
.home-card:hover::before { opacity: 1; }
.hc-icon { font-size: 1.5rem; line-height: 1; margin-bottom: 4px; }
.home-card h3 { font-size: 0.95rem; margin: 0; line-height: 1.4; }
.home-card p { font-size: 0.85rem; color: var(--muted); margin: 0; line-height: 1.55; flex: 1; }
.hc-more { font-size: 0.78rem; font-weight: 800; color: var(--green-deep); margin-top: 8px; display: inline-flex; align-items: center; gap: 5px; }
.hc-more .arrow { transition: transform 0.2s; }
.home-card:hover .hc-more .arrow { transform: translateX(4px); }

/* ---------- Article ---------- */
.article-header { margin-bottom: 26px; }
.breadcrumbs { font-size: 0.82rem; color: var(--muted); margin-bottom: 12px; }
.breadcrumbs a { color: var(--green-deep); font-weight: 600; }
.breadcrumbs .sep { margin: 0 7px; color: var(--green); }
.article-header h1 { font-size: 2.2rem; margin-bottom: 10px; }
.article-excerpt { font-size: 1.1rem; color: var(--muted); max-width: 70ch; }
.article-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; font-size: 0.82rem; color: var(--muted); }
.tag {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  background: var(--green-soft); color: var(--green-strong); font-weight: 800; font-size: 0.78rem;
  border: 1px solid transparent;
}
.spec-tag {
  display: inline-block; padding: 3px 10px; border-radius: 6px;
  background: var(--surface-2); color: var(--muted); font-family: var(--font-mono);
  font-size: 0.74rem; font-weight: 500; border: 1px solid var(--line);
}

.article-body { max-width: 780px; }
.article-body p { line-height: 1.72; }
.article-body ul, .article-body ol { line-height: 1.7; padding-left: 1.4em; margin: 0 0 1.2em; }
.article-body li { margin-bottom: 0.4em; }
.article-body h2 { margin-top: 2em; padding-top: 0.4em; border-top: 1px solid var(--line); scroll-margin-top: calc(var(--header-height) + 20px); }
.article-body h3 { margin-top: 1.6em; color: var(--green-deep); }
.article-body strong { color: var(--text); }
.article-body a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--green); text-decoration-thickness: 1.5px; }
.article-body a:hover { color: var(--green-strong); }

.article-toc {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--green);
  border-radius: var(--radius-sm); padding: 14px 18px; margin: 0 0 26px;
  box-shadow: var(--shadow-card);
}
.article-toc summary { cursor: pointer; font-weight: 800; font-size: 0.95rem; color: var(--green-deep); }
.article-toc ol { margin: 10px 0 2px; padding-left: 1.3em; font-size: 0.92rem; }
.article-toc li { margin-bottom: 5px; }
.article-toc a { color: var(--text); }

.info-box {
  background: var(--green-soft); border: 1px solid rgba(30, 122, 74, 0.4); border-radius: var(--radius-sm);
  padding: 16px 18px; margin: 1.4em 0; font-size: 0.97rem;
}
.info-box strong { color: var(--green-strong); }
.warn-box {
  background: var(--amber-soft); border: 1px solid rgba(166, 92, 18, 0.4); border-radius: var(--radius-sm);
  padding: 16px 18px; margin: 1.4em 0; font-size: 0.97rem;
}
.warn-box strong { color: var(--amber); }

.table-responsive { overflow-x: auto; margin: 1.4em 0; border-radius: var(--radius-sm); border: 1px solid var(--line); box-shadow: var(--shadow-card); }
table { width: 100%; border-collapse: collapse; font-size: 0.94rem; background: var(--surface); }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--green-deep); color: #fff; font-weight: 700; font-size: 0.88rem; }
tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: var(--surface-2); }
tbody tr:hover { background: var(--green-soft); }
.compare-table th:first-child, .compare-table td:first-child { font-weight: 700; color: var(--green-deep); white-space: nowrap; }
.compare-table td.yes { color: var(--green-deep); font-weight: 700; }
.compare-table td.no { color: var(--amber); font-weight: 700; }

.faq-item { margin: 0 0 18px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-card); }
.faq-item h3 { margin: 0 0 8px; font-size: 1.08rem; color: var(--green-deep); }
.faq-item p { margin: 0; }

dl.glossary { margin: 1.2em 0; }
dl.glossary dt { font-weight: 800; color: var(--green-deep); margin-top: 1.1em; font-size: 1.02rem; }
dl.glossary dt::before { content: ""; display: inline-block; width: 8px; height: 8px; background: var(--green); border-radius: 2px; margin-right: 9px; }
dl.glossary dd { margin: 0.25em 0 0 17px; }

.article-nav { display: flex; justify-content: space-between; gap: 16px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); }
.article-nav a { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 18px; transition: transform 0.18s, box-shadow 0.18s; }
.article-nav a:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-card-hover); }
.article-nav .an-label { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--green); margin-bottom: 4px; }
.article-nav .an-title { font-weight: 700; font-size: 0.95rem; color: var(--text); line-height: 1.4; }
.article-nav a.next { text-align: right; }

/* ---------- Footer ---------- */
.app-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 60px; }
.footer-inner { max-width: 1280px; margin: 0 auto; padding: 36px 20px 44px; }
.footer-inner p { font-size: 0.92rem; color: var(--muted); max-width: 90ch; }
.footer-note { font-size: 0.82rem !important; }
.footer-copy { margin-top: 18px; font-size: 0.85rem; font-weight: 700; color: var(--text) !important; }

/* ---------- Animations ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.5s ease-out, transform 0.5s ease-out; }
.reveal.in { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
  .el-bar-A.pulse { animation: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .menu-btn { display: flex; }
  .header-tagline { display: none; }
  .search-wrap { margin-left: 0; width: 100%; }
  .header-inner { gap: 12px; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 150;
    width: min(320px, 86vw); max-height: none; border-radius: 0;
    transform: translateX(-102%); transition: transform 0.26s ease-out;
    padding-top: calc(var(--header-height) + 10px);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(16, 21, 26, 0.55); z-index: 140; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
  .sidebar-overlay.show { opacity: 1; pointer-events: auto; }
  .layout { padding: calc(var(--header-height) + 16px) 14px 40px; }
  .home-hero { flex-direction: column; padding: 40px 26px 26px; align-items: stretch; }
  .hero-label svg { width: 100%; max-width: 320px; margin: 0 auto; height: auto; }
  .hero-stats { gap: 22px; flex-wrap: wrap; }
  .home-hero h1 { font-size: 2.05rem; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
  .article-header h1 { font-size: 1.85rem; }
}

@media (max-width: 600px) {
  body { font-size: 16.5px; }
  .brand-name { font-size: 1.18rem; }
  .search-input { height: 40px; }
  .home-hero { padding: 32px 20px 20px; border-radius: 10px; }
  .home-hero h1 { font-size: 1.75rem; }
  .hero-sub { font-size: 0.98rem; }
  .btn { width: 100%; justify-content: center; }
  .hero-cta { flex-direction: column; }
  .card-grid { grid-template-columns: 1fr; }
  .article-nav { flex-direction: column; }
  .article-nav a.next { text-align: left; }
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.45rem; }
  .app-footer { margin-top: 40px; }
}
