/* ============================================================
   smog.jock.pl · ATMOSPHERIC DARK
   Night sky, layered haze, luminous data.
   ============================================================ */

:root {
  /* powietrze: kategorie polskiego indeksu */
  --q1: #43e5c4;   /* bardzo dobry · czysty cyjan */
  --q2: #a4e05f;   /* dobry · zieleń */
  --q3: #f7cf52;   /* umiarkowany · bursztyn */
  --q4: #ff9a4d;   /* dostateczny · pomarańcz */
  --q5: #ff5e6c;   /* zły · czerwień */
  --q6: #c9184a;   /* bardzo zły · alarm */
  --q-none: #5a6478; /* brak danych */

  --bg-0: #05070f;
  --bg-1: #0a0f1e;
  --bg-2: #101830;
  --ink: #e9eef8;
  --ink-dim: #9aa7bd;
  --ink-faint: #64718a;
  --line: rgba(154, 176, 220, .14);
  --card: rgba(16, 24, 48, .55);
  --card-edge: rgba(120, 160, 230, .16);

  --font-sans: 'Hanken Grotesk', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Spline Sans Mono', ui-monospace, monospace;

  --radius: 18px;
  --maxw: 1080px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg-0);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 16px;
  /* warstwy nocnego nieba i mgły */
  background-image:
    radial-gradient(1100px 700px at 82% -8%, rgba(67, 229, 196, .075), transparent 60%),
    radial-gradient(900px 640px at -10% 12%, rgba(84, 110, 220, .12), transparent 62%),
    radial-gradient(1200px 900px at 50% 115%, rgba(201, 24, 74, .06), transparent 58%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0) 42%, #060a15 100%);
  background-attachment: fixed;
}

/* haze canvas + ziarno nad tłem, pod treścią */
#haze {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.page {
  position: relative;
  z-index: 2;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 clamp(18px, 4vw, 40px);
}

::selection { background: rgba(67, 229, 196, .28); }

a { color: var(--q1); text-decoration-color: rgba(67, 229, 196, .4); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--q1); }

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

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ============ HEADER ============ */

.site-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 0 10px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -.01em;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-dim { color: var(--ink-faint); font-weight: 500; }

.brand-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--q1);
  box-shadow: 0 0 12px var(--q1), 0 0 30px rgba(67, 229, 196, .5);
}

.site-nav { display: flex; gap: 22px; flex-wrap: wrap; }

.site-nav a {
  color: var(--ink-dim);
  text-decoration: none;
  font-size: .92rem;
  font-weight: 600;
  letter-spacing: .01em;
  transition: color .2s;
}
.site-nav a:hover { color: var(--ink); }

/* ============ HERO ============ */

.hero { padding: clamp(48px, 9vh, 96px) 0 24px; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 8px 16px;
  background: rgba(12, 18, 38, .5);
  backdrop-filter: blur(6px);
}

.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--q1);
  box-shadow: 0 0 10px var(--q1);
  animation: pulse-dot 2.4s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.8); }
}

.hero h1 {
  font-size: clamp(2.6rem, 7.2vw, 5rem);
  font-weight: 800;
  letter-spacing: -.035em;
  line-height: 1.02;
  margin: 26px 0 20px;
  background: linear-gradient(115deg, #f2f6ff 30%, #9fd9ff 62%, #43e5c4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 80px rgba(90, 160, 255, .25);
}

.lede {
  max-width: 56ch;
  color: var(--ink-dim);
  font-size: clamp(1rem, 2.1vw, 1.16rem);
  font-weight: 400;
}

/* karty hero */

.hero-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 18px;
  margin-top: 42px;
}

.hcard {
  position: relative;
  border-radius: var(--radius);
  padding: 26px 26px 22px;
  background: var(--card);
  border: 1px solid var(--card-edge);
  backdrop-filter: blur(10px);
  overflow: hidden;
  transition: transform .25s ease, border-color .25s ease;
}
.hcard:hover { transform: translateY(-3px); }

.hcard::before {
  content: "";
  position: absolute;
  inset: -40% -20% auto;
  height: 120%;
  pointer-events: none;
  opacity: .5;
}
.hcard-worst::before {
  background: radial-gradient(60% 70% at 75% 20%, rgba(255, 154, 77, .22), transparent 70%);
}
.hcard-best::before {
  background: radial-gradient(60% 70% at 75% 20%, rgba(67, 229, 196, .2), transparent 70%);
}
.hcard-worst { --hue: var(--q4); }
.hcard-best { --hue: var(--q1); }

