/* ============================================
   CZYSTE POWIETRZE - design system
   Koncept: "czyste niebo vs smog"
   Błękit nieba + grafit smogu + zieleń zdrowia
   + bursztyn/czerwień alertów (skala AQI)
   Fonty: Sora (display) + Karla (body)
   ============================================ */

:root {
  /* Light theme - czyste niebo */
  --bg: #f4f8fb;
  --bg-card: #ffffff;
  --bg-soft: #eaf3fa;
  --text: #10222e;
  --text-secondary: #46586a;
  --muted: #6b7f90;
  --accent: #0369a1;          /* sky-700: czysty błękit nieba */
  --accent-bright: #0ea5e9;   /* sky-500 */
  --accent-soft: #bae6fd;     /* sky-200 */
  --accent-subtle: #e0f2fe;   /* sky-100 */
  --health: #15803d;          /* green-700: zdrowie, natura */
  --health-subtle: #dcfce7;
  --warn: #b45309;            /* amber-700: alerty smogowe */
  --warn-subtle: #fef3c7;
  --danger: #b91c1c;
  --danger-subtle: #fee2e2;
  --aqi-purple: #7e22ce;
  --border: #d7e4ef;
  --border-light: #e6eff6;
  --shadow: 0 1px 2px rgba(15, 34, 46, .05), 0 4px 16px rgba(15, 34, 46, .06);
  --shadow-hover: 0 2px 4px rgba(15, 34, 46, .07), 0 10px 28px rgba(3, 105, 161, .12);

  --font-heading: 'Sora', 'Segoe UI', sans-serif;
  --font-body: 'Karla', 'Segoe UI', sans-serif;

  --header-height: 60px;
  --sidebar-width: 300px;
  --radius: 14px;
  --radius-sm: 8px;
  --transition: .2s ease-out;

  /* AQI scale colors (signature) */
  --aqi-good: #22c55e;
  --aqi-moderate: #eab308;
  --aqi-bad: #f97316;
  --aqi-very-bad: #ef4444;
  --aqi-extreme: #a855f7;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --bg-card: #111a2b;
    --bg-soft: #0e1830;
    --text: #dce6f0;
    --text-secondary: #9db1c4;
    --muted: #7c90a3;
    --accent: #38bdf8;
    --accent-bright: #7dd3fc;
    --accent-soft: #155e8a;
    --accent-subtle: rgba(56, 189, 248, .12);
    --health: #4ade80;
    --health-subtle: rgba(74, 222, 128, .12);
    --warn: #fbbf24;
    --warn-subtle: rgba(251, 191, 36, .12);
    --danger: #f87171;
    --danger-subtle: rgba(248, 113, 113, .12);
    --aqi-purple: #c084fc;
    --border: #1e2c40;
    --border-light: #17263a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, .4), 0 10px 28px rgba(56, 189, 248, .08);
  }
}

/* ---------- 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);
  -webkit-font-smoothing: antialiased;
}
body::before, body::after {
  content: '';
  position: fixed;
  pointer-events: none;
  z-index: -1;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .5;
}
body::before {
  width: 520px; height: 520px;
  background: var(--accent-soft);
  top: -180px; right: -140px;
}
body::after {
  width: 460px; height: 460px;
  background: var(--health-subtle);
  bottom: -160px; left: -140px;
}
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  line-height: 1.25;
  text-wrap: balance;
  margin: 0 0 .5em;
}
a { color: var(--accent); }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--accent-bright); outline-offset: 2px; border-radius: 4px; }

/* ---------- 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(--bg-card);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  backdrop-filter: blur(8px);
}
.app-header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-soft), transparent);
  opacity: .8;
  pointer-events: none;
}
.logo-mark { font-size: 1.5rem; line-height: 1; }
.site-title {
  font-family: var(--font-heading);
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.site-title a { color: var(--text); text-decoration: none; }
.site-title a:hover { color: var(--accent); }
.mobile-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  width: 38px; height: 38px;
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition);
}
.mobile-menu-btn:hover { background: var(--bg-soft); }

/* ---------- Search ---------- */
.header-search {
  position: relative;
  margin-left: auto;
  width: min(320px, 40vw);
}
.header-search .search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: .85rem;
  opacity: .6;
  pointer-events: none;
}
.header-search input {
  width: 100%;
  padding: 8px 14px 8px 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.header-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}
