/* =============================================================
   janjoosten.de — main stylesheet
   Design system: editorial / academic-meets-modern
   ============================================================= */

/* ---------- TOKENS ---------- */

:root {
  /* Brand palette (light) */
  --ink:       #0f0e0c;
  --ink-2:     #2a2722;
  --paper:     #f5f2eb;
  --paper-2:   #efeae0;
  --accent:    #c8441a;
  --accent-2:  #a8381a;
  --muted:     #7a7468;
  --muted-2:   #9a948a;
  --rule:      #d4cfc4;
  --highlight: #e8e2d4;

  /* Type */
  --serif: "Playfair Display", "Iowan Old Style", Georgia, serif;
  --sans:  "DM Sans", -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono:  "DM Mono", "JetBrains Mono", ui-monospace, "SF Mono", monospace;

  /* Scale */
  --fs-xs:   0.78rem;
  --fs-sm:   0.88rem;
  --fs-base: 1rem;
  --fs-md:   1.125rem;
  --fs-lg:   1.35rem;
  --fs-xl:   2rem;
  --fs-2xl:  3rem;
  --fs-3xl:  clamp(2.6rem, 5.5vw, 5rem);
  --fs-hero: clamp(3rem, 8vw, 7rem);

  /* Spacing */
  --pad-section-y: 7rem;
  --pad-section-x: 4rem;
  --maxw: 1320px;
  --maxw-prose: 68ch;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur:  450ms;
  --dur-fast: 220ms;

  /* Effects */
  --shadow-soft: 0 18px 40px -22px rgba(15, 14, 12, 0.25);
  --shadow-deep: 0 30px 60px -28px rgba(15, 14, 12, 0.4);

  color-scheme: light;
}

[data-theme="dark"] {
  --ink:       #f2ece0;
  --ink-2:     #d5cfc2;
  --paper:     #100f0d;
  --paper-2:   #181613;
  --accent:    #e96a3a;
  --accent-2:  #f08658;
  --muted:     #8b8576;
  --muted-2:   #6c6759;
  --rule:      #2c2924;
  --highlight: #1a1814;

  --shadow-soft: 0 18px 40px -22px rgba(0, 0, 0, 0.6);
  --shadow-deep: 0 30px 60px -28px rgba(0, 0, 0, 0.8);

  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink:       #f2ece0;
    --ink-2:     #d5cfc2;
    --paper:     #100f0d;
    --paper-2:   #181613;
    --accent:    #e96a3a;
    --accent-2:  #f08658;
    --muted:     #8b8576;
    --muted-2:   #6c6759;
    --rule:      #2c2924;
    --highlight: #1a1814;
    color-scheme: dark;
  }
}

/* ---------- RESET ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, picture, svg, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ---------- BASE ---------- */

body {
  font-family: var(--sans);
  font-size: var(--fs-base);
  font-weight: 400;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  position: relative;
  overflow-x: hidden;
}

/* Subtle noise overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.4;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
[data-theme="dark"] body::before { mix-blend-mode: screen; opacity: 0.25; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body::before { mix-blend-mode: screen; opacity: 0.25; }
}

main, header, footer, section { position: relative; z-index: 2; }

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

/* ---------- TYPOGRAPHY ---------- */

h1, h2, h3, h4, h5 {
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.015em;
  color: var(--ink);
}

h1 { font-size: var(--fs-3xl); font-weight: 800; }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); font-weight: 600; }

p { max-width: var(--maxw-prose); }

.eyebrow {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
}
.eyebrow::before {
  content: "";
  width: 1.6rem;
  height: 1px;
  background: var(--accent);
}

.lead { font-size: var(--fs-md); color: var(--ink-2); max-width: 56ch; }
.muted { color: var(--muted); }
.serif-ital { font-family: var(--serif); font-style: italic; font-weight: 400; }