.hcard-label {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.hcard-city {
  font-size: clamp(1.7rem, 3.6vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -.02em;
  margin-top: 10px;
  line-height: 1.1;
}

.hcard-region { color: var(--ink-faint); font-size: .9rem; margin-top: 2px; }

.hcard-num {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 18px;
}

.glow-num {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: clamp(3rem, 7vw, 4.4rem);
  line-height: 1;
  letter-spacing: -.03em;
  color: var(--hue);
  text-shadow:
    0 0 18px color-mix(in srgb, var(--hue) 65%, transparent),
    0 0 60px color-mix(in srgb, var(--hue) 35%, transparent);
}

.hcard-unit {
  font-size: .82rem;
  color: var(--ink-dim);
  line-height: 1.35;
}

.hcard-cat { margin-top: 14px; }

/* kategorie: świecące plakietki */

.badge {
  display: inline-block;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 4px 12px;
  border-radius: 100px;
  border: 1px solid;
  white-space: nowrap;
}
.badge[data-cat="Bardzo dobry"] { color: var(--q1); border-color: color-mix(in srgb, var(--q1) 45%, transparent); background: color-mix(in srgb, var(--q1) 10%, transparent); }
.badge[data-cat="Dobry"]        { color: var(--q2); border-color: color-mix(in srgb, var(--q2) 45%, transparent); background: color-mix(in srgb, var(--q2) 10%, transparent); }
.badge[data-cat="Umiarkowany"]  { color: var(--q3); border-color: color-mix(in srgb, var(--q3) 45%, transparent); background: color-mix(in srgb, var(--q3) 10%, transparent); }
.badge[data-cat="Dostateczny"]  { color: var(--q4); border-color: color-mix(in srgb, var(--q4) 45%, transparent); background: color-mix(in srgb, var(--q4) 10%, transparent); }
.badge[data-cat="Zły"]          { color: var(--q5); border-color: color-mix(in srgb, var(--q5) 45%, transparent); background: color-mix(in srgb, var(--q5) 10%, transparent); }
.badge[data-cat="Bardzo zły"]   { color: #ff7aa2; border-color: color-mix(in srgb, var(--q6) 60%, transparent); background: color-mix(in srgb, var(--q6) 18%, transparent); }
.badge[data-cat="brak"]         { color: var(--q-none); border-color: color-mix(in srgb, var(--q-none) 45%, transparent); background: color-mix(in srgb, var(--q-none) 10%, transparent); }

.hero-top5 {
  margin-top: 22px;
  font-size: .92rem;
  color: var(--ink-dim);
}
.hero-top5 strong { color: var(--ink); }

/* pasek statystyk */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  margin-top: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--line);
}

.stat {
  background: rgba(10, 16, 34, .72);
  padding: 18px 20px;
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
}

.stat dd {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.1;
}

.stat-of { font-size: 1rem; color: var(--ink-faint); }

.stat dt {
  font-size: .76rem;
  color: var(--ink-faint);
  letter-spacing: .02em;
}

.stat-alarm dd {
  color: var(--q1);
  text-shadow: 0 0 16px color-mix(in srgb, var(--q1) 50%, transparent);
}
.stat-alarm.is-alarm dd {
  color: var(--q5);
  text-shadow: 0 0 16px color-mix(in srgb, var(--q5) 60%, transparent);
}

/* ============ SEKCJE ============ */

section { padding: clamp(44px, 8vh, 80px) 0 0; }

h2 {
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -.025em;
  line-height: 1.15;
}

.section-sub {
  color: var(--ink-dim);
  max-width: 62ch;
  margin-top: 10px;
  font-size: .98rem;
}

/* ============ PULS ============ */

.pulse-meter {
  display: flex;
  height: 26px;
  border-radius: 100px;
  overflow: hidden;
  margin-top: 24px;
  border: 1px solid var(--line);
  background: rgba(10, 16, 34, .7);
}

.pulse-seg {
  height: 100%;
  min-width: 3px;
  box-shadow: 0 0 22px currentColor;
  transition: flex-grow 1s cubic-bezier(.2, .8, .2, 1);
}

.pulse-legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin-top: 16px;
}

