/* ==========================================================================
   Tokens — dark is the default; light uses a warm paper palette.
   ========================================================================== */

:root,
:root[data-theme="dark"] {
  --bg: #111110;
  --bg-raised: #191816;
  --ink: #eceae4;
  --ink-soft: #bdb9b0;
  --muted: #8a867e;
  --line: #2a2825;
  --accent: #e0826a;       /* rust */
  --accent-strong: #f0a08b;
  --blue: #7f99c4;
  --green: #9db27f;
  --chip-bg: rgba(255, 255, 255, 0.04);
  --selection: rgba(224, 130, 106, 0.35);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f7f5ef;
  --bg-raised: #fcfbf8;
  --ink: #211f1b;
  --ink-soft: #47443e;
  --muted: #747068;
  --line: #dcd7cc;
  --accent: #c65d43;
  --accent-strong: #9e422f;
  --blue: #526f9b;
  --green: #829467;
  --chip-bg: rgba(255, 255, 255, 0.5);
  --selection: rgba(198, 93, 67, 0.22);
  color-scheme: light;
}

:root {
  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --shell: 720px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ==========================================================================
   Base
   ========================================================================== */

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 250ms ease, color 250ms ease;
}

::selection { background: var(--selection); color: var(--ink); }

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

h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -0.02em; line-height: 1.2; }
p { margin: 0; }

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

.mono { font-family: var(--mono); font-size: 0.8125rem; letter-spacing: 0; }

.shell { width: min(calc(100% - 32px), var(--shell)); margin-inline: auto; }

.skip-link {
  position: fixed; top: 10px; left: 10px; z-index: 100;
  padding: 6px 12px; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  transform: translateY(-160%); transition: transform 160ms;
}
.skip-link:focus { transform: none; }

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

/* ==========================================================================
   Nav
   ========================================================================== */

.site-nav {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 200ms ease, background-color 250ms ease;
}
.site-nav.scrolled { border-bottom-color: var(--line); }

.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }

.brand {
  position: relative;
  font-weight: 600; font-size: 15px; letter-spacing: -0.01em;
  /* On the home page the portrait docks into the slot; --dock goes 0 -> 1 with scroll. */
  padding-left: calc(var(--dock, 0) * 38px);
}
.nav-avatar-slot { position: absolute; left: 0; top: 50%; width: 28px; height: 28px; margin-top: -14px; }

.nav-links { display: flex; align-items: center; gap: 22px; font-size: 14px; }
.nav-links a { color: var(--ink-soft); transition: color 150ms; }
.nav-links a:hover,
.nav-links a[aria-current="page"] { color: var(--ink); }
.nav-links .ext { font-size: 11px; margin-left: 2px; color: var(--muted); }

.theme-toggle {
  display: grid; place-items: center;
  width: 32px; height: 32px; margin-left: -6px; padding: 0;
  border: 0; border-radius: 999px; background: transparent;
  color: var(--ink-soft); cursor: pointer;
  transition: color 150ms, background-color 150ms;
}
.theme-toggle:hover { color: var(--ink); background: var(--chip-bg); }
.theme-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ==========================================================================
   Shared bits
   ========================================================================== */

.arrow-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink); font-weight: 500;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1px;
  transition: border-color 150ms, color 150ms;
}
.arrow-link span { transition: transform 200ms var(--ease); }
.arrow-link:hover { border-color: var(--accent); }
.arrow-link:hover span { transform: translate(2px, 1px); }
.arrow-link.small { font-size: 14px; color: var(--ink-soft); }
.arrow-link.small:hover { color: var(--ink); }

.socials { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; padding: 0; list-style: none; font-size: 14px; }
.socials a { color: var(--ink-soft); transition: color 150ms; }
.socials a:hover { color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font-family: var(--mono); font-size: 11.5px;
  padding: 2px 9px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink-soft); background: var(--chip-bg);
  transition: color 150ms, border-color 150ms;
}
.chip:hover { color: var(--accent); border-color: var(--accent); }

.venue { color: var(--muted); font-size: 14px; }
.blurb { color: var(--ink-soft); font-size: 14.5px; margin-top: 4px; }
.lede { color: var(--ink-soft); }
.lede a { color: var(--ink); border-bottom: 1px solid var(--line); transition: border-color 150ms; }
.lede a:hover { border-color: var(--accent); }