a.link {
  color: var(--ink);
  background-image: linear-gradient(var(--accent), var(--accent));
  background-position: 0 100%;
  background-repeat: no-repeat;
  background-size: 100% 1px;
  transition: background-size var(--dur) var(--ease), color var(--dur) var(--ease);
}
a.link:hover { background-size: 100% 2px; color: var(--accent); }

/* ---------- LAYOUT ---------- */

.shell { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--pad-section-x); }

section { padding-block: var(--pad-section-y); }
section.alt { background: var(--highlight); }

.section-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 4rem; align-items: end; margin-bottom: 4rem; }
.section-head h2 { max-width: 18ch; }

@media (max-width: 900px) {
  :root { --pad-section-y: 5rem; --pad-section-x: 1.5rem; }
  .section-head { grid-template-columns: 1fr; gap: 1.5rem; margin-bottom: 2.5rem; }
}

/* ---------- NAV ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  background: color-mix(in oklab, var(--paper) 78%, transparent);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.nav.scrolled { border-bottom-color: var(--rule); }
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding-block: 1.1rem;
}

/* Logo: wordmark by default; flip body[data-logo-style="jj"] for monogram */
.logo {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  position: relative;
}
.logo .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); display: inline-block; transform: translateY(-2px); }
.logo .mono { font-family: var(--serif); font-weight: 800; font-style: normal; }
.logo .full { display: inline; }
body[data-logo-style="jj"] .logo .full { display: none; }
body[data-logo-style="jj"] .logo .mono { font-size: 1.45rem; letter-spacing: -0.04em; }
body:not([data-logo-style="jj"]) .logo .mono { display: none; }

.nav-links { display: flex; gap: 2rem; align-items: center; }
.nav-links a {
  font-size: var(--fs-sm);
  letter-spacing: 0.02em;
  color: var(--ink-2);
  position: relative;
  padding-block: 0.3rem;
}
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  transition: right var(--dur) var(--ease);
}
.nav-links a:hover::after,
.nav-links a[aria-current="page"]::after { right: 0; }
.nav-links a[aria-current="page"] { color: var(--ink); }

.nav-tools { display: flex; align-items: center; gap: 0.75rem; }

.lang-toggle, .theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  color: var(--muted);
  transition: border-color var(--dur-fast), color var(--dur-fast), background var(--dur-fast);
}
.lang-toggle:hover, .theme-toggle:hover { border-color: var(--accent); color: var(--ink); }
.lang-toggle [aria-pressed="true"] { color: var(--accent); }
.lang-toggle button { font: inherit; padding: 0; }
.lang-toggle .sep { color: var(--muted-2); }

.theme-toggle svg { width: 14px; height: 14px; }

.menu-btn { display: none; }

@media (max-width: 820px) {
  .nav-links {
    position: fixed;
    inset: 64px 0 auto 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--paper);
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
    padding: 1.5rem var(--pad-section-x);
    transform: translateY(-110%);
    transition: transform var(--dur) var(--ease);
    z-index: 49;
  }
  .nav-links.open { transform: translateY(0); }
  .nav-links a { padding-block: 0.9rem; font-size: 1.05rem; width: 100%; border-bottom: 1px solid var(--rule); }
  .nav-links a:last-child { border-bottom: 0; }
  .menu-btn {
    display: inline-flex;
    width: 38px; height: 38px;
    border: 1px solid var(--rule);
    border-radius: 50%;
    align-items: center; justify-content: center;
  }
  .menu-btn span {
    width: 16px; height: 1px; background: var(--ink); position: relative; display: block;
    transition: transform var(--dur-fast), background var(--dur-fast);
  }
  .menu-btn span::before, .menu-btn span::after {
    content: ""; position: absolute; left: 0; width: 100%; height: 1px; background: var(--ink);
    transition: transform var(--dur-fast), top var(--dur-fast);
  }
  .menu-btn span::before { top: -5px; }
  .menu-btn span::after { top: 5px; }
  .menu-btn[aria-expanded="true"] span { background: transparent; }
  .menu-btn[aria-expanded="true"] span::before { top: 0; transform: rotate(45deg); }
  .menu-btn[aria-expanded="true"] span::after { top: 0; transform: rotate(-45deg); }
}

