/* =========================================================
   Design tokens
   ========================================================= */
:root {
  --bg-color: #fafafa;
  --bg-elevated: #ffffff;
  --card-bg: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --accent: #0f172a;
  --accent-soft: #1e293b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --pill-bg: #f1f5f9;
  --pill-text: #334155;
  --shadow-sm: 0 1px 2px 0 rgb(15 23 42 / 0.04);
  --shadow-md: 0 4px 6px -1px rgb(15 23 42 / 0.05),
    0 2px 4px -2px rgb(15 23 42 / 0.04);
  --shadow-lg: 0 10px 30px -8px rgb(15 23 42 / 0.12),
    0 4px 8px -4px rgb(15 23 42 / 0.06);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --max-width: 1140px;
  --nav-height: 76px;
  --section-pad-y: clamp(72px, 10vw, 128px);
}

/* =========================================================
   Reset / base
   ========================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--nav-height);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

a {
  color: inherit;
  text-decoration: none;
  transition: var(--transition-fast);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

p {
  margin: 0;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

::selection {
  background: var(--accent);
  color: #fff;
}

/* =========================================================
   Layout primitives
   ========================================================= */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 40px);
  width: 100%;
}

.section {
  padding: var(--section-pad-y) 0;
  border-bottom: 1px solid var(--border);
}

.section:last-of-type {
  border-bottom: none;
}

.section__header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 48px;
}

.section__title {
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.15;
}

.eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* =========================================================
   Navigation
   ========================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 40px);
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.nav__brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.nav__menu {
  display: flex;
  gap: clamp(20px, 3vw, 40px);
  align-items: center;
}

.nav__link {
  position: relative;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 0;
}

.nav__link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  transition: var(--transition-fast);
}

.nav__link:hover,
.nav__link.is-active {
  color: var(--text-primary);
}

.nav__link:hover::after,
.nav__link.is-active::after {
  width: 100%;
}

/* Hamburger */
.nav__toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  border: 1px solid var(--border);
  background: #fff;
  transition: var(--transition-fast);
}

.nav__toggle span {
  display: block;
  width: 18px;
  height: 1.8px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: var(--transition-fast);
}

.nav__toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav__toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav__toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* =========================================================
   About / hero
   ========================================================= */
.section--hero {
  padding-top: clamp(64px, 9vw, 112px);
  border-bottom: 1px solid var(--border);
}

.about {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: clamp(32px, 5vw, 72px);
  align-items: center;
}

.about__text {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.about__name {
  font-size: clamp(40px, 6vw, 64px);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.about__title {
  font-size: clamp(17px, 1.6vw, 19px);
  color: var(--text-secondary);
  font-weight: 500;
}

.about__bio {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.75;
  max-width: 56ch;
}

.about__cta {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  font-size: 14.5px;
  font-weight: 500;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: #1e293b;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn--ghost {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn--ghost:hover {
  background: var(--text-primary);
  color: #fff;
  border-color: var(--text-primary);
  transform: translateY(-1px);
}

.about__media {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 4 / 5;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.about__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* =========================================================
   Education card
   ========================================================= */
.education-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(28px, 4vw, 40px);
  box-shadow: var(--shadow-sm);
}

.education-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.education-card__title {
  font-size: clamp(22px, 2.5vw, 26px);
  font-weight: 700;
}

.education-card__meta {
  color: var(--text-secondary);
  font-size: 14.5px;
  margin-top: 4px;
}

.education-card__period {
  font-size: 13.5px;
  color: var(--text-tertiary);
  font-weight: 500;
  text-align: right;
}

.education-card__body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
  margin-top: 24px;
}

.education-fact h4 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}

.education-fact p {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 15px;
}