/* Entrance animation, staggered with --d */
.reveal { animation: rise 700ms var(--ease) both; animation-delay: var(--d, 0ms); }
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ==========================================================================
   Home — hero
   ========================================================================== */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  gap: 48px;
  align-items: center;
  padding: 72px 0 56px;
}

.hero-name { font-size: clamp(30px, 5vw, 40px); font-weight: 500; letter-spacing: -0.035em; }
.hero-tagline { margin-top: 14px; max-width: 460px; color: var(--ink-soft); font-size: 16.5px; }
.hero-cta { margin-top: 22px; font-size: 15px; }
.hero-socials { margin-top: 22px; }

/* Portrait: no frame, just the picture. Swaps are rendered as a diffusion
   process on a canvas overlay (see site.js). */
.portrait-slot { position: relative; z-index: 30; width: 200px; aspect-ratio: 4 / 5; }
.portrait {
  position: absolute; inset: 0; border-radius: 14px; overflow: hidden;
  transform-origin: 0 0; will-change: transform;
}
.portrait.docked { cursor: pointer; }

.photo-stack { position: relative; width: 100%; height: 100%; }
.photo-stack img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 14%;
  opacity: 0;
}
.photo-stack img.is-active { opacity: 1; }
.photo-stack canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; transition: opacity 200ms ease;
}
.photo-stack canvas.running { opacity: 1; transition: none; }

/* ==========================================================================
   Home — selected work
   ========================================================================== */

.section { padding: 8px 0 44px; }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.section-head h2,
.sub h2 { font-size: 13px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.work-list { margin: 0; padding: 0; list-style: none; }
.work-item {
  display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 16px;
  padding: 18px 0; border-bottom: 1px solid var(--line);
}
.work-item .year { color: var(--muted); padding-top: 2px; }
.work-item h3 { font-size: 16px; }
.work-item h3 a { background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 1px no-repeat; transition: background-size 300ms var(--ease), color 150ms; }
.work-item h3 a:hover { background-size: 100% 1px; }
.work-item .venue { margin-top: 2px; }

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer { padding: 28px 0 40px; }
.footer-inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
  padding-top: 20px; border-top: 1px solid var(--line);
}
.copy { color: var(--muted); }


/* ==========================================================================
   Inner pages
   ========================================================================== */

.page { padding: 56px 0 40px; }
.page-head { margin-bottom: 28px; }
.page-head h1 { font-size: clamp(28px, 4.5vw, 34px); letter-spacing: -0.03em; }
.page-head .lede { margin-top: 10px; font-size: 17px; max-width: 560px; }
.page-head .meta { color: var(--muted); margin-bottom: 8px; }

.prose { color: var(--ink-soft); }
.prose p + p { margin-top: 14px; }
.prose a { color: var(--ink); border-bottom: 1px solid var(--line); transition: border-color 150ms; }
.prose a:hover { border-color: var(--accent); }

.sub { margin-top: 44px; }
.sub h2 { padding-bottom: 12px; border-bottom: 1px solid var(--line); }

.entry-list { margin: 0; padding: 0; list-style: none; }
.entry {
  display: flex; justify-content: space-between; align-items: baseline; gap: 20px;
  padding: 16px 0; border-bottom: 1px solid var(--line);
}
.entry h3 { font-size: 16px; }
.entry h3 a:hover, .entry .venue a:hover { color: var(--accent); }
.entry .venue { margin-top: 2px; }
.entry .dates { flex-shrink: 0; color: var(--muted); white-space: nowrap; }
.timeline { border-top: 1px solid var(--line); }
.empty { color: var(--muted); padding: 16px 0; }

/* About */
.about-intro { display: grid; grid-template-columns: minmax(0, 1fr) 168px; gap: 40px; align-items: start; }
.about-photo { width: 168px; aspect-ratio: 4 / 5; border-radius: 14px; overflow: hidden; }

