/* ============================================================
   Dokumentacja — układ i komponenty (logika wyglądu).
   Zmienne kolorów/czcionek/wymiarów są w osobnym pliku: theme.css
   (edytowalnym po generacji). Ten plik zwykle nie wymaga zmian.

   Motyw: ASTRARIUM — dopasowany do mistycznej, nocnej strony wróżb.
   ============================================================ */

/* Kroje pisma wczytuje <head> każdej strony — bez @import, żeby nie blokować renderu. */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: var(--font-size-base, 16px);
  line-height: 1.65;
  color: var(--text);
  background:
    radial-gradient(ellipse 90% 55% at 50% -8%, rgba(154, 124, 232, .14), transparent 60%),
    radial-gradient(ellipse 70% 45% at 100% 105%, rgba(232, 196, 120, .07), transparent 60%),
    radial-gradient(ellipse 60% 40% at -5% 60%, rgba(212, 90, 168, .06), transparent 65%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(232, 196, 120, .3); color: #fff; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(232, 196, 120, .3); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(232, 196, 120, .48); }
::-webkit-scrollbar-track { background: transparent; }

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

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--serif);
  font-weight: 600; letter-spacing: .04em; color: var(--text);
  font-size: 16px; white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand .mark {
  width: 27px; height: 27px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 34% 28%, var(--accent), var(--accent-2) 100%);
  box-shadow: 0 0 14px rgba(232, 196, 120, .35);
  color: #1c1030; font-weight: 700; font-size: 14px; font-family: var(--serif);
}

/* powrót na stronę główną portalu */
.back-link {
  font-size: 12.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-faint); white-space: nowrap;
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px;
  transition: color .15s, border-color .15s;
}
.back-link:hover { color: var(--accent-text); border-color: var(--accent); text-decoration: none; }

.header-spacer { flex: 1; }

/* Wyszukiwarka */
.search {
  position: relative; width: 260px; max-width: 40vw;
}
.search input {
  width: 100%; height: 36px;
  padding: 0 30px 0 34px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 13.5px; font-family: var(--sans);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 20px rgba(232, 196, 120, .18);
}
.search .icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); pointer-events: none;
}
.search kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font: 600 10px/1 var(--mono); color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 5px;
  padding: 3px 5px; background: var(--bg);
}
.search-results {
  position: absolute; top: 44px; right: 0; left: auto;
  width: 420px; max-width: calc(100vw - 32px);
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
  padding: 6px; display: none; max-height: 60vh; overflow-y: auto;
}
.search-results.open { display: block; }
.search-results .hit {
  display: block; padding: 9px 11px; border-radius: 8px; color: var(--text);
}
.search-results .hit:hover, .search-results .hit.active {
  background: var(--accent-soft); text-decoration: none;
}
.search-results .hit .h-title { font-family: var(--serif); font-weight: 600; font-size: 14.5px; }
.search-results .hit .h-sec {
  font: 600 10px/1 var(--mono); color: var(--accent-text);
  text-transform: uppercase; letter-spacing: .1em;
}
.search-results .hit .h-snippet {
  font-size: 12.5px; color: var(--text-muted); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.search-results .hit mark {
  background: color-mix(in srgb, var(--accent) 26%, transparent);
  color: inherit; border-radius: 3px; padding: 0 1px;
}
.search-empty { padding: 16px; text-align: center; color: var(--text-faint); font-size: 13px; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--bg-subtle);
  color: var(--text-muted); transition: color .15s, border-color .15s, box-shadow .15s;
}
.icon-btn:hover { color: var(--accent-text); border-color: var(--accent); box-shadow: 0 0 14px rgba(232, 196, 120, .2); }
.menu-toggle { display: none; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  max-width: 1320px; margin: 0 auto;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto; padding: 24px 14px 60px 20px;
  border-right: 1px solid var(--border);
}
.nav-section {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(10px);
  padding: 12px 10px 10px;
}
.nav-section > .sec-title {
  font: 600 12px/1.3 var(--serif); letter-spacing: .06em;
  color: var(--accent-text); padding: 0 8px 8px; margin: 0 0 6px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
}
.nav-links { list-style: none; margin: 0; padding: 0; }
.nav-links a {
  display: block; padding: 6px 10px; border-radius: 7px;
  color: var(--text-muted); font-size: 13.5px; line-height: 1.4;
  border-left: 2px solid transparent; margin-left: -2px;
}
.nav-links a:hover { color: var(--text); background: var(--bg-subtle); text-decoration: none; }
.nav-links a.active {
  color: var(--accent-text); background: var(--accent-soft);
  border-left-color: var(--accent); font-weight: 600;
}

/* ---------- Main ---------- */
.main { min-width: 0; padding: 40px 56px 96px; }
.breadcrumb {
  max-width: var(--measure); margin: 0 auto 22px;
  font-size: 13px; color: var(--text-faint);
  display: flex; flex-wrap: wrap; gap: 7px; align-items: center;
  letter-spacing: .03em;
}
.breadcrumb .sep { opacity: .5; }
.breadcrumb .cur { color: var(--text-muted); }

