/* ---------- Tokens ---------- */
:root {
  --bg: #f6f3ee;
  --bg-alt: #efebe4;
  --surface: #fbf9f6;
  --text: #2e2a27;
  --muted: #86817a;
  --faint: #a8a298;
  --line: #dfdbd4;
  --accent: #b5603f;
  --accent-soft: #e8c9b9;
  --c1: #7b6a9b;   /* purple   */
  --c2: #c89b5e;   /* tan      */
  --c3: #5d7a8c;   /* slate    */
  --c4: #b5603f;   /* rust     */
  --c5: #6d8a5f;   /* sage     */
  --c6: #b7876a;   /* clay     */
  --noise-opacity: .35;
  --rail: 3.9rem;
  --nav-h: 5rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1918;
    --bg-alt: #211f1d;
    --surface: #242220;
    --text: #ece7df;
    --muted: #a39d93;
    --faint: #7c776f;
    --line: #36332f;
    --accent: #e08a65;
    --accent-soft: #5a3a2c;
    --c1: #a996cc;
    --c2: #dcb57a;
    --c3: #8fb0c4;
    --c4: #e08a65;
    --c5: #9cbc8c;
    --c6: #d7a88a;
    --noise-opacity: .12;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1918;
  --bg-alt: #211f1d;
  --surface: #242220;
  --text: #ece7df;
  --muted: #a39d93;
  --faint: #7c776f;
  --line: #36332f;
  --accent: #e08a65;
  --accent-soft: #5a3a2c;
  --c1: #a996cc;
  --c2: #dcb57a;
  --c3: #8fb0c4;
  --c4: #e08a65;
  --c5: #9cbc8c;
  --c6: #d7a88a;
  --noise-opacity: .12;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 1rem); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
::selection { background: var(--accent-soft); }

/* ---------- Left rail ---------- */
.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--rail);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: calc(var(--nav-h) + 2rem) 0 1.6rem;
  z-index: 20;
  background: var(--bg);
  transition: background-color .3s ease;
}
.rail-mark {
  position: relative;
  text-decoration: none;
  font-family: Sora, sans-serif;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  height: 12rem;
  display: flex;
  align-items: center;
}
.rail-mono, .rail-hello {
  transition: opacity .35s ease, transform .35s ease;
  white-space: nowrap;
}
.rail-mono { opacity: .55; letter-spacing: .08em; }
.rail-hello {
  position: absolute;
  opacity: 0;
  transform: translateY(8px);
  font-size: .85rem;
  color: var(--accent);
}
.rail-mark:hover .rail-mono { opacity: 0; transform: translateY(-8px); }
.rail-mark:hover .rail-hello { opacity: 1; transform: none; }

.theme-toggle {
  width: 2.4rem; height: 2.4rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: grid; place-items: center;
  transition: border-color .2s, color .2s, transform .3s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); transform: rotate(-15deg); }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

/* ---------- Navbar ---------- */
.navbar {
  position: fixed;
  top: 0; left: var(--rail); right: 0;
  height: var(--nav-h);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2.5rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 30;
}
.nav-left, .nav-right { display: flex; align-items: center; gap: 2rem; }
.logo {
  font-family: Sora, sans-serif;
  font-weight: 600;
  font-size: 1.35rem;
  text-decoration: none;
  letter-spacing: -.02em;
}
.logo span { color: var(--accent); }
.socials { display: flex; gap: .4rem; }
.socials a {
  width: 2.2rem; height: 2.2rem;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--muted);
  transition: color .2s, background-color .2s;
}
.socials a:hover { color: var(--accent); background: var(--bg-alt); }
.socials svg { width: 1.05rem; height: 1.05rem; }

.nav-menu { display: flex; gap: 1.75rem; }
.nav-link, .download-cv {
  text-transform: uppercase;
  font-size: .8rem;
  letter-spacing: .08em;
  text-decoration: none;
  position: relative;
}
.nav-link::after {
  content: "";
  position: absolute; left: 0; right: 100%; bottom: -4px;
  height: 1px; background: currentColor;
  transition: right .3s ease;
}
.nav-link:hover::after { right: 0; }
.download-cv {
  display: inline-flex; align-items: center; gap: .7rem;
  padding: .55rem .6rem .55rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color .2s;
}
.download-circle {
  width: 1.7rem; height: 1.7rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  transition: transform .3s ease;
}
.download-cv:hover { border-color: var(--accent); }
.download-cv:hover .download-circle { transform: translateY(2px); }

