/* ============================================================
   Baza wiedzy — design system
   Professional, calm, readable. One typeface (Inter) for the UI,
   a system serif for long-form article reading. Light theme.
   ============================================================ */

:root {
  /* Neutral surfaces + ink */
  --paper: #ffffff;
  --paper-2: #f5f6f8;
  --paper-3: #eef0f3;
  --ink: #17191d;
  --ink-soft: #3f444d;
  --ink-faint: #6b7280;
  --line: #e3e6ea;
  --line-strong: #cfd4db;

  /* Accent — professional blue (Geriatria) */
  --accent: #2456c9;
  --accent-strong: #1d47a8;
  --accent-wash: #eaf0fd;

  /* Teal — Gerontologia Polska */
  --teal: #0f766e;
  --teal-wash: #dbf1ec;

  --mark: #fff3c4;

  /* Type */
  --font-sans: 'Inter', ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: Charter, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, ui-serif, serif;

  /* Type scale */
  --t-xs: 0.78rem;
  --t-sm: 0.875rem;
  --t-base: 1rem;
  --t-md: 1.075rem;
  --t-lg: 1.25rem;
  --t-xl: 1.5rem;
  --t-2xl: 1.9rem;
  --t-3xl: clamp(1.9rem, 4vw, 2.6rem);

  /* Layout */
  --max: 68rem;
  --max-narrow: 44rem;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(23, 25, 29, 0.05);
  --shadow-md: 0 8px 24px rgba(23, 25, 29, 0.08);
  --tap: 44px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
*::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; color-scheme: light; }
body {
  font-family: var(--font-sans);
  font-size: var(--t-base);
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

h1, h2, h3, h4 {
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 0.6em;
  color: var(--ink);
}
h1 { font-size: var(--t-2xl); letter-spacing: -0.025em; line-height: 1.15; }
h2 { font-size: var(--t-xl); }
h3 { font-size: var(--t-lg); }
p  { margin: 0 0 1em; }

::selection { background: var(--accent); color: #fff; }

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

/* Header --------------------------------------------------------------- */

.site-header {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(160%) blur(8px);
  -webkit-backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: var(--t-md);
  letter-spacing: -0.015em;
  color: var(--ink);
}
.brand:hover { color: var(--accent); text-decoration: none; }
.brand-mark { color: var(--accent); flex-shrink: 0; }
.site-nav {
  margin-left: auto;
  display: flex;
  gap: 2px;
  font-size: var(--t-sm);
  font-weight: 500;
}
.site-nav a {
  color: var(--ink-soft);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  transition: color .15s, background .15s;
}
.site-nav a:hover { color: var(--ink); background: var(--paper-2); text-decoration: none; }

/* Footer --------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--paper-2);
  padding: 32px 24px;
  margin-top: 72px;
  font-size: var(--t-sm);
  color: var(--ink-faint);
  text-align: center;
}
.site-footer-inner { max-width: var(--max); margin: 0 auto; }
.site-footer p { margin: 0 0 4px; }
.site-footer strong { color: var(--ink-soft); font-weight: 600; }

/* Container ------------------------------------------------------------ */

.container { max-width: var(--max); margin: 0 auto; padding: 0 24px; }
.container-narrow { max-width: var(--max-narrow); margin: 0 auto; padding: 0 24px; }

/* Index page ----------------------------------------------------------- */

.hero {
  text-align: center;
  padding: clamp(2.5rem, 7vw, 4.5rem) 0 clamp(1.25rem, 3vw, 2rem);
}
.hero h1 {
  font-size: var(--t-3xl);
  letter-spacing: -0.03em;
  margin: 0 0 12px;
}
.hero h1 .accent { color: var(--accent); }
.hero .lead {
  max-width: 40rem;
  margin: 0 auto 28px;
  color: var(--ink-soft);
  font-size: var(--t-md);
  line-height: 1.55;
}
.hero .lead strong { color: var(--ink); font-weight: 700; }

/* Search input --------------------------------------------------------- */

.search-shell {
  max-width: 36rem;
  margin: 0 auto;
  position: relative;
}
.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 1rem;
  color: var(--ink-faint);
  pointer-events: none;
  transition: color .15s;
  width: 18px;
  height: 18px;
}
.search-input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: var(--t-md);
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.85rem 2.75rem 0.85rem 2.9rem;
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
.search-input::placeholder { color: var(--ink-faint); }
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.search-input:hover { border-color: var(--ink-faint); }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.search-input-wrap:focus-within .search-icon { color: var(--accent); }
.search-clear {
  position: absolute;
  right: 0.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.search-clear:hover { background: var(--paper-2); color: var(--ink); }
.search-clear[hidden] { display: none; }

/* Filter panel --------------------------------------------------------- */

.filter-panel {
  margin-top: 1.5rem;
  max-width: 50rem;
  margin-left: auto;
  margin-right: auto;
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  position: relative;
}

.dropdown { position: relative; }

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--t-sm);
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.filter-btn:hover { border-color: var(--ink-faint); background: var(--paper-2); }
.filter-btn[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
.filter-btn .lbl {
  color: var(--ink-faint);
  font-weight: 500;
}
.filter-btn .val {
  color: var(--ink);
  font-weight: 600;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filter-btn .caret {
  color: var(--ink-faint);
  flex-shrink: 0;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  min-width: 240px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dropdown-menu-wide { min-width: 280px; }
.dropdown-menu[hidden] { display: none; }

.dropdown-actions {
  display: flex;
  gap: 8px;
  padding: 4px 6px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}
.dropdown-actions button {
  font-family: var(--font-sans);
  font-size: var(--t-sm);
  font-weight: 500;
  background: transparent;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.dropdown-actions button:hover { background: var(--accent-wash); }

.year-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px 6px;
  max-height: 280px;
  overflow-y: auto;
  padding: 2px;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: var(--t-sm);
  cursor: pointer;
  color: var(--ink);
  transition: background .12s;
  user-select: none;
}
.check:hover { background: var(--paper-2); }
.check input[type="checkbox"] {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background .12s, border-color .12s;
}
.check input[type="checkbox"]:hover { border-color: var(--accent); }
.check input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.check input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.check .count {
  color: var(--ink-faint);
  font-size: var(--t-xs);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}

.opt {
  display: block;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 8px 12px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: var(--t-sm);
  color: var(--ink);
  cursor: pointer;
  width: 100%;
  transition: background .12s;
}
.opt:hover { background: var(--paper-2); }
.opt[aria-selected="true"] { background: var(--accent-wash); color: var(--accent); font-weight: 600; }

.reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink-faint);
  font-family: var(--font-sans);
  font-size: var(--t-sm);
  font-weight: 500;
  cursor: pointer;
  margin-left: auto;
  transition: color .15s, border-color .15s, background .15s;
}
.reset-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-wash); }
.reset-btn[hidden] { display: none; }