/* ---------- HERO ---------- */

.hero {
  padding-block: clamp(5rem, 10vw, 9rem) clamp(4rem, 8vw, 7rem);
  position: relative;
  overflow: hidden;
}
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 5rem;
  align-items: center;
}
.hero-meta { display: flex; flex-direction: column; gap: 1.6rem; }
.hero h1 {
  font-size: var(--fs-hero);
  line-height: 0.97;
  letter-spacing: -0.025em;
  font-weight: 800;
}
.hero h1 em {
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
}
.hero .lead { font-size: 1.2rem; max-width: 50ch; }
.hero-cta { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-top: 0.5rem; }

.hero-art {
  position: relative;
  aspect-ratio: 4/5;
  border-radius: 4px;
  overflow: hidden;
  background: var(--highlight);
  box-shadow: var(--shadow-deep);
}
.hero-art .frame { position: absolute; inset: 0; }
.hero-art .badge {
  position: absolute;
  bottom: 1.2rem;
  left: 1.2rem;
  right: 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--paper);
  background: color-mix(in oklab, var(--ink) 70%, transparent);
  backdrop-filter: blur(6px);
  padding: 0.6rem 0.9rem;
  border-radius: 3px;
}

.hero-marquee {
  margin-top: 5rem;
  display: flex;
  gap: 4rem;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}
.hero-marquee .item {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  display: inline-flex;
  gap: 0.6rem;
  align-items: center;
}
.hero-marquee .item strong {
  color: var(--ink);
  font-weight: 500;
  font-family: var(--sans);
  letter-spacing: normal;
  text-transform: none;
  font-size: var(--fs-sm);
}

@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; gap: 3rem; }
  .hero-art { max-width: 380px; aspect-ratio: 4/5; margin-inline: auto; }
  .hero-marquee { gap: 2rem; }
}

/* ---------- BUTTONS ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.95rem 1.5rem;
  font-family: var(--sans);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0.01em;
  border-radius: 999px;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast), box-shadow var(--dur-fast);
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-soft); }
.btn-ghost { border-color: var(--rule); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); transform: translateY(-2px); }
.btn-link {
  padding: 0;
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
  border-radius: 0;
  padding-bottom: 0.2rem;
  transition: gap var(--dur-fast) var(--ease);
}
.btn-link:hover { gap: 0.9rem; }

.btn .arrow { transition: transform var(--dur-fast) var(--ease); }
.btn:hover .arrow { transform: translateX(3px); }

/* ---------- FOCUS AREAS / CARDS ---------- */

.focus-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0;
  border-top: 1px solid var(--rule);
}
.focus-card {
  padding: 2.5rem 2rem;
  border-bottom: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  position: relative;
  transition: background var(--dur) var(--ease);
}
.focus-card:hover { background: var(--highlight); }
.focus-card .num {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--accent);
  letter-spacing: 0.16em;
}
.focus-card h3 { font-size: 1.55rem; }
.focus-card p { font-size: var(--fs-sm); color: var(--muted); }
.focus-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 0; height: 2px;
  background: var(--accent);
  transition: width var(--dur) var(--ease);
}
.focus-card:hover::before { width: 100%; }

@media (max-width: 700px) {
  .focus-card { border-right: 0; }
}