.burger {
  display: none;
  width: 2.5rem; height: 2.5rem;
  border: 0; background: transparent; cursor: pointer;
  position: relative;
}
.burger span {
  position: absolute; left: .5rem; right: .5rem; height: 1.5px;
  background: var(--text);
  transition: transform .3s ease, top .3s ease;
}
.burger span:first-child { top: 1rem; }
.burger span:last-child { top: 1.45rem; }
.burger[aria-expanded="true"] span:first-child { top: 1.22rem; transform: rotate(45deg); }
.burger[aria-expanded="true"] span:last-child { top: 1.22rem; transform: rotate(-45deg); }

.mobile-menu {
  position: fixed;
  inset: var(--nav-h) 0 0 0;
  background: var(--bg);
  z-index: 25;
  display: flex; flex-direction: column;
  padding: 2rem 1.5rem;
  gap: .25rem;
}
.mobile-menu[hidden] { display: none; }
.mobile-menu a {
  font-family: Sora, sans-serif;
  font-size: 1.6rem;
  text-decoration: none;
  padding: .7rem 0;
  border-bottom: 1px solid var(--line);
}

/* ---------- Hero ---------- */
main { margin-left: var(--rail); }
.hero {
  min-height: 100vh;
  min-height: 100svh;
  position: relative;
  display: flex;
  align-items: center;
  padding: calc(var(--nav-h) + 3rem) 2.5rem 5rem;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.noise::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.45 0 0 0 0 0.4 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.hero-inner {
  position: relative;
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 4rem;
  align-items: center;
}
.hero-hello {
  font-size: clamp(2rem, 4.2vw, 3.4rem);
  letter-spacing: -.03em;
  line-height: 1.1;
  font-weight: 400;
  margin-bottom: 2.5rem;
}
.accent { color: var(--accent); font-family: Sora, sans-serif; }
.keywords {
  font-size: clamp(1.25rem, 2.3vw, 1.9rem);
  letter-spacing: -.02em;
}
.code-line { font-weight: 400; }
.kw { color: var(--c1); font-family: Inconsolata, monospace; font-size: 1.1em; }
.flip {
  height: 1.5em;
  overflow: hidden;
  padding-left: 1.6em;
  font-family: Sora, sans-serif;
  font-weight: 300;
}
.flip ul { transition: transform .7s cubic-bezier(.7, 0, .2, 1); }
.flip li { height: 1.5em; line-height: 1.5em; white-space: nowrap; }
.flip:nth-of-type(1) li { color: var(--c4); }
.flip:nth-of-type(2) li { color: var(--c3); }
.flip:nth-of-type(3) li { color: var(--c5); }
.semi { color: var(--text); opacity: .5; }

.hero-photo { justify-self: end; width: min(100%, 25rem); }
.photo-frame {
  aspect-ratio: 4 / 5;
  border-radius: 12rem 12rem 1rem 1rem;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-alt);
  box-shadow: 0 30px 60px -30px rgba(60, 40, 30, .35);
}
.photo-frame img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 30%;
  transition: transform 1.2s ease;
}
.photo-frame:hover img { transform: scale(1.03); }
.photo-caption {
  margin-top: 1rem;
  font-family: Inconsolata, monospace;
  color: var(--muted);
  display: flex; align-items: center; gap: .5rem;
}
.dot {
  width: .5rem; height: .5rem; border-radius: 50%;
  background: var(--c5);
  box-shadow: 0 0 0 0 var(--c5);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c5) 60%, transparent); }
  70% { box-shadow: 0 0 0 .5rem transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.scroll-cue {
  position: absolute;
  left: 50%; bottom: 1.5rem;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  font-family: Inconsolata, monospace;
  font-size: .8rem;
  color: var(--muted);
  text-decoration: none;
  animation: bob 2.2s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translate(-50%, 6px); } }

