/* ---------------------------------------------------------------
   Maximilian Haensch — single-page academic site
   Plain CSS, no build step.
   --------------------------------------------------------------- */

:root {
  --bg:            #fbfbfa;
  --bg-elev:       #ffffff;
  --text:          #1c1c1a;
  --text-muted:    #6b6b66;
  --text-faint:    #71716b;
  --rule:          #e4e4e0;
  --accent:        #7a5c3e;
  --accent-soft:   rgba(122, 92, 62, 0.10);
  --nav-bg:        rgba(251, 251, 250, 0.72);

  --measure:       68ch;
  --shell:         920px;
  --gutter:        clamp(1.25rem, 5vw, 3rem);

  --ease:          cubic-bezier(0.22, 1, 0.36, 1);
  --dur:           .5s;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg:            #111110;
  --bg-elev:       #1a1a18;
  --text:          #eceae5;
  --text-muted:    #a3a29c;
  --text-faint:    #8a8983;
  --rule:          #2c2c29;
  --accent:        #c8a87e;
  --accent-soft:   rgba(200, 168, 126, 0.13);
  --nav-bg:        rgba(17, 17, 16, 0.72);

  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #111110;
    --bg-elev:     #1a1a18;
    --text:        #eceae5;
    --text-muted:  #a3a29c;
    --text-faint:  #8a8983;
    --rule:        #2c2c29;
    --accent:      #c8a87e;
    --accent-soft: rgba(200, 168, 126, 0.13);
    --nav-bg:      rgba(17, 17, 16, 0.72);

    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------
   Base
   --------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  /* keep anchored headings clear of the sticky nav */
  scroll-padding-top: 6rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Source Serif 4",
               Charter, Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 0.95rem + 0.2vw, 1.125rem);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

img { max-width: 100%; height: auto; display: block; }

a {
  color: inherit;
  text-decoration: none;
}

/* Understated underline that grows on hover */
.prose a,
.lede a,
.meta a {
  color: var(--text);
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 1px;
  padding-bottom: 1px;
  transition: background-size .35s var(--ease), color .35s var(--ease);
}
.prose a:hover,
.lede a:hover,
.meta a:hover {
  color: var(--accent);
  background-size: 100% 2px;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--bg-elev);
  padding: .75rem 1rem;
  border: 1px solid var(--rule);
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* ---------------------------------------------------------------
   Scroll progress
   --------------------------------------------------------------- */

.progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  z-index: 60;
  pointer-events: none;
}
.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transform-origin: 0 50%;
}

/* ---------------------------------------------------------------
   Navigation
   --------------------------------------------------------------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur) var(--ease),
              background-color var(--dur) var(--ease);
}
.nav.is-stuck { border-bottom-color: var(--rule); }

.nav-inner {
  max-width: var(--shell);
  margin-inline: auto;
  padding: 0 var(--gutter);
  height: 4.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-brand {
  font-size: .95rem;
  letter-spacing: .01em;
  font-weight: 600;
  margin-right: auto;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  pointer-events: none;
}
.nav.is-stuck .nav-brand {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.nav-links {
  position: relative;
  display: flex;
  gap: clamp(.75rem, 2.5vw, 1.75rem);
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: .8125rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.nav-links a {
  color: var(--text-muted);
  padding: .35rem 0;
  transition: color .3s var(--ease);
  white-space: nowrap;
}
.nav-links a:hover { color: var(--text); }
.nav-links a.is-active { color: var(--text); }

/* Sliding underline that follows the active section */
.nav-indicator {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 1px;
  width: 0;
  background: var(--accent);
  opacity: 0;
  transform: translateX(0);
  transition: transform .45s var(--ease), width .45s var(--ease), opacity .3s var(--ease);
}
.nav-indicator.is-visible { opacity: 1; }

