/* css/sections/08-machine.css · G6 · D08: macro reel under a veil
 * the section sits on the stage black (the renders' own ground), graded in from and back out to paper,
 * so no photo shows a box; photos melt in with a wide feathered mask, captions share a baseline per row;
 * phones: a horizontal strip that peeks the next photo; desktop: small/large, large/small on 12 columns */
@layer sections {
  .s-machine {
    background:
      linear-gradient(to bottom, var(--color-paper), var(--color-stage) var(--gap-b) calc(100% - var(--space-3xl)), var(--color-paper));
    padding-block: var(--gap-b) var(--space-3xl);
  }

  .s-machine .machine__head {
    margin-block-end: var(--space-xl);
  }
  .s-machine .machine__title { max-width: 14ch; }

  .s-machine .machine__item { min-width: 0; }

  /* the frame melts into the stage: a wide feather and no ring, so no edge of the render reads */
  .s-machine .photo__frame {
    aspect-ratio: 5 / 7;
    background: var(--color-stage);
    outline: 0;
    -webkit-mask-image:
      linear-gradient(to bottom, transparent, var(--mask-ink) 20% 80%, transparent),
      linear-gradient(to right, transparent, var(--mask-ink) 18% 82%, transparent);
    -webkit-mask-composite: source-in;
    mask-image:
      linear-gradient(to bottom, transparent, var(--mask-ink) 20% 80%, transparent),
      linear-gradient(to right, transparent, var(--mask-ink) 18% 82%, transparent);
    mask-composite: intersect;
  }
  .s-machine .photo__frame picture { display: block; }
  .s-machine .photo__frame picture,
  .s-machine .photo__frame img {
    width: 100%;
    height: 100%;
  }
  .s-machine .photo__frame img { object-fit: cover; }

  /* crops live on <picture> (the veil animates the img transform; `scale` composes with it) */
  /* the red ball: a 5:7 detail of the front render, the ball high in the frame (clear of the feather),
   * the group gauge and group under it, straight above the caption */
  .s-machine .machine__item--ball picture {
    scale: 1.5;
    transform-origin: 66% 17%;
  }
  /* the wands: crop below the panel ring, graded down to the black point of the other three */
  .s-machine .machine__item--wands picture {
    scale: 1.445;
    transform-origin: 65% 100%;
    filter: brightness(0.84) contrast(1.08);
  }

  .s-machine .machine__cap {
    margin-block-start: var(--space-sm);
    display: grid;
    gap: var(--space-2xs);
  }
  .s-machine .machine__name {
    font: 500 var(--text-title)/var(--leading-title) var(--font-body);
    color: var(--color-ink);
  }
  .s-machine .machine__text {
    font-size: var(--text-body);
    line-height: var(--leading-body);
    color: var(--color-ink-2);
    max-width: 36ch;
  }

  /* phones: one strip, scroll-snapped, the next photo peeking in from the edge */
  @media (max-width: 39.99em) {
    .s-machine .machine__grid {
      display: grid;
      grid-auto-flow: column;
      grid-auto-columns: 76%;
      column-gap: var(--space-md);
      align-items: start;
      margin-inline: calc(-1 * var(--gutter));
      padding-inline: var(--gutter);
      padding-block-end: var(--space-xs);
      scroll-padding-inline: var(--gutter);
      overflow-x: auto;
      overscroll-behavior-x: contain;
      scroll-snap-type: x mandatory;
      scrollbar-width: none;
    }
    .s-machine .machine__grid::-webkit-scrollbar { display: none; }
    .s-machine .machine__item { scroll-snap-align: start; }
  }

  /* 40em to 63.99em: two columns, the right one lowered */
  @media (min-width: 40em) {
    .s-machine .machine__head { margin-block-end: var(--space-2xl); }
    .s-machine .machine__grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      column-gap: var(--gap-columns);
      row-gap: var(--space-xl);
      align-items: start;
    }
    .s-machine .machine__item--ball,
    .s-machine .machine__item--wands { margin-block-start: var(--space-3xl); }
    .s-machine .machine__item--handle[hidden] + .machine__item--wands { margin-block-start: 0; }
  }

  /* 64em and up: row one small dials (under the head) beside the large ball, row two the large handle
   * beside the small wands; every row is bottom-aligned, so the two captions of a row share one baseline */
  @media (min-width: 64em) {
    .s-machine .machine__inner {
      display: grid;
      grid-template-columns: repeat(12, minmax(0, 1fr));
      grid-template-rows: auto auto auto;
      column-gap: var(--gap-columns);
      row-gap: var(--space-3xl);
      align-items: end;
    }
    .s-machine .machine__grid { display: contents; }
    .s-machine .machine__head { grid-column: 1 / 6; grid-row: 1; align-self: start; margin: 0; }
    .s-machine .machine__item { margin: 0; }
    .s-machine .machine__item--ball,
    .s-machine .machine__item--wands { margin-block-start: 0; }
    .s-machine .machine__item--dials { grid-column: 1 / 5; grid-row: 2; }
    .s-machine .machine__item--ball { grid-column: 7 / 13; grid-row: 1 / 3; }
    .s-machine .machine__item--handle { grid-column: 1 / 7; grid-row: 3; }
    .s-machine .machine__item--wands { grid-column: 9 / 13; grid-row: 3; }
    /* while the handle macro is missing, the wands take its place on the left */
    .s-machine .machine__item--handle[hidden] + .machine__item--wands { grid-column: 1 / 7; }
  }
}
