:root {
  --bg: #faf9f6;
  --text: #1c1b19;
  --muted: #6b6860;
  --line: #e3e0d8;
  --accent: #2f6f4f;
  --max-width: 650px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.6;
}

a {
  color: var(--accent);
}

h1 {
  margin: 0;
  /* Capped so the name fits on one line beside the headshot */
  font-size: clamp(2.5rem, 5.5vw, 4.25rem);
  white-space: nowrap;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0 0 1rem;
  font-size: 2rem;
}

h3 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

/* Navigation */

.nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

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

.nav__name {
  font-weight: 600;
  white-space: nowrap;
}

/* Three-dots button: only shown on small screens, where it opens the links as a dropdown */
.nav__menu {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin: -0.4rem -0.5rem -0.4rem 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text);
  cursor: pointer;
}

.nav__menu svg {
  fill: currentColor;
}

.nav__menu:hover,
.nav.is-open .nav__menu {
  background: var(--line);
}

.nav__links {
  display: flex;
  gap: 1.25rem;
  font-size: 0.95rem;
}

.nav__links a:hover {
  color: var(--accent);
}

/* Sections */

.section {
  min-height: 100vh;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 6rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* The intro only takes the room it needs */
.hero {
  min-height: 0;
  padding-bottom: 1.5rem;
}

/* Projects and Experience follow on directly instead of each filling its own screen */
#projects,
#experience {
  min-height: 0;
  padding-top: 1rem;
  scroll-margin-top: 3rem; /* keeps the heading clear of the fixed nav */
}

/* Same space below Projects and Experience as below the intro */
#projects,
#experience {
  padding-bottom: 1.5rem;
}

/* Contact links close the page, set a little further down than the sections above */
#contact {
  min-height: 0;
  padding-top: 2.5rem;
  padding-bottom: 3rem;
  scroll-margin-top: 3rem;
}

#contact p {
  margin: 0;
}

/* The About paragraph lives in the intro, under the name and background lines */
.about {
  margin: 1.25rem 0 0;
  scroll-margin-top: 5rem; /* keeps it clear of the fixed nav when the About link jumps here */
}

.hero__intro {
  display: flex;
  align-items: flex-end; /* headshot bottom lines up with the end of the intro text */
  justify-content: space-between;
  gap: 2rem;
}

.hero__text {
  flex: 1 1 0;
  min-width: 0;
}

.hero__photo {
  flex: 0 0 auto;
  width: clamp(110px, 18vw, 170px);
}

.hero__photo img,
.hero__photo canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* js/dissolve.js draws the photo on a canvas and keeps the <img> only as its source */
.hero__photo img[hidden] {
  display: none;
}

/* Full-page layer the headshot's blocks fly on while dissolved (js/dissolve.js) */
.dissolve-layer {
  position: fixed;
  inset: 0;
  z-index: 15;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.85rem;
}

.lede {
  margin: 1rem 0 0;
  font-size: 1.25rem;
  color: var(--muted);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.card {
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.card p {
  margin: 0 0 0.75rem;
  color: var(--muted);
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline li {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
}

.timeline__when {
  color: var(--muted);
  font-size: 0.9rem;
}

.timeline p {
  margin: 0;
  color: var(--muted);
}

/* Hand tracking UI */

/* One button in the corner: click to turn hand scrolling on or off. It also
   shows the tracker status and, while waiting for a hand, how to use it. */
.hand-toggle {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-width: min(17rem, calc(100vw - 2rem));
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

.hand-toggle:hover {
  border-color: var(--accent);
}

.hand-toggle__title {
  font-weight: 600;
}

/* Status dot */
.hand-toggle__title::before {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.45rem;
  border-radius: 50%;
  background: #b5b1a7;
}

.hand-toggle[data-state="connected"] .hand-toggle__title::before {
  background: #d9a441;
}

.hand-toggle[data-state="point"] .hand-toggle__title::before,
.hand-toggle[data-state="scroll"] .hand-toggle__title::before {
  background: var(--accent);
}

.hand-toggle__status,
.hand-toggle__help {
  color: var(--muted);
}

/* Instructions: only while the tracker is connected and sees no hand */
.hand-toggle__help {
  display: none;
  margin-top: 0.25rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--line);
}

.hand-toggle[data-state="connected"] .hand-toggle__help {
  display: block;
}

.hand-cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 30;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  pointer-events: none;
  transition: width 0.12s, height 0.12s, margin 0.12s, background 0.12s;
}

.hand-cursor.is-scrolling {
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  background: var(--accent);
}

.hand-cursor.is-clicking::after {
  content: "";
  position: absolute;
  inset: -2px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  animation: hand-click 0.35s ease-out forwards;
}

@keyframes hand-click {
  from {
    transform: scale(1);
    opacity: 0.9;
  }
  to {
    transform: scale(2.6);
    opacity: 0;
  }
}

/* The link or button the hand cursor is over */
.hand-hover {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}

@media (max-width: 560px) {
  /* Small screens: headshot to the right of the name and background lines,
     with the About paragraph full width underneath. */
  .hero__intro {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: 1fr auto auto; /* spare height goes above the greeting */
    gap: 0 1rem;
  }

  .hero__text {
    display: contents; /* its children become the grid's items */
  }

  .eyebrow {
    align-self: end;
  }

  .hero__photo {
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: end;
    width: clamp(84px, 26vw, 110px);
  }

  .about {
    grid-column: 1 / -1;
  }

  h1 {
    font-size: clamp(1.75rem, 8.5vw, 2.5rem);
  }

  .nav__menu {
    display: inline-flex;
  }

  .nav__links {
    display: none;
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 1rem;
    flex-direction: column;
    gap: 0;
    min-width: 10rem;
    padding: 0.4rem 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.08);
    font-size: 1rem;
  }

  .nav.is-open .nav__links {
    display: flex;
  }

  .nav__links a {
    padding: 0.6rem 1rem;
  }

  .timeline li {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}
