/* css/sections/01-opening.css · H01 · the machine comes out of the dark; the words are there from the first paint */
@layer sections {
  .s-opening {
    position: relative;
    display: flex;
    flex-direction: column;
    min-block-size: calc(100svh - var(--peek));
    background: var(--color-stage);
  }

  /* ---------- media (phone and portrait: a block under the words) ---------- */
  .hero__media {
    position: relative;
    flex: 1 0 auto;
    min-block-size: 50svh;
    isolation: isolate;
    overflow: clip;
    -webkit-mask-image: linear-gradient(to bottom, transparent, var(--mask-ink) 14%, var(--mask-ink) 90%, transparent);
            mask-image: linear-gradient(to bottom, transparent, var(--mask-ink) 14%, var(--mask-ink) 90%, transparent);
  }
  .hero__media picture { position: absolute; inset: 0; }
  .hero__img {
    inline-size: 100%;
    block-size: 100%;
    object-fit: cover;
    object-position: 50% 62%;
    transform-origin: 50% 55%;
  }
  .hero__band,
  .hero__shade,
  .hero__veil { position: absolute; pointer-events: none; }
  .hero__shade,
  .hero__veil { inset: 0; background: var(--color-stage); opacity: 0; }
  /* the beam: overlay keeps near-black black, so light only lands on chrome, glass, wood and steam */
  .hero__band {
    display: none;
    inset-block: -10%;
    inset-inline-start: 0;
    inline-size: 28%;
    background: linear-gradient(100deg, transparent 0%, color-mix(in oklch, var(--color-light) 55%, transparent) 50%, transparent 100%);
    mix-blend-mode: overlay;
  }
  .s-opening.is-motion .hero__band { display: block; }

  /* ---------- words ---------- */
  .hero__copy {
    order: -1;
    position: relative;
    z-index: var(--z-raised);
    padding-block: calc(var(--header-h) + var(--space-xl)) var(--space-lg);
  }
  .hero__title { max-inline-size: 12ch; }
  .hero__lede { margin-block: var(--space-lg) var(--space-xl); }

  @media (max-width: 22.49em) {
    .hero__cta { inline-size: 100%; justify-content: center; }
  }

  /* portrait tablets: a taller window, a higher crop and a short top feather, so the red ball sits clear of the fade and the drip tray stays in frame */
  @media (min-width: 40em) and (max-aspect-ratio: 4/3) {
    .hero__media {
      min-block-size: 60svh;
      -webkit-mask-image: linear-gradient(to bottom, transparent, var(--mask-ink) 7%, var(--mask-ink) 90%, transparent);
              mask-image: linear-gradient(to bottom, transparent, var(--mask-ink) 7%, var(--mask-ink) 90%, transparent);
    }
    .hero__img { object-position: 50% 44%; }
  }

  /* ---------- landscape: one frame, the machine in the right 45 %, words in the dark at the left ---------- */
  @media (min-width: 48em) and (min-aspect-ratio: 4/3) {
    .s-opening {
      --hero-h: clamp(560px, calc(100svh - var(--peek)), 1100px);
      display: block;
      block-size: var(--hero-h);
    }
    .hero__media {
      position: absolute;
      inset-block: 0;
      inset-inline-end: 0;
      /* never wider than the 16:9 frame at this height: on ultrawide screens the photo keeps its full height (the top of the
         machine, the red ball and the beam stay in frame) and the left side is stage, not a stretched, cropped render */
      inline-size: min(100%, calc(var(--hero-h) * 1.7778));
      min-block-size: 0;
      /* the floor sinks into the dark, so the next scene starts without a seam; the left edge melts into the stage */
      -webkit-mask-image: linear-gradient(to bottom, var(--mask-ink) 88%, transparent), linear-gradient(to right, transparent, var(--mask-ink) 18%);
      -webkit-mask-composite: source-in;
              mask-image: linear-gradient(to bottom, var(--mask-ink) 88%, transparent), linear-gradient(to right, transparent, var(--mask-ink) 18%);
              mask-composite: intersect;
    }
    .hero__img { object-position: 100% 50%; transform-origin: 77% 55%; }
    .hero__copy {
      block-size: 100%;
      display: grid;
      grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
      column-gap: var(--gap-columns);
      align-content: end;
      /* centre of the text block sits 0–60 px under the centre of the machine (y ≈ 55 %), its foot ≤ 160 px from the bottom */
      padding-block: calc(var(--header-h) + var(--space-lg)) max(var(--space-3xl), 17svh);
    }
    .hero__text { grid-column: 1 / span 5; }
  }
  /* ultrawide: the source of the beam sits under the navigation, so the top edge of the photo is feathered a little */
  @media (min-width: 48em) and (min-aspect-ratio: 2/1) {
    .hero__media {
      -webkit-mask-image: linear-gradient(to bottom, color-mix(in srgb, var(--mask-ink) 40%, transparent), var(--mask-ink) 14%, var(--mask-ink) 88%, transparent), linear-gradient(to right, transparent, var(--mask-ink) 18%);
              mask-image: linear-gradient(to bottom, color-mix(in srgb, var(--mask-ink) 40%, transparent), var(--mask-ink) 14%, var(--mask-ink) 88%, transparent), linear-gradient(to right, transparent, var(--mask-ink) 18%);
    }
  }
  /* landscape tablets and small laptops: the lede stops before the red steam knob at the left of the machine */
  @media (min-width: 48em) and (max-width: 79.99em) and (min-aspect-ratio: 4/3) {
    .hero__lede { max-inline-size: 26ch; }
  }
  @media (min-width: 64em) and (min-aspect-ratio: 4/3) {
    .hero__text { grid-column: 1 / span 6; }
  }
  @media (min-width: 90em) and (min-aspect-ratio: 4/3) {
    .hero__text { grid-column: 1 / span 5; }
  }

  /* ---------- load: only the picture rises out of the dark (not under .anim: the 3 s failsafe would replay it) ---------- */
  @media (prefers-reduced-motion: no-preference) {
    html.js .hero__veil { animation: hero-veil 1800ms cubic-bezier(.2, .7, .2, 1) both; }
  }
  @keyframes hero-veil {
    from { opacity: .94; }
    to { opacity: 0; }
  }

  @media print {
    .hero__band, .hero__shade, .hero__veil { display: none; }
  }
}