.pulse-legend li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .86rem;
  color: var(--ink-dim);
}
.pulse-legend li.is-zero { opacity: .45; }

.pulse-legend .swatch {
  width: 10px; height: 10px;
  border-radius: 3px;
  box-shadow: 0 0 8px currentColor;
}

.pulse-legend .cnt {
  font-family: var(--font-mono);
  color: var(--ink);
  font-weight: 600;
}

/* ============ RANKING ============ */

.search-wrap {
  position: relative;
  margin-top: 26px;
  max-width: 460px;
}

.search-ico {
  position: absolute;
  left: 16px; top: 50%;
  translate: 0 -50%;
  width: 18px; height: 18px;
  color: var(--ink-faint);
  pointer-events: none;
}

#city-search {
  width: 100%;
  font: inherit;
  font-size: .98rem;
  color: var(--ink);
  background: rgba(12, 18, 38, .7);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 13px 20px 13px 46px;
  transition: border-color .2s, box-shadow .2s;
}
#city-search::placeholder { color: var(--ink-faint); }
#city-search:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--q1) 55%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--q1) 15%, transparent);
}

.rank-status { margin-top: 14px; font-size: .9rem; color: var(--ink-dim); min-height: 1.3em; }

.rank-list {
  list-style: none;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(9, 14, 30, .55);
  backdrop-filter: blur(8px);
}

.crow + .crow { border-top: 1px solid var(--line); }

.crow-head {
  display: grid;
  grid-template-columns: 44px minmax(140px, 1.5fr) minmax(0, 1fr) 84px 84px 130px 20px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 18px;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .18s;
}
.crow-head:hover { background: rgba(120, 160, 230, .06); }
.crow-head:focus-visible { outline-offset: -3px; }

.crow-rank {
  font-family: var(--font-mono);
  font-size: .92rem;
  color: var(--ink-faint);
}
.crow:nth-child(-n+3) .crow-rank { color: var(--q4); font-weight: 600; }

.crow-city { font-weight: 700; letter-spacing: -.01em; min-width: 0; }
.crow-city small {
  display: block;
  font-weight: 500;
  font-size: .76rem;
  color: var(--ink-faint);
}

.crow-bar {
  height: 6px;
  border-radius: 100px;
  background: rgba(120, 160, 230, .1);
  overflow: hidden;
}
.crow-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
  transition: width .9s cubic-bezier(.2, .8, .2, 1);
}

.crow-val {
  font-family: var(--font-mono);
  font-size: .95rem;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
.crow-val small {
  display: block;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: .68rem;
  color: var(--ink-faint);
}
.crow-val.is-empty { color: var(--ink-faint); font-weight: 400; }

.crow-chev {
  width: 14px; height: 14px;
  color: var(--ink-faint);
  transition: transform .25s;
  justify-self: end;
}
.crow-head[aria-expanded="true"] .crow-chev { transform: rotate(180deg); }

.crow-panel {
  padding: 4px 18px 18px 74px;
  animation: panel-in .3s ease both;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.station-table-wrap { overflow-x: auto; }

.station-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: .88rem;
}
.station-table th {
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 8px 12px 8px 0;
  border-bottom: 1px solid var(--line);
}
.station-table td {
  padding: 9px 12px 9px 0;
  border-bottom: 1px solid rgba(154, 176, 220, .07);
  color: var(--ink-dim);
}
.station-table td:first-child { color: var(--ink); font-weight: 600; }
.station-table .num { font-family: var(--font-mono); }

.rank-loading { padding: 26px 22px; color: var(--ink-dim); font-size: .92rem; }
.rank-loading p { margin-top: 14px; }

.loading-line {
  height: 12px;
  border-radius: 100px;
  margin-bottom: 12px;
  background: linear-gradient(90deg, rgba(120, 160, 230, .08), rgba(120, 160, 230, .18), rgba(120, 160, 230, .08));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.rank-actions { margin-top: 18px; text-align: center; }

.ghost-btn {
  font: inherit;
  font-size: .92rem;
  font-weight: 700;
  color: var(--q1);
  background: color-mix(in srgb, var(--q1) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--q1) 35%, transparent);
  border-radius: 100px;
  padding: 11px 26px;
  cursor: pointer;
  transition: background .2s, box-shadow .2s;
}
.ghost-btn:hover {
  background: color-mix(in srgb, var(--q1) 15%, transparent);
  box-shadow: 0 0 24px color-mix(in srgb, var(--q1) 25%, transparent);
}

.no-data-block { margin-top: 26px; color: var(--ink-dim); }
.no-data-block summary {
  cursor: pointer;
  font-size: .92rem;
  font-weight: 600;
  color: var(--ink-faint);
  padding: 6px 2px;
}
.no-data-block summary:hover { color: var(--ink-dim); }
.no-data-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.no-data-list li {
  font-size: .82rem;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--ink-faint);
}