#search-results {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(420px, 80vw);
  max-height: 70vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  z-index: 200;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  overflow-y: auto;
  padding: 18px 10px 40px 14px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  z-index: 90;
  scrollbar-width: thin;
}
.sidebar-nav { list-style: none; margin: 0; padding: 0; }
.sidebar-nav li { margin: 1px 0; }
.sidebar-nav a {
  display: block;
  padding: 6px 10px;
  font-size: .9rem;            /* min 15px przy 17px bazie */
  line-height: 1.45;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition), transform var(--transition);
}
.sidebar-nav a:hover {
  background: var(--accent-subtle);
  color: var(--accent);
  transform: translateX(2px);
}
.sidebar-nav a.active {
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-section {
  margin-top: 18px;
  padding: 4px 10px 2px;
  font-family: var(--font-heading);
  font-size: .7rem;            /* sekcje nawigacji */
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}
.sidebar-nav > li:first-child { margin-top: 2px; }

/* ---------- Main ---------- */
.main-content {
  margin-left: var(--sidebar-width);
  padding: calc(var(--header-height) + 28px) 40px 80px;
  max-width: 980px;
}
.loading { display: flex; justify-content: center; padding: 80px 0; }
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.content-article {
  animation: fadeUp .28s ease-out;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 42px 48px;
  box-shadow: var(--shadow);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Home hero ---------- */
.home-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  padding: 44px 48px;
  margin-bottom: 36px;
  background: linear-gradient(150deg, var(--accent-subtle) 0%, var(--bg-card) 55%, var(--health-subtle) 130%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.home-hero::before {
  content: '';
  position: absolute;
  width: 260px; height: 90px;
  border-radius: 50%;
  background: var(--bg-card);
  opacity: .55;
  top: 26px; right: 120px;
  filter: blur(30px);
  animation: cloudDrift 16s ease-in-out infinite;
}
.home-hero::after {
  content: '';
  position: absolute;
  width: 200px; height: 70px;
  border-radius: 50%;
  background: var(--bg-card);
  opacity: .4;
  top: 64px; right: 300px;
  filter: blur(26px);
  animation: cloudDrift 22s ease-in-out infinite reverse;
}
@keyframes cloudDrift {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(26px); }
}
.hero-icon { font-size: 2.4rem; margin-bottom: 8px; }
.home-hero h1 {
  font-size: clamp(1.7rem, 3.4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -.02em;
  margin-bottom: .35em;
  color: var(--text);
}
.home-hero .hero-sub {
  font-size: 1.06rem;
  color: var(--text-secondary);
  max-width: 620px;
  margin: 0 0 24px;
}
.aqi-scale {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 26px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: .82rem;
  color: var(--text-secondary);
}
.aqi-scale .bar {
  display: inline-flex;
  border-radius: 999px;
  overflow: hidden;
  margin: 0 8px;
}
.aqi-scale .bar span {
  width: 16px; height: 8px;
  display: block;
}
.stats-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform var(--transition);
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card .num {
  display: block;
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
}
.stat-card .label {
  font-size: .78rem;
  color: var(--muted);
}

/* ---------- Home sections & cards ---------- */
.home-section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  margin: 34px 0 14px;
}
.accent-bar {
  width: 22px; height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--health));
  flex-shrink: 0;
}
.home-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;
  text-decoration: none;
  color: var(--text);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
}
.home-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--health));
  opacity: 0;
  transition: opacity var(--transition);
}
.home-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent-soft);
}
.home-card:hover::before { opacity: 1; }
.home-card .card-icon { font-size: 1.4rem; display: block; margin-bottom: 8px; }
.home-card h3 {
  font-size: .9rem;            /* min 15px */
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 6px;
}
.home-card p {
  font-size: .85rem;           /* min 14px - czytelne */
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 0;
}

/* ---------- Article ---------- */
.content-article h1 {
  font-size: clamp(1.5rem, 3vw, 2.05rem);
  font-weight: 800;
  letter-spacing: -.015em;
  margin-bottom: .3em;
}
.article-meta {
  font-size: .95rem;
  color: var(--text-secondary);
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
}
.content-article h2 {
  font-size: 1.32rem;
  font-weight: 700;
  margin-top: 1.8em;
  padding-bottom: .25em;
  border-bottom: 2px solid var(--accent-subtle);
}
.content-article h3 {
  font-size: 1.08rem;
  font-weight: 600;
  margin-top: 1.4em;
}
.content-article p { margin: .9em 0; }
.content-article ul, .content-article ol { padding-left: 1.3em; }
.content-article li { margin: .35em 0; }
.content-article strong { font-weight: 700; }

