/* Work page: builds on ../home/home.css (nav, hero illustrations, buttons, footer, cursor). */

/* ---------- Headline + filters ---------- */
.works-head {
  --head-top: calc(var(--space-8xl) + var(--space-5xl)); /* headline stays where it was */
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-5xl);
  padding-top: var(--head-top);
}

/* The headline reacts to the filters (work.js sets data-filter): the matching word gets
   a hand-drawn underline and the figure redraws in that discipline's pose. */
/* The figure sits to the right without adding height, so the filters stay 48px under the
   headline. It's centred on the headline + filters block as a whole. */
.works-hero {
  --pose-h: 244px; /* every pose is drawn 244px tall */
  --pose-w: 256px; /* fits the widest pose (service) at that height */
  width: 100%;
}

.works-hero__title {
  max-width: min(720px, 100% - var(--pose-w) - var(--space-5xl)); /* two lines: breaks after "physical," */
  margin: 0;
  font-family: var(--font-family-display);
  font-weight: 600;
  font-size: var(--type-h2-size);
  line-height: var(--type-h2-line-height);
  letter-spacing: -0.02em;
}

.works-hero__word {
  position: relative;
  white-space: nowrap;
  transition: color 0.3s ease;
}

.works-hero__mark {
  position: absolute;
  left: -2%;
  bottom: -0.12em;
  width: 104%;
  height: 0.32em;
  overflow: visible;
  pointer-events: none;
}

.works-hero__mark path {
  fill: none;
  stroke: var(--color-text-brand);
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-dasharray: 1 2;
  stroke-dashoffset: 1.1; /* fully hidden, round cap included */
  opacity: 0;
  transition: stroke-dashoffset 0.25s ease-in, opacity 0s linear 0.25s;
}

/* Draw in left to right; on "All Work" all three draw one after another. */
.works-hero[data-filter="all"] .works-hero__mark path,
.works-hero[data-filter="uiux"] [data-for="uiux"] .works-hero__mark path,
.works-hero[data-filter="service"] [data-for="service"] .works-hero__mark path,
.works-hero[data-filter="industrial"] [data-for="industrial"] .works-hero__mark path {
  stroke-dashoffset: 0;
  opacity: 1;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.65, 0, 0.35, 1) 0.15s, opacity 0s;
}

.works-hero[data-filter="all"] [data-for="industrial"] .works-hero__mark path { transition-delay: 0.35s; }
.works-hero[data-filter="all"] [data-for="service"] .works-hero__mark path { transition-delay: 0.55s; }

.works-hero__pose {
  position: absolute;
  top: calc((100% + var(--head-top) - var(--pose-h)) / 2); /* middle of the content below the top padding */
  right: var(--page-margin);
  width: var(--pose-w);
  height: var(--pose-h);
  animation: pose-float 4s ease-in-out infinite;
}

/* Each pose sits on top of the last; the new one is revealed top to bottom, as if drawn. */
.works-hero__pose img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 100%; /* poses share a baseline */
  opacity: 0;
  clip-path: inset(0 0 100% 0);
  transition: opacity 0.25s ease, clip-path 0s linear 0.25s;
}

.works-hero__pose img.is-shown {
  opacity: 1;
  clip-path: inset(0 0 -10% 0);
  transition: clip-path 0.8s cubic-bezier(0.65, 0, 0.35, 1) 0.1s, opacity 0s;
}

@keyframes pose-float {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  50% { translate: 0 -6px; rotate: 1.5deg; }
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xl);
}

.filter {
  padding: var(--space-sm) var(--space-lg);
  border: var(--border-width-thin) solid var(--color-border-inverse);
  border-radius: var(--radius-full);
  background: none;
  color: var(--color-text-primary);
  font: inherit;
  font-size: var(--type-body-md-size);
  line-height: var(--type-body-md-line-height);
  white-space: nowrap;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.filter:is(:hover, :focus-visible),
.filter.is-active {
  border-color: var(--color-border-brand);
  color: var(--color-text-brand);
}

/* ---------- Project grid ---------- */
.works {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-8xl) 28px;
  margin-top: var(--space-8xl); /* 96px below the filters */
}