.education-fact ul {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.education-fact ul li {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 15px;
}

.education-fact .award-period {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* =========================================================
   Timeline (experience)
   ========================================================= */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.timeline-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 28px clamp(20px, 3vw, 32px);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.timeline-item:hover {
  transform: translateX(2px);
  box-shadow: var(--shadow-md);
}

.timeline-item__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.timeline-item__title {
  font-size: 18px;
  font-weight: 600;
}

.timeline-item__period {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 500;
  white-space: nowrap;
}

.timeline-item__meta {
  font-size: 14.5px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.timeline-item__bullets {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.timeline-item__bullets li {
  position: relative;
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 14.5px;
  line-height: 1.65;
}

.timeline-item__bullets li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
}

/* =========================================================
   Leadership
   ========================================================= */
.leadership-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.leadership-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.leadership-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.leadership-card__org {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 18px;
  letter-spacing: -0.01em;
}

.leadership-card__roles {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.leadership-role {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.leadership-role:first-child {
  border-top: none;
  padding-top: 0;
}

.leadership-role__title {
  font-size: 14.5px;
  color: var(--text-primary);
  font-weight: 500;
}

.leadership-role__period {
  font-size: 13px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* =========================================================
   Projects
   ========================================================= */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 24px;
}

.project-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.project-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}

.project-card__media {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.project-card__media img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 14px;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Only apply the hover-slide carousel when there are two images */
.project-card__media img + img {
  opacity: 0;
  transform: translateX(20px);
}

.project-card__media:has(img + img):hover img:first-child {
  opacity: 0;
  transform: translateX(-20px);
}

.project-card__media:has(img + img):hover img + img {
  opacity: 1;
  transform: translateX(0);
}

.project-card__body {
  padding: 24px 26px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex-grow: 1;
}

.project-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.project-card__title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.project-card__period {
  font-size: 12.5px;
  color: var(--text-tertiary);
  font-weight: 500;
  white-space: nowrap;
  padding-top: 4px;
}

.project-card__github {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-primary);
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.project-card__github:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-1px);
}

.project-card__github svg {
  width: 18px;
  height: 18px;
}

.project-card__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--pill-bg);
  color: var(--pill-text);
  white-space: nowrap;
}

.project-card__description {
  font-size: 14.5px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* =========================================================
   Contact
   ========================================================= */
.section--contact {
  text-align: center;
}

.contact {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.contact__lead {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 52ch;
}

.contact__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
}

.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--card-bg);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
}

.contact-link:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.contact-link svg {
  width: 18px;
  height: 18px;
}

/* =========================================================
   Footer
   ========================================================= */
.site-footer {
  padding: 32px 0;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.site-footer__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-tertiary);
}

/* =========================================================
   Loader
   ========================================================= */
.loader {
  position: fixed;
  inset: 0;
  background: var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: opacity 0.4s ease;
}

.loader.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.loader__spinner {
  width: 32px;
  height: 32px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================
   Reveal animation
   ========================================================= */
.section {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.section.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 880px) {
  .about {
    grid-template-columns: 1fr;
    text-align: left;
  }
  .about__media {
    order: -1;
    max-width: 320px;
    aspect-ratio: 1 / 1;
  }
}

@media (max-width: 768px) {
  :root {
    --nav-height: 68px;
  }

  .nav__toggle {
    display: inline-flex;
  }

  .nav__menu {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 8px 0 16px;
    transform: translateY(-12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
  }

  .nav__menu.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .nav__menu li {
    width: 100%;
  }

  .nav__link {
    display: block;
    padding: 14px clamp(20px, 4vw, 40px);
    font-size: 15.5px;
    color: var(--text-primary);
  }

  .nav__link::after {
    display: none;
  }

  .nav__link:hover,
  .nav__link.is-active {
    background: var(--pill-bg);
  }

  .section__header {
    margin-bottom: 36px;
  }

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

  .education-card__head,
  .timeline-item__head {
    flex-direction: column;
    align-items: flex-start;
  }

  .education-card__period,
  .timeline-item__period {
    text-align: left;
  }
}

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