/* Home page. Matches the "Project intro block" frame in Figma:
   a big two-part intro, vertically centred in the screen. */

.home-intro {
  /* Fill the screen below the 68px header and centre the text vertically,
     instead of Figma's fixed 248px top/bottom padding, so it looks right
     on any screen height. */
  min-height: calc(100vh - 68px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-lg) 79px; /* 62px + 17px from the Figma frames */
}

.home-intro__text {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 860px;
}

.home-intro__title,
.home-intro__lead {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 32px;
  line-height: normal;
  color: var(--color-text);
}

.home-intro__title {
  letter-spacing: -0.32px;
}

.home-intro__lead {
  letter-spacing: -0.96px;
  padding: 0 0 25px 30px; /* the indent under the greeting */
}

@media (max-width: 768px) {
  .home-intro {
    padding: var(--space-md) 24px;
  }
  .home-intro__title,
  .home-intro__lead {
    font-size: 24px;
  }
  .home-intro__lead {
    padding-left: 20px;
  }
  /* On phones the manual line break looks odd, so let text flow. */
  .home-intro__lead br {
    display: none;
  }
}

/* The waving hand. Plays once when the page opens:
   a few quick back-and-forth swings pivoting from the wrist. */
.wave {
  display: inline-block;
  transform-origin: 70% 80%; /* roughly where the wrist is */
  animation: wave 1.6s ease-in-out 0.4s 1 both;
}

@keyframes wave {
  0%   { transform: rotate(0deg); }
  15%  { transform: rotate(14deg); }
  30%  { transform: rotate(-8deg); }
  45%  { transform: rotate(14deg); }
  60%  { transform: rotate(-4deg); }
  75%  { transform: rotate(10deg); }
  100% { transform: rotate(0deg); }
}

/* The intro paragraph drops down out of the greeting after the hand's
   first swing (wave starts at 0.4s, first back-and-forth ends ~0.9s),
   so it arrives while the hand is still waving.
   It slides down a little while being revealed from the top edge. */
.home-intro__lead {
  animation: drop-in 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.9s 1 both;
}

@keyframes drop-in {
  from {
    opacity: 0;
    transform: translateY(-24px);
    clip-path: inset(0 0 100% 0);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    clip-path: inset(0 0 0 0);
  }
}

/* Respect visitors who've asked their device to reduce motion. */
@media (prefers-reduced-motion: reduce) {
  .wave,
  .home-intro__lead { animation: none; }
}

/* ---------- Scroll gate: the intro holds while a bar fills ----------
   Purely tied to the scroll: nothing moves the page by itself. The intro
   stays put and slowly fades up while the bar fills; once it's full the
   projects scroll in underneath. */
.home-gate {
  position: relative;
  height: calc(100vh - 68px + 110vh);   /* 110vh of scrolling fills the bar */
}
.home-gate .home-intro {
  position: sticky;
  top: 0;
}
.home-gate .home-intro__text {
  opacity: calc(1 - var(--p, 0) * 0.8);
  transform: translateY(calc(var(--p, 0) * -32px));
}
.home-gate__bar {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;                               /* very top edge, over the header; Chrome's link preview covers the bottom */
  z-index: 50;
  height: 4px;
  background: #e6e6e6;                  /* the empty track */
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}
/* Only shown once the intro has fully appeared (home.js adds is-ready). */
.home-gate__bar.is-ready.is-on { opacity: 1; }
.home-gate__bar span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--color-signal);
  transform-origin: left center;
  transform: scaleX(var(--p, 0));
}
/* The page can't scroll until the intro has finished appearing. */
html.is-gated, html.is-gated body { overflow: hidden; }

/* ---------- The four projects ---------- */
/* All four cards fit one screen (sized for a 14" MacBook Pro and up):
   the card width is worked out from the screen height. */
.home-projects {
  --row: calc((100vh - 300px) / 2);              /* height of one cover */
  --w: min(100%, calc(var(--row) * 2.1 * 2 + 20px));
  min-height: 100vh;
  padding: 48px 79px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.home-projects__title {
  display: block;
  width: var(--w);
  margin: 0 auto 20px;
  font-weight: 400;   /* same weight as the header links */
}
.home-projects__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px 20px;
  width: var(--w);
  margin: 0 auto;
}
.project-card {
  display: flex;
  flex-direction: column;
  color: var(--color-text);
  text-decoration: none;
}
.project-card__media {
  aspect-ratio: 2.1 / 1;
  overflow: hidden;
  border-radius: 20px;
  /* very light shadow so white covers still read as cards */
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 18px rgba(0,0,0,.06);
}
.project-card__media img,
.project-card__media video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .6s cubic-bezier(.2, .8, .2, 1);
}
.project-card__meta {
  display: block;
  margin: 14px 0 4px;
  color: #6b6b6b;
}
.project-card__name {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.project-card:focus-visible { outline: 2px solid var(--color-signal); outline-offset: 6px; border-radius: 20px; }

/* Same hover as the case studies: the hovered card stays, the others
   fade back. With nothing hovered, all four show at full strength. */
@media (hover: hover) and (pointer: fine) {
  .project-card { transition: opacity .3s ease; }
  .home-projects__grid:has(.project-card:hover) .project-card:not(:hover) { opacity: .3; }
  .project-card:hover .project-card__media img,
  .project-card:hover .project-card__media video { transform: scale(1.02); }
}

@media (max-width: 768px) {
  .home-gate { height: auto; }
  .home-gate .home-intro { position: static; }
  .home-gate .home-intro__text { opacity: 1; transform: none; }
  .home-gate__bar { display: none; }
  .home-projects { padding: 56px 24px 80px; --w: 100%; min-height: 0; }
  .home-projects__grid { grid-template-columns: 1fr; gap: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .project-card__media img, .project-card__media video { transition: none; }
}
