/* ---------- Tokens ---------- */
:root {
  --bg: #ffffff;
  --surface: #f6f6f4;
  --text: #111111;
  --muted: #6b6b6b;
  --line: #e9e9e6;
  --accent: #1f3a93;

  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Instrument Sans", system-ui, sans-serif;

  --max: 960px;
  --gutter: 16px;
  --radius: 18px;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 88px; }
/* Lenis drives the scrolling itself, so the browser's own smoothing must be off */
html.lenis, html.lenis body { height: auto; }
html.lenis { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

a { color: inherit; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; line-height: 1.05; }
ul { list-style: none; margin: 0; padding: 0; }

main, .site-footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Full-width bar, content lined up with the page column */
  padding: 14px max(var(--gutter), calc((100% - var(--max)) / 2 + var(--gutter)));
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  text-decoration: none;
  letter-spacing: -0.02em;
}

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

.nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.nav a {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  color: var(--muted);
  transition: background 0.2s, color 0.2s;
}

.nav a:hover { background: var(--bg); color: var(--text); }

/* ---------- Hero ---------- */
.hero {
  min-height: 78vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 0 48px;
  will-change: transform, opacity;
}

.hero-photo {
  display: block;
  width: 112px;
  height: 112px;
  margin-bottom: 20px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface);
  /* Thin outline with a white gap, so the photo sits off the page */
  box-shadow: 0 0 0 4px var(--bg), 0 0 0 5px var(--line);
}

.hero-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-greeting {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--muted);
}

.hero-name {
  font-size: clamp(48px, 11vw, 112px);
  font-weight: 800;
  letter-spacing: -0.045em;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 28px 0 0;
}

.pill {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 500;
}

.hero-intro {
  max-width: 460px;
  margin: 20px 0 0;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 28px;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin-top: 24px;
  font-size: 14px;
}

.hero-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}

.hero-links a:hover { color: var(--text); }

/* ---------- Skills strip ---------- */
.skills {
  /* Break out of the page column to run edge to edge */
  width: 100vw;
  margin-left: calc(50% - 50vw);
  padding: 28px 0;
  border-top: 1px solid var(--line);
  overflow: hidden;
  /* Fade the strip out at both edges */
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}

.skills-track {
  display: flex;
  width: max-content;
  animation: marquee 40s linear infinite;
}

.skills:hover .skills-track { animation-play-state: paused; }

.skills-track li { padding: 0 24px; }

.skills-track a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-decoration: none;
  transition: color 0.2s;
}

.skills-track img {
  opacity: 0.9;
  transition: transform 0.3s var(--ease-out), opacity 0.2s;
}

.skills-track a:hover,
.skills-track a:focus-visible { color: var(--accent); }

.skills-track a:hover img,
.skills-track a:focus-visible img { transform: translateY(-2px) scale(1.12); opacity: 1; }

/* Keyboard users: stop the strip while a skill has focus */
.skills:focus-within .skills-track { animation-play-state: paused; }

@keyframes marquee {
  to { transform: translateX(-50%); }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid var(--text);
  font: 500 15px var(--font-body);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, color 0.2s;
}

.btn:hover { transform: translateY(-2px); }
.btn-dark { background: var(--text); color: var(--bg); }
.btn-light { background: var(--bg); color: var(--text); border-color: var(--line); }
.btn-light:hover { border-color: var(--text); }

/* ---------- Sections ---------- */
.section { padding: 72px 0; border-top: 1px solid var(--line); }

.section-title {
  font-size: clamp(32px, 6vw, 48px);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 32px;
}

/* ---------- Projects ---------- */
.projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 400px), 1fr));
  gap: 16px;
}

.project {
  display: flex;
  flex-direction: column;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.project:hover {
  border-color: #d4d4d0;
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

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

.project-media {
  position: relative;
  margin-bottom: 20px;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}

.project-media video,
.project-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease-out);
}

.has-details { cursor: pointer; }
.has-details:hover .project-media img { transform: scale(1.04); }