/* ---------- Body grid ---------- */
.body-grid {
  display: grid;
  grid-template-columns: 15rem 1fr;
  max-width: 80rem;
  margin: 0 auto;
}
.sticky-nav {
  position: sticky;
  top: var(--nav-h);
  align-self: start;
  height: calc(100vh - var(--nav-h));
  padding: 3rem 1.5rem 3rem 2.5rem;
  display: flex; flex-direction: column; gap: .35rem;
  border-right: 1px solid var(--line);
}
.sticky-link {
  display: flex; align-items: center; gap: .8rem;
  text-decoration: none;
  text-transform: uppercase;
  font-size: .78rem;
  letter-spacing: .08em;
  color: var(--muted);
  padding: .5rem 0;
  transition: color .2s;
}
.link-dot {
  width: .5rem; height: .5rem;
  border-radius: 50%;
  border: 1px solid currentColor;
  transition: background-color .2s, transform .2s;
  flex: none;
}
.sticky-link:hover { color: var(--text); }
.sticky-link.active { color: var(--accent); }
.sticky-link.active .link-dot { background: var(--accent); transform: scale(1.2); }

.content { min-width: 0; }
.block {
  padding: 4.5rem 3.5rem;
  border-bottom: 1px solid var(--line);
}
.block:last-child { border-bottom: 0; }
.code-label {
  font-family: Inconsolata, monospace;
  font-size: 1.15rem;
  color: var(--muted);
}
.c1 { color: var(--c1); } .c2 { color: var(--c2); }
.c3 { color: var(--c3); } .c4 { color: var(--c4); }
.c5 { color: var(--c5); } .c6 { color: var(--c6); }

.statement {
  margin: 1.25rem 0 2rem;
  font-size: clamp(1.45rem, 2.4vw, 2rem);
  line-height: 1.32;
  font-weight: 400;
  letter-spacing: -.02em;
  max-width: 44rem;
}
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; max-width: 52rem; }
.summary p { color: var(--muted); font-size: 1.02rem; }

.block-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  margin-bottom: 2.5rem;
}
.block-head h3 {
  font-size: clamp(1.6rem, 2.6vw, 2.1rem);
  font-weight: 400;
  letter-spacing: -.02em;
}

/* ---------- Timeline entries ---------- */
.timeline { display: grid; gap: 0; }
.entry {
  position: relative;
  padding: 1.6rem 0 1.6rem 1.75rem;
  border-left: 1px solid var(--line);
}
.entry::before {
  content: "";
  position: absolute; left: -5px; top: 2.05rem;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--accent);
  transition: background-color .2s;
}
.entry:hover::before { background: var(--accent); }
.date {
  font-size: .85rem;
  font-style: italic;
  color: var(--faint);
  margin-bottom: .35rem;
}
.entry h4 {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.3;
}
.native { font-weight: 400; color: var(--muted); margin-left: .35rem; }
.tag {
  display: inline-block;
  vertical-align: middle;
  margin-left: .5rem;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .15rem .55rem;
}
.role { margin-top: .2rem; font-size: 1.02rem; }
.detail { color: var(--c1); font-size: .93rem; margin-top: .15rem; }
.bullets { margin-top: .6rem; display: grid; gap: .3rem; }
.bullets li {
  position: relative;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: .95rem;
}
.bullets li::before {
  content: "›";
  position: absolute; left: 0;
  color: var(--accent);
}
.bullets em { color: var(--text); font-style: italic; }

