/* ═══════════════════════════════════════════════════════════════
   Niklas Stoehr — Cross-browser Swiss editorial + Syne display
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #f3f2ee;
  --ink: #141413;
  --mute: #74726c;
  --faint: rgba(20, 20, 19, 0.14);
  --accent: #d94626;
  --accent-soft: rgba(217, 70, 38, 0.32);
  --ink-soft: rgba(20, 20, 19, 0.14);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --display: "Syne", "Inter", -apple-system, sans-serif;
  --fs: 13.5px;
  --px: clamp(20px, 3vw, 42px);
  --bar-h: 52px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs);
  font-weight: 500;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
::selection { background: var(--ink); color: var(--bg); }

/* ───────── CURSOR: ONE FIXED ORANGE SHAPE PER PAGE (CROSS-BROWSER SAFE) ───────── */
.cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.cursor.on { opacity: 0.88; }
.cursor svg { display: block; overflow: visible; }
.cursor path {
  fill: var(--accent);
  stroke: none;
}
@media (hover: hover) and (pointer: fine) {
  body.custom-cursor, body.custom-cursor a, body.custom-cursor button { cursor: none; }
}
@media (hover: none), (pointer: coarse) {
  .cursor, .sticky-word, .pinned-layer, .pub-float-wrap { display: none !important; }
}

/* ───────── STICKY & CLICK-STAMPED WORDS ON HOME ───────── */
.held-word,
.pinned-word {
  position: fixed;
  top: 0;
  left: 0;
  font-family: var(--display);
  font-size: clamp(28px, 3.1vw, 46px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--accent);
  white-space: nowrap;
}
.sticky-word {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9998;
  pointer-events: none;
}
.held-word {
  pointer-events: none;
}

.pinned-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 40;
  pointer-events: none;
}
.pinned-word {
  pointer-events: auto;
  user-select: none;
}
.returning-word {
  transition: left 0.36s cubic-bezier(0.22, 1, 0.36, 1), top 0.36s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

/* ───────── TOLOOK-STYLE FLOATING DISTORTED PAPER FIGURE ───────── */
.pub-float-wrap {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 99;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.pub-float-wrap.show {
  visibility: visible;
  opacity: 0.96;
}
.pub-float-fig {
  display: block;
  max-width: 390px;
  max-height: 390px;
  width: auto;
  height: auto;
}

/* ───────── PURE TOP IDENTITY ───────── */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--bar-h);
  z-index: 50;
  display: flex;
  align-items: center;
  padding: 0 var(--px);
  background: var(--bg);
}
.identity {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--accent);
  transition: opacity 0.18s ease;
}
.identity:hover { opacity: 0.5; }

/* ───────── BOLD ORANGE BOTTOM BAR (HIGH-CONTRAST, NO BOX) ───────── */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bar-h);
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 var(--px);
  background: var(--accent);
  color: var(--ink);
  font-size: 13.5px;
}

.bar-primary {
  display: flex;
  align-items: center;
  gap: 30px;
}
.bar-primary a {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink);
  padding: 2px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.bar-primary a:hover {
  color: var(--bg);
}
.bar-primary a.current {
  color: var(--bg);
  border-bottom-color: var(--bg);
}

.bar-links {
  display: flex;
  align-items: center;
  gap: 20px;
  color: var(--ink);
  font-weight: 700;
}
.bar-links a {
  transition: color 0.15s ease;
}
.bar-links a:hover { color: var(--bg); }

/* ───────── MAIN STAGE (ONE-VIEWPORT ON DESKTOP, CROSS-BROWSER SAFE) ───────── */
.stage {
  height: 100vh;
  height: 100dvh;
  padding: var(--bar-h) var(--px);
  overflow: hidden;
}

.page {
  height: 100%;
  opacity: 0;
  transition: opacity 0.22s ease;
}
.page.active { opacity: 1; }
.page[hidden] { display: none !important; }

/* ───────── PAGE 1: HOME (BOLDER, BIGGER GROTESK + SYNE FLASHY ACCENTS) ───────── */
.home-layout {
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: clamp(32px, 5vw, 84px);
  padding: clamp(24px, 5vh, 60px) 0 clamp(20px, 3vh, 34px);
}

.corner-photo {
  margin: 0;
  flex: 0 0 auto;
  width: clamp(200px, 22vw, 300px);
  align-self: flex-end;
  background: var(--bg);
}
.corner-photo img {
  display: block;
  width: 100%;
  height: auto;
}

.home-copy {
  flex: 1 1 58%;
  max-width: 780px;
  align-self: flex-start;
  padding-top: clamp(24px, 8vh, 88px);
}

.bio-line {
  margin: 0 0 0.8em;
  font-family: var(--sans);
  font-size: clamp(28px, 3.1vw, 46px);
  line-height: 1.14;
  font-weight: 500;
  letter-spacing: -0.035em;
}
.bio-line:last-child { margin-bottom: 0; }

.steal-word {
  display: inline-block;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.02em;
  letter-spacing: -0.04em;
  color: var(--accent);
}
.steal-word.stolen {
  visibility: hidden;
}

/* ───────── SHARED SYNE TAB TITLE & HAIRLINE LIST ───────── */
.tab-title {
  margin: 4px 0 8px;
  font-family: var(--display);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1;
}

