@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@300;400;500&display=swap');

/* ── Design tokens ── */
:root {
  --bg: #0a0e1a;
  --text:       #e8dcc8;
  --text-dim:   #b8ad9e;
  --text-muted: rgba(232, 220, 200, 0.58);
  --surface:      rgba(10, 14, 26, 0.58);
  --surface-side: rgba(8, 11, 22, 0.74);
  --border:        rgba(232, 220, 200, 0.09);
  --border-h:      rgba(232, 220, 200, 0.22);
  --border-accent: rgba(232, 220, 200, 0.2);
  --fill:   rgba(232, 220, 200, 0.05);
  --fill-h: rgba(232, 220, 200, 0.1);
  --fill-a: rgba(232, 220, 200, 0.13);
  --blur:      18px;
  --sidebar-w: 260px;
  --content-w: 540px;
  --font: 'Figtree', system-ui, -apple-system, sans-serif;
}

/* ── Light mode ── */
body.light {
  --bg: #e4ddd0;
  --text:       #000000;
  --text-dim:   #1c1c1c;
  --text-muted: rgba(0, 0, 0, 0.52);
  --surface:      rgba(205, 193, 175, 0.40);
  --surface-side: rgba(198, 184, 165, 0.68);
  --border:        rgba(13, 18, 36, 0.09);
  --border-h:      rgba(13, 18, 36, 0.22);
  --border-accent: rgba(13, 18, 36, 0.22);
  --fill:   rgba(13, 18, 36, 0.05);
  --fill-h: rgba(13, 18, 36, 0.09);
  --fill-a: rgba(13, 18, 36, 0.12);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
html { font-size: 19px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 500;
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ── Vertical split line ── */
body::after {
  content: '';
  position: fixed;
  left: 50%;
  top: 0;
  height: 100vh;
  width: 1px;
  background: var(--border-h);
  z-index: 5;
  pointer-events: none;
}

/* ─────────────────────────────────────────
   PARTICLE ZONES
   Both canvases are full-viewport so that
   particle x/y positions match window coords
   exactly — fixing the mouse-offset bug.
   The right zone is clipped via clip-path
   to hide particles behind the sidebar.
───────────────────────────────────────── */
/* One canvas, full viewport, clipped to right half only.
   Left half has zero particles by design. */
#particles-right-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  /* L-shaped clip: full width from sidebar edge in the tab-nav strip (top 10rem),
     right half only below that — so particles are visible behind the tab buttons
     but not behind the intro / body text. */
  -webkit-clip-path: inset(0 0 0 50%);
  clip-path: inset(0 0 0 50%);
}

#particles-left-bg canvas,
#particles-right-bg canvas {
  position: absolute !important;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

/* ── App shell ── */
#app {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

/* ── Sidebar ── */
#sidebar {
  height: 100vh;
  overflow-y: auto;
  padding: 1.5rem 1.75rem 2rem;
  background: var(--surface-side);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border-right: 1px solid var(--border);
  scrollbar-width: none;
  transition: background 0.3s ease, border-color 0.3s ease;
}
#sidebar::-webkit-scrollbar { display: none; }

/* ── Theme toggle ── */
.theme-toggle-wrap {
  margin-bottom: 1.6rem;
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  background: var(--fill);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 0.28rem 0.75rem;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  outline: none;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}
.theme-btn:hover {
  background: var(--fill-h);
  color: var(--text);
  border-color: var(--border-h);
}
.theme-btn svg {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
  opacity: 0.6;
}

/* ── Avatar ── */
.avatar {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: 1px solid var(--border-h);
  background: var(--fill);
  overflow: hidden;
  position: relative;
  margin-bottom: 1.1rem;
  transition: border-color 0.3s;
}
.avatar-initials {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Sidebar text ── */
.profile-name {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}
.profile-handle {
  font-size: 0.76rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
  font-weight: 500;
}
.profile-bio {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.85rem;
  line-height: 1.65;
}
.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 1.2rem 0;
  transition: background 0.3s;
}
.meta-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.meta-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.62rem;
  color: var(--text-dim);
}
.meta-item a {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
}
.meta-item a:hover { color: var(--text); }
.meta-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: 0.4;
}
.sidebar-section-label {
  font-size: 0.63rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  opacity: 0.5;
  margin-bottom: 0.55rem;
}
.affil-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.affil-list li {
  font-size: 0.76rem;
  color: var(--text-dim);
}

/* ── Download buttons ── */
.dl-buttons {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
}

.dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--fill);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 9999px;
  padding: 0.36rem 0.9rem;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.74rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  text-decoration: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}
.dl-btn:hover {
  background: var(--fill-h);
  color: var(--text);
  border-color: var(--border-h);
}
.dl-btn svg {
  opacity: 0.45;
  flex-shrink: 0;
}

/* ── Glimmer effect (shared by tab-btn, theme-btn, dl-btn) ── */
.tab-btn::before,
.dl-btn::before,
.theme-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    circle at var(--gx, 50%) var(--gy, 50%),
    rgba(255, 255, 255, 0.15) 0%,
    transparent 65%
  );
  opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: none;
}
.tab-btn:hover::before,
.dl-btn:hover::before,
.theme-btn:hover::before {
  opacity: 1;
}

