/* ============================================================
   pbiecek.github.io — design system
   Modern academic. Light + dark. No build step.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --bg:            #fcfcfb;
  --bg-tint:       #f6f6f4;
  --surface:       #ffffff;
  --surface-2:     #f4f4f2;
  --border:        #e5e5e1;
  --border-strong: #d3d3ce;
  --text:          #14161a;
  --text-2:        #4b515c;
  --text-3:        #656c78;
  --accent:        #0d6a78;
  --accent-hover:  #0a545f;
  --accent-soft:   rgba(13, 106, 120, 0.08);
  --accent-line:   rgba(13, 106, 120, 0.22);
  --warm:          #9a6b1f;
  --warm-soft:     rgba(154, 107, 31, 0.10);
  --shadow-sm:     0 1px 2px rgba(20, 22, 26, 0.04), 0 1px 3px rgba(20, 22, 26, 0.04);
  --shadow-md:     0 2px 4px rgba(20, 22, 26, 0.04), 0 8px 24px rgba(20, 22, 26, 0.06);

  --font-display: "Newsreader", ui-serif, Georgia, "Times New Roman", serif;
  --font-body:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono:    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --w-page:  1120px;
  --w-text:  680px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;

  --ease: cubic-bezier(0.2, 0, 0, 1);
}

html[data-theme="dark"] {
  --bg:            #0c0e11;
  --bg-tint:       #101317;
  --surface:       #14171b;
  --surface-2:     #1a1e23;
  --border:        #24292f;
  --border-strong: #333a43;
  --text:          #eceef1;
  --text-2:        #a4abb6;
  --text-3:        #8a919e;
  --accent:        #56c3d2;
  --accent-hover:  #7dd4e0;
  --accent-soft:   rgba(86, 195, 210, 0.10);
  --accent-line:   rgba(86, 195, 210, 0.26);
  --warm:          #d6a441;
  --warm-soft:     rgba(214, 164, 65, 0.12);
  --shadow-sm:     0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md:     0 2px 4px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 0;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16.5px;
  line-height: 1.65;
  font-feature-settings: "kern" 1, "liga" 1, "cv02" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease);
}

img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
a { color: inherit; }

::selection { background: var(--accent-soft); color: var(--text); }

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

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--text);
  text-wrap: balance;
}
h1 { font-size: clamp(2.1rem, 1.3rem + 3.2vw, 3.5rem); }
h2 { font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.15rem); }
h3 { font-size: 1.2rem; font-family: var(--font-body); font-weight: 600; letter-spacing: -0.01em; }
h4 { font-size: 1rem;   font-family: var(--font-body); font-weight: 600; letter-spacing: 0; }

p { text-wrap: pretty; }
.lead {
  font-size: clamp(1.05rem, 0.98rem + 0.35vw, 1.22rem);
  line-height: 1.62;
  color: var(--text-2);
}

.eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--accent);
  font-family: var(--font-body);
}

.muted { color: var(--text-2); }
.small { font-size: 0.9rem; }
.tiny  { font-size: 0.8rem; color: var(--text-3); }

/* ---------- Layout ---------- */
.wrap {
  width: 100%;
  max-width: var(--w-page);
  margin-inline: auto;
  padding-inline: 24px;
}
@media (max-width: 640px) { .wrap { padding-inline: 18px; } }

.prose { max-width: var(--w-text); }
.prose p + p { margin-top: 1em; }

section { padding-block: clamp(48px, 6vw, 88px); }
section.tinted { background: var(--bg-tint); border-block: 1px solid var(--border); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 28px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.section-head .eyebrow { margin-bottom: 6px; display: block; }

/* ---------- Header / nav ---------- */
.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff; padding: 10px 16px; z-index: 200;
  border-radius: 0 0 var(--r-sm) 0;
}
.skip:focus { left: 0; }

.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.site-header.is-stuck { border-bottom-color: var(--border); }