/* ---------- RESEARCH LIST ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 3rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
  align-items: center;
}
.controls .group { display: inline-flex; gap: 0; border: 1px solid var(--rule); border-radius: 999px; padding: 0.25rem; }
.controls .group button {
  padding: 0.45rem 1rem;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  border-radius: 999px;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.controls .group button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.controls .label {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.pub-year { margin-bottom: 3.5rem; }
.pub-year h3 {
  font-family: var(--mono);
  font-size: var(--fs-lg);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--accent);
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 1rem;
}
.pub {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 2rem;
  padding: 2rem 0;
  border-bottom: 1px solid var(--rule);
  align-items: start;
}
.pub-type {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 0.3rem;
}
.pub-body h4 { font-family: var(--serif); font-weight: 500; font-size: 1.45rem; line-height: 1.25; letter-spacing: -0.005em; margin-bottom: 0.6rem; }
.pub-body .authors { color: var(--ink-2); font-size: var(--fs-sm); margin-bottom: 0.3rem; }
.pub-body .venue { color: var(--muted); font-size: var(--fs-sm); font-style: italic; }
.pub-actions { display: flex; gap: 1rem; margin-top: 1rem; flex-wrap: wrap; }
.pub-actions button, .pub-actions a {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  transition: border-color var(--dur-fast), color var(--dur-fast), background var(--dur-fast);
  display: inline-flex; gap: 0.4rem; align-items: center;
}
.pub-actions button:hover, .pub-actions a:hover { border-color: var(--accent); color: var(--accent); }
.pub-abstract {
  display: none;
  font-size: var(--fs-sm);
  color: var(--ink-2);
  margin-top: 1.2rem;
  padding: 1rem 1.3rem;
  background: var(--highlight);
  border-left: 2px solid var(--accent);
  border-radius: 2px;
  max-width: 80ch;
}
.pub.expanded .pub-abstract { display: block; }
.pub.hidden { display: none; }

@media (max-width: 700px) {
  .pub { grid-template-columns: 1fr; gap: 0.6rem; }
  .pub-type { padding-top: 0; }
}

/* ---------- ABOUT ---------- */

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 5rem;
  align-items: start;
}
.about-portrait {
  position: sticky;
  top: 110px;
  aspect-ratio: 4/5;
  background: var(--highlight);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--shadow-deep);
}
.about-portrait .frame { position: absolute; inset: 0; }
.about-prose p { font-size: var(--fs-md); color: var(--ink-2); margin-bottom: 1.4rem; max-width: 64ch; }
.about-prose p.first::first-letter {
  font-family: var(--serif);
  font-size: 4.2rem;
  float: left;
  line-height: 0.9;
  padding: 0.4rem 0.6rem 0 0;
  color: var(--accent);
  font-weight: 800;
}
.mantra {
  margin: 3rem 0;
  padding: 2rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.7rem;
  line-height: 1.3;
  color: var(--ink);
  text-align: center;
}
.mantra::before { content: "“"; color: var(--accent); margin-right: 0.2rem; }
.mantra::after { content: "”"; color: var(--accent); margin-left: 0.2rem; }

.timeline { display: grid; gap: 1.5rem; margin-top: 2.5rem; }
.timeline-item {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 1.5rem;
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--rule);
}
.timeline-item .when { font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: 0.1em; color: var(--accent); padding-top: 0.3rem; }
.timeline-item .what strong { display: block; font-family: var(--serif); font-size: 1.15rem; font-weight: 500; margin-bottom: 0.2rem; }
.timeline-item .what span { font-size: var(--fs-sm); color: var(--muted); }

@media (max-width: 900px) {
  .about-grid { grid-template-columns: minmax(0, 1fr); gap: 3rem; }
  .about-portrait { position: static; max-width: 380px; margin-inline: auto; }
  /* Stack timeline rows on mobile — fixed 130px label column + long unbreakable phrases force overflow */
  .timeline-item { grid-template-columns: 1fr; gap: 0.4rem; }
  .timeline-item .when { padding-top: 0; }
}

/* ---------- CONTACT ---------- */