body.light .tab-btn::before,
body.light .dl-btn::before,
body.light .theme-btn::before {
  background: radial-gradient(
    circle at var(--gx, 50%) var(--gy, 50%),
    rgba(0, 0, 0, 0.07) 0%,
    transparent 65%
  );
}

/* ── Main content ── */
#main-content {
  height: 100vh;
  overflow-y: auto;
  padding: 2.8rem 3.5rem 4rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#main-content::-webkit-scrollbar { width: 3px; }
#main-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ── Tab nav ── */
#tab-nav {
  display: flex;
  gap: 0.45rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid var(--border-accent);
  margin-bottom: 2.2rem;
  max-width: var(--content-w);
  transition: border-color 0.3s;
}

.tab-btn {
  background: var(--fill);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 9999px;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  padding: 0.46rem 1.35rem;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  outline: none;
  user-select: none;
}
.tab-btn:hover {
  background: var(--fill-h);
  color: var(--text);
  border-color: var(--border-h);
}
.tab-btn.active {
  background: var(--fill-a);
  color: var(--text);
  border-color: var(--border-h);
}

/* ── Tab panels ── */
#tab-panels {
  max-width: var(--content-w);
}

.tab-panel { display: none; }
.tab-panel.active {
  display: block;
  animation: fadeUp 0.24s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Intro — particle shield ── */
.intro {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 1.8rem;
  line-height: 1.75;
  /* invisible glass bubble: blurs particles behind, no visible border */
  background: rgba(10, 14, 26, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}
body.light .intro {
  background: rgba(228, 221, 208, 0.18);
}

/* ── Section labels ── */
.section-label {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  opacity: 0.78;
  margin-bottom: 0.8rem;
  margin-top: 2rem;
  padding-left: 0.7rem;
  border-left: 2px solid var(--border-accent);
}

/* ── Glass cards ── */
.glass-card {
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border-radius: 10px;
  padding: 1.05rem 1.3rem;
  margin-bottom: 0.6rem;
  transition: border-color 0.18s, background 0.3s;
}
.glass-card:hover {
  border-color: var(--border-h);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}
.card-role {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.card-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.card-org {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-top: 0.18rem;
}
.card-body {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.55rem;
  line-height: 1.65;
}
.glass-card.research .card-role {
  margin-bottom: 0.2rem;
}

/* ── Pills ── */
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.pill {
  background: var(--fill);
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 0.72rem;
  color: var(--text-dim);
  padding: 0.2rem 0.7rem;
  letter-spacing: 0.01em;
}
.pill.lang {
  font-weight: 400;
  letter-spacing: 0.06em;
  font-size: 0.67rem;
  text-transform: uppercase;
}

/* ── GitHub link card ── */
.gh-card { display: flex; align-items: center; }
.gh-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s;
}
.gh-link:hover { color: var(--text); }
.gh-link svg { opacity: 0.45; flex-shrink: 0; }

/* ── Typewriter ── */
#typewriter-wrap {
  position: fixed;
  left: 52%;
  top: 60%;
  right: auto;
  max-width: 36vw;
  z-index: 3;
  pointer-events: none;
}

#typewriter-text,
.tw-cursor {
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  opacity: 0.68;
}

.tw-cursor {
  display: inline-block;
  width: 1.5px;
  height: 1.1rem;
  background: var(--text-dim);
  margin-left: 2px;
  vertical-align: text-bottom;
  border-radius: 1px;
  animation: tw-blink 0.75s step-end infinite;
}

@keyframes tw-blink {
  0%, 100% { opacity: 0.68; }
  50%       { opacity: 0; }
}

/* ── Comet animation ── */
.tw-comet {
  position: fixed;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text);
  box-shadow:
    0 0 6px 2px var(--text-dim),
    0 0 14px 5px rgba(184, 173, 158, 0.18);
  pointer-events: none;
  z-index: 100;
  transform: translate(-50%, -50%);
}

.tw-trail {
  position: fixed;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-dim);
  opacity: 0.45;
  pointer-events: none;
  z-index: 99;
  transform: translate(-50%, -50%);
  transition: opacity 0.48s ease;
}

.tw-cursor--hidden {
  display: none !important;
}

/* ── Particle mode controls ── */
#particle-controls {
  position: fixed;
  bottom: 1.4rem;
  right: 1.6rem;
  z-index: 10;
  display: flex;
  gap: 0.38rem;
  opacity: 0.28;
  transition: opacity 0.22s ease;
}
#particle-controls:hover { opacity: 1; }

.pmode-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  background: var(--fill);
  border: 1px solid var(--border);
  border-radius: 9999px;
  color: var(--text-dim);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pmode-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.pmode-btn:hover {
  background: var(--fill-h);
  border-color: var(--border-h);
  color: var(--text);
}
.pmode-btn.active {
  background: var(--fill-a);
  border-color: var(--border-h);
  color: var(--text);
}

/* ── Responsive ── */
@media (max-width: 820px) {
  :root { --sidebar-w: 200px; --content-w: 480px; }
  #main-content { padding: 2.5rem 2rem 3rem; }
}

@media (max-width: 640px) {
  html, body { overflow: auto; }
  body::after { display: none; }
  #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; }
  #particles-right-bg { -webkit-clip-path: none; clip-path: none; }
  #typewriter-wrap { display: none; }
  #sidebar {
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 1.5rem;
  }
  #main-content { height: auto; padding: 2rem 1.5rem 3rem; }
  :root { --content-w: 100%; }
}
