/* ---------- Tokens (dark-first design; light mode below) ---------- */
:root {
  color-scheme: dark;
  --bg: #0a0b10;
  --bg-soft: #12141d;
  --bg-card: #10121a;
  --text: #eef0f6;
  --text-muted: #9aa3b5;
  --accent: #22d3ee;
  --accent-2: #a78bfa;
  --border: #232735;
  --gradient: linear-gradient(100deg, var(--accent), var(--accent-2));
  --on-gradient: #0a0b10;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --code-comment: #6b7487;
  --code-keyword: #a78bfa;
  --code-string: #34d399;
  --code-number: #fbbf24;
  --code-func: #22d3ee;
}

/* Light palette: darker accent stops so gradient text and markers
   keep their contrast on white */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #fafbfd;
  --bg-soft: #f1f4f9;
  --bg-card: #ffffff;
  --text: #14171f;
  --text-muted: #5b6472;
  --accent: #0e7490;
  --accent-2: #7c3aed;
  --border: #dde3ec;
  --on-gradient: #ffffff;
  --code-comment: #6b7280;
  --code-keyword: #7c3aed;
  --code-string: #059669;
  --code-number: #b45309;
  --code-func: #0e7490;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #fafbfd;
    --bg-soft: #f1f4f9;
    --bg-card: #ffffff;
    --text: #14171f;
    --text-muted: #5b6472;
    --accent: #0e7490;
    --accent-2: #7c3aed;
    --border: #dde3ec;
    --on-gradient: #ffffff;
    --code-comment: #6b7280;
    --code-keyword: #7c3aed;
    --code-string: #059669;
    --code-number: #b45309;
    --code-func: #0e7490;
  }
}

/* ---------- Base ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

/* Scale everything up a notch on large monitors so the page doesn't
   look tiny in the middle of the screen (layout widths are in rem) */
@media (min-width: 1600px) {
  html {
    font-size: 112.5%;
  }
}

/* Footer always sits at the bottom of the screen, even on short pages */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1 0 auto;
}

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

/* Horizontal padding only, so it doesn't wipe out the vertical
   padding of <section class="container"> blocks */
.container {
  max-width: 60rem;
  margin: 0 auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05em 0.35em;
}

h1, h2, h3 {
  font-family: var(--font-display);
}

.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
}

.nav-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: 0.02em;
}

.nav-name {
  padding: 0.35rem 0;
}

.nav-name:hover {
  text-decoration: none;
}

.nav-dot {
  color: var(--accent);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  font-size: 0.92rem;
  font-weight: 500;
}

.nav-links a {
  color: var(--text-muted);
}

/* Taller hit area for thumbs */
.nav-links a:not(.nav-cta) {
  padding: 0.45rem 0.1rem;
}

.nav-links a:hover {
  color: var(--text);
  text-decoration: none;
}

.nav-links .nav-cta {
  padding: 0.4rem 1rem;
  line-height: 1.4;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
}

.nav-links .nav-cta:hover,
.nav-links .nav-cta.nav-active {
  border-color: var(--accent);
  color: var(--accent);
}

#theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease;
}

#theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Show the icon of the theme you'd switch TO (design is dark-first) */
.icon-sun { display: block; }
.icon-moon { display: none; }

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

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .icon-sun { display: none; }
  :root:not([data-theme="dark"]) .icon-moon { display: block; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 7rem 0 3rem;
  overflow: hidden;
}

/* background glow + grid */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(600px 300px at 20% 10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
    radial-gradient(600px 300px at 85% 60%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent 70%),
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: auto, auto, 44px 44px, 44px 44px;
  opacity: 0.5;
  mask-image: linear-gradient(to bottom, black 60%, transparent);
  pointer-events: none;
}

.hero .container {
  position: relative;
}

.hero-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  margin-bottom: 2rem;
  background: color-mix(in srgb, var(--bg-soft) 70%, transparent);
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .pulse { animation: none; }
}

.hero-name {
  font-size: clamp(2.6rem, 9.5vw, 5.2rem);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.03em;
  margin-bottom: 1.5rem;
}

.hero-tagline {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 3.5vw, 1.9rem);
  font-weight: 500;
  margin-bottom: 1rem;
}