.error-box {
  margin-top: 20px;
  padding: 18px 22px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--q5) 40%, transparent);
  background: color-mix(in srgb, var(--q5) 8%, transparent);
  color: var(--ink);
  font-size: .95rem;
}

/* ============ WYKRES ============ */

.chart-scroll { overflow-x: auto; margin-top: 26px; }

.chart { min-width: 640px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart-loading { color: var(--ink-dim); font-size: .92rem; }

/* ============ CO ZNACZĄ TE LICZBY ============ */

.explain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 18px;
  margin-top: 28px;
}

.ecard {
  border-radius: var(--radius);
  border: 1px solid var(--card-edge);
  background: var(--card);
  backdrop-filter: blur(8px);
  padding: 24px;
}

.ecard h3 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ecard-tag {
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 600;
  color: var(--q1);
  border: 1px solid color-mix(in srgb, var(--q1) 40%, transparent);
  border-radius: 8px;
  padding: 3px 9px;
  text-shadow: 0 0 12px color-mix(in srgb, var(--q1) 50%, transparent);
}

.ecard p { margin-top: 12px; color: var(--ink-dim); font-size: .93rem; }
.ecard strong { color: var(--ink); }

.table-title {
  margin-top: 40px;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -.01em;
}

.table-scroll {
  overflow-x: auto;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(9, 14, 30, .55);
}

.thresholds {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: .9rem;
}
.thresholds th, .thresholds td { padding: 12px 18px; text-align: left; }
.thresholds thead th {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--line);
}
.thresholds tbody tr + tr td { border-top: 1px solid rgba(154, 176, 220, .07); }
.thresholds td { color: var(--ink-dim); }
.thresholds td:nth-child(2), .thresholds td:nth-child(3) { font-family: var(--font-mono); white-space: nowrap; }

.explain-note {
  margin-top: 22px;
  color: var(--ink-faint);
  font-size: .88rem;
  max-width: 70ch;
}

/* ============ FOOTER ============ */

.site-foot {
  margin-top: clamp(60px, 10vh, 110px);
  border-top: 1px solid var(--line);
  padding: 36px 0 48px;
}

.foot-grid {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(280px, 1.6fr);
  gap: 28px;
}

.foot-brand { font-weight: 800; font-size: 1.05rem; }
.foot-tag { color: var(--ink-faint); font-size: .88rem; margin-top: 6px; }

.foot-meta { font-size: .86rem; color: var(--ink-dim); }
.foot-meta p + p { margin-top: 10px; }

/* ============ ANIMACJE WEJŚCIA ============ */

.reveal {
  opacity: 0;
  transform: translateY(16px);
  animation: rise .8s cubic-bezier(.2, .8, .2, 1) forwards;
}
.r1 { animation-delay: .05s; }
.r2 { animation-delay: .15s; }
.r3 { animation-delay: .28s; }
.r4 { animation-delay: .42s; }
.r5 { animation-delay: .55s; }
.r6 { animation-delay: .65s; }

@keyframes rise {
  to { opacity: 1; transform: none; }
}

/* ============ RESPONSYWNOŚĆ ============ */

@media (max-width: 860px) {
  .crow-head {
    grid-template-columns: 34px minmax(0, 1fr) 76px 76px 20px;
    gap: 10px;
    padding: 12px 14px;
  }
  .crow-bar, .crow-badge-cell { display: none; }
  .crow-panel { padding-left: 14px; }
}

@media (max-width: 560px) {
  .crow-head { grid-template-columns: 28px minmax(0, 1fr) 76px 18px; }
  .crow-val-pm10 { display: none; }
  .foot-grid { grid-template-columns: 1fr; }
  .stat dd { font-size: 1.5rem; }
  .hero { padding-top: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { animation: none; opacity: 1; transform: none; }
  .live-dot { animation: none; }
  .loading-line { animation: none; }
  #haze { display: none; }
  * { transition-duration: .01ms !important; }
}
