/* ============================================================
   Kompendium ADHD - design system
   Paleta: głęboki teal (zaufanie, zdrowie) + bursztyn (energia ADHD)
   Typografia: Figtree (nagłówki) + Cabin (treść)
   ============================================================ */

:root {
  /* Light theme */
  --bg: #f7f5ef;
  --bg-card: #ffffff;
  --bg-subtle: #f0ede3;
  --text: #22302a;
  --muted: #5d6b64;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --primary-soft: #d9efec;
  --accent: #d97706;
  --accent-soft: #fdf0dc;
  --border: #e5e0d3;
  --header-bg: rgba(247, 245, 239, 0.92);
  --shadow: 0 1px 3px rgba(34, 48, 42, 0.07), 0 4px 16px rgba(34, 48, 42, 0.05);
  --shadow-hover: 0 4px 12px rgba(15, 118, 110, 0.12), 0 8px 28px rgba(34, 48, 42, 0.09);
  --radius: 14px;
  --radius-sm: 9px;
  --font-heading: 'Figtree', 'Segoe UI', sans-serif;
  --font-body: 'Cabin', 'Segoe UI', sans-serif;
  --header-height: 60px;
  --sidebar-width: 290px;
  --transition: 0.2s ease-out;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1311;
    --bg-card: #161d1a;
    --bg-subtle: #1b2420;
    --text: #e8e6de;
    --muted: #9aa79f;
    --primary: #2dd4bf;
    --primary-strong: #5eead4;
    --primary-soft: #123a34;
    --accent: #fbbf24;
    --accent-soft: #33270f;
    --border: #26302b;
    --header-bg: rgba(14, 19, 17, 0.92);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 12px rgba(45, 212, 191, 0.1), 0 8px 28px rgba(0, 0, 0, 0.45);
  }
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 700px 500px at -10% -10%, rgba(15, 118, 110, 0.06), transparent 60%),
    radial-gradient(ellipse 700px 500px at 110% 110%, rgba(217, 119, 6, 0.07), transparent 60%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

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

/* ---------- 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(10px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.app-header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary-soft), transparent);
  opacity: 0.6;
  pointer-events: none;
}

.logo-mark { font-size: 1.35rem; line-height: 1; }

.logo-text {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  white-space: nowrap;
}
.logo-text a { color: var(--text); }
.logo-text a:hover { color: var(--primary); }

.mobile-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1.15rem;
  width: 40px; height: 40px;
  cursor: pointer;
  color: var(--text);
  transition: all var(--transition);
}
.mobile-menu-btn:hover { border-color: var(--primary); background: var(--primary-soft); }

.header-search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 16px;
  width: min(360px, 40vw);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.header-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.header-search input {
  border: none;
  background: none;
  outline: none;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text);
  width: 100%;
}
.search-icon { font-size: 0.9rem; opacity: 0.6; }

/* Reading progress (signature element) */
.reading-progress {
  position: fixed;
  top: var(--header-height);
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.reading-progress.visible { opacity: 1; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  overflow-y: auto;
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  padding: 16px 10px 40px;
  z-index: 90;
  scrollbar-width: thin;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 0.9rem;          /* min 15px - wymóg użytkownika */
  color: var(--text);
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.sidebar-nav a:hover {
  background: var(--primary-soft);
  color: var(--primary-strong);
}
.sidebar-nav a.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}
@media (prefers-color-scheme: dark) {
  .sidebar-nav a.active { color: #06211d; }
}

.nav-section {
  padding: 14px 12px 5px;
  font-family: var(--font-heading);
  font-size: 0.7rem;          /* sekcje - małe etykiety */
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}
.nav-section:first-of-type { padding-top: 6px; }

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

/* ---------- Main ---------- */
.main {
  margin-left: var(--sidebar-width);
  padding: calc(var(--header-height) + 28px) 32px 60px;
  max-width: 940px;
}

/* ---------- Home ---------- */
.home-hero {
  background: linear-gradient(135deg, var(--primary-soft), var(--bg-card) 60%, var(--accent-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 44px 40px;
  margin-bottom: 36px;
  position: relative;
  overflow: hidden;
}
.home-hero::before {
  content: '';
  position: absolute;
  top: -80px; right: -60px;
  width: 260px; height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(217, 119, 6, 0.14), transparent 70%);
  pointer-events: none;
}
.home-hero h1 {
  font-size: 2.1rem;
  font-weight: 800;
  margin-bottom: 10px;
  color: var(--text);
}
.home-hero .hero-sub {
  font-size: 1.08rem;
  color: var(--muted);
  max-width: 560px;
  margin-bottom: 22px;
}
.home-hero .hero-badges { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-badge {
  display: inline-block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary-strong);
}
.hero-badge .num { color: var(--accent); font-weight: 800; margin-right: 4px; }

.home-section { margin-bottom: 34px; }

.home-section h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  position: relative;
}
.home-section h2::after {
  content: '';
  position: absolute;
  left: 0; bottom: -2px;
  width: 64px; height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.home-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  color: var(--text);
}
.home-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
  color: var(--text);
}
.home-card .card-icon { font-size: 1.4rem; margin-bottom: 8px; display: block; }
.home-card h3 { font-size: 0.9rem; font-weight: 700; margin-bottom: 5px; }   /* min 15px */
.home-card p { font-size: 0.85rem; color: var(--muted); line-height: 1.55; } /* min 14px */
.home-card .card-arrow {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 700;
  opacity: 0;
  transform: translateX(-6px);
  transition: all var(--transition);
}
.home-card:hover .card-arrow { opacity: 1; transform: translateX(0); }

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

.content-article h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 10px;
}
.article-meta {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 26px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.article-meta .section-label {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 12px;
  margin-right: 10px;
  font-family: var(--font-heading);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
}

.content-article h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 30px 0 12px;
  padding-top: 8px;
  scroll-margin-top: calc(var(--header-height) + 16px);
}
.content-article h3 {
  font-size: 1.12rem;
  font-weight: 700;
  margin: 22px 0 8px;
  scroll-margin-top: calc(var(--header-height) + 16px);
}

.content-article p { margin-bottom: 14px; }
.content-article ul, .content-article ol { margin: 0 0 16px 22px; }
.content-article li { margin-bottom: 6px; }
.content-article strong { font-weight: 700; }

/* TOC */
.toc {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin: 0 0 26px;
  font-size: 0.92rem;
}
.toc-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}
.toc ul { list-style: none; margin: 0; }
.toc li { margin-bottom: 4px; }
.toc a { color: var(--text); }
.toc a:hover { color: var(--primary); }