/* ---------- TOC ---------- */
.article-toc {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 18px 0 24px;
  font-size: .9rem;
}
.article-toc h3 {
  margin: 0 0 8px;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}
.article-toc a {
  display: block;
  padding: 3px 0;
  color: var(--text-secondary);
  text-decoration: none;
}
.article-toc a:hover { color: var(--accent); }
.article-toc .toc-h3 { padding-left: 16px; font-size: .87rem; }

/* ---------- Tables ---------- */
.table-responsive { overflow-x: auto; margin: 1.2em 0; }
.content-article table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
  background: var(--bg-card);
}
.content-article th {
  background: var(--accent-subtle);
  color: var(--text);
  font-family: var(--font-heading);
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.content-article td {
  padding: 9px 14px;
  border: 1px solid var(--border);
  vertical-align: top;
}
.content-article tr:nth-child(even) td { background: var(--bg-soft); }
.comparison-table th { background: var(--health-subtle); }

/* ---------- Boxes ---------- */
.info-box {
  background: var(--accent-subtle);
  border: 1px solid var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 1.2em 0;
  font-size: .95rem;
}
.info-box strong { color: var(--accent); }
.warn-box {
  background: var(--warn-subtle);
  border: 1px solid var(--warn);
  border-left: 4px solid var(--warn);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 1.2em 0;
  font-size: .95rem;
}
.danger-box {
  background: var(--danger-subtle);
  border: 1px solid var(--danger);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 1.2em 0;
  font-size: .95rem;
}
.health-box {
  background: var(--health-subtle);
  border: 1px solid var(--health);
  border-left: 4px solid var(--health);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 1.2em 0;
  font-size: .95rem;
}

/* ---------- FAQ ---------- */
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 12px 0;
  overflow: hidden;
}
.faq-item summary {
  cursor: pointer;
  padding: 14px 18px;
  font-weight: 600;
  font-size: 1rem;
  background: var(--bg-soft);
  list-style: none;
  transition: background var(--transition);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before { content: '❓ '; }
.faq-item summary:hover { background: var(--accent-subtle); }
.faq-item[open] summary { background: var(--accent-subtle); }
.faq-item .faq-answer {
  padding: 6px 18px 14px;
  font-size: .95rem;
  border-top: 1px solid var(--border-light);
}

/* ---------- Glossary ---------- */
.glossary dl { margin: 0; }
.glossary dt {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}
.glossary dt:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.glossary dd {
  margin: 4px 0 0;
  font-size: .95rem;
  color: var(--text-secondary);
}

/* ---------- Comparison verdict ---------- */
.verdict {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 1.2em 0;
}

/* ---------- 404 ---------- */
.notfound { text-align: center; padding: 5em 0; }
.notfound h1 {
  font-size: 4.5rem;
  margin-bottom: .2em;
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---------- Cursor orbs (ambient) ---------- */
@media (pointer: fine) {
  .cursor-orb {
    position: fixed;
    width: 340px; height: 340px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-subtle), transparent 70%);
    opacity: 0;
    pointer-events: none;
    z-index: 0;
    transition: opacity .4s ease;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .mobile-menu-btn { display: block; }
  .sidebar {
    transform: translateX(-105%);
    transition: transform .25s ease-out;
    width: min(320px, 86vw);
    box-shadow: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-hover); }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 20, 30, .5);
    z-index: 85;
  }
  .sidebar-overlay.show { display: block; }
  .main-content {
    margin-left: 0;
    padding: calc(var(--header-height) + 20px) 18px 60px;
  }
  .content-article { padding: 28px 22px; }
  .home-hero { padding: 30px 24px; }
  .header-search { width: min(260px, 46vw); }
}

@media (max-width: 600px) {
  body { font-size: 16.5px; }
  .app-header { padding: 0 12px; gap: 10px; }
  .site-title { font-size: .98rem; }
  .home-grid { grid-template-columns: 1fr; }
  .header-search { width: 40vw; }
  .header-search input { padding: 7px 10px 7px 30px; font-size: .88rem; }
  .stats-row { gap: 8px; }
  .stat-card { padding: 8px 14px; }
  .stat-card .num { font-size: 1.1rem; }
}

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