.nav {
  display: flex; align-items: center; gap: 18px;
  height: 62px;
}
.brand {
  font-family: var(--font-display);
  font-size: 1.06rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  text-decoration: none;
  white-space: nowrap;
  margin-right: auto;
}
.brand span { color: var(--text-3); font-size: 0.82rem; font-family: var(--font-body); margin-left: 9px; letter-spacing: 0; }
@media (max-width: 860px) { .brand span { display: none; } }

.nav-links { display: flex; gap: 4px; align-items: center; }
.nav-links a {
  text-decoration: none;
  color: var(--text-2);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 7px 11px;
  border-radius: var(--r-sm);
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
  white-space: nowrap;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); }
.nav-links a[aria-current] { color: var(--accent); background: var(--accent-soft); }

.icon-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all 0.15s var(--ease);
  flex: none;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 16px; height: 16px; }
html[data-theme="dark"] .icon-sun { display: block; }
html[data-theme="dark"] .icon-moon { display: none; }
.icon-sun { display: none; }
.icon-moon { display: block; }

.nav-toggle { display: none; }
@media (max-width: 780px) {
  .nav-toggle { display: grid; }
  .nav-links {
    position: absolute; top: 62px; left: 0; right: 0;
    flex-direction: column; align-items: stretch;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 18px 16px;
    gap: 2px;
    box-shadow: var(--shadow-md);
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 11px 12px; font-size: 1rem; }
}

/* ---------- Hero ---------- */
.hero { padding-top: clamp(44px, 5vw, 76px); padding-bottom: clamp(36px, 4vw, 60px); }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: clamp(28px, 5vw, 64px);
  align-items: start;
}
@media (max-width: 860px) {
  /* Headline first on small screens; portrait + affiliations follow the intro. */
  .hero-grid { grid-template-columns: 1fr; gap: 34px; }
  .hero-aside {
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
    padding-top: 26px;
    border-top: 1px solid var(--border);
  }
  .hero-aside .affil { margin-top: 0; }
}
@media (max-width: 460px) {
  .hero-aside { grid-template-columns: 1fr; }
}

.hero h1 { margin-bottom: 20px; }
.hero .lead + .lead { margin-top: 14px; }

.portrait {
  width: 100%;
  max-width: 260px;
  aspect-ratio: 4 / 5;   /* matches the 200×250 source, so nothing is cropped */
  object-fit: cover;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface-2);
  box-shadow: var(--shadow-md);
}
@media (max-width: 860px) { .portrait { max-width: 132px; } }
@media (max-width: 460px) { .portrait { max-width: 150px; } }

.hero-aside .affil {
  margin-top: 18px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-2);
}
.hero-aside .affil strong { color: var(--text); font-weight: 600; }
.hero-aside .affil li { list-style: none; padding-left: 13px; position: relative; margin-bottom: 9px; }
.hero-aside .affil li::before {
  content: ""; position: absolute; left: 0; top: 0.62em;
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent-line);
}
.hero-aside ul { padding: 0; }

/* ---------- Buttons & links ---------- */
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 17px;
  font-size: 0.9rem; font-weight: 550;
  border-radius: var(--r-sm);
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: all 0.16s var(--ease);
  white-space: nowrap;
}
.btn:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
html[data-theme="dark"] .btn-primary { color: #06171a; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn svg { width: 15px; height: 15px; flex: none; }

.link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-line);
  transition: border-color 0.15s var(--ease);
}
.link:hover { border-bottom-color: var(--accent); }

.arrow-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--accent); text-decoration: none;
  font-size: 0.9rem; font-weight: 550;
}
.arrow-link::after { content: "→"; transition: transform 0.18s var(--ease); }
.arrow-link:hover::after { transform: translateX(3px); }

/* ---------- Social row ---------- */
.socials { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 22px; }
.socials a {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.8rem; font-weight: 500;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 100px;
  text-decoration: none;
  color: var(--text-2);
  transition: all 0.15s var(--ease);
}
.socials a:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.socials svg { width: 13px; height: 13px; }

