/* dane.jock.pl: Swiss International data poster
   paper / ink / one red. 8pt grid. Archivo. */

:root {
  --paper: #F2EFE7;
  --paper-2: #EAE6D9;
  --ink: #14120E;
  --ink-70: #4A463C;
  --ink-50: #6E6857;
  --rule: #14120E;
  --rule-soft: #D4CEBE;
  --acc: #C81E17;
  --c1: #C81E17;
  --c2: #1E56C8;
  --c3: #8A6A00;
  --c4: #1E7A46;
  --ghost: #C7C0AF;
  --grid-line: #DDD8C9;
  --u: 8px;
  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--ink); text-decoration-color: var(--acc); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--acc); }

strong { font-weight: 700; }

.wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 calc(var(--u) * 3);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: var(--u) calc(var(--u) * 2);
  z-index: 100;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--acc);
  outline-offset: 2px;
}

/* ---------- labels & titles ---------- */

.label {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}

.section-title {
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 0 calc(var(--u) * 4);
  padding-top: calc(var(--u) * 3);
  border-top: 3px solid var(--rule);
  text-transform: uppercase;
}

.idx {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--acc);
  vertical-align: super;
  margin-right: calc(var(--u) * 2);
}

/* ---------- masthead ---------- */

.masthead { padding: calc(var(--u) * 3) 0 calc(var(--u) * 6); }

.meta-row {
  display: flex;
  gap: calc(var(--u) * 3);
  padding-bottom: calc(var(--u) * 2);
  border-bottom: 3px solid var(--rule);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.meta-right { margin-left: auto; white-space: nowrap; }

.site-title {
  font-size: clamp(40px, 11.5vw, 152px);
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 0.92;
  text-transform: uppercase;
  margin: calc(var(--u) * 4) 0 calc(var(--u) * 3);
}
.site-title .acc { color: var(--acc); }

.lede {
  max-width: 46ch;
  font-size: clamp(17px, 2vw, 21px);
  line-height: 1.45;
  margin: 0;
  color: var(--ink-70);
}
.lede strong { color: var(--ink); }

/* ---------- facts rotator ---------- */

.facts {
  border-top: 3px solid var(--rule);
  border-bottom: 3px solid var(--rule);
  background: var(--ink);
  color: var(--paper);
  padding: calc(var(--u) * 3) 0 calc(var(--u) * 4);
}
.facts .label { color: var(--paper); }

.facts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: calc(var(--u) * 2);
}

.facts-controls { display: flex; gap: var(--u); }

.ctrl {
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  width: calc(var(--u) * 5);
  height: calc(var(--u) * 5);
  background: transparent;
  color: var(--paper);
  border: 2px solid var(--paper);
  border-radius: 0;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ctrl:hover { background: var(--paper); color: var(--ink); }

.facts-stage { position: relative; min-height: calc(var(--u) * 22); }

.fact {
  margin: 0;
  font-size: clamp(22px, 3.6vw, 40px);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.22;
  max-width: 30ch;
  display: none;
}
.fact strong { color: #FF6A5E; font-weight: 800; }
html.js .fact { position: absolute; inset: 0; }
html.js .fact.is-active {
  display: block;
  animation: fact-in 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
html:not(.js) .fact { display: block; position: static; margin-bottom: calc(var(--u) * 3); }
html:not(.js) .facts-stage { min-height: 0; }

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

.facts-foot {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 3);
  margin-top: calc(var(--u) * 3);
}

.fact-goto {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--acc);
  color: #fff;
  border: none;
  padding: calc(var(--u) * 1.5) calc(var(--u) * 3);
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.fact-goto:hover { background: #A21510; }
html:not(.js) .fact-goto, html:not(.js) .fact-progress, html:not(.js) .facts-controls { display: none; }

.fact-progress {
  flex: 1;
  height: 2px;
  background: rgba(242, 239, 231, 0.25);
  overflow: hidden;
}
#fact-bar {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--paper);
  transform: scaleX(0);
  transform-origin: left;
}
#fact-bar.run { animation: bar-run 9s linear forwards; }
@keyframes bar-run { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- picker ---------- */

.picker-section { padding: calc(var(--u) * 6) 0 calc(var(--u) * 4); }

.loading {
  font-size: 15px;
  color: var(--ink-50);
  letter-spacing: 0.04em;
  padding: calc(var(--u) * 2) 0;
  animation: pulse 1.2s ease-in-out infinite alternate;
}
@keyframes pulse { from { opacity: 0.45; } to { opacity: 1; } }

.error-msg {
  border: 3px solid var(--acc);
  padding: calc(var(--u) * 2) calc(var(--u) * 3);
  font-weight: 600;
  max-width: 60ch;
}

.theme-group { margin-bottom: calc(var(--u) * 3); }

.theme-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-50);
  border-top: 1px solid var(--rule-soft);
  padding: calc(var(--u) * 1.5) 0 var(--u);
  margin: 0;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--u);
}