.theme-toggle {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .3s var(--ease), border-color .3s var(--ease), background-color .3s var(--ease);
}
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--text-faint);
  background: var(--accent-soft);
}
.theme-toggle svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  overflow: visible;
}
.theme-toggle .sun-core {
  transition: r .45s var(--ease), fill .45s var(--ease);
  fill: transparent;
}
.theme-toggle .sun-rays {
  transform-origin: 12px 12px;
  transition: opacity .35s var(--ease), transform .55s var(--ease);
}
/* In dark mode the sun collapses into a crescent-ish dot, rays fade out */
:root[data-theme="dark"] .theme-toggle .sun-core { r: 7; fill: currentColor; }
:root[data-theme="dark"] .theme-toggle .sun-rays { opacity: 0; transform: rotate(45deg) scale(.5); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun-core { r: 7; fill: currentColor; }
  :root:not([data-theme="light"]) .theme-toggle .sun-rays { opacity: 0; transform: rotate(45deg) scale(.5); }
}

@media (max-width: 40rem) {
  .nav-brand { display: none; }
  .nav-inner { gap: .75rem; }

  /* Too many links to fit a phone: let the strip scroll sideways on its own
     rather than widening the page. The toggle stays pinned. */
  .nav-links {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
    gap: 1rem;
    font-size: .6875rem;
    letter-spacing: .04em;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links a { flex-shrink: 0; }
}

/* ---------------------------------------------------------------
   Hero
   --------------------------------------------------------------- */

.hero {
  position: relative;
  /* vh first: browsers without svh (Safari < 15.4) drop the whole
     declaration as invalid, so they need a unit they understand. */
  min-height: calc(100vh - 4.25rem);
  min-height: calc(100svh - 4.25rem);
  display: grid;
  place-items: center;
  padding: clamp(3rem, 9vh, 7rem) var(--gutter) 7rem;
}

.hero-inner {
  max-width: var(--shell);
  width: 100%;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}

.portrait {
  margin: 0;
  width: 200px;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-elev);
  box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 12px 40px -18px rgba(0,0,0,.35);
}
.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .9s var(--ease), filter .6s var(--ease);
}
.portrait:hover img { transform: scale(1.04); }