.dense-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--ink);
}

@media (hover: hover) and (pointer: fine) {
  .dense-list:hover > li { opacity: 0.34; }
  .dense-list:hover > li:hover { opacity: 1; }
}

/* ───────── PAGE 2: PUBLICATIONS (BIGGER & BOLDER, ALL 26 ON ONE PAGE) ───────── */
#page-publications {
  display: flex;
  flex-direction: column;
  padding: 4px 0 8px;
}

.pub-dense {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pub-row {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 48px minmax(0, 1.38fr) minmax(0, 1fr) 190px;
  align-items: center;
  gap: 16px;
  padding: 0 2px;
  border-bottom: 1px solid var(--ink);
  transition: opacity 0.16s ease, background 0.16s ease;
}
.pub-row:hover {
  background: rgba(20, 20, 19, 0.035);
}

.pub-year {
  font-family: var(--sans);
  font-size: var(--fs);
  font-weight: 500;
  color: var(--mute);
  font-variant-numeric: tabular-nums;
}

.pub-title-cell {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--sans);
  font-size: var(--fs);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.pub-title-cell a {
  display: inline;
  padding: 0 1px;
  background-image: linear-gradient(rgba(217, 70, 38, 0.42), rgba(217, 70, 38, 0.42));
  background-position: 0 84%;
  background-size: 0% 0.56em;
  background-repeat: no-repeat;
  transition: background-size 0.18s ease;
}
.pub-row:hover .pub-title-cell a {
  background-size: 100% 0.56em;
}

.pub-authors {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--sans);
  font-size: var(--fs);
  font-weight: 500;
  color: var(--mute);
}
.pub-authors b {
  color: var(--ink);
  font-weight: 700;
}

.pub-venue {
  font-family: var(--sans);
  font-size: var(--fs);
  font-weight: 500;
  color: var(--mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}

/* ───────── PAGE 3: CV (UNIFIED ROW FONT & SIZE, PURE BLACK, NO HOVER) ───────── */
#page-cv {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px 0;
}

.cv-layout {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.cv-band {
  display: flex;
  align-items: flex-start;
  gap: clamp(16px, 2.4vw, 34px);
}

/* Cross-browser 90° vertical titles at the very left side in Syne 800 */
.cv-vtitle {
  margin: 0;
  flex: 0 0 28px;
  width: 28px;
  writing-mode: vertical-rl;
  -webkit-writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
  line-height: 1;
  white-space: nowrap;
}

.cv-raw {
  flex: 1 1 auto;
  min-width: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}

.cv-item {
  display: grid;
  grid-template-columns: 36% minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 16px;
  padding: 5px 0;
  border-bottom: 1px solid var(--ink);
  font-family: var(--sans);
  font-size: clamp(18px, 1.75vw, 24px);
  font-weight: 500;
  letter-spacing: -0.026em;
  line-height: 1.2;
  color: var(--ink);
}
.cv-item:last-child {
  border-bottom: 0;
}

.cv-org {
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cv-role {
  color: var(--ink);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cv-right {
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 16px;
  font-family: var(--sans);
  font-size: clamp(18px, 1.75vw, 24px);
  font-weight: 500;
  letter-spacing: -0.026em;
  color: var(--ink);
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ───────── MOBILE (<= 820px) ───────── */
@media (max-width: 820px) {
  .stage {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
    padding: calc(var(--bar-h) + 12px) 16px 108px;
  }
  .page { height: auto; }

  .home-layout {
    height: auto;
    flex-direction: column;
    gap: 40px;
    padding: 20px 0 0;
  }
  .home-copy { order: -1; padding-top: 0; max-width: none; }
  .bio-line { font-size: clamp(24px, 7vw, 32px); }
  .corner-photo { width: min(70vw, 260px); align-self: flex-end; }

  /* Publications on mobile */
  #page-publications { display: block; padding: 0; }
  .pub-dense { height: auto; }
  .pub-row {
    flex: none;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 3px 10px;
    padding: 9px 0;
    align-items: baseline;
  }
  .pub-title-cell, .pub-authors, .pub-venue {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .pub-title-cell { font-size: 14px; line-height: 1.32; }
  .pub-authors {
    grid-column: 2;
    font-size: 12px;
    line-height: 1.4;
  }
  .pub-venue {
    grid-column: 2;
    text-align: left;
    font-size: 11px;
  }

  /* CV on mobile */
  #page-cv { display: block; padding: 0; }
  .cv-layout { gap: 22px; }
  .cv-band { gap: 12px; }
  .cv-vtitle { flex: 0 0 22px; width: 22px; font-size: 17px; }
  .cv-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 0;
    font-size: 16.5px;
  }
  .cv-org, .cv-role { text-align: left; white-space: normal; }
  .cv-right { justify-content: flex-start; font-size: 14px; text-align: left; }

  /* Bold orange bottom bar wraps cleanly on narrow mobile */
  .bottom-bar {
    height: auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    font-size: 12px;
  }
  .bar-primary { gap: 22px; }
  .bar-primary a { font-size: 18px; }
  .bar-links { flex-wrap: wrap; gap: 4px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .page { transition: none; }
}