.card {
  font-family: var(--font);
  text-align: left;
  background: transparent;
  border: 2px solid var(--ink);
  border-radius: 0;
  padding: calc(var(--u) * 2);
  cursor: pointer;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 0.5);
  min-height: calc(var(--u) * 13);
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.card:hover { transform: translate(-2px, -2px); box-shadow: 4px 4px 0 var(--ink); }
.card[aria-pressed="true"] {
  background: var(--acc);
  border-color: var(--acc);
  color: #fff;
}
.card[aria-pressed="true"]:hover { box-shadow: 4px 4px 0 var(--ink); }

.card-no { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; opacity: 0.65; }
.card-name { font-size: 18px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.15; }
.card-unit { font-size: 13px; opacity: 0.75; margin-top: auto; }

/* ---------- explorer ---------- */

.explorer { padding: calc(var(--u) * 2) 0 calc(var(--u) * 6); }

.ind-header {
  border-top: 3px solid var(--rule);
  padding-top: calc(var(--u) * 3);
}

.ind-header .label { color: var(--acc); }

.ind-name {
  font-size: clamp(34px, 6vw, 72px);
  font-weight: 900;
  letter-spacing: -0.025em;
  line-height: 1;
  text-transform: uppercase;
  margin: var(--u) 0 calc(var(--u) * 1.5);
}

.ind-meta {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-50);
  margin: 0 0 calc(var(--u) * 2);
}
.dot-sep { margin: 0 var(--u); color: var(--acc); }

.ind-context {
  font-size: clamp(16px, 1.8vw, 19px);
  max-width: 62ch;
  margin: 0 0 calc(var(--u) * 4);
  color: var(--ink-70);
}

/* stats tiles */

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
  margin-bottom: calc(var(--u) * 6);
}

.stat {
  padding: calc(var(--u) * 3) calc(var(--u) * 3) calc(var(--u) * 3) 0;
  border-left: 1px solid var(--rule-soft);
  padding-left: calc(var(--u) * 3);
}
.stat:first-child { border-left: none; padding-left: 0; }

.stat-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-50);
  margin: 0 0 var(--u);
}

.stat-value {
  font-size: clamp(30px, 4.6vw, 56px);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat-value .stat-unit { font-size: 0.45em; font-weight: 700; letter-spacing: 0; margin-left: 0.15em; }
.stat.stat-best .stat-value { color: var(--acc); }

.stat-sub { font-size: 14px; font-weight: 600; margin: var(--u) 0 0; color: var(--ink-70); }

/* chart */

.chart-block, .ranking-block, .powiaty-block { margin-bottom: calc(var(--u) * 6); }

.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: calc(var(--u) * 3);
  flex-wrap: wrap;
  border-top: 3px solid var(--rule);
  padding-top: calc(var(--u) * 2);
  margin-bottom: calc(var(--u) * 3);
}

.block-title {
  font-size: clamp(20px, 2.6vw, 28px);
  font-weight: 800;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  margin: 0;
}

.chart-hint { font-size: 13px; color: var(--ink-50); margin: 0; max-width: 44ch; }

.chart-wrap { position: relative; }

#chart { display: block; width: 100%; height: auto; }

#chart .grid-y { stroke: var(--grid-line); stroke-width: 1; }
#chart .axis-text {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  fill: var(--ink-50);
  font-variant-numeric: tabular-nums;
}
#chart .zero-line { stroke: var(--ink-70); stroke-width: 1; stroke-dasharray: 2 3; }

#chart .line {
  fill: none;
  stroke: var(--ghost);
  stroke-width: 1.5;
  transition: stroke 0.15s, stroke-width 0.15s, opacity 0.15s;
}
#chart .line.is-hi { stroke-width: 2.5; }
#chart .line.is-hover { stroke: var(--ink); stroke-width: 2.5; cursor: pointer; }
#chart.has-hover .line:not(.is-hover):not(.is-hi) { opacity: 0.45; }

#chart .end-dot { stroke: var(--paper); stroke-width: 2; }
#chart .cross { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; }
#chart .cross-dot { stroke: var(--paper); stroke-width: 1.5; }

#chart .hit { fill: none; pointer-events: all; }

@keyframes draw { to { stroke-dashoffset: 0; } }
#chart .line.draw { animation: draw 0.9s cubic-bezier(0.4, 0, 0.2, 1) forwards; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: var(--paper);
  padding: calc(var(--u) * 1.25) calc(var(--u) * 1.75);
  font-size: 13px;
  line-height: 1.5;
  min-width: 160px;
  z-index: 5;
  box-shadow: 4px 4px 0 rgba(20, 18, 14, 0.2);
}
.tooltip .tt-year {
  font-weight: 800;
  letter-spacing: 0.08em;
  border-bottom: 1px solid rgba(242, 239, 231, 0.3);
  padding-bottom: 4px;
  margin-bottom: 4px;
}
.tooltip .tt-row { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.tooltip .tt-dot { width: 10px; height: 10px; flex: none; align-self: center; }
.tooltip .tt-val { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }

/* legend */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--u);
  margin-top: calc(var(--u) * 2);
  border-top: 1px solid var(--rule-soft);
  padding-top: calc(var(--u) * 2);
}

