:root {
  --ink-50:  #F7F7F6;
  --ink-100: #EFEFED;
  --ink-200: #E2E2DF;
  --ink-300: #C9C9C4;
  --ink-400: #9A9A93;
  --ink-500: #6E6E66;
  --ink-600: #4A4A43;
  --ink-700: #2E2E2A;
  --ink-800: #1C1C1A;
  --ink-900: #101010;
  --accent:  #059669;

  --grain-dot: rgba(0, 0, 0, 0.025);
  --selection-bg: var(--ink-800);
  --selection-fg: var(--ink-50);
}

html.dark {
  --grain-dot: rgba(255, 255, 255, 0.035);
  --selection-bg: var(--ink-50);
  --selection-fg: var(--ink-900);
  color-scheme: dark;
}

html { scroll-behavior: smooth; }
body { font-feature-settings: "ss01", "cv11"; }

/* fade body on initial paint so theme switch isn't jarring */
body {
  transition: background-color 0.3s ease, color 0.3s ease;
}

.grain::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(var(--grain-dot) 1px, transparent 1px);
  background-size: 3px 3px;
  pointer-events: none;
  z-index: 0;
}

.hover-underline {
  background-image: linear-gradient(currentColor, currentColor);
  background-position: 0 100%;
  background-repeat: no-repeat;
  background-size: 0% 1px;
  transition: background-size 0.3s ease;
}
.hover-underline:hover { background-size: 100% 1px; }

.card-link { transition: background-color 0.3s ease; }
.card-link:hover .card-title { color: var(--accent); }
.card-link:hover .arrow { transform: translate(2px, -2px); }
.card-link:hover .card-image img { transform: scale(1.03); }
.arrow { transition: transform 0.25s ease; }

.card-image {
  overflow: hidden;
}
.card-image img {
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

::selection { background: var(--selection-bg); color: var(--selection-fg); }

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

/* Reveal on scroll */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--reveal-delay, 0s);
}
.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Hero entrance — runs once on load */
.fade-in {
  opacity: 0;
  transform: translateY(8px);
  animation: fadeInUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: var(--fade-delay, 0s);
}
@keyframes fadeInUp {
  to { opacity: 1; transform: none; }
}

/* Marker line that draws in */
.draw-line {
  transform: scaleX(0);
  transform-origin: left center;
  animation: drawLine 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: var(--fade-delay, 0s);
}
@keyframes drawLine {
  to { transform: scaleX(1); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal,
  .fade-in,
  .draw-line {
    opacity: 1;
    transform: none;
    animation: none;
    transition: none;
  }
  .arrow,
  .hover-underline,
  .card-image img,
  .back-to-top,
  body {
    transition: none;
  }
  .back-to-top { transform: none; }
}

.mobile-menu[hidden] { display: none; }

/* Theme toggle icon swap */
.theme-toggle .icon-moon { display: inline; }
.theme-toggle .icon-sun  { display: none; }
html.dark .theme-toggle .icon-moon { display: none; }
html.dark .theme-toggle .icon-sun  { display: inline; }

/* Active nav link */
.nav-link {
  position: relative;
  padding-bottom: 2px;
}
.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.nav-link.is-active {
  color: var(--ink-900);
}
html.dark .nav-link.is-active { color: var(--ink-50); }
.nav-link.is-active::after { transform: scaleX(1); }

.mobile-nav-link.is-active {
  color: var(--accent);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
  margin-left: -12px;
}

/* Floating back-to-top button */
.back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 30;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 9999px;
  background: var(--ink-900);
  color: var(--ink-50);
  border: 1px solid var(--ink-700);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s, background-color 0.2s ease;
}
html.dark .back-to-top {
  background: var(--ink-50);
  color: var(--ink-900);
  border-color: var(--ink-300);
}
.back-to-top:hover { background: var(--ink-700); }
html.dark .back-to-top:hover { background: var(--ink-200); }
.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
}

