/* ============ Design tokens ============ */
:root{
  --bg: #faf9f6;
  --bg-alt: #f2f0ea;
  --surface: #ffffff;
  --text: #1c1b19;
  --text-muted: #5b5850;
  --text-faint: #8a8579;
  --border: #e5e1d8;
  --accent: #8a3324;
  --accent-2: #c96f4a;
  --accent-soft: #f4e4dc;
  --gold: #b8863f;
  --shadow: 0 1px 2px rgba(28,27,25,.04), 0 8px 24px rgba(28,27,25,.06);
  --shadow-lg: 0 4px 12px rgba(28,27,25,.06), 0 20px 48px rgba(28,27,25,.10);
  --radius-sm: 8px;
  --radius: 14px;
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"]{
  --bg: #15140f;
  --bg-alt: #1c1b16;
  --surface: #201f19;
  --text: #efece3;
  --text-muted: #b3ac9c;
  --text-faint: #837c6c;
  --border: #34322a;
  --accent: #e08a63;
  --accent-2: #cf6a45;
  --accent-soft: #35281f;
  --gold: #d6ab6d;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.35), 0 24px 56px rgba(0,0,0,.45);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg: #15140f;
    --bg-alt: #1c1b16;
    --surface: #201f19;
    --text: #efece3;
    --text-muted: #b3ac9c;
    --text-faint: #837c6c;
    --border: #34322a;
    --accent: #e08a63;
    --accent-2: #cf6a45;
    --accent-soft: #35281f;
    --gold: #d6ab6d;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    --shadow-lg: 0 4px 16px rgba(0,0,0,.35), 0 24px 56px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}

/* ============ Reset ============ */
*,*::before,*::after{ box-sizing: border-box; }
html{ scroll-behavior: smooth; }
body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
img{ max-width:100%; display:block; }
a{ color: inherit; text-decoration: none; }
ul,ol{ margin:0; padding:0; list-style:none; }
h1,h2,h3,h4{ font-family: var(--font-serif); font-weight: 600; margin: 0; color: var(--text); }
p{ margin: 0; }

.skip-link{
  position:absolute; left:-999px; top:0; background:var(--accent); color:#fff;
  padding:.6rem 1rem; border-radius: 0 0 8px 0; z-index: 999;
}
.skip-link:focus{ left:0; }

/* ============ Mobile top bar ============ */
.mobile-bar{
  display:none;
  position: sticky; top:0; z-index: 100;
  align-items:center; justify-content:space-between;
  height: 60px; padding: 0 1.25rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.mobile-bar .brand{ font-family: var(--font-serif); font-size: 1.15rem; font-weight:700; }

/* ============ Page shell ============ */
.page-shell{
  max-width: 1240px;
  margin: 0 auto;
  padding: 3.5rem 1.5rem;
  display:flex;
  align-items:flex-start;
  gap: 3.5rem;
}

/* ============ Sidebar ============ */
.sidebar{
  flex: 0 0 260px;
  position: sticky;
  top: 2.5rem;
  display:flex;
  flex-direction:column;
  align-items:flex-start;
}
.theme-toggle{
  width: 38px; height:38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface);
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; color: var(--text); flex-shrink:0;
  transition: border-color .2s ease, transform .15s ease;
}
.theme-toggle:hover{ border-color: var(--accent); transform: translateY(-1px); }
.theme-toggle svg{ width:18px; height:18px; }
.theme-toggle .icon-moon{ display:none; }
:root[data-theme="dark"] .theme-toggle .icon-sun{ display:none; }
:root[data-theme="dark"] .theme-toggle .icon-moon{ display:block; }
.theme-toggle-desktop{ align-self:flex-end; margin-bottom: 1rem; }

.avatar-ring{
  width: 108px; height: 108px; border-radius: 50%;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 4px solid var(--surface);
  outline: 1px solid var(--border);
  margin-bottom: 1.2rem;
  flex-shrink: 0;
}
.avatar-ring img{
  width:100%; height:100%; object-fit: cover; display:block;
}

.side-name{ font-size: 1.6rem; letter-spacing:-.01em; margin-bottom: .3rem; }
.side-tagline{ color: var(--accent); font-weight:600; font-size: .95rem; margin-bottom: 1.3rem; }

.side-meta{ display:flex; flex-direction:column; gap: .6rem; margin-bottom: 1.3rem; width:100%; }
.side-meta li{ display:flex; align-items:flex-start; gap: .55rem; color: var(--text-muted); font-size: .87rem; }
.side-meta svg{ width:16px; height:16px; flex-shrink:0; margin-top:.1rem; color: var(--text-faint); }

.side-socials{ display:flex; flex-direction:column; gap: .55rem; margin-bottom: 1.5rem; width:100%; }
.side-socials a{
  display:flex; align-items:center; gap:.55rem; font-size:.87rem; font-weight:600;
  color: var(--text-muted); transition: color .18s ease;
}
.side-socials a:hover{ color: var(--accent); }
.side-socials svg{ width:16px; height:16px; }

.side-nav{ display:flex; flex-direction:column; gap: .15rem; width:100%; border-top: 1px solid var(--border); padding-top: 1.3rem; }
.side-nav a{
  padding: .55rem .7rem; border-radius: 8px; font-size: .9rem; font-weight:500;
  color: var(--text-muted); transition: color .15s ease, background .15s ease;
}
.side-nav a:hover{ color: var(--text); background: var(--bg-alt); }
.side-nav a.active{ color: var(--accent); background: var(--accent-soft); font-weight:600; }

/* ============ Content ============ */
.content{ flex: 1; min-width: 0; }

.section{ padding-bottom: 4rem; border-bottom: 1px solid var(--border); margin-bottom: 4rem; }
.section:last-of-type{ border-bottom:none; margin-bottom: 0; padding-bottom: 0; }
.section-title{
  display:flex; align-items:baseline; gap: .85rem;
  font-size: clamp(1.5rem, 2.6vw, 1.9rem);
  margin-bottom: 2.2rem; letter-spacing:-.01em;
}
.section-title .num{
  font-family: var(--font-sans); font-size: .8rem; font-weight:700;
  color: var(--accent); border: 1px solid var(--border);
  border-radius: 999px; padding: .28rem .62rem; letter-spacing:.04em;
}
.section-intro{ color: var(--text-muted); margin-bottom: 2rem; max-width: 62ch; }
.subsection-title{ font-size: 1.1rem; margin: 2.2rem 0 1.1rem; }
.two-col{ display:grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; }

/* ============ About ============ */
.about-content{ display:flex; flex-direction:column; gap: 1.5rem; }
.about-text{ font-size: 1.12rem; line-height: 1.75; color: var(--text-muted); max-width: 68ch; }
.about-text strong{ color: var(--text); font-weight: 600; }
.focus-tags{ display:flex; flex-wrap:wrap; gap: .6rem; }
.focus-tags li{
  font-size: .82rem; font-weight:600; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: .48rem .95rem;
}

/* ============ Timeline ============ */
.timeline{ position:relative; padding-left: 1.9rem; }
.timeline::before{
  content:""; position:absolute; left: 5px; top: 6px; bottom: 6px; width: 2px;
  background: linear-gradient(var(--accent), var(--border));
}
.timeline-item{ position: relative; padding-bottom: 2.3rem; }
.timeline-item:last-child{ padding-bottom:0; }
.timeline-item::before{
  content:""; position:absolute; left: -1.9rem; top: 6px;
  width: 12px; height:12px; border-radius:50%;
  background: var(--accent); border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px var(--accent);
}
.timeline-date{
  font-size: .8rem; font-weight:700; text-transform:uppercase; letter-spacing:.06em;
  color: var(--accent); margin-bottom: .35rem;
}
.timeline-content h3{ font-size: 1.2rem; margin-bottom: .25rem; }
.timeline-org{ color: var(--text-muted); font-weight:600; font-size:.92rem; margin-bottom: .5rem; }
.timeline-content p{ color: var(--text-muted); max-width: 68ch; }
.timeline-content p em{ color: var(--text); font-style: italic; }

/* ============ Cards ============ */
.card-grid{ display:grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 1.3rem; margin-top: 1.6rem; }
.proj-card, .award-card{
  background: var(--surface); border:1px solid var(--border); border-radius: var(--radius);
  padding: 1.4rem; box-shadow: var(--shadow); transition: transform .18s ease, box-shadow .18s ease;
}
.proj-card:hover, .award-card:hover{ transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.proj-date{ display:flex; align-items:center; gap: .5rem; font-size: .78rem; font-weight:700; color: var(--accent); text-transform:uppercase; letter-spacing:.05em; }
.proj-card h4{ font-size: 1.02rem; margin: .5rem 0 .6rem; }
.proj-card p{ color: var(--text-muted); font-size: .92rem; }

.badge-progress{ background: var(--bg-alt); color: var(--text-muted); border: 1px solid var(--border); }

.award-icon{ margin-bottom: .8rem; color: var(--gold); }
.award-icon svg{ width: 30px; height: 30px; }
.award-year{ font-size: .78rem; font-weight:700; color: var(--gold); text-transform:uppercase; letter-spacing:.05em; }
.award-card h4{ font-size: 1.02rem; margin: .5rem 0 .6rem; line-height:1.35; }
.award-card p{ color: var(--text-muted); font-size: .88rem; }

/* ============ Publications ============ */
.badge{
  display:inline-block; font-size: .7rem; font-weight:700; letter-spacing:.03em;
  padding: .25rem .6rem; border-radius: 999px; text-transform: uppercase;
}
.badge-award{ background: var(--accent-soft); color: var(--accent); }

.pub-list{ counter-reset: pub; display:flex; flex-direction:column; gap: .85rem; }
.pub-list li{
  counter-increment: pub; position:relative;
  padding: 1rem 1.1rem 1rem 3.1rem;
  background: var(--surface); border:1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .92rem; color: var(--text-muted);
  transition: border-color .18s ease, transform .18s ease;
}
.pub-list li:hover{ border-color: var(--accent); transform: translateX(2px); }
.pub-list li::before{
  content: counter(pub);
  position:absolute; left: .95rem; top: 1rem;
  font-family: var(--font-serif); font-weight:700; color: var(--text-faint);
  font-size: .88rem;
}
.pub-list li.award{ border-color: color-mix(in srgb, var(--gold) 60%, var(--border)); background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface)); }
.pub-list li em{ color: var(--text); font-style: italic; }
.pub-list .badge{ display:block; width:max-content; margin-bottom: .5rem; }