/* Results -------------------------------------------------------------- */

.results-bar {
  max-width: 50rem;
  margin: 1.75rem auto 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 1rem 4px 0;
  font-size: var(--t-sm);
  color: var(--ink-faint);
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.results-bar .count .num { color: var(--ink); font-weight: 700; }

.results-list {
  max-width: 50rem;
  margin: 0 auto;
  padding: 0 4px 24px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.result-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.result-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}
.card-link {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.15rem 1.3rem;
  color: inherit;
  text-decoration: none;
}
.card-link:hover { color: inherit; text-decoration: none; }
.result-card .cat {
  font-size: var(--t-xs);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.badge {
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-geriatria { color: var(--accent-strong); background: var(--accent-wash); }
.badge-gerontologia-polska { color: var(--teal); background: var(--teal-wash); }
.badge-neutral {
  color: var(--ink-faint);
  background: transparent;
  padding: 0;
  font-weight: 500;
}
.result-title {
  font-family: var(--font-sans);
  font-size: var(--t-md);
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 0;
  color: var(--ink);
}
.result-title mark {
  background: var(--mark);
  color: var(--ink);
  padding: 0 2px;
  border-radius: 2px;
}
.result-authors {
  font-size: var(--t-sm);
  color: var(--ink-soft);
  margin: 0;
}
.result-excerpt {
  font-size: var(--t-sm);
  color: var(--ink-faint);
  line-height: 1.55;
  margin: 0.15rem 0 0;
}
.result-excerpt mark {
  background: var(--mark);
  color: var(--ink);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 500;
}

.empty-state, .no-results {
  max-width: 32rem;
  margin: 3.5rem auto;
  text-align: center;
  color: var(--ink-soft);
  padding: 0 16px;
}
.empty-state h2, .no-results h2 {
  font-size: var(--t-lg);
  color: var(--ink);
  margin: 0 0 8px;
  letter-spacing: -0.015em;
}
.empty-state p, .no-results p {
  font-size: var(--t-base);
  margin: 0 0 16px;
  line-height: 1.55;
}

.loading-skel {
  max-width: 50rem;
  margin: 1.25rem auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0 4px;
}
.skel-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.3rem;
  height: 104px;
  position: relative;
  overflow: hidden;
}
.skel-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--paper-2), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* Article page -------------------------------------------------------- */

.article-wrap {
  padding: clamp(1.75rem, 4vw, 3rem) 0 40px;
}
.breadcrumb {
  font-size: var(--t-sm);
  color: var(--ink-faint);
  margin: 0 0 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.breadcrumb a { color: var(--ink-soft); }
.breadcrumb a:hover { color: var(--accent); text-decoration: none; }
.breadcrumb .sep { color: var(--line-strong); }
.breadcrumb .current { color: var(--ink-faint); }

.article-header {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.article-header .cat {
  font-size: var(--t-xs);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.article-header .cat .meta-pill {
  color: var(--ink-faint);
  background: transparent;
  padding: 0;
  font-weight: 500;
}
.article-header h1 {
  font-family: var(--font-sans);
  font-size: clamp(1.55rem, 3.5vw, 2.1rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin: 0 0 14px;
  color: var(--ink);
}
.article-header .authors {
  font-size: var(--t-md);
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.5;
}

.action-bar {
  position: sticky;
  top: 60px;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 14px 24px;
  margin: 0 -24px 28px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  font-size: var(--t-sm);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; box-shadow: var(--shadow-md); }

.btn-secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-secondary:hover { background: var(--paper-2); border-color: var(--ink-faint); color: var(--ink); }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--paper-2); color: var(--ink); border-color: var(--line); }

/* Article body — readable serif column ------------------------------- */

.article-body {
  font-family: var(--font-serif);
  font-size: var(--t-md);
  line-height: 1.75;
  color: var(--ink-soft);
  max-width: 38rem;
}
.article-body h1 { font-family: var(--font-sans); font-size: var(--t-xl); margin-top: 2em; line-height: 1.2; }
.article-body h2 {
  font-family: var(--font-sans);
  font-size: var(--t-lg);
  margin-top: 1.8em;
  margin-bottom: 0.5em;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  letter-spacing: -0.015em;
}
.article-body h3 { font-family: var(--font-sans); font-size: var(--t-md); margin-top: 1.5em; }
.article-body p { margin: 0 0 1.1em; }
.article-body sup { font-size: 0.65em; vertical-align: super; line-height: 0; }
.article-body sub { font-size: 0.65em; vertical-align: sub; line-height: 0; }
.article-body strong { font-weight: 700; }
.article-body em { font-style: italic; }
.article-body ul, .article-body ol { margin: 0 0 1.1em; padding-left: 1.5em; }
.article-body li { margin-bottom: 0.4em; }
.article-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.4em 0;
  padding: 0.85rem 1rem;
  color: var(--ink-soft);
  font-style: italic;
  background: var(--paper-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.article-body table {
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: var(--t-sm);
  font-family: var(--font-sans);
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  display: block;
}
.article-body td, .article-body th {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
}
.article-body th { background: var(--paper-2); font-weight: 600; }
.article-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--paper-2);
  padding: 2px 5px;
  border-radius: 3px;
}
.article-body pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--t-sm);
  background: var(--paper-2);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
}
.article-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.article-body a:hover { color: var(--accent-strong); }

.footnote {
  font-size: var(--t-sm);
  color: var(--ink-faint);
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  max-width: 38rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 32px 0 0;
  font-size: var(--t-sm);
  color: var(--ink-faint);
  font-weight: 500;
  transition: color .15s;
}
.back-link:hover { color: var(--accent); text-decoration: none; }

/* Responsive ---------------------------------------------------------- */

@media (max-width: 720px) {
  .site-header-inner { gap: 12px; padding: 0 16px; }
  .site-nav { gap: 0; }
  .site-nav a { padding: 6px 8px; font-size: var(--t-xs); }
  .hero { padding-top: 2.5rem; }
  .search-shell { max-width: 100%; }
  .container, .container-narrow { padding: 0 16px; }
  .action-bar { margin: 0 -16px 20px; padding-left: 16px; padding-right: 16px; top: 56px; }
  .article-body { font-size: var(--t-base); }
  .card-link { padding: 1rem 1.1rem; }
  .btn { height: 42px; padding: 0 14px; }
  .filter-btn { height: 38px; padding: 0 12px; }
  .filter-btn .val { max-width: 120px; }
  .year-grid { grid-template-columns: repeat(2, 1fr); }
}
