/* ==========================================================================
   Design tokens
   ========================================================================== */

:root {
  --bg: #0b0c0f;
  --bg-elevated: #131519;
  --bg-elevated-2: #1a1d23;
  --text: #f4f5f7;
  --text-dim: #a3a8b4;
  --text-faint: #6b7080;
  --border: #23262e;
  --accent: #1eadab;
  --accent-dim: #163a39;
  --accent-text: #04211f;
  --icon-filter: invert(1);
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.6);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
  --nav-h: 76px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f7f7f5;
    --bg-elevated: #ffffff;
    --bg-elevated-2: #eeeeec;
    --text: #14161a;
    --text-dim: #4b4f58;
    --text-faint: #8a8e98;
    --border: #e3e3e0;
    --accent: #1eadab;
    --accent-dim: #cdeeed;
    --accent-text: #04211f;
    --icon-filter: none;
    --shadow: 0 20px 60px -25px rgba(20, 22, 26, 0.25);
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg: #f7f7f5;
  --bg-elevated: #ffffff;
  --bg-elevated-2: #eeeeec;
  --text: #14161a;
  --text-dim: #4b4f58;
  --text-faint: #8a8e98;
  --border: #e3e3e0;
  --accent: #1eadab;
  --accent-dim: #cdeeed;
  --accent-text: #04211f;
  --icon-filter: none;
  --shadow: 0 20px 60px -25px rgba(20, 22, 26, 0.25);
  color-scheme: light;
}

/* ==========================================================================
   Reset & base
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !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;
  transition: background 0.3s ease, color 0.3s ease;
}

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

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
}

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

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

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding: 120px 0;
  border-top: 1px solid var(--border);
}

@media (max-width: 720px) {
  .section {
    padding: 80px 0;
  }
}

.section-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 56px;
  max-width: 640px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow::before {
  content: "";
  width: 24px;
  height: 1px;
  background: var(--accent);
}

.section-head h2 {
  font-size: clamp(28px, 4vw, 42px);
}

.section-head p {
  color: var(--text-dim);
  font-size: 17px;
}

/* ==========================================================================
   Reveal-on-scroll
   ========================================================================== */

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* ==========================================================================
   Nav
   ========================================================================== */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
}

.nav-brand img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 36px;
}

.nav-links a {
  font-size: 14px;
  color: var(--text-dim);
  transition: color 0.2s ease;
  position: relative;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
  transform: rotate(15deg);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.icon-sun {
  display: none;
}
:root[data-theme="light"] .icon-moon {
  display: none;
}
:root[data-theme="light"] .icon-sun {
  display: block;
}

.nav-toggle {
  display: none;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
}

.nav-toggle svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 860px) {
  .nav-links {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px 24px;
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }
  .nav-links a {
    padding: 10px 0;
    width: 100%;
  }
  body.nav-open .nav-links {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
  .nav-toggle {
    display: flex;
  }
  .icon-close {
    display: none;
  }
  body.nav-open .icon-menu {
    display: none;
  }
  body.nav-open .icon-close {
    display: block;
  }
}

/* ==========================================================================
   Buttons & pills
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-mono);
  border: 1px solid var(--border);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-family: var(--font-mono);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.pill-accent {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

/* ==========================================================================
   Hero (bento layout)
   ========================================================================== */

.hero {
  padding: calc(var(--nav-h) + 64px) 0 100px;
}

.bento {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .bento {
    grid-template-columns: 1fr;
  }
}

.bento-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
}

.hero-intro {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
}

.hero-intro h1 {
  font-size: clamp(34px, 5.2vw, 58px);
}

.hero-intro h1 .accent {
  color: var(--accent);
}

.hero-intro .desc {
  color: var(--text-dim);
  font-size: 17px;
  max-width: 54ch;
}

.hero-intro .desc strong {
  color: var(--text);
  font-weight: 600;
}