.hero-tagline em {
  font-style: normal;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-summary {
  color: var(--text-muted);
  max-width: 68ch;
  margin-bottom: 2.25rem;
  font-size: 1.05rem;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.btn {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  transition: border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}

.btn:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-2px);
}

.btn-primary {
  background: var(--gradient);
  border: none;
  color: var(--on-gradient);
}

.btn-primary:hover {
  box-shadow: 0 6px 24px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* ---------- Stats ---------- */
.stats {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 2.5rem 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2rem;
}

.stat-value {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.1;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  line-height: 1.45;
}

/* ---------- Sections ---------- */
section {
  padding: 2.5rem 0;
}

/* Breathing room above the footer on every page */
main > :last-child {
  padding-bottom: 5rem;
}

/* Keep headings clear of the sticky header when jumping via nav links */
section[id] {
  scroll-margin-top: 3.25rem;
}

/* Section titles are quiet labels, not big slide headings: the content
   (rows, cards) carries the weight */
.section-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* Desktop: label in a left column, content in the right column */
@media (min-width: 821px) {
  .home-section {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr);
    column-gap: 2.5rem;
    align-items: start;
  }

  .home-section > * {
    grid-column: 2;
  }

  .home-section > .section-title {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
    padding-top: 1.25rem;
  }
}

/* ---------- Experience ---------- */
.job {
  padding: 1rem 0.25rem;
  border-bottom: 1px solid var(--border);
}

.job:first-of-type {
  border-top: 1px solid var(--border);
}

.job .job-head {
  margin-bottom: 0;
}

.job-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 0.7rem;
}

.job-head h3 {
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.job-company {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.job-dates {
  font-size: 0.88rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.job ul {
  list-style: none;
}

.job li {
  position: relative;
  padding-left: 1.25rem;
  margin-bottom: 0.55rem;
  color: var(--text-muted);
}

.job li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--accent);
}

.job li em {
  font-style: normal;
  color: var(--text);
  font-weight: 500;
}

/* ---------- Projects ---------- */
.project-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.project-card {
  display: block;
  position: relative;
  border-radius: 14px;
  padding: 1px; /* room for the gradient border */
  background: var(--border);
  color: var(--text);
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.project-card.featured {
  grid-column: 1 / -1;
}

.project-card-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: 13px;
  background: var(--bg-card);
  padding: 1.5rem;
}

.project-card:hover {
  text-decoration: none;
  transform: translateY(-3px);
  background: var(--gradient);
  box-shadow: 0 12px 32px color-mix(in srgb, var(--accent) 14%, transparent);
}

.project-card h3 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--accent);
}

/* Signals the card opens GitHub in a new tab */
.project-arrow {
  font-family: var(--font-body);
  color: var(--text-muted);
  transition: transform 150ms ease, color 150ms ease;
}

.project-card:hover .project-arrow {
  color: var(--accent);
  transform: translate(2px, -2px);
}

.project-card p {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
}

.project-tags,
.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0 !important;
}

.project-tags span,
.skill-tags span {
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.18rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--bg-soft);
  white-space: nowrap;
}

.project-tags {
  margin-top: auto;
}

.projects-more {
  margin-top: 1.5rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Inline padding: bigger tap target, no layout shift */
.projects-more a,
.post-back a {
  padding: 0.5rem 0;
}

/* ---------- Skills ---------- */
/* Same divider rows as Experience / Education */
.skill-group {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  column-gap: 1.5rem;
  align-items: baseline;
  padding: 1rem 0.25rem;
  border-bottom: 1px solid var(--border);
}

.skill-group:first-of-type {
  border-top: 1px solid var(--border);
}

.skill-group h3 {
  font-size: 1rem;
}

/* ---------- Education ---------- */
.edu-school {
  margin-top: 0.15rem;
  font-size: 0.92rem;
  color: var(--text-muted);
}

/* ---------- Contact ---------- */
#contact {
  padding-bottom: 5rem;
}

.contact-box {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3.5rem 2rem;
  text-align: center;
  background:
    radial-gradient(500px 200px at 50% 0%, color-mix(in srgb, var(--accent-2) 10%, transparent), transparent 70%),
    var(--bg-soft);
  overflow: hidden;
}

