/* ---------- Tokens ---------- */
:root {
  --bg: oklch(0.98 0.005 80);
  --fg: oklch(0.18 0.01 250);
  --muted: oklch(0.55 0.01 250);
  --faint: oklch(0.88 0.005 250);
  --hairline: oklch(0.85 0.005 250);
  --accent: oklch(0.62 0.18 145);
  --grid: oklch(0.92 0.005 250);

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --maxw: 1180px;
  --gutter: clamp(20px, 4vw, 48px);
}

[data-theme="dark"] {
  --bg: oklch(0.16 0.008 250);
  --fg: oklch(0.96 0.005 80);
  --muted: oklch(0.62 0.01 250);
  --faint: oklch(0.24 0.008 250);
  --hairline: oklch(0.28 0.008 250);
  --accent: oklch(0.78 0.18 145);
  --grid: oklch(0.22 0.008 250);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 200ms ease, color 200ms ease;
  min-height: 100vh;
  position: relative;
}

/* Subtle grid background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 80px 80px;
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 20%, transparent 80%);
}

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

/* ---------- Layout ---------- */
.shell {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Nav ---------- */
.nav {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 28px 0;
  border-bottom: 1px solid var(--hairline);
}
.nav-brand {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-brand .dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
}
.nav-links {
  display: flex;
  gap: 28px;
  font-family: var(--mono);
  font-size: 13px;
}
.nav-links a {
  position: relative;
  color: var(--muted);
  transition: color 150ms ease;
  padding: 4px 0;
}
.nav-links a:hover { color: var(--fg); }
.nav-links a.active { color: var(--fg); }
.nav-links a.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background: var(--accent);
}

@media (max-width: 720px) {
  .nav {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand toggle"
      "links links";
    gap: 12px 12px;
    padding: 16px 0;
  }
  .nav-brand { grid-area: brand; font-size: 11px; }
  .theme-toggle { grid-area: toggle; }
  .nav-links {
    grid-area: links;
    gap: 18px;
    justify-content: flex-start;
    border-top: 1px solid var(--hairline);
    padding-top: 12px;
    margin-top: 0;
  }
}

@media (max-width: 380px) {
  .nav-brand { font-size: 10px; }
  .nav-links { gap: 14px; font-size: 12px; }
}

.theme-toggle {
  font-family: var(--mono);
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--hairline);
  color: var(--muted);
  padding: 6px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 150ms ease;
}
.theme-toggle:hover {
  color: var(--fg);
  border-color: var(--fg);
}
.theme-toggle .icon {
  width: 12px; height: 12px;
  display: inline-block;
}

/* ---------- Footer ---------- */
.footer {
  margin-top: auto;
  padding: 32px 0 28px;
  border-top: 1px solid var(--hairline);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .footer { flex-direction: column; align-items: flex-start; gap: 4px; }
}
.footer-meta { display: flex; gap: 24px; }
.footer .live::before {
  content: "●";
  color: var(--accent);
  margin-right: 6px;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---------- Type ---------- */
.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
}
.eyebrow::before {
  content: "";
  width: 24px;
  height: 1px;
  background: var(--muted);
  display: inline-block;
}

h1.display {
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(40px, 7vw, 84px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  margin: 24px 0 0;
  text-wrap: balance;
}
h1.display em {
  font-style: italic;
  font-family: "Inter", serif;
  font-weight: 400;
  color: var(--muted);
}

h2.section {
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin: 0 0 8px;
}

.lead {
  font-size: 18px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 56ch;
  text-wrap: pretty;
}

.mono { font-family: var(--mono); }

/* ---------- Hero ---------- */
.hero {
  padding: clamp(60px, 12vh, 140px) 0 clamp(40px, 8vh, 80px);
}
.hero-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 56px;
}
.hero-cta {
  margin-top: 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--mono);
  font-size: 13px;
  padding: 12px 18px;
  border: 1px solid var(--hairline);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: all 180ms ease;
  position: relative;
}
.btn:hover {
  border-color: var(--fg);
  transform: translateY(-1px);
}
.btn.primary {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.btn.primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: oklch(0.15 0.01 250);
}
.btn .arrow {
  transition: transform 180ms ease;
}
.btn:hover .arrow {
  transform: translateX(3px);
}