/* ---------- Publications ---------- */
.pub { padding: 1.4rem 0; border-top: 1px solid var(--line); }
.pub-venue {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .5rem;
}
.pub-title {
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -.02em;
  margin-bottom: .55rem;
  max-width: 46rem;
}
.pub-title a { text-decoration: none; transition: color .15s; }
.pub-title a:hover { color: var(--accent); }
.pub-authors { color: var(--muted); font-size: .95rem; }
.pub-authors strong { color: var(--text); font-weight: 600; }
.pub-links { margin-top: .7rem; display: flex; gap: .5rem; }
.pub-links a {
  font-family: Inconsolata, monospace;
  font-size: .85rem;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .2rem .7rem;
  transition: border-color .2s, color .2s;
}
.pub-links a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Skills ---------- */
.skills { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; }
.skills-label {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
}
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chips li {
  font-family: Inconsolata, monospace;
  font-size: .95rem;
  padding: .3rem .8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
.langs { display: grid; }
.langs li {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .65rem 0;
  border-bottom: 1px solid var(--line);
}
.langs li:first-child { border-top: 1px solid var(--line); }
.lvl { color: var(--muted); font-size: .9rem; text-align: right; }

/* ---------- Talks ---------- */
.talks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1.75rem;
  margin-bottom: 2rem;
}
.talk { display: flex; flex-direction: column; text-decoration: none; }
.talk-thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: var(--surface);
  transition: border-color .2s, transform .2s;
}
.talk-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .6s ease;
}
.talk:hover .talk-thumb { border-color: var(--accent); transform: translateY(-2px); }
.talk:hover .talk-thumb img { transform: scale(1.03); }
.talk-play {
  position: absolute; left: 1rem; bottom: 1rem;
  width: 2.75rem; height: 2.75rem;
  border-radius: .8rem;
  background: #d9372b;
  color: #fff;
  display: grid; place-items: center;
}
.talk-meta {
  margin-top: .9rem;
  font-family: Inconsolata, monospace;
  font-size: .9rem;
  color: var(--muted);
}
.talk-title {
  display: flex; align-items: baseline; gap: .75rem;
  font-family: Sora, sans-serif; font-weight: 500; font-size: 1.1rem;
}
.talk:hover .yt-arrow { color: var(--accent); transform: translate(2px, -2px); }

/* ---------- YouTube ---------- */
.yt-card {
  display: flex; align-items: center; gap: 1.25rem;
  padding: 1.4rem 1.6rem;
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: var(--surface);
  text-decoration: none;
  max-width: 34rem;
  transition: border-color .2s, transform .2s;
}
.yt-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.yt-play {
  flex: none;
  width: 3.5rem; height: 3.5rem;
  border-radius: 1rem;
  background: #d9372b;
  color: #fff;
  display: grid; place-items: center;
}
.yt-text { display: flex; flex-direction: column; min-width: 0; }
.yt-handle { font-family: Sora, sans-serif; font-weight: 500; font-size: 1.2rem; }
.yt-desc { color: var(--muted); font-size: .95rem; }
.yt-arrow { margin-left: auto; font-size: 1.3rem; color: var(--muted); transition: color .2s, transform .2s; }
.yt-card:hover .yt-arrow { color: var(--accent); transform: translate(2px, -2px); }

/* ---------- Footer ---------- */
.footer {
  margin-left: var(--rail);
  border-top: 1px solid var(--line);
  padding: 2rem 2.5rem;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem;
  font-size: .9rem;
  color: var(--muted);
}
.footer a { text-decoration: none; }
.footer a:hover { color: var(--accent); }

/* ---------- Reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .body-grid { grid-template-columns: 1fr; }
  .sticky-nav { display: none; }
  .block { padding: 3.5rem 2.5rem; }
}
@media (max-width: 820px) {
  :root { --rail: 0px; --nav-h: 4.25rem; }
  .rail {
    inset: auto 1rem 1rem auto;
    width: auto; padding: 0;
    border: 0; background: transparent;
  }
  .rail-mark { display: none; }
  .theme-toggle { background: var(--surface); box-shadow: 0 4px 16px rgba(0,0,0,.12); }
  .navbar { padding: 0 1rem; }
  .nav-left { gap: 1rem; }
  .nav-menu, .download-cv { display: none; }
  .burger { display: block; }
  .socials a { width: 2rem; height: 2rem; }
  .hero { padding: calc(var(--nav-h) + 2rem) 1rem 5rem; align-items: flex-start; }
  .hero-inner { grid-template-columns: 1fr; gap: 2.5rem; }
  .hero-photo { justify-self: start; width: min(100%, 18rem); order: -1; }
  .hero-hello { margin-bottom: 1.5rem; }
  .flip { padding-left: 1em; }
  .block { padding: 3rem 1rem; }
  .summary, .skills { grid-template-columns: 1fr; gap: 1.25rem; }
  .skills { gap: 2.5rem; }
  .footer { padding: 1.5rem 1rem 5rem; }
}
@media (max-width: 380px) {
  .socials a:nth-child(3) { display: none; }
}

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