/* ---------- Metrics ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
@media (max-width: 700px) { .metrics { grid-template-columns: repeat(2, 1fr); } }
.metric { background: var(--surface); padding: 20px 18px; }
.metric dt {
  font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3); font-weight: 600; margin-bottom: 5px;
}
.metric dd {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 1.2rem + 1.2vw, 2.05rem);
  font-weight: 500; letter-spacing: -0.02em; margin: 0;
  font-variant-numeric: tabular-nums;
}

/* ---------- Cards ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 940px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 22px;
  transition: border-color 0.18s var(--ease), transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
a.card { text-decoration: none; display: block; }
a.card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card h3 { margin-bottom: 8px; }
.card p { color: var(--text-2); font-size: 0.93rem; line-height: 1.6; }

.pillar { position: relative; padding-top: 26px; }
.pillar .num {
  position: absolute; top: 20px; right: 20px;
  font-family: var(--font-mono); font-size: 0.72rem;
  color: var(--text-3); letter-spacing: 0.06em;
}
.pillar .verb {
  font-family: var(--font-display);
  font-size: 1.45rem; font-weight: 500; letter-spacing: -0.02em;
  color: var(--accent);
  display: block; margin-bottom: 4px;
}
.pillar .q { font-size: 0.88rem; color: var(--text-3); font-style: italic; margin-bottom: 10px; }

/* ---------- Tags ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  font-size: 0.71rem; font-weight: 600; letter-spacing: 0.02em;
  padding: 2.5px 8px;
  border-radius: 100px;
  background: var(--surface-2);
  color: var(--text-3);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.tag-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.tag-warm   { background: var(--warm-soft);   color: var(--warm);   border-color: transparent; }

/* ---------- Publication list ---------- */
.pubs { list-style: none; padding: 0; }
.pub {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 20px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}
.pub:first-child { border-top: 1px solid var(--border); }
@media (max-width: 640px) {
  .pub { grid-template-columns: 1fr; gap: 6px; }
}
.pub-year {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-3);
  padding-top: 3px;
  font-variant-numeric: tabular-nums;
}
.pub-title {
  font-size: 1rem; font-weight: 550; line-height: 1.45;
  text-decoration: none; color: var(--text);
  transition: color 0.15s var(--ease);
  display: inline-block;
}
a.pub-title:hover { color: var(--accent); }
.pub-meta { font-size: 0.87rem; color: var(--text-2); margin-top: 4px; }
.pub-venue { font-weight: 600; color: var(--text-2); }
.pub-badge {
  display: inline-block; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--warm); background: var(--warm-soft);
  padding: 1px 6px; border-radius: 3px; margin-left: 6px;
  vertical-align: 1px;
}
.pub .tags { margin-top: 8px; }