/* Education + Interests side by side when there's room */
.about-cols .entry { flex-direction: column; gap: 2px; }
.about-cols .xp-head { flex-direction: column; gap: 2px; }
.about-cols .xp-head .dates { order: -1; font-size: 12px; }
.about-cols .entry .dates { order: -1; font-size: 12px; }
@media (min-width: 700px) {
  .about-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; margin-top: 44px; }
  .about-cols .sub { margin-top: 0; }
}

/* Experience */
.xp-group + .xp-group { margin-top: 40px; }
.xp-group h2 {
  font-size: 13px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.xp { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.logo-tile {
  width: 40px; height: 40px; border-radius: 10px; overflow: hidden;
  background: #fff; box-shadow: 0 0 0 1px var(--line);
  display: grid; place-items: center;
}
.logo-tile img { width: 62%; height: 62%; object-fit: contain; }
.logo-tile.bleed img { width: 100%; height: 100%; object-fit: cover; }
.logo-tile.large img { width: 86%; height: 86%; }
.xp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.xp-head h3 { font-size: 16px; }
.xp-head .dates { flex-shrink: 0; color: var(--muted); white-space: nowrap; }
.xp .venue { margin-top: 2px; }
.xp .venue a:hover { color: var(--accent); }
.xp-note { margin-top: 4px; color: var(--ink-soft); font-size: 14px; }
.xp-note p { margin: 0; }
.xp-note a,
.interests .blurb a { color: var(--ink); border-bottom: 1px solid var(--line); transition: border-color 150ms, color 150ms; }
.interests .blurb a:hover { color: var(--accent); border-color: var(--accent); }
.xp-note a:hover { border-color: var(--accent); }
.xp-points { margin: 6px 0 0; padding-left: 16px; list-style: disc; color: var(--ink-soft); font-size: 14.5px; }
.xp-points li + li { margin-top: 2px; }
.xp-points li::marker { color: var(--muted); }

/* Home — updates */
.update-list { margin: 0; padding: 0; list-style: none; }
.update-list li {
  display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 16px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.update-list .date { color: var(--muted); padding-top: 2px; white-space: nowrap; }
.update-text { color: var(--ink-soft); font-size: 15px; }
.update-text p { margin: 0; }
.update-text a { color: var(--ink); border-bottom: 1px solid var(--line); transition: border-color 150ms; }
.update-text a:hover { border-color: var(--accent); }

/* CV */
.cv-actions { margin: -12px 0 16px; }
.cv-frame { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg-raised); }
.cv-frame iframe { display: block; width: 100%; height: 80vh; min-height: 520px; border: 0; }
.cv-empty { display: grid; place-items: center; min-height: 320px; color: var(--muted); }

.pub-year { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 16px; border-top: 1px solid var(--line); padding-top: 18px; margin-bottom: 18px; }
.pub-year h2 { color: var(--muted); font-weight: 400; }
.pub-list { margin: 0; padding: 0; list-style: none; }
.pub-list li + li { margin-top: 18px; }
.pub-list h3 { font-size: 16px; }
.pub-list h3 a { background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 1px no-repeat; transition: background-size 300ms var(--ease); }
.pub-list h3 a:hover { background-size: 100% 1px; }
.authors { color: var(--ink-soft); font-size: 14px; margin-top: 3px; }
.authors b { color: var(--ink); font-weight: 500; }

.back { margin-top: 40px; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 640px) {
  .nav-links { gap: 16px; }
  .hero { grid-template-columns: 1fr; gap: 28px; padding: 40px 0 44px; }
  .portrait-slot { order: -1; width: 150px; }
  .work-item, .pub-year { grid-template-columns: 1fr; gap: 4px; }
  .entry { flex-direction: column; gap: 4px; }
  .entry .dates { order: -1; }
  .about-intro { grid-template-columns: 1fr; gap: 24px; }
  .about-photo { order: -1; width: 128px; }
  .update-list li { grid-template-columns: 1fr; gap: 2px; }
  .xp { grid-template-columns: 34px minmax(0, 1fr); gap: 12px; }
  .logo-tile { width: 34px; height: 34px; border-radius: 8px; }
  .xp-head { flex-direction: column; gap: 2px; }
  .xp-head .dates { order: -1; font-size: 12px; }
}

@media (max-width: 380px) {
  .brand { font-size: 14px; }
  .nav-links { gap: 12px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