/* ---------- Stat strip ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  margin: clamp(40px, 8vh, 80px) 0;
}
.stat {
  padding: 28px 24px;
  border-right: 1px solid var(--hairline);
}
.stat:last-child { border-right: none; }
.stat .num {
  font-family: var(--sans);
  font-size: clamp(24px, 3vw, 36px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
}
.stat .lbl {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: 10px;
}

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat { padding: 20px 16px; }
  .stat:nth-child(2) { border-right: none; }
  .stat:nth-child(1), .stat:nth-child(2) { border-bottom: 1px solid var(--hairline); }

  .hero { padding-top: 36px; padding-bottom: 28px; }
  .stats { margin-top: 28px; margin-bottom: 28px; }
  .marquee { margin: 28px 0; --speed: 28s; }
  .marquee-track { gap: 36px; }
  .marquee-item { gap: 36px; }
  .page-head { padding-top: 32px; padding-bottom: 32px; margin-bottom: 28px; }

  .two-col { margin: 36px 0; }
  .contact-strip { margin-top: 36px; }
  .section-head { margin-bottom: 24px; padding-bottom: 16px; gap: 12px; }
  .section-head .meta { font-size: 11px; }

  .project { padding: 28px 0 40px; }
  .project-meta { margin: 28px 0 36px; }
  .project-meta .cell { padding: 16px; }

  body { font-size: 14px; }
  .lead { font-size: 16px; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr; }
  .stat { border-right: none !important; border-bottom: 1px solid var(--hairline); }
  .stat:last-child { border-bottom: none; }

  .project-meta { grid-template-columns: 1fr; }
  .project-meta .cell { border-right: none !important; border-bottom: 1px solid var(--hairline); }
  .project-meta .cell:last-child { border-bottom: none; }

  .hero-cta .btn { flex: 1 1 auto; justify-content: center; }
}

/* ---------- Section header ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 40px;
}
.section-head .meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

@media (max-width: 540px) {
  .section-head { flex-direction: column; gap: 8px; align-items: flex-start; }
}

/* ---------- Card grid (work) ---------- */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  border-top: 1px solid var(--hairline);
}
.card {
  padding: 32px 0;
  border-bottom: 1px solid var(--hairline);
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 32px;
  align-items: start;
  transition: padding 200ms ease;
  cursor: pointer;
}
.card:hover {
  padding-left: 16px;
  padding-right: 16px;
}
.card .idx {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  padding-top: 6px;
}
.card .title {
  font-family: var(--sans);
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 8px;
}
.card .title em { color: var(--accent); font-style: normal; }
.card .desc {
  color: var(--muted);
  max-width: 64ch;
  margin: 8px 0 0;
  text-wrap: pretty;
}
.card .tag-row {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--hairline);
  padding: 4px 8px;
  border-radius: 999px;
}
.card .go {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 8px;
  transition: color 150ms ease;
}
.card .go a { color: inherit; transition: color 150ms ease; }
.card .go-multi {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}
.card:hover .go,
.card:hover .go a { color: var(--accent); }

@media (max-width: 720px) {
  .card {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 24px 0;
  }
  .card:hover { padding-left: 0; padding-right: 0; }
  .card .idx { padding-top: 0; font-size: 11px; }
  .card .go {
    padding-top: 4px;
    color: var(--muted);
    justify-self: start;
  }
  .card .go a { color: inherit; }
  .card:hover .go,
  .card:hover .go a { color: var(--accent); }
  .card .title { font-size: 22px; }
  .card .desc { font-size: 14px; }
}