.content { max-width: var(--measure); margin: 0 auto; }
.content .doc-h { scroll-margin-top: calc(var(--header-h) + 16px); }
.content h1.doc-h {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(30px, 4vw, 40px); line-height: 1.14; letter-spacing: .01em;
  margin: 0 0 28px; padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.content h2.doc-h { font-family: var(--serif); font-weight: 600; font-size: 27px; margin: 44px 0 14px; letter-spacing: .005em; }
.content h3.doc-h { font-family: var(--serif); font-weight: 600; font-size: 21px; margin: 32px 0 10px; }
.content h4.doc-h { font-family: var(--serif); font-weight: 600; font-size: 17px; margin: 24px 0 8px; color: var(--accent-text); }

/* Wyrównanie do lewej — justowanie polskiego tekstu robi „rzeki" i zła dzieli wyrazy. */
.content p {
  margin: 0 0 1.15em; color: var(--text);
  text-align: left; text-wrap: pretty;
  hyphens: manual;
  line-height: var(--line-height-base, 1.75);
}
/* pierwszy akapit jako wprowadzenie */
.content > p:first-of-type { font-size: 1.06em; color: var(--text); }

.content ul, .content ol { margin: 0 0 1.15em; padding-left: 24px; }
.content li {
  margin: 10px 0; text-wrap: pretty;
  line-height: var(--line-height-base, 1.75);
}
.content li::marker { color: var(--accent-text); }
.content li > ul, .content li > ol { margin: 10px 0; }

.content blockquote {
  margin: 0 0 16px; padding: 4px 18px; border-left: 3px solid var(--accent);
  background: var(--bg-subtle); border-radius: 0 10px 10px 0; color: var(--text-muted);
  font-family: var(--serif); font-style: italic; font-size: 1.05em;
}
.content hr {
  border: none; border-top: 1px solid var(--border); margin: 32px 0;
  position: relative;
}
.content hr::after {
  content: "✦"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: var(--bg); color: var(--accent-text); font-size: 12px; padding: 0 10px;
}

.inline-code {
  font: .88em var(--mono); background: var(--bg-code);
  padding: .15em .4em; border-radius: 5px; border: 1px solid var(--border);
}
.code-block {
  margin: 0 0 18px; padding: 16px 18px; overflow-x: auto;
  background: var(--bg-code); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13px; line-height: 1.6;
}
.code-block code { font-family: var(--mono); background: none; border: none; padding: 0; }

/* nawigacja prev/next */
.page-nav {
  max-width: var(--measure); margin: 56px auto 0;
  display: flex; justify-content: space-between; gap: 16px;
  padding-top: 24px; border-top: 1px solid var(--border);
}
.page-nav a {
  flex: 1; padding: 14px 16px; border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); max-width: 48%;
  background: var(--panel); backdrop-filter: blur(10px);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.page-nav a:hover { border-color: var(--accent); text-decoration: none; box-shadow: 0 0 20px rgba(232, 196, 120, .14); }
.page-nav a.next { text-align: right; margin-left: auto; }
.page-nav .dir { font-size: 11.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .1em; }
.page-nav .lbl { font-family: var(--serif); font-weight: 600; font-size: 16px; margin-top: 2px; }

/* ---------- Landing ---------- */
.landing { max-width: 880px; margin: 0 auto; }
.landing .hero { padding: 24px 0 8px; }
.landing .eyebrow {
  font: 600 12px/1 var(--serif); letter-spacing: .3em; text-transform: uppercase;
  color: var(--accent-text);
}
.landing h1 {
  font-family: var(--serif); font-size: clamp(38px, 5vw, 52px); letter-spacing: .01em; margin: 14px 0;
  font-weight: 600; line-height: 1.12; color: var(--text);
}
.landing .lede { font-size: 1.05em; line-height: 1.7; color: var(--text-muted); max-width: 60ch; }
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px; margin-top: 40px;
}
.card {
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  padding: 20px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); backdrop-filter: blur(10px);
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; box-shadow: 0 10px 30px rgba(0,0,0,.35), 0 0 30px rgba(232, 196, 120, .14); }
.card .c-title { font-family: var(--serif); font-weight: 600; font-size: 19px; line-height: 1.3; color: var(--text); }
.card .c-meta {
  font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint);
}

/* ---------- Responsive ---------- */
.backdrop { display: none; }
@media (max-width: 1100px) {
  .main { padding: 36px 32px 90px; }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .menu-toggle { display: grid; }
  .sidebar {
    position: fixed; top: var(--header-h); left: 0; z-index: 35;
    width: min(300px, 84vw); height: calc(100vh - var(--header-h));
    background: var(--panel); backdrop-filter: blur(16px); transform: translateX(-100%);
    transition: transform .22s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .backdrop.open {
    display: block; position: fixed; inset: var(--header-h) 0 0 0; z-index: 30;
    background: rgba(4, 3, 14, .6);
  }
  .main { padding: 28px 20px 80px; }
  .search { width: 180px; }
  .search kbd { display: none; }
  .back-link { border: 0; padding: 5px 2px; font-size: 0; }
  .back-link::before { content: "‹ Portal"; font-size: 12.5px; }
}
@media (max-width: 560px) {
  .site-header { gap: 10px; padding: 0 12px; }
  .back-link { display: none; }
  .search { width: auto; flex: 1; max-width: none; }
  .page-nav { flex-direction: column; }
  .page-nav a { max-width: none; }
}