.contact-cta {
  text-align: center;
  padding-block: clamp(5rem, 10vw, 9rem);
  background: var(--ink);
  color: var(--paper);
}
[data-theme="dark"] .contact-cta { background: var(--paper-2); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .contact-cta { background: var(--paper-2); }
}
.contact-cta h2 { color: var(--paper); font-size: var(--fs-3xl); max-width: 18ch; margin: 0 auto; }
[data-theme="dark"] .contact-cta h2 { color: var(--ink); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .contact-cta h2 { color: var(--ink); }
}
.contact-cta h2 em { font-style: italic; color: var(--accent); }
.contact-cta p { color: color-mix(in oklab, var(--paper) 70%, transparent); margin: 1.5rem auto 2.5rem; max-width: 50ch; }
.contact-cta .btn-primary { background: var(--paper); color: var(--ink); }
.contact-cta .btn-primary:hover { background: var(--accent); color: var(--paper); }

/* Form */
.form-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 2.5rem;
  max-width: 640px;
  margin: 0 auto;
}
.form-row { display: grid; gap: 1.2rem; margin-bottom: 1.2rem; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 600px) { .form-row.cols-2 { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field label {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input, .field textarea, .field select {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 0.7rem 0;
  font-size: var(--fs-base);
  font-family: var(--sans);
  color: var(--ink);
  outline: none;
  transition: border-color var(--dur-fast);
  border-radius: 0;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 130px; }
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 2rem; }

.consent { display: flex; gap: 0.7rem; align-items: flex-start; font-size: var(--fs-sm); color: var(--muted); margin: 1.4rem 0; }
.consent input { margin-top: 0.25rem; accent-color: var(--accent); }
.honeypot { position: absolute; left: -9999px; top: -9999px; opacity: 0; pointer-events: none; height: 0; width: 0; }

.form-status { display: none; padding: 1rem; border-radius: 4px; margin-bottom: 1rem; font-size: var(--fs-sm); }
.form-status.ok { display: block; background: color-mix(in oklab, var(--accent) 12%, transparent); border-left: 3px solid var(--accent); color: var(--ink); }
.form-status.err { display: block; background: color-mix(in oklab, #d62828 14%, transparent); border-left: 3px solid #d62828; color: var(--ink); }

/* ---------- MODAL ---------- */

.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal.open { display: flex; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in oklab, var(--ink) 60%, transparent);
  backdrop-filter: blur(4px);
  animation: fadeIn 220ms var(--ease);
}
.modal-card {
  position: relative;
  background: var(--paper);
  max-width: 640px;
  width: 100%;
  border-radius: 4px;
  padding: 2.5rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  box-shadow: var(--shadow-deep);
  animation: slideUp 380ms var(--ease);
}
.modal-close {
  position: absolute;
  top: 1rem; right: 1rem;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { border-color: var(--accent); color: var(--accent); }
.modal h3 { font-family: var(--serif); font-size: 1.8rem; margin-bottom: 0.5rem; }
.modal .lead { font-size: var(--fs-sm); margin-bottom: 1.5rem; }

/* ---------- FOOTER ---------- */

.footer {
  border-top: 1px solid var(--rule);
  padding-block: 4rem 2rem;
  font-size: var(--fs-sm);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 3rem;
  margin-bottom: 3rem;
}
.footer h5 {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
}
.footer ul li { margin-bottom: 0.5rem; }
.footer ul a { color: var(--ink-2); transition: color var(--dur-fast); }
.footer ul a:hover { color: var(--accent); }
.footer-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  flex-wrap: wrap;
  gap: 1rem;
}
.footer-tagline {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-2);
  max-width: 30ch;
  margin-top: 1rem;
}
.socials { display: flex; gap: 0.7rem; }
.socials a {
  width: 38px; height: 38px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color var(--dur-fast), color var(--dur-fast), transform var(--dur-fast);
  color: var(--ink-2);
}
.socials a:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
.socials svg { width: 16px; height: 16px; }

@media (max-width: 800px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 2rem; }
  .footer-meta { flex-direction: column; align-items: flex-start; }
}

/* ---------- COOKIE BANNER (DIY fallback) ---------- */

.cookie {
  position: fixed;
  left: 1.5rem;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 90;
  background: var(--ink);
  color: var(--paper);
  padding: 1.4rem 1.6rem;
  border-radius: 4px;
  display: none;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: space-between;
  box-shadow: var(--shadow-deep);
  max-width: 720px;
  margin-inline: auto;
  animation: slideUp 480ms var(--ease) 1.2s both;
}
.cookie.show { display: flex; }
.cookie p { font-size: var(--fs-sm); color: color-mix(in oklab, var(--paper) 80%, transparent); margin: 0; max-width: 42ch; }
.cookie p a { color: var(--paper); text-decoration: underline; }
.cookie .actions { display: flex; gap: 0.6rem; }
.cookie button {
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.cookie .accept { background: var(--accent); color: var(--paper); }
.cookie .reject { border: 1px solid color-mix(in oklab, var(--paper) 40%, transparent); color: var(--paper); }
.cookie .accept:hover { background: var(--paper); color: var(--ink); }

/* ---------- LEGAL PAGES ---------- */

.legal { padding-block: 6rem 5rem; }
.legal h1 { margin-bottom: 0.5rem; }
.legal .updated { font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; margin-bottom: 3rem; }
.legal h2 { font-size: 1.6rem; margin-top: 3rem; margin-bottom: 1rem; }
.legal h3 { font-size: 1.2rem; font-family: var(--sans); font-weight: 500; margin-top: 2rem; margin-bottom: 0.5rem; }
.legal p, .legal li { font-size: var(--fs-md); color: var(--ink-2); max-width: 70ch; margin-bottom: 0.8rem; }
.legal ul { padding-left: 1.4rem; list-style: disc; }
.legal a { color: var(--accent); border-bottom: 1px solid currentColor; }

.lawyer-note {
  margin: 2rem 0;
  padding: 1.2rem 1.4rem;
  background: var(--highlight);
  border-left: 2px solid var(--accent);
  font-size: var(--fs-sm);
  font-family: var(--mono);
  color: var(--ink-2);
}

/* ---------- 404 ---------- */

.notfound {
  min-height: 80vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding-block: 6rem;
}
.notfound .code { font-family: var(--serif); font-weight: 800; font-size: clamp(8rem, 18vw, 14rem); line-height: 1; color: var(--accent); letter-spacing: -0.04em; }
.notfound h1 { margin-block: 0.5rem 1rem; }
.notfound p { margin: 0 auto 2rem; max-width: 40ch; color: var(--muted); }

/* ---------- REVEAL ANIMATIONS ---------- */

.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 700ms var(--ease), transform 700ms var(--ease);
  will-change: opacity, transform;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.hero-meta > * { opacity: 0; animation: fadeUp 800ms var(--ease) forwards; }
.hero-meta > *:nth-child(1) { animation-delay: 80ms; }
.hero-meta > *:nth-child(2) { animation-delay: 200ms; }
.hero-meta > *:nth-child(3) { animation-delay: 320ms; }
.hero-meta > *:nth-child(4) { animation-delay: 440ms; }
.hero-art { opacity: 0; animation: fadeUp 900ms var(--ease) 280ms forwards; }
.hero-marquee { opacity: 0; animation: fadeUp 800ms var(--ease) 600ms forwards; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- MOBILE IMPROVEMENTS (bilingual EN/DE) ---------- */

/* Long German compounds + long unbreakable English phrases ("Three Essays on AI Applications…")
   both push containers wider than the viewport on phones. */
h1, h2, h3, h4, .mantra, .pub-body h4, .focus-card h3 {
  overflow-wrap: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.about-prose p, .timeline-item .what, .pub-body .authors, .pub-body .venue,
.legal p, .legal li {
  overflow-wrap: break-word;
}
:lang(de) h1, :lang(de) h2,
:lang(de) .about-prose p,
:lang(de) .legal p { hyphens: auto; -webkit-hyphens: auto; }

/* Contact page: collapse two-column layout on mobile (was inline-styled) */
.contact-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 4rem;
  align-items: start;
}
@media (max-width: 820px) {
  .contact-layout { grid-template-columns: 1fr; gap: 2.5rem; }
}

@media (max-width: 820px) {
  /* Reclaim horizontal space in nav-bar so logo + tools + menu fit ≤ 380px */
  .nav-inner { gap: 0.75rem; padding-block: 0.85rem; }
  .nav-tools { gap: 0.4rem; }
  .lang-toggle { padding: 0.4rem 0.6rem; gap: 0.3rem; }
  .theme-toggle { padding: 0.4rem 0.5rem; }
  /* Touch-target compliance (≥ 44px tap area without bloating visual size) */
  .menu-btn { width: 44px; height: 44px; }
  .modal-close { width: 44px; height: 44px; }
  /* Sticky-menu offset must follow the new nav height */
  .nav-links { inset: 56px 0 auto 0; }
}

@media (max-width: 700px) {
  /* Filter pill on research.html holds 6 buttons — must wrap on mobile, otherwise it overflows by 200–330px */
  .controls .group { flex-wrap: wrap; border-radius: 14px; padding: 0.35rem; gap: 0.25rem; }
  .controls .group button { border-radius: 999px; }
}

@media (max-width: 480px) {
  /* Fewer focus-card columns so 320px viewports don't overflow the 280px minmax */
  .focus-grid { grid-template-columns: 1fr; }
  /* Hero CTAs: allow wrap so DE "Lass uns zusammenarbeiten" doesn't push past edge */
  .btn { white-space: normal; text-align: center; }
  .hero-cta { width: 100%; }
  .hero-cta .btn { width: 100%; justify-content: center; }
  /* Tighter modal padding on phones */
  .modal-card { padding: 1.5rem 1.25rem; max-height: calc(100dvh - 1rem); }
  .modal h3 { font-size: 1.45rem; }
  /* Hero typography: looser tracking helps narrow DE words breathe */
  .hero h1 { letter-spacing: -0.015em; }
  .mantra { font-size: 1.35rem; padding: 1.5rem 0; margin: 2rem 0; }
  /* Footer collapses fully on small phones */
  .footer-grid { grid-template-columns: 1fr; gap: 1.75rem; }
  /* Center the about portrait when grid is single-column */
  .about-portrait { margin-inline: auto; }
  /* Cookie banner: tighter padding, stack actions */
  .cookie { padding: 1rem 1.1rem; gap: 1rem; left: 0.75rem; right: 0.75rem; bottom: 0.75rem; }
  .cookie .actions { width: 100%; justify-content: stretch; }
  .cookie .actions button { flex: 1; }
  /* Pub layout on tiny phones — tighter rhythm */
  .pub { padding: 1.5rem 0; }
  .pub-body h4 { font-size: 1.2rem; }
  /* Hero marquee — single-column stack reads cleaner than wrapped flex */
  .hero-marquee { gap: 1rem; flex-direction: column; align-items: flex-start; }
}

/* Allow the nav action buttons to remain selectable when EN/DE pill is small */
.lang-toggle button { min-height: 32px; padding-inline: 0.15rem; }

/* About portrait: prevent the sticky position from glitching on mobile when section padding shrinks */
@media (max-width: 900px) {
  .about-portrait { width: 100%; max-width: 360px; }
}

/* Skip-link must clear the sticky nav when focused */
.skip-link { top: 0.75rem; }

/* ---------- UTIL ---------- */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 1rem; top: 1rem;
  background: var(--ink); color: var(--paper);
  padding: 0.5rem 1rem; border-radius: 4px;
  transform: translateY(-200%); transition: transform var(--dur-fast);
  z-index: 200;
}
.skip-link:focus { transform: translateY(0); }

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