/* ==============================================================================
   HERO BLOCK

   A project page opens the way the home page's showcase does (doc/07):
   the photo edge to edge under the header, and the project's name and
   use in a paper caption, the drawing's title block, at its lower left.
   Coming from the showcase, the visitor lands on the same photo with
   the same caption. On a phone the caption would hide half the picture,
   so it sits under the photo instead.
   ============================================================================== */

/* The hero spans the page's full track, like the full-screen slideshow
   (page.css), and cancels the page's top padding so no band of page
   background separates it from the header. */
.page > .block-hero {
  grid-column: full;
  margin-block-start: calc(var(--spacing-xl) * -1);
}

.block-hero {
  /* Same inset as the showcase's caption: the content column's edge on
     a wide screen, the page gutter on a narrow one. */
  --hero-inset: max(var(--page-gutter, var(--spacing-lg)), (100% - var(--content-max-width)) / 2);

  display: grid;
}

.hero__media {
  background: var(--paper-secondary-bg);
}

/* svh, not dvh, for the same reason as the showcase: the address bar
   collapsing must not resize the photo under the visitor's finger. vh
   is the fallback for a browser without the small-viewport unit. */
.hero__media img {
  display: block;
  width: 100%;
  height: clamp(15rem, 58vh, 42rem);
  height: clamp(15rem, 58svh, 42rem);
  object-fit: cover;
}

.hero__copy {
  padding: var(--spacing-lg) var(--hero-inset) 0;
}

.hero__copy h1 {
  margin: 0;
  font-size: var(--font-size-display);
  line-height: 0.95;
  text-wrap: balance;
}

.hero__subtitle {
  margin: var(--spacing-sm) 0 0;
  color: var(--text-secondary);
  font-size: var(--font-size-lg);
}

.hero__cta {
  margin-top: var(--spacing-md);
}

/* From a tablet up the caption is laid over the photo's lower left, in
   the same grid cell, rather than positioned absolutely. */
@media (min-width: 48em) {
  .block-hero {
    grid-template-areas: "hero";
  }

  .hero__media,
  .hero__copy {
    grid-area: hero;
  }

  .hero__media img {
    height: clamp(24rem, 72vh, 46rem);
    height: clamp(24rem, 72svh, 46rem);
  }

  .hero__copy {
    align-self: end;
    justify-self: start;
    width: min(32rem, 100% - 2 * var(--hero-inset));
    /* The side inset lines the caption up with the content column; the
       one below is capped, or on a wide screen the caption would float
       halfway up the photo instead of resting near its foot. */
    margin: 0 0 min(var(--hero-inset), var(--space-7)) var(--hero-inset);
    padding: var(--spacing-lg) var(--spacing-xl) var(--spacing-lg) var(--spacing-lg);
    background: var(--paper-bg);
  }
}

/* page.css pads the page less on a small phone; the hero follows it. */
@media (max-width: 480px) {
  .page > .block-hero {
    margin-block-start: calc(var(--spacing-lg) * -1);
  }
}