.hero-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.hero-socials {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.hero-socials a {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.hero-socials a:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
}

.hero-socials img,
.footer-socials img {
  filter: var(--icon-filter);
  transition: filter 0.3s ease;
}

.hero-socials img {
  width: 17px;
  height: 17px;
}

.hero-side {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.hero-portrait {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 4 / 3;
}

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

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.stat-card {
  text-align: center;
  padding: 26px 12px;
}

.stat-card .num {
  font-family: var(--font-display);
  font-size: clamp(24px, 3vw, 32px);
  color: var(--accent);
}

.stat-card .label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 6px;
}

@media (max-width: 520px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Articles
   ========================================================================== */

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 22px;
}

.article-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.article-card:hover {
  transform: translateY(-6px);
  border-color: var(--accent-dim);
}

.article-thumb {
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--accent-dim), var(--bg-elevated-2));
  overflow: hidden;
}

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

.article-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.article-title {
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.35;
}

.article-excerpt {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.55;
  flex: 1;
}

.article-more {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   Portfolio
   ========================================================================== */

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 22px;
}

.project-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.project-card:hover {
  transform: translateY(-6px);
  border-color: var(--accent-dim);
}

.project-thumb {
  aspect-ratio: 16 / 10;
  position: relative;
  overflow: hidden;
}

.project-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.project-card:hover .project-thumb img {
  transform: scale(1.06);
}

.project-tags {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.project-tags .pill {
  background: color-mix(in srgb, var(--bg) 65%, transparent);
  backdrop-filter: blur(6px);
  border-color: color-mix(in srgb, var(--text) 15%, transparent);
  color: var(--text);
}

.project-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.project-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.project-title {
  font-family: var(--font-display);
  font-size: 19px;
}

.project-downloads {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
}

.project-role {
  font-size: 13px;
  color: var(--accent);
  font-family: var(--font-mono);
}

.project-desc {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.55;
  flex: 1;
}

.project-links-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-top: 4px;
}

.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.project-links a {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  transition: border-color 0.2s ease, color 0.2s ease;
}

.project-links a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ==========================================================================
   Experience timeline
   ========================================================================== */

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-left: 1px solid var(--border);
  margin-left: 28px;
}

.timeline-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 24px;
  padding: 28px 0 28px 32px;
  position: relative;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 34px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}

.timeline-logo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

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

.timeline-content h4 {
  font-size: 20px;
}

.timeline-content .date {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.timeline-content .role {
  display: block;
  color: var(--text-dim);
  font-size: 14px;
  font-family: var(--font-mono);
  margin-top: 2px;
}

.timeline-content p {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.6;
  margin-top: 10px;
  max-width: 60ch;
}

.timeline-positions {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 14px;
}

/* Multiple positions at one company (e.g. a promotion) render as a nested
   thread with its own connecting line + dot per role. */
.timeline-positions.threaded {
  padding-left: 22px;
  border-left: 2px solid var(--border);
}

.timeline-positions.threaded .timeline-position {
  position: relative;
}

.timeline-positions.threaded .timeline-position::before {
  content: "";
  position: absolute;
  left: -27px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

@media (max-width: 560px) {
  .timeline {
    margin-left: 0;
    border-left: none;
  }
  .timeline-item {
    grid-template-columns: 1fr;
    padding-left: 0;
    border-left: 1px solid var(--border);
    margin-left: 12px;
    padding-left: 24px;
  }
  .timeline-item::before {
    left: -6px;
  }
}

/* ==========================================================================
   404 page
   ========================================================================== */

.error-hero {
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  align-items: center;
  padding: 60px 0;
}

.error-card {
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.error-code {
  font-family: var(--font-display);
  font-size: clamp(64px, 12vw, 120px);
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
}

.error-card .desc {
  color: var(--text-dim);
  font-size: 17px;
}

.error-card .hero-links {
  justify-content: center;
  margin-top: 8px;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  padding: 60px 0 40px;
  border-top: 1px solid var(--border);
}

.footer .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.footer-socials {
  display: flex;
  gap: 14px;
}

.footer-socials img {
  width: 16px;
  height: 16px;
}

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

.back-to-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease, border-color 0.2s ease;
  z-index: 90;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  border-color: var(--accent);
}

.back-to-top svg {
  width: 18px;
  height: 18px;
}