/* Experience timeline */
.exp-timeline {
  position: relative;
}
.exp-item {
  position: relative;
  padding-left: 3.5rem;
  padding-bottom: 1.5rem;
}
.exp-item:last-child {
  padding-bottom: 0;
}
/* connecting line between nodes */
.exp-item::before {
  content: "";
  position: absolute;
  left: 1.249rem;
  top: 2.5rem;
  bottom: -0.25rem;
  width: 1px;
  background: var(--ink-200);
}
.exp-item:last-child::before {
  display: none;
}
html.dark .exp-item::before {
  background: var(--ink-800);
}

.exp-node {
  position: absolute;
  left: 0;
  top: 0;
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink-300);
  border-radius: 9999px;
  background: var(--ink-50);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--ink-500);
  transition: color 0.3s ease, border-color 0.3s ease, background-color 0.3s ease, transform 0.3s ease;
}
html.dark .exp-node {
  border-color: var(--ink-700);
  background: var(--ink-900);
}
.exp-item:hover .exp-node {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.06);
}

.exp-org {
  position: relative;
  display: inline-block;
}

/* start–end period marker */
.exp-period {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-500);
}
.exp-period::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 0.5rem;
  vertical-align: middle;
  border-radius: 9999px;
  border: 1px solid var(--ink-400);
  background: transparent;
}
/* ongoing roles get a filled accent dot */
.exp-period.is-current {
  color: var(--accent);
}
.exp-period.is-current::before {
  background: var(--accent);
  border-color: var(--accent);
}
.exp-item:hover .exp-title {
  color: var(--accent);
}
.exp-title {
  transition: color 0.3s ease;
}

@media (prefers-reduced-motion: reduce) {
  .exp-node {
    transition: none;
  }
}

/* Blog article typography */
.article-body :where(h2, h3) {
  font-family: 'Fraunces', Georgia, serif;
  color: var(--ink-900);
  line-height: 1.25;
}
html.dark .article-body :where(h2, h3) { color: var(--ink-50); }

.article-body h2 {
  font-size: 1.625rem;
  margin-top: 2.75rem;
  margin-bottom: 1rem;
}
.article-body h3 {
  font-size: 1.25rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}
@media (min-width: 768px) {
  .article-body h2 { font-size: 1.875rem; }
  .article-body h3 { font-size: 1.375rem; }
}

.article-body p {
  color: var(--ink-700);
  line-height: 1.8;
  margin-top: 1.25rem;
}
html.dark .article-body p { color: var(--ink-300); }

.article-body :where(ul, ol) {
  margin-top: 1.25rem;
  padding-left: 1.25rem;
  color: var(--ink-700);
  line-height: 1.8;
}
html.dark .article-body :where(ul, ol) { color: var(--ink-300); }
.article-body ul { list-style: none; }
.article-body ul > li { position: relative; padding-left: 1.25rem; }
.article-body ul > li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.85em;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 9999px;
}
.article-body ol { list-style: decimal; }
.article-body ol > li::marker {
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  font-size: 0.85em;
}
.article-body li + li { margin-top: 0.5rem; }

.article-body strong {
  color: var(--ink-900);
  font-weight: 600;
}
html.dark .article-body strong { color: var(--ink-50); }

.article-body blockquote {
  margin: 2rem 0;
  padding: 0.25rem 0 0.25rem 1.5rem;
  border-left: 2px solid var(--accent);
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.25rem;
  font-style: italic;
  color: var(--ink-800);
  line-height: 1.6;
}
html.dark .article-body blockquote { color: var(--ink-100); }

.article-body figure {
  margin: 2.5rem 0;
}
.article-body figure img {
  width: 100%;
  border-radius: 2px;
  border: 1px solid var(--ink-200);
}
html.dark .article-body figure img { border-color: var(--ink-800); }
.article-body figcaption {
  margin-top: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-500);
  text-align: center;
}

.article-body hr {
  margin: 3rem 0;
  border: none;
  border-top: 1px solid var(--ink-200);
}
html.dark .article-body hr { border-color: var(--ink-800); }

.article-body a {
  color: var(--ink-900);
  text-decoration: underline;
  text-decoration-color: var(--ink-300);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s ease;
}
.article-body a:hover { text-decoration-color: var(--accent); }
html.dark .article-body a { color: var(--ink-50); }
html.dark .article-body a:hover { text-decoration-color: var(--accent); }