/* Info box */
.info-box {
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 18px 0;
  font-size: 0.95rem;
}
.info-box .info-title {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--primary-strong);
  margin-bottom: 4px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
@media (prefers-color-scheme: dark) {
  .info-box .info-title { color: var(--primary); }
}

.warn-box {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 18px 0;
  font-size: 0.95rem;
}
.warn-box .info-title {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Tables */
.table-responsive { overflow-x: auto; margin: 18px 0; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
table th, table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table th {
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
@media (prefers-color-scheme: dark) {
  table th { color: var(--primary); }
}
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: var(--bg-subtle); }
.error-table th { background: var(--accent-soft); color: var(--accent); }

/* FAQ */
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
  background: var(--bg-card);
}
.faq-item summary {
  cursor: pointer;
  padding: 14px 18px;
  font-weight: 700;
  font-family: var(--font-heading);
  font-size: 1rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: background var(--transition);
}
.faq-item summary:hover { background: var(--bg-subtle); }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+';
  font-size: 1.3rem;
  color: var(--primary);
  flex-shrink: 0;
  transition: transform var(--transition);
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item .faq-body { padding: 0 18px 14px; font-size: 0.95rem; }

/* Glossary */
.glossary dl { margin: 0; }
.glossary dt {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--primary-strong);
  margin-top: 16px;
  font-size: 1rem;
}
@media (prefers-color-scheme: dark) {
  .glossary dt { color: var(--primary); }
}
.glossary dd { margin: 3px 0 0; font-size: 0.95rem; }

/* Search results */
.search-results {
  margin-top: 20px;
}
.search-result-item {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 10px;
  color: var(--text);
  transition: all var(--transition);
}
.search-result-item:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  color: var(--text);
}
.search-result-item .sr-title { font-weight: 700; font-family: var(--font-heading); }
.search-result-item .sr-excerpt { font-size: 0.88rem; color: var(--muted); }

.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

/* Footer */
.app-footer {
  margin-left: var(--sidebar-width);
  padding: 26px 32px 40px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  max-width: 940px;
}
.app-footer p { margin-bottom: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease-out;
    box-shadow: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.2); }
  .sidebar-overlay.show { display: block; }
  .main { margin-left: 0; padding: calc(var(--header-height) + 20px) 18px 50px; }
  .app-footer { margin-left: 0; padding: 20px 18px 34px; }
  .mobile-menu-btn { display: block; }
  .header-search { width: auto; flex: 1; max-width: none; }
  .home-hero { padding: 32px 24px; }
  .home-hero h1 { font-size: 1.65rem; }
  .content-article h1 { font-size: 1.6rem; }
}

@media (max-width: 600px) {
  .logo-text { font-size: 0.98rem; }
  .card-grid { grid-template-columns: 1fr; }
  .home-hero { padding: 26px 20px; }
  .content-article h2 { font-size: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