.work-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--color-bg-secondary);
  container-type: inline-size;
  transition: opacity 0.3s ease, translate 0.3s ease;
}

.work-card.is-hidden {
  display: none;
}

.work-card.is-entering {
  opacity: 0;
  translate: 0 12px;
}

.work-card__cover {
  position: relative;
  overflow: hidden;
  aspect-ratio: 658 / 437;
  /* Clip to the card's top corners so a zooming video can never show its square
     (black-cornered) frame, which overflow clipping alone doesn't always catch. */
  clip-path: inset(0 round var(--radius-md) var(--radius-md) 0 0);
  isolation: isolate;
}

/* Reels sit exactly as in the Works frame (height and top as % of the 437 cover).
   A 3% zoom pushes the black rounded corners baked into the video files out of view,
   since the cover's bottom corners are square. */
.work-card__cover video {
  position: absolute;
  left: 0;
  top: var(--vt, 0%);
  width: 100%;
  height: var(--vh, 100%);
  object-fit: cover;
  scale: 1.03;
}

/* Photos are placed exactly as cropped in Figma (width / left / top as % of the cover). */
.work-card__cover img {
  position: absolute;
  left: var(--il);
  top: var(--it);
  width: var(--iw);
  max-width: none;
  height: auto;
}

.work-card__cover > * {
  transition: scale 0.6s var(--ease-morph);
}

/* CNN: the reel is scaled to 92.2% (605 × 439) in the Works frame, 26px in from the left.
   Its soft pink background continues behind it, and the video's edges fade into that
   so its baked-in corners never show. */
.work-card__cover--cnn {
  background: linear-gradient(rgb(254, 227, 229), rgb(252, 222, 224) 50%, rgb(249, 217, 219));
}

.work-card__cover--cnn video {
  left: 3.95%;
  width: 91.95%;
  scale: 1;
  -webkit-mask-image:
    linear-gradient(to right, transparent, #000 2%, #000 98%, transparent),
    linear-gradient(to bottom, transparent, #000 2.5%, #000 97.5%, transparent);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to right, transparent, #000 2%, #000 98%, transparent),
    linear-gradient(to bottom, transparent, #000 2.5%, #000 97.5%, transparent);
  mask-composite: intersect;
}

@media (hover: hover) {
  .work-card:hover .work-card__cover > * {
    scale: 1.03;
  }

  .work-card:hover .work-card__cover video {
    scale: 1.06;
  }

  .work-card:hover .work-card__cover--cnn video {
    scale: 1.03;
  }
}

.work-card__info {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 50px;
  min-height: 114px;
  padding: var(--space-lg);
}

.work-card__meta {
  flex: none;
  width: 210px;
}

.work-card__meta p,
.work-card__desc {
  margin: 0;
  font-size: var(--type-body-sm-size);
  line-height: var(--type-body-sm-line-height);
}

.work-card__title {
  margin: 0;
  font-size: var(--type-body-lg-size);
  font-weight: 400;
  line-height: var(--type-body-lg-line-height);
}

.work-card__desc {
  flex: 1;
  color: var(--color-text-secondary);
}

/* Narrow cards: description drops under the title block. */
@container (max-width: 559px) {
  .work-card__info {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .work-card__meta {
    width: auto;
  }
}

@media (max-width: 899px) {
  .works {
    grid-template-columns: 1fr;
    gap: var(--space-5xl);
  }
}

@media (max-width: 767px) {
  .works-head {
    --head-top: calc(var(--layout-nav-height) + var(--space-5xl));
  }

  .works-hero__title {
    max-width: none;
  }

  /* Phones: no figure; the underlines still react to the filters. */
  .works-hero__pose {
    display: none;
  }

  .works {
    margin-top: var(--layout-block-gap);
    gap: var(--space-3xl);
  }

  .filters {
    gap: var(--space-sm);
  }
}

@media (prefers-reduced-motion: reduce) {
  .works-hero__pose {
    animation: none;
  }

  .works-hero__pose img,
  .works-hero__mark path,
  .work-card,
  .work-card__cover > * {
    transition: none;
  }
}
