/*
 * Reusable gallery hero -- a clickable cover image on top of route-execution
 * cards (and anywhere else a "one tap opens the slideshow" affordance fits).
 *
 * Markup: see registry/templates/registry/_gallery_hero.html
 *
 *   <a class="gallery-hero">...</a>
 *     <img>                             -- cover-fit thumbnail
 *     <span class="gallery-hero__stamp"> -- shown only on asset-sourced heroes
 *     <span class="gallery-hero__count"> -- shown only with 2+ images
 *
 * Empty state posts to an upload URL via the `gallery-upload` controller.
 */

@layer components {
  .gallery-hero {
    --gallery-hero-height: 14ch;
    --gallery-hero-radius: var(--radius, 0.6ch);

    aspect-ratio: auto;
    background-color: oklch(var(--lch-ink-lighter) / 40%);
    block-size: var(--gallery-hero-height);
    border-radius: var(--gallery-hero-radius);
    display: block;
    inline-size: 100%;
    isolation: isolate;
    overflow: hidden;
    position: relative;
    text-decoration: none;
    transition: transform 0.15s ease-out, box-shadow 0.15s ease-out;

    & > img {
      block-size: 100%;
      display: block;
      inline-size: 100%;
      object-fit: cover;
      object-position: center;
    }

    &:hover,
    &:focus-visible {
      box-shadow: 0 1px 3px oklch(0 0 0 / 12%), 0 6px 14px oklch(0 0 0 / 14%);
      transform: translateY(-1px);
    }

    @media (min-width: 100ch) {
      --gallery-hero-height: 18ch;
    }
  }

  /* Asset-photo stamp -- corner "sticker" in the style of card__closed,
     communicating "this image belongs to the asset, not this specific point." */
  .gallery-hero__stamp {
    background-color: oklch(var(--lch-white) / 88%);
    border-radius: 0.2em;
    border: 2px solid oklch(var(--lch-ink-medium) / 55%);
    color: oklch(var(--lch-ink-medium) / 85%);
    font-size: var(--text-x-small, 0.7em);
    font-weight: 800;
    inset: 0.75ch auto auto 0.75ch;
    letter-spacing: 0.04em;
    padding: 0.25ch 0.8ch;
    position: absolute;
    rotate: -4deg;
    text-transform: uppercase;
    transform-origin: top left;
    z-index: 1;
  }

  /* Count badge -- pill in the bottom-right with photo icon + N. */
  .gallery-hero__count {
    align-items: center;
    background-color: oklch(0 0 0 / 62%);
    border-radius: 999px;
    color: white;
    display: inline-flex;
    font-size: var(--text-x-small, 0.75em);
    font-weight: 700;
    gap: 0.35ch;
    inset: auto 0.75ch 0.75ch auto;
    line-height: 1;
    padding: 0.45ch 0.9ch;
    position: absolute;
    z-index: 1;

    & .icon {
      block-size: 1.1em;
      inline-size: 1.1em;
    }
  }

  /* Empty state -- dashed drop-zone to attach the first reference photo. */
  .gallery-hero--empty {
    align-items: center;
    background-color: transparent;
    border: 1px dashed oklch(var(--lch-ink-lighter));
    color: var(--color-ink-medium);
    display: flex;
    justify-content: center;

    &:hover,
    &:focus-within {
      background-color: oklch(var(--lch-ink-lightest, var(--lch-ink-lighter)) / 30%);
      box-shadow: none;
      transform: none;
    }

    .gallery-hero__upload-label {
      align-items: center;
      cursor: pointer;
      display: inline-flex;
      gap: 0.6ch;

      & .icon {
        block-size: 1.3em;
        inline-size: 1.3em;
      }
    }
  }
}