.contact-title {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.contact-sub {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.contact-links {
  justify-content: center;
}

/* ---------- Blog: post lists ---------- */
.post-list {
  display: flex;
  flex-direction: column;
}

.post-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0.25rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: transform 120ms ease;
}

.post-row:first-child {
  border-top: 1px solid var(--border);
}

.post-row:hover {
  text-decoration: none;
  transform: translateX(4px);
}

.post-row:hover .post-row-title {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.post-row-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.post-row-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
}

.post-row-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.post-row-date {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.blog-index {
  padding-top: 4rem;
}

.blog-title {
  font-size: clamp(2.2rem, 7vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.blog-head {
  margin-bottom: 2.5rem;
}

.blog-empty {
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

/* ---------- Blog: single post ---------- */
.post {
  max-width: 45rem;
  padding-top: 4rem;
}

.post-meta {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.post-title {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.post-desc {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

.post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.post-back {
  margin-top: 3rem;
}

/* ---------- Prose (rendered Markdown) ---------- */
.prose {
  font-size: 1.02rem;
  /* long URLs wrap instead of pushing the page sideways */
  overflow-wrap: break-word;
}

.prose h2,
.prose h3 {
  letter-spacing: -0.01em;
  margin: 2.2rem 0 0.8rem;
}

.prose h2 {
  font-size: 1.5rem;
}

.prose h3 {
  font-size: 1.2rem;
}

.prose p {
  margin-bottom: 1.1rem;
}

.prose ul,
.prose ol {
  margin: 0 0 1.1rem 1.4rem;
}

.prose li {
  margin-bottom: 0.4rem;
}

.prose blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1.1rem;
  margin: 1.4rem 0;
  color: var(--text-muted);
}

.prose img {
  max-width: 100%;
  border-radius: 10px;
  margin: 1.4rem 0;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.prose table {
  border-collapse: collapse;
  margin: 1.4rem 0;
  width: 100%;
  font-size: 0.95rem;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.8rem;
  text-align: left;
}

.prose th {
  background: var(--bg-soft);
}

/* Code blocks (Chroma emits .highlight > pre.chroma) */
.prose .highlight {
  margin: 1.4rem 0;
}

.prose pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

/* Chroma token colors — theme-aware via tokens */
.chroma .c, .chroma .c1, .chroma .cm, .chroma .ch, .chroma .cs,
.chroma .cp, .chroma .cpf { color: var(--code-comment); font-style: italic; }
.chroma .k, .chroma .kc, .chroma .kd, .chroma .kn, .chroma .kp,
.chroma .kr, .chroma .kt, .chroma .nt { color: var(--code-keyword); }
.chroma .s, .chroma .s1, .chroma .s2, .chroma .sa, .chroma .sb,
.chroma .sc, .chroma .dl, .chroma .sd, .chroma .se, .chroma .sh,
.chroma .si, .chroma .sx, .chroma .sr, .chroma .ss { color: var(--code-string); }
.chroma .m, .chroma .mb, .chroma .mf, .chroma .mh, .chroma .mi,
.chroma .il, .chroma .mo { color: var(--code-number); }
.chroma .nf, .chroma .fm, .chroma .nx { color: var(--code-func); }

/* ---------- 404 ---------- */
.notfound {
  padding-top: 5rem;
}

.notfound .hero-summary {
  margin-top: 1rem;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.75rem 0 2.25rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }
}

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

  .hero {
    padding: 4.5rem 0 2.5rem;
  }

  section {
    padding: 2rem 0;
  }

  .nav-links {
    gap: 0.8rem;
    font-size: 0.88rem;
  }

  .skill-group {
    display: block;
  }

  .skill-group h3 {
    margin-bottom: 0.5rem;
  }

  /* Date above the title so long titles get the full width */
  .post-row {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 0.2rem;
  }

  /* Tables shrink to fit the screen instead of scrolling sideways */
  .prose table {
    font-size: 0.8rem;
    line-height: 1.4;
  }

  .prose th,
  .prose td {
    padding: 0.4rem 0.35rem;
  }

  .prose th {
    vertical-align: bottom;
  }
}

/* Only the tiniest phones drop the section links */
@media (max-width: 359px) {
  .nav-links a:not(.nav-cta) {
    display: none;
  }

  .prose table {
    font-size: 0.72rem;
  }

  .prose th,
  .prose td {
    padding: 0.35rem 0.2rem;
  }
}