h1 {
  margin: 0 0 .6rem;
  font-size: clamp(2.1rem, 1.4rem + 3.4vw, 3.5rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-weight: 500;
}

.lede {
  margin: 0 0 1.5rem;
  max-width: 46ch;
  color: var(--text-muted);
  font-size: clamp(1.02rem, 0.98rem + 0.25vw, 1.2rem);
}

.meta {
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.5rem;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: .875rem;
  color: var(--text-muted);
}
.meta li { display: flex; align-items: center; gap: .5rem; }
.meta svg {
  width: 15px; height: 15px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
  color: var(--text-faint);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: .625rem;
}

/* Buttons that follow a paragraph need breathing room. In the hero the
   buttons follow .meta, which already carries its own bottom margin. */
.prose + .actions { margin-top: 1.75rem; }

.btn {
  --btn-border: var(--rule);
  display: inline-flex;
  align-items: center;
  padding: .5rem 1.05rem;
  border: 1px solid var(--btn-border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: .8125rem;
  letter-spacing: .03em;
  transition: transform .3s var(--ease), color .3s var(--ease),
              border-color .3s var(--ease), background-color .3s var(--ease);
}
.btn:hover {
  color: var(--text);
  border-color: var(--text-faint);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }

.btn-primary {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}
.btn-primary:hover {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}

.scroll-cue {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  translate: -50% 0;
  color: var(--text-faint);
  animation: bob 2.6s var(--ease) infinite;
  transition: color .3s var(--ease), opacity .4s var(--ease);
}
.scroll-cue:hover { color: var(--text); }
.scroll-cue svg {
  width: 26px; height: 26px;
  fill: none; stroke: currentColor; stroke-width: 1.4;
  stroke-linecap: round; stroke-linejoin: round;
}
.scroll-cue.is-hidden { opacity: 0; pointer-events: none; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(7px); }
}

@media (max-width: 46rem) {
  .hero-inner {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
  .portrait { width: 150px; }
  .lede { margin-inline: auto; }
  .meta, .actions { justify-content: center; }
  .scroll-cue { display: none; }
}

/* ---------------------------------------------------------------
   Sections
   --------------------------------------------------------------- */

.section {
  padding: clamp(4rem, 10vh, 7rem) var(--gutter);
  border-top: 1px solid var(--rule);
  transition: border-color var(--dur) var(--ease);
}

.section-inner {
  max-width: var(--shell);
  margin-inline: auto;
}

.section h2 {
  margin: 0 0 2rem;
  font-size: clamp(1.4rem, 1.2rem + 0.8vw, 1.85rem);
  font-weight: 500;
  letter-spacing: -0.01em;
  display: flex;
  align-items: baseline;
  gap: .9rem;
}

.num {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .75rem;
  letter-spacing: .1em;
  color: var(--accent);
  font-weight: 400;
}

.prose {
  max-width: var(--measure);
}
.prose p { margin: 0 0 1.15rem; }
.prose p:last-child { margin-bottom: 0; }

.sub {
  margin: 2.5rem 0 1rem;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.sub:first-of-type { margin-top: 0; }

/* ---------------------------------------------------------------
   Publications
   --------------------------------------------------------------- */

.pubs {
  list-style: none;
  margin: 0;
  padding: 0;
}
.pubs li {
  position: relative;
  padding: 1.25rem 0 1.25rem 1.25rem;
  border-top: 1px solid var(--rule);
  transition: border-color var(--dur) var(--ease);
}
.pubs li:last-child { border-bottom: 1px solid var(--rule); }

/* Accent bar wipes in on hover */
.pubs li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1.25rem;
  bottom: 1.25rem;
  width: 2px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: 50% 0;
  transition: transform .4s var(--ease);
}
.pubs li:hover::before { transform: scaleY(1); }

.pub-title {
  display: inline-block;
  max-width: var(--measure);
  font-size: 1.075rem;
  line-height: 1.4;
  color: var(--text);
  transition: color .3s var(--ease), transform .35s var(--ease);
}
.pubs li:hover .pub-title {
  color: var(--accent);
  transform: translateX(3px);
}

.pub-meta {
  margin: .3rem 0 .65rem;
  color: var(--text-muted);
  font-size: .925rem;
}
.pub-meta em { font-style: italic; }

/* Talk subtitle sits directly above the venue line, so close the gap. */
.pub-meta:has(+ .pub-venue) { margin-bottom: .1rem; }

.pub-venue {
  margin: 0 0 .65rem;
  color: var(--text-faint);
  font-size: .875rem;
}

/* Supersymmetry count, e.g. N = 4. Italic rather than the calligraphic
   U+1D4A9, which falls back to tofu on some systems. */
.susy { font-style: italic; }

/* A talk with no slides online uses <span class="pub-title">, which should
   look identical but stay put on hover. */
span.pub-title { cursor: default; }
.pubs li:hover span.pub-title { color: var(--text); transform: none; }

.pub-links {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.tag {
  display: inline-block;
  padding: .2rem .6rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .75rem;
  color: var(--text-muted);
  transition: color .3s var(--ease), border-color .3s var(--ease), background-color .3s var(--ease);
}
.tag:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ---------------------------------------------------------------
   Footer
   --------------------------------------------------------------- */

.footer {
  padding: 2.5rem var(--gutter) 3.5rem;
  border-top: 1px solid var(--rule);
  color: var(--text-faint);
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: .8125rem;
  transition: border-color var(--dur) var(--ease);
}
.footer p { margin: 0; }

/* ---------------------------------------------------------------
   Reveal-on-scroll
   Elements start hidden ONLY when JS is present (html.js), so the
   page degrades to fully visible content without JavaScript.
   --------------------------------------------------------------- */

.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}
.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ---------------------------------------------------------------
   Reduced motion
   --------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .js .reveal { opacity: 1; transform: none; }
  .portrait:hover img { transform: none; }
}

/* ---------------------------------------------------------------
   Print
   --------------------------------------------------------------- */

@media print {
  .nav, .progress, .scroll-cue, .theme-toggle, .actions { display: none !important; }
  .js .reveal { opacity: 1 !important; transform: none !important; }
  body { background: #fff; color: #000; }
  .section { border-top: none; padding: 1rem 0; }
}