.media-badge {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.82);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.project .project-event,
.dialog-body .project-event {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.project h3 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.project-year { font-size: 14px; color: var(--muted); }
.project p { margin: 10px 0 0; color: var(--muted); }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}

.tags li {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
}

.project-links {
  display: flex;
  gap: 18px;
  margin-top: auto;
  padding-top: 20px;
}

.project-links a {
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: border-color 0.2s;
}

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

.project h3,
.dialog-body h2 { display: flex; align-items: center; gap: 10px; }

.project-logo { flex: none; display: block; }

/* A link that isn't live yet: shown, but does nothing */
.link-soon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  cursor: not-allowed;
}

.soon-pill {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.btn.is-soon { color: var(--muted); cursor: not-allowed; }
.btn.is-soon:hover { transform: none; border-color: var(--line); }

.project-more {
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--accent);
  background: none;
  color: var(--accent);
  font: 600 15px var(--font-body);
  cursor: pointer;
}

/* ---------- Project details pop-up ---------- */
.project-dialog {
  width: min(860px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
}

html.modal-open { overflow: hidden; }

.project-dialog::backdrop {
  background: rgba(17, 17, 17, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* The panel scrolls inside the pop-up; the page behind stays put */
.dialog-panel {
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.project-dialog[open] .dialog-panel { animation: dialog-in 0.45s var(--ease-out); }
.project-dialog[open]::backdrop { animation: fade-in 0.3s ease; }
.project-dialog.closing .dialog-panel { animation: dialog-out 0.25s ease forwards; }
.project-dialog.closing::backdrop { animation: fade-out 0.25s ease forwards; }

@keyframes dialog-in { from { opacity: 0; transform: translateY(24px) scale(0.98); } }
@keyframes dialog-out { to { opacity: 0; transform: translateY(16px) scale(0.98); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

.dialog-close {
  position: sticky;
  top: 12px;
  z-index: 2;
  float: right;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin: 12px 12px -50px 0;
  border: 0;
  border-radius: 50%;
  background: rgba(17, 17, 17, 0.75);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.2s, transform 0.2s;
}

.dialog-close:hover { background: var(--text); transform: rotate(90deg); }

.dialog-media {
  aspect-ratio: 16 / 9;
  background: var(--text);
}

.dialog-media video { display: block; width: 100%; height: 100%; }

.dialog-body { padding: 28px 32px 36px; }

.dialog-body h2 {
  margin-top: 6px;
  font-size: clamp(32px, 5vw, 44px);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.dialog-lead {
  margin: 10px 0 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.35;
}

.dialog-body > p:not(.project-event):not(.dialog-lead) { margin: 16px 0 0; color: var(--muted); }

.dialog-body h3 {
  margin: 32px 0 12px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.dialog-list { display: grid; gap: 8px; color: var(--muted); }

.dialog-list li {
  position: relative;
  padding-left: 20px;
}

.dialog-list li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.68em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* Numbered agent pipeline */
.pipeline {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.pipeline li {
  counter-increment: step;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.pipeline strong {
  display: block;
  font-family: var(--font-display);
  font-size: 16px;
}

.pipeline strong::before {
  content: counter(step, decimal-leading-zero) "  ";
  color: var(--accent);
}

.pipeline span { display: block; margin-top: 4px; font-size: 14px; line-height: 1.5; color: var(--muted); }

.dialog-list strong { color: var(--text); font-weight: 600; }

/* Live numbers row */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 24px;
}

.stats li {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.stats strong {
  display: block;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.stats span { font-size: 14px; color: var(--muted); }

/* Screenshot gallery: swipe or scroll sideways */
.gallery {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 86%;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 10px;
  overscroll-behavior-x: contain;
}

.gallery figure { margin: 0; scroll-snap-align: start; }

.gallery img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.gallery figcaption { margin-top: 8px; font-size: 14px; color: var(--muted); }

.dialog-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }

@media (max-width: 520px) {
  .project-dialog { width: calc(100% - 16px); max-height: calc(100dvh - 16px); border-radius: 16px; }
  .dialog-panel { max-height: calc(100dvh - 16px); }
  .dialog-body { padding: 22px 20px 28px; }
}

/* ---------- About ---------- */
.about { max-width: 640px; }
.about p { margin: 0 0 16px; color: var(--muted); }

.about-lead {
  font-family: var(--font-display);
  font-size: clamp(22px, 3.5vw, 30px);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text) !important;
}

/* ---------- Footer / contact ---------- */
.site-footer {
  padding-top: 88px;
  padding-bottom: 32px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.footer-title {
  font-size: clamp(36px, 8vw, 72px);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.footer-text { margin: 16px 0 0; color: var(--muted); }

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: 88px;
  font-size: 14px;
  color: var(--muted);
}

.footer-links { display: flex; gap: 18px; }
.footer-links a { text-decoration: none; }
.footer-links a:hover { color: var(--text); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Scroll reveal ---------- */
:root { --ease-out: cubic-bezier(0.16, 1, 0.3, 1); }

/* Blocks: rise up out of a soft blur */
.js .reveal {
  opacity: 0;
  transform: translateY(28px);
  filter: blur(6px);
  transition:
    opacity 0.9s var(--ease-out),
    transform 1.1s var(--ease-out),
    filter 0.9s var(--ease-out);
}

.js .reveal.visible { opacity: 1; transform: none; filter: none; }

/* Titles: each letter blurs and rises in, one after another */
.split .word { display: inline-block; white-space: nowrap; }

.js .split .char {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.45em) rotate(4deg);
  filter: blur(10px);
  transition:
    opacity 0.8s var(--ease-out),
    transform 1s var(--ease-out),
    filter 0.8s var(--ease-out);
  transition-delay: calc(var(--i) * 32ms + 0.05s);
}

.js .split.visible .char { opacity: 1; transform: none; filter: none; }

/* ---------- Scroll progress bar ---------- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
}

/* ---------- Target cursor ---------- */
/* Only switched on by script.js for mouse users */
html.custom-cursor,
html.custom-cursor * { cursor: none !important; }

.cursor,
.cursor-dot {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  will-change: transform;
}

.cursor { z-index: 1000; width: 0; height: 0; }
.cursor.active, .cursor-dot.active { opacity: 1; }

/* Four corner brackets: ⌜ ⌝ ⌟ ⌞ */
.cursor-corner {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 12px;
  height: 12px;
  border: 2.5px solid var(--text);
  transition: border-color 0.25s;
  will-change: transform;
}

.cursor-corner:nth-child(1) { border-right: 0; border-bottom: 0; }
.cursor-corner:nth-child(2) { border-left: 0; border-bottom: 0; }
.cursor-corner:nth-child(3) { border-left: 0; border-top: 0; }
.cursor-corner:nth-child(4) { border-right: 0; border-top: 0; }

.cursor.locked .cursor-corner { border-color: var(--accent); }

/* Center dot: inverts so it shows on both white and the dark buttons */
.cursor-dot {
  z-index: 1001;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: #fff;
  mix-blend-mode: difference;
}

@media (pointer: coarse) { .cursor, .cursor-dot { display: none; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal, .js .split .char { opacity: 1; transform: none; filter: none; transition: none; }
  .btn:hover, .project:hover { transform: none; }
  .cursor, .cursor-dot { display: none; }
  .project-dialog .dialog-panel, .project-dialog::backdrop { animation: none !important; }
  .has-details:hover .project-media img { transform: none; }
  .skills-track { animation: none; flex-wrap: wrap; justify-content: center; width: auto; row-gap: 16px; }
  .skills-track li[aria-hidden] { display: none; }
}

/* ---------- Small screens ---------- */
@media (max-width: 520px) {
  body { font-size: 16px; }
  .nav a { padding: 6px 10px; font-size: 13px; }
  .hero { min-height: 70vh; }
  .hero-photo { width: 96px; height: 96px; }
  .section { padding: 56px 0; }
  .project { padding: 20px; }
  .footer-bottom { justify-content: center; text-align: center; }
}
