/* ==========================================================================
   Tokens (dark theme = default)
   ========================================================================== */
:root {
  --bg: #0F1115;
  --surface: #171A21;
  --surface-2: #1E222B;
  --border: #2A2F3A;
  --text: #EAEBEF;
  --text-muted: #8992A6;
  --text-faint: #565D6E;
  --accent: #F2A93C;
  --accent-soft: rgba(242, 169, 60, 0.14);
  --accent-2: #5FB3B3;

  --font-display: "Space Grotesk", "Inter", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --container: 1120px;
  --nav-h: 72px;

  /* smooth theme transitions */
  --theme-transition: background 0.25s ease, color 0.25s ease,
                      border-color 0.25s ease, fill 0.25s ease;
}

/* Light theme overrides (only applied via JS) */
body.light-theme {
  --bg: #F5F7FA;
  --surface: #EDF0F5;
  --surface-2: #E2E6ED;
  --border: #D0D5DE;
  --text: #1A1E26;
  --text-muted: #4A5266;
  --text-faint: #7A8399;
  --accent: #D48C2C;
  --accent-soft: rgba(212, 140, 44, 0.15);
  --accent-2: #3A8F8F;
}

* {
  box-sizing: border-box;
  transition: background var(--theme-transition), color var(--theme-transition),
              border-color var(--theme-transition), fill var(--theme-transition);
}
html { scroll-behavior: smooth; scroll-padding-top: var(--nav-h); }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

p { margin: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

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

.section-inner, .nav-inner, .hero-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 32px;
}

/* Jupyter‑style labels */
.cell-label {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 14px;
  letter-spacing: 0.02em;
}
.cell-label .fn { color: var(--text-muted); }

.cell-out {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-faint);
}

.section-title {
  font-size: clamp(28px, 4vw, 38px);
  margin-bottom: 40px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 26px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn-sm { padding: 9px 16px; font-size: 13px; }

.btn-primary {
  background: var(--accent);
  color: #16110A;
}
.btn-primary:hover { background: #ffb955; }
.light-theme .btn-primary:hover { background: #e6a03a; }

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
  transition: border-color 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
.light-theme .theme-toggle .icon-sun { display: block; }
.light-theme .theme-toggle .icon-moon { display: none; }

/* ==========================================================================
   Navbar
   ========================================================================== */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 100;
  background: rgba(15, 17, 21, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  transition: background var(--theme-transition), border-color var(--theme-transition);
}
.light-theme .navbar {
  background: rgba(245, 247, 250, 0.85);
}
.nav-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}
.brand-bracket { color: var(--accent); }

.nav-menu {
  display: flex;
  align-items: center;
  gap: 40px;
}
.nav-links {
  list-style: none;
  display: flex;
  gap: 30px;
  margin: 0;
  padding: 0;
}
.nav-links a {
  font-size: 14.5px;
  color: var(--text-muted);
  transition: color 0.15s ease;
  position: relative;
}
.nav-links a:hover { color: var(--text); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.lang-switch {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px;
  font-family: var(--font-mono);
}
.lang-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 5px 12px;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.lang-btn.active { background: var(--accent); color: #16110A; }
.light-theme .lang-btn.active { color: #16110A; }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
}
.nav-toggle span {
  width: 22px;
  height: 2px;
  background: var(--text);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  padding-top: calc(var(--nav-h) + 60px);
  padding-bottom: 60px;
  min-height: 92vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    radial-gradient(ellipse 900px 500px at 85% 15%, var(--accent-soft), transparent 60%);
}
.hero-inner {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 40px;
  align-items: center;
  width: 100%;
}
.hero-name {
  font-size: clamp(40px, 6vw, 64px);
  line-height: 1.05;
  margin-bottom: 10px;
}
.hero-title {
  font-family: var(--font-mono);
  font-size: clamp(16px, 2vw, 19px);
  color: var(--accent);
  margin-bottom: 18px;
}
.hero-tagline {
  font-size: 17px;
  color: var(--text-muted);
  max-width: 46ch;
  margin-bottom: 32px;
}
.hero-actions {
  display: flex;
  gap: 14px;
  margin-bottom: 34px;
  flex-wrap: wrap;
}

.hero-chart {
  width: 100%;
  max-width: 100%;
}
.loss-svg {
  width: 100%;
  height: auto;
  max-width: 100%;
  overflow: visible;
}
.loss-svg .grid line { stroke: var(--border); stroke-width: 1; }
.loss-svg .grid-line { stroke-dasharray: 3 5; opacity: 0.6; }
.axis-label {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--text-faint);
}
.legend-text {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--text-muted);
}
.legend-dot.train { fill: var(--accent); }
.legend-dot.val { fill: var(--accent-2); }

.train-line, .val-line {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 900;
  stroke-dashoffset: 900;
  animation: draw-line 2.2s cubic-bezier(0.6, 0.02, 0.15, 1) forwards;
  animation-delay: 0.3s;
}
.train-line { stroke: var(--accent); }
.val-line { stroke: var(--accent-2); stroke-dasharray: 6 5, 900; animation-delay: 0.5s; }

@keyframes draw-line {
  to { stroke-dashoffset: 0; }
}

.scroll-cue {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}
.scroll-cue span {
  width: 1px; height: 40px;
  background: linear-gradient(var(--border), transparent);
  display: block;
}

/* ==========================================================================
   Sections
   ========================================================================== */
.section { padding: 100px 0; }
.section-alt { background: var(--surface); }

/* About */
.about-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 56px;
  align-items: start;
}
.about-photo {
  width: 240px;
  height: 240px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  background: var(--surface-2);
}
.about-photo img { width: 100%; height: 100%; object-fit: cover; }
.avatar-fallback {
  display: none;
  align-items: center; justify-content: center;
  width: 100%; height: 100%;
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 600;
  color: var(--accent);
  background: var(--surface-2);
}
.about-text {
  font-size: 17px;
  color: var(--text-muted);
  max-width: 62ch;
  margin-bottom: 40px;
}
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 40px;
}
.stat-num {
  font-family: var(--font-mono);
  font-size: 30px;
  color: var(--accent);
  font-weight: 600;
}
.stat-label {
  font-size: 13px;
  color: var(--text-faint);
  margin-top: 4px;
}

