/* ==========================================================================
   HOME
   Hero — Figma 134:276. Role top-left, the name across the
   middle ("Ahwin" left, "David" right), intro bottom-left; the fixed header and
   Menu stay as they are.
   The work — Figma 10:113, with the switcher (137:326) bent onto a circle.
   ========================================================================== */

.home-hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-40);
  padding-top: max(90px, calc(var(--header-h) + var(--space-24)));   /* Figma: 90 */
  padding-bottom: 90px;
}
/* the Playground's particle morph and its edit panel, centred in the hero behind the name.
   The sphere sits in the middle; the dot that opens the panel sits just right of it and the
   panel opens beside the sphere. (Its canvas overflows the box.) */
.home-hero { position: relative; }
.home-hero__morph {
  --sphere: min(30vw, 26rem);
  position: absolute; left: 50%; top: 50%; translate: -50% -50%;
  width: min(calc(var(--sphere) * 2 + 22rem), 100%); height: var(--sphere);
  z-index: 0;
}
.home-hero__morph #morph-root { position: absolute; inset: 0; min-height: 0; overflow: visible; }
.home-hero__morph #sphere-container { width: var(--sphere); height: var(--sphere); }
.home-hero__morph #panel-trigger { right: auto; left: calc(50% + var(--sphere) / 2 + 16px); }
.home-hero__morph:has(#panel-wrapper.open) { z-index: 2; }   /* the open panel sits over the name */
.home-hero__morph #panel-wrapper { right: auto; left: calc(50% + var(--sphere) / 2 + 40px); transform-origin: left center; }
.home-hero__top, .home-hero__name, .home-hero__intro { position: relative; z-index: 1; pointer-events: none; }
.home-hero__top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-24); }
.home-hero__role {
  margin: 0;
  font-size: var(--text-md);
  line-height: 24px;
  color: var(--color-text-secondary);                   /* Figma: #484848 */
}
.home-hero__role { display: flex; flex-direction: column; width: min(100%, 23.8125rem); }   /* 381 */
/* a word slot is a mask: the words slide up through it like the line reveal (scripts/home.js) */
.word-cycle {
  display: inline-grid;
  vertical-align: bottom;
  padding-bottom: 0.12em;                 /* room for descenders inside the clip */
  margin-bottom: -0.12em;
  overflow: clip;
}
.word-cycle__word { grid-area: 1 / 1; will-change: transform; }

.home-hero__name {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: min(11.67vw, 168px);                             /* Figma: 168 between the lines */
  font-size: min(13.9vw, 200px);                        /* Figma: 180, a touch larger */
  line-height: 1;
  font-weight: var(--weight-regular);
  letter-spacing: -0.02em;
  color: var(--color-text-strong);
}
.home-hero__first,
.home-hero__last { display: block; white-space: nowrap; }
.home-hero__last { align-self: flex-end; }

.home-hero__intro {
  max-width: 23.8125rem;                                /* 381 */
  font-size: var(--text-md);
  line-height: 24px;
  color: var(--color-text-secondary);
}

/* ---------- The work ---------- */
/* The dial's ticks: darker on light paper so they read clearly; Figma's #BABABA / #767676 on dark */
:root { --work-tick: var(--grey-300); --work-tick-active: var(--grey-450); }
:root[data-theme="dark"] { --work-tick: var(--grey-150); --work-tick-active: var(--grey-300); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --work-tick: var(--grey-150); --work-tick-active: var(--grey-300); }
}
.home-work { position: relative; height: 640vh; }       /* the scroll that drives the scene */
.home-work__stage {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  overflow: hidden;
}
.home-work__title {
  position: absolute; left: 0; right: 0; top: 50%;
  translate: 0 -50%;
  margin: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: min(12.2vw, 175.715px);                    /* Figma: 175.7 */
  line-height: 1;
  font-weight: var(--weight-regular);
  letter-spacing: -0.02em;
  color: var(--color-text-strong);
  white-space: nowrap;
  pointer-events: none;
}
/* each word moves through a mask, like the site's line reveal: the big title slides up and out
   as the dial sets off (.is-small); the small one slides in once the dial is in place (.is-projects) */
.home-work__mask { display: inline-block; overflow: clip; padding-bottom: 0.12em; margin-bottom: -0.12em; }
.home-work__word { display: inline-block; transition: transform 800ms var(--ease-out); }
.home-work__mask + .home-work__slot + .home-work__mask .home-work__word,
.home-work__small .home-work__mask:last-child .home-work__word { transition-delay: 70ms; }
.home-work.is-small .home-work__title .home-work__word { transform: translateY(-110%); }
.home-work__small .home-work__word { transform: translateY(110%); }
.home-work.is-projects .home-work__small .home-work__word { transform: none; }   /* only once the dial is in place */
/* the room the window opens between the words */
.home-work__slot {
  display: block; flex: none;
  width: var(--slot-w, 0px); height: 0.78em;
  margin-inline: max(0.13em, var(--slot-gap, 0px));   /* closed: a word space between "The" and "work" */
}
/* where the words end up — Figma 137:324: 20px, left of the card */
.home-work__small {
  position: absolute; left: calc(16.67% + 23px); top: 50%; translate: 0 -50%;
  margin: 0; font-size: 20px; line-height: 1; letter-spacing: 0;
  white-space: nowrap; color: var(--color-text-strong);
}