/* ---------- CV / timeline ---------- */
.cv-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0;
}
.cv-section {
  display: contents;
}
.cv-label {
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 24px 0;
  border-top: 1px solid var(--hairline);
}
.cv-items {
  padding: 0;
  border-top: 1px solid var(--hairline);
}
.cv-item {
  padding: 24px 0;
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 24px;
  align-items: baseline;
  border-bottom: 1px solid var(--faint);
}
.cv-item:last-child { border-bottom: none; }
.cv-when {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.cv-what .role {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.cv-what .org {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}
.cv-what .org .pin {
  color: var(--accent);
  margin-right: 6px;
}

@media (max-width: 720px) {
  .cv-grid { grid-template-columns: 1fr; }
  .cv-label { padding-bottom: 8px; }
  .cv-item { grid-template-columns: 1fr; gap: 4px; }
}

/* ---------- Project detail ---------- */
.project {
  padding: 60px 0 80px;
}
.project-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  margin: 40px 0 60px;
}
.project-meta .cell {
  padding: 20px 24px;
  border-right: 1px solid var(--hairline);
}
.project-meta .cell:last-child { border-right: none; }
.project-meta .k {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}
.project-meta .v {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
}

@media (max-width: 720px) {
  .project-meta { grid-template-columns: repeat(2, 1fr); }
  .project-meta .cell:nth-child(2) { border-right: none; }
  .project-meta .cell:nth-child(1), .project-meta .cell:nth-child(2) {
    border-bottom: 1px solid var(--hairline);
  }
}

/* Placeholder image */
.placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
  background:
    repeating-linear-gradient(
      135deg,
      var(--faint) 0,
      var(--faint) 1px,
      transparent 1px,
      transparent 12px
    ),
    var(--bg);
  border: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  position: relative;
}
.placeholder::after {
  content: attr(data-label);
  position: absolute;
  top: 16px;
  left: 16px;
  background: var(--bg);
  padding: 4px 8px;
  border: 1px solid var(--hairline);
}

/* ---------- Marquee ---------- */
.marquee {
  overflow: hidden;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  padding: 18px 0;
  margin: 60px 0;
  position: relative;
  --speed: 40s;
  mask-image: linear-gradient(to right, transparent, black 8%, black 92%, transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, black 8%, black 92%, transparent);
}
.marquee-track {
  display: flex;
  gap: 60px;
  width: max-content;
  animation: scroll var(--speed) linear infinite;
}
.marquee-item {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 60px;
  white-space: nowrap;
}
.marquee-item::after {
  content: "✦";
  color: var(--accent);
}
@keyframes scroll {
  to { transform: translateX(-50%); }
}

/* ---------- Page heading block ---------- */
.page-head {
  padding: clamp(40px, 8vh, 80px) 0 clamp(40px, 6vh, 60px);
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 40px;
}
.page-head .eyebrow { margin-bottom: 24px; }

/* ---------- Contact row on home ---------- */
.contact-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  margin: 60px 0 0;
}
.contact-strip a {
  padding: 28px 24px;
  border-right: 1px solid var(--hairline);
  display: block;
  transition: background 200ms ease;
  position: relative;
}
.contact-strip a:last-child { border-right: none; }
.contact-strip a:hover {
  background: var(--faint);
}
.contact-strip .k {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.contact-strip .k .arr { color: var(--accent); transition: transform 200ms ease; }
.contact-strip a:hover .k .arr { transform: translate(2px, -2px); }
.contact-strip .v {
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

@media (max-width: 720px) {
  .contact-strip { grid-template-columns: 1fr; }
  .contact-strip a { border-right: none; border-bottom: 1px solid var(--hairline); }
  .contact-strip a:last-child { border-bottom: none; }
}

/* ---------- Two col ---------- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  margin: 60px 0;
}
@media (max-width: 720px) {
  .two-col { grid-template-columns: 1fr; gap: 32px; }
}

/* ---------- Reveal on load ---------- */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  animation: reveal 700ms cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}
.reveal.d1 { animation-delay: 80ms; }
.reveal.d2 { animation-delay: 160ms; }
.reveal.d3 { animation-delay: 240ms; }
.reveal.d4 { animation-delay: 320ms; }
.reveal.d5 { animation-delay: 400ms; }
@keyframes reveal {
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Cursor blinker for hero ---------- */
.cursor {
  display: inline-block;
  width: 0.55ch;
  height: 0.85em;
  background: var(--accent);
  vertical-align: -0.05em;
  margin-left: 0.1ch;
  animation: blink 1.1s steps(2) infinite;
}
@keyframes blink {
  50% { opacity: 0; }
}