/* Skills — tag‑based, no bars/percentages */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 48px 60px;
}
.skill-category-title {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}
.skill-items-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}
.skill-item-tag {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  transition: border-color 0.2s, background 0.2s;
}
.skill-item-tag:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Experience */
.timeline {
  position: relative;
  padding-left: 32px;
  border-left: 1px solid var(--border);
}
.timeline-item {
  position: relative;
  padding-bottom: 44px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -37px;
  top: 4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}
.timeline-period {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--accent);
  margin-bottom: 6px;
}
.timeline-role { font-size: 19px; margin-bottom: 2px; }
.timeline-company { font-size: 14.5px; color: var(--text-muted); margin-bottom: 12px; }
.timeline-desc { font-size: 15px; color: var(--text-muted); max-width: 68ch; }

/* Projects */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 28px;
}
.project-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.section-alt .project-card { background: var(--surface-2); }
.project-card:hover { border-color: var(--accent); transform: translateY(-3px); }
.project-thumb {
  aspect-ratio: 16 / 9;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 12px;
  overflow: hidden;
}
.project-thumb img { width: 100%; height: 100%; object-fit: cover; }
.project-body { padding: 22px; flex: 1; display: flex; flex-direction: column; }
.project-title { font-size: 18px; margin-bottom: 8px; }
.project-desc { font-size: 14.5px; color: var(--text-muted); margin-bottom: 16px; flex: 1; }
.project-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 9px;
  border-radius: 4px;
}
.project-link {
  font-size: 13.5px;
  color: var(--accent);
  font-weight: 600;
}
.project-link:hover { text-decoration: underline; }

/* Publications */
.cv-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 30px;
  margin-bottom: 36px;
}
.cv-card h3 { font-size: 18px; margin-bottom: 6px; }
.cv-card p { color: var(--text-muted); font-size: 14px; }
.cv-card-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.pub-list { list-style: none; margin: 0; padding: 0; }
.pub-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.pub-item:last-child { border-bottom: none; }
.pub-main { flex: 1; min-width: 220px; }
.pub-title { font-size: 15.5px; margin-bottom: 4px; }
.pub-meta { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-faint); }
.pub-link {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.pub-link:hover { border-color: var(--accent); }

/* Contact */
.contact-lead {
  font-size: 18px;
  color: var(--text-muted);
  max-width: 50ch;
  margin-bottom: 44px;
}
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}
.contact-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.section-alt .contact-item { background: var(--surface-2); }
.contact-item:hover { border-color: var(--accent); transform: translateY(-2px); }
.contact-icon {
  width: 38px; height: 38px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 15px;
  flex-shrink: 0;
}
.contact-label { font-size: 12px; color: var(--text-faint); margin-bottom: 2px; }
.contact-value { font-size: 14.5px; color: var(--text); word-break: break-word; }

/* Footer */
.footer {
  padding: 40px 32px 50px;
  text-align: center;
  border-top: 1px solid var(--border);
}

/* Scroll reveal */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.in-view { opacity: 1; transform: translateY(0); }

/* ==========================================================================
   RESPONSIVE BREAKPOINTS — Super fluid
   ========================================================================== */

