@font-face {
  font-family: Inter;
  src: url('/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #ffffff;
  --text: #0a0a0a;
  --muted: #6b7280;
  --line: #e5e7eb;

  --accent: #3b82f6;
  --accent-weak: #93c5fd;
  --good: #22c55e;
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --text: #f5f5f5;
  --muted: #a3a3a3;
  --line: #333;

  --accent: #60a5fa;
  --accent-weak: #2563eb;
  --good: #4ade80;
}

/* Disable transitions during first paint to avoid flashes */
.no-anim *, .no-anim *::before, .no-anim *::after { transition: none !important; }

/* Reserve scrollbar gutter so page width is identical regardless of whether
   the bar is needed — but only show the bar when content overflows. */
html { scrollbar-gutter: stable; }

body {
  margin: 0;
  display: flex;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 18px;
  line-height: 1.65;
  transition: background 0.25s ease, color 0.25s ease;
  overscroll-behavior-y: none;
}
@media (prefers-reduced-motion: reduce) { body { transition: none; } }

.wrap { width: min(50rem, 100%); padding: 0 1.25rem; margin: 10vh 0 0; }

h1 { font-size: clamp(2.5rem, 6vw, 3.25rem); margin: 0 0 0.25rem; letter-spacing: -0.01em; }
h1 a { color: inherit; text-decoration: none; border-bottom: none; }
h1 a:hover, h1 a:focus-visible { color: var(--muted); text-decoration: underline; }

hr { border: none; border-top: 1px solid var(--line); margin: 2rem 0; }

p { margin: 0 0 1rem; font-size: 1.15rem; max-width: 72ch; }

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

/* ---------- Theme toggle ---------- */
.theme-toggle {
  position: fixed; top: 1rem; right: 1rem; z-index: 30;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  line-height: 1;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Wandering links (desktop) ---------- */
.floatingLink {
  position: absolute;
  font-weight: 500;
  border-bottom: none;
  color: var(--muted);
  text-transform: lowercase;
  transition: color 0.2s ease, opacity 0.4s ease, transform 0.15s ease;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  padding: .25rem .4rem;
}
.floatingLink.ready { opacity: 1; pointer-events: auto; }
.floatingLink:hover, .floatingLink:focus-visible { transform: translateY(-2px); }
.floatingLink:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Bottom link rail (mobile) ---------- */
#linkRail {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem clamp(.5rem, 4vw, 1rem);
  padding-bottom: calc(.5rem + env(safe-area-inset-bottom));
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;

  background: color-mix(in oklab, var(--bg) 75%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  -webkit-backdrop-filter: saturate(1.2) blur(8px);

  border-top: 1px solid var(--line);
}

.chip {
  position: static;
  opacity: 1;
  pointer-events: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .45rem .7rem;
  margin: 0;
  white-space: nowrap;
  font-size: 1rem;
  scroll-snap-align: start;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.1) blur(6px);
  -webkit-backdrop-filter: saturate(1.1) blur(6px);
}

/* Give space so the fixed rail doesn't cover content */
body.rail-active { padding-bottom: 4.5rem; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .floatingLink { transition: none; }
  #linkRail { scroll-behavior: auto; }
}

/* ---------- CV: unified spacing & typography ---------- */
h2 { margin: 0; }
.section-title { margin: 0 0 1rem 0; font-size: 1.65rem; font-weight: 600; text-transform: lowercase; line-height: 1.2; padding-top: 0; }
.page-header + .section-title {
  margin-top: 0;
  padding-top: 0;
}
.profile-section + .section-title { margin-top: 0; }
.org-block { margin: 1rem 0 1.25rem; }
.section-title + .org-block { margin-top: 0.25rem; }
.org-name { font-size: inherit; font-weight: 600; margin: 0 0 .35rem; line-height: inherit; }
.role-list { list-style: none; margin: 0; padding: 0; }
.role-item {
  display: grid; grid-template-columns: 1fr auto;
  gap: .35rem 1rem; padding: .25rem 0; align-items: baseline;
}
.dates { color: var(--muted); font-size: .95rem; white-space: nowrap; }

.wrap > *:not(h1):not(hr) { max-width: 72ch; }

/* ---------- Profile section (home page) ---------- */
.profile-section {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 2.5rem;
  row-gap: 1rem;
  align-items: flex-end;
  margin-bottom: 2rem;
}

.profile-image {
  width: 140px;
  height: 140px;
  border-radius: 16px;
  object-fit: cover;
  flex-shrink: 0;
  grid-row: 1;
  align-self: start;
}

.profile-section h1,
.page-header h1 {
  grid-column: 2;
  grid-row: 1;
  margin-top: auto;
}

.greeting {
  font-size: clamp(2rem, 5vw, 2.8rem);
  margin: 0 0 1rem 0;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-weight: 700;
}

.profile-section > p {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.4;
}
.profile-section > p:first-of-type { margin-top: 0.75rem; }

/* ---------- Page header (other pages) ---------- */
.page-header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2.5rem;
  align-items: flex-end;
  margin-bottom: 2rem;
}

@media (max-width: 720px) {
  .section-title { font-size: 1.5rem; margin-top: 2rem; }
  p { font-size: 1.05rem; line-height: 1.6; }
  .role-item { grid-template-columns: 1fr; gap: 0.1rem; padding: 0.15rem 0; }
  .org-name { font-size: 1.1rem; }
  .dates { order: 3; font-size: 0.95rem; }
  .profile-section { gap: 1.25rem; }
  .page-header { gap: 1.25rem; }
  .profile-image { width: 100px; height: 100px; }
  .greeting { font-size: 1.75rem; }
}

/* ---------- Fallback for browsers without backdrop-filter ---------- */
@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  #linkRail { background: var(--bg); }
}

@supports not (background: color-mix(in oklab, white 75%, transparent)) {
  #linkRail { background: var(--bg); }
}