/* ============ Lists ============ */
.plain-list li{ padding: .55rem 0; border-bottom: 1px dashed var(--border); color: var(--text-muted); font-size: .92rem; }
.plain-list li:last-child{ border-bottom:none; }
.plain-list strong{ color: var(--text); }

/* ============ Contact ============ */
.contact-grid{ display:flex; gap: 1.1rem; flex-wrap:wrap; margin-top: 1rem; }
.contact-card{
  display:flex; align-items:center; gap:.6rem;
  background: var(--surface); border:1px solid var(--border); border-radius: 999px;
  padding: .85rem 1.5rem; font-weight:600; font-size:.92rem;
  box-shadow: var(--shadow); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.contact-card:hover{ transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--accent); color: var(--accent); }
.contact-card svg{ width:18px; height:18px; }

/* ============ Footer ============ */
.site-footer{ display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:.8rem; padding-top: 2.5rem; margin-top: -1rem; }
.site-footer p{ color: var(--text-faint); font-size: .85rem; }
.back-to-top{ color: var(--text-muted); font-size: .85rem; font-weight:600; transition: color .18s ease; }
.back-to-top:hover{ color: var(--accent); }

/* ============ Responsive ============ */
@media (max-width: 900px){
  .mobile-bar{ display:flex; }
  .page-shell{ flex-direction:column; padding-top: 2.4rem; gap: 2.5rem; }
  .sidebar{
    position: static; flex: 1 1 auto; width:100%;
    flex-direction:row; flex-wrap:wrap; align-items:center;
    gap: 0 1.4rem;
  }
  .theme-toggle-desktop{ display:none; }
  .avatar-ring{ width:76px; height:76px; margin-bottom:0; }
  .side-name{ font-size: 1.3rem; margin-bottom:.15rem; }
  .side-tagline{ margin-bottom:0; }
  .side-meta, .side-socials{ width:auto; flex-direction:row; flex-wrap:wrap; gap: 1.1rem; margin: 1rem 0 0; }
  .side-nav{
    width:100%; flex-direction:row; flex-wrap:wrap; border-top:none; padding-top: 1.3rem;
    margin-top: .3rem; border-top: 1px solid var(--border);
  }
  .two-col{ grid-template-columns: 1fr; gap: 1rem; }
}

@media (max-width: 560px){
  .page-shell{ padding: 1.8rem 1.25rem; }
  .section{ padding-bottom: 3rem; margin-bottom: 3rem; }
}

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