.chip {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--rule-soft);
  border-radius: 0;
  color: var(--ink-70);
  padding: calc(var(--u) * 0.75) calc(var(--u) * 1.5);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  font-variant-numeric: tabular-nums;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip .chip-dot { width: 10px; height: 10px; background: var(--ghost); flex: none; transition: background 0.15s; }
.chip[aria-pressed="true"] { border: 2px solid var(--ink); color: var(--ink); font-weight: 700; padding: calc(var(--u) * 0.75 - 1px) calc(var(--u) * 1.5 - 1px); }
.chip .chip-val { opacity: 0.7; }

/* ranking */

.rank-row {
  display: grid;
  grid-template-columns: 24px 168px 1fr;
  align-items: center;
  gap: calc(var(--u) * 1.5);
  padding: 5px 0;
  border-bottom: 1px solid var(--rule-soft);
  cursor: pointer;
  background: transparent;
  border-left: none; border-right: none; border-top: none;
  width: 100%;
  font-family: var(--font);
  color: var(--ink);
  text-align: left;
}
.rank-row:hover { background: var(--paper-2); }

.rank-no { font-size: 12px; font-weight: 700; color: var(--ink-50); font-variant-numeric: tabular-nums; }
.rank-name { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-row.is-hi .rank-name { color: var(--acc); }
.rank-row.is-hi .rank-name.hi-2 { color: var(--c2); }

.rank-track { position: relative; height: 20px; }
.rank-zero { position: absolute; top: -4px; bottom: -4px; width: 1px; background: var(--ink-70); }
.rank-bar {
  position: absolute;
  top: 2px;
  height: 16px;
  background: var(--ink);
  border-radius: 0 4px 4px 0;
  transition: width 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), background 0.15s;
  width: 0;
}
.rank-bar.neg { border-radius: 4px 0 0 4px; }
.rank-val {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* powiaty */

.powiaty {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(var(--u) * 5);
}

.pow-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 calc(var(--u) * 1.5);
  padding-bottom: var(--u);
  border-bottom: 2px solid var(--acc);
}
.pow-title-low { border-bottom-color: var(--ink); }

.pow-list { list-style: none; margin: 0; padding: 0; counter-reset: pow; }
.pow-list li {
  counter-increment: pow;
  display: flex;
  align-items: baseline;
  gap: calc(var(--u) * 1.5);
  padding: 6px 0;
  border-bottom: 1px solid var(--rule-soft);
  font-size: 14px;
}
.pow-list li::before {
  content: counter(pow, decimal-leading-zero);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-50);
  font-variant-numeric: tabular-nums;
}
.pow-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pow-val { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- about & footer ---------- */

.about { padding: calc(var(--u) * 4) 0 calc(var(--u) * 6); }

.about-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: calc(var(--u) * 4);
}
.about-h {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 var(--u);
  color: var(--acc);
}
.about-grid p { margin: 0; font-size: 15px; color: var(--ink-70); }

.footer {
  background: var(--ink);
  color: var(--paper);
  padding: calc(var(--u) * 4) 0 calc(var(--u) * 5);
  font-size: 14px;
}
.footer a { color: var(--paper); text-decoration-color: #FF6A5E; }
.footer a:hover { color: #FF6A5E; }
.footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: calc(var(--u) * 4);
  align-items: start;
}
.footer p { margin: 0; line-height: 1.7; }
.footer-brand { font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; }
.footer-brand a { text-decoration: none; border: 2px solid var(--paper); padding: var(--u) calc(var(--u) * 2); display: inline-block; }
.footer-brand a:hover { background: var(--paper); color: var(--ink); }

/* ---------- reveal on load ---------- */

html.js .reveal { animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
html.js .reveal.r2 { animation-delay: 0.08s; }
html.js .reveal.r3 { animation-delay: 0.16s; }
html.js .reveal.r4 { animation-delay: 0.24s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .stats { grid-template-columns: 1fr; }
  .stat { border-left: none; padding-left: 0; border-top: 1px solid var(--rule-soft); padding-top: calc(var(--u) * 2); padding-bottom: calc(var(--u) * 2); }
  .stat:first-child { border-top: none; }
  .about-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .powiaty { grid-template-columns: 1fr; }
  .rank-row { grid-template-columns: 20px 108px 1fr; gap: var(--u); }
  .rank-name { font-size: 12px; }
  .rank-val { font-size: 11px; }
  .meta-row { font-size: 10px; gap: calc(var(--u) * 2); }
  .fact { max-width: none; }
  .facts-stage { min-height: calc(var(--u) * 30); }
  .tooltip { display: none; }
}

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