/* Tablets & small laptops */
@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-chart { order: -1; max-width: 460px; margin: 0 auto; }
  .about-grid { grid-template-columns: 1fr; }
  .about-photo { width: 180px; height: 180px; }
  .skills-grid { grid-template-columns: 1fr; }
}

/* Mobile navigation & spacing */
@media (max-width: 768px) {
  .nav-toggle { display: flex; }
  .nav-menu {
    position: fixed;
    top: var(--nav-h);
    left: 0; right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: flex-start;
    gap: 24px;
    padding: 28px 32px 34px;
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }
  .nav-menu.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
  .nav-links { flex-direction: column; gap: 18px; }
  .nav-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 12px;
  }
  .section { padding: 70px 0; }
  .section-inner, .nav-inner, .hero-inner { padding: 0 20px; }
  .hero { padding-top: calc(var(--nav-h) + 36px); }
}

/* Small phones */
@media (max-width: 480px) {
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .hero-actions .btn {
    justify-content: center;
  }
  .stats-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
  .stat-num { font-size: 24px; }
  .cv-card {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Ultra‑small devices (≤ 400px) */
@media (max-width: 400px) {
  .section-inner, .nav-inner, .hero-inner {
    padding: 0 16px;
  }

  .hero-name {
    font-size: clamp(32px, 10vw, 40px);
  }
  .hero-title {
    font-size: 15px;
  }
  .hero-tagline {
    font-size: 15px;
  }
  .hero-chart {
    max-width: 100%;
  }

  .about-photo {
    width: 140px;
    height: 140px;
    margin: 0 auto;
  }
  .about-grid {
    gap: 32px;
  }
  .about-text {
    font-size: 15px;
  }

  .stats-row {
    grid-template-columns: 1fr;
    gap: 12px;
    text-align: center;
  }
  .stat-num {
    font-size: 28px;
  }

  .skills-grid {
    gap: 32px;
  }
  .skill-items-list {
    gap: 6px 8px;
  }
  .skill-item-tag {
    font-size: 13px;
    padding: 3px 10px;
  }

  .projects-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .contact-grid {
    grid-template-columns: 1fr;
  }

  .timeline {
    padding-left: 20px;
  }
  .timeline-item::before {
    left: -25px;
    width: 8px;
    height: 8px;
  }
  .timeline-role {
    font-size: 17px;
  }
  .timeline-desc {
    font-size: 14px;
  }

  .cv-card {
    padding: 20px;
  }

  .section {
    padding: 50px 0;
  }
  .section-title {
    font-size: 26px;
    margin-bottom: 28px;
  }
}

/* ==========================================================================
   ADDITIONS: Skip link, Back-to-top, Form, Copy, Toast, Last updated
   ========================================================================== */

/* --- Skip link --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #16110A;
  padding: 12px 24px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-weight: 600;
  z-index: 999;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 0;
}

/* --- Back-to-top --- */
.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: #16110A;
  border: none;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s;
  z-index: 99;
}
.back-to-top.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.back-to-top:hover {
  background: #ffb955;
}
.light-theme .back-to-top:hover {
  background: #e6a03a;
}

/* --- Contact form --- */
.contact-form-wrap {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}
.contact-form-wrap .form-heading {
  font-size: 20px;
  margin-bottom: 20px;
  font-family: var(--font-display);
}
.contact-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.contact-form .form-group:last-of-type {
  grid-column: 1 / -1;
}
.contact-form .form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.contact-form .form-group input,
.contact-form .form-group textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  transition: border-color 0.2s;
}
.contact-form .form-group input:focus,
.contact-form .form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.contact-form button[type="submit"] {
  grid-column: 1 / -1;
  justify-self: start;
  min-width: 140px;
}
.form-status {
  grid-column: 1 / -1;
  font-size: 14px;
  min-height: 28px;
  margin-top: 4px;
}

/* --- Copy badge on contact card --- */
.contact-item .copy-badge {
  margin-left: auto;
  font-size: 14px;
  opacity: 0.5;
  transition: opacity 0.2s;
}
.contact-item:hover .copy-badge {
  opacity: 1;
}

/* --- Toast notification --- */
.toast-msg {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  z-index: 999;
  animation: toastIn 0.3s ease;
}
.toast-msg.fade-out {
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
}
@keyframes toastIn {
  0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --- Footer last updated --- */
.footer-last-updated {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 10px;
}

/* --- Responsive tweaks for form --- */
@media (max-width: 600px) {
  .contact-form {
    grid-template-columns: 1fr;
  }
  .contact-form .form-group:last-of-type {
    grid-column: 1;
  }
  .contact-form button[type="submit"] {
    grid-column: 1;
    width: 100%;
    justify-self: stretch;
  }
  .back-to-top {
    bottom: 20px;
    right: 20px;
    width: 42px;
    height: 42px;
    font-size: 20px;
  }
}