/* the project card (Figma 137:403): wipes up into place once the dial has arrived */
.home-work__window {
  position: absolute; left: 0; top: 0;
  width: var(--w, 0px); height: var(--h, 0px);
  translate: var(--x, 0px) var(--y, 0px);
  border-radius: 16px; overflow: hidden;
  background: var(--color-surface-muted);
  clip-path: inset(100% 0 0 0 round 16px);
  transition: clip-path 900ms cubic-bezier(0.77, 0, 0.175, 1);
}
.home-work.is-projects .home-work__window { clip-path: inset(0 0 0 0 round 16px); }
.home-work__layer { position: absolute; inset: 0; }
.home-work__layer > * { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }

/* the project's name, its tags and year — Figma 137:412, right of the card */
.home-work__info {
  position: absolute; left: calc(66.67% + 61px); top: 50%;
  width: min(316px, calc(33.33% - 61px - var(--grid-margin)));
  translate: 0 calc(-50% + 16px);
  opacity: 0;
  transition: opacity 500ms var(--ease-out), translate 700ms var(--ease-out);
  display: flex; flex-direction: column; gap: var(--space-8);
  pointer-events: none;
}
.home-work.is-projects .home-work__info { opacity: 1; translate: 0 -50%; transition-delay: 250ms; }
.home-work__name { margin: 0; font-size: var(--text-md); line-height: 24px; color: var(--color-text); }
.home-work__summary { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-8); }
.home-work__year { font-size: 14px; line-height: 20px; color: var(--color-text-muted); }

/* the dial — Figma 137:326 bent onto a circle: a short arc of ticks under the card */
/* placed each frame: from small, in the gap between the words, down to full size under the card */
.home-work__dial {
  position: absolute; left: 0; top: 0;
  width: min(788px, calc(100% - var(--grid-margin) * 2)); height: 120px;
  translate: var(--dial-x, 0px) var(--dial-y, 0px);
  scale: var(--dial-s, 0.5);
  transform-origin: 50% 0;
  /* turned away in 3D on its way (swung round and tipped back a little), flat in 2D when it lands */
  transform: perspective(700px) rotateY(var(--dial-tilt, 0deg)) rotateX(calc(var(--dial-tilt, 0deg) * 0.3));
  opacity: var(--dial-opacity, 0);
  pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 34%, #000 66%, transparent 100%);
          mask-image: linear-gradient(90deg, transparent 0, #000 34%, #000 66%, transparent 100%);   /* Figma: the fades */
}
.home-work__wheel {
  position: absolute; left: 50%; top: calc(47px + var(--r));   /* the circle's centre, below; the top tick's base 47px down */
  width: 0; height: 0;
  rotate: var(--turn, 0deg);
}
.home-work__tick {
  position: absolute; left: -0.5px; bottom: var(--r);
  width: 1px; height: 20px;
  background: var(--work-tick);
  transform-origin: 50% calc(100% + var(--r));
  rotate: var(--a);
  transition: height 300ms var(--ease-out), background-color 300ms var(--ease-out);
}
.home-work__tick.is-active { height: 43px; background: var(--work-tick-active); }   /* Figma: 43 tall */
.home-work__tick--project { pointer-events: auto; cursor: pointer; border: 0; padding: 0; }
.home-work__tick--project::after { content: ""; position: absolute; inset: -12px -10px; }   /* an easier target */

/* narrow screens: the small title sits above the card; the project's name and tags sit at
   the bottom, left of the Menu button */
@media (max-width: 56rem) {
  .home-work__small { left: 50%; translate: -50% 0; top: var(--small-top, 12%); }
  .home-work__small .home-work__mask { vertical-align: top; }
  .home-work__info {
    left: var(--grid-margin); right: calc(var(--grid-margin) + 7.5rem);   /* clear of the Menu button */
    top: auto; bottom: calc(var(--space-24) + env(safe-area-inset-bottom, 0px));
    width: auto; translate: 0 16px;
  }
  .home-work.is-projects .home-work__info { translate: 0 0; }
}

/* phones: the particle sphere stays, its edit panel (and the dot that opens it) doesn't */
@media (max-width: 40rem) {
  .home-hero__morph #panel-trigger,
  .home-hero__morph #panel-wrapper { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .home-work__tick { transition: none; }
}