/* filter bar */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 22px; }
.filter {
  font-size: 0.83rem; font-weight: 550;
  padding: 5px 13px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s var(--ease);
  font-family: inherit;
}
.filter:hover { border-color: var(--border-strong); color: var(--text); }
.filter[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
html[data-theme="dark"] .filter[aria-pressed="true"] { color: #06171a; }

/* ---------- Software / books ---------- */
.soft {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  padding: 16px 0; border-bottom: 1px solid var(--border);
}
@media (max-width: 560px) { .soft { grid-template-columns: 1fr; gap: 4px; } }
.soft:first-child { border-top: 1px solid var(--border); }
.soft-name {
  padding-top: 1px;
  font-family: var(--font-mono); font-size: 0.9rem; font-weight: 600;
  color: var(--accent); text-decoration: none;
  white-space: normal; overflow-wrap: anywhere; line-height: 1.4;
}
.soft-name:hover { text-decoration: underline; }
.soft-body { min-width: 0; }
.soft-body p { font-size: 0.9rem; color: var(--text-2); margin-top: 2px; }

.book-card { display: flex; flex-direction: column; height: 100%; }
.book-card .year {
  font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-3);
  margin-bottom: 8px; display: block;
}
.book-card h3 { font-family: var(--font-display); font-weight: 500; font-size: 1.15rem; letter-spacing: -0.015em; }
.book-card .btn-row { margin-top: auto; padding-top: 14px; }

/* ---------- News / timeline ---------- */
.news { list-style: none; padding: 0; }
.news li {
  display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 18px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
.news li:first-child { border-top: 1px solid var(--border); }
@media (max-width: 640px) { .news li { grid-template-columns: 1fr; gap: 3px; } }
.news .when {
  font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-3);
  padding-top: 3px; white-space: nowrap;
}
.news .what { color: var(--text-2); }
.news .what strong { color: var(--text); font-weight: 600; }

/* ---------- People ---------- */
.people { display: flex; flex-wrap: wrap; gap: 8px; }
.person {
  display: inline-flex; align-items: baseline; gap: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 0.88rem;
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s var(--ease);
}
.person:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.person em { font-style: normal; font-size: 0.76rem; color: var(--text-3); }

/* ---------- Quote ---------- */
.quote {
  border-left: 2px solid var(--accent);
  padding: 6px 0 6px 22px;
  margin: 30px 0;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 1.05rem + 0.85vw, 1.7rem);
  line-height: 1.35;
  letter-spacing: -0.015em;
  color: var(--text);
}

/* ---------- Table (teaching) ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.tbl th {
  text-align: left; font-weight: 600; font-size: 0.75rem;
  letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3);
  padding: 0 14px 10px 0; border-bottom: 1px solid var(--border);
}
.tbl td { padding: 12px 14px 12px 0; border-bottom: 1px solid var(--border); vertical-align: top; color: var(--text-2); }
.tbl td:first-child { color: var(--text); font-weight: 500; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .yrs { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-3); white-space: nowrap; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-tint);
  padding-block: 40px 32px;
  margin-top: 20px;
}
.footer-grid {
  display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 32px;
}
@media (max-width: 780px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }
.site-footer h4 { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); margin-bottom: 12px; }
.site-footer ul { list-style: none; padding: 0; }
.site-footer li { margin-bottom: 7px; }
.site-footer a { color: var(--text-2); text-decoration: none; font-size: 0.9rem; }
.site-footer a:hover { color: var(--accent); }
.footer-bottom {
  margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  font-size: 0.82rem; color: var(--text-3);
}

/* ---------- Reveal ---------- */
.reveal { opacity: 0; transform: translateY(10px); }
.reveal.in { opacity: 1; transform: none; transition: opacity 0.5s var(--ease), transform 0.5s var(--ease); }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } }

/* ---------- Print ---------- */
@media print {
  .site-header, .site-footer, .btn-row, .socials, .filters { display: none !important; }
  .reveal { opacity: 1 !important; transform: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .card { break-inside: avoid; border-color: #ccc; }
  a { text-decoration: none; color: #000; }
}


/* ---------- Single-page additions ---------- */

/* Section anchors clear the sticky header. scroll-margin (not scroll-padding)
   so the offset applies to fragment links and scrollIntoView alike, and the two
   never stack. */
section[id] { scroll-margin-top: 76px; }

/* Back-to-top */
.to-top {
  position: fixed;
  right: 22px; bottom: 22px;
  z-index: 90;
  display: grid; place-items: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.15s var(--ease);
}
.to-top:hover { color: var(--accent); border-color: var(--accent-line); transform: translateY(-2px); }
.to-top svg { width: 17px; height: 17px; }
.to-top[hidden] { display: none; }
@media (max-width: 640px) { .to-top { right: 14px; bottom: 14px; } }
@media print { .to-top { display: none !important; } }

/* Six nav items need slightly tighter padding on narrow desktops. */
@media (min-width: 781px) and (max-width: 940px) {
  .nav-links a { padding: 7px 8px; font-size: 0.88rem; }
}
